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
#!/bin/bash -e | |
REPO=$@ | |
publishable() { | |
export REPO | |
/usr/bin/env node <<'SCRIPT' | |
const { execSync } = require("child_process"); | |
const local = require("./package.json"); | |
try { |
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
listen( | |
<Service> | |
<Status code={200} /> | |
<Body>ok</Body> | |
</Service>, | |
4000 | |
); |
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 hyphenize = s => s.replace(/([A-Z])/g, g => `-${g[0].toLowerCase()}`); | |
const classify = (block, element, modifier) => { | |
const parts = [hyphenize(block)]; | |
if (element) { | |
parts.push("__"); | |
parts.push(hyphenize(element)); | |
} |
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
// Same as promise.js but with debug messages. | |
// Just run the code with node promise-debug.js. | |
// By setting DEBUG to true each promise will output in console some debug info | |
// There are 13 samples. In terms of debug output is better to focus in one of them at a time. | |
// You can do that by setting the FOCUS variable (i.e. FOCUS=11) | |
const DEBUG = false; | |
const FOCUS = false; | |
let promiseId = 1; |
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 { curry, __ as _ } from "ramda"; | |
const sum4 = curry((a, b, c, d) => a + b + c + d); | |
// Currying | |
sum4(1, 2, 3, 4); | |
sum4()(1, 2, 3, 4); | |
sum4(1)(2, 3, 4); | |
sum4(1)(2)(3, 4); | |
sum4(1)(2)(3)(4); |
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
expect(sum4(1)(2)(3,4)).toBe(10); | |
expect(sum4(1)(2)(3)(4)).toBe(10); | |
expect(sum4(1,2)(3)(4)).toBe(10); |
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 curry = fn => (...args) => | |
args.length >= fn.length | |
? fn(...args) | |
: curry((...innerArgs) => fn(...args, ...innerArgs)); |
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 expect = x => ({ | |
toBe: y => { | |
if (x !== y) { | |
throw new Error(`expected ${x} to be ${y}`); | |
} | |
} | |
}); | |
const sum4 = curry((a, b, c, d) => a + b + c + d); |
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 curry = fn => { | |
const curryN = (n, fn) => (...args) => | |
args.length >= n | |
? fn(...args) | |
: curryN(n - args.length, (...innerArgs) => fn(...args, ...innerArgs)); | |
return curryN(fn.length, fn); | |
}; |
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 curry = fn => (...args) => | |
args.length >= fn.length | |
? fn(...args) | |
: (...innerArgs) => fn(...args, ...innerArgs); |