This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reduce = fn => (Arr, acc) => Arr.reduce(fn, acc); | |
var add = reduce((acc,x)=>acc+x); | |
add([1,2,3],0);// -> 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Async compose | |
const compose = (…functions) => input => functions.reduceRight((chain, func) => chain.then(func), Promise.resolve(input)); | |
// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise | |
compose(fn3, fn2, fn1)(input).then(result => console.log(`Do with the ${result} as you please`)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = { | |
user: { | |
name: 'anonymous', | |
token: null | |
} | |
} | |
const getUser = state => state.user || {} | |
const isAuthenticated = state => Boolean(getUser(state).token) | |
const isAnonymous = state => !isAuthenticated(user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Browse Ramda documentation in Terminal | |
# Requires jq and a tool such as fzf or peco for interactive filtering | |
LATEST="http://raine.github.io/ramda-json-docs/latest.json" | |
DOCS_URL="http://ramdajs.com/docs/" | |
json=$(curl -s $LATEST) | |
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#%RAML 1.0 | |
title: Booking Service | |
version: v1 | |
baseUri: / | |
types: | |
Booking: | |
properties: | |
city: string | |
cinema: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Rx = require('rx'); | |
const R = require('ramda'); | |
const seq = Rx.Observable.range(1, 10); | |
const isEven = (x) => x % 2 === 0; | |
const add1 = (x) => x + 1; | |
const transducer = R.compose( | |
R.map(add1), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Requires Node 8+ | |
* Works in chrome, simply copy and paste into console. | |
*/ | |
const R = require('ramda'); | |
const compose = | |
(...funcs) => | |
(...args) => | |
funcs.reduceRight(async (a, f) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'mocha'; | |
import {expect} from 'chai'; | |
import 'isomorphic-fetch'; | |
import ApolloClient from 'apollo-client'; | |
import gql from 'graphql-tag'; | |
import {print} from 'graphql-tag/bundledPrinter'; | |
describe('some test', () => { | |
it('should pass', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { graphql } from 'react-apollo'; | |
import { MatchSummary, NoDataSummary } from '@mls-digital/react-components'; | |
import MatchSummaryQuery from './match-summary.graphql'; | |
const mapResultsToProps = ({ data }) => { | |
if (!data.match) | |
return { | |
loading: data.loading, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { get } from 'lodash'; | |
import { withRouter } from 'react-router'; | |
import { graphql } from 'react-apollo'; | |
import { compose, mapProps } from 'recompose'; | |
import jobListQuery from './jobList.graphql'; | |
function SomeBaseComponent() { | |
{/*... some component...*/} | |
} |
NewerOlder