I hereby claim:
- I am rjhilgefort on github.
- I am rjhilgefort (https://keybase.io/rjhilgefort) on keybase.
- I have a public key ASDJQfOqOlsZCq_eKVHu4Vn3-qJVIaQv3fbLXPMcQCFhawo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
/* eslint-disable no-console */ | |
import * as R from 'ramda'; | |
import util from 'util'; | |
const inspect = R.compose( | |
R.flip, | |
R.curryN(2), | |
)(util.inspect); | |
export default x => { |
const { log } = console; | |
const trace = (tag) => (x) => { | |
log(`\n${tag}\n==================================================`); | |
log(JSON.stringify(x, 0, 2)); | |
return x; | |
} |
const { log, clear } = console; | |
clear() | |
const trace = (tag) => (x) => { | |
log(`\n${tag}\n==================================================`); | |
log(JSON.stringify(x, 0, 2)); | |
return x; | |
} | |
// misc.js | |
/////////////////////////////////////////////////////////////////////////////////////// |
// validateRequired :: [String] | String a -> a | ThrownError | |
const validateRequired = propOrPath => R.cond([ | |
[isString, R.compose(validateRequired, R.of)], | |
[R.T, path => R.when( | |
R.pathSatisfies(R.isNil, path), | |
R.compose( | |
fpThrow, | |
R.always(`"${path}" is required and must be present`), | |
) | |
)] |
const R = require('ramda') | |
const { Logger } = require('../logger') | |
// higher order "plugin" factories; these functions accept | |
// a factory, add functionality to it, and then return it | |
const locksHof = require('./locksHof') | |
const loggerHof = require('./methodLoggerHof') | |
const speakHof = require('./speakHof') | |
// create a "base" higher-order factory that has adds the methods |
// `tryCatch` is useful when you want to do assignment and have a sane default | |
// The value provided is not parseable, so we get `{}` because there was an error | |
tryCatch(JSON.parse, always({}))('{{50') | |
// {} | |
// Here, the value is parseable, so we get the parsed object literal | |
tryCatch(JSON.parse, always({}))('{ "foo": "HI" }') | |
// {"foo": "HI"} |
console.clear() | |
// util.js | |
///////////////////////////////////////////////////////////////// | |
const PromiseResolve = x => Promise.resolve(x) | |
// pipeAny.js | |
///////////////////////////////////////////////////////////////// | |
const pipeAny = compose( | |
apply(pipeP), |
const evolveAll = spec => compose( | |
evolve(spec), | |
compose(pickAll, keys)(spec), | |
) | |
const maybeHof = compose(when, complement)(isNil) | |
const maybeToUpper = maybeHof(toUpper) | |
evolveAll({ |
const maybeHof = compose(when, complement)(isNil) | |
const maybeToUpper = maybeHof(toUpper) | |
maybeToUpper(null) // null | |
maybeToUpper(undefined) // undefined | |
maybeToUpper('foo') // 'FOO' |