-
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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
attributeBindings: ['index:data-item-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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
'title': 'Hello World', | |
actions: { | |
updateTitle () { | |
this.set('title': 'This is magic') | |
} | |
} | |
}); |
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
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent | |
function simulateClick() { | |
var evt = new MouseEvent("click", { | |
bubbles: true, | |
cancelable: true, | |
view: window | |
}); | |
var cb = document.getElementById("checkbox"); //element to click on | |
var canceled = !cb.dispatchEvent(evt); | |
if(canceled) { |
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 |
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
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
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
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!!')) |