Skip to content

Instantly share code, notes, and snippets.

@VitorLuizC
Last active March 1, 2018 04:30
Show Gist options
  • Select an option

  • Save VitorLuizC/bc4c023f4a8517cd88306993180a681f to your computer and use it in GitHub Desktop.

Select an option

Save VitorLuizC/bc4c023f4a8517cd88306993180a681f to your computer and use it in GitHub Desktop.
import Uncouple from 'uncouple'
const { replace } = Uncouple(String)
const { map, join, reduceRight } = Uncouple(Array)
const compose = (...λs) => (value) => reduceRight(λs, (value, λ) => λ(value), value)
const HighOrder = (λ, ...params) => (value) => λ(value, params)
const toRaw = compose(
HighOrder(replace, /\u2028/g, '\\u2028'),
HighOrder(replace, /\u2029/g, '\\u2029'),
JSON.stringify
)
const toRawQuery = compose(
toRaw,
HighOrder(join, '\n')
)
const toRequireStatements = (files) => files.map((file) => `require('${file}')`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment