-
Define a
compose(..)
that takes any number of functions (as individual arguments) and composes them right-to-left. -
Define a
pipe(..)
that takes any number of functions (as individual arguments) and composes them left-to-right.
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, { useState, useEffect, useContext, createContext } from "react"; | |
import moment from "moment"; | |
const BeatContext = createContext(); | |
export function BeatProvider({ beatEveryInMs, children }) { | |
const [lastUpdated, update] = useState(moment()); | |
const secondsInNow = moment().seconds(); | |
// this tries to ensure we trigger the update when the minute changes |
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
.reset-select { | |
border: 0; | |
padding: 0; | |
margin: 0; | |
outline: 0; | |
height: 100%; | |
background: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0Ljk1IDEwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzQ0NDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmFycm93czwvdGl0bGU+PHJlY3QgY2xhc3M9ImNscy0xIiB3aWR0aD0iNC45NSIgaGVpZ2h0PSIxMCIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxLjQxIDQuNjcgMi40OCAzLjE4IDMuNTQgNC42NyAxLjQxIDQuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iMy41NCA1LjMzIDIuNDggNi44MiAxLjQxIDUuMzMgMy41NCA1LjMzIi8+PC9zdmc+) | |
no-repeat 98% 50%, #F5F7FA; | |
-moz-appearance: none; | |
-webkit-appearance: none; |
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 UserDetailRepos = ({login}) => { | |
const {data} = useQuery(USER_REPOS, { | |
variables: {login} | |
}) | |
const { | |
user: { | |
reposositories: { nodes } | |
} | |
} = data |
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
ASQ() | |
.promise(delayWithReject(200)) | |
.or(() => console.log('caught')) | |
.val(() => console.log('The sequence deactivates. So this never gets logged.')) | |
ASQ() | |
// a `try` always ends up in a sequence progress | |
// in case the task fails the next step will receive a special messsage | |
// -> {error: "Reason for failure" } | |
.try((done) => done.fail('Doomed!!')) |
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 the_redundants = [1, 2, 2, 3, 4, 6, 6, 7, 7, 7, 8] | |
// this is posiible because indexOf always | |
// returns the left most index | |
const the_pures = the_redundants | |
.filter((n, index, arr) => | |
arr.indexOf(n) === index | |
) |
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 the_redundants = [1, 2, 2, 3, 4, 6, 6, 7, 7, 7, 8] | |
// this is posiible because indexOf always | |
// returns the left most index | |
const the_pures = the_redundants | |
.filter((n, index, arr) => | |
arr.indexOf(n) === index | |
) |
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 ASQ = require("asynquence") | |
const asyncTaskFactory = () => { | |
let invokationCount = 0 | |
const asyncTask = () => { | |
return ASQ().then(done => { | |
setTimeout(() => { | |
invokationCount = invokationCount + 1 | |
done({ |
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, {Fragment} from 'react' | |
import {ThemeProvider} from 'emotion-theming' | |
import {configure, addDecorator} from '@storybook/react' | |
import DarkTheme from '../src/styles/themes/Dark' | |
import LightTheme from '../src/styles/themes/Light' | |
import {withKnobs} from '@storybook/addon-knobs' | |
import {select} from '@storybook/addon-knobs' |
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
function mockAsyncTask () { | |
console.log('Simulating Failure'); | |
return Promise.reject(new Error('failure')); | |
} | |
const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) | |
const retry = (asyncTask, strategy) => { | |
return strategy.reduce(function (promiseChain, interval, index) { | |
return promiseChain |