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 2.2.1 to 3.0.0

.nyc_output/33944.json

11

CHANGELOG.md
# Changelog
## 3.0.0
Dropped *implicit* Ramda compatibility. To interop with Ramda, one must now
explicitly convert lenses using `L.toRamda` and `L.fromRamda`. In particular,
`L.compose` no longer necessarily returns a Ramda compatible lens and, in the
future, the implementation may be changed more drastically. This change was
made, because now a lens returned by `L.compose` can take less memory and it
will also be possible to further optimize the implementation in the future.
Removed deprecated functions `L.view`, `L.over` and `L.firstOf`.
## 2.2.0

@@ -4,0 +15,0 @@

166

lib/partial.lenses.js

@@ -6,13 +6,11 @@ "use strict";

});
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.firstOf = exports.choice = exports.orElse = exports.nothing = exports.choose = exports.view = exports.get = exports.set = exports.over = exports.modify = exports.lens = exports.removeAll = exports.remove = exports.compose = exports.lift = undefined;
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.get = exports.set = exports.modify = exports.lens = exports.removeAll = exports.remove = exports.compose = exports.toRamda = exports.fromRamda = undefined;
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; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _ramda = require("ramda");
var _ramda2 = _interopRequireDefault(_ramda);
var R = _interopRequireWildcard(_ramda);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -25,11 +23,21 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

