Starting code:
const getRanges = compose(
chain(([x, y]) => range(x, y + 1)),
map(compose(map(Number), split('..'))),
match(rangeRegex)
)
const getNumbers = compose(
chain(identity),
map(compose(map(Number), split(','))),| const regex = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u | |
| const result = regex.exec('2018-07-05') | |
| console.log(result[0]) // > '2018-07-05' | |
| console.log(result[1]) // > '2018' | |
| console.log(result[2]) // > '07' | |
| console.log(result[3]) // > '05' | |
| console.log(result.groups.year) // > '2018' | |
| console.log(result.groups.month) // > '07' |
| fetch('http://example/endpoint') | |
| .then(data => data.json()) // todo bien, todo correcto... | |
| .catch(err => console.error(err)) // oh oh... | |
| .finally(() => console.log('...y yo que me alegro!')) // <-- lo nuevo 😎 |
| for await (const line of readLines(filePath)) { | |
| console.log(line) | |
| } |
| const foo = { a: 1, b: 2, c: 3 } | |
| const { x, ...y } = foo // rest properties | |
| console.log(x) // 1 | |
| console.log(y) // { b: 2, c: 3 } | |
| const bar = { d: 4, e: 5 } | |
| const baz = { ...foo, ...bar } // spread properties | |
| console.log(baz) // { a: 1, b: 2, c: 3, d: 4, e: 5 } |
Starting code:
const getRanges = compose(
chain(([x, y]) => range(x, y + 1)),
map(compose(map(Number), split('..'))),
match(rangeRegex)
)
const getNumbers = compose(
chain(identity),
map(compose(map(Number), split(','))),| function node_sos --description 'Node plz SAVE ME!!!' | |
| rm -rf node_modules package-lock.json; and npm install $argv; | |
| end |
| function clear_local_branches --description 'Removes all the local branches that have already been merged' | |
| command git fetch -p; and git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D | |
| end |
| const copySort = (array, order, key) => | |
| [...array].sort( | |
| (a, b) => order.findIndex(x => x[key] === a[key]) - order.findIndex(x => x[key] === b[key]) | |
| ) | |
| const order = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }] | |
| const unordered = [ | |
| { id: 2, label: 'Two' }, | |
| { id: 3, label: 'Three' }, | |
| { id: 5, label: 'Five' }, | |
| { id: 4, label: 'Four' }, |
| 'use strict' | |
| require('now-env') | |
| const Twit = require('twit') | |
| const Task = require('data.task') | |
| const Maybe = require('data.maybe') | |
| const bot = new Twit({ | |
| consumer_key: process.env.CONSUMER_KEY, | |
| consumer_secret: process.env.CONSUMER_SECRET, | |
| access_token: process.env.ACCESS_TOKEN, |
Closure is when a function "remembers" its lexical scope even when the function is executed outside that lexical scope. (IMO: just a stupid function returning another partially applied function).
Variable and function declarations are put into memory during the compile phase, but stays exactly where you typed it in your coding. There is no physically lifting to the top of the file at all.