New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

partial.lenses

Package Overview
Dependencies
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

partial.lenses - npm Package Compare versions

Comparing version

to
1.4.1

.nyc_output/64325.json

33

lib/partial.lenses.js

@@ -264,35 +264,6 @@ "use strict";

var kks = [k].concat(ks);
return _ramda2.default.lens(function () {
var o = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var r = void 0;
kks.forEach(function (k) {
if (k in o) {
if (!r) r = {};
r[k] = o[k];
}
});
return r;
}, toConserve(function () {
var s = arguments.length <= 0 || arguments[0] === undefined ? empty : arguments[0];
var o = arguments.length <= 1 || arguments[1] === undefined ? empty : arguments[1];
var r = void 0;
for (var _k in o) {
if (!_ramda2.default.contains(_k, kks)) {
if (!r) r = {};
r[_k] = o[_k];
}
}
kks.forEach(function (k) {
if (k in s) {
if (!r) r = {};
r[k] = s[k];
}
});
return r;
}));
return L.pick(_ramda2.default.zipObj(kks, kks));
};
exports.default = L;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wYXJ0aWFsLmxlbnNlcy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBOzs7Ozs7Ozs7Ozs7QUFJQSxJQUFNLFFBQVEsRUFBUjs7QUFFTixJQUFNLFlBQVksU0FBWixTQUFZLENBQUMsQ0FBRCxFQUFJLENBQUosRUFBVTtBQUMxQixNQUFJLE1BQU0sU0FBTixJQUFtQixFQUFFLEtBQUssQ0FBTCxDQUFGLEVBQ3JCLE9BQU8sQ0FBUCxDQURGO0FBRUEsTUFBSSxVQUFKLENBSDBCO0FBSTFCLE9BQUssSUFBTSxDQUFOLElBQVcsQ0FBaEIsRUFBbUI7QUFDakIsUUFBSSxNQUFNLENBQU4sRUFB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GssIHYpID0+IHtcbiAgICAgIGlmICh1bmRlZmluZWQgPT09IHopXG4gICAgICAgIHogPSB7fVxuICAgICAgeltrXSA9IHZcbiAgICB9XG4gICAgZm9yIChjb25zdCBrIGluIHkpIHtcbiAgICAgIGlmICghKGsgaW4gdGVtcGxhdGUpKVxuICAgICAgICBzZXQoaywgeVtrXSlcbiAgICAgIGVsc2VcbiAgICAgICAgaWYgKGsgaW4gYylcbiAgICAgICAgICBzZXQoaywgY1trXSlcbiAgICB9XG4gICAgcmV0dXJuIHpcbiAgfSkpXG5cbkwucGljayA9IHRlbXBsYXRlID0+IFIubGVucyhcbiAgYyA9PiB7XG4gICAgbGV0IHJcbiAgICBmb3IgKGNvbnN0IGsgaW4gdGVtcGxhdGUpIHtcbiAgICAgIGNvbnN0IHYgPSBMLnZpZXcodGVtcGxhdGVba10sIGMpXG4gICAgICBpZiAodiAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIGlmIChyID09PSB1bmRlZmluZWQpXG4gICAgICAgICAgciA9IHt9XG4gICAgICAgIHJba10gPSB2XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiByXG4gIH0sXG4gIChvID0gZW1wdHksIGNJbikgPT4ge1xuICAgIGxldCBjID0gY0luXG4gICAgZm9yIChjb25zdCBrIGluIHRlbXBsYXRlKVxuICAgICAgYyA9IEwuc2V0KHRlbXBsYXRlW2tdLCBvW2tdLCBjKVxuICAgIHJldHVybiBjXG4gIH0pXG5cbkwuaWRlbnRpdHkgPSBSLmxlbnMoUi5pZGVudGl0eSwgUi5pZGVudGl0eSlcblxuTC5wcm9wcyA9IChrLCAuLi5rcykgPT4ge1xuICBjb25zdCBra3MgPSBbaywgLi4ua3NdXG4gIHJldHVybiBSLmxlbnMoXG4gICAgKG8gPSBlbXB0eSkgPT4ge1xuICAgICAgbGV0IHJcbiAgICAgIGtrcy5mb3JFYWNoKGsgPT4ge1xuICAgICAgICBpZiAoayBpbiBvKSB7XG4gICAgICAgICAgaWYgKCFyKVxuICAgICAgICAgICAgciA9IHt9XG4gICAgICAgICAgcltrXSA9IG9ba11cbiAgICAgICAgfVxuICAgICAgfSlcbiAgICAgIHJldHVybiByXG4gICAgfSxcbiAgICB0b0NvbnNlcnZlKChzID0gZW1wdHksIG8gPSBlbXB0eSkgPT4ge1xuICAgICAgbGV0IHJcbiAgICAgIGZvciAoY29uc3QgayBpbiBvKSB7XG4gICAgICAgIGlmICghUi5jb250YWlucyhrLCBra3MpKSB7XG4gICAgICAgICAgaWYgKCFyKVxuICAgICAgICAgICAgciA9IHt9XG4gICAgICAgICAgcltrXSA9IG9ba11cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAga2tzLmZvckVhY2goayA9PiB7XG4gICAgICAgIGlmIChrIGluIHMpIHtcbiAgICAgICAgICBpZiAoIXIpXG4gICAgICAgICAgICByID0ge31cbiAgICAgICAgICByW2tdID0gc1trXVxuICAgICAgICB9XG4gICAgICB9KVxuICAgICAgcmV0dXJuIHJcbiAgICB9KSlcbn1cblxuZXhwb3J0IGRlZmF1bHQgTFxuIl19
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wYXJ0aWFsLmxlbnNlcy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBOzs7Ozs7Ozs7Ozs7QUFJQSxJQUFNLFFBQVEsRUFBUjs7QUFFTixJQUFNLFlBQVksU0FBWixTQUFZLENBQUMsQ0FBRCxFQUFJLENBQUosRUFBVTtBQUMxQixNQUFJLE1BQU0sU0FBTixJQUFtQixFQUFFLEtBQUssQ0FBTCxDQUFGLEVBQ3JCLE9BQU8sQ0FBUCxDQURGO0FBRUEsTUFBSSxVQUFKLENBSDBCO0FBSTFCLE9BQUssSUFBTSxDQUFOLElBQVcsQ0FBaEIsRUFBbUI7QUFDakIsUUFBSSxNQUFNLENBQU4sRUFBUztBQUNYLFVBQUksY0FBYyxDQUFkLEVBQ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eClcbiAgICByZXR1cm4gelxuICB9KSxcbiAgdG9Db25zZXJ2ZSgoeSwgYykgPT4ge1xuICAgIGlmICh5ID09PSB1bmRlZmluZWQpXG4gICAgICByZXR1cm4gdW5kZWZpbmVkXG4gICAgbGV0IHpcbiAgICBjb25zdCBzZXQgPSAoaywgdikgPT4ge1xuICAgICAgaWYgKHVuZGVmaW5lZCA9PT0geilcbiAgICAgICAgeiA9IHt9XG4gICAgICB6W2tdID0gdlxuICAgIH1cbiAgICBmb3IgKGNvbnN0IGsgaW4geSkge1xuICAgICAgaWYgKCEoayBpbiB0ZW1wbGF0ZSkpXG4gICAgICAgIHNldChrLCB5W2tdKVxuICAgICAgZWxzZVxuICAgICAgICBpZiAoayBpbiBjKVxuICAgICAgICAgIHNldChrLCBjW2tdKVxuICAgIH1cbiAgICByZXR1cm4gelxuICB9KSlcblxuTC5waWNrID0gdGVtcGxhdGUgPT4gUi5sZW5zKFxuICBjID0+IHtcbiAgICBsZXQgclxuICAgIGZvciAoY29uc3QgayBpbiB0ZW1wbGF0ZSkge1xuICAgICAgY29uc3QgdiA9IEwudmlldyh0ZW1wbGF0ZVtrXSwgYylcbiAgICAgIGlmICh2ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgaWYgKHIgPT09IHVuZGVmaW5lZClcbiAgICAgICAgICByID0ge31cbiAgICAgICAgcltrXSA9IHZcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHJcbiAgfSxcbiAgKG8gPSBlbXB0eSwgY0luKSA9PiB7XG4gICAgbGV0IGMgPSBjSW5cbiAgICBmb3IgKGNvbnN0IGsgaW4gdGVtcGxhdGUpXG4gICAgICBjID0gTC5zZXQodGVtcGxhdGVba10sIG9ba10sIGMpXG4gICAgcmV0dXJuIGNcbiAgfSlcblxuTC5pZGVudGl0eSA9IFIubGVucyhSLmlkZW50aXR5LCBSLmlkZW50aXR5KVxuXG5MLnByb3BzID0gKGssIC4uLmtzKSA9PiB7XG4gIGNvbnN0IGtrcyA9IFtrLCAuLi5rc11cbiAgcmV0dXJuIEwucGljayhSLnppcE9iaihra3MsIGtrcykpXG59XG5cbmV4cG9ydCBkZWZhdWx0IExcbiJdfQ==
{
"name": "partial.lenses",
"version": "1.4.0",
"version": "1.4.1",
"description": "Ramda compatible partial lenses",

@@ -10,3 +10,3 @@ "main": "lib/partial.lenses.js",

"prepublish": "npm run lint && npm run test && npm run dist",
"test": "node_modules/mocha/bin/mocha"
"test": "node_modules/.bin/nyc node_modules/mocha/bin/mocha"
},

