diff --git a/dist/partial.lenses.cjs.js b/dist/partial.lenses.cjs.js index 1d82b4a2..1bab68e1 100644 --- a/dist/partial.lenses.cjs.js +++ b/dist/partial.lenses.cjs.js @@ -141,20 +141,32 @@ var rev = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : res(I.fre // +var isEmptyArrayStringOrObject = function isEmptyArrayStringOrObject(x) { + return I.acyclicEqualsU(I.array0, x) || I.acyclicEqualsU(I.object0, x) || x === ""; +}; + +var warnEmpty = function warnEmpty(o, v, f) { + var msg = "`" + f + "(" + JSON.stringify(v) + ")` is likely unnecessary, because combinators no longer remove empty arrays, objects, or strings by default. See CHANGELOG for more information."; + return function (x) { + if (I.acyclicEqualsU(v, x)) warn(o, msg); + return x; + }; +}; + +// + var mapPartialIndexU = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : res(I.freeze))(function (xi2y, xs) { var n = xs.length, ys = Array(n); var j = 0; for (var i = 0, y; i < n; ++i) { if (void 0 !== (y = xi2y(xs[i], i))) ys[j++] = y; - }if (j) { - if (j < n) ys.length = j; - return ys; - } + }if (j < n) ys.length = j; + return ys; }); var mapIfArrayLike = function mapIfArrayLike(xi2y, xs) { - return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) || I.array0 : void 0; + return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) : void 0; }; var copyToFrom = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : function (fn$$1) { @@ -313,36 +325,30 @@ var cons = function cons(t) { }; }; var consTo = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : res(I.freeze))(function (n) { - if (cons !== n) { - var xs = []; - do { - xs.push(n[0]); - n = n[1]; - } while (cons !== n); - return xs.reverse(); + var xs = []; + while (cons !== n) { + xs.push(n[0]); + n = n[1]; } + return xs.reverse(); }); var traversePartialIndex = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : par(0, ef(reqApplicative("elems"))))(function (A, xi2yA, xs) { var map = A.map, - ap = A.ap, - of = A.of; + ap = A.ap; - var xsA = of(cons); + var xsA = A.of(cons); var n = xs.length; - for (var i = 0; i < n; ++i) { - xsA = ap(map(cons, xsA), xi2yA(xs[i], i)); - }return map(consTo, xsA); -}); - -// - -function object0ToUndefined(o) { - if (!(o instanceof Object)) return o; - for (var k in o) { - return o; + if (map === I.sndU) { + for (var i = 0; i < n; ++i) { + xsA = ap(xsA, xi2yA(xs[i], i)); + }return xsA; + } else { + for (var _i2 = 0; _i2 < n; ++_i2) { + xsA = ap(map(cons, xsA), xi2yA(xs[_i2], _i2)); + }return map(consTo, xsA); } -} +}); // @@ -363,7 +369,7 @@ var getProp = function getProp(k, o) { }; var setProp = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : res(I.freeze))(function (k, v, o) { - return void 0 !== v ? I.assocPartialU(k, v, o) : I.dissocPartialU(k, o); + return void 0 !== v ? I.assocPartialU(k, v, o) : I.dissocPartialU(k, o) || I.object0; }); var funProp = /*#__PURE__*/lensFrom(getProp, setProp); @@ -385,17 +391,13 @@ var setIndex = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : fn(n }ys[i] = x; return ys; } else { - if (0 < n) { - if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); - if (1 < n) { - var _ys = Array(n - 1); - for (var _j = 0; _j < i; ++_j) { - _ys[_j] = xs[_j]; - }for (var _j2 = i + 1; _j2 < n; ++_j2) { - _ys[_j2 - 1] = xs[_j2]; - }return _ys; - } - } + if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); + var _ys = Array(n - 1); + for (var _j = 0; _j < i; ++_j) { + _ys[_j] = xs[_j]; + }for (var _j2 = i + 1; _j2 < n; ++_j2) { + _ys[_j2 - 1] = xs[_j2]; + }return _ys; } }); @@ -405,9 +407,8 @@ var funIndex = /*#__PURE__*/lensFrom(getIndex, setIndex); var composedMiddle = function composedMiddle(o, r) { return function (F, xi2yF) { - var n = r(F, xi2yF); - return function (x, i) { - return o(x, i, F, n); + return xi2yF = r(F, xi2yF), function (x, i) { + return o(x, i, F, xi2yF); }; }; }; @@ -591,13 +592,10 @@ var toObject$1 = function toObject$$1(x) { // var mapPartialObjectU = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : res(I.freeze))(function (xi2y, o) { - var r = void 0; + var r = {}; for (var k in o) { var v = xi2y(o[k], k); - if (void 0 !== v) { - if (void 0 === r) r = {}; - r[k] = v; - } + if (void 0 !== v) r[k] = v; } return r; }); @@ -610,23 +608,19 @@ var branchOnMerge = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : var v = xs[0]; o[keys$$1[--i]] = void 0 !== v ? v : o; } - var r = void 0; + var r = {}; x = toObject$1(x); for (var k in x) { var _v = o[k]; if (o !== _v) { o[k] = o; - if (!r) r = {}; r[k] = void 0 !== _v ? _v : x[k]; } } - for (var _i2 = 0; _i2 < n; ++_i2) { - var _k = keys$$1[_i2]; + for (var _i3 = 0; _i3 < n; ++_i3) { + var _k = keys$$1[_i3]; var _v2 = o[_k]; - if (o !== _v2) { - if (!r) r = {}; - r[_k] = _v2; - } + if (o !== _v2) r[_k] = _v2; } return r; }; @@ -643,7 +637,7 @@ var branchOn = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : dep( var of = A.of; var n = keys$$1.length; - if (!n) return of(object0ToUndefined(x)); + if (!n) return of(x); if (!(x instanceof Object)) x = I.object0; if (Select === A) { for (var i = 0; i < n; ++i) { @@ -657,10 +651,10 @@ var branchOn = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : dep( ap = A.ap; var xsA = of(cpair); - for (var _i3 = 0; _i3 < n; ++_i3) { - var _k2 = keys$$1[_i3], + for (var _i4 = 0; _i4 < n; ++_i4) { + var _k2 = keys$$1[_i4], _v3 = x[_k2]; - xsA = ap(map(cpair, xsA), vals ? vals[_i3](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); + xsA = ap(map(cpair, xsA), vals ? vals[_i4](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); } return map(branchOnMerge(x, keys$$1), xsA); } @@ -719,16 +713,19 @@ var reIndex = function reIndex(m) { return m.index; }; -function reNext(m, re) { +var reNext = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : function (fn$$1) { + return function (m, re) { + var res$$1 = fn$$1(m, re); + if ("" === res$$1) warn(reNext, "`matches(" + re + ")` traversal terminated due to empty match. `matches` traversal shouldn't be used with regular expressions that can produce empty matches."); + return res$$1; + }; +})(function (m, re) { var lastIndex = re.lastIndex; re.lastIndex = reIndex(m) + m[0].length; var n = re.exec(m.input); re.lastIndex = lastIndex; - if (n) { - if (n[0]) return n; - if (process.env.NODE_ENV !== "production") warn(reNext, "`matches(" + re + ")` traversal terminated at index " + reIndex(n) + " in " + JSON.stringify(n.input) + " due to empty match."); - } -} + return n && n[0] && n; +}); // @@ -772,13 +769,10 @@ var keyed = /*#__PURE__*/isoU(expect(instanceofObject, (process.env.NODE_ENV === es.push([key, x[key]]); }return es; })), expect(I.isArray, (process.env.NODE_ENV === "production" ? I.id : res(I.freeze))(function (es) { - var o = void 0; + var o = {}; for (var i = 0, n = es.length; i < n; ++i) { var entry = es[i]; - if (entry.length === 2) { - if (void 0 === o) o = {}; - o[entry[0]] = entry[1]; - } + if (entry.length === 2) o[entry[0]] = entry[1]; } return o; }))); @@ -801,7 +795,7 @@ var matchesJoin = function matchesJoin(input) { } result += input.slice(lastIndex); - return result || void 0; + return result; }; }; @@ -1066,7 +1060,7 @@ var matches = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : dep(f } else { var m = x.match(re); if (m) return map(function (y) { - return x.replace(re, void 0 !== y ? y : "") || void 0; + return x.replace(re, void 0 !== y ? y : ""); }, xi2yC(m[0], reIndex(m))); } } @@ -1250,20 +1244,30 @@ function defaults(out) { }; } -function define(v) { +var define = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([isoU(warnEmpty(fn$$1, inn, "define"), I.id), res$$1, isoU(I.id, warnEmpty(define, inn, "define"))]);else return res$$1; + }; +})(function (v) { var untoV = unto(v); return function (x, i, F, xi2yF) { return F.map(untoV, xi2yF(void 0 !== x ? x : v, i)); }; -} +}); var normalize = function normalize(xi2x) { return [reread(xi2x), rewrite(xi2x)]; }; -var required = function required(inn) { +var required = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([res$$1, isoU(I.id, warnEmpty(required, inn, "required"))]);else return res$$1; + }; +})(function (inn) { return replace(inn, void 0); -}; +}); var reread = function reread(xi2x) { return function (x, i, _F, xi2yF) { @@ -1299,7 +1303,7 @@ var filter = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.id : res(fu var tsN = ts ? ts.length : 0, fsN = fs ? fs.length : 0, n = tsN + fsN; - if (n) return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); + return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); }, xi2yF(ts, i)); }; }); @@ -1315,14 +1319,6 @@ function find(xih2b) { }; } -var findHint = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.curry : res(ef(function () { - warn(findHint, "`L.findHint` will be removed. Use `L.find`, which supports an optional hint."); -})))(function (xh2b, hint) { - return find(function (x, _, h) { - return xh2b(x, h); - }, hint); -}); - function findWith(o) { var oo = toFunction(o), p = isDefined$1(oo); @@ -1351,7 +1347,7 @@ var slice = /*#__PURE__*/(process.env.NODE_ENV === "production" ? I.curry : res( var zsN = zs ? zs.length : 0, bPzsN = b + zsN, n = xsN - e + bPzsN; - return n ? copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN) : void 0; + return copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN); }, xsi2yF(seems ? copyToFrom(Array(Math.max(0, e - b)), 0, xs, b, e) : void 0, i)); }; }); @@ -1478,17 +1474,15 @@ var indexed = /*#__PURE__*/isoU(expect(seemsArrayLike, (process.env.NODE_ENV === } n = xs.length; var j = 0; - for (var _i4 = 0; _i4 < n; ++_i4) { - var x = xs[_i4]; + for (var _i5 = 0; _i5 < n; ++_i5) { + var x = xs[_i5]; if (void 0 !== x) { - if (_i4 !== j) xs[j] = x; + if (_i5 !== j) xs[j] = x; ++j; } } - if (j) { - xs.length = j; - return xs; - } + xs.length = j; + return xs; }))); var is = function is(v) { @@ -1622,7 +1616,6 @@ exports.rewrite = rewrite; exports.append = append; exports.filter = filter; exports.find = find; -exports.findHint = findHint; exports.findWith = findWith; exports.index = index; exports.last = last; diff --git a/dist/partial.lenses.es.js b/dist/partial.lenses.es.js index f966ecd2..a3c0ce9f 100644 --- a/dist/partial.lenses.es.js +++ b/dist/partial.lenses.es.js @@ -137,20 +137,32 @@ var rev = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : res(freeze) // +var isEmptyArrayStringOrObject = function isEmptyArrayStringOrObject(x) { + return acyclicEqualsU(array0, x) || acyclicEqualsU(object0, x) || x === ""; +}; + +var warnEmpty = function warnEmpty(o, v, f) { + var msg = "`" + f + "(" + JSON.stringify(v) + ")` is likely unnecessary, because combinators no longer remove empty arrays, objects, or strings by default. See CHANGELOG for more information."; + return function (x) { + if (acyclicEqualsU(v, x)) warn(o, msg); + return x; + }; +}; + +// + var mapPartialIndexU = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : res(freeze))(function (xi2y, xs) { var n = xs.length, ys = Array(n); var j = 0; for (var i = 0, y; i < n; ++i) { if (void 0 !== (y = xi2y(xs[i], i))) ys[j++] = y; - }if (j) { - if (j < n) ys.length = j; - return ys; - } + }if (j < n) ys.length = j; + return ys; }); var mapIfArrayLike = function mapIfArrayLike(xi2y, xs) { - return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) || array0 : void 0; + return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) : void 0; }; var copyToFrom = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : function (fn$$1) { @@ -309,36 +321,30 @@ var cons = function cons(t) { }; }; var consTo = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : res(freeze))(function (n) { - if (cons !== n) { - var xs = []; - do { - xs.push(n[0]); - n = n[1]; - } while (cons !== n); - return xs.reverse(); + var xs = []; + while (cons !== n) { + xs.push(n[0]); + n = n[1]; } + return xs.reverse(); }); var traversePartialIndex = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : par(0, ef(reqApplicative("elems"))))(function (A, xi2yA, xs) { var map = A.map, - ap = A.ap, - of = A.of; + ap = A.ap; - var xsA = of(cons); + var xsA = A.of(cons); var n = xs.length; - for (var i = 0; i < n; ++i) { - xsA = ap(map(cons, xsA), xi2yA(xs[i], i)); - }return map(consTo, xsA); -}); - -// - -function object0ToUndefined(o) { - if (!(o instanceof Object)) return o; - for (var k in o) { - return o; + if (map === sndU) { + for (var i = 0; i < n; ++i) { + xsA = ap(xsA, xi2yA(xs[i], i)); + }return xsA; + } else { + for (var _i2 = 0; _i2 < n; ++_i2) { + xsA = ap(map(cons, xsA), xi2yA(xs[_i2], _i2)); + }return map(consTo, xsA); } -} +}); // @@ -359,7 +365,7 @@ var getProp = function getProp(k, o) { }; var setProp = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : res(freeze))(function (k, v, o) { - return void 0 !== v ? assocPartialU(k, v, o) : dissocPartialU(k, o); + return void 0 !== v ? assocPartialU(k, v, o) : dissocPartialU(k, o) || object0; }); var funProp = /*#__PURE__*/lensFrom(getProp, setProp); @@ -381,17 +387,13 @@ var setIndex = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : fn(nth }ys[i] = x; return ys; } else { - if (0 < n) { - if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); - if (1 < n) { - var _ys = Array(n - 1); - for (var _j = 0; _j < i; ++_j) { - _ys[_j] = xs[_j]; - }for (var _j2 = i + 1; _j2 < n; ++_j2) { - _ys[_j2 - 1] = xs[_j2]; - }return _ys; - } - } + if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); + var _ys = Array(n - 1); + for (var _j = 0; _j < i; ++_j) { + _ys[_j] = xs[_j]; + }for (var _j2 = i + 1; _j2 < n; ++_j2) { + _ys[_j2 - 1] = xs[_j2]; + }return _ys; } }); @@ -401,9 +403,8 @@ var funIndex = /*#__PURE__*/lensFrom(getIndex, setIndex); var composedMiddle = function composedMiddle(o, r) { return function (F, xi2yF) { - var n = r(F, xi2yF); - return function (x, i) { - return o(x, i, F, n); + return xi2yF = r(F, xi2yF), function (x, i) { + return o(x, i, F, xi2yF); }; }; }; @@ -587,13 +588,10 @@ var toObject$1 = function toObject$$1(x) { // var mapPartialObjectU = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : res(freeze))(function (xi2y, o) { - var r = void 0; + var r = {}; for (var k in o) { var v = xi2y(o[k], k); - if (void 0 !== v) { - if (void 0 === r) r = {}; - r[k] = v; - } + if (void 0 !== v) r[k] = v; } return r; }); @@ -606,23 +604,19 @@ var branchOnMerge = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : r var v = xs[0]; o[keys$$1[--i]] = void 0 !== v ? v : o; } - var r = void 0; + var r = {}; x = toObject$1(x); for (var k in x) { var _v = o[k]; if (o !== _v) { o[k] = o; - if (!r) r = {}; r[k] = void 0 !== _v ? _v : x[k]; } } - for (var _i2 = 0; _i2 < n; ++_i2) { - var _k = keys$$1[_i2]; + for (var _i3 = 0; _i3 < n; ++_i3) { + var _k = keys$$1[_i3]; var _v2 = o[_k]; - if (o !== _v2) { - if (!r) r = {}; - r[_k] = _v2; - } + if (o !== _v2) r[_k] = _v2; } return r; }; @@ -639,7 +633,7 @@ var branchOn = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : dep(fu var of = A.of; var n = keys$$1.length; - if (!n) return of(object0ToUndefined(x)); + if (!n) return of(x); if (!(x instanceof Object)) x = object0; if (Select === A) { for (var i = 0; i < n; ++i) { @@ -653,10 +647,10 @@ var branchOn = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : dep(fu ap = A.ap; var xsA = of(cpair); - for (var _i3 = 0; _i3 < n; ++_i3) { - var _k2 = keys$$1[_i3], + for (var _i4 = 0; _i4 < n; ++_i4) { + var _k2 = keys$$1[_i4], _v3 = x[_k2]; - xsA = ap(map(cpair, xsA), vals ? vals[_i3](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); + xsA = ap(map(cpair, xsA), vals ? vals[_i4](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); } return map(branchOnMerge(x, keys$$1), xsA); } @@ -715,16 +709,19 @@ var reIndex = function reIndex(m) { return m.index; }; -function reNext(m, re) { +var reNext = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : function (fn$$1) { + return function (m, re) { + var res$$1 = fn$$1(m, re); + if ("" === res$$1) warn(reNext, "`matches(" + re + ")` traversal terminated due to empty match. `matches` traversal shouldn't be used with regular expressions that can produce empty matches."); + return res$$1; + }; +})(function (m, re) { var lastIndex = re.lastIndex; re.lastIndex = reIndex(m) + m[0].length; var n = re.exec(m.input); re.lastIndex = lastIndex; - if (n) { - if (n[0]) return n; - if (process.env.NODE_ENV !== "production") warn(reNext, "`matches(" + re + ")` traversal terminated at index " + reIndex(n) + " in " + JSON.stringify(n.input) + " due to empty match."); - } -} + return n && n[0] && n; +}); // @@ -768,13 +765,10 @@ var keyed = /*#__PURE__*/isoU(expect(instanceofObject, (process.env.NODE_ENV === es.push([key, x[key]]); }return es; })), expect(isArray, (process.env.NODE_ENV === "production" ? id : res(freeze))(function (es) { - var o = void 0; + var o = {}; for (var i = 0, n = es.length; i < n; ++i) { var entry = es[i]; - if (entry.length === 2) { - if (void 0 === o) o = {}; - o[entry[0]] = entry[1]; - } + if (entry.length === 2) o[entry[0]] = entry[1]; } return o; }))); @@ -797,7 +791,7 @@ var matchesJoin = function matchesJoin(input) { } result += input.slice(lastIndex); - return result || void 0; + return result; }; }; @@ -1062,7 +1056,7 @@ var matches = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : dep(fun } else { var m = x.match(re); if (m) return map(function (y) { - return x.replace(re, void 0 !== y ? y : "") || void 0; + return x.replace(re, void 0 !== y ? y : ""); }, xi2yC(m[0], reIndex(m))); } } @@ -1246,20 +1240,30 @@ function defaults(out) { }; } -function define(v) { +var define = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([isoU(warnEmpty(fn$$1, inn, "define"), id), res$$1, isoU(id, warnEmpty(define, inn, "define"))]);else return res$$1; + }; +})(function (v) { var untoV = unto(v); return function (x, i, F, xi2yF) { return F.map(untoV, xi2yF(void 0 !== x ? x : v, i)); }; -} +}); var normalize = function normalize(xi2x) { return [reread(xi2x), rewrite(xi2x)]; }; -var required = function required(inn) { +var required = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([res$$1, isoU(id, warnEmpty(required, inn, "required"))]);else return res$$1; + }; +})(function (inn) { return replace(inn, void 0); -}; +}); var reread = function reread(xi2x) { return function (x, i, _F, xi2yF) { @@ -1295,7 +1299,7 @@ var filter = /*#__PURE__*/(process.env.NODE_ENV === "production" ? id : res(func var tsN = ts ? ts.length : 0, fsN = fs ? fs.length : 0, n = tsN + fsN; - if (n) return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); + return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); }, xi2yF(ts, i)); }; }); @@ -1311,14 +1315,6 @@ function find(xih2b) { }; } -var findHint = /*#__PURE__*/(process.env.NODE_ENV === "production" ? curry : res(ef(function () { - warn(findHint, "`L.findHint` will be removed. Use `L.find`, which supports an optional hint."); -})))(function (xh2b, hint) { - return find(function (x, _, h) { - return xh2b(x, h); - }, hint); -}); - function findWith(o) { var oo = toFunction(o), p = isDefined$1(oo); @@ -1347,7 +1343,7 @@ var slice = /*#__PURE__*/(process.env.NODE_ENV === "production" ? curry : res(fu var zsN = zs ? zs.length : 0, bPzsN = b + zsN, n = xsN - e + bPzsN; - return n ? copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN) : void 0; + return copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN); }, xsi2yF(seems ? copyToFrom(Array(Math.max(0, e - b)), 0, xs, b, e) : void 0, i)); }; }); @@ -1474,17 +1470,15 @@ var indexed = /*#__PURE__*/isoU(expect(seemsArrayLike, (process.env.NODE_ENV === } n = xs.length; var j = 0; - for (var _i4 = 0; _i4 < n; ++_i4) { - var x = xs[_i4]; + for (var _i5 = 0; _i5 < n; ++_i5) { + var x = xs[_i5]; if (void 0 !== x) { - if (_i4 !== j) xs[j] = x; + if (_i5 !== j) xs[j] = x; ++j; } } - if (j) { - xs.length = j; - return xs; - } + xs.length = j; + return xs; }))); var is = function is(v) { @@ -1540,4 +1534,4 @@ var pointer = function pointer(s) { return ts; }; -export { seemsArrayLike, toFunction, assign, modify, remove, set, transform, traverse, compose, lazy, choices, choose, iftes, orElse, chain, choice, unless, when, optional, zero, assignOp, modifyOp, setOp, removeOp, log, seq, branch, elems, entries, flatten, keys$1 as keys, matches, values, all, and, any, collectAs, collect, concatAs, concat, countIf, count, countsAs, counts, foldl, foldr, forEach, isDefined$1 as isDefined, isEmpty, joinAs, join, maximumBy, maximum, meanAs, mean, minimumBy, minimum, none, or, productAs, product, selectAs, select, sumAs, sum, get, lens, setter, foldTraversalLens, defaults, define, normalize, required, reread, rewrite, append, filter, find, findHint, findWith, index, last, prefix, slice, suffix, pickIn, prop, props, propsOf, removable, valueOr, pick, replace, getInverse, iso, array, inverse, complement, identity, indexed, is, keyed, reverse, singleton, uri, uriComponent, json, pointer }; +export { seemsArrayLike, toFunction, assign, modify, remove, set, transform, traverse, compose, lazy, choices, choose, iftes, orElse, chain, choice, unless, when, optional, zero, assignOp, modifyOp, setOp, removeOp, log, seq, branch, elems, entries, flatten, keys$1 as keys, matches, values, all, and, any, collectAs, collect, concatAs, concat, countIf, count, countsAs, counts, foldl, foldr, forEach, isDefined$1 as isDefined, isEmpty, joinAs, join, maximumBy, maximum, meanAs, mean, minimumBy, minimum, none, or, productAs, product, selectAs, select, sumAs, sum, get, lens, setter, foldTraversalLens, defaults, define, normalize, required, reread, rewrite, append, filter, find, findWith, index, last, prefix, slice, suffix, pickIn, prop, props, propsOf, removable, valueOr, pick, replace, getInverse, iso, array, inverse, complement, identity, indexed, is, keyed, reverse, singleton, uri, uriComponent, json, pointer }; diff --git a/dist/partial.lenses.js b/dist/partial.lenses.js index 7e17090f..13edfac9 100644 --- a/dist/partial.lenses.js +++ b/dist/partial.lenses.js @@ -141,20 +141,32 @@ var rev = /*#__PURE__*/(res(I.freeze))(function (xs) { // +var isEmptyArrayStringOrObject = function isEmptyArrayStringOrObject(x) { + return I.acyclicEqualsU(I.array0, x) || I.acyclicEqualsU(I.object0, x) || x === ""; +}; + +var warnEmpty = function warnEmpty(o, v, f) { + var msg = "`" + f + "(" + JSON.stringify(v) + ")` is likely unnecessary, because combinators no longer remove empty arrays, objects, or strings by default. See CHANGELOG for more information."; + return function (x) { + if (I.acyclicEqualsU(v, x)) warn(o, msg); + return x; + }; +}; + +// + var mapPartialIndexU = /*#__PURE__*/(res(I.freeze))(function (xi2y, xs) { var n = xs.length, ys = Array(n); var j = 0; for (var i = 0, y; i < n; ++i) { if (void 0 !== (y = xi2y(xs[i], i))) ys[j++] = y; - }if (j) { - if (j < n) ys.length = j; - return ys; - } + }if (j < n) ys.length = j; + return ys; }); var mapIfArrayLike = function mapIfArrayLike(xi2y, xs) { - return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) || I.array0 : void 0; + return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) : void 0; }; var copyToFrom = /*#__PURE__*/(function (fn$$1) { @@ -313,36 +325,30 @@ var cons = function cons(t) { }; }; var consTo = /*#__PURE__*/(res(I.freeze))(function (n) { - if (cons !== n) { - var xs = []; - do { - xs.push(n[0]); - n = n[1]; - } while (cons !== n); - return xs.reverse(); + var xs = []; + while (cons !== n) { + xs.push(n[0]); + n = n[1]; } + return xs.reverse(); }); var traversePartialIndex = /*#__PURE__*/(par(0, ef(reqApplicative("elems"))))(function (A, xi2yA, xs) { var map = A.map, - ap = A.ap, - of = A.of; + ap = A.ap; - var xsA = of(cons); + var xsA = A.of(cons); var n = xs.length; - for (var i = 0; i < n; ++i) { - xsA = ap(map(cons, xsA), xi2yA(xs[i], i)); - }return map(consTo, xsA); -}); - -// - -function object0ToUndefined(o) { - if (!(o instanceof Object)) return o; - for (var k in o) { - return o; + if (map === I.sndU) { + for (var i = 0; i < n; ++i) { + xsA = ap(xsA, xi2yA(xs[i], i)); + }return xsA; + } else { + for (var _i2 = 0; _i2 < n; ++_i2) { + xsA = ap(map(cons, xsA), xi2yA(xs[_i2], _i2)); + }return map(consTo, xsA); } -} +}); // @@ -363,7 +369,7 @@ var getProp = function getProp(k, o) { }; var setProp = /*#__PURE__*/(res(I.freeze))(function (k, v, o) { - return void 0 !== v ? I.assocPartialU(k, v, o) : I.dissocPartialU(k, o); + return void 0 !== v ? I.assocPartialU(k, v, o) : I.dissocPartialU(k, o) || I.object0; }); var funProp = /*#__PURE__*/lensFrom(getProp, setProp); @@ -385,17 +391,13 @@ var setIndex = /*#__PURE__*/(fn(nth(0, ef(reqIndex)), I.freeze))(function (i, x, }ys[i] = x; return ys; } else { - if (0 < n) { - if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); - if (1 < n) { - var _ys = Array(n - 1); - for (var _j = 0; _j < i; ++_j) { - _ys[_j] = xs[_j]; - }for (var _j2 = i + 1; _j2 < n; ++_j2) { - _ys[_j2 - 1] = xs[_j2]; - }return _ys; - } - } + if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); + var _ys = Array(n - 1); + for (var _j = 0; _j < i; ++_j) { + _ys[_j] = xs[_j]; + }for (var _j2 = i + 1; _j2 < n; ++_j2) { + _ys[_j2 - 1] = xs[_j2]; + }return _ys; } }); @@ -405,9 +407,8 @@ var funIndex = /*#__PURE__*/lensFrom(getIndex, setIndex); var composedMiddle = function composedMiddle(o, r) { return function (F, xi2yF) { - var n = r(F, xi2yF); - return function (x, i) { - return o(x, i, F, n); + return xi2yF = r(F, xi2yF), function (x, i) { + return o(x, i, F, xi2yF); }; }; }; @@ -591,13 +592,10 @@ var toObject$1 = function toObject$$1(x) { // var mapPartialObjectU = /*#__PURE__*/(res(I.freeze))(function (xi2y, o) { - var r = void 0; + var r = {}; for (var k in o) { var v = xi2y(o[k], k); - if (void 0 !== v) { - if (void 0 === r) r = {}; - r[k] = v; - } + if (void 0 !== v) r[k] = v; } return r; }); @@ -610,23 +608,19 @@ var branchOnMerge = /*#__PURE__*/(res(res(I.freeze)))(function (x, keys$$1) { var v = xs[0]; o[keys$$1[--i]] = void 0 !== v ? v : o; } - var r = void 0; + var r = {}; x = toObject$1(x); for (var k in x) { var _v = o[k]; if (o !== _v) { o[k] = o; - if (!r) r = {}; r[k] = void 0 !== _v ? _v : x[k]; } } - for (var _i2 = 0; _i2 < n; ++_i2) { - var _k = keys$$1[_i2]; + for (var _i3 = 0; _i3 < n; ++_i3) { + var _k = keys$$1[_i3]; var _v2 = o[_k]; - if (o !== _v2) { - if (!r) r = {}; - r[_k] = _v2; - } + if (o !== _v2) r[_k] = _v2; } return r; }; @@ -643,7 +637,7 @@ var branchOn = /*#__PURE__*/(dep(function (_ref) { var of = A.of; var n = keys$$1.length; - if (!n) return of(object0ToUndefined(x)); + if (!n) return of(x); if (!(x instanceof Object)) x = I.object0; if (Select === A) { for (var i = 0; i < n; ++i) { @@ -657,10 +651,10 @@ var branchOn = /*#__PURE__*/(dep(function (_ref) { ap = A.ap; var xsA = of(cpair); - for (var _i3 = 0; _i3 < n; ++_i3) { - var _k2 = keys$$1[_i3], + for (var _i4 = 0; _i4 < n; ++_i4) { + var _k2 = keys$$1[_i4], _v3 = x[_k2]; - xsA = ap(map(cpair, xsA), vals ? vals[_i3](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); + xsA = ap(map(cpair, xsA), vals ? vals[_i4](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); } return map(branchOnMerge(x, keys$$1), xsA); } @@ -719,16 +713,19 @@ var reIndex = function reIndex(m) { return m.index; }; -function reNext(m, re) { +var reNext = /*#__PURE__*/(function (fn$$1) { + return function (m, re) { + var res$$1 = fn$$1(m, re); + if ("" === res$$1) warn(reNext, "`matches(" + re + ")` traversal terminated due to empty match. `matches` traversal shouldn't be used with regular expressions that can produce empty matches."); + return res$$1; + }; +})(function (m, re) { var lastIndex = re.lastIndex; re.lastIndex = reIndex(m) + m[0].length; var n = re.exec(m.input); re.lastIndex = lastIndex; - if (n) { - if (n[0]) return n; - warn(reNext, "`matches(" + re + ")` traversal terminated at index " + reIndex(n) + " in " + JSON.stringify(n.input) + " due to empty match."); - } -} + return n && n[0] && n; +}); // @@ -772,13 +769,10 @@ var keyed = /*#__PURE__*/isoU(expect(instanceofObject, (res(freezeArrayOfObjects es.push([key, x[key]]); }return es; })), expect(I.isArray, (res(I.freeze))(function (es) { - var o = void 0; + var o = {}; for (var i = 0, n = es.length; i < n; ++i) { var entry = es[i]; - if (entry.length === 2) { - if (void 0 === o) o = {}; - o[entry[0]] = entry[1]; - } + if (entry.length === 2) o[entry[0]] = entry[1]; } return o; }))); @@ -801,7 +795,7 @@ var matchesJoin = function matchesJoin(input) { } result += input.slice(lastIndex); - return result || void 0; + return result; }; }; @@ -1066,7 +1060,7 @@ var matches = /*#__PURE__*/(dep(function (_ref5) { } else { var m = x.match(re); if (m) return map(function (y) { - return x.replace(re, void 0 !== y ? y : "") || void 0; + return x.replace(re, void 0 !== y ? y : ""); }, xi2yC(m[0], reIndex(m))); } } @@ -1250,20 +1244,30 @@ function defaults(out) { }; } -function define(v) { +var define = /*#__PURE__*/(function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([isoU(warnEmpty(fn$$1, inn, "define"), I.id), res$$1, isoU(I.id, warnEmpty(define, inn, "define"))]);else return res$$1; + }; +})(function (v) { var untoV = unto(v); return function (x, i, F, xi2yF) { return F.map(untoV, xi2yF(void 0 !== x ? x : v, i)); }; -} +}); var normalize = function normalize(xi2x) { return [reread(xi2x), rewrite(xi2x)]; }; -var required = function required(inn) { +var required = /*#__PURE__*/(function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([res$$1, isoU(I.id, warnEmpty(required, inn, "required"))]);else return res$$1; + }; +})(function (inn) { return replace(inn, void 0); -}; +}); var reread = function reread(xi2x) { return function (x, i, _F, xi2yF) { @@ -1299,7 +1303,7 @@ var filter = /*#__PURE__*/(res(function (lens) { var tsN = ts ? ts.length : 0, fsN = fs ? fs.length : 0, n = tsN + fsN; - if (n) return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); + return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); }, xi2yF(ts, i)); }; }); @@ -1315,14 +1319,6 @@ function find(xih2b) { }; } -var findHint = /*#__PURE__*/(res(ef(function () { - warn(findHint, "`L.findHint` will be removed. Use `L.find`, which supports an optional hint."); -})))(function (xh2b, hint) { - return find(function (x, _, h) { - return xh2b(x, h); - }, hint); -}); - function findWith(o) { var oo = toFunction(o), p = isDefined$1(oo); @@ -1351,7 +1347,7 @@ var slice = /*#__PURE__*/(res(function (lens) { var zsN = zs ? zs.length : 0, bPzsN = b + zsN, n = xsN - e + bPzsN; - return n ? copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN) : void 0; + return copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN); }, xsi2yF(seems ? copyToFrom(Array(Math.max(0, e - b)), 0, xs, b, e) : void 0, i)); }; }); @@ -1478,17 +1474,15 @@ var indexed = /*#__PURE__*/isoU(expect(seemsArrayLike, (res(freezeArrayOfObjects } n = xs.length; var j = 0; - for (var _i4 = 0; _i4 < n; ++_i4) { - var x = xs[_i4]; + for (var _i5 = 0; _i5 < n; ++_i5) { + var x = xs[_i5]; if (void 0 !== x) { - if (_i4 !== j) xs[j] = x; + if (_i5 !== j) xs[j] = x; ++j; } } - if (j) { - xs.length = j; - return xs; - } + xs.length = j; + return xs; }))); var is = function is(v) { @@ -1622,7 +1616,6 @@ exports.rewrite = rewrite; exports.append = append; exports.filter = filter; exports.find = find; -exports.findHint = findHint; exports.findWith = findWith; exports.index = index; exports.last = last; diff --git a/dist/partial.lenses.min.js b/dist/partial.lenses.min.js index 247ba3d3..6df49ef3 100644 --- a/dist/partial.lenses.min.js +++ b/dist/partial.lenses.min.js @@ -1 +1 @@ -!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("infestines")):"function"==typeof define&&define.amd?define(["exports","infestines"],r):r(n.L={},n.I)}(this,function(n,r){"use strict";function t(n,r){for(var t=0,u=r.length;t1?arguments[1]:{hint:0};return function(t,u,e,i){var o=On(t)?t:"",c=r.hint=f(r,n,o);return e.map(function(n){return K(c,n,o)},i(o[c],c))}}function m(){for(var n,r=arguments.length,t={},u=0;u>0&&0<=n||r.isString(n)},xn=r.id(function(n){switch(typeof n){case"string":return $(n);case"number":return Q(n);case"object":return e(0,n);default:return 4===n.length?n:dn(n)}}),wn=r.curry(function(n,r,t){return X([n,zr(r)],r,t)}),Un=r.curry(Y),kn=r.curry(function(n,r){return X(n,void 0,r)}),In=r.curry(X),Sn=r.curry(function(n,t){return Y(n,r.id,t)}),Rn=r.curry(P),Mn=function(n){return function(r,t,u,e){return xn(n(r,t))(r,t,u,e)}},qn=r.curry(An),En=r.curry(function(n,r){return[r,Mn(function(r,t){return void 0!==r?n(r,t):Nn})]}),Cn=function(n){return bn(n,mn,s)},Dn=Cn(r.isDefined),Nn=function(n,r,t,u){return s(n,r,t,u)},zn=function(n){return function(r,t,u,e){return s(n,t,u,e,n)}},Ln=zn(),Pn=r.id(function(){function n(u,e,i,o){return o===r?u.of:function(r){return u.chain(n(u,e,i,o+1),t[o](r,i,u,e))}}for(var r=arguments.length,t=Array(r),u=0;ur}),dr=vr(r.id),sr=r.curry(function(n,r,t){var u=0,e=0;return P(E,function(r,t){var i=n(r,t);void 0!==i&&(e+=1,u+=i)},r,t),u/e}),lr=sr(r.id),pr=L(function(n,r){return n1?r-1:0),u=1;u1?g(t,arguments[1]):g(t),r]},n.index=qr,n.last=Er,n.prefix=function(n){return Cr(0,n)},n.slice=Cr,n.suffix=function(n){return Cr(0===n?1/0:n?-n:0,void 0)},n.pickIn=Dr,n.prop=Nr,n.props=m,n.propsOf=zr,n.removable=function(){function n(n){if(!(n instanceof Object))return n;for(var t=0,e=u.length;t1?arguments[1]:{hint:0};return function(t,u,e,i){var o=jn(t)?t:"",f=r.hint=c(r,n,o);return e.map(function(n){return G(f,n,o)},i(o[f],f))}}function y(){for(var n,r=arguments.length,t={},u=0;u>0&&0<=n||r.isString(n)},On=r.id(function(n){switch(typeof n){case"string":return W(n);case"number":return H(n);case"object":return u(0,n);default:return 4===n.length?n:an(n)}}),xn=r.curry(function(n,r,t){return Q([n,zr(r)],r,t)}),Un=r.curry(V),wn=r.curry(function(n,r){return Q(n,void 0,r)}),kn=r.curry(Q),In=r.curry(function(n,t){return V(n,r.id,t)}),Sn=r.curry(z),Rn=function(n){return function(r,t,u,e){return On(n(r,t))(r,t,u,e)}},Mn=r.curry(bn),qn=r.curry(function(n,r){return[r,Rn(function(r,t){return void 0!==r?n(r,t):Dn})]}),En=function(n){return mn(n,gn,v)},Cn=En(r.isDefined),Dn=function(n,r,t,u){return v(n,r,t,u)},Nn=function(n){return function(r,t,u,e){return v(n,t,u,e,n)}},zn=Nn(),Ln=r.id(function(){function n(u,e,i,o){return o===r?u.of:function(r){return u.chain(n(u,e,i,o+1),t[o](r,i,u,e))}}for(var r=arguments.length,t=Array(r),u=0;ur}),vr=ar(r.id),dr=r.curry(function(n,r,t){var u=0,e=0;return z(M,function(r,t){var i=n(r,t);void 0!==i&&(e+=1,u+=i)},r,t),u/e}),sr=dr(r.id),lr=N(function(n,r){return n1?r-1:0),u=1;u1?h(t,arguments[1]):h(t),r]},n.index=qr,n.last=Er,n.prefix=function(n){return Cr(0,n)},n.slice=Cr,n.suffix=function(n){return Cr(0===n?1/0:n?-n:0,void 0)},n.pickIn=Dr,n.prop=Nr,n.props=y,n.propsOf=zr,n.removable=function(){function n(n){if(!(n instanceof Object))return n;for(var t=0,e=u.length;tAssociation list
  • Use L.removable.
  • -
  • Make it so that the array does not become undefined once empty. -
  • Support insertion and make it so that keys remain ordered.
    • Use L.valueOr to add the key property in case there is no matching object.
    • @@ -196,10 +192,8 @@

      Xces

      'x'.
  • -
  • Support removal so that the whole coordinate pair is removed and removing the -last one produces an empty array.
      +
    • Support removal so that the whole coordinate pair is removed.
    diff --git a/docs/index.html b/docs/index.html index b6a32d1b..4ebc9efa 100644 --- a/docs/index.html +++ b/docs/index.html @@ -198,7 +198,6 @@

    L.append ~> lens v1.0.0

  • L.filter((maybeValue, index) => testable) ~> lens v1.0.0
  • L.find((maybeValue, index, {hint: index}) => testable[, {hint: index}]) ~> lens v1.0.0
  • -
  • L.findHint((maybeValue, {hint: index}) => testable, {hint: index}) ~> lens v10.1.0
  • L.findWith(optic[, {hint: index}]) ~> optic v1.0.0
  • L.index(elemIndex) ~> lens or elemIndex v1.0.0
  • L.last ~> lens v9.8.0
  • @@ -393,7 +392,6 @@

    Let's then just compose a parameterized lens for accessing the text of titles:

    var textIn = language => L.compose(L.prop("titles"),
    -                                     L.define([]),
                                          L.normalize(R.sortBy(L.get("language"))),
                                          L.find(R.whereEq({language})),
                                          L.valueOr({language, text: ""}),
    @@ -429,7 +427,7 @@ 

    undefined:

    L.get(textIn("fi"), undefined)
     
    -

    With partial lenses, undefined is the equivalent of empty or non-existent.

    +

    With partial lenses, undefined is the equivalent of non-existent.

    Updating data

    As with ordinary lenses, we can use the same lens to update titles:

    L.set(textIn("en"), "The title", sampleTitles)
    @@ -458,22 +456,20 @@ 

    L.removable("text") part of our lens composition. It makes it so that when the text property is set to undefined, the result will be undefined rather than merely an object without the text property.

    -

    If we remove all of the titles, we get the required value:

    +

    If we remove all of the titles, we get an empty array:

    L.set(L.seq(textIn("sv"),
                 textIn("en")),
           undefined,
           sampleTitles)
     

    Above we use L.seq to run the L.set operation over both -of the focused titles. The titles property is not removed thanks to the -L.define([]) part of our lens composition. It makes it so that -when reading or writing through the lens, undefined becomes the given value.

    +of the focused titles.

    Exercises

    -

    Take out one (or more) L.define(...), -L.normalize(...), L.valueOr(...) or -L.removable(...) part(s) from the lens composition and try to -predict what happens when you rerun the examples with the modified lens -composition. Verify your reasoning by actually rerunning the examples.

    +

    Take out one (or more) L.normalize(...), +L.valueOr(...) or L.removable(...) part(s) +from the lens composition and try to predict what happens when you rerun the +examples with the modified lens composition. Verify your reasoning by actually +rerunning the examples.

    Shorthands

    For clarity, the previous code snippets avoided some of the shorthands that this library supports. In particular,

    @@ -488,7 +484,6 @@

    L.compose(L.prop("titles"), - L.define([]), L.normalize(R.sortBy(L.get("language"))), L.find(R.whereEq({language})), L.valueOr({language, text: ""}), @@ -515,7 +510,6 @@

    ▶ play with the laws in your browser.

    -

    Note, however, that partial lenses are not (total) lenses. To support -propagating removal, partial lenses treat empty objects, {}, and empty arrays, -[], as equivalent to undefined in certain contexts. You need to account for -this behaviour in laws or adjust the behaviour using combinators like -L.define.

    +

    Note, however, that partial lenses are not (total) lenses. undefined is +given special meaning and should not appear in the manipulated data.

    Myth: Partial Lenses are not lawful

    For some reason there seems to be a persistent myth that partial lenses cannot obey lens laws. The @@ -855,10 +846,7 @@

    Put-Get law. Does this make the L.find combinator useless? Far from it.

    Consider the following lens:

    -
    var valOf = key => [L.define([]),
    -                      L.find(R.whereEq({key})),
    -                      L.defaults({key}),
    -                      "val"]
    +
    var valOf = key => [L.find(R.whereEq({key})), L.defaults({key}), "val"]
     

    The valOf lens constructor is for accessing association arrays that contain {key, val} pairs. For example:

    @@ -885,8 +873,8 @@
    supposed to work on valid association arrays. A valid association array must not contain duplicate keys, undefined is not valid val, and the order of elements is not significant. (Note that you could also add -L.rewrite(R.sortBy(L.get("key"))) to the composition after -L.define([]) to ensure that elements stay in the same order.)

    +L.rewrite(R.sortBy(L.get("key"))) to the composition to ensure +that elements stay in the same order.)

    The gist of this example is important. Even if it is the case that not all parts of a lens composition obey lens laws, it can be that a composition taken as a whole obeys lens laws. The reason why this use of L.find @@ -911,7 +899,7 @@

    L.remove(optic, maybeData) ~> maybeData v2.0.0

    L.remove allows one to remove the elements focused on by the given optic.

    For example:

    -
    L.remove([0, "x"], [{x: 1}, {x: 2}, {x: 3}])
    +
    L.remove([0, L.defaults({}), "x"], [{x: 1}, {x: 2}, {x: 3}])
     
    L.remove([L.elems, "x", L.when(x => x > 1)], [{x: 1}, {x: 2, y: 1}, {x: 3}])
     
    @@ -1376,8 +1364,6 @@
    L.set(["items", L.defaults([])], [], {items: [1, 2, 3]})
    -

    Note that L.defaults(valueIn) is equivalent -to L.replace(undefined, valueIn).

    +

    Note that L.defaults(valueIn) is equivalent to L.replace(undefined, +valueIn).

    L.define(value) ~> lens v1.0.0

    L.define is used to specify a value to act as both the default value and the required value for an element.

    @@ -1788,11 +1774,9 @@
    L.remove(["items", 0], {items: [1]}) +
    L.remove(["item"], {item: 1})
     
    -
    L.remove([L.required({}), "items", 0], {items: [1]})
    -
    -
    L.remove(["items", L.required([]), 0], {items: [1]})
    +
    L.remove(["item", L.required(null)], {item: 1})
     

    Note that L.required(valueOut) is equivalent to L.replace(valueOut, undefined).

    @@ -1810,8 +1794,7 @@

    Lensing array-like objects

    considered Object instances in JavaScript, are considered array-like objects by partial optics. See also L.seemsArrayLike.

    When writing through a lens or traversal that operates on array-like objects, -the result is always either undefined, in case the result would be empty, or a -plain Array. For example:

    +the result is always a plain Array. For example:

    L.set(1, "a", "LoLa")
     

    It may seem like the result should be of the same type as the object being @@ -1848,8 +1831,7 @@

    L.set(L.filter(x => x <= "2"), "abcd", "3141592")
    @@ -1893,11 +1875,6 @@
    here for discussion and an example.

    -
    L.findHint((maybeValue, {hint: index}) => testable, {hint: index}) ~> lens v10.1.0
    -

    WARNING: L.findHint will be removed. Use L.find, which -supports an optional hint.

    -

    L.findHint is a wrapper around L.find and is provided to ease -transitioning. Use L.find in new code.

    L.findWith(optic[, {hint: index}]) ~> optic v1.0.0

    L.findWith chooses an index from an array-like object through which the given optic has a non-undefined view and then returns an optic that @@ -1913,43 +1890,15 @@

    L.set(2, "z", ["x", "y", "c"])
    -

    NOTE: There is a gotcha related to removing elements from array-like -objects. Namely, when the last element is removed, the result is undefined -rather than an empty array. This is by design, because this allows the removal -to propagate upwards. It is not uncommon, however, to have cases where removing -the last element from an array-like object must not remove the array itself. -Consider the following examples without L.required([]):

    -
    L.remove(0, ["a", "b"])
    -
    -
    L.remove(0, ["b"])
    -
    -
    L.remove(["elems", 0], {elems: ["b"], some: "thing"})
    -
    -

    Then consider the same examples with L.required([]):

    -
    L.remove([L.required([]), 0], ["a", "b"])
    -
    -
    L.remove([L.required([]), 0], ["b"])
    +
    L.remove(0, ["x"])
     
    -
    L.remove(["elems", L.required([]), 0], {elems: ["b"], some: "thing"})
    -
    -

    There is a related gotcha with L.required. Consider the -following example:

    -
    L.remove(L.required([]), [])
    -
    -
    L.get(L.required([]), [])
    -
    -

    In other words, L.required works in both directions. Thanks to -the handling of undefined within partial lenses, this is often not a problem, -but sometimes you need the "default" value both ways. In that case you can use -L.define.

    L.last ~> lens v9.8.0

    L.last focuses on the last element of an array-like object or works like L.append in case no such element exists.

    @@ -2019,9 +1968,8 @@
    Lensing objects

    Anything that is an instanceof Object is considered an object by partial lenses.

    -

    When writing through an optic that operates on objects, the result is always -either undefined, in case the result would be empty, or a plain Object. For -example:

    +

    When writing through an optic that operates on objects, the result is always a +plain Object. For example:

    function Custom(gold, silver, bronze) {
       this.gold   = gold
       this.silver = silver
    @@ -2059,8 +2007,7 @@ 
    L.props(...propNames) ~> lens v1.4.0

    L.props 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 +none of the properties is defined. This allows L.props to be used with +e.g. L.choices. 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 missing properties are removed if they did exists previously. When set, any extra properties are ignored.

    @@ -2097,8 +2045,6 @@
    L.remove([L.removable("x"), "x"], {x: 1, y: 2})
    -

    Note that L.removable(...ps) is roughly equivalent to rewrite(y => y -instanceof Object && !L.get(L.props(...ps), y) ? undefined : y).

    Also note that, in a composition, L.removable is likely preceded by L.valueOr (or L.defaults) like in the tutorial example. In such a pair, the preceding lens gives a @@ -2119,8 +2065,6 @@

    Providing defaults
    L.valueOr(valueOut) ~> lens v3.5.0

    L.valueOr is an asymmetric lens used to specify a default value in case the @@ -2137,11 +2081,12 @@

    L.pick({prop: lens, ...props}) ~> lens v1.2.0

    L.pick creates a lens out of the given possibly nested object template of 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 -properties of the object are set to the context via the lenses of the template. -undefined is treated as the equivalent of empty or non-existent in both -directions.

    +together. When viewed, undefined properties are not added to the result and +if the result would be an empty object, the result will be undefined. This +allows L.pick to be used with e.g. L.choices. Otherwise an +object is created, whose properties are obtained by viewing through the lenses +of the template. When set with an object, the 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:

    var sampleFlat = {px: 1, py: 2, vx: 1, vy: 0}
    @@ -2253,12 +2198,7 @@ 
    L.getInverse(L.array(L.pick({x: "y", z: "x"})), [{x:2, z:1}, {x:4, z:3}])

    Elements mapped to undefined by the isomorphism on elements are removed from -the resulting array in both directions. However, unlike with lenses operating -on elements or slices of arrays, an empty array is not implicitly -converted to undefined. You can pre compose with -L.defaults([]) and post compose with -L.required([]) to convert empty arrays to undefined if -desired.

    +the resulting array in both directions.

    L.inverse(isomorphism) ~> isomorphism v4.1.0

    L.inverse returns the inverse of the given isomorphism. Note that this operation only makes sense on isomorphisms.

    @@ -2557,17 +2497,15 @@

    var sampleList = Immutable.List(["a", "l", "i", "s", "t"]) L.get(idxList(2), sampleList) @@ -2575,13 +2513,9 @@

    L.modify(idxList(1), R.toUpper, sampleList)

    -

    Remove existing elements:

    +

    And remove existing elements:

    L.remove(idxList(0), sampleList)
     
    -

    And removing the last element propagates removal:

    -
    L.remove(["elems", idxList(0)],
    -         {elems: Immutable.List(["x"]), look: "No elems!"})
    -

    We can also create lists from non-lists:

    L.set(idxList(0), "x", undefined)
     
    diff --git a/docs/partial.lenses.js b/docs/partial.lenses.js index 7e17090f..13edfac9 100644 --- a/docs/partial.lenses.js +++ b/docs/partial.lenses.js @@ -141,20 +141,32 @@ var rev = /*#__PURE__*/(res(I.freeze))(function (xs) { // +var isEmptyArrayStringOrObject = function isEmptyArrayStringOrObject(x) { + return I.acyclicEqualsU(I.array0, x) || I.acyclicEqualsU(I.object0, x) || x === ""; +}; + +var warnEmpty = function warnEmpty(o, v, f) { + var msg = "`" + f + "(" + JSON.stringify(v) + ")` is likely unnecessary, because combinators no longer remove empty arrays, objects, or strings by default. See CHANGELOG for more information."; + return function (x) { + if (I.acyclicEqualsU(v, x)) warn(o, msg); + return x; + }; +}; + +// + var mapPartialIndexU = /*#__PURE__*/(res(I.freeze))(function (xi2y, xs) { var n = xs.length, ys = Array(n); var j = 0; for (var i = 0, y; i < n; ++i) { if (void 0 !== (y = xi2y(xs[i], i))) ys[j++] = y; - }if (j) { - if (j < n) ys.length = j; - return ys; - } + }if (j < n) ys.length = j; + return ys; }); var mapIfArrayLike = function mapIfArrayLike(xi2y, xs) { - return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) || I.array0 : void 0; + return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs) : void 0; }; var copyToFrom = /*#__PURE__*/(function (fn$$1) { @@ -313,36 +325,30 @@ var cons = function cons(t) { }; }; var consTo = /*#__PURE__*/(res(I.freeze))(function (n) { - if (cons !== n) { - var xs = []; - do { - xs.push(n[0]); - n = n[1]; - } while (cons !== n); - return xs.reverse(); + var xs = []; + while (cons !== n) { + xs.push(n[0]); + n = n[1]; } + return xs.reverse(); }); var traversePartialIndex = /*#__PURE__*/(par(0, ef(reqApplicative("elems"))))(function (A, xi2yA, xs) { var map = A.map, - ap = A.ap, - of = A.of; + ap = A.ap; - var xsA = of(cons); + var xsA = A.of(cons); var n = xs.length; - for (var i = 0; i < n; ++i) { - xsA = ap(map(cons, xsA), xi2yA(xs[i], i)); - }return map(consTo, xsA); -}); - -// - -function object0ToUndefined(o) { - if (!(o instanceof Object)) return o; - for (var k in o) { - return o; + if (map === I.sndU) { + for (var i = 0; i < n; ++i) { + xsA = ap(xsA, xi2yA(xs[i], i)); + }return xsA; + } else { + for (var _i2 = 0; _i2 < n; ++_i2) { + xsA = ap(map(cons, xsA), xi2yA(xs[_i2], _i2)); + }return map(consTo, xsA); } -} +}); // @@ -363,7 +369,7 @@ var getProp = function getProp(k, o) { }; var setProp = /*#__PURE__*/(res(I.freeze))(function (k, v, o) { - return void 0 !== v ? I.assocPartialU(k, v, o) : I.dissocPartialU(k, o); + return void 0 !== v ? I.assocPartialU(k, v, o) : I.dissocPartialU(k, o) || I.object0; }); var funProp = /*#__PURE__*/lensFrom(getProp, setProp); @@ -385,17 +391,13 @@ var setIndex = /*#__PURE__*/(fn(nth(0, ef(reqIndex)), I.freeze))(function (i, x, }ys[i] = x; return ys; } else { - if (0 < n) { - if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); - if (1 < n) { - var _ys = Array(n - 1); - for (var _j = 0; _j < i; ++_j) { - _ys[_j] = xs[_j]; - }for (var _j2 = i + 1; _j2 < n; ++_j2) { - _ys[_j2 - 1] = xs[_j2]; - }return _ys; - } - } + if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n); + var _ys = Array(n - 1); + for (var _j = 0; _j < i; ++_j) { + _ys[_j] = xs[_j]; + }for (var _j2 = i + 1; _j2 < n; ++_j2) { + _ys[_j2 - 1] = xs[_j2]; + }return _ys; } }); @@ -405,9 +407,8 @@ var funIndex = /*#__PURE__*/lensFrom(getIndex, setIndex); var composedMiddle = function composedMiddle(o, r) { return function (F, xi2yF) { - var n = r(F, xi2yF); - return function (x, i) { - return o(x, i, F, n); + return xi2yF = r(F, xi2yF), function (x, i) { + return o(x, i, F, xi2yF); }; }; }; @@ -591,13 +592,10 @@ var toObject$1 = function toObject$$1(x) { // var mapPartialObjectU = /*#__PURE__*/(res(I.freeze))(function (xi2y, o) { - var r = void 0; + var r = {}; for (var k in o) { var v = xi2y(o[k], k); - if (void 0 !== v) { - if (void 0 === r) r = {}; - r[k] = v; - } + if (void 0 !== v) r[k] = v; } return r; }); @@ -610,23 +608,19 @@ var branchOnMerge = /*#__PURE__*/(res(res(I.freeze)))(function (x, keys$$1) { var v = xs[0]; o[keys$$1[--i]] = void 0 !== v ? v : o; } - var r = void 0; + var r = {}; x = toObject$1(x); for (var k in x) { var _v = o[k]; if (o !== _v) { o[k] = o; - if (!r) r = {}; r[k] = void 0 !== _v ? _v : x[k]; } } - for (var _i2 = 0; _i2 < n; ++_i2) { - var _k = keys$$1[_i2]; + for (var _i3 = 0; _i3 < n; ++_i3) { + var _k = keys$$1[_i3]; var _v2 = o[_k]; - if (o !== _v2) { - if (!r) r = {}; - r[_k] = _v2; - } + if (o !== _v2) r[_k] = _v2; } return r; }; @@ -643,7 +637,7 @@ var branchOn = /*#__PURE__*/(dep(function (_ref) { var of = A.of; var n = keys$$1.length; - if (!n) return of(object0ToUndefined(x)); + if (!n) return of(x); if (!(x instanceof Object)) x = I.object0; if (Select === A) { for (var i = 0; i < n; ++i) { @@ -657,10 +651,10 @@ var branchOn = /*#__PURE__*/(dep(function (_ref) { ap = A.ap; var xsA = of(cpair); - for (var _i3 = 0; _i3 < n; ++_i3) { - var _k2 = keys$$1[_i3], + for (var _i4 = 0; _i4 < n; ++_i4) { + var _k2 = keys$$1[_i4], _v3 = x[_k2]; - xsA = ap(map(cpair, xsA), vals ? vals[_i3](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); + xsA = ap(map(cpair, xsA), vals ? vals[_i4](_v3, _k2, A, xi2yA) : xi2yA(_v3, _k2)); } return map(branchOnMerge(x, keys$$1), xsA); } @@ -719,16 +713,19 @@ var reIndex = function reIndex(m) { return m.index; }; -function reNext(m, re) { +var reNext = /*#__PURE__*/(function (fn$$1) { + return function (m, re) { + var res$$1 = fn$$1(m, re); + if ("" === res$$1) warn(reNext, "`matches(" + re + ")` traversal terminated due to empty match. `matches` traversal shouldn't be used with regular expressions that can produce empty matches."); + return res$$1; + }; +})(function (m, re) { var lastIndex = re.lastIndex; re.lastIndex = reIndex(m) + m[0].length; var n = re.exec(m.input); re.lastIndex = lastIndex; - if (n) { - if (n[0]) return n; - warn(reNext, "`matches(" + re + ")` traversal terminated at index " + reIndex(n) + " in " + JSON.stringify(n.input) + " due to empty match."); - } -} + return n && n[0] && n; +}); // @@ -772,13 +769,10 @@ var keyed = /*#__PURE__*/isoU(expect(instanceofObject, (res(freezeArrayOfObjects es.push([key, x[key]]); }return es; })), expect(I.isArray, (res(I.freeze))(function (es) { - var o = void 0; + var o = {}; for (var i = 0, n = es.length; i < n; ++i) { var entry = es[i]; - if (entry.length === 2) { - if (void 0 === o) o = {}; - o[entry[0]] = entry[1]; - } + if (entry.length === 2) o[entry[0]] = entry[1]; } return o; }))); @@ -801,7 +795,7 @@ var matchesJoin = function matchesJoin(input) { } result += input.slice(lastIndex); - return result || void 0; + return result; }; }; @@ -1066,7 +1060,7 @@ var matches = /*#__PURE__*/(dep(function (_ref5) { } else { var m = x.match(re); if (m) return map(function (y) { - return x.replace(re, void 0 !== y ? y : "") || void 0; + return x.replace(re, void 0 !== y ? y : ""); }, xi2yC(m[0], reIndex(m))); } } @@ -1250,20 +1244,30 @@ function defaults(out) { }; } -function define(v) { +var define = /*#__PURE__*/(function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([isoU(warnEmpty(fn$$1, inn, "define"), I.id), res$$1, isoU(I.id, warnEmpty(define, inn, "define"))]);else return res$$1; + }; +})(function (v) { var untoV = unto(v); return function (x, i, F, xi2yF) { return F.map(untoV, xi2yF(void 0 !== x ? x : v, i)); }; -} +}); var normalize = function normalize(xi2x) { return [reread(xi2x), rewrite(xi2x)]; }; -var required = function required(inn) { +var required = /*#__PURE__*/(function (fn$$1) { + return function (inn) { + var res$$1 = fn$$1(inn); + if (isEmptyArrayStringOrObject(inn)) return toFunction([res$$1, isoU(I.id, warnEmpty(required, inn, "required"))]);else return res$$1; + }; +})(function (inn) { return replace(inn, void 0); -}; +}); var reread = function reread(xi2x) { return function (x, i, _F, xi2yF) { @@ -1299,7 +1303,7 @@ var filter = /*#__PURE__*/(res(function (lens) { var tsN = ts ? ts.length : 0, fsN = fs ? fs.length : 0, n = tsN + fsN; - if (n) return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); + return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN); }, xi2yF(ts, i)); }; }); @@ -1315,14 +1319,6 @@ function find(xih2b) { }; } -var findHint = /*#__PURE__*/(res(ef(function () { - warn(findHint, "`L.findHint` will be removed. Use `L.find`, which supports an optional hint."); -})))(function (xh2b, hint) { - return find(function (x, _, h) { - return xh2b(x, h); - }, hint); -}); - function findWith(o) { var oo = toFunction(o), p = isDefined$1(oo); @@ -1351,7 +1347,7 @@ var slice = /*#__PURE__*/(res(function (lens) { var zsN = zs ? zs.length : 0, bPzsN = b + zsN, n = xsN - e + bPzsN; - return n ? copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN) : void 0; + return copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN); }, xsi2yF(seems ? copyToFrom(Array(Math.max(0, e - b)), 0, xs, b, e) : void 0, i)); }; }); @@ -1478,17 +1474,15 @@ var indexed = /*#__PURE__*/isoU(expect(seemsArrayLike, (res(freezeArrayOfObjects } n = xs.length; var j = 0; - for (var _i4 = 0; _i4 < n; ++_i4) { - var x = xs[_i4]; + for (var _i5 = 0; _i5 < n; ++_i5) { + var x = xs[_i5]; if (void 0 !== x) { - if (_i4 !== j) xs[j] = x; + if (_i5 !== j) xs[j] = x; ++j; } } - if (j) { - xs.length = j; - return xs; - } + xs.length = j; + return xs; }))); var is = function is(v) { @@ -1622,7 +1616,6 @@ exports.rewrite = rewrite; exports.append = append; exports.filter = filter; exports.find = find; -exports.findHint = findHint; exports.findWith = findWith; exports.index = index; exports.last = last; diff --git a/package-lock.json b/package-lock.json index d579c504..3adcc9a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "partial.lenses", - "version": "12.1.0", + "version": "13.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -34,12 +34,14 @@ } }, "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz", + "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=", "dev": true, "requires": { "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "json-schema-traverse": "0.3.1", "json-stable-stringify": "1.0.1" } }, @@ -234,7 +236,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -1110,9 +1112,9 @@ "dev": true }, "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", "dev": true }, "chalk": { @@ -1173,13 +1175,13 @@ "dev": true }, "codecov": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-2.3.0.tgz", - "integrity": "sha1-rSWixuBELRN0DZ1N27mj4nFDMPQ=", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/codecov/-/codecov-2.3.1.tgz", + "integrity": "sha1-fdqUXNWKH2CBAltbA+4Bou8g+G4=", "dev": true, "requires": { "argv": "0.0.2", - "request": "2.81.0", + "request": "2.77.0", "urlgrey": "0.4.4" } }, @@ -1363,9 +1365,9 @@ "dev": true }, "eslint": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.8.0.tgz", - "integrity": "sha1-Ip7w41Tg5h2DfHqA/fuoJeGZgV4=", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.9.0.tgz", + "integrity": "sha1-doedJ0BoJhsZH+Dy9Wx0wvQgjos=", "dev": true, "requires": { "ajv": "5.2.3", @@ -1407,18 +1409,6 @@ "text-table": "0.2.0" }, "dependencies": { - "ajv": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz", - "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=", - "dev": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "json-schema-traverse": "0.3.1", - "json-stable-stringify": "1.0.1" - } - }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", @@ -2607,6 +2597,21 @@ "globule": "1.2.0" } }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "dev": true + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "dev": true, + "requires": { + "is-property": "1.0.2" + } + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -2706,20 +2711,16 @@ "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, - "har-schema": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", - "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", - "dev": true - }, "har-validator": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", + "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", "dev": true, "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" + "chalk": "1.1.3", + "commander": "2.11.0", + "is-my-json-valid": "2.16.1", + "pinkie-promise": "2.0.1" } }, "has-ansi": { @@ -2970,6 +2971,18 @@ "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", "dev": true }, + "is-my-json-valid": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz", + "integrity": "sha512-ochPsqWS1WXj8ZnMIV0vnNXooaMhp7cyL4FMSIPKTtnV0Ha/T19G2b9kkhcNsabV9bxYkze7/aLZJb/bYuFduQ==", + "dev": true, + "requires": { + "generate-function": "2.0.0", + "generate-object-property": "1.2.0", + "jsonpointer": "4.0.1", + "xtend": "4.0.1" + } + }, "is-number": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", @@ -3021,6 +3034,12 @@ "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "dev": true + }, "is-resolvable": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", @@ -3137,6 +3156,12 @@ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "dev": true + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -3350,6 +3375,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "node-uuid": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", + "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", + "dev": true + }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -5125,12 +5156,6 @@ "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", "dev": true }, - "performance-now": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", - "dev": true - }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -5177,9 +5202,9 @@ "dev": true }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=", + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", "dev": true }, "process-nextick-args": { @@ -5207,9 +5232,9 @@ "dev": true }, "qs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz", + "integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw=", "dev": true }, "ramda": { @@ -5369,33 +5394,31 @@ } }, "request": { - "version": "2.81.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "version": "2.77.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.77.0.tgz", + "integrity": "sha1-KwDYIDDt7cyXCJ/6XYgQqcKqMUs=", "dev": true, "requires": { "aws-sign2": "0.6.0", "aws4": "1.6.0", - "caseless": "0.12.0", + "caseless": "0.11.0", "combined-stream": "1.0.5", "extend": "3.0.1", "forever-agent": "0.6.1", "form-data": "2.1.4", - "har-validator": "4.2.1", + "har-validator": "2.0.6", "hawk": "3.1.3", "http-signature": "1.1.1", "is-typedarray": "1.0.0", "isstream": "0.1.2", "json-stringify-safe": "5.0.1", "mime-types": "2.1.17", + "node-uuid": "1.4.8", "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.1.1", + "qs": "6.3.2", "stringstream": "0.0.5", "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" + "tunnel-agent": "0.4.3" } }, "require-uncached": { @@ -5726,18 +5749,6 @@ "string-width": "2.1.1" }, "dependencies": { - "ajv": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz", - "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=", - "dev": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "json-schema-traverse": "0.3.1", - "json-stable-stringify": "1.0.1" - } - }, "ansi-styles": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", @@ -5818,13 +5829,10 @@ "dev": true }, "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", + "dev": true }, "tweetnacl": { "version": "0.14.5", @@ -5882,12 +5890,6 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", - "dev": true - }, "v8flags": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", @@ -5984,6 +5986,12 @@ "ultron": "1.0.2" } }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", diff --git a/package.json b/package.json index 2e9235e1..743b12ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "partial.lenses", - "version": "12.1.0", + "version": "13.0.0", "description": "Partial lenses is a comprehensive, high-performance optics library for JavaScript", "module": "dist/partial.lenses.es.js", "main": "dist/partial.lenses.cjs.js", @@ -69,8 +69,8 @@ "babel-polyfill": "^6.26.0", "babel-register": "^6.26.0", "benchmark": "^2.1.4", - "codecov": "^2.3.0", - "eslint": "^4.8.0", + "codecov": "^2.3.1", + "eslint": "^4.9.0", "livereload": "^0.6.2", "mocha": "^4.0.1", "nyc": "^11.2.1",