Comparing version 0.2.1 to 0.2.2
@@ -20,4 +20,2 @@ "use strict"; | ||
var empty = []; | ||
var pass = function pass(x, f) { | ||
@@ -95,7 +93,7 @@ return f(x); | ||
if (isArray(focus)) { | ||
return downIndex(focus, head ? 0 : focus.length - 1, { up: up }); | ||
} else if (isObject(focus)) { | ||
if (isObject(focus)) { | ||
var keys = R.keys(focus); | ||
return downIndex(R.values(focus), head ? 0 : keys.length - 1, { keys: keys, up: up }); | ||
} else if (isArray(focus)) { | ||
return downIndex(focus, head ? 0 : focus.length - 1, { up: up }); | ||
} else { | ||
@@ -112,3 +110,3 @@ return undefined; | ||
var shift = function shift(f, c, t, k) { | ||
return f.length === 0 ? undefined : k(R.dropLast(1, f), R.last(f), R.append(c, t)); | ||
return f && f.length !== 0 ? k(R.dropLast(1, f), R.last(f), R.append(c, t)) : undefined; | ||
}; | ||
@@ -152,3 +150,3 @@ | ||
var toZipper = exports.toZipper = function toZipper(focus) { | ||
return { left: empty, right: empty, focus: focus }; | ||
return { focus: focus }; | ||
}; | ||
@@ -193,2 +191,2 @@ | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9mYXN0ZW5lci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQTs7SUFBWSxDOzs7Ozs7OztBQUVaLElBQU0sUUFBUSxFQUFkOztBQUVBLElBQU0sT0FBTyxTQUFQLElBQU8sQ0FBQyxDQUFELEVBQUksQ0FBSjtBQUFBLFNBQVUsRUFBRSxDQUFGLENBQVY7QUFBQSxDQUFiOztBQUVBLElBQU0sV0FBVyxTQUFYLFFBQVc7QUFBQSxTQUFLLEtBQUssRUFBRSxXQUFGLEtBQWtCLE1BQTVCO0FBQUEsQ0FBakI7QUFDQSxJQUFNLFVBQVUsU0FBVixPQUFVO0FBQUEsU0FBSyxLQUFLLEVBQUUsV0FBRixLQUFrQixLQUE1QjtBQUFB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
"description": "Zipper for manipulating JSON", | ||
"main": "lib/fastener.js", | ||
"scripts": { | ||
"bench": "node bench/bench.js", | ||
"dist": "babel src --source-maps inline --out-dir lib", | ||
@@ -18,4 +17,9 @@ "lint": "eslint src test", | ||
"keywords": [ | ||
"zipper", | ||
"json" | ||
"cursor", | ||
"functional", | ||
"immutable", | ||
"json", | ||
"query", | ||
"transform", | ||
"zipper" | ||
], | ||
@@ -36,3 +40,2 @@ "license": "MIT", | ||
"babel-preset-stage-2": "^6.5.0", | ||
"benchmark": "^2.1.0", | ||
"eslint": "^2.8.0", | ||
@@ -39,0 +42,0 @@ "mocha": "^2.4.5", |
209
README.md
@@ -13,2 +13,211 @@ [ [Tutorial](#tutorial) | [Reference](#reference) | [Related Work](#related-work) ] | ||
Playing with zippers in a REPL can be very instructive. First we require the | ||
libraries and define a little helper using | ||
[`reduce`](http://ramdajs.com/0.21.0/docs/#reduce) to perform a sequence of | ||
operations on a value: | ||
```js | ||
const R = require("ramda") | ||
const F = require("fastener") | ||
const seq = (x, ...fs) => R.reduce((x, f) => f(x), x, fs) | ||
``` | ||
Let's work with the following simple JSON object: | ||
```js | ||
const data = { contents: [ { language: "en", text: "Title" }, | ||
{ language: "sv", text: "Rubrik" } ] } | ||
``` | ||
First we just create a zipper using [`F.toZipper`](#toZipper): | ||
```js | ||
seq(F.toZipper(data)) | ||
// { focus: { contents: [ [Object], [Object] ] } } | ||
``` | ||
As can be seen, the zipper is just a simple JSON object and the `focus` is the | ||
`data` object that we gave to [`F.toZipper`](#toZipper). However, you should | ||
use the zipper combinators to operate on zippers rather than rely on their exact | ||
format. | ||
Let's then move into the `contents` property of the object using | ||
[`F.downTo`](#downTo): | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents')) | ||
// { left: [], | ||
// focus: | ||
// [ { language: 'en', text: 'Title' }, | ||
// { language: 'sv', text: 'Rubrik' } ], | ||
// right: [], | ||
// keys: [ 'contents' ], | ||
// up: {} } | ||
``` | ||
As seen above, the `focus` now has the `contents` array. We can use | ||
[`F.get`](#get) to extract the value under focus: | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents'), | ||
F.get) | ||
// [ { language: 'en', text: 'Title' }, | ||
// { language: 'sv', text: 'Rubrik' } ] | ||
``` | ||
Then we move into the first item of `contents` using [`F.downHead`](#downHead): | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents'), | ||
F.downHead) | ||
// { left: [], | ||
// focus: { language: 'en', text: 'Title' }, | ||
// right: [ { language: 'sv', text: 'Rubrik' } ], | ||
// up: { left: [], right: [], keys: [ 'contents' ], up: {} } } | ||
``` | ||
And continue into the first item of that which happens to the `language`: | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents'), | ||
F.downHead, | ||
F.downHead) | ||
// { left: [], | ||
// focus: 'en', | ||
// right: [ 'Title' ], | ||
// keys: [ 'language', 'text' ], | ||
// up: | ||
// { left: [], | ||
// right: [ [Object] ], | ||
// up: { left: [], right: [], keys: [Object], up: {} } } } | ||
``` | ||
And to the next item, `title`, using [`F.right`](#right): | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents'), | ||
F.downHead, | ||
F.downHead, | ||
F.right) | ||
// { left: [ 'en' ], | ||
// focus: 'Title', | ||
// right: [], | ||
// keys: [ 'language', 'text' ], | ||
// up: | ||
// { left: [], | ||
// right: [ [Object] ], | ||
// up: { left: [], right: [], keys: [Object], up: {} } } } | ||
``` | ||
Let's then use [`F.modify`](#modify) to modify the `title`: | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents'), | ||
F.downHead, | ||
F.downHead, | ||
F.right, | ||
F.modify(t => "The " + t)) | ||
// { left: [ 'en' ], | ||
// focus: 'The Title', | ||
// right: [], | ||
// keys: [ 'language', 'text' ], | ||
// up: | ||
// { left: [], | ||
// right: [ [Object] ], | ||
// up: { left: [], right: [], keys: [Object], up: {} } } } | ||
``` | ||
When we now move outwards using [`F.up`](#up) we can see the changed title | ||
become part of the data: | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents'), | ||
F.downHead, | ||
F.downHead, | ||
F.right, | ||
F.modify(t => "The " + t), | ||
F.up) | ||
// { focus: { language: 'en', text: 'The Title' }, | ||
// left: [], | ||
// right: [ { language: 'sv', text: 'Rubrik' } ], | ||
// up: { left: [], right: [], keys: [ 'contents' ], up: {} } } | ||
``` | ||
We can also just move back to the root and get the updated data structure using | ||
[`F.fromZipper`](#fromZipper): | ||
```js | ||
seq(F.toZipper(data), | ||
F.downTo('contents'), | ||
F.downHead, | ||
F.downHead, | ||
F.right, | ||
F.modify(t => "The " + t), | ||
F.fromZipper) | ||
// { contents: | ||
// [ { language: 'en', text: 'The Title' }, | ||
// { language: 'sv', text: 'Rubrik' } ] } | ||
``` | ||
The above hopefully helped to understand how zippers work. However, it is | ||
important to realize that one typically does not use zipper combinators to | ||
create such a specific sequence of operations. One rather uses the zipper | ||
combinators to create new combinators that perform more complex operations | ||
directly. | ||
Let's first define a zipper combinator that, given a zipper focused on an array, | ||
tries to focus on an element inside the array that satisfies a given predicate: | ||
```js | ||
const find = R.curry((p, z) => | ||
F.downTo(R.findIndex(p, F.get(z)), z)) | ||
``` | ||
Like all the basic zipper movement combinators, [`F.downTo`](#downTo) is a | ||
*partial function* that returns `undefined` in case the index is out of bounds. | ||
Let's define a simple function to compose partial functions: | ||
```js | ||
const pipeU = (...fs) => z => { | ||
let r = z | ||
for (let i=0; r !== undefined && i<fs.length; ++i) | ||
r = fs[i](r) | ||
return r | ||
} | ||
``` | ||
We can now compose a zipper combinator that, given a zipper focused on an object | ||
like `data`, tries to focus on the `text` element of an object with the given | ||
`language` inside the `contents`: | ||
```js | ||
const textIn = language => | ||
pipeU(F.downTo('contents'), | ||
find(r => r.language === language), | ||
F.downTo('text')) | ||
``` | ||
Now we can say: | ||
```js | ||
pipeU(F.toZipper, textIn("en"), F.modify(x => 'The ' + x), F.fromZipper)(data) | ||
// { contents: | ||
// [ { language: 'en', text: 'The Title' }, | ||
// { language: 'sv', text: 'Rubrik' } ] } | ||
``` | ||
Of course, this just scratches the surface. Zippers are powerful enough to | ||
implement arbitrary transforms on data structures. This can also make them more | ||
difficult to compose and reason about than more limited approaches such as | ||
[lenses](https://github.com/calmm-js/partial.lenses). | ||
## Reference | ||
@@ -15,0 +224,0 @@ |
import * as R from "ramda" | ||
const empty = [] | ||
const pass = (x, f) => f(x) | ||
@@ -49,7 +47,7 @@ | ||
const downMost = head => ({focus, ...up}) => { | ||
if (isArray(focus)) { | ||
return downIndex(focus, head ? 0 : focus.length-1, {up}) | ||
} else if (isObject(focus)) { | ||
if (isObject(focus)) { | ||
const keys = R.keys(focus) | ||
return downIndex(R.values(focus), head ? 0 : keys.length-1, {keys, up}) | ||
} else if (isArray(focus)) { | ||
return downIndex(focus, head ? 0 : focus.length-1, {up}) | ||
} else { | ||
@@ -65,3 +63,3 @@ return undefined | ||
const shift = (f, c, t, k) => | ||
f.length === 0 ? undefined : k(R.dropLast(1, f), R.last(f), R.append(c, t)) | ||
f && f.length !== 0 ? k(R.dropLast(1, f), R.last(f), R.append(c, t)) : undefined | ||
@@ -77,3 +75,3 @@ export const left = ({left, focus, right, ...rest}) => | ||
export const toZipper = focus => ({left: empty, right: empty, focus}) | ||
export const toZipper = focus => ({focus}) | ||
@@ -80,0 +78,0 @@ export const fromZipper = z => |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65161
8
439
304