diff options
Diffstat (limited to 'src_js/hatter/lenses.js')
| -rw-r--r-- | src_js/hatter/lenses.js | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/src_js/hatter/lenses.js b/src_js/hatter/lenses.js deleted file mode 100644 index 39da314..0000000 --- a/src_js/hatter/lenses.js +++ /dev/null @@ -1,21 +0,0 @@ -import R from 'ramda'; - - -export const index = R.lensIndex; - -export const prop = R.lensProp; - -export function path(...xs) { - return R.reduce((acc, i) => R.compose(acc, pathParamToLens(i)), - R.identity, xs); -} - -function pathParamToLens(x) { - switch (typeof(x)) { - case 'function': return x; - case 'number': return index(x); - case 'string': return prop(x); - case 'object': if (Array.isArray(x)) return R.apply(path, x); - } - throw 'Invalid path parameter'; -} |
