This file contains hidden or 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 pluralize = (n, [singular, plural]) => (n === 1 ? `${n} ${singular}` : `${n} ${plural}`); | |
| const translateBiggestUnit = ( | |
| n, | |
| [divisor, ...divisors], | |
| [unit, ...units], | |
| candidateDivisor, | |
| divisorsUsed, | |
| unitsUsed, | |
| ) => { |
This file contains hidden or 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 scale = { | |
| c: 0, | |
| 'c#': 1, | |
| d: 2, | |
| 'd#': 3, | |
| e: 4, | |
| f: 5, | |
| 'f#': 6, | |
| g: 7, | |
| 'g#': 8, |
This file contains hidden or 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 scale = { | |
| c: 0, | |
| 'c#': 1, | |
| d: 2, | |
| 'd#': 3, | |
| e: 4, | |
| f: 5, | |
| 'f#': 6, | |
| g: 7, | |
| 'g#': 8, |
This file contains hidden or 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 { | |
| Cluster, | |
| N1qlQuery, | |
| MutationState, | |
| } = require('couchbase'); | |
| const URL = require('url'); | |
| const addQueryParams = params => url => { | |
| const parsed = URL.parse(url); |
This file contains hidden or 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 just = x => Promise.resolve(x); | |
| const nothing = () => Promise.reject(); | |
| chain( | |
| () => just(1), | |
| () => nothing(), | |
| (_, x, y) => just(x / y) | |
| )() | |
| .should.be.rejected; | |
This file contains hidden or 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 chainStep = fn => (argSource, history) => { | |
| if (argSource && (typeof argSource === 'object')) { | |
| const then = argSource.then; | |
| if (typeof then === 'function') { | |
| return Promise.all(history).then( | |
| settledHistory => | |
| then.call(argSource, arg => fn(arg, ...settledHistory)) | |
| ); | |
| } | |
| } |
This file contains hidden or 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
| do | |
| a <- makeId "dress" | |
| b <- makeId "dress" | |
| c <- makeId "dress" | |
| return checkOrdered a b c |
This file contains hidden or 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
| storage.makeId('dress') | |
| .then( | |
| a => | |
| storage.makeId('dress') | |
| .then( | |
| b => | |
| storage.makeId('dress') | |
| .then( | |
| c => { | |
| a.should.be.lessThan(b); |
This file contains hidden or 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
| chain( | |
| () => storage.makeId('dress'), | |
| () => storage.makeId('dress'), | |
| () => storage.makeId('dress'), | |
| (_, a, b, c) => { | |
| a.should.be.lessThan(b); | |
| a.should.be.lessThan(c); | |
| b.should.be.lessThan(c); | |
| } | |
| )() |
This file contains hidden or 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 chain = (...fns) => | |
| initialValue => fns.reduce( | |
| (result, fn) => { | |
| if (result && (typeof result === 'object')) { | |
| const then = result.then; | |
| if (typeof then === 'function') { | |
| return then.call(result, fn); | |
| } | |
| } | |
| return fn(result); |