partial.lenses
Advanced tools
Comparing version 3.3.1 to 3.4.0
# Changelog | ||
## 3.4.0 | ||
Added minimalistic *experimental* traversal support in the form of the | ||
`sequence` traversal. | ||
## 3.0.0 | ||
@@ -4,0 +9,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.log = exports.props = exports.identity = exports.pick = exports.augment = exports.filter = exports.append = exports.index = exports.findWith = exports.find = exports.prop = exports.normalize = exports.define = exports.required = exports.defaults = exports.replace = exports.choice = exports.orElse = exports.nothing = exports.choose = exports.just = exports.chain = exports.get = exports.set = exports.modify = exports.lens = exports.removeAll = exports.remove = exports.compose = exports.toRamda = exports.fromRamda = undefined; | ||
exports.sequence = exports.log = exports.props = exports.identity = exports.pick = exports.augment = exports.filter = exports.append = exports.index = exports.findWith = exports.find = exports.prop = exports.normalize = exports.define = exports.required = exports.defaults = exports.replace = exports.choice = exports.orElse = exports.nothing = exports.choose = exports.just = exports.chain = exports.get = exports.set = exports.modify = exports.lens = exports.removeAll = exports.remove = exports.compose = exports.toRamda = exports.fromRamda = undefined; | ||
@@ -23,5 +23,34 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function Identity(value) { | ||
this.value = value; | ||
} | ||
var Ident = function Ident(x) { | ||
return new Identity(x); | ||
}; | ||
Identity.prototype.map = function (x2y) { | ||
return new Identity(x2y(this.value)); | ||
}; | ||
Identity.prototype.of = Ident; | ||
Identity.prototype.ap = function (x) { | ||
return new Identity(this.value(x.value)); | ||
}; | ||
// | ||
function Constant(value) { | ||
this.value = value; | ||
} | ||
var Const = function Const(x) { | ||
return new Constant(x); | ||
}; | ||
Constant.prototype.map = function () { | ||
return this; | ||
}; | ||
Constant.prototype.of = Const; | ||
// | ||
var warned = {}; | ||
var deprecated = function deprecated(message) { | ||
var warn = function warn(message) { | ||
if (!(message in warned)) { | ||
@@ -128,7 +157,7 @@ warned[message] = message; | ||
var remove = exports.remove = R.curry(function (l, s) { | ||
return R.set(toRamda(l), undefined, s); | ||
return setI(toRamda(l), undefined, s); | ||
}); | ||
var removeAll = exports.removeAll = R.curry(function (lens, data) { | ||
deprecated("`removeAll` is deprecated and there is no planned replacement --- use a different approach."); | ||
warn("`removeAll` is deprecated and will be removed in next major version --- use a different approach."); | ||
while (get(lens, data) !== undefined) { | ||
@@ -139,11 +168,34 @@ data = remove(lens, data); | ||
var lens = exports.lens = R.lens; | ||
var setI = function setI(l, x, s) { | ||
return l(function () { | ||
return Ident(x); | ||
})(s).value; | ||
}; | ||
var getI = function getI(l, s) { | ||
return l(Const)(s).value; | ||
}; | ||
var modifyI = function modifyI(l, x2x, s) { | ||
return l(function (y) { | ||
return Ident(x2x(y)); | ||
})(s).value; | ||
}; | ||
var lensI = function lensI(getter, setter) { | ||
return function (toFn) { | ||
return function (target) { | ||
return toFn(getter(target)).map(function (focus) { | ||
return setter(focus, target); | ||
}); | ||
}; | ||
}; | ||
}; | ||
var lens = exports.lens = R.curry(lensI); | ||
var modify = exports.modify = R.curry(function (l, x2x, s) { | ||
return R.over(toRamda(l), x2x, s); | ||
return modifyI(toRamda(l), x2x, s); | ||
}); | ||
var set = exports.set = R.curry(function (l, x, s) { | ||
return R.set(toRamda(l), x, s); | ||
return setI(toRamda(l), x, s); | ||
}); | ||
var get = exports.get = R.curry(function (l, s) { | ||
return R.view(toRamda(l), s); | ||
return getI(toRamda(l), s); | ||
}); | ||
@@ -158,3 +210,3 @@ | ||
var just = exports.just = function just(x) { | ||
return lens(R.always(x), snd); | ||
return lensI(R.always(x), snd); | ||
}; | ||
@@ -167,4 +219,4 @@ | ||
return R.map(function (focus) { | ||
return R.set(l, focus, target); | ||
}, toFunctor(R.view(l, target))); | ||
return setI(l, focus, target); | ||
}, toFunctor(getI(l, target))); | ||
}; | ||
@@ -174,7 +226,7 @@ }; | ||
var nothing = exports.nothing = lens(snd, snd); | ||
var nothing = exports.nothing = lensI(snd, snd); | ||
var orElse = exports.orElse = R.curry(function (d, l) { | ||
return choose(function (x) { | ||
return get(l, x) !== undefined ? l : d; | ||
return getI(toRamda(l), x) !== undefined ? l : d; | ||
}); | ||
@@ -190,3 +242,3 @@ }); | ||
var i = ls.findIndex(function (l) { | ||
return get(l, x) !== undefined; | ||
return getI(toRamda(l), x) !== undefined; | ||
}); | ||
@@ -198,3 +250,3 @@ return 0 <= i ? ls[i] : nothing; | ||
var replace = exports.replace = R.curry(function (inn, out) { | ||
return lens(function (x) { | ||
return lensI(function (x) { | ||
return R.equals(x, inn) ? out : x; | ||
@@ -215,3 +267,3 @@ }, toConserve(function (y) { | ||
var normalize = exports.normalize = function normalize(transform) { | ||
return lens(toPartial(transform), toConserve(toPartial(transform))); | ||
return lensI(toPartial(transform), toConserve(toPartial(transform))); | ||
}; | ||
@@ -226,3 +278,3 @@ | ||
var toRamdaProp = function toRamdaProp(k) { | ||
return lens(function (o) { | ||
return lensI(function (o) { | ||
return o && o[k]; | ||
@@ -245,3 +297,3 @@ }, function (v, o) { | ||
return compose(find(function (x) { | ||
return R.view(lls, x) !== undefined; | ||
return getI(lls, x) !== undefined; | ||
}), lls); | ||
@@ -257,3 +309,3 @@ }; | ||
var toRamdaIndex = function toRamdaIndex(i) { | ||
return lens(function (xs) { | ||
return lensI(function (xs) { | ||
return xs && xs[i]; | ||
@@ -274,3 +326,3 @@ }, function (x, xs) { | ||
var append = exports.append = lens(snd, function (x, xs) { | ||
var append = exports.append = lensI(snd, function (x, xs) { | ||
return x === undefined ? xs : xs === undefined ? [x] : xs.concat([x]); | ||
@@ -280,3 +332,3 @@ }); | ||
var filter = exports.filter = function filter(p) { | ||
return lens(function (xs) { | ||
return lensI(function (xs) { | ||
return xs && xs.filter(p); | ||
@@ -289,3 +341,3 @@ }, function (ys, xs) { | ||
var augment = exports.augment = function augment(template) { | ||
return lens(toPartial(function (x) { | ||
return lensI(toPartial(function (x) { | ||
var z = _extends({}, x); | ||
@@ -310,6 +362,6 @@ for (var k in template) { | ||
var pick = exports.pick = function pick(template) { | ||
return lens(function (c) { | ||
return lensI(function (c) { | ||
var r = void 0; | ||
for (var k in template) { | ||
var v = get(template[k], c); | ||
var v = getI(toRamda(template[k]), c); | ||
if (v !== undefined) { | ||
@@ -327,3 +379,3 @@ if (r === undefined) r = {}; | ||
for (var k in template) { | ||
c = set(template[k], o[k], c); | ||
c = setI(toRamda(template[k]), o[k], c); | ||
}return c; | ||
@@ -333,3 +385,3 @@ }); | ||
var identity = exports.identity = lens(id, conserve); | ||
var identity = exports.identity = lensI(id, conserve); | ||
@@ -361,6 +413,14 @@ var props = exports.props = function props() { | ||
return lens(show.apply(undefined, labels.concat(["get"])), show.apply(undefined, labels.concat(["set"]))); | ||
return lensI(show.apply(undefined, labels.concat(["get"])), show.apply(undefined, labels.concat(["set"]))); | ||
}; | ||
var sequence = exports.sequence = function sequence(toApplicative) { | ||
return function (target) { | ||
return warn("`sequence` is experimental and might be removed, renamed or changed semantically before next major release") || R.sequence(Ident, R.map(toApplicative, target)).map(R.pipe(R.filter(function (x) { | ||
return x !== undefined; | ||
}), dropped)); | ||
}; | ||
}; | ||
exports.default = compose; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wYXJ0aWFsLmxlbnNlcy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQTs7SUFBWTs7Ozs7Ozs7OztBQUlaLElBQU0sU0FBUyxFQUFUOztBQUVOLElBQU0sYUFBYSxTQUFiLFVBQWEsVUFBVztBQUM1QixNQUFJLEVBQUUsV0FBVyxNQUFYLENBQUYsRUFBc0I7QUFDeEIsV0FBTyxPQUFQLElBQWtCLE9BQWxCLENBRHdCO0FBRXhCLFlBQVEsSUFBUixDQUFhLGlCQUFiLEVBQWdDLE9BQWhDLEVBRndCO0dBQTFCO0NBRGlCOzs7O0FBU25CLElBQU0sS0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1bmRlZmluZWRcbiAgICBsZXQgelxuICAgIGNvbnN0IHNldCA9IChrLCB2KSA9PiB7XG4gICAgICBpZiAodW5kZWZpbmVkID09PSB6KVxuICAgICAgICB6ID0ge31cbiAgICAgIHpba10gPSB2XG4gICAgfVxuICAgIGZvciAoY29uc3QgayBpbiB5KSB7XG4gICAgICBpZiAoIShrIGluIHRlbXBsYXRlKSlcbiAgICAgICAgc2V0KGssIHlba10pXG4gICAgICBlbHNlXG4gICAgICAgIGlmIChrIGluIGMpXG4gICAgICAgICAgc2V0KGssIGNba10pXG4gICAgfVxuICAgIHJldHVybiB6XG4gIH0pKVxuXG5leHBvcnQgY29uc3QgcGljayA9IHRlbXBsYXRlID0+IGxlbnNJKFxuICBjID0+IHtcbiAgICBsZXQgclxuICAgIGZvciAoY29uc3QgayBpbiB0ZW1wbGF0ZSkge1xuICAgICAgY29uc3QgdiA9IGdldEkodG9SYW1kYSh0ZW1wbGF0ZVtrXSksIGMpXG4gICAgICBpZiAodiAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIGlmIChyID09PSB1bmRlZmluZWQpXG4gICAgICAgICAgciA9IHt9XG4gICAgICAgIHJba10gPSB2XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiByXG4gIH0sXG4gIChvID0gZW1wdHksIGNJbikgPT4ge1xuICAgIGxldCBjID0gY0luXG4gICAgZm9yIChjb25zdCBrIGluIHRlbXBsYXRlKVxuICAgICAgYyA9IHNldEkodG9SYW1kYSh0ZW1wbGF0ZVtrXSksIG9ba10sIGMpXG4gICAgcmV0dXJuIGNcbiAgfSlcblxuZXhwb3J0IGNvbnN0IGlkZW50aXR5ID0gbGVuc0koaWQsIGNvbnNlcnZlKVxuXG5leHBvcnQgY29uc3QgcHJvcHMgPSAoLi4ua3MpID0+IHBpY2soUi56aXBPYmooa3MsIGtzKSlcblxuY29uc3Qgc2hvdyA9ICguLi5sYWJlbHMpID0+IHggPT4gY29uc29sZS5sb2coLi4ubGFiZWxzLCB4KSB8fCB4XG5cbmV4cG9ydCBjb25zdCBsb2cgPSAoLi4ubGFiZWxzKSA9PlxuICBsZW5zSShzaG93KC4uLmxhYmVscywgXCJnZXRcIiksIHNob3coLi4ubGFiZWxzLCBcInNldFwiKSlcblxuZXhwb3J0IGNvbnN0IHNlcXVlbmNlID0gdG9BcHBsaWNhdGl2ZSA9PiB0YXJnZXQgPT5cbiAgd2FybihcImBzZXF1ZW5jZWAgaXMgZXhwZXJpbWVudGFsIGFuZCBtaWdodCBiZSByZW1vdmVkLCByZW5hbWVkIG9yIGNoYW5nZWQgc2VtYW50aWNhbGx5IGJlZm9yZSBuZXh0IG1ham9yIHJlbGVhc2VcIikgfHxcbiAgUi5zZXF1ZW5jZShJZGVudCwgUi5tYXAodG9BcHBsaWNhdGl2ZSwgdGFyZ2V0KSlcbiAgLm1hcChSLnBpcGUoUi5maWx0ZXIoeCA9PiB4ICE9PSB1bmRlZmluZWQpLCBkcm9wcGVkKSlcblxuZXhwb3J0IGRlZmF1bHQgY29tcG9zZVxuIl19 |
{ | ||
"name": "partial.lenses", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"description": "Partial lenses", | ||
@@ -10,3 +10,3 @@ "main": "lib/partial.lenses.js", | ||
"prepublish": "npm run lint && npm run test && npm run dist", | ||
"test": "node_modules/.bin/nyc node_modules/mocha/bin/mocha" | ||
"test": "nyc mocha" | ||
}, | ||
@@ -13,0 +13,0 @@ "repository": { |
@@ -343,3 +343,4 @@ [ [Tutorial](#tutorial) | [Reference](#reference) | [Background](#background) ] | ||
The lenses and operations on lenses are accessed via the default import: | ||
The lens combinators are available as named imports. Typically one just imports | ||
the library as: | ||
@@ -849,2 +850,25 @@ ```js | ||
### Traversal combinators | ||
Aside from lenses, there is experimental support for traversals. Traversals and | ||
lenses can be composed and the result is a traversal. A traversal operates over | ||
a collection of focuses and for this reason traversals cannot be viewed | ||
([`get`](#get) does not work on a traversal), but they can be modified, set and | ||
removed. Traversals (and lenses) can also be folded over (or reduced), but such | ||
an operation is currently not provided. | ||
#### <a name="sequence"></a>[`L.sequence`](#sequence "L.sequence :: Traversal s s") | ||
**`L.sequence` is experimental and might be removed, renamed or changed | ||
semantically before next major release.** | ||
`L.sequence` is a traversal (rather than a lens) over an array. | ||
For example: | ||
```js | ||
L.modify(P("xs", L.sequence, "x"), R.add(1), {xs: [{x: 1}, {x: 2}]}) | ||
// { xs: [ { x: 2 }, { x: 3 } ] } | ||
``` | ||
### Debugging | ||
@@ -851,0 +875,0 @@ |
@@ -5,5 +5,20 @@ import * as R from "ramda" | ||
function Identity(value) {this.value = value} | ||
const Ident = x => new Identity(x) | ||
Identity.prototype.map = function (x2y) {return new Identity(x2y(this.value))} | ||
Identity.prototype.of = Ident | ||
Identity.prototype.ap = function (x) {return new Identity(this.value(x.value))} | ||
// | ||
function Constant(value) {this.value = value} | ||
const Const = x => new Constant(x) | ||
Constant.prototype.map = function () {return this} | ||
Constant.prototype.of = Const | ||
// | ||
const warned = {} | ||
const deprecated = message => { | ||
const warn = message => { | ||
if (!(message in warned)) { | ||
@@ -92,6 +107,6 @@ warned[message] = message | ||
export const remove = R.curry((l, s) => R.set(toRamda(l), undefined, s)) | ||
export const remove = R.curry((l, s) => setI(toRamda(l), undefined, s)) | ||
export const removeAll = R.curry((lens, data) => { | ||
deprecated("`removeAll` is deprecated and there is no planned replacement --- use a different approach.") | ||
warn("`removeAll` is deprecated and will be removed in next major version --- use a different approach.") | ||
while (get(lens, data) !== undefined) | ||
@@ -102,24 +117,30 @@ data = remove(lens, data) | ||
export const lens = R.lens | ||
export const modify = R.curry((l, x2x, s) => R.over(toRamda(l), x2x, s)) | ||
export const set = R.curry((l, x, s) => R.set(toRamda(l), x, s)) | ||
export const get = R.curry((l, s) => R.view(toRamda(l), s)) | ||
const setI = (l, x, s) => l(() => Ident(x))(s).value | ||
const getI = (l, s) => l(Const)(s).value | ||
const modifyI = (l, x2x, s) => l(y => Ident(x2x(y)))(s).value | ||
const lensI = (getter, setter) => toFn => target => | ||
toFn(getter(target)).map(focus => setter(focus, target)) | ||
export const lens = R.curry(lensI) | ||
export const modify = R.curry((l, x2x, s) => modifyI(toRamda(l), x2x, s)) | ||
export const set = R.curry((l, x, s) => setI(toRamda(l), x, s)) | ||
export const get = R.curry((l, s) => getI(toRamda(l), s)) | ||
export const chain = R.curry((x2yL, xL) => | ||
compose(xL, choose(xO => xO === undefined ? nothing : x2yL(xO)))) | ||
export const just = x => lens(R.always(x), snd) | ||
export const just = x => lensI(R.always(x), snd) | ||
export const choose = x2yL => toFunctor => target => { | ||
const l = toRamda(x2yL(target)) | ||
return R.map(focus => R.set(l, focus, target), toFunctor(R.view(l, target))) | ||
return R.map(focus => setI(l, focus, target), toFunctor(getI(l, target))) | ||
} | ||
export const nothing = lens(snd, snd) | ||
export const nothing = lensI(snd, snd) | ||
export const orElse = | ||
R.curry((d, l) => choose(x => get(l, x) !== undefined ? l : d)) | ||
R.curry((d, l) => choose(x => getI(toRamda(l), x) !== undefined ? l : d)) | ||
export const choice = (...ls) => choose(x => { | ||
const i = ls.findIndex(l => get(l, x) !== undefined) | ||
const i = ls.findIndex(l => getI(toRamda(l), x) !== undefined) | ||
return 0 <= i ? ls[i] : nothing | ||
@@ -129,4 +150,4 @@ }) | ||
export const replace = R.curry((inn, out) => | ||
lens(x => R.equals(x, inn) ? out : x, | ||
toConserve(y => R.equals(y, out) ? inn : y))) | ||
lensI(x => R.equals(x, inn) ? out : x, | ||
toConserve(y => R.equals(y, out) ? inn : y))) | ||
@@ -138,3 +159,3 @@ export const defaults = replace(undefined) | ||
export const normalize = transform => | ||
lens(toPartial(transform), toConserve(toPartial(transform))) | ||
lensI(toPartial(transform), toConserve(toPartial(transform))) | ||
@@ -146,4 +167,4 @@ const isProp = x => typeof x === "string" | ||
const toRamdaProp = k => | ||
lens(o => o && o[k], | ||
(v, o) => v === undefined ? deleteKey(k, o) : setKey(k, v, o)) | ||
lensI(o => o && o[k], | ||
(v, o) => v === undefined ? deleteKey(k, o) : setKey(k, v, o)) | ||
@@ -159,3 +180,3 @@ export const find = predicate => choose(xs => { | ||
const lls = toRamda(compose(...ls)) | ||
return compose(find(x => R.view(lls, x) !== undefined), lls) | ||
return compose(find(x => getI(lls, x) !== undefined), lls) | ||
} | ||
@@ -167,3 +188,3 @@ | ||
const toRamdaIndex = i => lens(xs => xs && xs[i], (x, xs) => { | ||
const toRamdaIndex = i => lensI(xs => xs && xs[i], (x, xs) => { | ||
if (x === undefined) { | ||
@@ -186,9 +207,9 @@ if (xs === undefined) | ||
export const append = lens(snd, (x, xs) => | ||
export const append = lensI(snd, (x, xs) => | ||
x === undefined ? xs : xs === undefined ? [x] : xs.concat([x])) | ||
export const filter = p => lens(xs => xs && xs.filter(p), (ys, xs) => | ||
export const filter = p => lensI(xs => xs && xs.filter(p), (ys, xs) => | ||
conserve(dropped(R.concat(ys || [], (xs || []).filter(R.complement(p)))), xs)) | ||
export const augment = template => lens( | ||
export const augment = template => lensI( | ||
toPartial(x => { | ||
@@ -219,7 +240,7 @@ const z = {...x} | ||
export const pick = template => lens( | ||
export const pick = template => lensI( | ||
c => { | ||
let r | ||
for (const k in template) { | ||
const v = get(template[k], c) | ||
const v = getI(toRamda(template[k]), c) | ||
if (v !== undefined) { | ||
@@ -236,7 +257,7 @@ if (r === undefined) | ||
for (const k in template) | ||
c = set(template[k], o[k], c) | ||
c = setI(toRamda(template[k]), o[k], c) | ||
return c | ||
}) | ||
export const identity = lens(id, conserve) | ||
export const identity = lensI(id, conserve) | ||
@@ -247,4 +268,10 @@ export const props = (...ks) => pick(R.zipObj(ks, ks)) | ||
export const log = (...labels) => lens(show(...labels, "get"), show(...labels, "set")) | ||
export const log = (...labels) => | ||
lensI(show(...labels, "get"), show(...labels, "set")) | ||
export const sequence = toApplicative => target => | ||
warn("`sequence` is experimental and might be removed, renamed or changed semantically before next major release") || | ||
R.sequence(Ident, R.map(toApplicative, target)) | ||
.map(R.pipe(R.filter(x => x !== undefined), dropped)) | ||
export default compose |
@@ -217,2 +217,9 @@ import * as R from "ramda" | ||
describe("L.sequence", () => { | ||
testEq('L.modify(P("xs", L.sequence, "x", L.sequence), R.add(1), {xs: [{x: [1]}, {x: [2,3,4]}]})', {xs: [{x: [2]}, {x: [3,4,5]}]}) | ||
testEq('L.set(P("xs", L.sequence, "x", L.sequence), 101, {xs: [{x: [1]}, {x: [2,3,4]}]})', {xs: [{x: [101]}, {x: [101,101,101]}]}) | ||
testEq('L.remove(P("xs", L.sequence, "x", L.sequence), {ys: "hip", xs: [{x: [1]}, {x: [2,3,4]}]})', {ys: "hip"}) | ||
testEq('L.modify(P("xs", L.sequence, "x"), x => x < 2 ? undefined : x, {xs: [{x:3},{x:1},{x:4},{x:1,y:0},{x:5},{x:9},{x:2}]})', {xs:[{x:3},{x:4},{y:0},{x:5},{x:9},{x:2}]}) | ||
}) | ||
describe("L.pick", () => { | ||
@@ -219,0 +226,0 @@ testEq('L.get(L.pick({x: "c"}), {a: [2], b: 1})', undefined) |
Sorry, the diff of this file is not supported yet
156888
15
814
1017