Last active
March 1, 2018 04:30
-
-
Save VitorLuizC/bc4c023f4a8517cd88306993180a681f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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