diff --git a/README.md b/README.md index 505d6ac4..377784aa 100644 --- a/README.md +++ b/README.md @@ -20,55 +20,10 @@ immutad●t gives you a short and meaningful syntax to apply operations on immut [![codecov](https://codecov.io/gh/Zenika/immutadot/branch/master/graph/badge.svg)](https://codecov.io/gh/Zenika/immutadot) [![Greenkeeper](https://badges.greenkeeper.io/Zenika/immutadot.svg)](https://greenkeeper.io/) -## [1.0 Release Candidate](https://github.com/Zenika/immutadot/releases) is out 🎉 - -We are still writing the documentation, you can already find out about the [updated API](https://zenika.github.io/immutadot/immutadot/1.0) and our new package [immutadot-lodash](https://zenika.github.io/immutadot/immutadot-lodash/1.0). - -If you would like to try out 1.0 before its official release, install it with : - -```shell -yarn add immutadot@next -``` - -or - - -```shell -npm install immutadot@next -``` +## [1.0](https://github.com/Zenika/immutadot/releases) is out 🎉 If you were using a previous version of immutad●t, check out the [migrating guide](docs/MIGRATING_TO_1_0.md). -## Immutability - -In the last few years one of our biggest challenge has been to find an efficient way to detect changes in our data to determine when to re-render our interfaces. - -An immutable object is an object that cannot be changed once created. It brings several benefits[1](#notes): - -- Data changes detection made simple (Shallow comparison) -- Memoization -- Improve rendering performances -- Explicit data changes -- Avoid side effects - -## Our approach - -### Concise - -[ES2015+](https://mdn.io/JavaScript/Reference) new features are great to deal with arrays and objects. As data structures expand, the code you write to make data immutable gets bigger and less readable. immutad●t uses the dot notation to address this issue. - -### Interoperability - -immutad●t uses plain JavaScript objects so you can access your data using standard ways. Moreover, it lets you freely enjoy your favorite libraries. - -### Exhaustive and yet extensible - -immutad●t comes with a large set of built-in utilities, mostly based on [ES2015+](https://mdn.io/JavaScript/Reference). You can also find a package called [immutadot-lodash](https://github.com/Zenika/immutadot/tree/master/packages/immutadot-lodash) with some of [lodash](https://lodash.com/)'s utilities. You haven't found what you're looking for? Do it yourself with the [`convert`](https://zenika.github.io/immutadot/immutadot/1.0/core.html#.convert) feature. - -### Learning curve - -If you are already familiar with [ES2015+](https://mdn.io/JavaScript/Reference) and [lodash](https://lodash.com/) then you should be able to use immutad●t quickly. - ## Installation immutad●t is available on [npm repository](https://www.npmjs.com/package/immutadot). @@ -103,90 +58,43 @@ const { set } = require('immutadot') ### Example -Object used in the following example: +Quickly set nested properties using [set()](https://zenika.github.io/immutadot/immutadot/1.0/core.html#.set) ```js +import { set } from 'immutadot' + const animals = { - weasels: [ - { - vernacularName: 'badger', - scientificName: 'Meles meles' + weasels: { + lutraLutra: { + commonNames: ['eurasian otter'], }, - { - vernacularName: 'otter', - } - ] + }, } -``` - -Let's add the otter's scientific name without mutating the original object structure. -using ES2015+: - -```js -const newAnimals = { - ...animals, - weasels: [...animals.weasels] -} - -newAnimals.weasels[1] = { - ...newAnimals.weasels[1], - scientificName: 'Lutrinae' -} -``` - -using immutad●t: - -```js -const newAnimals = set(animals, 'weasels[1].scientificName', 'Lutrinae') +const newAnimals = set(animals, 'weasels.lutraLutra.name', 'Lutrinae') ``` +Learn more about what immutad●t can do in the [Getting started](https://github.com/Zenika/immutadot/blob/master/docs/GETTING_STARTED.md). Feel free to [try immutad●t on runkit](https://npm.runkit.com/immutadot). -## Path notation - -immutad●t brings a few improvements to the classic dot notation: - -### Slice notation - -The slice notation lets you iterate over arrays to apply operations without having to map arrays at each level of imbrication. - -We forgot to capitalize vernacular names in the [input](#Example). - -using ES2015+: +## Documentation -```js -import { capitalize } from 'lodash' -const newAnimals = { - ...animals, - weasels: animals.weasels.map(weasel => { - return { - ...weasel, - vernacularName: capitalize(weasel.vernacularName), - } - }), -} -``` +### Getting started -using immutad●t-lodash: +A fast overview of immutad●t's features is available in the [Getting started](https://github.com/Zenika/immutadot/blob/master/docs/GETTING_STARTED.md) guide. -```js -import { capitalize } from 'immutadot-lodash' -const newAnimals = capitalize(animals, 'weasels[:].vernacularName') -``` +### API -### List notation +The detailed API documentations of the different packages are available here: +- [immutadot](https://zenika.github.io/immutadot/immutadot) +- [immutadot-lodash](https://zenika.github.io/immutadot/immutadot-lodash/) -The list notation lets you iterate over the keys of objects used as collection or map to apply operations. +Looking for older versions API documentation? Links are available [here](https://github.com/Zenika/immutadot/blob/master/docs/README.md). -```js -toggle({ nested: { prop: { 1: { active: true }, 2: { active: false } } } }, 'nested.prop.{*}.active') -// { nested: { prop: { 1: { active: false }, 2: { active: true }] } } +### Migrating from 0.x versions -toLowerCase({ nested: { prop: { 1: { msg: 'Hello' }, 2: { msg: 'Hi' }, 3: { msg: 'Good morning' } } } }, 'nested.prop{2, 3}.msg') -// { nested: { prop: { 1: { msg: 'Hello' }, 2: { msg: 'hi' }, 3: { msg: 'good morning' } } } } -``` +If you were using a version of immutad●t previous to 1.0, check out the [migrating guide](docs/MIGRATING_TO_1_0.md). ## Performances @@ -218,19 +126,35 @@ Update large todos list (100000 items): immutad●t 1.0.0: ~23ops/s (44.15ms/op) on 500ops ``` -## Documentation +## Immutability -### Getting started +In the last few years one of our biggest challenge has been to find an efficient way to detect changes in our data to determine when to re-render our interfaces. -A fast overview of immutad●t's features is available in the [Getting started](https://github.com/Zenika/immutadot/blob/master/docs/GETTING_STARTED.md) guide. +An immutable object is an object that cannot be changed once created. It brings several benefits[1](#notes): -### API +- Data changes detection made simple (Shallow comparison) +- Memoization +- Improve rendering performances +- Explicit data changes +- Avoid side effects -The detailed API documentations of the different packages are available here: -- [immutadot](https://zenika.github.io/immutadot/immutadot) -- [immutadot-lodash](https://zenika.github.io/immutadot/immutadot-lodash/) +## Our approach -Looking for older versions API documentation? Links are available [here](https://github.com/Zenika/immutadot/blob/master/docs/README.md). +### Concise + +[ES2015+](https://mdn.io/JavaScript/Reference) new features are great to deal with arrays and objects. As data structures expand, the code you write to make data immutable gets bigger and less readable. immutad●t uses the dot notation to address this issue. + +### Interoperability + +immutad●t uses plain JavaScript objects so you can access your data using standard ways. Moreover, it lets you freely enjoy your favorite libraries. + +### Exhaustive and yet extensible + +immutad●t comes with a large set of built-in utilities, mostly based on [ES2015+](https://mdn.io/JavaScript/Reference). You can also find a package called [immutadot-lodash](https://github.com/Zenika/immutadot/tree/master/packages/immutadot-lodash) with some of [lodash](https://lodash.com/)'s utilities. You haven't found what you're looking for? Do it yourself with the [`convert`](https://zenika.github.io/immutadot/immutadot/1.0/core.html#.convert) feature. + +### Learning curve + +If you are already familiar with [ES2015+](https://mdn.io/JavaScript/Reference) and [lodash](https://lodash.com/) then you should be able to use immutad●t quickly. ## Contributing diff --git a/dist/immutadot-lodash.js b/dist/immutadot-lodash.js index 83168abc..e65ab13e 100644 --- a/dist/immutadot-lodash.js +++ b/dist/immutadot-lodash.js @@ -16,7 +16,7 @@ * @see {@link https://lodash.com/docs#difference|lodash.difference} for more information. * @since 1.0.0 */ -var difference$1 = immutadot.convert(lodash.difference); +var difference = immutadot.convert(lodash.difference); /** * This method is like {@link array.difference} except that it uses iteratee to generate the value to be compared for each element. @@ -31,7 +31,7 @@ var difference$1 = immutadot.convert(lodash.difference); * @see {@link https://lodash.com/docs#differenceBy|lodash.differenceBy} for more information. * @since 1.0.0 */ -var differenceBy$1 = immutadot.convert(lodash.differenceBy); +var differenceBy = immutadot.convert(lodash.differenceBy); /** * This method is like {@link array.difference} except that it uses comparator to compare elements of the former array to values. @@ -46,7 +46,7 @@ var differenceBy$1 = immutadot.convert(lodash.differenceBy); * @see {@link https://lodash.com/docs#differenceWith|lodash.differenceWith} for more information. * @since 1.0.0 */ -var differenceWith$1 = immutadot.convert(lodash.differenceWith); +var differenceWith = immutadot.convert(lodash.differenceWith); /** * Replaces an array dropping one or several elements at the start of the former array. @@ -60,7 +60,7 @@ var differenceWith$1 = immutadot.convert(lodash.differenceWith); * @see {@link https://lodash.com/docs#drop|lodash.drop} for more information. * @since 1.0.0 */ -var drop$1 = immutadot.convert(lodash.drop); +var drop = immutadot.convert(lodash.drop); /** * Replaces an array dropping one or several elements at the end of the former array. @@ -74,7 +74,7 @@ var drop$1 = immutadot.convert(lodash.drop); * @see {@link https://lodash.com/docs#dropRight|lodash.dropRight} for more information. * @since 1.0.0 */ -var dropRight$1 = immutadot.convert(lodash.dropRight); +var dropRight = immutadot.convert(lodash.dropRight); /** * Replaces an array excluding elements dropped from the end. Elements are dropped until predicate returns falsey. @@ -88,7 +88,7 @@ var dropRight$1 = immutadot.convert(lodash.dropRight); * @see {@link https://lodash.com/docs#dropRightWhile|lodash.dropRightWhile} for more information. * @since 1.0.0 */ -var dropRightWhile$1 = immutadot.convert(lodash.dropRightWhile); +var dropRightWhile = immutadot.convert(lodash.dropRightWhile); /** * Replaces an array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey. @@ -102,7 +102,7 @@ var dropRightWhile$1 = immutadot.convert(lodash.dropRightWhile); * @see {@link https://lodash.com/docs#dropWhile|lodash.dropWhile} for more information. * @since 1.0.0 */ -var dropWhile$1 = immutadot.convert(lodash.dropWhile); +var dropWhile = immutadot.convert(lodash.dropWhile); /** * Replaces by an array of unique values that are included in th former array and all given arrays. @@ -116,7 +116,7 @@ var dropWhile$1 = immutadot.convert(lodash.dropWhile); * @see {@link https://lodash.com/docs#intersection|lodash.intersection} for more information. * @since 1.0.0 */ -var intersection$1 = immutadot.convert(lodash.intersection); +var intersection = immutadot.convert(lodash.intersection); /** * This method is like {@link array.intersection} except that it uses iteratee to generate the value to be compared for each element. @@ -131,7 +131,7 @@ var intersection$1 = immutadot.convert(lodash.intersection); * @see {@link https://lodash.com/docs#intersectionBy|lodash.intersectionBy} for more information. * @since 1.0.0 */ -var intersectionBy$1 = immutadot.convert(lodash.intersectionBy); +var intersectionBy = immutadot.convert(lodash.intersectionBy); /** * This method is like {@link array.intersection} except that it uses comparator to compare elements of the former array to arrays. @@ -146,7 +146,7 @@ var intersectionBy$1 = immutadot.convert(lodash.intersectionBy); * @see {@link https://lodash.com/docs#intersectionWith|lodash.intersectionWith} for more information. * @since 1.0.0 */ -var intersectionWith$1 = immutadot.convert(lodash.intersectionWith); +var intersectionWith = immutadot.convert(lodash.intersectionWith); var lodashFpConvertOptions = { curry: false, @@ -190,7 +190,7 @@ var convertLodashFp = function convertLodashFp(fn) { * @see {@link https://lodash.com/docs#pull|lodash.pull} for more information. * @since 1.0.0 */ -var pull$1 = convertLodashFp(fp.pull); +var pull = convertLodashFp(fp.pull); /** * This method is like {@link array.pull} except that it accepts an array of values to remove. @@ -204,7 +204,7 @@ var pull$1 = convertLodashFp(fp.pull); * @see {@link https://lodash.com/docs#pullAll|lodash.pullAll} for more information. * @since 1.0.0 */ -var pullAll$1 = convertLodashFp(fp.pullAll); +var pullAll = convertLodashFp(fp.pullAll); /** * This method is like {@link array.pullAll} except that it accepts iteratee to generate the criterion by which each element is compared. @@ -219,7 +219,7 @@ var pullAll$1 = convertLodashFp(fp.pullAll); * @see {@link https://lodash.com/docs#pullAllBy|lodash.pullAllBy} for more information. * @since 1.0.0 */ -var pullAllBy$1 = convertLodashFp(fp.pullAllBy); +var pullAllBy = convertLodashFp(fp.pullAllBy); /** * This method is like {@link array.pullAll} except that it accepts comparator to compare elements. @@ -234,7 +234,7 @@ var pullAllBy$1 = convertLodashFp(fp.pullAllBy); * @see {@link https://lodash.com/docs#pullAllWith|lodash.pullAllWith} for more information. * @since 1.0.0 */ -var pullAllWith$1 = convertLodashFp(fp.pullAllWith); +var pullAllWith = convertLodashFp(fp.pullAllWith); /** * Replaces an array removing the specified indexes from the former array. @@ -248,7 +248,7 @@ var pullAllWith$1 = convertLodashFp(fp.pullAllWith); * @see {@link https://lodash.com/docs#pullAt|lodash.pullAt} for more information. * @since 1.0.0 */ -var pullAt$1 = convertLodashFp(fp.pullAt); +var pullAt = convertLodashFp(fp.pullAt); /** * Replaces an array removing elements that predicate returns truthy for from the former array. @@ -262,7 +262,7 @@ var pullAt$1 = convertLodashFp(fp.pullAt); * @see {@link https://lodash.com/docs#remove|lodash.remove} for more information. * @since 1.0.0 */ -var remove$1 = convertLodashFp(fp.remove); +var remove = convertLodashFp(fp.remove); /** * Creates a slice of array with n elements taken from the beginning. @@ -276,7 +276,7 @@ var remove$1 = convertLodashFp(fp.remove); * @see {@link https://lodash.com/docs#take|lodash.take} for more information. * @since 1.0.0 */ -var take$1 = immutadot.convert(lodash.take); +var take = immutadot.convert(lodash.take); /** * Creates a slice of array with n elements taken from the end. @@ -290,7 +290,7 @@ var take$1 = immutadot.convert(lodash.take); * @see {@link https://lodash.com/docs#takeRight|lodash.takeRight} for more information. * @since 1.0.0 */ -var takeRight$1 = immutadot.convert(lodash.takeRight); +var takeRight = immutadot.convert(lodash.takeRight); /** * Creates a slice of array with elements taken from the end. @@ -306,7 +306,7 @@ var takeRight$1 = immutadot.convert(lodash.takeRight); * @see {@link https://lodash.com/docs#takeRightWhile|lodash.takeRightWhile} for more information. * @since 1.0.0 */ -var takeRightWhile$1 = immutadot.convert(lodash.takeRightWhile); +var takeRightWhile = immutadot.convert(lodash.takeRightWhile); /** * Creates a slice of array with elements taken from the beginning. @@ -322,7 +322,7 @@ var takeRightWhile$1 = immutadot.convert(lodash.takeRightWhile); * @see {@link https://lodash.com/docs#takeWhile|lodash.takeWhile} for more information. * @since 1.0.0 */ -var takeWhile$1 = immutadot.convert(lodash.takeWhile); +var takeWhile = immutadot.convert(lodash.takeWhile); /** * Replaces an array by an array of unique values, in order, from the former array and the given arrays. @@ -336,7 +336,7 @@ var takeWhile$1 = immutadot.convert(lodash.takeWhile); * @see {@link https://lodash.com/docs#union|lodash.union} for more information. * @since 1.0.0 */ -var union$1 = immutadot.convert(lodash.union); +var union = immutadot.convert(lodash.union); /** * This method is like {@link array.union} except that it accepts iteratee to generate the criterion by which elements are compared. @@ -351,7 +351,7 @@ var union$1 = immutadot.convert(lodash.union); * @see {@link https://lodash.com/docs#unionBy|lodash.unionBy} for more information. * @since 1.0.0 */ -var unionBy$1 = immutadot.convert(lodash.unionBy); +var unionBy = immutadot.convert(lodash.unionBy); /** * This method is like {@link array.union} except that it accepts comparator to compare elements. @@ -366,7 +366,7 @@ var unionBy$1 = immutadot.convert(lodash.unionBy); * @see {@link https://lodash.com/docs#unionWith|lodash.unionWith} for more information. * @since 1.0.0 */ -var unionWith$1 = immutadot.convert(lodash.unionWith); +var unionWith = immutadot.convert(lodash.unionWith); /** * This method is an alias of {@link array.pull}. @@ -374,7 +374,7 @@ var unionWith$1 = immutadot.convert(lodash.unionWith); * @memberof array * @since 1.0.0 */ -var without = pull$1; +var without = pull; /** * Replaces an array by the symmetric difference of the former array and the given arrays. @@ -388,7 +388,7 @@ var without = pull$1; * @see {@link https://lodash.com/docs#xor|lodash.xor} for more information. * @since 1.0.0 */ -var xor$1 = immutadot.convert(lodash.xor); +var xor = immutadot.convert(lodash.xor); /** * This method is like {@link array.xor} except that it accepts iteratee to generate the criterion by which elements are compared. @@ -403,7 +403,7 @@ var xor$1 = immutadot.convert(lodash.xor); * @see {@link https://lodash.com/docs#xorBy|lodash.xorBy} for more information. * @since 1.0.0 */ -var xorBy$1 = immutadot.convert(lodash.xorBy); +var xorBy = immutadot.convert(lodash.xorBy); /** * This method is like {@link array.xor} except that it accepts comparator to compare elements. @@ -418,7 +418,7 @@ var xorBy$1 = immutadot.convert(lodash.xorBy); * @see {@link https://lodash.com/docs#xorWith|lodash.xorWith} for more information. * @since 1.0.0 */ -var xorWith$1 = immutadot.convert(lodash.xorWith); +var xorWith = immutadot.convert(lodash.xorWith); /** * Replaces by an array of elements predicate returns truthy for. @@ -432,7 +432,7 @@ var xorWith$1 = immutadot.convert(lodash.xorWith); * @example filter({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [1, 3] } } * @since 1.0.0 */ -var filter$1 = immutadot.convert(lodash.filter); +var filter = immutadot.convert(lodash.filter); /** * Replaces by an array of values by running each element in the former collection thru iteratee. @@ -447,7 +447,7 @@ var filter$1 = immutadot.convert(lodash.filter); * @example map({ nested: { prop: [1, 2, 3] } }, 'nested.prop', v => v * 2) // => { nested: { prop: [2, 4, 6] } } * @since 1.0.0 */ -var map$1 = immutadot.convert(lodash.map); +var map = immutadot.convert(lodash.map); /** * Replaces by an array of sorted by iteratees in specified orders. @@ -464,7 +464,7 @@ var map$1 = immutadot.convert(lodash.map); * // => { nested: { prop: [{ name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }, { name: 'Yvo', age: 2 }] } } * @since 1.0.0 */ -var orderBy$1 = immutadot.convert(lodash.orderBy); +var orderBy = immutadot.convert(lodash.orderBy); /** * Replaces by an array of elements predicate returns falsy for. @@ -478,7 +478,7 @@ var orderBy$1 = immutadot.convert(lodash.orderBy); * @example reject({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [2, 4] } } * @since 1.0.0 */ -var reject$1 = immutadot.convert(lodash.reject); +var reject = immutadot.convert(lodash.reject); /** * Replaces by an array of shuffled elements. @@ -491,7 +491,7 @@ var reject$1 = immutadot.convert(lodash.reject); * @example shuffle({ nested: { prop: [1, 2, 3, 4, 5, 6, 7, 8, 9] } }, 'nested.prop') // => { nested: { prop: [7, 3, 9, 1, 4, 5, 6, 8, 2] } } * @since 1.0.0 */ -var shuffle$1 = immutadot.convert(lodash.shuffle); +var shuffle = immutadot.convert(lodash.shuffle); /** * Replaces by an array of sorted by iteratees. @@ -507,7 +507,7 @@ var shuffle$1 = immutadot.convert(lodash.shuffle); * // => { nested: { prop: [{ name: 'Nico', age: 30 }, { name: 'Nico', age: 666 }, { name: 'Yvo', age: 2 }] } } * @since 1.0.0 */ -var sortBy$1 = immutadot.convert(lodash.sortBy); +var sortBy = immutadot.convert(lodash.sortBy); /** * Replaces by an object assigning own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined.
@@ -522,7 +522,7 @@ var sortBy$1 = immutadot.convert(lodash.sortBy); * @see {@link https://lodash.com/docs#defaults|lodash.defaults} for more information. * @since 1.0.0 */ -var defaults$1 = convertLodashFp(fp.defaults); +var defaults = convertLodashFp(fp.defaults); /** * Replaces by an object with the same values as the former object and values generated by running each own enumerable string keyed property of the former object thru iteratee. @@ -537,7 +537,7 @@ var defaults$1 = convertLodashFp(fp.defaults); * @see {@link https://lodash.com/docs#mapKeys|lodash.mapKeys} for more information. * @since 1.0.0 */ -var mapKeys$1 = immutadot.convert(lodash.mapKeys); +var mapKeys = immutadot.convert(lodash.mapKeys); /** * Replaces by an object with the same keys as the former object and values generated by running each own enumerable string keyed property of object thru iteratee. @@ -553,7 +553,7 @@ var mapKeys$1 = immutadot.convert(lodash.mapKeys); * @see {@link https://lodash.com/docs#mapValues|lodash.mapValues} for more information. * @since 1.0.0 */ -var mapValues$1 = immutadot.convert(lodash.mapValues); +var mapValues = immutadot.convert(lodash.mapValues); /** * Replaces by an object deeply merging own enumerable string keyed properties of source objects to the former object.
@@ -568,7 +568,7 @@ var mapValues$1 = immutadot.convert(lodash.mapValues); * @see {@link https://lodash.com/docs#merge|lodash.merge} for more information. * @since 1.0.0 */ -var merge$1 = convertLodashFp(fp.merge); +var merge = convertLodashFp(fp.merge); /** * Replaces by an object omitting specified properties. @@ -582,7 +582,7 @@ var merge$1 = convertLodashFp(fp.merge); * @see {@link https://lodash.com/docs#omit|lodash.omit} for more information. * @since 1.0.0 */ -var omit$1 = immutadot.convert(lodash.omit); +var omit = immutadot.convert(lodash.omit); /** * Replaces by an object omitting properties that predicate doesn't return truthy for. @@ -596,7 +596,7 @@ var omit$1 = immutadot.convert(lodash.omit); * @see {@link https://lodash.com/docs#omitBy|lodash.omitBy} for more information. * @since 1.0.0 */ -var omitBy$1 = immutadot.convert(lodash.omitBy); +var omitBy = immutadot.convert(lodash.omitBy); /** * Replaces by an object picking specified properties. @@ -610,7 +610,7 @@ var omitBy$1 = immutadot.convert(lodash.omitBy); * @see {@link https://lodash.com/docs#pick|lodash.pick} for more information. * @since 1.0.0 */ -var pick$1 = immutadot.convert(lodash.pick); +var pick = immutadot.convert(lodash.pick); /** * Replaces by an object picking properties that predicate returns truthy for. @@ -624,7 +624,7 @@ var pick$1 = immutadot.convert(lodash.pick); * @see {@link https://lodash.com/docs#pickBy|lodash.pickBy} for more information. * @since 1.0.0 */ -var pickBy$1 = immutadot.convert(lodash.pickBy); +var pickBy = immutadot.convert(lodash.pickBy); /** * Converts the first character of string to upper case and the remaining to lower case. @@ -637,7 +637,7 @@ var pickBy$1 = immutadot.convert(lodash.pickBy); * @see {@link https://lodash.com/docs#capitalize|lodash.capitalize} for more information. * @since 1.0.0 */ -var capitalize$1 = immutadot.convert(lodash.capitalize); +var capitalize = immutadot.convert(lodash.capitalize); /** * Converts string, as a whole, to lower case just like String#toLowerCase. @@ -651,7 +651,7 @@ var capitalize$1 = immutadot.convert(lodash.capitalize); * @see {@link https://mdn.io/String/toLowerCase|String.toLowerCase} for more information. * @since 1.0.0 */ -var toLower$1 = immutadot.convert(lodash.toLower); +var toLower = immutadot.convert(lodash.toLower); /** * Converts string, as a whole, to upper case just like String#toUpperCase. @@ -665,52 +665,52 @@ var toLower$1 = immutadot.convert(lodash.toLower); * @see {@link https://mdn.io/String/toUpperCase|String.toUpperCase} for more information. * @since 1.0.0 */ -var toUpper$1 = immutadot.convert(lodash.toUpper); - -exports.difference = difference$1; -exports.differenceBy = differenceBy$1; -exports.differenceWith = differenceWith$1; -exports.drop = drop$1; -exports.dropRight = dropRight$1; -exports.dropRightWhile = dropRightWhile$1; -exports.dropWhile = dropWhile$1; -exports.intersection = intersection$1; -exports.intersectionBy = intersectionBy$1; -exports.intersectionWith = intersectionWith$1; -exports.pull = pull$1; -exports.pullAll = pullAll$1; -exports.pullAllBy = pullAllBy$1; -exports.pullAllWith = pullAllWith$1; -exports.pullAt = pullAt$1; -exports.remove = remove$1; -exports.take = take$1; -exports.takeRight = takeRight$1; -exports.takeRightWhile = takeRightWhile$1; -exports.takeWhile = takeWhile$1; -exports.union = union$1; -exports.unionBy = unionBy$1; -exports.unionWith = unionWith$1; +var toUpper = immutadot.convert(lodash.toUpper); + +exports.difference = difference; +exports.differenceBy = differenceBy; +exports.differenceWith = differenceWith; +exports.drop = drop; +exports.dropRight = dropRight; +exports.dropRightWhile = dropRightWhile; +exports.dropWhile = dropWhile; +exports.intersection = intersection; +exports.intersectionBy = intersectionBy; +exports.intersectionWith = intersectionWith; +exports.pull = pull; +exports.pullAll = pullAll; +exports.pullAllBy = pullAllBy; +exports.pullAllWith = pullAllWith; +exports.pullAt = pullAt; +exports.remove = remove; +exports.take = take; +exports.takeRight = takeRight; +exports.takeRightWhile = takeRightWhile; +exports.takeWhile = takeWhile; +exports.union = union; +exports.unionBy = unionBy; +exports.unionWith = unionWith; exports.without = without; -exports.xor = xor$1; -exports.xorBy = xorBy$1; -exports.xorWith = xorWith$1; -exports.filter = filter$1; -exports.map = map$1; -exports.orderBy = orderBy$1; -exports.reject = reject$1; -exports.shuffle = shuffle$1; -exports.sortBy = sortBy$1; -exports.defaults = defaults$1; -exports.mapKeys = mapKeys$1; -exports.mapValues = mapValues$1; -exports.merge = merge$1; -exports.omit = omit$1; -exports.omitBy = omitBy$1; -exports.pick = pick$1; -exports.pickBy = pickBy$1; -exports.capitalize = capitalize$1; -exports.toLower = toLower$1; -exports.toUpper = toUpper$1; +exports.xor = xor; +exports.xorBy = xorBy; +exports.xorWith = xorWith; +exports.filter = filter; +exports.map = map; +exports.orderBy = orderBy; +exports.reject = reject; +exports.shuffle = shuffle; +exports.sortBy = sortBy; +exports.defaults = defaults; +exports.mapKeys = mapKeys; +exports.mapValues = mapValues; +exports.merge = merge; +exports.omit = omit; +exports.omitBy = omitBy; +exports.pick = pick; +exports.pickBy = pickBy; +exports.capitalize = capitalize; +exports.toLower = toLower; +exports.toUpper = toUpper; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/dist/immutadot.js b/dist/immutadot.js index 3f839c94..b0761fbc 100644 --- a/dist/immutadot.js +++ b/dist/immutadot.js @@ -302,21 +302,21 @@ var _uid = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -var shared = _shared('keys'); +var shared$1 = _shared('keys'); var _sharedKey = function (key) { - return shared[key] || (shared[key] = _uid(key)); + return shared$1[key] || (shared$1[key] = _uid(key)); }; var arrayIndexOf = _arrayIncludes(false); -var IE_PROTO$1 = _sharedKey('IE_PROTO'); +var IE_PROTO = _sharedKey('IE_PROTO'); var _objectKeysInternal = function (object, names) { var O = _toIobject(object); var i = 0; var result = []; var key; - for (key in O) if (key != IE_PROTO$1) _has(O, key) && result.push(key); + for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key); // Don't enum bug & hidden keys while (names.length > i) if (_has(O, key = names[i++])) { ~arrayIndexOf(result, key) || result.push(key); @@ -354,7 +354,7 @@ var _html = document$1 && document$1.documentElement; -var IE_PROTO = _sharedKey('IE_PROTO'); +var IE_PROTO$1 = _sharedKey('IE_PROTO'); var Empty = function () { /* empty */ }; var PROTOTYPE$1 = 'prototype'; @@ -387,7 +387,7 @@ var _objectCreate = Object.create || function create(O, Properties) { result = new Empty(); Empty[PROTOTYPE$1] = null; // add "__proto__" for Object.getPrototypeOf polyfill - result[IE_PROTO] = O; + result[IE_PROTO$1] = O; } else result = createDict(); return Properties === undefined ? result : _objectDps(result, Properties); }; @@ -632,20 +632,20 @@ _export(_export.S + _export.F * !_iterDetect(function (iter) { }), 'Array', { } }); -var from$2 = _core.Array.from; +var from = _core.Array.from; -var from = createCommonjsModule(function (module) { -module.exports = { "default": from$2, __esModule: true }; +var from$2 = createCommonjsModule(function (module) { +module.exports = { "default": from, __esModule: true }; }); -unwrapExports(from); +unwrapExports(from$2); var toConsumableArray = createCommonjsModule(function (module, exports) { exports.__esModule = true; -var _from2 = _interopRequireDefault(from); +var _from2 = _interopRequireDefault(from$2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -715,13 +715,13 @@ var core_getIterator = _core.getIterator = function (it) { return _anObject(iterFn.call(it)); }; -var getIterator$1 = core_getIterator; +var getIterator = core_getIterator; -var getIterator = createCommonjsModule(function (module) { -module.exports = { "default": getIterator$1, __esModule: true }; +var getIterator$2 = createCommonjsModule(function (module) { +module.exports = { "default": getIterator, __esModule: true }; }); -var _getIterator = unwrapExports(getIterator); +var _getIterator = unwrapExports(getIterator$2); // most Object methods by ES6 should accept primitives @@ -744,13 +744,13 @@ _objectSap('keys', function () { }; }); -var keys$1 = _core.Object.keys; +var keys = _core.Object.keys; -var keys = createCommonjsModule(function (module) { -module.exports = { "default": keys$1, __esModule: true }; +var keys$2 = createCommonjsModule(function (module) { +module.exports = { "default": keys, __esModule: true }; }); -var _Object$keys = unwrapExports(keys); +var _Object$keys = unwrapExports(keys$2); var ITERATOR$4 = _wks('iterator'); @@ -762,24 +762,24 @@ var core_isIterable = _core.isIterable = function (it) { || _iterators.hasOwnProperty(_classof(O)); }; -var isIterable$2 = core_isIterable; +var isIterable = core_isIterable; -var isIterable = createCommonjsModule(function (module) { -module.exports = { "default": isIterable$2, __esModule: true }; +var isIterable$2 = createCommonjsModule(function (module) { +module.exports = { "default": isIterable, __esModule: true }; }); -unwrapExports(isIterable); +unwrapExports(isIterable$2); var slicedToArray = createCommonjsModule(function (module, exports) { exports.__esModule = true; -var _isIterable3 = _interopRequireDefault(isIterable); +var _isIterable3 = _interopRequireDefault(isIterable$2); -var _getIterator3 = _interopRequireDefault(getIterator); +var _getIterator3 = _interopRequireDefault(getIterator$2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -824,12 +824,12 @@ exports.default = function () { var _slicedToArray = unwrapExports(slicedToArray); -var toArray$1 = createCommonjsModule(function (module, exports) { +var toArray = createCommonjsModule(function (module, exports) { exports.__esModule = true; -var _from2 = _interopRequireDefault(from); +var _from2 = _interopRequireDefault(from$2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -838,7 +838,7 @@ exports.default = function (arr) { }; }); -var _toArray = unwrapExports(toArray$1); +var _toArray = unwrapExports(toArray); var f$1 = Object.getOwnPropertySymbols; @@ -891,20 +891,20 @@ var _objectAssign = !$assign || _fails(function () { _export(_export.S + _export.F, 'Object', { assign: _objectAssign }); -var assign$1 = _core.Object.assign; +var assign = _core.Object.assign; -var assign = createCommonjsModule(function (module) { -module.exports = { "default": assign$1, __esModule: true }; +var assign$2 = createCommonjsModule(function (module) { +module.exports = { "default": assign, __esModule: true }; }); -var _Object$assign = unwrapExports(assign); +var _Object$assign = unwrapExports(assign$2); var _extends = createCommonjsModule(function (module, exports) { exports.__esModule = true; -var _assign2 = _interopRequireDefault(assign); +var _assign2 = _interopRequireDefault(assign$2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -1025,17 +1025,17 @@ var _isArray = Array.isArray || function isArray(arg) { var hiddenKeys = _enumBugKeys.concat('length', 'prototype'); -var f$5 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { +var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return _objectKeysInternal(O, hiddenKeys); }; var _objectGopn = { - f: f$5 + f: f$4 }; // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window -var gOPN$1 = _objectGopn.f; +var gOPN = _objectGopn.f; var toString$1 = {}.toString; var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames @@ -1043,27 +1043,27 @@ var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNa var getWindowNames = function (it) { try { - return gOPN$1(it); + return gOPN(it); } catch (e) { return windowNames.slice(); } }; -var f$4 = function getOwnPropertyNames(it) { - return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN$1(_toIobject(it)); +var f$5 = function getOwnPropertyNames(it) { + return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(_toIobject(it)); }; var _objectGopnExt = { - f: f$4 + f: f$5 }; -var gOPD$1 = Object.getOwnPropertyDescriptor; +var gOPD = Object.getOwnPropertyDescriptor; -var f$6 = _descriptors ? gOPD$1 : function getOwnPropertyDescriptor(O, P) { +var f$6 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) { O = _toIobject(O); P = _toPrimitive(P, true); if (_ie8DomDefine) try { - return gOPD$1(O, P); + return gOPD(O, P); } catch (e) { /* empty */ } if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); }; @@ -1097,9 +1097,9 @@ var META = _meta.KEY; -var gOPD = _objectGopd.f; +var gOPD$1 = _objectGopd.f; var dP$1 = _objectDp.f; -var gOPN = _objectGopnExt.f; +var gOPN$1 = _objectGopnExt.f; var $Symbol = _global.Symbol; var $JSON = _global.JSON; var _stringify = $JSON && $JSON.stringify; @@ -1122,7 +1122,7 @@ var setSymbolDesc = _descriptors && _fails(function () { get: function () { return dP$1(this, 'a', { value: 7 }).a; } })).a != 7; }) ? function (it, key, D) { - var protoDesc = gOPD(ObjectProto$1, key); + var protoDesc = gOPD$1(ObjectProto$1, key); if (protoDesc) delete ObjectProto$1[key]; dP$1(it, key, D); if (protoDesc && it !== ObjectProto$1) dP$1(ObjectProto$1, key, protoDesc); @@ -1176,12 +1176,12 @@ var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { it = _toIobject(it); key = _toPrimitive(key, true); if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return; - var D = gOPD(it, key); + var D = gOPD$1(it, key); if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; return D; }; var $getOwnPropertyNames = function getOwnPropertyNames(it) { - var names = gOPN(_toIobject(it)); + var names = gOPN$1(_toIobject(it)); var result = []; var i = 0; var key; @@ -1191,7 +1191,7 @@ var $getOwnPropertyNames = function getOwnPropertyNames(it) { }; var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { var IS_OP = it === ObjectProto$1; - var names = gOPN(IS_OP ? OPSymbols : _toIobject(it)); + var names = gOPN$1(IS_OP ? OPSymbols : _toIobject(it)); var result = []; var i = 0; var key; @@ -1310,13 +1310,13 @@ _wksDefine('asyncIterator'); _wksDefine('observable'); -var symbol$1 = _core.Symbol; +var symbol = _core.Symbol; -var symbol = createCommonjsModule(function (module) { -module.exports = { "default": symbol$1, __esModule: true }; +var symbol$2 = createCommonjsModule(function (module) { +module.exports = { "default": symbol, __esModule: true }; }); -var _Symbol = unwrapExports(symbol); +var _Symbol = unwrapExports(symbol$2); var allProps = _Symbol('allProps'); var index = _Symbol('index'); @@ -1342,32 +1342,32 @@ _export(_export.S, 'Number', { } }); -var isSafeInteger$1 = _core.Number.isSafeInteger; +var isSafeInteger = _core.Number.isSafeInteger; -var isSafeInteger = createCommonjsModule(function (module) { -module.exports = { "default": isSafeInteger$1, __esModule: true }; +var isSafeInteger$2 = createCommonjsModule(function (module) { +module.exports = { "default": isSafeInteger, __esModule: true }; }); -var _Number$isSafeInteger = unwrapExports(isSafeInteger); +var _Number$isSafeInteger = unwrapExports(isSafeInteger$2); -var iterator$2 = _wksExt.f('iterator'); +var iterator = _wksExt.f('iterator'); -var iterator = createCommonjsModule(function (module) { -module.exports = { "default": iterator$2, __esModule: true }; +var iterator$2 = createCommonjsModule(function (module) { +module.exports = { "default": iterator, __esModule: true }; }); -unwrapExports(iterator); +unwrapExports(iterator$2); var _typeof_1 = createCommonjsModule(function (module, exports) { exports.__esModule = true; -var _iterator2 = _interopRequireDefault(iterator); +var _iterator2 = _interopRequireDefault(iterator$2); -var _symbol2 = _interopRequireDefault(symbol); +var _symbol2 = _interopRequireDefault(symbol$2); var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; @@ -1938,13 +1938,13 @@ var _setCollectionFrom = function (COLLECTION) { // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from _setCollectionFrom('Map'); -var map$1 = _core.Map; +var map = _core.Map; -var map = createCommonjsModule(function (module) { -module.exports = { "default": map$1, __esModule: true }; +var map$2 = createCommonjsModule(function (module) { +module.exports = { "default": map, __esModule: true }; }); -var _Map = unwrapExports(map); +var _Map = unwrapExports(map$2); var runtime = createCommonjsModule(function (module) { /** @@ -2749,7 +2749,7 @@ var regexp = function regexp(_regexp) { * @private * @since 1.0.0 */ -var filter$1 = function filter(parser, predicate) { +var filter = function filter(parser, predicate) { return function (str) { return maybeMap(parser(str), function (parsed) { return predicate(parsed) ? parsed : null; @@ -2851,25 +2851,6 @@ var isSliceIndexString = function isSliceIndexString(arg) { return isSliceIndex(arg ? Number(arg) : undefined); }; -/** - * Wraps fn allowing to call it with an array instead of a string.
- * The returned function behaviour is :
- * - If called with an array, returns a copy of the array with values converted to path keys
- * - Otherwise, calls fn with the string representation of its argument - * @function - * @param {function} fn The function to wrap - * @returns {function} The wrapper function - * @memberof path - * @private - * @since 1.0.0 - */ -var allowingArrays = function allowingArrays(fn) { - return function (arg) { - if (Array.isArray(arg)) return arg; - return fn(arg); - }; -}; - var emptyStringParser = function emptyStringParser(str) { return str.length === 0 ? [] : null; }; @@ -2880,7 +2861,7 @@ var quotedBracketNotationParser = map$3(regexp(/^\[(['"])(.*?[^\\])\1\]?\.?(.*)$ property = _ref2[1], rest = _ref2[2]; - return [[prop, unescapeQuotes(property, quote)]].concat(_toConsumableArray(stringToPath(rest))); + return [[prop, unescapeQuotes(property, quote)]].concat(_toConsumableArray(applyParsers(rest))); }); var incompleteQuotedBracketNotationParser = map$3(regexp(/^(\[["'][^.[{]*)\.?(.*)$/), function (_ref3) { @@ -2888,7 +2869,7 @@ var incompleteQuotedBracketNotationParser = map$3(regexp(/^(\[["'][^.[{]*)\.?(.* beforeNewSegment = _ref4[0], rest = _ref4[1]; - return [[prop, beforeNewSegment]].concat(_toConsumableArray(stringToPath(rest))); + return [[prop, beforeNewSegment]].concat(_toConsumableArray(applyParsers(rest))); }); var bareBracketNotationParser = map$3(regexp(/^\[([^\]]*)\]\.?(.*)$/), function (_ref5) { @@ -2896,7 +2877,7 @@ var bareBracketNotationParser = map$3(regexp(/^\[([^\]]*)\]\.?(.*)$/), function property = _ref6[0], rest = _ref6[1]; - return isIndex(Number(property)) ? [[index, Number(property)]].concat(_toConsumableArray(stringToPath(rest))) : [[prop, property]].concat(_toConsumableArray(stringToPath(rest))); + return isIndex(Number(property)) ? [[index, Number(property)]].concat(_toConsumableArray(applyParsers(rest))) : [[prop, property]].concat(_toConsumableArray(applyParsers(rest))); }); var incompleteBareBracketNotationParser = map$3(regexp(/^(\[[^.[{]*)\.?(.*)$/), function (_ref7) { @@ -2904,10 +2885,10 @@ var incompleteBareBracketNotationParser = map$3(regexp(/^(\[[^.[{]*)\.?(.*)$/), beforeNewSegment = _ref8[0], rest = _ref8[1]; - return [[prop, beforeNewSegment]].concat(_toConsumableArray(stringToPath(rest))); + return [[prop, beforeNewSegment]].concat(_toConsumableArray(applyParsers(rest))); }); -var sliceNotationParser = map$3(filter$1(regexp(/^\[([^:\]]*):([^:\]]*)\]\.?(.*)$/), function (_ref9) { +var sliceNotationParser = map$3(filter(regexp(/^\[([^:\]]*):([^:\]]*)\]\.?(.*)$/), function (_ref9) { var _ref10 = _slicedToArray(_ref9, 2), sliceStart = _ref10[0], sliceEnd = _ref10[1]; @@ -2919,14 +2900,14 @@ var sliceNotationParser = map$3(filter$1(regexp(/^\[([^:\]]*):([^:\]]*)\]\.?(.*) sliceEnd = _ref12[1], rest = _ref12[2]; - return [[slice, [toSliceIndex(sliceStart, 0), toSliceIndex(sliceEnd)]]].concat(_toConsumableArray(stringToPath(rest))); + return [[slice, [toSliceIndex(sliceStart, 0), toSliceIndex(sliceEnd)]]].concat(_toConsumableArray(applyParsers(rest))); }); var listWildCardParser = map$3(regexp(/^{\*}\.?(.*)$/), function (_ref13) { var _ref14 = _slicedToArray(_ref13, 1), rest = _ref14[0]; - return [[allProps]].concat(_toConsumableArray(stringToPath(rest))); + return [[allProps]].concat(_toConsumableArray(applyParsers(rest))); }); var listPropRegexp = /^,?((?!["'])([^,]*)|(["'])(.*?[^\\])\3)(.*)/; @@ -2977,7 +2958,7 @@ var listNotationParser = map$3(regexp(/^\{(((?!["'])[^,}]*|(["']).*?[^\\]\2)(,(( rest = _ref16[6]; var props = [].concat(_toConsumableArray(extractListProps(rawProps))); - return props.length === 1 ? [[prop, props[0]]].concat(_toConsumableArray(stringToPath(rest))) : [[list, props]].concat(_toConsumableArray(stringToPath(rest))); + return props.length === 1 ? [[prop, props[0]]].concat(_toConsumableArray(applyParsers(rest))) : [[list, props]].concat(_toConsumableArray(applyParsers(rest))); }); var incompleteListNotationParser = map$3(regexp(/^(\{[^.[{]*)\.?(.*)$/), function (_ref17) { @@ -2985,7 +2966,7 @@ var incompleteListNotationParser = map$3(regexp(/^(\{[^.[{]*)\.?(.*)$/), functio beforeNewSegment = _ref18[0], rest = _ref18[1]; - return [[prop, beforeNewSegment]].concat(_toConsumableArray(stringToPath(rest))); + return [[prop, beforeNewSegment]].concat(_toConsumableArray(applyParsers(rest))); }); var pathSegmentEndedByNewSegment = map$3(regexp(/^([^.[{]*)\.?([[{]?.*)$/), function (_ref19) { @@ -2993,34 +2974,28 @@ var pathSegmentEndedByNewSegment = map$3(regexp(/^([^.[{]*)\.?([[{]?.*)$/), func beforeNewSegment = _ref20[0], rest = _ref20[1]; - return [[prop, beforeNewSegment]].concat(_toConsumableArray(stringToPath(rest))); + return [[prop, beforeNewSegment]].concat(_toConsumableArray(applyParsers(rest))); }); var applyParsers = race([emptyStringParser, quotedBracketNotationParser, incompleteQuotedBracketNotationParser, sliceNotationParser, bareBracketNotationParser, incompleteBareBracketNotationParser, listWildCardParser, listNotationParser, incompleteListNotationParser, pathSegmentEndedByNewSegment]); -/** - * Converts arg to a path represented as an array of keys. - * @function - * @param {*} arg The value to convert - * @returns {Array} The path represented as an array of keys - * @memberof path - * @private - * @since 1.0.0 - */ -var stringToPath = function stringToPath(arg) { - if (isNil(arg)) return []; - return applyParsers(toString$2(arg)); -}; - var MAX_CACHE_SIZE = 1000; var cache = new _Map(); +var stringToPath = function stringToPath(pStr) { + var str = pStr.startsWith('.') ? pStr.substring(1) : pStr; + + var path = applyParsers(str); + + return pStr.endsWith('.') ? [].concat(_toConsumableArray(path), [[prop, '']]) : path; +}; + /** - * Memoized version of {@link core.stringToPath}.
+ * Memoized version of {@link path.stringToPath}.
* The cache has a maximum size of 1000, when overflowing the cache is cleared. * @function * @param {string} str The string to convert - * @returns {Array} The path represented as an array of keys + * @returns {Array>} The path represented as an array of keys * @memberof path * @private * @since 1.0.0 @@ -3037,15 +3012,23 @@ var memoizedStringToPath = function memoizedStringToPath(str) { }; /** - * This method is like {@link core.toPath} except it returns memoized arrays which must not be mutated. + * Converts arg to a path represented as an array of keys.
+ * arg may be a string, in which case it will be parsed.
+ * It may also be an Array, in which case a copy of the array with values converted to path keys will be returned.
+ * If arg is neither a string nor an Array, its string representation will be parsed. * @function * @param {string|Array|*} arg The value to convert - * @returns {Array>} The path represented as an array of keys + * @returns {Array>} The path represented as an array of keys * @memberof path * @since 1.0.0 + * @example toPath('a.b[1]["."][1:-1]') // => [[prop, 'a'], [prop, 'b'], [index, 1], [prop, '.'], [slice, [1, -1]]] * @private */ -var unsafeToPath = allowingArrays(memoizedStringToPath); +var toPath = function toPath(arg) { + if (isNil(arg)) return []; + + return memoizedStringToPath(toString$2(arg)); +}; /** * Makes a copy of value. @@ -3120,7 +3103,7 @@ var apply = function apply(operation) { args[_key - 1] = arguments[_key]; } - var path = unsafeToPath(pPath); + var path = toPath(pPath); if (path.length === 0) throw new TypeError('path should not be empty'); @@ -3161,7 +3144,7 @@ var apply = function apply(operation) { var _newObj = copy(curObj, false); var _noop2 = true; - var listProps = allProps ? _Object$keys(_newObj) : propValue; + var listProps = propType === allProps ? _Object$keys(_newObj) : propValue; var _iteratorNormalCompletion = true; var _didIteratorError = false; @@ -3277,7 +3260,7 @@ var convert = function convert(updater) { return apply(makeOperation(updater)); }; -var toArray = function toArray(array) { +var toArray$1 = function toArray(array) { if (isNil(array)) return []; if (Array.isArray(array)) return array; return [array]; @@ -3311,7 +3294,7 @@ var callMethodReturnArray = function callMethodReturnArray(array, method, args) var convertArrayMethod = function convertArrayMethod(method) { var mutating = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - var getArray = mutating ? toArrayCopy : toArray; + var getArray = mutating ? toArrayCopy : toArray$1; var callMethod = mutating ? callMethodReturnArray : callMethodReturnResult; return convert(function (value) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { @@ -3334,7 +3317,7 @@ var convertArrayMethod = function convertArrayMethod(method) { * @see {@link https://mdn.io/Array.prototype.filter|Array.prototype.filter} for more information. * @since 1.0.0 */ -var filter = convertArrayMethod('filter', false); +var filter$1 = convertArrayMethod('filter', false); /** * Replaces an array concatenating the former array with additional arrays and/or values.
@@ -3595,7 +3578,7 @@ function get(obj, path, defaultValue) { return walkPath(curObj[prop$$1], pathRest); } - var parsedPath = unsafeToPath(path); + var parsedPath = toPath(path); if (parsedPath.some(function (_ref) { var _ref2 = _slicedToArray(_ref, 1), propType = _ref2[0]; @@ -3687,6 +3670,28 @@ var add = convert(function (value, addition) { return Number(value) + Number(addition); }); +/** + * Applies && between the former value and args + * @function + * @memberof lang + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {...*} [args] Other operands. + * @return {Object} Returns the updated object. + * @example and({ nested: { prop: true } }, 'nested.prop', true) // { nested: { prop: true } } + * @example and({ nested: { prop: true } }, 'nested.prop', true, false) // { nested: { prop: false } } + * @since 1.0.0 + */ +var and = convert(function (v) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return args.reduce(function (acc, arg) { + return acc && arg; + }, v); +}); + /** * Replaces by the division of the former number and the given number. * @function @@ -3717,6 +3722,28 @@ var multiply = convert(function (value, multiplier) { return Number(value) * Number(multiplier); }); +/** + * Applies || between the former value and args + * @function + * @memberof lang + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {...*} [args] Other operands. + * @return {Object} Returns the updated object. + * @example or({ nested: { prop: false } }, 'nested.prop', true) // { nested: { prop: true } } + * @example or({ nested: { prop: true } }, 'nested.prop', false, false) // { nested: { prop: true } } + * @since 1.0.0 + */ +var or = convert(function (v) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return args.reduce(function (acc, arg) { + return acc || arg; + }, v); +}); + /** * Replaces by the subtraction of the former number by the given number. * @function @@ -4003,7 +4030,7 @@ var trimRight = convertStringMethod('trimRight'); exports.arrayConcat = concat; exports.fill = fill; -exports.filter = filter; +exports.filter = filter$1; exports.map = map$4; exports.pop = pop; exports.push = push; @@ -4034,8 +4061,10 @@ exports.set = set; exports.unset = unset; exports.update = update; exports.add = add; +exports.and = and; exports.divide = divide; exports.multiply = multiply; +exports.or = or; exports.subtract = subtract; exports.toggle = toggle; exports.assign = assign$3; diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index c224a05e..b45d4f67 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -47,8 +47,8 @@ const animals = { weasels: { lutraLutra: { commonNames: ['eurasian otter'], - } - } + }, + }, } const newAnimals = { @@ -58,8 +58,8 @@ const newAnimals = { lutraLutra: { ...animals.weasels.otter, name: 'Lutra lutra', - } - } + }, + }, } ``` @@ -72,8 +72,8 @@ const animals = { weasels: { lutraLutra: { commonNames: ['eurasian otter'], - } - } + }, + }, } const newAnimals = set(animals, 'weasels.lutraLutra.name', 'Lutrinae') diff --git a/docs/immutadot-lodash/1.0/array_difference.js.html b/docs/immutadot-lodash/1.0/array_difference.js.html index 064413d2..7e339911 100644 --- a/docs/immutadot-lodash/1.0/array_difference.js.html +++ b/docs/immutadot-lodash/1.0/array_difference.js.html @@ -35,7 +35,7 @@

array/difference.js

-
  1. import _difference from 'lodash/difference'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces an array removing values in the other given arrays from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} values The arrays of values to exclude.
  10. * @return {Object} Returns the updated object.
  11. * @example difference({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1] } }
  12. * @see {@link https://lodash.com/docs#difference|lodash.difference} for more information.
  13. * @since 1.0.0
  14. */
  15. const difference = convert(_difference)
  16. export { difference }
+
  1. import { difference as _difference } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces an array removing values in the other given arrays from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} values The arrays of values to exclude.
  10. * @return {Object} Returns the updated object.
  11. * @example difference({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1] } }
  12. * @see {@link https://lodash.com/docs#difference|lodash.difference} for more information.
  13. * @since 1.0.0
  14. */
  15. const difference = convert(_difference)
  16. export { difference }
diff --git a/docs/immutadot-lodash/1.0/array_differenceBy.js.html b/docs/immutadot-lodash/1.0/array_differenceBy.js.html index 7cf05d5c..93d88d48 100644 --- a/docs/immutadot-lodash/1.0/array_differenceBy.js.html +++ b/docs/immutadot-lodash/1.0/array_differenceBy.js.html @@ -35,7 +35,7 @@

array/differenceBy.js

-
  1. import _differenceBy from 'lodash/differenceBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.difference} except that it uses <code>iteratee</code> to generate the value to be compared for each element.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} values The arrays of values to exclude.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example differenceBy({ nested: { prop: [1.2, 3.4, 5.6] } }, 'nested.prop', [5.4, 2.1], Math.floor) // => { nested: { prop: [1.2, 3.4] } }
  13. * @see {@link https://lodash.com/docs#differenceBy|lodash.differenceBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const differenceBy = convert(_differenceBy)
  17. export { differenceBy }
+
  1. import { differenceBy as _differenceBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.difference} except that it uses <code>iteratee</code> to generate the value to be compared for each element.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} values The arrays of values to exclude.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example differenceBy({ nested: { prop: [1.2, 3.4, 5.6] } }, 'nested.prop', [5.4, 2.1], Math.floor) // => { nested: { prop: [1.2, 3.4] } }
  13. * @see {@link https://lodash.com/docs#differenceBy|lodash.differenceBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const differenceBy = convert(_differenceBy)
  17. export { differenceBy }
diff --git a/docs/immutadot-lodash/1.0/array_differenceWith.js.html b/docs/immutadot-lodash/1.0/array_differenceWith.js.html index ac704ce9..a394964a 100644 --- a/docs/immutadot-lodash/1.0/array_differenceWith.js.html +++ b/docs/immutadot-lodash/1.0/array_differenceWith.js.html @@ -35,7 +35,7 @@

array/differenceWith.js

-
  1. import _differenceWith from 'lodash/differenceWith'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.difference} except that it uses <code>comparator</code> to compare elements of the former array to <code>values</code>.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} values The arrays of values to exclude.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example differenceWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 1 }] } }
  13. * @see {@link https://lodash.com/docs#differenceWith|lodash.differenceWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const differenceWith = convert(_differenceWith)
  17. export { differenceWith }
+
  1. import { differenceWith as _differenceWith } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.difference} except that it uses <code>comparator</code> to compare elements of the former array to <code>values</code>.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} values The arrays of values to exclude.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example differenceWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 1 }] } }
  13. * @see {@link https://lodash.com/docs#differenceWith|lodash.differenceWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const differenceWith = convert(_differenceWith)
  17. export { differenceWith }
diff --git a/docs/immutadot-lodash/1.0/array_drop.js.html b/docs/immutadot-lodash/1.0/array_drop.js.html index f33b1ead..e5e3dfa2 100644 --- a/docs/immutadot-lodash/1.0/array_drop.js.html +++ b/docs/immutadot-lodash/1.0/array_drop.js.html @@ -35,7 +35,7 @@

array/drop.js

-
  1. import _drop from 'lodash/drop'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces an array dropping one or several elements at the start of the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] The number of elements to drop.
  10. * @return {Object} Returns the updated object.
  11. * @example drop({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [3, 4] } }
  12. * @see {@link https://lodash.com/docs#drop|lodash.drop} for more information.
  13. * @since 1.0.0
  14. */
  15. const drop = convert(_drop)
  16. export { drop }
+
  1. import { drop as _drop } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces an array dropping one or several elements at the start of the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] The number of elements to drop.
  10. * @return {Object} Returns the updated object.
  11. * @example drop({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [3, 4] } }
  12. * @see {@link https://lodash.com/docs#drop|lodash.drop} for more information.
  13. * @since 1.0.0
  14. */
  15. const drop = convert(_drop)
  16. export { drop }
diff --git a/docs/immutadot-lodash/1.0/array_dropRight.js.html b/docs/immutadot-lodash/1.0/array_dropRight.js.html index 25ce0a06..d300365f 100644 --- a/docs/immutadot-lodash/1.0/array_dropRight.js.html +++ b/docs/immutadot-lodash/1.0/array_dropRight.js.html @@ -35,7 +35,7 @@

array/dropRight.js

-
  1. import _dropRight from 'lodash/dropRight'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces an array dropping one or several elements at the end of the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] The number of elements to drop.
  10. * @return {Object} Returns the updated object.
  11. * @example dropRight({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#dropRight|lodash.dropRight} for more information.
  13. * @since 1.0.0
  14. */
  15. const dropRight = convert(_dropRight)
  16. export { dropRight }
+
  1. import { dropRight as _dropRight } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces an array dropping one or several elements at the end of the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] The number of elements to drop.
  10. * @return {Object} Returns the updated object.
  11. * @example dropRight({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#dropRight|lodash.dropRight} for more information.
  13. * @since 1.0.0
  14. */
  15. const dropRight = convert(_dropRight)
  16. export { dropRight }
diff --git a/docs/immutadot-lodash/1.0/array_dropRightWhile.js.html b/docs/immutadot-lodash/1.0/array_dropRightWhile.js.html index d1ebfc58..53f63a31 100644 --- a/docs/immutadot-lodash/1.0/array_dropRightWhile.js.html +++ b/docs/immutadot-lodash/1.0/array_dropRightWhile.js.html @@ -35,7 +35,7 @@

array/dropRightWhile.js

-
  1. import _dropRightWhile from 'lodash/dropRightWhile'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces an array excluding elements dropped from the end. Elements are dropped until <code>predicate</code> returns falsey.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example dropRightWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#dropRightWhile|lodash.dropRightWhile} for more information.
  13. * @since 1.0.0
  14. */
  15. const dropRightWhile = convert(_dropRightWhile)
  16. export { dropRightWhile }
+
  1. import { dropRightWhile as _dropRightWhile } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces an array excluding elements dropped from the end. Elements are dropped until <code>predicate</code> returns falsey.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example dropRightWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#dropRightWhile|lodash.dropRightWhile} for more information.
  13. * @since 1.0.0
  14. */
  15. const dropRightWhile = convert(_dropRightWhile)
  16. export { dropRightWhile }
diff --git a/docs/immutadot-lodash/1.0/array_dropWhile.js.html b/docs/immutadot-lodash/1.0/array_dropWhile.js.html index 8f17d338..7fca5938 100644 --- a/docs/immutadot-lodash/1.0/array_dropWhile.js.html +++ b/docs/immutadot-lodash/1.0/array_dropWhile.js.html @@ -35,7 +35,7 @@

array/dropWhile.js

-
  1. import _dropWhile from 'lodash/dropWhile'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces an array excluding elements dropped from the beginning. Elements are dropped until <code>predicate</code> returns falsey.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example dropWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v < 3) // => { nested: { prop: [3, 4] } }
  12. * @see {@link https://lodash.com/docs#dropWhile|lodash.dropWhile} for more information.
  13. * @since 1.0.0
  14. */
  15. const dropWhile = convert(_dropWhile)
  16. export { dropWhile }
+
  1. import { dropWhile as _dropWhile } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces an array excluding elements dropped from the beginning. Elements are dropped until <code>predicate</code> returns falsey.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example dropWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v < 3) // => { nested: { prop: [3, 4] } }
  12. * @see {@link https://lodash.com/docs#dropWhile|lodash.dropWhile} for more information.
  13. * @since 1.0.0
  14. */
  15. const dropWhile = convert(_dropWhile)
  16. export { dropWhile }
diff --git a/docs/immutadot-lodash/1.0/array_intersection.js.html b/docs/immutadot-lodash/1.0/array_intersection.js.html index dd39b650..1779c817 100644 --- a/docs/immutadot-lodash/1.0/array_intersection.js.html +++ b/docs/immutadot-lodash/1.0/array_intersection.js.html @@ -35,7 +35,7 @@

array/intersection.js

-
  1. import _intersection from 'lodash/intersection'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an array of unique values that are included in th former array and all given arrays.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @return {Object} Returns the updated object.
  11. * @example intersection({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [2] } }
  12. * @see {@link https://lodash.com/docs#intersection|lodash.intersection} for more information.
  13. * @since 1.0.0
  14. */
  15. const intersection = convert(_intersection)
  16. export { intersection }
+
  1. import { intersection as _intersection } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an array of unique values that are included in th former array and all given arrays.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @return {Object} Returns the updated object.
  11. * @example intersection({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [2] } }
  12. * @see {@link https://lodash.com/docs#intersection|lodash.intersection} for more information.
  13. * @since 1.0.0
  14. */
  15. const intersection = convert(_intersection)
  16. export { intersection }
diff --git a/docs/immutadot-lodash/1.0/array_intersectionBy.js.html b/docs/immutadot-lodash/1.0/array_intersectionBy.js.html index e219b153..b42d6e91 100644 --- a/docs/immutadot-lodash/1.0/array_intersectionBy.js.html +++ b/docs/immutadot-lodash/1.0/array_intersectionBy.js.html @@ -35,7 +35,7 @@

array/intersectionBy.js

-
  1. import _intersectionBy from 'lodash/intersectionBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.intersection} except that it uses <code>iteratee</code> to generate the value to be compared for each element.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example intersectionBy({ nested: { prop: [1.2, 2.1] } }, 'nested.prop', [2.3, 3.2], Math.floor) // => { nested: { prop: [2.1] } }
  13. * @see {@link https://lodash.com/docs#intersectionBy|lodash.intersectionBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const intersectionBy = convert(_intersectionBy)
  17. export { intersectionBy }
+
  1. import { intersectionBy as _intersectionBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.intersection} except that it uses <code>iteratee</code> to generate the value to be compared for each element.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example intersectionBy({ nested: { prop: [1.2, 2.1] } }, 'nested.prop', [2.3, 3.2], Math.floor) // => { nested: { prop: [2.1] } }
  13. * @see {@link https://lodash.com/docs#intersectionBy|lodash.intersectionBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const intersectionBy = convert(_intersectionBy)
  17. export { intersectionBy }
diff --git a/docs/immutadot-lodash/1.0/array_intersectionWith.js.html b/docs/immutadot-lodash/1.0/array_intersectionWith.js.html index 04e3aaed..0afa44ff 100644 --- a/docs/immutadot-lodash/1.0/array_intersectionWith.js.html +++ b/docs/immutadot-lodash/1.0/array_intersectionWith.js.html @@ -35,7 +35,7 @@

array/intersectionWith.js

-
  1. import _intersectionWith from 'lodash/intersectionWith'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.intersection} except that it uses <code>comparator</code> to compare elements of the former array to <code>arrays</code>.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example intersectionWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 2 }] } }
  13. * @see {@link https://lodash.com/docs#intersectionWith|lodash.intersectionWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const intersectionWith = convert(_intersectionWith)
  17. export { intersectionWith }
+
  1. import { intersectionWith as _intersectionWith } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.intersection} except that it uses <code>comparator</code> to compare elements of the former array to <code>arrays</code>.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example intersectionWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 2 }] } }
  13. * @see {@link https://lodash.com/docs#intersectionWith|lodash.intersectionWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const intersectionWith = convert(_intersectionWith)
  17. export { intersectionWith }
diff --git a/docs/immutadot-lodash/1.0/array_pull.js.html b/docs/immutadot-lodash/1.0/array_pull.js.html index 02e238ff..493552bf 100644 --- a/docs/immutadot-lodash/1.0/array_pull.js.html +++ b/docs/immutadot-lodash/1.0/array_pull.js.html @@ -35,7 +35,7 @@

array/pull.js

-
  1. import _pull from 'lodash/fp/pull'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces an array removing all given values from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...*} values The values to remove.
  10. * @return {Object} Returns the updated object.
  11. * @example pull({ nested: { prop: [1, 2, 3, 1, 2, 3] } }, 'nested.prop', 1, 3) // => { nested: { prop: [2, 2] } }
  12. * @see {@link https://lodash.com/docs#pull|lodash.pull} for more information.
  13. * @since 1.0.0
  14. */
  15. const pull = convertLodashFp(_pull)
  16. export { pull }
+
  1. import { pull as _pull } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces an array removing all given values from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...*} values The values to remove.
  10. * @return {Object} Returns the updated object.
  11. * @example pull({ nested: { prop: [1, 2, 3, 1, 2, 3] } }, 'nested.prop', 1, 3) // => { nested: { prop: [2, 2] } }
  12. * @see {@link https://lodash.com/docs#pull|lodash.pull} for more information.
  13. * @since 1.0.0
  14. */
  15. const pull = convertLodashFp(_pull)
  16. export { pull }
diff --git a/docs/immutadot-lodash/1.0/array_pullAll.js.html b/docs/immutadot-lodash/1.0/array_pullAll.js.html index 97598104..bed6c0e8 100644 --- a/docs/immutadot-lodash/1.0/array_pullAll.js.html +++ b/docs/immutadot-lodash/1.0/array_pullAll.js.html @@ -35,7 +35,7 @@

array/pullAll.js

-
  1. import _pullAll from 'lodash/fp/pullAll'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * This method is like {@link array.pull} except that it accepts an array of values to remove.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array} values The values to remove.
  10. * @return {Object} Returns the updated object.
  11. * @example pullAll({ nested: { prop: [1, 2, 3, 1, 2, 3] } }, 'nested.prop', [1, 3]) // => { nested: { prop: [2, 2] } }
  12. * @see {@link https://lodash.com/docs#pullAll|lodash.pullAll} for more information.
  13. * @since 1.0.0
  14. */
  15. const pullAll = convertLodashFp(_pullAll)
  16. export { pullAll }
+
  1. import { pullAll as _pullAll } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * This method is like {@link array.pull} except that it accepts an array of values to remove.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array} values The values to remove.
  10. * @return {Object} Returns the updated object.
  11. * @example pullAll({ nested: { prop: [1, 2, 3, 1, 2, 3] } }, 'nested.prop', [1, 3]) // => { nested: { prop: [2, 2] } }
  12. * @see {@link https://lodash.com/docs#pullAll|lodash.pullAll} for more information.
  13. * @since 1.0.0
  14. */
  15. const pullAll = convertLodashFp(_pullAll)
  16. export { pullAll }
diff --git a/docs/immutadot-lodash/1.0/array_pullAllBy.js.html b/docs/immutadot-lodash/1.0/array_pullAllBy.js.html index 66e8ab04..85b7f6bd 100644 --- a/docs/immutadot-lodash/1.0/array_pullAllBy.js.html +++ b/docs/immutadot-lodash/1.0/array_pullAllBy.js.html @@ -35,7 +35,7 @@

array/pullAllBy.js

-
  1. import _pullAllBy from 'lodash/fp/pullAllBy'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * This method is like {@link array.pullAll} except that it accepts <code>iteratee</code> to generate the criterion by which each element is compared.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array} values The values to remove.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example pullAllBy({ nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }, { x: 2 }, { x: 3 }] } }, 'nested.prop', [{ x: 1 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 2 }, { x: 2 }] } }
  13. * @see {@link https://lodash.com/docs#pullAllBy|lodash.pullAllBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const pullAllBy = convertLodashFp(_pullAllBy)
  17. export { pullAllBy }
+
  1. import { pullAllBy as _pullAllBy } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * This method is like {@link array.pullAll} except that it accepts <code>iteratee</code> to generate the criterion by which each element is compared.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array} values The values to remove.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example pullAllBy({ nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }, { x: 2 }, { x: 3 }] } }, 'nested.prop', [{ x: 1 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 2 }, { x: 2 }] } }
  13. * @see {@link https://lodash.com/docs#pullAllBy|lodash.pullAllBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const pullAllBy = convertLodashFp(_pullAllBy)
  17. export { pullAllBy }
diff --git a/docs/immutadot-lodash/1.0/array_pullAllWith.js.html b/docs/immutadot-lodash/1.0/array_pullAllWith.js.html index 9005cd45..77e91a3d 100644 --- a/docs/immutadot-lodash/1.0/array_pullAllWith.js.html +++ b/docs/immutadot-lodash/1.0/array_pullAllWith.js.html @@ -35,7 +35,7 @@

array/pullAllWith.js

-
  1. import _pullAllWith from 'lodash/fp/pullAllWith'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * This method is like {@link array.pullAll} except that it accepts <code>comparator</code> to compare elements.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array} values The values to remove.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example pullAllWith({ nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }, { x: 2 }, { x: 3 }] } }, 'nested.prop', [{ x: 1 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 2 }, { x: 2 }] } }
  13. * @see {@link https://lodash.com/docs#pullAllWith|lodash.pullAllWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const pullAllWith = convertLodashFp(_pullAllWith)
  17. export { pullAllWith }
+
  1. import { pullAllWith as _pullAllWith } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * This method is like {@link array.pullAll} except that it accepts <code>comparator</code> to compare elements.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array} values The values to remove.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example pullAllWith({ nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }, { x: 2 }, { x: 3 }] } }, 'nested.prop', [{ x: 1 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 2 }, { x: 2 }] } }
  13. * @see {@link https://lodash.com/docs#pullAllWith|lodash.pullAllWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const pullAllWith = convertLodashFp(_pullAllWith)
  17. export { pullAllWith }
diff --git a/docs/immutadot-lodash/1.0/array_pullAt.js.html b/docs/immutadot-lodash/1.0/array_pullAt.js.html index 8642b090..9d33ad32 100644 --- a/docs/immutadot-lodash/1.0/array_pullAt.js.html +++ b/docs/immutadot-lodash/1.0/array_pullAt.js.html @@ -35,7 +35,7 @@

array/pullAt.js

-
  1. import _pullAt from 'lodash/fp/pullAt'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces an array removing the specified indexes from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  10. * @return {Object} Returns the updated object.
  11. * @example pullAt({ nested: { prop: [4, 3, 2, 1] } }, 'nested.prop', 1, 3) // => { nested: { prop: [4, 2] } }
  12. * @see {@link https://lodash.com/docs#pullAt|lodash.pullAt} for more information.
  13. * @since 1.0.0
  14. */
  15. const pullAt = convertLodashFp(_pullAt)
  16. export { pullAt }
+
  1. import { pullAt as _pullAt } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces an array removing the specified indexes from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  10. * @return {Object} Returns the updated object.
  11. * @example pullAt({ nested: { prop: [4, 3, 2, 1] } }, 'nested.prop', 1, 3) // => { nested: { prop: [4, 2] } }
  12. * @see {@link https://lodash.com/docs#pullAt|lodash.pullAt} for more information.
  13. * @since 1.0.0
  14. */
  15. const pullAt = convertLodashFp(_pullAt)
  16. export { pullAt }
diff --git a/docs/immutadot-lodash/1.0/array_remove.js.html b/docs/immutadot-lodash/1.0/array_remove.js.html index 58359034..40bbf0b4 100644 --- a/docs/immutadot-lodash/1.0/array_remove.js.html +++ b/docs/immutadot-lodash/1.0/array_remove.js.html @@ -35,7 +35,7 @@

array/remove.js

-
  1. import _remove from 'lodash/fp/remove'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces an array removing elements that predicate returns truthy for from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example remove({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#remove|lodash.remove} for more information.
  13. * @since 1.0.0
  14. */
  15. const remove = convertLodashFp(_remove)
  16. export { remove }
+
  1. import { remove as _remove } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces an array removing elements that predicate returns truthy for from the former array.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example remove({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#remove|lodash.remove} for more information.
  13. * @since 1.0.0
  14. */
  15. const remove = convertLodashFp(_remove)
  16. export { remove }
diff --git a/docs/immutadot-lodash/1.0/array_take.js.html b/docs/immutadot-lodash/1.0/array_take.js.html index b57cb440..7c665e77 100644 --- a/docs/immutadot-lodash/1.0/array_take.js.html +++ b/docs/immutadot-lodash/1.0/array_take.js.html @@ -35,7 +35,7 @@

array/take.js

-
  1. import _take from 'lodash/take'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Creates a slice of array with <code>n</code> elements taken from the beginning.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] Number of elements to take from the beginning of the array.
  10. * @return {Object} Returns the updated object.
  11. * @example take({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#take|lodash.take} for more information.
  13. * @since 1.0.0
  14. */
  15. const take = convert(_take)
  16. export { take }
+
  1. import { take as _take } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Creates a slice of array with <code>n</code> elements taken from the beginning.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] Number of elements to take from the beginning of the array.
  10. * @return {Object} Returns the updated object.
  11. * @example take({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
  12. * @see {@link https://lodash.com/docs#take|lodash.take} for more information.
  13. * @since 1.0.0
  14. */
  15. const take = convert(_take)
  16. export { take }
diff --git a/docs/immutadot-lodash/1.0/array_takeRight.js.html b/docs/immutadot-lodash/1.0/array_takeRight.js.html index d1142ff4..7b8495c2 100644 --- a/docs/immutadot-lodash/1.0/array_takeRight.js.html +++ b/docs/immutadot-lodash/1.0/array_takeRight.js.html @@ -35,7 +35,7 @@

array/takeRight.js

-
  1. import _takeRight from 'lodash/takeRight'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Creates a slice of array with <code>n</code> elements taken from the end.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] Number of elements to take from the end of the array.
  10. * @return {Object} Returns the updated object.
  11. * @example takeRight({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [3, 4] } }
  12. * @see {@link https://lodash.com/docs#takeRight|lodash.takeRight} for more information.
  13. * @since 1.0.0
  14. */
  15. const takeRight = convert(_takeRight)
  16. export { takeRight }
+
  1. import { takeRight as _takeRight } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Creates a slice of array with <code>n</code> elements taken from the end.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {number} [n=1] Number of elements to take from the end of the array.
  10. * @return {Object} Returns the updated object.
  11. * @example takeRight({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [3, 4] } }
  12. * @see {@link https://lodash.com/docs#takeRight|lodash.takeRight} for more information.
  13. * @since 1.0.0
  14. */
  15. const takeRight = convert(_takeRight)
  16. export { takeRight }
diff --git a/docs/immutadot-lodash/1.0/array_takeRightWhile.js.html b/docs/immutadot-lodash/1.0/array_takeRightWhile.js.html index b376aed9..872d6dbb 100644 --- a/docs/immutadot-lodash/1.0/array_takeRightWhile.js.html +++ b/docs/immutadot-lodash/1.0/array_takeRightWhile.js.html @@ -35,7 +35,7 @@

array/takeRightWhile.js

-
  1. import _takeRightWhile from 'lodash/takeRightWhile'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Creates a slice of array with elements taken from the end.
  5. * Elements are taken until predicate returns falsey.
  6. * The predicate is invoked with three arguments: (value, index, array).
  7. * @function
  8. * @memberof array
  9. * @param {Object} object The object to modify.
  10. * @param {Array|string} path The path of the property to set.
  11. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  12. * @return {Object} Returns the updated object.
  13. * @example takeRightWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 3) // => { nested: { prop: [4] } }
  14. * @see {@link https://lodash.com/docs#takeRightWhile|lodash.takeRightWhile} for more information.
  15. * @since 1.0.0
  16. */
  17. const takeRightWhile = convert(_takeRightWhile)
  18. export { takeRightWhile }
+
  1. import { takeRightWhile as _takeRightWhile } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Creates a slice of array with elements taken from the end.
  5. * Elements are taken until predicate returns falsey.
  6. * The predicate is invoked with three arguments: (value, index, array).
  7. * @function
  8. * @memberof array
  9. * @param {Object} object The object to modify.
  10. * @param {Array|string} path The path of the property to set.
  11. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  12. * @return {Object} Returns the updated object.
  13. * @example takeRightWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 3) // => { nested: { prop: [4] } }
  14. * @see {@link https://lodash.com/docs#takeRightWhile|lodash.takeRightWhile} for more information.
  15. * @since 1.0.0
  16. */
  17. const takeRightWhile = convert(_takeRightWhile)
  18. export { takeRightWhile }
diff --git a/docs/immutadot-lodash/1.0/array_takeWhile.js.html b/docs/immutadot-lodash/1.0/array_takeWhile.js.html index 8f5cb2c2..46d19839 100644 --- a/docs/immutadot-lodash/1.0/array_takeWhile.js.html +++ b/docs/immutadot-lodash/1.0/array_takeWhile.js.html @@ -35,7 +35,7 @@

array/takeWhile.js

-
  1. import _takeWhile from 'lodash/takeWhile'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Creates a slice of array with elements taken from the beginning.
  5. * Elements are taken until predicate returns falsey.
  6. * The predicate is invoked with three arguments: (value, index, array).
  7. * @function
  8. * @memberof array
  9. * @param {Object} object The object to modify.
  10. * @param {Array|string} path The path of the property to set.
  11. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  12. * @return {Object} Returns the updated object.
  13. * @example takeWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v < 2) // => { nested: { prop: [1] } }
  14. * @see {@link https://lodash.com/docs#takeWhile|lodash.takeWhile} for more information.
  15. * @since 1.0.0
  16. */
  17. const takeWhile = convert(_takeWhile)
  18. export { takeWhile }
+
  1. import { takeWhile as _takeWhile } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Creates a slice of array with elements taken from the beginning.
  5. * Elements are taken until predicate returns falsey.
  6. * The predicate is invoked with three arguments: (value, index, array).
  7. * @function
  8. * @memberof array
  9. * @param {Object} object The object to modify.
  10. * @param {Array|string} path The path of the property to set.
  11. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  12. * @return {Object} Returns the updated object.
  13. * @example takeWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v < 2) // => { nested: { prop: [1] } }
  14. * @see {@link https://lodash.com/docs#takeWhile|lodash.takeWhile} for more information.
  15. * @since 1.0.0
  16. */
  17. const takeWhile = convert(_takeWhile)
  18. export { takeWhile }
diff --git a/docs/immutadot-lodash/1.0/array_union.js.html b/docs/immutadot-lodash/1.0/array_union.js.html index 6373002a..9dcd07e4 100644 --- a/docs/immutadot-lodash/1.0/array_union.js.html +++ b/docs/immutadot-lodash/1.0/array_union.js.html @@ -35,7 +35,7 @@

array/union.js

-
  1. import _union from 'lodash/union'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces an array by an array of unique values, in order, from the former array and the given arrays.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @return {Object} Returns the updated object.
  11. * @example union({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1, 2, 3] } }
  12. * @see {@link https://lodash.com/docs#union|lodash.union} for more information.
  13. * @since 1.0.0
  14. */
  15. const union = convert(_union)
  16. export { union }
+
  1. import { union as _union } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces an array by an array of unique values, in order, from the former array and the given arrays.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @return {Object} Returns the updated object.
  11. * @example union({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1, 2, 3] } }
  12. * @see {@link https://lodash.com/docs#union|lodash.union} for more information.
  13. * @since 1.0.0
  14. */
  15. const union = convert(_union)
  16. export { union }
diff --git a/docs/immutadot-lodash/1.0/array_unionBy.js.html b/docs/immutadot-lodash/1.0/array_unionBy.js.html index bd97403b..e7606540 100644 --- a/docs/immutadot-lodash/1.0/array_unionBy.js.html +++ b/docs/immutadot-lodash/1.0/array_unionBy.js.html @@ -35,7 +35,7 @@

array/unionBy.js

-
  1. import _unionBy from 'lodash/unionBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.union} except that it accepts <code>iteratee</code> to generate the criterion by which elements are compared.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example unionBy({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#unionBy|lodash.unionBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const unionBy = convert(_unionBy)
  17. export { unionBy }
+
  1. import { unionBy as _unionBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.union} except that it accepts <code>iteratee</code> to generate the criterion by which elements are compared.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example unionBy({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#unionBy|lodash.unionBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const unionBy = convert(_unionBy)
  17. export { unionBy }
diff --git a/docs/immutadot-lodash/1.0/array_unionWith.js.html b/docs/immutadot-lodash/1.0/array_unionWith.js.html index 57bdb9c5..78541483 100644 --- a/docs/immutadot-lodash/1.0/array_unionWith.js.html +++ b/docs/immutadot-lodash/1.0/array_unionWith.js.html @@ -35,7 +35,7 @@

array/unionWith.js

-
  1. import _unionWith from 'lodash/unionWith'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.union} except that it accepts <code>comparator</code> to compare elements.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example unionWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#unionWith|lodash.unionWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const unionWith = convert(_unionWith)
  17. export { unionWith }
+
  1. import { unionWith as _unionWith } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.union} except that it accepts <code>comparator</code> to compare elements.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} [arrays] The arrays to inspect.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example unionWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#unionWith|lodash.unionWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const unionWith = convert(_unionWith)
  17. export { unionWith }
diff --git a/docs/immutadot-lodash/1.0/array_xor.js.html b/docs/immutadot-lodash/1.0/array_xor.js.html index 863f799a..12ec6529 100644 --- a/docs/immutadot-lodash/1.0/array_xor.js.html +++ b/docs/immutadot-lodash/1.0/array_xor.js.html @@ -35,7 +35,7 @@

array/xor.js

-
  1. import _xor from 'lodash/xor'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces an array by the symmetric difference of the former array and the given arrays.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} arrays The arrays to inspect.
  10. * @return {Object} Returns the updated object.
  11. * @example xor({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1, 3] } }
  12. * @see {@link https://lodash.com/docs#xor|lodash.xor} for more information.
  13. * @since 1.0.0
  14. */
  15. const xor = convert(_xor)
  16. export { xor }
+
  1. import { xor as _xor } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces an array by the symmetric difference of the former array and the given arrays.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} arrays The arrays to inspect.
  10. * @return {Object} Returns the updated object.
  11. * @example xor({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1, 3] } }
  12. * @see {@link https://lodash.com/docs#xor|lodash.xor} for more information.
  13. * @since 1.0.0
  14. */
  15. const xor = convert(_xor)
  16. export { xor }
diff --git a/docs/immutadot-lodash/1.0/array_xorBy.js.html b/docs/immutadot-lodash/1.0/array_xorBy.js.html index cfe218c5..7d0f45bf 100644 --- a/docs/immutadot-lodash/1.0/array_xorBy.js.html +++ b/docs/immutadot-lodash/1.0/array_xorBy.js.html @@ -35,7 +35,7 @@

array/xorBy.js

-
  1. import _xorBy from 'lodash/xorBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.xor} except that it accepts <code>iteratee</code> to generate the criterion by which elements are compared.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} arrays The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example xorBy({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 1 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#xorBy|lodash.xorBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const xorBy = convert(_xorBy)
  17. export { xorBy }
+
  1. import { xorBy as _xorBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.xor} except that it accepts <code>iteratee</code> to generate the criterion by which elements are compared.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} arrays The arrays to inspect.
  10. * @param {Function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The iteratee invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example xorBy({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 1 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#xorBy|lodash.xorBy} for more information.
  14. * @since 1.0.0
  15. */
  16. const xorBy = convert(_xorBy)
  17. export { xorBy }
diff --git a/docs/immutadot-lodash/1.0/array_xorWith.js.html b/docs/immutadot-lodash/1.0/array_xorWith.js.html index f884a068..c09f47ee 100644 --- a/docs/immutadot-lodash/1.0/array_xorWith.js.html +++ b/docs/immutadot-lodash/1.0/array_xorWith.js.html @@ -35,7 +35,7 @@

array/xorWith.js

-
  1. import _xorWith from 'lodash/xorWith'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * This method is like {@link array.xor} except that it accepts <code>comparator</code> to compare elements.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} arrays The arrays to inspect.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example xorWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === a.b) // => { nested: { prop: [{ x: 1 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#xorWith|lodash.xorWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const xorWith = convert(_xorWith)
  17. export { xorWith }
+
  1. import { xorWith as _xorWith } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * This method is like {@link array.xor} except that it accepts <code>comparator</code> to compare elements.
  5. * @function
  6. * @memberof array
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...Array} arrays The arrays to inspect.
  10. * @param {Function} [comparator] The comparator invoked per element.
  11. * @return {Object} Returns the updated object.
  12. * @example xorWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === a.b) // => { nested: { prop: [{ x: 1 }, { x: 3 }] } }
  13. * @see {@link https://lodash.com/docs#xorWith|lodash.xorWith} for more information.
  14. * @since 1.0.0
  15. */
  16. const xorWith = convert(_xorWith)
  17. export { xorWith }
diff --git a/docs/immutadot-lodash/1.0/collection_filter.js.html b/docs/immutadot-lodash/1.0/collection_filter.js.html index a47854ce..2b96deb1 100644 --- a/docs/immutadot-lodash/1.0/collection_filter.js.html +++ b/docs/immutadot-lodash/1.0/collection_filter.js.html @@ -35,7 +35,7 @@

collection/filter.js

-
  1. import _filter from 'lodash/filter'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an array of elements <code>predicate</code> returns truthy for.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @see {@link https://lodash.com/docs#filter|lodash.filter} for more information.
  12. * @example filter({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [1, 3] } }
  13. * @since 1.0.0
  14. */
  15. const filter = convert(_filter)
  16. export { filter }
+
  1. import { filter as _filter } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an array of elements <code>predicate</code> returns truthy for.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @see {@link https://lodash.com/docs#filter|lodash.filter} for more information.
  12. * @example filter({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [1, 3] } }
  13. * @since 1.0.0
  14. */
  15. const filter = convert(_filter)
  16. export { filter }
diff --git a/docs/immutadot-lodash/1.0/collection_map.js.html b/docs/immutadot-lodash/1.0/collection_map.js.html index c4032211..17929164 100644 --- a/docs/immutadot-lodash/1.0/collection_map.js.html +++ b/docs/immutadot-lodash/1.0/collection_map.js.html @@ -35,7 +35,7 @@

collection/map.js

-
  1. import _map from 'lodash/map'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an array of values by running each element in the former collection thru iteratee.
  5. * The iteratee is invoked with three arguments: (value, index|key, collection).
  6. * @function
  7. * @memberof collection
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  11. * @return {Object} Returns the updated object.
  12. * @see {@link https://lodash.com/docs#map|lodash.map} for more information.
  13. * @example map({ nested: { prop: [1, 2, 3] } }, 'nested.prop', v => v * 2) // => { nested: { prop: [2, 4, 6] } }
  14. * @since 1.0.0
  15. */
  16. const map = convert(_map)
  17. export { map }
+
  1. import { map as _map } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an array of values by running each element in the former collection thru iteratee.
  5. * The iteratee is invoked with three arguments: (value, index|key, collection).
  6. * @function
  7. * @memberof collection
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  11. * @return {Object} Returns the updated object.
  12. * @see {@link https://lodash.com/docs#map|lodash.map} for more information.
  13. * @example map({ nested: { prop: [1, 2, 3] } }, 'nested.prop', v => v * 2) // => { nested: { prop: [2, 4, 6] } }
  14. * @since 1.0.0
  15. */
  16. const map = convert(_map)
  17. export { map }
diff --git a/docs/immutadot-lodash/1.0/collection_orderBy.js.html b/docs/immutadot-lodash/1.0/collection_orderBy.js.html index 05f48168..bbf07395 100644 --- a/docs/immutadot-lodash/1.0/collection_orderBy.js.html +++ b/docs/immutadot-lodash/1.0/collection_orderBy.js.html @@ -35,7 +35,7 @@

collection/orderBy.js

-
  1. import _orderBy from 'lodash/orderBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an array of sorted by <code>iteratees</code> in specified <code>orders</code>.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[{@link https://lodash.com/docs#identity|lodash.identity}]] The iteratees to sort by.
  10. * @param {string[]} [orders] The sort orders of <code>iteratees</code>.
  11. * @return {Object} Returns the updated object.
  12. * @see {@link https://lodash.com/docs#orderBy|lodash.orderBy} for more information.
  13. * @example
  14. * orderBy({ nested: { prop: [{ name: 'Yvo', age: 2 }, { name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }] } }, 'nested.prop', ['name', 'age'], ['asc', 'desc'])
  15. * // => { nested: { prop: [{ name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }, { name: 'Yvo', age: 2 }] } }
  16. * @since 1.0.0
  17. */
  18. const orderBy = convert(_orderBy)
  19. export { orderBy }
+
  1. import { orderBy as _orderBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an array of sorted by <code>iteratees</code> in specified <code>orders</code>.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[{@link https://lodash.com/docs#identity|lodash.identity}]] The iteratees to sort by.
  10. * @param {string[]} [orders] The sort orders of <code>iteratees</code>.
  11. * @return {Object} Returns the updated object.
  12. * @see {@link https://lodash.com/docs#orderBy|lodash.orderBy} for more information.
  13. * @example
  14. * orderBy({ nested: { prop: [{ name: 'Yvo', age: 2 }, { name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }] } }, 'nested.prop', ['name', 'age'], ['asc', 'desc'])
  15. * // => { nested: { prop: [{ name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }, { name: 'Yvo', age: 2 }] } }
  16. * @since 1.0.0
  17. */
  18. const orderBy = convert(_orderBy)
  19. export { orderBy }
diff --git a/docs/immutadot-lodash/1.0/collection_reject.js.html b/docs/immutadot-lodash/1.0/collection_reject.js.html index 673e09fa..4eef7dae 100644 --- a/docs/immutadot-lodash/1.0/collection_reject.js.html +++ b/docs/immutadot-lodash/1.0/collection_reject.js.html @@ -35,7 +35,7 @@

collection/reject.js

-
  1. import _reject from 'lodash/reject'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an array of elements <code>predicate</code> returns falsy for.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @see {@link https://lodash.com/docs#reject|lodash.reject} for more information.
  12. * @example reject({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [2, 4] } }
  13. * @since 1.0.0
  14. */
  15. const reject = convert(_reject)
  16. export { reject }
+
  1. import { reject as _reject } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an array of elements <code>predicate</code> returns falsy for.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @see {@link https://lodash.com/docs#reject|lodash.reject} for more information.
  12. * @example reject({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [2, 4] } }
  13. * @since 1.0.0
  14. */
  15. const reject = convert(_reject)
  16. export { reject }
diff --git a/docs/immutadot-lodash/1.0/collection_shuffle.js.html b/docs/immutadot-lodash/1.0/collection_shuffle.js.html index 934f9d4f..eb1bf7f1 100644 --- a/docs/immutadot-lodash/1.0/collection_shuffle.js.html +++ b/docs/immutadot-lodash/1.0/collection_shuffle.js.html @@ -35,7 +35,7 @@

collection/shuffle.js

-
  1. import _shuffle from 'lodash/shuffle'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an array of shuffled elements.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @see {@link https://lodash.com/docs#shuffle|lodash.shuffle} for more information.
  11. * @example shuffle({ nested: { prop: [1, 2, 3, 4, 5, 6, 7, 8, 9] } }, 'nested.prop') // => { nested: { prop: [7, 3, 9, 1, 4, 5, 6, 8, 2] } }
  12. * @since 1.0.0
  13. */
  14. const shuffle = convert(_shuffle)
  15. export { shuffle }
+
  1. import { shuffle as _shuffle } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an array of shuffled elements.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @see {@link https://lodash.com/docs#shuffle|lodash.shuffle} for more information.
  11. * @example shuffle({ nested: { prop: [1, 2, 3, 4, 5, 6, 7, 8, 9] } }, 'nested.prop') // => { nested: { prop: [7, 3, 9, 1, 4, 5, 6, 8, 2] } }
  12. * @since 1.0.0
  13. */
  14. const shuffle = convert(_shuffle)
  15. export { shuffle }
diff --git a/docs/immutadot-lodash/1.0/collection_sortBy.js.html b/docs/immutadot-lodash/1.0/collection_sortBy.js.html index 8fb3ec76..958aa3fe 100644 --- a/docs/immutadot-lodash/1.0/collection_sortBy.js.html +++ b/docs/immutadot-lodash/1.0/collection_sortBy.js.html @@ -35,7 +35,7 @@

collection/sortBy.js

-
  1. import _sortBy from 'lodash/sortBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an array of sorted by <code>iteratees</code>.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[{@link https://lodash.com/docs#identity|lodash.identity}]] The iteratees to sort by.
  10. * @return {Object} Returns the updated object.
  11. * @see {@link https://lodash.com/docs#sortBy|lodash.sortBy} for more information.
  12. * @example
  13. * sortBy({ nested: { prop: [{ name: 'Yvo', age: 2 }, { name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }] } }, 'nested.prop', ['name', 'age'])
  14. * // => { nested: { prop: [{ name: 'Nico', age: 30 }, { name: 'Nico', age: 666 }, { name: 'Yvo', age: 2 }] } }
  15. * @since 1.0.0
  16. */
  17. const sortBy = convert(_sortBy)
  18. export { sortBy }
+
  1. import { sortBy as _sortBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an array of sorted by <code>iteratees</code>.
  5. * @function
  6. * @memberof collection
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[{@link https://lodash.com/docs#identity|lodash.identity}]] The iteratees to sort by.
  10. * @return {Object} Returns the updated object.
  11. * @see {@link https://lodash.com/docs#sortBy|lodash.sortBy} for more information.
  12. * @example
  13. * sortBy({ nested: { prop: [{ name: 'Yvo', age: 2 }, { name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }] } }, 'nested.prop', ['name', 'age'])
  14. * // => { nested: { prop: [{ name: 'Nico', age: 30 }, { name: 'Nico', age: 666 }, { name: 'Yvo', age: 2 }] } }
  15. * @since 1.0.0
  16. */
  17. const sortBy = convert(_sortBy)
  18. export { sortBy }
diff --git a/docs/immutadot-lodash/1.0/index.html b/docs/immutadot-lodash/1.0/index.html index aae6a87c..a61b624d 100644 --- a/docs/immutadot-lodash/1.0/index.html +++ b/docs/immutadot-lodash/1.0/index.html @@ -56,87 +56,69 @@

NamespacesCircleCI codecov Greenkeeper

-

1.0 Release Candidate is out 🎉

We are still writing the documentation, you can already find out about the updated API and our new package immutadot-lodash.

-

If you would like to try out 1.0 before its official release, install it with :

-
yarn add immutadot@next

or

-
npm install immutadot@next

Immutability

In the last few years one of our biggest challenge has been to find an efficient way to detect changes in our data to determine when to re-render our interfaces.

-

An immutable object is an object that cannot be changed once created. It brings several benefits1:

-
    -
  • Data changes detection made simple (Shallow comparison)
  • -
  • Memoization
  • -
  • Improve rendering performances
  • -
  • Explicit data changes
  • -
  • Avoid side effects
  • -
-

Our approach

Concise

ES2015+ new features are great to deal with arrays and objects. As data structures expand, the code you write to make data immutable gets bigger and less readable. immutadâ—Źt uses the dot notation to address this issue.

-

Interoperability

immutadâ—Źt uses plain JavaScript objects so you can access your data using standard ways. Moreover, it lets you freely enjoy your favorite libraries.

-

Exhaustive and yet extensible

immutadâ—Źt comes with a large set of built-in utilities, mostly based on ES2015+. You can also find a package called immutadot-lodash with some of lodash's utilities. You haven't found what you're looking for? Do it yourself with the convert feature.

-

Learning curve

If you are already familiar with ES2015+ and lodash then you should be able to use immutadâ—Źt quickly.

+

1.0 is out 🎉

If you were using a previous version of immutadâ—Źt, check out the migrating guide.

Installation

immutadâ—Źt is available on npm repository.

using yarn:

$ yarn add immutadot

using npm:

$ npm install immutadot

or you can directly download sources.

Usage

ES modules:

import { set } from 'immutadot'

CommonJS:

-
const { set } = require('immutadot')

Example

Object used in the following example:

-
const animals = {
-  weasels: [
-    {
-      vernacularName: 'badger',
-      scientificName: 'Meles meles'
+
const { set } = require('immutadot')

Example

Quickly set nested properties using set()

+
import { set } from 'immutadot'
+
+const animals = {
+  weasels: {
+    lutraLutra: {
+      commonNames: ['eurasian otter'],
     },
-    {
-      vernacularName: 'otter',
-    }
-  ]
-}

Let's add the otter's scientific name without mutating the original object structure.

-

using ES2015+:

-
const newAnimals = {
-  ...animals,
-  weasels: [...animals.weasel]
+  },
 }
 
-newAnimals.weasels[1] = {
-  ...newAnimals.weasels[1],
-  scientificName: 'Lutrinae'
-}

using immutadâ—Źt:

-
const newAnimals = set(animals, 'weasels[1].scientificName', 'Lutrinae')

Feel free to try immutadâ—Źt on runkit.

-

Path notation

immutadâ—Źt brings a few improvements to the classic dot notation:

-

Slice notation

The slice notation lets you iterate over arrays to apply operations without having to map arrays at each level of imbrication.

-

We forgot to capitalize vernacular names in the input.

-

using ES2015+:

-
import { capitalize } from 'lodash'
-const newAnimals = {
-  ...animals,
-  weasels: animals.weasels.map(weasel => {
-    return {
-      ...weasel,
-      vernacularName: capitalize(weasel.vernacularName),
-    }
-  }),
-}

using immutadâ—Źt-lodash:

-
import { capitalize } from 'immutadot-lodash'
-const newAnimals = capitalize(animals, 'weasels[:].vernacularName')

List notation

The list notation lets you iterate over the keys of objects used as collection or map to apply operations.

-
toggle({ nested: { prop: { 1: { active: true }, 2: { active: false } } } }, 'nested.prop.{*}.active')
-// { nested: { prop: { 1: { active: false }, 2: { active: true }] } }
-
-toLowerCase({ nested: { prop: { 1: { msg: 'Hello' }, 2: { msg: 'Hi' }, 3: { msg: 'Good morning' } } } }, 'nested.prop{2, 3}.msg')
-// { nested: { prop: { 1: { msg: 'Hello' }, 2: { msg: 'hi' }, 3: { msg: 'good morning' } } } }

Performances

We reused a simple benchmark originally made by mweststrate for immer. -It updates 10.000 items out of list of 100.000 todos items, these tests were ran with Node 8.4.0 on an Intel® Core™ i7-6560U CPU @ 2.20GHz:

-
Update todos list
-  âś“ with mutation (2ms)
-  âś“ with deep cloning, then mutation (689ms)
-  âś“ with ES2015 destructuring (42ms)
-  âś“ with immutable (w/o conversion to plain JS objects) (50ms)
-  âś“ with immutable (w/ conversion to plain JS objects) (1011ms)
-  âś“ with immer (proxy implementation w/o autofreeze) (259ms)
-  âś“ with immutadâ—Źt (77ms)

When applying operations on a path immutadâ—Źt tries to create the minimum of objects or arrays needed to guarantee your data structure to be immutable.

-

Documentation

Latest API documentation for our different packages are available here:

+const newAnimals = set(animals, 'weasels.lutraLutra.name', 'Lutrinae')

Learn more about what immutadâ—Źt can do in the Getting started.

+

Feel free to try immutadâ—Źt on runkit.

+

Documentation

Getting started

A fast overview of immutadâ—Źt's features is available in the Getting started guide.

+

API

The detailed API documentations of the different packages are available here:

Looking for older versions API documentation? Links are available here.

+

Migrating from 0.x versions

If you were using a version of immutadâ—Źt previous to 1.0, check out the migrating guide.

+

Performances

A simple benchmark (freely inspired from one made by mweststrate for immer) reveals that immutadâ—Źt shows good results compared to other libraries.

+

:warning: The following results should be taken with caution, they may vary depending on the hardware, the JavaScript engine, and the kind of operations performed. This particular test updates 10% out of a list of todos items, and was ran with Node 9.3.0 on an Intel® Core™ i7-6560U CPU @ 2.20GHz.

+
Update small todos list (1000 items):
+  ES2015 destructuring: ~16961ops/s (0.06ms/op) on 50000ops
+  immutable 3.8.2 (w/o conversion to plain JS objects): ~6538ops/s (0.15ms/op) on 50000ops
+  immutable 3.8.2 (w/ conversion to plain JS objects): ~106ops/s (9.43ms/op) on 3195ops
+  immer 0.8.1 (proxy implementation w/o autofreeze): ~2191ops/s (0.46ms/op) on 50000ops
+  immer 0.8.1 (ES5 implementation w/o autofreeze): ~494ops/s (2.02ms/op) on 14827ops
+  immutadâ—Źt 1.0.0: ~2431ops/s (0.41ms/op) on 50000ops
+Update medium todos list (10000 items):
+  ES2015 destructuring: ~1781ops/s (0.56ms/op) on 5000ops
+  immutable 3.8.2 (w/o conversion to plain JS objects): ~587ops/s (1.70ms/op) on 5000ops
+  immutable 3.8.2 (w/ conversion to plain JS objects): ~10ops/s (100.80ms/op) on 299ops
+  immer 0.8.1 (proxy implementation w/o autofreeze): ~185ops/s (5.42ms/op) on 5000ops
+  immer 0.8.1 (ES5 implementation w/o autofreeze): ~47ops/s (21.21ms/op) on 1415ops
+  immutadâ—Źt 1.0.0: ~245ops/s (4.08ms/op) on 5000ops
+Update large todos list (100000 items):
+  ES2015 destructuring: ~116ops/s (8.61ms/op) on 500ops
+  immutable 3.8.2 (w/o conversion to plain JS objects): ~56ops/s (17.95ms/op) on 500ops
+  immutable 3.8.2 (w/ conversion to plain JS objects): ~1ops/s (1052.45ms/op) on 29ops
+  immer 0.8.1 (proxy implementation w/o autofreeze): ~21ops/s (47.81ms/op) on 500ops
+  immer 0.8.1 (ES5 implementation w/o autofreeze): ~4ops/s (275.59ms/op) on 110ops
+  immutadâ—Źt 1.0.0: ~23ops/s (44.15ms/op) on 500ops

Immutability

In the last few years one of our biggest challenge has been to find an efficient way to detect changes in our data to determine when to re-render our interfaces.

+

An immutable object is an object that cannot be changed once created. It brings several benefits1:

+
    +
  • Data changes detection made simple (Shallow comparison)
  • +
  • Memoization
  • +
  • Improve rendering performances
  • +
  • Explicit data changes
  • +
  • Avoid side effects
  • +
+

Our approach

Concise

ES2015+ new features are great to deal with arrays and objects. As data structures expand, the code you write to make data immutable gets bigger and less readable. immutadâ—Źt uses the dot notation to address this issue.

+

Interoperability

immutadâ—Źt uses plain JavaScript objects so you can access your data using standard ways. Moreover, it lets you freely enjoy your favorite libraries.

+

Exhaustive and yet extensible

immutadâ—Źt comes with a large set of built-in utilities, mostly based on ES2015+. You can also find a package called immutadot-lodash with some of lodash's utilities. You haven't found what you're looking for? Do it yourself with the convert feature.

+

Learning curve

If you are already familiar with ES2015+ and lodash then you should be able to use immutadâ—Źt quickly.

Contributing

We want contributing to immutadâ—Źt to be fun, enjoyable, and educational for anyone, and everyone.

Code of Conduct

In the interest of fostering an open and welcoming environment, we have adopted a Code of Conduct that we expect project participants to commit to. Please read the full text so that you can understand what behavior will and will not be tolerated.

Contributing guide

If you are interested in contributing to immutadâ—Źt, please read our contributing guide to learn more about how to suggest bugfixes and improvements.

diff --git a/docs/immutadot-lodash/1.0/object_defaults.js.html b/docs/immutadot-lodash/1.0/object_defaults.js.html index 91358843..cfdfb5bf 100644 --- a/docs/immutadot-lodash/1.0/object_defaults.js.html +++ b/docs/immutadot-lodash/1.0/object_defaults.js.html @@ -35,7 +35,7 @@

object/defaults.js

-
  1. import _defaults from 'lodash/fp/defaults'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces by an object assigning own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to <code>undefined</code>.<br >
  5. * Source objects are applied from left to right. Once a property is set, additional values of the same property are ignored.
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {...Object} [sources] The source objects.
  11. * @return {Object} Returns the updated object.
  12. * @example defaults({ nested: { a: 1, b: 2 } }, 'nested', { b: 3, c: 4 }) // => { nested: { a:1, b: 2, c: 4 } }
  13. * @see {@link https://lodash.com/docs#defaults|lodash.defaults} for more information.
  14. * @since 1.0.0
  15. */
  16. const defaults = convertLodashFp(_defaults)
  17. export { defaults }
+
  1. import { defaults as _defaults } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces by an object assigning own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to <code>undefined</code>.<br >
  5. * Source objects are applied from left to right. Once a property is set, additional values of the same property are ignored.
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {...Object} [sources] The source objects.
  11. * @return {Object} Returns the updated object.
  12. * @example defaults({ nested: { a: 1, b: 2 } }, 'nested', { b: 3, c: 4 }) // => { nested: { a:1, b: 2, c: 4 } }
  13. * @see {@link https://lodash.com/docs#defaults|lodash.defaults} for more information.
  14. * @since 1.0.0
  15. */
  16. const defaults = convertLodashFp(_defaults)
  17. export { defaults }
diff --git a/docs/immutadot-lodash/1.0/object_mapKeys.js.html b/docs/immutadot-lodash/1.0/object_mapKeys.js.html index e0cd0b22..7cda6563 100644 --- a/docs/immutadot-lodash/1.0/object_mapKeys.js.html +++ b/docs/immutadot-lodash/1.0/object_mapKeys.js.html @@ -35,7 +35,7 @@

object/mapKeys.js

-
  1. import _mapKeys from 'lodash/mapKeys'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an object with the same values as the former object and values generated by running each own enumerable string keyed property of the former object thru <code>iteratee</code>.
  5. * The iteratee is invoked with three arguments: (value, key, object).
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  11. * @return {Object} Returns the updated object.
  12. * @example mapKeys({ nested: { a: 1, b: 2, c: 3 } }, 'nested', (v, k) => '_' + k) // => { nested: { _a: 1, _b: 2, _c: 3 } }
  13. * @see {@link https://lodash.com/docs#mapKeys|lodash.mapKeys} for more information.
  14. * @since 1.0.0
  15. */
  16. const mapKeys = convert(_mapKeys)
  17. export { mapKeys }
+
  1. import { mapKeys as _mapKeys } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an object with the same values as the former object and values generated by running each own enumerable string keyed property of the former object thru <code>iteratee</code>.
  5. * The iteratee is invoked with three arguments: (value, key, object).
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  11. * @return {Object} Returns the updated object.
  12. * @example mapKeys({ nested: { a: 1, b: 2, c: 3 } }, 'nested', (v, k) => '_' + k) // => { nested: { _a: 1, _b: 2, _c: 3 } }
  13. * @see {@link https://lodash.com/docs#mapKeys|lodash.mapKeys} for more information.
  14. * @since 1.0.0
  15. */
  16. const mapKeys = convert(_mapKeys)
  17. export { mapKeys }
diff --git a/docs/immutadot-lodash/1.0/object_mapValues.js.html b/docs/immutadot-lodash/1.0/object_mapValues.js.html index b8148f9e..9cf79707 100644 --- a/docs/immutadot-lodash/1.0/object_mapValues.js.html +++ b/docs/immutadot-lodash/1.0/object_mapValues.js.html @@ -35,7 +35,7 @@

object/mapValues.js

-
  1. import _mapValues from 'lodash/mapValues'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an object with the same keys as the former object and values generated by running each own enumerable string keyed property of object thru <code>iteratee</code>.
  5. * The iteratee is invoked with three arguments: (value, key, object).
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  11. * @return {Object} Returns the updated object.
  12. * @example mapValues({ nested: { a: 1, b: 2, c: 3 } }, 'nested', v => v * v) // => { nested: { a: 1, b: 4, c: 9 } }
  13. * @example mapValues({ nested: { a: { age: 40, name: 'John' }, b: { age: 30, name: 'Alice' } } }, 'nested', 'age') // => { nested: { a: 40, b: 30 } }
  14. * @see {@link https://lodash.com/docs#mapValues|lodash.mapValues} for more information.
  15. * @since 1.0.0
  16. */
  17. const mapValues = convert(_mapValues)
  18. export { mapValues }
+
  1. import { mapValues as _mapValues } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an object with the same keys as the former object and values generated by running each own enumerable string keyed property of object thru <code>iteratee</code>.
  5. * The iteratee is invoked with three arguments: (value, key, object).
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {function} [iteratee={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  11. * @return {Object} Returns the updated object.
  12. * @example mapValues({ nested: { a: 1, b: 2, c: 3 } }, 'nested', v => v * v) // => { nested: { a: 1, b: 4, c: 9 } }
  13. * @example mapValues({ nested: { a: { age: 40, name: 'John' }, b: { age: 30, name: 'Alice' } } }, 'nested', 'age') // => { nested: { a: 40, b: 30 } }
  14. * @see {@link https://lodash.com/docs#mapValues|lodash.mapValues} for more information.
  15. * @since 1.0.0
  16. */
  17. const mapValues = convert(_mapValues)
  18. export { mapValues }
diff --git a/docs/immutadot-lodash/1.0/object_merge.js.html b/docs/immutadot-lodash/1.0/object_merge.js.html index 9d0b1e0c..289ae683 100644 --- a/docs/immutadot-lodash/1.0/object_merge.js.html +++ b/docs/immutadot-lodash/1.0/object_merge.js.html @@ -35,7 +35,7 @@

object/merge.js

-
  1. import _merge from 'lodash/fp/merge'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces by an object deeply merging own enumerable string keyed properties of source objects to the former object.<br />
  5. * Source objects are applied from left to right. Subsequent sources overwrite properties of previous sources.
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {...Object} [sources] The source objects.
  11. * @return {Object} Returns the updated object.
  12. * @example merge({ nested: { prop: { a: 1 } } }, 'nested', { prop: { a: 2, b: 3 } }) // => { nested: { prop: { a: 2, b: 3 } } }
  13. * @see {@link https://lodash.com/docs#merge|lodash.merge} for more information.
  14. * @since 1.0.0
  15. */
  16. const merge = convertLodashFp(_merge)
  17. export { merge }
+
  1. import { merge as _merge } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces by an object deeply merging own enumerable string keyed properties of source objects to the former object.<br />
  5. * Source objects are applied from left to right. Subsequent sources overwrite properties of previous sources.
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {...Object} [sources] The source objects.
  11. * @return {Object} Returns the updated object.
  12. * @example merge({ nested: { prop: { a: 1 } } }, 'nested', { prop: { a: 2, b: 3 } }) // => { nested: { prop: { a: 2, b: 3 } } }
  13. * @see {@link https://lodash.com/docs#merge|lodash.merge} for more information.
  14. * @since 1.0.0
  15. */
  16. const merge = convertLodashFp(_merge)
  17. export { merge }
diff --git a/docs/immutadot-lodash/1.0/object_omit.js.html b/docs/immutadot-lodash/1.0/object_omit.js.html index 0e1897d6..a80a3a98 100644 --- a/docs/immutadot-lodash/1.0/object_omit.js.html +++ b/docs/immutadot-lodash/1.0/object_omit.js.html @@ -35,7 +35,7 @@

object/omit.js

-
  1. import _omit from 'lodash/omit'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an object omitting specified properties.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...(string|string[])} [paths] The property paths to omit.
  10. * @return {Object} Returns the updated object.
  11. * @example omit({ nested: { a: 1, b: 2, c: 3 } }, 'nested', 'b') // => { nested: { a:1, c: 3 } }
  12. * @see {@link https://lodash.com/docs#omit|lodash.omit} for more information.
  13. * @since 1.0.0
  14. */
  15. const omit = convert(_omit)
  16. export { omit }
+
  1. import { omit as _omit } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an object omitting specified properties.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...(string|string[])} [paths] The property paths to omit.
  10. * @return {Object} Returns the updated object.
  11. * @example omit({ nested: { a: 1, b: 2, c: 3 } }, 'nested', 'b') // => { nested: { a:1, c: 3 } }
  12. * @see {@link https://lodash.com/docs#omit|lodash.omit} for more information.
  13. * @since 1.0.0
  14. */
  15. const omit = convert(_omit)
  16. export { omit }
diff --git a/docs/immutadot-lodash/1.0/object_omitBy.js.html b/docs/immutadot-lodash/1.0/object_omitBy.js.html index 960065bf..d0ddcc6e 100644 --- a/docs/immutadot-lodash/1.0/object_omitBy.js.html +++ b/docs/immutadot-lodash/1.0/object_omitBy.js.html @@ -35,7 +35,7 @@

object/omitBy.js

-
  1. import _omitBy from 'lodash/omitBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an object omitting properties that <code>predicate</code> doesn't return truthy for.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per property.
  10. * @return {Object} Returns the updated object.
  11. * @example omitBy({ nested: { a: 1, b: 2, c: 3 } }, 'nested', v => v === 2) // => { nested: { a:1, c: 3 } }
  12. * @see {@link https://lodash.com/docs#omitBy|lodash.omitBy} for more information.
  13. * @since 1.0.0
  14. */
  15. const omitBy = convert(_omitBy)
  16. export { omitBy }
+
  1. import { omitBy as _omitBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an object omitting properties that <code>predicate</code> doesn't return truthy for.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per property.
  10. * @return {Object} Returns the updated object.
  11. * @example omitBy({ nested: { a: 1, b: 2, c: 3 } }, 'nested', v => v === 2) // => { nested: { a:1, c: 3 } }
  12. * @see {@link https://lodash.com/docs#omitBy|lodash.omitBy} for more information.
  13. * @since 1.0.0
  14. */
  15. const omitBy = convert(_omitBy)
  16. export { omitBy }
diff --git a/docs/immutadot-lodash/1.0/object_pick.js.html b/docs/immutadot-lodash/1.0/object_pick.js.html index 224f659e..f73fcc37 100644 --- a/docs/immutadot-lodash/1.0/object_pick.js.html +++ b/docs/immutadot-lodash/1.0/object_pick.js.html @@ -35,7 +35,7 @@

object/pick.js

-
  1. import _pick from 'lodash/pick'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an object picking specified properties.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...(string|string[])} [paths] The property paths to pick.
  10. * @return {Object} Returns the updated object.
  11. * @example pick({ nested: { a: 1, b: 2, c: 3 } }, 'nested', 'b') // => { nested: { b: 2 } }
  12. * @see {@link https://lodash.com/docs#pick|lodash.pick} for more information.
  13. * @since 1.0.0
  14. */
  15. const pick = convert(_pick)
  16. export { pick }
+
  1. import { pick as _pick } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an object picking specified properties.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {...(string|string[])} [paths] The property paths to pick.
  10. * @return {Object} Returns the updated object.
  11. * @example pick({ nested: { a: 1, b: 2, c: 3 } }, 'nested', 'b') // => { nested: { b: 2 } }
  12. * @see {@link https://lodash.com/docs#pick|lodash.pick} for more information.
  13. * @since 1.0.0
  14. */
  15. const pick = convert(_pick)
  16. export { pick }
diff --git a/docs/immutadot-lodash/1.0/object_pickBy.js.html b/docs/immutadot-lodash/1.0/object_pickBy.js.html index f185f096..49b809b5 100644 --- a/docs/immutadot-lodash/1.0/object_pickBy.js.html +++ b/docs/immutadot-lodash/1.0/object_pickBy.js.html @@ -35,7 +35,7 @@

object/pickBy.js

-
  1. import _pickBy from 'lodash/pickBy'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Replaces by an object picking properties that <code>predicate</code> returns truthy for.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example pickBy({ nested: { a: 1, b: 2, c: 3, d: 4 } }, 'nested', v => v < 3) // => { nested: { a: 1, b: 2 } }
  12. * @see {@link https://lodash.com/docs#pickBy|lodash.pickBy} for more information.
  13. * @since 1.0.0
  14. */
  15. const pickBy = convert(_pickBy)
  16. export { pickBy }
+
  1. import { pickBy as _pickBy } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Replaces by an object picking properties that <code>predicate</code> returns truthy for.
  5. * @function
  6. * @memberof object
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @param {function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  10. * @return {Object} Returns the updated object.
  11. * @example pickBy({ nested: { a: 1, b: 2, c: 3, d: 4 } }, 'nested', v => v < 3) // => { nested: { a: 1, b: 2 } }
  12. * @see {@link https://lodash.com/docs#pickBy|lodash.pickBy} for more information.
  13. * @since 1.0.0
  14. */
  15. const pickBy = convert(_pickBy)
  16. export { pickBy }
diff --git a/docs/immutadot-lodash/1.0/string_capitalize.js.html b/docs/immutadot-lodash/1.0/string_capitalize.js.html index 09577ae8..b7a96d04 100644 --- a/docs/immutadot-lodash/1.0/string_capitalize.js.html +++ b/docs/immutadot-lodash/1.0/string_capitalize.js.html @@ -35,7 +35,7 @@

string/capitalize.js

-
  1. import _capitalize from 'lodash/capitalize'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Converts the first character of string to upper case and the remaining to lower case.
  5. * @function
  6. * @memberof string
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @example capitalize({ nested: { a: "a string" } }, 'nested.a') // => { nested: { a: "A string" } }
  11. * @see {@link https://lodash.com/docs#capitalize|lodash.capitalize} for more information.
  12. * @since 1.0.0
  13. */
  14. const capitalize = convert(_capitalize)
  15. export { capitalize }
+
  1. import { capitalize as _capitalize } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Converts the first character of string to upper case and the remaining to lower case.
  5. * @function
  6. * @memberof string
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @example capitalize({ nested: { a: "a string" } }, 'nested.a') // => { nested: { a: "A string" } }
  11. * @see {@link https://lodash.com/docs#capitalize|lodash.capitalize} for more information.
  12. * @since 1.0.0
  13. */
  14. const capitalize = convert(_capitalize)
  15. export { capitalize }
diff --git a/docs/immutadot-lodash/1.0/string_toLower.js.html b/docs/immutadot-lodash/1.0/string_toLower.js.html index 9f3cc516..25e18825 100644 --- a/docs/immutadot-lodash/1.0/string_toLower.js.html +++ b/docs/immutadot-lodash/1.0/string_toLower.js.html @@ -35,7 +35,7 @@

string/toLower.js

-
  1. import _toLower from 'lodash/toLower'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Converts string, as a whole, to lower case just like String#toLowerCase.
  5. * @function
  6. * @memberof string
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @example toLower({ nested: { a: "A STRING" } }, 'nested.a') // => { nested: { a: "a string" } }
  11. * @see {@link https://lodash.com/docs#toLower|lodash.toLower} for more information.
  12. * @see {@link https://mdn.io/String/toLowerCase|String.toLowerCase} for more information.
  13. * @since 1.0.0
  14. */
  15. const toLower = convert(_toLower)
  16. export { toLower }
+
  1. import { toLower as _toLower } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Converts string, as a whole, to lower case just like String#toLowerCase.
  5. * @function
  6. * @memberof string
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @example toLower({ nested: { a: "A STRING" } }, 'nested.a') // => { nested: { a: "a string" } }
  11. * @see {@link https://lodash.com/docs#toLower|lodash.toLower} for more information.
  12. * @see {@link https://mdn.io/String/toLowerCase|String.toLowerCase} for more information.
  13. * @since 1.0.0
  14. */
  15. const toLower = convert(_toLower)
  16. export { toLower }
diff --git a/docs/immutadot-lodash/1.0/string_toUpper.js.html b/docs/immutadot-lodash/1.0/string_toUpper.js.html index ff1e2339..6c677c76 100644 --- a/docs/immutadot-lodash/1.0/string_toUpper.js.html +++ b/docs/immutadot-lodash/1.0/string_toUpper.js.html @@ -35,7 +35,7 @@

string/toUpper.js

-
  1. import _toUpper from 'lodash/toUpper'
  2. import { convert } from 'immutadot/core/convert'
  3. /**
  4. * Converts string, as a whole, to upper case just like String#toUpperCase.
  5. * @function
  6. * @memberof string
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @example toUpper({ nested: { a: "a string" } }, 'nested.a') // => { nested: { a: "A STRING" } }
  11. * @see {@link https://lodash.com/docs#toUpper|lodash.toUpper} for more information.
  12. * @see {@link https://mdn.io/String/toUpperCase|String.toUpperCase} for more information.
  13. * @since 1.0.0
  14. */
  15. const toUpper = convert(_toUpper)
  16. export { toUpper }
+
  1. import { toUpper as _toUpper } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Converts string, as a whole, to upper case just like String#toUpperCase.
  5. * @function
  6. * @memberof string
  7. * @param {Object} object The object to modify.
  8. * @param {Array|string} path The path of the property to set.
  9. * @return {Object} Returns the updated object.
  10. * @example toUpper({ nested: { a: "a string" } }, 'nested.a') // => { nested: { a: "A STRING" } }
  11. * @see {@link https://lodash.com/docs#toUpper|lodash.toUpper} for more information.
  12. * @see {@link https://mdn.io/String/toUpperCase|String.toUpperCase} for more information.
  13. * @since 1.0.0
  14. */
  15. const toUpper = convert(_toUpper)
  16. export { toUpper }
diff --git a/docs/immutadot-lodash/1.0/util_convertLodashFp.js.html b/docs/immutadot-lodash/1.0/util_convertLodashFp.js.html index dab39e5e..0d619be8 100644 --- a/docs/immutadot-lodash/1.0/util_convertLodashFp.js.html +++ b/docs/immutadot-lodash/1.0/util_convertLodashFp.js.html @@ -35,7 +35,7 @@

util/convertLodashFp.js

-
  1. import { convert } from 'immutadot/core/convert'
  2. import { lodashFpConvert } from './lodashFpConvert'
  3. /**
  4. * Converts and wraps a lodash/fp function.
  5. * @memberof util
  6. * @param {function} fn The lodash/fp function.
  7. * @return {function} Returns the wrapped function.
  8. * @see {@link util.convert|convert} for more information.
  9. * @since 0.2.0
  10. * @private
  11. */
  12. const convertLodashFp = fn => convert(lodashFpConvert(fn))
  13. /**
  14. * This is an alias for {@link core.convert}.
  15. * @memberof object
  16. * @function convert
  17. * @deprecated Use {@link core.convert}
  18. * @since 0.2.0
  19. */
  20. export {
  21. convertLodashFp,
  22. }
+
  1. import { convert } from 'immutadot'
  2. import { lodashFpConvert } from './lodashFpConvert'
  3. /**
  4. * Converts and wraps a lodash/fp function.
  5. * @memberof util
  6. * @param {function} fn The lodash/fp function.
  7. * @return {function} Returns the wrapped function.
  8. * @see {@link util.convert|convert} for more information.
  9. * @since 0.2.0
  10. * @private
  11. */
  12. const convertLodashFp = fn => convert(lodashFpConvert(fn))
  13. /**
  14. * This is an alias for {@link core.convert}.
  15. * @memberof object
  16. * @function convert
  17. * @deprecated Use {@link core.convert}
  18. * @since 0.2.0
  19. */
  20. export {
  21. convertLodashFp,
  22. }
diff --git a/docs/immutadot/1.0/array.html b/docs/immutadot/1.0/array.html index 5f3c9943..3e8502dc 100644 --- a/docs/immutadot/1.0/array.html +++ b/docs/immutadot/1.0/array.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_concat.js.html b/docs/immutadot/1.0/array_concat.js.html index b82cc680..f74917e9 100644 --- a/docs/immutadot/1.0/array_concat.js.html +++ b/docs/immutadot/1.0/array_concat.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_fill.js.html b/docs/immutadot/1.0/array_fill.js.html index 81037453..2f2a6058 100644 --- a/docs/immutadot/1.0/array_fill.js.html +++ b/docs/immutadot/1.0/array_fill.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_filter.js.html b/docs/immutadot/1.0/array_filter.js.html index f4ca4535..44a10fc9 100644 --- a/docs/immutadot/1.0/array_filter.js.html +++ b/docs/immutadot/1.0/array_filter.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_index.js.html b/docs/immutadot/1.0/array_index.js.html index 78f08e04..4c11a54a 100644 --- a/docs/immutadot/1.0/array_index.js.html +++ b/docs/immutadot/1.0/array_index.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_map.js.html b/docs/immutadot/1.0/array_map.js.html index bb957abf..b36a458b 100644 --- a/docs/immutadot/1.0/array_map.js.html +++ b/docs/immutadot/1.0/array_map.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_pop.js.html b/docs/immutadot/1.0/array_pop.js.html index 4dd445ac..7fbaa27f 100644 --- a/docs/immutadot/1.0/array_pop.js.html +++ b/docs/immutadot/1.0/array_pop.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_push.js.html b/docs/immutadot/1.0/array_push.js.html index 799bd962..eb97e991 100644 --- a/docs/immutadot/1.0/array_push.js.html +++ b/docs/immutadot/1.0/array_push.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_reverse.js.html b/docs/immutadot/1.0/array_reverse.js.html index 245fa07e..815d97fb 100644 --- a/docs/immutadot/1.0/array_reverse.js.html +++ b/docs/immutadot/1.0/array_reverse.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_shift.js.html b/docs/immutadot/1.0/array_shift.js.html index 44262b76..7aa70f77 100644 --- a/docs/immutadot/1.0/array_shift.js.html +++ b/docs/immutadot/1.0/array_shift.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_slice.js.html b/docs/immutadot/1.0/array_slice.js.html index 5dfd5c01..459f4615 100644 --- a/docs/immutadot/1.0/array_slice.js.html +++ b/docs/immutadot/1.0/array_slice.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_sort.js.html b/docs/immutadot/1.0/array_sort.js.html index af78fb65..976d82bb 100644 --- a/docs/immutadot/1.0/array_sort.js.html +++ b/docs/immutadot/1.0/array_sort.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_splice.js.html b/docs/immutadot/1.0/array_splice.js.html index 890ca589..92c74d35 100644 --- a/docs/immutadot/1.0/array_splice.js.html +++ b/docs/immutadot/1.0/array_splice.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/array_unshift.js.html b/docs/immutadot/1.0/array_unshift.js.html index f71357ad..bbf5b8ff 100644 --- a/docs/immutadot/1.0/array_unshift.js.html +++ b/docs/immutadot/1.0/array_unshift.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/core.html b/docs/immutadot/1.0/core.html index 2a5ed90f..d3957a87 100644 --- a/docs/immutadot/1.0/core.html +++ b/docs/immutadot/1.0/core.html @@ -20,7 +20,7 @@
@@ -307,6 +307,188 @@
Returns:
+
+ +

(static) flow(…args) → {flow.flowFunction}

+ + + + + + +
+ + +
Source:
+
+ + + + + +
Since:
+
  • 1.0.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ Creates a function that will successively call all functions contained in args.
+Each function is called with the result of the previous one.
+Non functions args are tolerated and will be ignored. +
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
+ + args + + + +function +| + +Array.<function()> + + + + + + + + + +
repeatable
+ +
The functions to apply
+ + + + + + + + + + + + + + +
Returns:
+ + +
+ A function successively calling function args +
+ + + +
+
+ Type +
+
+ +flow.flowFunction + + +
+
+ + +
+ + + +

(static) get(obj, path, defaultValue) → {*}

diff --git a/docs/immutadot/1.0/core_convert.js.html b/docs/immutadot/1.0/core_convert.js.html index ab08becb..a88a1a30 100644 --- a/docs/immutadot/1.0/core_convert.js.html +++ b/docs/immutadot/1.0/core_convert.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/core_flow.js.html b/docs/immutadot/1.0/core_flow.js.html new file mode 100644 index 00000000..38cbe25f --- /dev/null +++ b/docs/immutadot/1.0/core_flow.js.html @@ -0,0 +1,54 @@ + + + + + + core/flow.js - Documentation + + + + + + + + + + + + + +
+ +

core/flow.js

+ + + + + + + +
+
+
  1. import { flatten } from 'util/array'
  2. import { isFunction } from 'util/lang'
  3. /**
  4. * A function successively calling a list of functions.
  5. * @callback flowFunction
  6. * @memberof flow
  7. * @param {*} arg The starting value
  8. * @returns {*} The resulting value
  9. * @since 1.0.0
  10. */
  11. /**
  12. * Creates a function that will successively call all functions contained in <code>args</code>.<br/>
  13. * Each function is called with the result of the previous one.<br/>
  14. * Non functions <code>args</code> are tolerated and will be ignored.
  15. * @memberof core
  16. * @param {...(function|Array<function>)} args The functions to apply
  17. * @returns {flow.flowFunction} A function successively calling function <code>args</code>
  18. * @since 1.0.0
  19. */
  20. function flow(...args) {
  21. const fns = flatten(args)
  22. .filter(fn => isFunction(fn))
  23. .map(fn => fn.applier === undefined ? (
  24. ([obj, appliedPaths]) => [fn(obj), appliedPaths]
  25. ) : (
  26. ([obj, appliedPaths]) => [
  27. fn.applier(obj, appliedPaths),
  28. [...appliedPaths, fn.applier.path],
  29. ]
  30. ))
  31. return obj => {
  32. const [result] = fns.reduce(
  33. (acc, fn) => fn(acc),
  34. [obj, []],
  35. )
  36. return result
  37. }
  38. }
  39. export { flow }
+
+
+ + + + + +
+ + + + + + diff --git a/docs/immutadot/1.0/core_get.js.html b/docs/immutadot/1.0/core_get.js.html index 78aaaa9e..61fd0d8f 100644 --- a/docs/immutadot/1.0/core_get.js.html +++ b/docs/immutadot/1.0/core_get.js.html @@ -20,7 +20,7 @@
@@ -35,7 +35,7 @@

core/get.js

-
  1. import {
  2. index,
  3. prop,
  4. } from 'path/consts'
  5. import { isNil } from 'util/lang'
  6. import { unsafeToPath } from 'path/toPath'
  7. /**
  8. * Gets the value at <code>path</code> of <code>obj</code>.
  9. * @memberof core
  10. * @param {*} obj The object.
  11. * @param {string|Array} path The path of the property to get.
  12. * @param {*} defaultValue The default value.
  13. * @return {*} Returns the value or <code>defaultValue</code>.
  14. * @example get({ nested: { prop: 'val' } }, 'nested.prop') // => 'val'
  15. * @example get({ nested: { prop: 'val' } }, 'nested.unknown', 'default') // => 'default'
  16. * @since 1.0.0
  17. */
  18. function get(obj, path, defaultValue) {
  19. function walkPath(curObj, remPath) {
  20. if (remPath.length === 0) return curObj === undefined ? defaultValue : curObj
  21. if (isNil(curObj)) return defaultValue
  22. const [[, prop], ...pathRest] = remPath
  23. return walkPath(curObj[prop], pathRest)
  24. }
  25. const parsedPath = unsafeToPath(path)
  26. if (parsedPath.some(([propType]) => propType !== prop && propType !== index))
  27. throw TypeError('get supports only properties and array indexes in path')
  28. return walkPath(obj, parsedPath)
  29. }
  30. export { get }
+
  1. import {
  2. index,
  3. prop,
  4. } from 'path/consts'
  5. import { isNil } from 'util/lang'
  6. import { toPath } from 'path/toPath'
  7. /**
  8. * Gets the value at <code>path</code> of <code>obj</code>.
  9. * @memberof core
  10. * @param {*} obj The object.
  11. * @param {string|Array} path The path of the property to get.
  12. * @param {*} defaultValue The default value.
  13. * @return {*} Returns the value or <code>defaultValue</code>.
  14. * @example get({ nested: { prop: 'val' } }, 'nested.prop') // => 'val'
  15. * @example get({ nested: { prop: 'val' } }, 'nested.unknown', 'default') // => 'default'
  16. * @since 1.0.0
  17. */
  18. function get(obj, path, defaultValue) {
  19. function walkPath(curObj, remPath) {
  20. if (remPath.length === 0) return curObj === undefined ? defaultValue : curObj
  21. if (isNil(curObj)) return defaultValue
  22. const [[, prop], ...pathRest] = remPath
  23. return walkPath(curObj[prop], pathRest)
  24. }
  25. const parsedPath = toPath(path)
  26. if (parsedPath.some(([propType]) => propType !== prop && propType !== index))
  27. throw TypeError('get supports only properties and array indexes in path')
  28. return walkPath(obj, parsedPath)
  29. }
  30. export { get }
diff --git a/docs/immutadot/1.0/core_index.js.html b/docs/immutadot/1.0/core_index.js.html index be1d700d..01547efc 100644 --- a/docs/immutadot/1.0/core_index.js.html +++ b/docs/immutadot/1.0/core_index.js.html @@ -20,7 +20,7 @@
@@ -35,7 +35,7 @@

core/index.js

-
  1. /**
  2. * Core functions.
  3. * @namespace core
  4. * @since 1.0.0
  5. */
  6. export { convert } from './convert'
  7. export { get } from './get'
  8. export { set } from './set'
  9. export { unset } from './unset'
  10. export { update } from './update'
+
  1. /**
  2. * Core functions.
  3. * @namespace core
  4. * @since 1.0.0
  5. */
  6. export { convert } from './convert'
  7. export { flow } from './flow'
  8. export { get } from './get'
  9. export { set } from './set'
  10. export { unset } from './unset'
  11. export { update } from './update'
diff --git a/docs/immutadot/1.0/core_set.js.html b/docs/immutadot/1.0/core_set.js.html index 7c2c5aff..2c1fff61 100644 --- a/docs/immutadot/1.0/core_set.js.html +++ b/docs/immutadot/1.0/core_set.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/core_unset.js.html b/docs/immutadot/1.0/core_unset.js.html index 5dbc6498..d25efffe 100644 --- a/docs/immutadot/1.0/core_unset.js.html +++ b/docs/immutadot/1.0/core_unset.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/core_update.js.html b/docs/immutadot/1.0/core_update.js.html index 3ecfea08..59826801 100644 --- a/docs/immutadot/1.0/core_update.js.html +++ b/docs/immutadot/1.0/core_update.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/flow.html b/docs/immutadot/1.0/flow.html deleted file mode 100644 index cd386b1d..00000000 --- a/docs/immutadot/1.0/flow.html +++ /dev/null @@ -1,497 +0,0 @@ - - - - - - flow - Documentation - - - - - - - - - - - - - -
- -

flow

- - - - - - - -
- - - -
-
- - - -
- - -
Source:
-
- - - - - -
Since:
-
  • 1.0.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
Flow functions.
- - - - -
- - - - - - - - - - - - - - -
-

Methods

- - - - -
- -

(static) flow(…args) → {flow.flowFunction}

- - - - - - -
- - -
Source:
-
- - - - - -
Since:
-
  • 1.0.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
- Successively calls fns.
-Each function is called with the result of the previous one.
-Falsey functions (null, undefined and false) are tolerated and will be skipped. -
- - - - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
- - args - - - -function -| - -Array.<function()> - - - - - - - - - -
repeatable
- -
The functions to apply
- - - - - - - - - - - - - - -
Returns:
- - -
- A function successively calling fns -
- - - -
-
- Type -
-
- -flow.flowFunction - - -
-
- - -
- - -
- - - -
-

Type Definitions

- - - - -
- -

flowFunction(arg) → {*}

- - - - - - -
- - -
Source:
-
- - - - - -
Since:
-
  • 1.0.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
- A function successively applying a list of functions. -
- - - - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
- - arg - - - -* - - - - The starting value
- - - - - - - - - - - - - - -
Returns:
- - -
- The resulting value -
- - - -
-
- Type -
-
- -* - - -
-
- - -
- - -
- - - -
- -
- - - - -
- - - - - - \ No newline at end of file diff --git a/docs/immutadot/1.0/flow_flow.js.html b/docs/immutadot/1.0/flow_flow.js.html deleted file mode 100644 index 03fdb6af..00000000 --- a/docs/immutadot/1.0/flow_flow.js.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - flow/flow.js - Documentation - - - - - - - - - - - - - -
- -

flow/flow.js

- - - - - - - -
-
-
  1. import { flatten } from 'util/array'
  2. import { isNil } from 'util/lang'
  3. /**
  4. * A function successively applying a list of functions.
  5. * @callback flowFunction
  6. * @memberof flow
  7. * @param {*} arg The starting value
  8. * @returns {*} The resulting value
  9. * @since 1.0.0
  10. */
  11. /**
  12. * Successively calls <code>fns</code>.<br/>
  13. * Each function is called with the result of the previous one.<br/>
  14. * Falsey functions (<code>null</code>, <code>undefined</code> and <code>false</code>) are tolerated and will be skipped.
  15. * @memberof flow
  16. * @param {...(function|Array<function>)} args The functions to apply
  17. * @returns {flow.flowFunction} A function successively calling <code>fns</code>
  18. * @since 1.0.0
  19. */
  20. function flow(...args) {
  21. const fns = flatten(args)
  22. .filter(fn => !isNil(fn) && fn !== false)
  23. .map(fn => fn.applier === undefined ? (
  24. ([obj, appliedPaths]) => [fn(obj), appliedPaths]
  25. ) : (
  26. ([obj, appliedPaths]) => [
  27. fn.applier(obj, appliedPaths),
  28. [...appliedPaths, fn.applier.path],
  29. ]
  30. ))
  31. return obj => {
  32. const [result] = fns.reduce(
  33. (acc, fn) => fn(acc),
  34. [obj, []],
  35. )
  36. return result
  37. }
  38. }
  39. export { flow }
-
-
- - - - - -
- - - - - - diff --git a/docs/immutadot/1.0/flow_index.js.html b/docs/immutadot/1.0/flow_index.js.html deleted file mode 100644 index 598bbfc0..00000000 --- a/docs/immutadot/1.0/flow_index.js.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - flow/index.js - Documentation - - - - - - - - - - - - - -
- -

flow/index.js

- - - - - - - -
-
-
  1. /**
  2. * Flow functions.
  3. * @namespace flow
  4. * @since 1.0.0
  5. */
  6. export { flow } from './flow'
-
-
- - - - - -
- - - - - - diff --git a/docs/immutadot/1.0/index.html b/docs/immutadot/1.0/index.html index 3a8fbcff..6f31eda1 100644 --- a/docs/immutadot/1.0/index.html +++ b/docs/immutadot/1.0/index.html @@ -20,7 +20,7 @@
@@ -56,87 +56,69 @@

NamespacesCircleCI codecov Greenkeeper

-

1.0 Release Candidate is out 🎉

We are still writing the documentation, you can already find out about the updated API and our new package immutadot-lodash.

-

If you would like to try out 1.0 before its official release, install it with :

-
yarn add immutadot@next

or

-
npm install immutadot@next

Immutability

In the last few years one of our biggest challenge has been to find an efficient way to detect changes in our data to determine when to re-render our interfaces.

-

An immutable object is an object that cannot be changed once created. It brings several benefits1:

-
    -
  • Data changes detection made simple (Shallow comparison)
  • -
  • Memoization
  • -
  • Improve rendering performances
  • -
  • Explicit data changes
  • -
  • Avoid side effects
  • -
-

Our approach

Concise

ES2015+ new features are great to deal with arrays and objects. As data structures expand, the code you write to make data immutable gets bigger and less readable. immutadâ—Źt uses the dot notation to address this issue.

-

Interoperability

immutadâ—Źt uses plain JavaScript objects so you can access your data using standard ways. Moreover, it lets you freely enjoy your favorite libraries.

-

Exhaustive and yet extensible

immutadâ—Źt comes with a large set of built-in utilities, mostly based on ES2015+. You can also find a package called immutadot-lodash with some of lodash's utilities. You haven't found what you're looking for? Do it yourself with the convert feature.

-

Learning curve

If you are already familiar with ES2015+ and lodash then you should be able to use immutadâ—Źt quickly.

+

1.0 is out 🎉

If you were using a previous version of immutadâ—Źt, check out the migrating guide.

Installation

immutadâ—Źt is available on npm repository.

using yarn:

$ yarn add immutadot

using npm:

$ npm install immutadot

or you can directly download sources.

Usage

ES modules:

import { set } from 'immutadot'

CommonJS:

-
const { set } = require('immutadot')

Example

Object used in the following example:

-
const animals = {
-  weasels: [
-    {
-      vernacularName: 'badger',
-      scientificName: 'Meles meles'
+
const { set } = require('immutadot')

Example

Quickly set nested properties using set()

+
import { set } from 'immutadot'
+
+const animals = {
+  weasels: {
+    lutraLutra: {
+      commonNames: ['eurasian otter'],
     },
-    {
-      vernacularName: 'otter',
-    }
-  ]
-}

Let's add the otter's scientific name without mutating the original object structure.

-

using ES2015+:

-
const newAnimals = {
-  ...animals,
-  weasels: [...animals.weasel]
+  },
 }
 
-newAnimals.weasels[1] = {
-  ...newAnimals.weasels[1],
-  scientificName: 'Lutrinae'
-}

using immutadâ—Źt:

-
const newAnimals = set(animals, 'weasels[1].scientificName', 'Lutrinae')

Feel free to try immutadâ—Źt on runkit.

-

Path notation

immutadâ—Źt brings a few improvements to the classic dot notation:

-

Slice notation

The slice notation lets you iterate over arrays to apply operations without having to map arrays at each level of imbrication.

-

We forgot to capitalize vernacular names in the input.

-

using ES2015+:

-
import { capitalize } from 'lodash'
-const newAnimals = {
-  ...animals,
-  weasels: animals.weasels.map(weasel => {
-    return {
-      ...weasel,
-      vernacularName: capitalize(weasel.vernacularName),
-    }
-  }),
-}

using immutadâ—Źt-lodash:

-
import { capitalize } from 'immutadot-lodash'
-const newAnimals = capitalize(animals, 'weasels[:].vernacularName')

List notation

The list notation lets you iterate over the keys of objects used as collection or map to apply operations.

-
toggle({ nested: { prop: { 1: { active: true }, 2: { active: false } } } }, 'nested.prop.{*}.active')
-// { nested: { prop: { 1: { active: false }, 2: { active: true }] } }
-
-toLowerCase({ nested: { prop: { 1: { msg: 'Hello' }, 2: { msg: 'Hi' }, 3: { msg: 'Good morning' } } } }, 'nested.prop{2, 3}.msg')
-// { nested: { prop: { 1: { msg: 'Hello' }, 2: { msg: 'hi' }, 3: { msg: 'good morning' } } } }

Performances

We reused a simple benchmark originally made by mweststrate for immer. -It updates 10.000 items out of list of 100.000 todos items, these tests were ran with Node 8.4.0 on an Intel® Core™ i7-6560U CPU @ 2.20GHz:

-
Update todos list
-  âś“ with mutation (2ms)
-  âś“ with deep cloning, then mutation (689ms)
-  âś“ with ES2015 destructuring (42ms)
-  âś“ with immutable (w/o conversion to plain JS objects) (50ms)
-  âś“ with immutable (w/ conversion to plain JS objects) (1011ms)
-  âś“ with immer (proxy implementation w/o autofreeze) (259ms)
-  âś“ with immutadâ—Źt (77ms)

When applying operations on a path immutadâ—Źt tries to create the minimum of objects or arrays needed to guarantee your data structure to be immutable.

-

Documentation

Latest API documentation for our different packages are available here:

+const newAnimals = set(animals, 'weasels.lutraLutra.name', 'Lutrinae')

Learn more about what immutadâ—Źt can do in the Getting started.

+

Feel free to try immutadâ—Źt on runkit.

+

Documentation

Getting started

A fast overview of immutadâ—Źt's features is available in the Getting started guide.

+

API

The detailed API documentations of the different packages are available here:

Looking for older versions API documentation? Links are available here.

+

Migrating from 0.x versions

If you were using a version of immutadâ—Źt previous to 1.0, check out the migrating guide.

+

Performances

A simple benchmark (freely inspired from one made by mweststrate for immer) reveals that immutadâ—Źt shows good results compared to other libraries.

+

:warning: The following results should be taken with caution, they may vary depending on the hardware, the JavaScript engine, and the kind of operations performed. This particular test updates 10% out of a list of todos items, and was ran with Node 9.3.0 on an Intel® Core™ i7-6560U CPU @ 2.20GHz.

+
Update small todos list (1000 items):
+  ES2015 destructuring: ~16961ops/s (0.06ms/op) on 50000ops
+  immutable 3.8.2 (w/o conversion to plain JS objects): ~6538ops/s (0.15ms/op) on 50000ops
+  immutable 3.8.2 (w/ conversion to plain JS objects): ~106ops/s (9.43ms/op) on 3195ops
+  immer 0.8.1 (proxy implementation w/o autofreeze): ~2191ops/s (0.46ms/op) on 50000ops
+  immer 0.8.1 (ES5 implementation w/o autofreeze): ~494ops/s (2.02ms/op) on 14827ops
+  immutadâ—Źt 1.0.0: ~2431ops/s (0.41ms/op) on 50000ops
+Update medium todos list (10000 items):
+  ES2015 destructuring: ~1781ops/s (0.56ms/op) on 5000ops
+  immutable 3.8.2 (w/o conversion to plain JS objects): ~587ops/s (1.70ms/op) on 5000ops
+  immutable 3.8.2 (w/ conversion to plain JS objects): ~10ops/s (100.80ms/op) on 299ops
+  immer 0.8.1 (proxy implementation w/o autofreeze): ~185ops/s (5.42ms/op) on 5000ops
+  immer 0.8.1 (ES5 implementation w/o autofreeze): ~47ops/s (21.21ms/op) on 1415ops
+  immutadâ—Źt 1.0.0: ~245ops/s (4.08ms/op) on 5000ops
+Update large todos list (100000 items):
+  ES2015 destructuring: ~116ops/s (8.61ms/op) on 500ops
+  immutable 3.8.2 (w/o conversion to plain JS objects): ~56ops/s (17.95ms/op) on 500ops
+  immutable 3.8.2 (w/ conversion to plain JS objects): ~1ops/s (1052.45ms/op) on 29ops
+  immer 0.8.1 (proxy implementation w/o autofreeze): ~21ops/s (47.81ms/op) on 500ops
+  immer 0.8.1 (ES5 implementation w/o autofreeze): ~4ops/s (275.59ms/op) on 110ops
+  immutadâ—Źt 1.0.0: ~23ops/s (44.15ms/op) on 500ops

Immutability

In the last few years one of our biggest challenge has been to find an efficient way to detect changes in our data to determine when to re-render our interfaces.

+

An immutable object is an object that cannot be changed once created. It brings several benefits1:

+
    +
  • Data changes detection made simple (Shallow comparison)
  • +
  • Memoization
  • +
  • Improve rendering performances
  • +
  • Explicit data changes
  • +
  • Avoid side effects
  • +
+

Our approach

Concise

ES2015+ new features are great to deal with arrays and objects. As data structures expand, the code you write to make data immutable gets bigger and less readable. immutadâ—Źt uses the dot notation to address this issue.

+

Interoperability

immutadâ—Źt uses plain JavaScript objects so you can access your data using standard ways. Moreover, it lets you freely enjoy your favorite libraries.

+

Exhaustive and yet extensible

immutadâ—Źt comes with a large set of built-in utilities, mostly based on ES2015+. You can also find a package called immutadot-lodash with some of lodash's utilities. You haven't found what you're looking for? Do it yourself with the convert feature.

+

Learning curve

If you are already familiar with ES2015+ and lodash then you should be able to use immutadâ—Źt quickly.

Contributing

We want contributing to immutadâ—Źt to be fun, enjoyable, and educational for anyone, and everyone.

Code of Conduct

In the interest of fostering an open and welcoming environment, we have adopted a Code of Conduct that we expect project participants to commit to. Please read the full text so that you can understand what behavior will and will not be tolerated.

Contributing guide

If you are interested in contributing to immutadâ—Źt, please read our contributing guide to learn more about how to suggest bugfixes and improvements.

diff --git a/docs/immutadot/1.0/lang.html b/docs/immutadot/1.0/lang.html index 181fc6d2..416b57b0 100644 --- a/docs/immutadot/1.0/lang.html +++ b/docs/immutadot/1.0/lang.html @@ -20,7 +20,7 @@
@@ -328,6 +328,271 @@
Parameters:
+
Returns:
+ + +
+ Returns the updated object. +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + +
+ + + + +
+ +

(static) and(object, path, […args]) → {Object}

+ + + + + + +
+ + +
Source:
+
+ + + + + +
Since:
+
  • 1.0.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ Applies && between the former value and args +
+ + + + + + + + + +
Examples
+ +
and({ nested: { prop: true } }, 'nested.prop', true) // { nested: { prop: true } }
+ +
and({ nested: { prop: true } }, 'nested.prop', true, false) // { nested: { prop: false } }
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
+ + object + + + +Object + + + + + + + + + + The object to modify.
+ + path + + + +Array +| + +string + + + + + + + + + + The path of the property to set.
+ + args + + + +* + + + + + +
optional
+ + + + + +
repeatable
+ +
Other operands.
+ + + + + + + + + + + + + +
Returns:
@@ -794,6 +1059,271 @@
Parameters:
+
Returns:
+ + +
+ Returns the updated object. +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + +
+ + + + +
+ +

(static) or(object, path, […args]) → {Object}

+ + + + + + +
+ + +
Source:
+
+ + + + + +
Since:
+
  • 1.0.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ Applies || between the former value and args +
+ + + + + + + + + +
Examples
+ +
or({ nested: { prop: false } }, 'nested.prop', true) // { nested: { prop: true } }
+ +
or({ nested: { prop: true } }, 'nested.prop', false, false) // { nested: { prop: true } }
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
+ + object + + + +Object + + + + + + + + + + The object to modify.
+ + path + + + +Array +| + +string + + + + + + + + + + The path of the property to set.
+ + args + + + +* + + + + + +
optional
+ + + + + +
repeatable
+ +
Other operands.
+ + + + + + + + + + + + + +
Returns:
diff --git a/docs/immutadot/1.0/lang_add.js.html b/docs/immutadot/1.0/lang_add.js.html index fec036da..47ed8798 100644 --- a/docs/immutadot/1.0/lang_add.js.html +++ b/docs/immutadot/1.0/lang_add.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/lang_and.js.html b/docs/immutadot/1.0/lang_and.js.html new file mode 100644 index 00000000..f78a9f59 --- /dev/null +++ b/docs/immutadot/1.0/lang_and.js.html @@ -0,0 +1,54 @@ + + + + + + lang/and.js - Documentation + + + + + + + + + + + + + +
+ +

lang/and.js

+ + + + + + + +
+
+
  1. import { convert } from 'core/convert'
  2. /**
  3. * Applies <code>&&</code> between the former value and <code>args</code>
  4. * @function
  5. * @memberof lang
  6. * @param {Object} object The object to modify.
  7. * @param {Array|string} path The path of the property to set.
  8. * @param {...*} [args] Other operands.
  9. * @return {Object} Returns the updated object.
  10. * @example and({ nested: { prop: true } }, 'nested.prop', true) // { nested: { prop: true } }
  11. * @example and({ nested: { prop: true } }, 'nested.prop', true, false) // { nested: { prop: false } }
  12. * @since 1.0.0
  13. */
  14. const and = convert((v, ...args) => args.reduce((acc, arg) => acc && arg, v))
  15. export { and }
+
+
+ + + + + +
+ + + + + + diff --git a/docs/immutadot/1.0/lang_divide.js.html b/docs/immutadot/1.0/lang_divide.js.html index e3b3e962..cbf86609 100644 --- a/docs/immutadot/1.0/lang_divide.js.html +++ b/docs/immutadot/1.0/lang_divide.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/lang_index.js.html b/docs/immutadot/1.0/lang_index.js.html index 114a8a44..8e87baa3 100644 --- a/docs/immutadot/1.0/lang_index.js.html +++ b/docs/immutadot/1.0/lang_index.js.html @@ -20,7 +20,7 @@
@@ -35,7 +35,7 @@

lang/index.js

-
  1. /**
  2. * Lang functions.
  3. * @namespace lang
  4. * @since 0.1.5
  5. */
  6. export { add } from './add'
  7. export { divide } from './divide'
  8. export { multiply } from './multiply'
  9. export { subtract } from './subtract'
  10. export { toggle } from './toggle'
+
  1. /**
  2. * Lang functions.
  3. * @namespace lang
  4. * @since 0.1.5
  5. */
  6. export { add } from './add'
  7. export { and } from './and'
  8. export { divide } from './divide'
  9. export { multiply } from './multiply'
  10. export { or } from './or'
  11. export { subtract } from './subtract'
  12. export { toggle } from './toggle'
diff --git a/docs/immutadot/1.0/lang_multiply.js.html b/docs/immutadot/1.0/lang_multiply.js.html index 829d8ed1..9f7f91da 100644 --- a/docs/immutadot/1.0/lang_multiply.js.html +++ b/docs/immutadot/1.0/lang_multiply.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/lang_or.js.html b/docs/immutadot/1.0/lang_or.js.html new file mode 100644 index 00000000..820c4ec9 --- /dev/null +++ b/docs/immutadot/1.0/lang_or.js.html @@ -0,0 +1,54 @@ + + + + + + lang/or.js - Documentation + + + + + + + + + + + + + +
+ +

lang/or.js

+ + + + + + + +
+
+
  1. import { convert } from 'core/convert'
  2. /**
  3. * Applies <code>||</code> between the former value and <code>args</code>
  4. * @function
  5. * @memberof lang
  6. * @param {Object} object The object to modify.
  7. * @param {Array|string} path The path of the property to set.
  8. * @param {...*} [args] Other operands.
  9. * @return {Object} Returns the updated object.
  10. * @example or({ nested: { prop: false } }, 'nested.prop', true) // { nested: { prop: true } }
  11. * @example or({ nested: { prop: true } }, 'nested.prop', false, false) // { nested: { prop: true } }
  12. * @since 1.0.0
  13. */
  14. const or = convert((v, ...args) => args.reduce((acc, arg) => acc || arg, v))
  15. export { or }
+
+
+ + + + + +
+ + + + + + diff --git a/docs/immutadot/1.0/lang_subtract.js.html b/docs/immutadot/1.0/lang_subtract.js.html index 62f3db4d..f9fec8d4 100644 --- a/docs/immutadot/1.0/lang_subtract.js.html +++ b/docs/immutadot/1.0/lang_subtract.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/lang_toggle.js.html b/docs/immutadot/1.0/lang_toggle.js.html index 646d513e..8dec8c29 100644 --- a/docs/immutadot/1.0/lang_toggle.js.html +++ b/docs/immutadot/1.0/lang_toggle.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/object.html b/docs/immutadot/1.0/object.html index bc828523..1715dc94 100644 --- a/docs/immutadot/1.0/object.html +++ b/docs/immutadot/1.0/object.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/object_assign.js.html b/docs/immutadot/1.0/object_assign.js.html index f1566967..498eedf6 100644 --- a/docs/immutadot/1.0/object_assign.js.html +++ b/docs/immutadot/1.0/object_assign.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/object_index.js.html b/docs/immutadot/1.0/object_index.js.html index ed3611d8..9f6d7822 100644 --- a/docs/immutadot/1.0/object_index.js.html +++ b/docs/immutadot/1.0/object_index.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/path.html b/docs/immutadot/1.0/path.html deleted file mode 100644 index 431a4627..00000000 --- a/docs/immutadot/1.0/path.html +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - path - Documentation - - - - - - - - - - - - - -
- -

path

- - - - - - - -
- - - -
-
- - - -
- - -
Source:
-
- - - - - -
Since:
-
  • 1.0.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
Path functions.
- - - - -
- - - - - - - - - - - - - - -
-

Methods

- - - - -
- -

(static) toPath(arg) → {Array.<Array.<Symbol, ...*>>}

- - - - - - -
- - -
Source:
-
- - - - - -
Since:
-
  • 1.0.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
- Converts arg to a path represented as an array of keys.
-arg may be a string, in which case it will be parsed.
-It may also be an Array, in which case a copy of the array with values converted to path keys will be returned.
-If arg is neither a string nor an Array, its string representation will be parsed. -
- - - - - - - - - -
Example
- -
toPath('a.b[1]["."][1:-1]') // => [[prop, 'a'], [prop, 'b'], [index, 1], [prop, '.'], [slice, [1, -1]]]
- - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
- - arg - - - -string -| - -Array -| - -* - - - - The value to convert
- - - - - - - - - - - - - - -
Returns:
- - -
- The path represented as an array of keys -
- - - -
-
- Type -
-
- -Array.<Array.<Symbol, ...*>> - - -
-
- - -
- - -
- - - - - -
- -
- - - - -
- - - - - - \ No newline at end of file diff --git a/docs/immutadot/1.0/path_index.js.html b/docs/immutadot/1.0/path_index.js.html deleted file mode 100644 index 49320606..00000000 --- a/docs/immutadot/1.0/path_index.js.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - path/index.js - Documentation - - - - - - - - - - - - - -
- -

path/index.js

- - - - - - - -
-
-
  1. /**
  2. * Path functions.
  3. * @namespace path
  4. * @since 1.0.0
  5. */
  6. export { toPath } from './toPath'
-
-
- - - - - -
- - - - - - diff --git a/docs/immutadot/1.0/path_toPath.js.html b/docs/immutadot/1.0/path_toPath.js.html deleted file mode 100644 index a49b99dc..00000000 --- a/docs/immutadot/1.0/path_toPath.js.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - path/toPath.js - Documentation - - - - - - - - - - - - - -
- -

path/toPath.js

- - - - - - - -
-
-
  1. import {
  2. allProps,
  3. index,
  4. list,
  5. prop,
  6. slice,
  7. } from './consts'
  8. import {
  9. filter,
  10. map,
  11. race,
  12. regexp,
  13. } from './parser.utils'
  14. import {
  15. isIndex,
  16. isSliceIndex,
  17. } from './utils'
  18. import {
  19. isNil,
  20. toString,
  21. } from 'util/lang'
  22. /**
  23. * Strip slashes preceding occurences of <code>quote</code> from <code>str</code><br />
  24. * Possible quotes are <code>"</code> and <code>'</code>.
  25. * @function
  26. * @param {string} str The string
  27. * @param {string} quote The quote to unescape
  28. * @returns {string} The unescaped string
  29. * @memberof path
  30. * @private
  31. * @since 1.0.0
  32. */
  33. const unescapeQuotes = (str, quote) => str.replace(new RegExp(`\\\\${quote}`, 'g'), quote)
  34. /**
  35. * Converts <code>str</code> to a slice index.
  36. * @function
  37. * @param {string} str The string to convert
  38. * @param {number?} defaultValue The default value if <code>str</code> is empty
  39. * @returns {number} <code>undefined</code> if <code>str</code> is empty, otherwise an int (may be NaN)
  40. * @memberof path
  41. * @private
  42. * @since 1.0.0
  43. */
  44. const toSliceIndex = (str, defaultValue) => str === '' ? defaultValue : Number(str)
  45. /**
  46. * Tests whether <code>arg</code> is a valid slice index once converted to a number.
  47. * @function
  48. * @memberof path
  49. * @param {*} arg The value to test
  50. * @returns {boolean} True if <code>arg</code> is a valid slice index once converted to a number, false otherwise.
  51. * @private
  52. * @since 1.0.0
  53. */
  54. const isSliceIndexString = arg => isSliceIndex(arg ? Number(arg) : undefined)
  55. /**
  56. * Wraps <code>fn</code> allowing to call it with an array instead of a string.<br />
  57. * The returned function behaviour is :<br />
  58. * - If called with an array, returns a copy of the array with values converted to path keys<br />
  59. * - Otherwise, calls <code>fn</code> with the string representation of its argument
  60. * @function
  61. * @param {function} fn The function to wrap
  62. * @returns {function} The wrapper function
  63. * @memberof path
  64. * @private
  65. * @since 1.0.0
  66. */
  67. const allowingArrays = fn => arg => {
  68. if (Array.isArray(arg)) return arg
  69. return fn(arg)
  70. }
  71. const emptyStringParser = str => str.length === 0 ? [] : null
  72. const quotedBracketNotationParser = map(
  73. regexp(/^\[(['"])(.*?[^\\])\1\]?\.?(.*)$/),
  74. ([quote, property, rest]) => [[prop, unescapeQuotes(property, quote)], ...stringToPath(rest)],
  75. )
  76. const incompleteQuotedBracketNotationParser = map(
  77. regexp(/^(\[["'][^.[{]*)\.?(.*)$/),
  78. ([beforeNewSegment, rest]) => [[prop, beforeNewSegment], ...stringToPath(rest)],
  79. )
  80. const bareBracketNotationParser = map(
  81. regexp(/^\[([^\]]*)\]\.?(.*)$/),
  82. ([property, rest]) => {
  83. return isIndex(Number(property))
  84. ? [[index, Number(property)], ...stringToPath(rest)]
  85. : [[prop, property], ...stringToPath(rest)]
  86. },
  87. )
  88. const incompleteBareBracketNotationParser = map(
  89. regexp(/^(\[[^.[{]*)\.?(.*)$/),
  90. ([beforeNewSegment, rest]) => [[prop, beforeNewSegment], ...stringToPath(rest)],
  91. )
  92. const sliceNotationParser = map(
  93. filter(
  94. regexp(/^\[([^:\]]*):([^:\]]*)\]\.?(.*)$/),
  95. ([sliceStart, sliceEnd]) => isSliceIndexString(sliceStart) && isSliceIndexString(sliceEnd),
  96. ),
  97. ([sliceStart, sliceEnd, rest]) => [[slice, [toSliceIndex(sliceStart, 0), toSliceIndex(sliceEnd)]], ...stringToPath(rest)],
  98. )
  99. const listWildCardParser = map(
  100. regexp(/^{\*}\.?(.*)$/),
  101. ([rest]) => [[allProps], ...stringToPath(rest)],
  102. )
  103. const listPropRegexp = /^,?((?!["'])([^,]*)|(["'])(.*?[^\\])\3)(.*)/
  104. function* extractListProps(rawProps) {
  105. if (rawProps.startsWith(',')) yield ''
  106. let remProps = rawProps
  107. while (remProps !== '') {
  108. const [, , bareProp, , quotedProp, rest] = listPropRegexp.exec(remProps)
  109. yield bareProp === undefined ? quotedProp : bareProp
  110. remProps = rest
  111. }
  112. }
  113. const listNotationParser = map(
  114. regexp(/^\{(((?!["'])[^,}]*|(["']).*?[^\\]\2)(,((?!["'])[^,}]*|(["']).*?[^\\]\6))*)\}\.?(.*)$/),
  115. ([rawProps, , , , , , rest]) => {
  116. const props = [...extractListProps(rawProps)]
  117. return props.length === 1 ? [[prop, props[0]], ...stringToPath(rest)] : [[list, props], ...stringToPath(rest)]
  118. },
  119. )
  120. const incompleteListNotationParser = map(
  121. regexp(/^(\{[^.[{]*)\.?(.*)$/),
  122. ([beforeNewSegment, rest]) => [[prop, beforeNewSegment], ...stringToPath(rest)],
  123. )
  124. const pathSegmentEndedByNewSegment = map(
  125. regexp(/^([^.[{]*)\.?([[{]?.*)$/),
  126. ([beforeNewSegment, rest]) => [[prop, beforeNewSegment], ...stringToPath(rest)],
  127. )
  128. const applyParsers = race([
  129. emptyStringParser,
  130. quotedBracketNotationParser,
  131. incompleteQuotedBracketNotationParser,
  132. sliceNotationParser,
  133. bareBracketNotationParser,
  134. incompleteBareBracketNotationParser,
  135. listWildCardParser,
  136. listNotationParser,
  137. incompleteListNotationParser,
  138. pathSegmentEndedByNewSegment,
  139. ])
  140. /**
  141. * Converts <code>arg</code> to a path represented as an array of keys.
  142. * @function
  143. * @param {*} arg The value to convert
  144. * @returns {Array<string|number|Array>} The path represented as an array of keys
  145. * @memberof path
  146. * @private
  147. * @since 1.0.0
  148. */
  149. const stringToPath = arg => {
  150. if (isNil(arg)) return []
  151. return applyParsers(toString(arg))
  152. }
  153. const MAX_CACHE_SIZE = 1000
  154. const cache = new Map()
  155. /**
  156. * Memoized version of {@link core.stringToPath}.<br />
  157. * The cache has a maximum size of 1000, when overflowing the cache is cleared.
  158. * @function
  159. * @param {string} str The string to convert
  160. * @returns {Array<string|number|Array>} The path represented as an array of keys
  161. * @memberof path
  162. * @private
  163. * @since 1.0.0
  164. */
  165. const memoizedStringToPath = str => {
  166. if (cache.has(str)) return cache.get(str)
  167. const path = stringToPath(str)
  168. if (cache.size === MAX_CACHE_SIZE) cache.clear()
  169. cache.set(str, path)
  170. return path
  171. }
  172. /**
  173. * Converts <code>arg</code> to a path represented as an array of keys.<br />
  174. * <code>arg</code> may be a string, in which case it will be parsed.<br />
  175. * It may also be an Array, in which case a copy of the array with values converted to path keys will be returned.<br />
  176. * If <code>arg</code> is neither a string nor an Array, its string representation will be parsed.
  177. * @function
  178. * @param {string|Array|*} arg The value to convert
  179. * @returns {Array<Array<Symbol,...*>>} The path represented as an array of keys
  180. * @memberof path
  181. * @since 1.0.0
  182. * @example toPath('a.b[1]["."][1:-1]') // => [[prop, 'a'], [prop, 'b'], [index, 1], [prop, '.'], [slice, [1, -1]]]
  183. */
  184. const toPath = allowingArrays(arg => [...memoizedStringToPath(arg)])
  185. /**
  186. * This method is like {@link core.toPath} except it returns memoized arrays which must not be mutated.
  187. * @function
  188. * @param {string|Array|*} arg The value to convert
  189. * @returns {Array<Array<Symbol,...*>>} The path represented as an array of keys
  190. * @memberof path
  191. * @since 1.0.0
  192. * @private
  193. */
  194. const unsafeToPath = allowingArrays(memoizedStringToPath)
  195. export { toPath, unsafeToPath }
-
-
- - - - - -
- - - - - - diff --git a/docs/immutadot/1.0/string.html b/docs/immutadot/1.0/string.html index 67b9b817..bbc11003 100644 --- a/docs/immutadot/1.0/string.html +++ b/docs/immutadot/1.0/string.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_concat.js.html b/docs/immutadot/1.0/string_concat.js.html index 49cd5c96..c5c51823 100644 --- a/docs/immutadot/1.0/string_concat.js.html +++ b/docs/immutadot/1.0/string_concat.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_index.js.html b/docs/immutadot/1.0/string_index.js.html index 5d54cbf4..5c20ca71 100644 --- a/docs/immutadot/1.0/string_index.js.html +++ b/docs/immutadot/1.0/string_index.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_padEnd.js.html b/docs/immutadot/1.0/string_padEnd.js.html index 03e8aecd..5365350d 100644 --- a/docs/immutadot/1.0/string_padEnd.js.html +++ b/docs/immutadot/1.0/string_padEnd.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_padStart.js.html b/docs/immutadot/1.0/string_padStart.js.html index 9c0ee1d4..f796b12b 100644 --- a/docs/immutadot/1.0/string_padStart.js.html +++ b/docs/immutadot/1.0/string_padStart.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_replace.js.html b/docs/immutadot/1.0/string_replace.js.html index 973c1263..8518f055 100644 --- a/docs/immutadot/1.0/string_replace.js.html +++ b/docs/immutadot/1.0/string_replace.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_slice.js.html b/docs/immutadot/1.0/string_slice.js.html index 9008d938..1ea7ebbe 100644 --- a/docs/immutadot/1.0/string_slice.js.html +++ b/docs/immutadot/1.0/string_slice.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_substr.js.html b/docs/immutadot/1.0/string_substr.js.html index 677186b4..9aba1ad3 100644 --- a/docs/immutadot/1.0/string_substr.js.html +++ b/docs/immutadot/1.0/string_substr.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_substring.js.html b/docs/immutadot/1.0/string_substring.js.html index adecb3df..95941e07 100644 --- a/docs/immutadot/1.0/string_substring.js.html +++ b/docs/immutadot/1.0/string_substring.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_toLocaleLowerCase.js.html b/docs/immutadot/1.0/string_toLocaleLowerCase.js.html index 6df75f3c..57fd3d9a 100644 --- a/docs/immutadot/1.0/string_toLocaleLowerCase.js.html +++ b/docs/immutadot/1.0/string_toLocaleLowerCase.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_toLocaleUpperCase.js.html b/docs/immutadot/1.0/string_toLocaleUpperCase.js.html index 904440d8..e54d0b2d 100644 --- a/docs/immutadot/1.0/string_toLocaleUpperCase.js.html +++ b/docs/immutadot/1.0/string_toLocaleUpperCase.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_toLowerCase.js.html b/docs/immutadot/1.0/string_toLowerCase.js.html index 41cfceb5..6d66f016 100644 --- a/docs/immutadot/1.0/string_toLowerCase.js.html +++ b/docs/immutadot/1.0/string_toLowerCase.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_toUpperCase.js.html b/docs/immutadot/1.0/string_toUpperCase.js.html index cd2e96b8..a4725ed6 100644 --- a/docs/immutadot/1.0/string_toUpperCase.js.html +++ b/docs/immutadot/1.0/string_toUpperCase.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_trim.js.html b/docs/immutadot/1.0/string_trim.js.html index 3e3a47b4..5238a85c 100644 --- a/docs/immutadot/1.0/string_trim.js.html +++ b/docs/immutadot/1.0/string_trim.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_trimLeft.js.html b/docs/immutadot/1.0/string_trimLeft.js.html index abf2f3fb..472ed6ab 100644 --- a/docs/immutadot/1.0/string_trimLeft.js.html +++ b/docs/immutadot/1.0/string_trimLeft.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/string_trimRight.js.html b/docs/immutadot/1.0/string_trimRight.js.html index f8d64f3c..0a470b1a 100644 --- a/docs/immutadot/1.0/string_trimRight.js.html +++ b/docs/immutadot/1.0/string_trimRight.js.html @@ -20,7 +20,7 @@
diff --git a/docs/immutadot/1.0/util_protect.js.html b/docs/immutadot/1.0/util_protect.js.html index 7957f340..b947153b 100644 --- a/docs/immutadot/1.0/util_protect.js.html +++ b/docs/immutadot/1.0/util_protect.js.html @@ -20,7 +20,7 @@
diff --git a/lerna.json b/lerna.json index 0c8acbf2..f26908c6 100644 --- a/lerna.json +++ b/lerna.json @@ -5,5 +5,5 @@ "packages/*" ], "useWorkspaces": true, - "version": "1.0.0-rc.7" + "version": "1.0.0" } diff --git a/package.json b/package.json index d1e811b1..c82d84de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutadot", - "version": "1.0.0-rc.7", + "version": "1.0.0", "license": "MIT", "private": true, "scripts": { diff --git a/packages/immutadot-benchmark/package.json b/packages/immutadot-benchmark/package.json index 5180d158..1d4b6d8e 100644 --- a/packages/immutadot-benchmark/package.json +++ b/packages/immutadot-benchmark/package.json @@ -1,13 +1,13 @@ { "name": "immutadot-benchmark", - "version": "1.0.0-rc.7", + "version": "1.0.0", "private": "true", "license": "MIT", "devDependencies": { "cross-env": "~5.1.3", "immer": "~0.8.2", "immutable": "~3.8.2", - "immutadot": "~1.0.0-rc.7", + "immutadot": "~1.0.0", "jest": "~21.2.1", "lerna": "~2.8.0" }, diff --git a/packages/immutadot-lodash/package.json b/packages/immutadot-lodash/package.json index af521bfa..ec3fbf56 100644 --- a/packages/immutadot-lodash/package.json +++ b/packages/immutadot-lodash/package.json @@ -1,6 +1,6 @@ { "name": "immutadot-lodash", - "version": "1.0.0-rc.7", + "version": "1.0.0", "description": "immutadot-lodash is an extension to immutadot, adding functions based on lodash.", "keywords": [ "immutable", @@ -22,7 +22,7 @@ "Charles-Henri GUÉRIN (https://github.com/charlyx)" ], "peerDependencies": { - "immutadot": "^1.0.0-rc.7", + "immutadot": "^1.0.0", "lodash": "^4.6.0" }, "devDependencies": { diff --git a/packages/immutadot/package.json b/packages/immutadot/package.json index d040c3c4..094523d1 100644 --- a/packages/immutadot/package.json +++ b/packages/immutadot/package.json @@ -1,6 +1,6 @@ { "name": "immutadot", - "version": "1.0.0-rc.7", + "version": "1.0.0", "description": "immutad●t (pronounced immutadot) is a set of immutable functions using dot notation.", "keywords": [ "immutable",