var warned = {};
var id = function id(x) {
return x;
};
var snd = function snd(_, c) {
return c;
};
var deprecated = function deprecated(message) {
if (!(message in warned)) {
warned[message] = message;
console.warn("partial.lenses:", message);
}
//
var check = function check(expected, predicate) {
return function (x) {
if (predicate(x)) return x;else throw new Error("Expected " + expected + ", but got " + x + ".");
};
};
var assert = process.env.NODE_ENV === "production" ? function () {
return id;
} : check;
//

@@ -53,3 +61,3 @@

if (o === undefined) return _defineProperty({}, k, v);
if (k in o && _ramda2.default.equals(v, o[k])) return o;
if (k in o && R.equals(v, o[k])) return o;
var r = _defineProperty({}, k, v);

@@ -78,3 +86,3 @@ for (var p in o) {

var conserve = function conserve(c1, c0) {
return _ramda2.default.equals(c1, c0) ? c0 : c1;
return R.equals(c1, c0) ? c0 : c1;
};

@@ -90,17 +98,12 @@

var snd = function snd(_, c) {
return c;
var seemsLens = function seemsLens(x) {
return typeof x === "function" && x.length === 1;
};
//
var fromRamda = exports.fromRamda = assert("a lens", seemsLens);
var lift = exports.lift = function lift(l) {
switch (typeof l === "undefined" ? "undefined" : _typeof(l)) {
case "string":
return prop(l);
case "number":
return index(l);
default:
return l;
}
var toRamda = exports.toRamda = function toRamda(l) {
if (isProp(l)) return toRamdaProp(l);
if (isIndex(l)) return toRamdaIndex(l);
return fromRamda(l);
};

@@ -113,10 +116,10 @@

return ls.length === 0 ? identity : ls.length === 1 ? lift(ls[0]) : _ramda2.default.compose.apply(_ramda2.default, _toConsumableArray(ls.map(lift)));
return ls.length === 0 ? identity : ls.length === 1 ? ls[0] : R.compose.apply(R, _toConsumableArray(ls.map(toRamda)));
};
var remove = exports.remove = _ramda2.default.curry(function (l, s) {
return _ramda2.default.set(lift(l), undefined, s);
var remove = exports.remove = R.curry(function (l, s) {
return R.set(toRamda(l), undefined, s);
});
var removeAll = exports.removeAll = _ramda2.default.curry(function (lens, data) {
var removeAll = exports.removeAll = R.curry(function (lens, data) {
while (get(lens, data) !== undefined) {

@@ -127,18 +130,12 @@ data = remove(lens, data);

var lens = exports.lens = _ramda2.default.lens;
var modify = exports.modify = _ramda2.default.curry(function (l, x2x, s) {
return _ramda2.default.over(lift(l), x2x, s);
var lens = exports.lens = R.lens;
var modify = exports.modify = R.curry(function (l, x2x, s) {
return R.over(toRamda(l), x2x, s);
});
var over = exports.over = _ramda2.default.curry(function (l, x2x, s) {
return deprecated("`over` has been deprecated --- use `modify`") || _ramda2.default.over(lift(l), x2x, s);
var set = exports.set = R.curry(function (l, x, s) {
return R.set(toRamda(l), x, s);
});
var set = exports.set = _ramda2.default.curry(function (l, x, s) {
return _ramda2.default.set(lift(l), x, s);
var get = exports.get = R.curry(function (l, s) {
return R.view(toRamda(l), s);
});
var get = exports.get = _ramda2.default.curry(function (l, s) {
return _ramda2.default.view(lift(l), s);
});
var view = exports.view = _ramda2.default.curry(function (l, s) {
return deprecated("`view` has been deprecated --- use `get`") || _ramda2.default.view(lift(l), s);
});

@@ -148,6 +145,6 @@ var choose = exports.choose = function choose(x2yL) {

return function (target) {
var l = lift(x2yL(target));
return _ramda2.default.map(function (focus) {
return _ramda2.default.set(l, focus, target);
}, toFunctor(_ramda2.default.view(l, target)));
var l = toRamda(x2yL(target));
return R.map(function (focus) {
return R.set(l, focus, target);
}, toFunctor(R.view(l, target)));
};

@@ -159,3 +156,3 @@ };

var orElse = exports.orElse = _ramda2.default.curry(function (d, l) {
var orElse = exports.orElse = R.curry(function (d, l) {
return choose(function (x) {

@@ -179,15 +176,7 @@ return get(l, x) !== undefined ? l : d;

var firstOf = exports.firstOf = function firstOf(l) {
for (var _len3 = arguments.length, ls = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
ls[_key3 - 1] = arguments[_key3];
}
return deprecated("`firstOf` has been deprecated --- use `choice` and `orElse`") || orElse(l, choice.apply(undefined, [l].concat(ls)));
};
var replace = exports.replace = _ramda2.default.curry(function (inn, out) {
return _ramda2.default.lens(function (x) {
return _ramda2.default.equals(x, inn) ? out : x;
var replace = exports.replace = R.curry(function (inn, out) {
return lens(function (x) {
return R.equals(x, inn) ? out : x;
}, toConserve(function (y) {
return _ramda2.default.equals(y, out) ? inn : y;
return R.equals(y, out) ? inn : y;
}));

@@ -201,11 +190,17 @@ });

var define = exports.define = function define(v) {
return _ramda2.default.compose(required(v), defaults(v));
return R.compose(required(v), defaults(v));
};
var normalize = exports.normalize = function normalize(transform) {
return _ramda2.default.lens(toPartial(transform), toConserve(toPartial(transform)));
return lens(toPartial(transform), toConserve(toPartial(transform)));
};
var prop = exports.prop = function prop(k) {
return _ramda2.default.lens(function (o) {
var isProp = function isProp(x) {
return typeof x === "string";
};
var prop = exports.prop = assert("a string", isProp);
var toRamdaProp = function toRamdaProp(k) {
return lens(function (o) {
return o && o[k];

@@ -225,15 +220,17 @@ }, function (v, o) {

var findWith = exports.findWith = function findWith(l) {
for (var _len4 = arguments.length, ls = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
ls[_key4 - 1] = arguments[_key4];
}
var lls = compose.apply(undefined, [l].concat(ls));
var findWith = exports.findWith = function findWith() {
var lls = toRamda(compose.apply(undefined, arguments));
return compose(find(function (x) {
return _ramda2.default.view(lls, x) !== undefined;
return R.view(lls, x) !== undefined;
}), lls);
};
var index = exports.index = function index(i) {
return _ramda2.default.lens(function (xs) {
var isIndex = function isIndex(x) {
return Number.isInteger(x) && 0 <= x;
};
var index = exports.index = assert("a non-negative integer", isIndex);
var toRamdaIndex = function toRamdaIndex(i) {
return lens(function (xs) {
return xs && xs[i];

@@ -248,3 +245,3 @@ }, function (x, xs) {

if (xs.length <= i) return xs.concat(Array(i - xs.length), [x]);
if (_ramda2.default.equals(x, xs[i])) return xs;
if (R.equals(x, xs[i])) return xs;
return xs.slice(0, i).concat([x], xs.slice(i + 1));

@@ -255,3 +252,3 @@ }

var append = exports.append = _ramda2.default.lens(snd, function (x, xs) {
var append = exports.append = lens(snd, function (x, xs) {
return x === undefined ? xs : xs === undefined ? [x] : xs.concat([x]);

@@ -261,6 +258,6 @@ });

var filter = exports.filter = function filter(p) {
return _ramda2.default.lens(function (xs) {
return lens(function (xs) {
return xs && xs.filter(p);
}, function (ys, xs) {
return conserve(dropped(_ramda2.default.concat(ys || [], (xs || []).filter(_ramda2.default.complement(p)))), xs);
return conserve(dropped(R.concat(ys || [], (xs || []).filter(R.complement(p)))), xs);
});

@@ -270,3 +267,3 @@ };

var augment = exports.augment = function augment(template) {
return _ramda2.default.lens(toPartial(function (x) {
return lens(toPartial(function (x) {
var z = _extends({}, x);

@@ -291,3 +288,3 @@ for (var k in template) {

var pick = exports.pick = function pick(template) {
return _ramda2.default.lens(function (c) {
return lens(function (c) {
var r = void 0;

@@ -313,14 +310,13 @@ for (var k in template) {

var identity = exports.identity = _ramda2.default.lens(_ramda2.default.identity, conserve);
var identity = exports.identity = lens(id, conserve);
var props = exports.props = function props(k) {
for (var _len5 = arguments.length, ks = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
ks[_key5 - 1] = arguments[_key5];
var props = exports.props = function props() {
for (var _len3 = arguments.length, ks = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
ks[_key3] = arguments[_key3];
}
var kks = [k].concat(ks);
return pick(_ramda2.default.zipObj(kks, kks));
return pick(R.zipObj(ks, ks));
};
exports.default = compose;
//# sourceMappingURL=data:application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KSlcblxuZXhwb3J0IGRlZmF1bHQgY29tcG9zZVxuIl19
{
"name": "partial.lenses",
"version": "2.2.1",
"description": "Ramda compatible partial lenses",
"version": "3.0.0",
"description": "Partial lenses",
"main": "lib/partial.lenses.js",

@@ -17,6 +17,6 @@ "scripts": {

"keywords": [
"ramda",
"json",
"lens",
"partial",
"json"
"ramda"
],

@@ -23,0 +23,0 @@ "license": "MIT",

@@ -5,7 +5,5 @@ [ [Tutorial](#tutorial) | [Reference](#reference) | [Background](#background) ]

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 *remove* existing data and can provide *defaults* and maintain
*required* data structure parts.
collection of *partial* lenses. A partial lens can *view* optional data,
*insert* new data, *update* existing data and *remove* existing data and can,
for example, provide *defaults* and maintain *required* data structure parts.

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

inserts the new part. Setting an existing part to `undefined` removes it.
Partial lenses are defined in such a way that operations compose and one can
conveniently and robustly operate on deeply nested data structures.
Partial lenses are defined in such a way that operations [compose](#lcomposels)
and one can conveniently and robustly operate on deeply nested data structures.

@@ -336,2 +334,5 @@ [![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)

**Protip:** The link headings for functions in this reference have naive
approximate types as tooltips.
### Usage

@@ -353,5 +354,3 @@

`L.get(l, s)` is the same as `R.view(lift(l), s)` (see
[view](http://ramdajs.com/0.20.0/docs/#view)) and returns the focused element
from a data structure.
`L.get(l, s)` returns the focused element from a data structure.

@@ -367,5 +366,4 @@ For example:

`L.modify(l, x2x, s)` is the same as `R.over(lift(l), x2x, s)` (see
[over](http://ramdajs.com/0.20.0/docs/#over)) and allows one to map over the
focused element of a data structure.
`L.modify(l, x2x, s)` allows one to map over the focused element of a data
structure.

@@ -379,6 +377,2 @@ For example:

#### [`L.over(l, x2x, s)`](#loverl-x2x-s "L.over :: PLens s a -> (Maybe a -> Maybe a) -> Maybe s -> Maybe s")
**`L.over` is a deprecated synonym for `L.modify` and will be removed.**
#### [`L.remove(l, s)`](#lremovel-s "L.remove :: PLens s a -> Maybe s -> Maybe s")

@@ -413,7 +407,3 @@

`L.set(l, x, s)` is the same as `R.set(lift(l), x, s)` (see
[set](http://ramdajs.com/0.20.0/docs/#set)) and is also equivalent to
`L.modify(l, () => x, s)`. Assuming that `0 <= i && i < xs.length` and `x !==
undefined` then `L.set(i, x, xs)` is also equivalent to `R.update(i, x, xs)`
(see [update](http://ramdajs.com/0.20.0/docs/#update)).
`L.set(l, x, s)` is equivalent to `L.modify(l, () => x, s)`.

@@ -427,6 +417,2 @@ For example:

#### [`L.view(l, s)`](#lviewl-s "L.get :: PLens s a -> Maybe s -> Maybe a")
**`L.view` is a deprecated synonym for `L.get` and will be removed.**
### Lens combinators

@@ -498,10 +484,15 @@

#### [`L.compose(l, ...ls)`](#lcomposel-ls "L.compose :: (PLens s s1, ...PLens sN a) -> PLens s a")
#### [`L.compose(...ls)`](#lcomposels "L.compose :: (PLens s s1, ...PLens sN a) -> PLens s a")
The default import `P(l, ...ls)` and `L.compose(l, ...ls)` both are the same as
`R.compose(lift(l), ...ls.map(lift))` (see
[compose](http://ramdajs.com/0.20.0/docs/#compose)) and compose a lens from a
path of lenses. Furthermore, `L.compose()` is the same as `L.identity`, which
reflects the fact that `L.identity` is the identity element of lens composition.
The default import `P` and `L.compose` refer to the one and same function, which
performs lens composition. The following equations characterize lens
composition:
```js
L.compose() = L.identity
L.compose(l) = l
L.get(L.compose(l, ...ls)) = R.pipe(L.get(l), ...ls.map(L.get))
L.modify(L.compose(l, ...ls)) = R.pipe(L.modify(l), ...ls.map(L.modify))
```
For example:

@@ -569,7 +560,7 @@

#### [`L.findWith(l, ...ls)`](#lfindwithl-ls "L.findWith :: (PLens s s1, ...PLens sN a) -> PLens [s] a")
#### [`L.findWith(...ls)`](#lfindwithls "L.findWith :: (PLens s s1, ...PLens sN a) -> PLens [s] a")
`L.findWith(l, ...ls)` chooses an index from an array through which the given
lens, `P(l, ...ls)`, focuses on a defined item and then returns a lens that
focuses on that item.
`L.findWith(...ls)` chooses an index from an array through which the given lens,
`P(...ls)`, focuses on a defined item and then returns a lens that focuses on
that item.

@@ -585,31 +576,23 @@ For example:

#### [`L.firstOf(l, ...ls)`](#lfirstofl-ls "L.firstOf :: (PLens s a, ...PLens s a) -> PLens s a")
#### [`L.identity`](#lidentity "L.identity :: PLens s s")
**`L.firstOf` is deprecated and will be removed. See `L.choice` and `L.orElse`.**
`L.identity` is the identity element of lens composition. The following
equations characterize `L.identity`:
`L.firstOf(l, ...ls)` returns a partial lens that acts like the first of the
given lenses, `l, ...ls`, whose view is not undefined on the given target. When
the views of all of the given lenses are undefined, the returned lens acts like
`l`.
```js
L.get(L.identity, x) = x
L.modify(L.identity, f, x) = f(x)
L.compose(L.identity, l) = l
L.compose(l, L.identity) = l
```
Note that `L.firstOf` is an associative operation, but there is no identity
element.
#### [`L.index(integer)`](#lindexinteger "L.index :: Integer -> PLens [a] a")
#### [`L.identity`](#lidentity "L.identity :: PLens s s")
`L.index(integer)` or `integer` focuses on the specified array index.
`L.identity` is equivalent to `R.lens(R.identity, R.identity)` and is the
identity element of lenses: both `P(L.identity, l)` and `P(l, L.identity)` are
equivalent to `l`.
#### [`L.index(integer)`](#lindexinteger "L.index :: Integer -> PLens [a] a")
`L.index(integer)` or `P(integer)` is similar to `R.lensIndex(integer)` (see
[lensIndex](http://ramdajs.com/0.20.0/docs/#lensIndex)), but acts as a partial
lens:
* When viewing an undefined array index or an undefined array, the result is
undefined.
* When setting an array index to undefined, the element is removed from the
resulting array, shifting all higher indices down by one. If the result would
be an array without indices (ignoring length), the whole result will be
undefined.
* When setting to undefined, the element is removed from the resulting array,
shifting all higher indices down by one. If the result would be an array
without indices (ignoring length), the whole result will be undefined.

@@ -646,5 +629,37 @@ **NOTE:** There is a gotcha related to removing elements from an array. Namely,

`L.lens(get, set)` is the same as `R.lens(get, set)` (see
[lens](http://ramdajs.com/0.20.0/docs/#lens)) and creates a new primitive lens.
`L.lens(get, set)` creates a new primitive lens. One should think twice before
introducing a new primitive lens&mdash;most of the combinators in this library
have been introduced to reduce the need to write new primitive lenses. With
that said, there are still valid reasons to create new primitive lenses. For
example, here is a lens that we've used in production, written with the help of
[Moment.js](http://momentjs.com/), to bidirectionally convert a pair of `start`
and `end` times to a duration:
```js
const timesAsDuration = L.lens(
({start, end} = {}) => {
if (undefined === start)
return undefined
if (undefined === end)
return "Infinity"
return moment.duration(moment(end).diff(moment(start))).toJSON()
},
(duration, {start = moment().toJSON()} = {}) => {
if (undefined === duration || "Infinity" === duration) {
return {start}
} else {
return {
start,
end: moment(start).add(moment.duration(duration)).toJSON()
};
}
}
)
```
When composed with `L.pick`, to flexibly pick the `start` and `end` times, the
above can be adapted to work in a wide variety of cases. However, the above
lens will never be added to this library, because it would require adding
dependency to [Moment.js](http://momentjs.com/).
#### [`L.normalize(value => value)`](#lnormalizevalue--value "L.normalize :: (s -> s) -> PLens s s")

@@ -735,5 +750,4 @@

`L.prop(string)` or `P(string)` is similar to `R.lensProp(string)` (see
[lensProp](http://ramdajs.com/0.20.0/docs/#lensProp)), but acts as a partial
lens:
`L.prop(string)` or `string` focuses on the specified object property.
* When viewing an undefined property or an undefined object, the result is

@@ -744,3 +758,3 @@ undefined.

#### [`L.props(key, ...keys)`](#lpropskey-keys "L.props :: (p1 :: a1, ...ps) -> PLens {p1 :: a1, ...ps, ...o} {p1 :: a1, ...ps}")
#### [`L.props(...strings)`](#lpropsstrings "L.props :: (p1 :: a1, ...ps) -> PLens {p1 :: a1, ...ps, ...o} {p1 :: a1, ...ps}")

@@ -796,21 +810,16 @@ `L.props(k1, ..., kN)` is equivalent to `L.pick({[k1]: k1, ..., [kN]: kN})` and

### Auxiliary
### Interop
#### [`L.lift(pl)`](#lliftpl "L.lift :: (p :: a) -> PLens {p :: a, ...ps} a & Integer -> PLens [a] a & PLens s a -> PLens s a")
Conversions between lens libraries.
The idempotent `lift` operation is defined as
#### [`L.fromRamda(lens)`](#lfromramdalens "L.fromRamda :: Lens s a -> PLens s a")
```js
const lift = l => {
switch (typeof l) {
case "string": return L.prop(l)
case "number": return L.index(l)
default: return l
}
}
```
`L.fromRamda(lens)` converts the given Ramda lens to a partial lens. Note that
this does not change the behavior of the lens on undefined values.
and is available as a non-default export. All operations in this library that
take lenses as arguments implicitly lift them.
#### [`L.toRamda(plens)`](#ltoramdaplens "L.toRamda :: PLens s a -> Lens s a")
`L.toRamda(plens)` converts the given partial lens to a Ramda lens. Note that
this does not change the behavior of the lens on undefined values.
## Background

@@ -841,3 +850,3 @@

With partial lenses you can robustly compose a path lens from prop lenses
`R.compose(L.prop(p0), ...ps.map(L.prop))` or just use the shorthand notation
`L.compose(L.prop(p0), ...ps.map(L.prop))` or just use the shorthand notation
`P(p0, ...ps)`.

@@ -844,0 +853,0 @@

@@ -1,14 +0,19 @@

import R from "ramda"
import * as R from "ramda"
//
const warned = {}
const id = x => x
const snd = (_, c) => c
const deprecated = message => {
if (!(message in warned)) {
warned[message] = message
console.warn("partial.lenses:", message)
}
//
const check = (expected, predicate) => x => {
if (predicate(x))
return x
else
throw new Error(`Expected ${expected}, but got ${x}.`)
}
const assert = process.env.NODE_ENV === "production" ? () => id : check
//

@@ -60,20 +65,18 @@

const snd = (_, c) => c
const seemsLens = x => typeof x === "function" && x.length === 1
//
export const fromRamda = assert("a lens", seemsLens)
export const lift = l => {
switch (typeof l) {
case "string": return prop(l)
case "number": return index(l)
default: return l
}
export const toRamda = l => {
if (isProp(l)) return toRamdaProp(l)
if (isIndex(l)) return toRamdaIndex(l)
return fromRamda(l)
}
export const compose = (...ls) =>
ls.length === 0 ? identity :
ls.length === 1 ? lift(ls[0]) :
R.compose(...ls.map(lift))
ls.length === 0 ? identity :
ls.length === 1 ? ls[0] :
R.compose(...ls.map(toRamda))
export const remove = R.curry((l, s) => R.set(lift(l), undefined, s))
export const remove = R.curry((l, s) => R.set(toRamda(l), undefined, s))

@@ -87,14 +90,8 @@ export const removeAll = R.curry((lens, data) => {

export const lens = R.lens
export const modify = R.curry((l, x2x, s) => R.over(lift(l), x2x, s))
export const over = R.curry((l, x2x, s) =>
deprecated("`over` has been deprecated --- use `modify`") ||
R.over(lift(l), x2x, s))
export const set = R.curry((l, x, s) => R.set(lift(l), x, s))
export const get = R.curry((l, s) => R.view(lift(l), s))
export const view = R.curry((l, s) =>
deprecated("`view` has been deprecated --- use `get`") ||
R.view(lift(l), s))
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))
export const choose = x2yL => toFunctor => target => {
const l = lift(x2yL(target))
const l = toRamda(x2yL(target))
return R.map(focus => R.set(l, focus, target), toFunctor(R.view(l, target)))

@@ -113,9 +110,5 @@ }

export const firstOf = (l, ...ls) =>
deprecated("`firstOf` has been deprecated --- use `choice` and `orElse`") ||
orElse(l, choice(l, ...ls))
export const replace = R.curry((inn, out) =>
R.lens(x => R.equals(x, inn) ? out : x,
toConserve(y => R.equals(y, out) ? inn : y)))
lens(x => R.equals(x, inn) ? out : x,
toConserve(y => R.equals(y, out) ? inn : y)))

@@ -127,8 +120,12 @@ export const defaults = replace(undefined)

export const normalize = transform =>
R.lens(toPartial(transform), toConserve(toPartial(transform)))
lens(toPartial(transform), toConserve(toPartial(transform)))
export const prop = k =>
R.lens(o => o && o[k],
(v, o) => v === undefined ? deleteKey(k, o) : setKey(k, v, o))
const isProp = x => typeof x === "string"
export const prop = assert("a string", isProp)
const toRamdaProp = k =>
lens(o => o && o[k],
(v, o) => v === undefined ? deleteKey(k, o) : setKey(k, v, o))
export const find = predicate => choose(xs => {

@@ -141,8 +138,12 @@ if (xs === undefined)

export const findWith = (l, ...ls) => {
const lls = compose(l, ...ls)
export const findWith = (...ls) => {
const lls = toRamda(compose(...ls))
return compose(find(x => R.view(lls, x) !== undefined), lls)
}
export const index = i => R.lens(xs => xs && xs[i], (x, xs) => {
const isIndex = x => Number.isInteger(x) && 0 <= x
export const index = assert("a non-negative integer", isIndex)
const toRamdaIndex = i => lens(xs => xs && xs[i], (x, xs) => {
if (x === undefined) {

@@ -165,9 +166,9 @@ if (xs === undefined)

export const append = R.lens(snd, (x, xs) =>
export const append = lens(snd, (x, xs) =>
x === undefined ? xs : xs === undefined ? [x] : xs.concat([x]))
export const filter = p => R.lens(xs => xs && xs.filter(p), (ys, xs) =>
export const filter = p => lens(xs => xs && xs.filter(p), (ys, xs) =>
conserve(dropped(R.concat(ys || [], (xs || []).filter(R.complement(p)))), xs))
export const augment = template => R.lens(
export const augment = template => lens(
toPartial(x => {

@@ -198,3 +199,3 @@ const z = {...x}

export const pick = template => R.lens(
export const pick = template => lens(
c => {

@@ -219,9 +220,6 @@ let r

export const identity = R.lens(R.identity, conserve)
export const identity = lens(id, conserve)
export const props = (k, ...ks) => {
const kks = [k, ...ks]
return pick(R.zipObj(kks, kks))
}
export const props = (...ks) => pick(R.zipObj(ks, ks))
export default compose

@@ -1,2 +0,2 @@

import R from "ramda"
import * as R from "ramda"

@@ -15,4 +15,6 @@ import P, * as L from "../src/partial.lenses"

const run = expr => eval(`(P, L, R) => ${expr}`)(P, L, R)
const testEq = (expr, expect) => it(`${expr} => ${show(expect)}`, () => {
const actual = eval(`(P, L, R) => ${expr}`)(P, L, R)
const actual = run(expr)
if (!R.equals(actual, expect))

@@ -22,9 +24,23 @@ throw new Error(`Expected: ${show(expect)}, actual: ${show(actual)}`)

describe("default === compose", () => {
it("P === L.compose", () => {
if (P !== L.compose)
throw new Error("Not the same")
})
const testThrows = expr => it(`${expr} => throws`, () => {
let raised
let result
try {
result = run(expr)
raised = false
} catch (e) {
result = e
raised = true
}
if (!raised)
throw new Error(`Expected ${expr} to throw, returned ${show(result)}`)
})
describe("compose", () => {
testEq("P === L.compose", true)
testEq('P() === L.identity', true)
testEq('P("x")', "x")
testEq('P(101)', 101)
})
describe("arities", () => {

@@ -38,3 +54,4 @@ testEq('L.augment.length', 1)

testEq('L.find.length', 1)
testEq('L.findWith.length', 1)
testEq('L.findWith.length', 0)
testEq('L.fromRamda.length', 1)
testEq('L.get.length', 2)

@@ -48,3 +65,3 @@ testEq('L.index.length', 1)

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

@@ -54,4 +71,10 @@ testEq('L.replace.length', 2)

testEq('L.set.length', 3)
testEq('L.toRamda.length', 1)
})
describe("interop", () => {
testEq('R.set(L.toRamda(0), "a", ["b"])', ["a"])
testEq('L.get(L.fromRamda(R.lensProp("x")), {x: "b"})', "b")
})
describe('L.find', () => {

@@ -69,2 +92,7 @@ testEq('L.set(L.find(R.equals(2)), undefined, [,,2])', undefined)

describe('L.index', () => {
if (process.env.NODE_ENV !== "production") {
testThrows('L.index("x")')
testThrows('L.index(-1)')
testThrows('L.index()')
}
testEq('L.set(P(1), undefined, [,,])', undefined)

@@ -85,2 +113,7 @@ testEq('L.set(P(L.required([]), 1), undefined, [,,])', [])

describe('L.prop', () => {
if (process.env.NODE_ENV !== "production") {
testThrows('L.prop(2)')
testThrows('L.prop(x => x)')
testThrows('L.prop()')
}
testEq('L.set(P("x"), undefined, {x: 1})', undefined)

@@ -144,15 +177,2 @@ testEq('L.set(P("x", L.required(null)), undefined, {x: 1})', {x: null})

describe("L.firstOf", () => {
testEq('L.get(L.firstOf("x", "y"), {x: 11, y: 12})', 11)
testEq('L.get(L.firstOf("y", "x"), {x: 11, y: 12})', 12)
testEq('L.get(L.firstOf("x", "y"), {z: 13})', undefined)
testEq('L.modify(L.firstOf("x", "y"), x => x-2, {x: 11, y: 12})', {x: 9, y: 12})
testEq('L.modify(L.firstOf("y", "x"), x => x-2, {x: 11, y: 12})', {x: 11, y: 10})
testEq('L.set(L.firstOf("x", "y"), 12, {z: 13})', {x: 12, z: 13})
testEq('L.set(L.firstOf("y", "x"), 12, {z: 13})', {y: 12, z: 13})
testEq('L.remove(L.firstOf("x", "y"), {z: 13})', {z: 13})
testEq('L.remove(L.firstOf("x", "y"), {x: 11, y: 12})', {y: 12})
testEq('L.remove(L.firstOf("y", "x"), {x: 11, y: 12})', {x: 11})
})
describe("L.findWith", () => {

@@ -194,3 +214,3 @@ testEq('L.get(L.findWith("x", 1), [{x: ["a"]},{x: ["b","c"]}])', "c")

testEq('L.remove(P(L.pick({x: "b"}), "x"), {a: [2], b: 1})', {a: [2]})
testEq('L.removeAll(P(L.pick({x: "b", y: "a"}), L.firstOf("y", "x")), {a: [2], b: 1})', undefined)
testEq('L.removeAll(P(L.pick({x: "b", y: "a"}), L.choice("y", "x")), {a: [2], b: 1})', undefined)
})

@@ -197,0 +217,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc