- logging & reporting
- update system
Copy/paste is orders of magnitude cheaper than cementing the wrong abstraction.
-- Benedikt Meurer https://twitter.com/bmeurer/status/992723662225723394
const { readFileSync } = require("fs"); | |
const depsCount = {}; | |
function processDeps(deps) { | |
deps !== undefined && | |
Object.keys(deps).forEach(dep => { | |
depsCount[dep] = 1 + (depsCount[dep] || 0); | |
}); | |
} |
function dispatch() { | |
if (this._dispatched) { | |
return | |
} | |
this._dispatched = true | |
const resolve = this._resolve | |
if (resolve !== undefined) { | |
this._resolve = undefined |
import { isFunction } from 'lodash' | |
export default function combinePredicates(...predicates) { | |
predicates = predicates.filter(isFunction) | |
const n = predicates.length | |
return n === 0 | |
? undefined | |
: n === 1 | |
? predicates[0] | |
: function() { |
class MissingPropertyAccess extends TypeError { | |
get name() { | |
return this.constructor.name; | |
} | |
constructor(object, property) { | |
super(`access to missing property ${String(property)}`); | |
this.object = object; | |
this.property = property; | |
} |
export const O_APPEND = 1024 | |
export const O_CREAT = 64 | |
export const O_EXCL = 128 | |
export const O_RDONLY = 0 | |
export const O_RDWR = 2 | |
export const O_SYNC = 1052672 | |
export const O_TRUNC = 512 | |
export const O_WRONLY = 1 | |
// https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea |
// create a bound function which receive itself injected as first arg | |
function rbind(fn, thisArg, ...args) { | |
function bound() { | |
return fn.apply( | |
thisArg === undefined ? this : thisArg, | |
args.concat(arguments) | |
); | |
} | |
args.unshift(bound); | |
return bound; |
#!/usr/bin/env node | |
const hrp = require('http-request-plus').default | |
const JSON5 = require('json5') | |
const required = param => { | |
throw new Error(`missing required param ${param}`) | |
} | |
async function main (args) { |
export default (stream, n) => new Promise((resolve, reject) => { | |
const chunks = [] | |
let i = 0 | |
function clean () { | |
stream.removeListener('readable', onReadable) | |
stream.removeListener('end', onEnd) | |
stream.removeListener('error', onError) | |
} | |
function resolve2 (done) { | |
clean() |
Copy/paste is orders of magnitude cheaper than cementing the wrong abstraction.
-- Benedikt Meurer https://twitter.com/bmeurer/status/992723662225723394
const makeAsyncGenerator = require('./make-async-generator') | |
const f = makeAsyncGenerator(function * () { | |
yield 'foo' | |
const value = yield Promise.resolve('bar') // yield promises to await them | |
yield value | |
try { | |
yield Promise.reject('baz') | |
} catch (value) { | |
yield value |