@@ -38,4 +38,5 @@ "repository": {

"eslint": "2.2.x",
"mocha": "^2.4.5"
"mocha": "^2.4.5",
"nyc": "^6.1.1"
}
}
[ [Tutorial](#tutorial) | [Reference](#reference) | [Background](#background) ]
This library provides a collection of [Ramda](http://ramdajs.com/) compatible
*partial* lenses. While an ordinary lens can be used to view and update an
existing part of a data structure, a partial lens can *view* optional data,
*insert* new data, *update* existing data and *delete* existing data and can
provide *default* values and maintain *required* data structure parts.
Lenses are a convenient abstraction for performing updates on individual
elements of immutable data structures. This library provides a collection of
[Ramda](http://ramdajs.com/) compatible *partial* lenses. While an ordinary
lens can be used to view and update an existing part of a data structure, a
partial lens can *view* optional data, *insert* new data, *update* existing data
and *delete* existing data and can provide *default* values and maintain
*required* data structure parts.

@@ -16,3 +18,3 @@ In JavaScript, missing data can be mapped to `undefined`, which is what partial

[![npm version](https://badge.fury.io/js/partial.lenses.svg)](http://badge.fury.io/js/partial.lenses) [![Build Status](https://travis-ci.org/calmm-js/partial.lenses.svg?branch=master)](https://travis-ci.org/calmm-js/partial.lenses) [![](https://david-dm.org/calmm-js/partial.lenses.svg)](https://david-dm.org/calmm-js/partial.lenses) [![](https://david-dm.org/calmm-js/partial.lenses/dev-status.svg)](https://david-dm.org/calmm-js/partial.lenses#info=devDependencies) [![Gitter](https://img.shields.io/gitter/room/calmm-js/chat.js.svg?style=flat-square)](https://gitter.im/calmm-js)
[![npm version](https://badge.fury.io/js/partial.lenses.svg)](http://badge.fury.io/js/partial.lenses) [![Build Status](https://travis-ci.org/calmm-js/partial.lenses.svg?branch=master)](https://travis-ci.org/calmm-js/partial.lenses) [![](https://david-dm.org/calmm-js/partial.lenses.svg)](https://david-dm.org/calmm-js/partial.lenses) [![](https://david-dm.org/calmm-js/partial.lenses/dev-status.svg)](https://david-dm.org/calmm-js/partial.lenses#info=devDependencies) [![Gitter](https://img.shields.io/gitter/room/calmm-js/chat.js.svg?style=flat-square)](https://gitter.im/calmm-js/chat)

@@ -216,18 +218,19 @@ ## Tutorial

Binary search may initially seem to be outside the scope of definable lenses.
However, the `L.choose` lens allows for dynamic construction of lenses based on
examining the data structure being manipulated. Inside `L.choose` we can write
the ordinary BST logic to pick the correct branch based on the key in the
currently examined node and the key that we are looking for. So, here is our
first attempt at a BST lens:
Binary search might initially seem to be outside the scope of definable lenses.
However, given basic BST operations, one could easily wrap them as a primitive
partial lens. But could we leverage lens combinators to build a BST lens more
directly? We can. The `L.choose` lens combinator allows for dynamic
construction of lenses based on examining the data structure being manipulated.
Inside `L.choose` we can write the ordinary BST logic to pick the correct branch
based on the key in the currently examined node and the key that we are looking
for. So, here is our first attempt at a BST lens:
```js
const binarySearch = key =>
const search = key =>
L(L.default({key}),
L.choose(node =>
key < node.key ? L("smaller", binarySearch(key)) :
node.key < key ? L("greater", binarySearch(key)) :
L.identity))
L.choose(n => key < n.key ? L("smaller", search(key)) :
n.key < key ? L("greater", search(key)) :
L.identity))
const valueOf = key => L(binarySearch(key), "value")
const valueOf = key => L(search(key), "value")
```

@@ -250,3 +253,3 @@

However, the above `binarySearch` lens constructor does not maintain the BST
However, the above `search` lens constructor does not maintain the BST
structure when values are being deleted:

@@ -262,25 +265,17 @@

How do we fix this? What we need is to normalize the data structure after
changes. The `L.normalize` lens can be used for that purpose. Here is the
updated `binarySearch` definition:
How do we fix this? We could check and transform the data structure to a BST
after changes. The `L.normalize` lens can be used for that purpose. Here is
the updated `search` definition:
```js
const binarySearch = key =>
L(L.normalize(node => {
if (!node)
return node
if ("value" in node)
return node
if (!("greater" in node) && "smaller" in node)
return node.smaller
if (!("smaller" in node) && "greater" in node)
return node.greater
return L.set(binarySearch(node.smaller.key),
node.smaller,
node.greater)}),
const search = key =>
L(L.normalize(n =>
undefined !== n.value ? n :
n.smaller && !n.greater ? n.smaller :
!n.smaller && n.greater ? n.greater :
L.set(search(n.smaller.key), n.smaller, n.greater)),
L.default({key}),
L.choose(node =>
key < node.key ? L("smaller", binarySearch(key)) :
node.key < key ? L("greater", binarySearch(key)) :
L.identity))
L.choose(n => key < n.key ? L("smaller", search(key)) :
n.key < key ? L("greater", search(key)) :
L.identity))
```

@@ -425,2 +420,9 @@

For example:
```js
> L.set(L.append, "x", undefined)
[ 'x' ]
```
#### [`L.augment({prop: obj => val, ...props})`](#laugmentprop-obj--val-props "L.augment :: {p1 :: o -> a1, ...ps} -> PLens {...o} {...o, p1 :: a1, ...ps}")

@@ -434,2 +436,9 @@

For example:
```js
> L.over(L.augment({y: r => r.x + 1}), r => ({x: r.x + r.y, y: 2, z: r.x - r.y}), {x: 1})
{ x: 3, z: -1 }
```
#### [`L.choose(maybeValue => PLens)`](#lchoosemaybevalue--plens "L.choose :: (Maybe s -> PLens s a) -> PLens s a")

@@ -439,4 +448,24 @@

the given function that maps the underlying view, which can be undefined, to a
lens. The lens returned by the given function will be lifted.
lens. In other words, the `L.choose` combinator allows a lens to be constructed
*after* examining the data structure being manipulated. The lens returned by
the function given to `L.choose` will be lifted.
For example, given:
```js
const majorAxis = L.choose(({x, y} = {}) =>
Math.abs(x) < Math.abs(y) ? "y" : "x")
```
we get:
```js
> L.view(majorAxis, {x: 1, y: 2})
2
> L.view(majorAxis, {x: -3, y: 1})
-3
> L.over(majorAxis, R.negate, {x: 2, y: -3})
{ y: 3, x: 2 }
```
#### [`L.filter(predicate)`](#lfilterpredicate "L.filter :: (a -> Boolean) -> PLens [a] [a]")

@@ -450,2 +479,9 @@

For example:
```js
> L.delete(L.filter(x => x <= 2), [3,1,4,1,5,9,2])
[ 3, 4, 5, 9 ]
```
*Note:* An alternative design for filter could implement a smarter algorithm to

@@ -465,17 +501,22 @@ combine arrays when set. For example, an algorithm based on

```js
> L.deleteAll(L.find(x => x <= 2), [3,1,4,1,5,9,2])
[ 3, 4, 5, 9 ]
```
#### [`L.findWith(l, ...ls)`](#lfindwithl-ls "L.findWith :: (PLens s s1, ...PLens sN a) -> PLens [s] a")
`L.findWith(l, ...ls)` is defined as
`L.findWith(l, ...ls)` chooses an index from an array through which the given
lens, `L(l, ...ls)`, focuses on a defined item and then returns a lens that
focuses on that item.
For example:
```js
L.findWith = (l, ...ls) => {
const lls = L(l, ...ls)
return L(L.find(x => L.view(lls, x) !== undefined), lls)
}
> L.view(L.findWith("x"), [{z: 6}, {x: 9}, {y: 6}])
9
> L.set(L.findWith("x"), 3, [{z: 6}, {x: 9}, {y: 6}])
[ { z: 6 }, { x: 3 }, { y: 6 } ]
```
and basically chooses an index from an array through which the given lens, `L(l,
...ls)`, focuses on a defined item and then returns a lens that focuses on that
item.
#### [`L.firstOf(l, ...ls)`](#lfirstofl-ls "L.firstOf :: (PLens s a, ...PLens s a) -> PLens s a")

@@ -527,3 +568,4 @@

`L.pick({p1: l1, ...pls})` creates a lens out of the given object template of
lenses. When viewed, an object is created, whose properties are obtained by
lenses and allows one to pick apart a data structure and then put it back
together. When viewed, an object is created, whose properties are obtained by
viewing through the lenses of the template. When set with an object, the

@@ -534,2 +576,37 @@ properties of the object are set to the context via the lenses of the template.

For example, let's say we need to deal with data and schema in need of some
semantic restructuring:
```js
const data = {px: 1, py: 2, vx: 1.0, vy: 0.0}
```
We can use `L.pick` to create lenses to pick apart the data and put it back
together into a more meaningful structure:
```js
const asVec = prefix => L.pick({x: prefix + "x", y: prefix + "y"})
const sanitize = L.pick({pos: asVec("p"), vel: asVec("v")})
```
We now have a better structured view of the data:
```js
> L.view(sanitize, data)
{ pos: { x: 1, y: 2 }, vel: { x: 1, y: 0 } }
```
That works in both directions:
```js
> L.over(L(sanitize, "pos", "x"), R.add(5), data)
{ px: 6, py: 2, vx: 1, vy: 0 }
```
**NOTE:** In order for a lens created with `L.pick` to work in a predictable
manner, the given lenses must operate on independent parts of the data
structure. As a trivial example, in `L.pick({x: "same", y: "same"})` both of
the resulting object properties, `x` and `y`, address the same property of the
underlying object, so writing through the lens will give unpredictable results.
Note that, when set, `L.pick` simply ignores any properties that the given

@@ -551,9 +628,15 @@ template doesn't mention. Note that the underlying data structure need not be

`L.props(key, ...keys)` focuses on a subset of properties of an object. The
view of `L.props` is undefined when none of the properties is defined.
Otherwise the view is an object containing a subset of the properties. Setting
through `L.props` updates the whole subset of properties, which means that any
undefined properties are removed if they did exists previously. When set, any
extra properties are ignored.
`L.props(k1, ..., kN)` is equivalent to `L.pick({[k1]: k1, ..., [kN]: kN})` and
focuses on a subset of properties of an object, allowing one to treat the subset
of properties as a unit. The view of `L.props` is undefined when none of the
properties is defined. Otherwise the view is an object containing a subset of
the properties. Setting through `L.props` updates the whole subset of
properties, which means that any undefined properties are removed if they did
exists previously. When set, any extra properties are ignored.
```js
> L.set(L.props("x", "y"), {x: 4}, {x: 1, y: 2, z: 3})
{ z: 3, x: 4 }
```
#### [`L.replace(inn, out)`](#lreplaceinn-out "L.replace :: Maybe s -> Maybe s -> PLens s s")

@@ -565,2 +648,11 @@

For example:
```js
> L.view(L.replace(1, 2), 1)
2
> L.set(L.replace(1, 2), 2, 0)
1
```
The main use case for `replace` is to handle optional and required properties

@@ -572,12 +664,38 @@ and elements. In most cases, rather than using `replace`, you will make

`L.default(out)` is the same as `L.replace(undefined, out)`.
`L.default(out)` is the same as `L.replace(undefined, out)`. `L.default` is
used to specify a default value for an element in case it is missing. This can
be useful to avoid having to check for and provide default behavior elsewhere.
For example:
```js
> L.view(L("items", L.default([])), {})
[]
> L.view(L("items", L.default([])), {items: [1, 2, 3]})
[ 1, 2, 3 ]
```
##### [`L.define(value)`](#ldefinevalue "L.define :: s -> PLens s s")
`L.define(value)` is the same as `L(L.required(value), L.default(value))`.
`L.define` is used to specify a value to act as both the default value and the
required value for an element.
##### [`L.required(inn)`](#lrequiredinn "L.required :: s -> PLens s s")
`L.required(inn)` is the same as `L.replace(inn, undefined)`.
`L.required(inn)` is the same as `L.replace(inn, undefined)`. `L.required` is
used to specify that an element is not to be deleted; in case it is deleted, the
given value will be substituted instead.
For example:
```js
> L.delete(L("items", 0), {items: [1]})
undefined
> L.delete(L(L.required({}), "items", 0), {items: [1]})
{}
> L.delete(L("items", L.required([]), 0), {items: [1]})
{ items: [] }
```
## Background

@@ -584,0 +702,0 @@

@@ -183,34 +183,5 @@ import R from "ramda"

const kks = [k, ...ks]
return R.lens(
(o = empty) => {
let r
kks.forEach(k => {
if (k in o) {
if (!r)
r = {}
r[k] = o[k]
}
})
return r
},
toConserve((s = empty, o = empty) => {
let r
for (const k in o) {
if (!R.contains(k, kks)) {
if (!r)
r = {}
r[k] = o[k]
}
}
kks.forEach(k => {
if (k in s) {
if (!r)
r = {}
r[k] = s[k]
}
})
return r
}))
return L.pick(R.zipObj(kks, kks))
}
export default L

@@ -37,2 +37,3 @@ import R from "ramda"

testEq('L.prop.length', 1)
testEq('L.props.length', 1)
testEq('L.replace.length', 2)

@@ -67,2 +68,3 @@ testEq('L.required.length', 1)

testEq('L.view(L(5), [1, 2, 3])', undefined)
testEq('L.set(1, "2", ["1", "2", "3"])', ["1", "2", "3"])
})

@@ -147,2 +149,3 @@

testEq('L.delete(L(L.augment({y: () => 1}), "x"), {x:0})', undefined)
testEq('L.delete(L.augment({z: c => c.x + c.y}), {x: 1, y: 2})', undefined)
})

@@ -168,31 +171,29 @@

testEq('L.delete(L.props("x", "y"), {x: 1, y: 2})', undefined)
testEq('L.set(L.props("a", "b"), {a: 2}, {a: 1, b: 3})', {a: 2})
})
const BST = {
search: key =>
L(L.normalize(node => {
if (!node)
return node
if ("value" in node)
return node
if (!("greater" in node) && "smaller" in node)
return node.smaller
if (!("smaller" in node) && "greater" in node)
return node.greater
return L.set(BST.search(node.smaller.key),
node.smaller,
node.greater)}),
L.default({key}),
L.choose(node =>
key < node.key ? L("smaller", BST.search(key)) :
node.key < key ? L("greater", BST.search(key)) :
L.identity)),
search: key => {
const rec =
L(L.normalize(n =>
undefined !== n.value ? n :
n.smaller && !n.greater ? n.smaller :
!n.smaller && n.greater ? n.greater :
L.set(BST.search(n.smaller.key), n.smaller, n.greater)),
L.default({key}),
L.choose(n => key < n.key ? L("smaller", rec) :
n.key < key ? L("greater", rec) :
L.identity))
return rec
},
valueOf: key => L(BST.search(key), "value"),
isValid: (node, keyPred = () => true) =>
undefined === node
|| "key" in node
&& "value" in node
&& keyPred(node.key)
&& BST.isValid(node.smaller, key => key < node.key)
&& BST.isValid(node.greater, key => node.key < key)
isValid: (n, keyPred = () => true) =>
undefined === n
|| "key" in n
&& "value" in n
&& keyPred(n.key)
&& BST.isValid(n.smaller, key => key < n.key)
&& BST.isValid(n.greater, key => n.key < key)
}

@@ -207,13 +208,15 @@

it("maintains validity through operations", () => {
let t0
let t1
let before
let after
let op
let k
let key
const error = () => {
throw new Error("From " + show(t0) + " " + op + " with " + k + " gave " + t1)
throw new Error("From " + show(before) +
" " + op + " with " + key +
" gave " + show(after))
}
for (let i=0; i<1000; ++i) {
k = randomInt(0, 10)
key = randomInt(0, 10)
op = randomPick("set", "delete")

@@ -223,9 +226,9 @@

case "set":
t1 = L.set(BST.valueOf(k), k, t0)
if (undefined === L.view(BST.valueOf(k), t1))
after = L.set(BST.valueOf(key), key, before)
if (undefined === L.view(BST.valueOf(key), after))
error()
break
case "delete":
t1 = L.delete(BST.valueOf(k), t0)
if (undefined !== L.view(BST.valueOf(k), t1))
after = L.delete(BST.valueOf(key), before)
if (undefined !== L.view(BST.valueOf(key), after))
error()

@@ -235,8 +238,8 @@ break

if (!BST.isValid(t1))
if (!BST.isValid(after))
error()
t0 = t1
before = after
}
})
})

Sorry, the diff of this file is not supported yet