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 0.6.0 to 0.7.0

27

lib/partial.lenses.js

@@ -94,2 +94,7 @@ "use strict";

});
L.deleteAll = _ramda2.default.curry(function (lens, data) {
while (L.view(lens, data) !== undefined) {
data = L.delete(lens, data);
}return data;
});
L.lens = _ramda2.default.lens;

@@ -162,7 +167,17 @@ L.over = _ramda2.default.curry(function (l, x2x, s) {

var i = xs.findIndex(predicate);
if (i < 0) return L.append;
return L.index(i);
return i < 0 ? L.append : i;
});
};
L.findWith = function (l) {
for (var _len3 = arguments.length, ls = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
ls[_key3 - 1] = arguments[_key3];
}
var lls = L.apply(undefined, [l].concat(ls));
return L(L.find(function (x) {
return L.view(lls, x) !== undefined;
}), lls);
};
L.index = function (i) {

@@ -186,7 +201,3 @@ return _ramda2.default.lens(function (xs) {

L.append = _ramda2.default.lens(function () {}, function (x, xs) {
if (x === undefined) {
return xs;
} else {
if (xs === undefined) return [x];else return xs.concat([x]);
}
return x === undefined ? xs : xs === undefined ? [x] : xs.concat([x]);
});

@@ -203,2 +214,2 @@

exports.default = L;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wYXJ0aWFsLmxlbnNlcy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFJQSxJQUFNLFlBQVksU0FBWixTQUFZLENBQUMsQ0FBRCxFQUFJLENBQUosRUFBVTtBQUMxQixNQUFJLE1BQU0sU0FBTixJQUFtQixFQUFFLEtBQUssQ0FBTCxDQUFGLEVBQ3JCLE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IubGVucygoKSA9PiB7fSwgKHgsIHhzKSA9PlxuICB4ID09PSB1bmRlZmluZWQgPyB4cyA6IHhzID09PSB1bmRlZmluZWQgPyBbeF0gOiB4cy5jb25jYXQoW3hdKSlcblxuTC5maWx0ZXIgPSBwID0+IFIubGVucyh4cyA9PiB4cyAmJiB4cy5maWx0ZXIocCksICh5cywgeHMpID0+XG4gIGNvbnNlcnZlKHhzLCBkcm9wcGVkKFIuY29uY2F0KHlzIHx8IFtdLCAoeHMgfHwgW10pLmZpbHRlcihSLmNvbXBsZW1lbnQocCkpKSkpKVxuXG5leHBvcnQgZGVmYXVsdCBMXG4iXX0=
{
"name": "partial.lenses",
"version": "0.6.0",
"version": "0.7.0",
"description": "Ramda compatible lenses",

@@ -33,9 +33,9 @@ "main": "lib/partial.lenses.js",

"babel-cli": "^6.5.1",
"babel-eslint": "^4.1.8",
"babel-eslint": "^5.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.5.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-stage-2": "^6.5.0",
"eslint": "^2.0.0",
"eslint": "^2.2.0",
"mocha": "^2.4.5"
}
}

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

[ [Examples](#examples) | [Reference](#reference) | [Background](#background) ]
[ [Tutorial](#tutorial) | [Reference](#reference) | [Background](#background) ]

@@ -16,5 +16,5 @@ This library provides a collection of [Ramda](http://ramdajs.com/) compatible

[![npm version](https://badge.fury.io/js/partial.lenses.svg)](http://badge.fury.io/js/partial.lenses)
[![npm version](https://badge.fury.io/js/partial.lenses.svg)](http://badge.fury.io/js/partial.lenses) [![](https://david-dm.org/dirty-js/partial.lenses.svg)](https://david-dm.org/dirty-js/partial.lenses)
## Examples
## Tutorial

@@ -28,5 +28,12 @@ Let's work with the following sample JSON object:

First we define a parameterized lens for accessing texts:
First we import libraries
```js
import L from "partial.lenses"
import R from "ramda"
```
and compose a parameterized lens for accessing texts:
```js
const textIn = language =>

@@ -42,5 +49,11 @@ L.compose(L.prop("contents"),

Like with ordinary lenses, we can now use the partial lens to view or query
texts:
Take a moment to read through the above definition line by line. Each line has
a specific purpose. The purpose of the `L.prop(...)` lines is probably obvious.
The other lines we will mention below.
### Querying data
Thanks to the parameterized search part, `L.find(R.whereEq({language}))`, of the
lens composition, we can use it to query texts:
```js

@@ -53,3 +66,4 @@ > L.view(textIn("sv"), data)

If we query a text that does not exist, we get the default:
Partial lenses can deal with missing data. If we use the partial lens to query
a text that does not exist, we get the default:

@@ -61,4 +75,5 @@ ```js

With the partial lens we defined, we get the default even if we query from
`undefined`:
We get this default, rather than undefined, thanks to the last part,
`L.default("")`, of our lens composition. We get the default even if we query
from `undefined`:

@@ -72,2 +87,4 @@ ```js

### Updating data
As with ordinary lenses, we can use the same lens to update texts:

@@ -81,2 +98,4 @@

### Inserting data
The same partial lens also allows us to insert new texts:

@@ -91,4 +110,8 @@

Note the position into which the new text was inserted.
Note the position into which the new text was inserted. The array of texts is
kept sorted thanks to the `L.normalize(R.sortBy(R.prop("language")))` part of
our lens.
### Deleting data
Finally, we can use the same partial lens to delete texts:

@@ -101,2 +124,8 @@

Note that a single text is actually a part of an object. The key to having the
whole object vanish, rather than just the `text` property, is the
`L.default({language})` part of our lens composition. A `L.default(value)` lens
works *symmetrically*. When set with `value`, the result is `undefined`, which
means that the focus of the lens is to be deleted.
If we delete all of the texts, we get the required value:

@@ -110,7 +139,21 @@

The `contents` property is not removed thanks to the `L.required([])` part of
our lens composition. `L.required` is the dual of `L.default`. `L.default`
replaces undefined values when viewed and `L.required` replaces undefined values
when set.
Note that unless required and default values are explicitly specified as part of
the lens, they will both be undefined.
For clarity, the code snippets in this section avoided some of the shorthands
that this library supports. In particular,
### Exercise
Take out one (or more) `L.required(...)`, `L.normalize(...)` or `L.default(...)`
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,
* `L.compose(...)` can be abbreviated as `L(...)`,

@@ -120,2 +163,59 @@ * `L.prop(string)` can be abbreviated as `string`, and

### Systematic decomposition
It is also typical to compose lenses out of short paths following the schema of
the JSON data being manipulated. Reconsider the lens from the start of the
example:
```js
const textIn = language =>
L.compose(L.prop("contents"),
L.required([]),
L.normalize(R.sortBy(R.prop("language"))),
L.find(R.whereEq({language})),
L.default({language}),
L.prop("text"),
L.default(""))
```
Following the structure or schema of the JSON, we could break this into three
separate lenses:
* a lens for accessing the contents of a data object,
* a parameterized lens for querying a content object from contents, and
* a lens for accessing the text of a content object.
Furthermore, we could organize the lenses into an object following the structure
of the JSON:
```js
const M = {
data: {
contents: L("contents",
L.required([]),
L.normalize(R.sortBy(R.prop("language"))))
},
contents: {
contentIn: language => L(L.find(R.whereEq({language})),
L.default({language}))
},
content: {
text: L("text", L.default(""))
}
}
```
Using the above object, we could rewrite the parameterized `textIn` lens as:
```js
const textIn = language => L(M.data.contents,
M.contents.contentIn(language),
M.content.text)
```
This style of organizing lenses is overkill for our toy example. In a more
realistic case the `data` object would contain many more properties. Also,
rather than composing a lens, like `textIn` above, to access a leaf property
from the root of our object, we might actually compose lenses incrementally as
we inspect the model structure.
## Reference

@@ -170,2 +270,9 @@

#### L.deleteAll(l, s)
`L.deleteAll(l, s)` deletes all the non `undefined` items targeted by the lens
`l` from `s`. This only makes sense for a lens that
* can potentially focus on more than one item and
* will focus on `undefined` when it doesn't find an item to focus on.
### Lenses

@@ -186,4 +293,12 @@

determined by the given function that maps the underlying view, which can be
undefined, to a lens.
undefined, to a lens. The lens returned by the given function will be lifted.
Note that the type of `L.choose` is
```haskell
choose :: (Maybe a -> PartialLens b s) -> PartialLens a s -> PartialLens b s
```
which is very similar to the type of the monadic bind operation.
#### L.filter(predicate)

@@ -211,2 +326,17 @@

#### L.findWith(l, ...ls)
`L.findWith(l, ...ls)` is defined as
```js
L.findWith = (l, ...ls) => {
const lls = L(l, ...ls)
return L(L.find(x => L.view(lls, x) !== undefined), lls)
}
```
and basically chooses an index from an array through which the given lens, `L(l,
...ls)`, focuses on a defined item and then returns a lens that focuses on that
item.
#### L.firstOf(l, ...ls)

@@ -222,2 +352,3 @@

#### L.index(integer)

@@ -224,0 +355,0 @@

@@ -60,2 +60,7 @@ import R from "ramda"

L.delete = R.curry((l, s) => R.set(lift(l), undefined, s))
L.deleteAll = R.curry((lens, data) => {
while (L.view(lens, data) !== undefined)
data = L.delete(lens, data)
return data
})
L.lens = R.lens

@@ -95,7 +100,10 @@ L.over = R.curry((l, x2x, s) => R.over(lift(l), x2x, s))

const i = xs.findIndex(predicate)
if (i < 0)
return L.append
return L.index(i)
return i < 0 ? L.append : i
})
L.findWith = (l, ...ls) => {
const lls = L(l, ...ls)
return L(L.find(x => L.view(lls, x) !== undefined), lls)
}
L.index = i => R.lens(xs => xs && xs[i], (x, xs) => {

@@ -119,12 +127,4 @@ if (x === undefined) {

L.append = R.lens(() => {}, (x, xs) => {
if (x === undefined) {
return xs
} else {
if (xs === undefined)
return [x]
else
return xs.concat([x])
}
})
L.append = R.lens(() => {}, (x, xs) =>
x === undefined ? xs : xs === undefined ? [x] : xs.concat([x]))

@@ -131,0 +131,0 @@ L.filter = p => R.lens(xs => xs && xs.filter(p), (ys, xs) =>

@@ -115,2 +115,8 @@ import R from "ramda"

describe("L.findWith", () => {
testEq('L.view(L.findWith("x", 1), [{x: ["a"]},{x: ["b","c"]}])', "c")
testEq('L.set(L.findWith("x", 1), "d", [{x: ["a"]},{x: ["b","c"]}])', [{x: ["a"]},{x: ["b","d"]}])
testEq('L.delete(L.findWith("x", 1), [{x: ["a"]},{x: ["b","c"]}])', [{x: ["a"]},{x: ["b"]}])
})
describe("L.filter", () => {

@@ -125,1 +131,5 @@ testEq('L.view(L.filter(R.lt(9)), [3,1,4,1,5,9,2])', [])

})
describe("L.deleteAll", () => {
testEq('L.deleteAll(L.find(x => x < 2), [3,1,4,1,5,9,2])', [3,4,5,9,2])
})

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