immutable-recursive
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -15,3 +15,3 @@ 'use strict'; | ||
/** | ||
* Returns a specific node from the tree. | ||
* Once fully applied, this returns a specific node from the tree. | ||
* When no `childPath` is provided then this is functionally equivalent to Immutable's `getIn()` function. | ||
@@ -21,3 +21,3 @@ * | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
* @param [notSetValue=null] A value to return when there is no node corresponding to `nodePath`. | ||
* @param {*} [notSetValue=null] A value to return when there is no node corresponding to `nodePath`. | ||
* @return {InputFunction} A partially applied function which accepts a single tree `Iterable`. `InputFunction` will return the node at the specified `nodePath`, or if no node exists then `notSetValue` will be returned. | ||
@@ -35,8 +35,10 @@ */ | ||
/** | ||
* Returns the children of a specific node from the tree. | ||
* When no `childPat`h is provided then this is functionally equivalent to Immutable's `getIn()` function or `deepMap()`. | ||
* Once fully applied, this returns the children of a specific node from the tree. | ||
* | ||
* This is intended to be used with a `childPath`, but if no `childPath` is provided | ||
* then this is functionally equivalent to Immutable's `getIn()` function or `deepMap()`. | ||
* | ||
* @param {NodePath} nodePath A `NodePath` used to identify the node to return. | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
* @param [notSetValue=null] A value to return when there is no node corresponding to `nodePath`, or if the node doesn't have any children. | ||
* @param {*} [notSetValue=null] A value to return when there is no node corresponding to `nodePath`, or if the node doesn't have any children. | ||
* @return {InputFunction} A partially applied function which accepts a single tree `Iterable`. `InputFunction` will return the children of the node at the specified `nodePath`, or if no node or children exist then `notSetValue` will be returned | ||
@@ -43,0 +45,0 @@ */ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.deepMapParents = exports.deepMapLeaves = exports.deepMap = exports.deepSetChildren = exports.deepSet = exports.deepGetChildren = exports.deepGet = undefined; | ||
exports.deepMapParents = exports.deepMapLeaves = exports.deepMap = exports.deepDeleteChildren = exports.deepDelete = exports.deepSetChildren = exports.deepSet = exports.deepUpdateChildren = exports.deepUpdate = exports.deepGetChildren = exports.deepGet = undefined; | ||
@@ -24,2 +24,17 @@ var _get = require('./get'); | ||
var _update = require('./update'); | ||
Object.defineProperty(exports, 'deepUpdate', { | ||
enumerable: true, | ||
get: function get() { | ||
return _update.deepUpdate; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'deepUpdateChildren', { | ||
enumerable: true, | ||
get: function get() { | ||
return _update.deepUpdateChildren; | ||
} | ||
}); | ||
var _set = require('./set'); | ||
@@ -40,2 +55,17 @@ | ||
var _delete = require('./delete'); | ||
Object.defineProperty(exports, 'deepDelete', { | ||
enumerable: true, | ||
get: function get() { | ||
return _delete.deepDelete; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'deepDeleteChildren', { | ||
enumerable: true, | ||
get: function get() { | ||
return _delete.deepDeleteChildren; | ||
} | ||
}); | ||
var _map = require('./map'); | ||
@@ -42,0 +72,0 @@ |
@@ -26,3 +26,3 @@ 'use strict'; | ||
* @param {NodePath} nodePath A NodePath used to uniquely identify the node to set. | ||
* @param value The value to set the node to. | ||
* @param {*} value The value to set the node to. | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
@@ -32,3 +32,5 @@ * @return {InputFunction} A partially applied function which accepts a single tree `Iterable`, and returns the modified tree `Iterable`. | ||
function deepSet(nodePath, value, childPath) { | ||
function deepSet(nodePath, value) { | ||
var childPath = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; | ||
return function (tree) { | ||
@@ -45,3 +47,3 @@ return tree.setIn((0, _utils.nodePathToKeys)(nodePath, childPath), value); | ||
* @param {NodePath} nodePath A `NodePath` used to uniquely identify a node whose children will be set. | ||
* @param value The value to set the node to. | ||
* @param {*} value The value to set the node to. | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
@@ -51,3 +53,5 @@ * @return {InputFunction} A partially applied function which accepts a single tree `Iterable`, and returns the modified tree `Iterable`. | ||
function deepSetChildren(nodePath, value, childPath) { | ||
function deepSetChildren(nodePath, value) { | ||
var childPath = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; | ||
return function (tree) { | ||
@@ -54,0 +58,0 @@ return tree.setIn((0, _utils.nodePathToKeysChildren)(nodePath, childPath), value); |
{ | ||
"name": "immutable-recursive", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Extra functions for use with Immutable.js to better handle tree structures / nested data and recursive iteration", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -8,41 +8,45 @@ # immutable-recursive | ||
Completely pre-alpha at this point, won't be long until this is ready for public. Hold on to your hats, anything could change in the near future. | ||
## Warning | ||
[Github](https://github.com/dxinteractive/immutable-recursive/) | [Preliminary documentation](https://dxinteractive.github.io/immutable-recursive/) | ||
While I anticipate this library will be very stable once release, it is completely in development / pre-alpha at this point. | ||
Won't be long until this is ready for public though. Hold on to your hats, anything could change in the near future. | ||
* [Github](https://github.com/dxinteractive/immutable-recursive/) | ||
* [Preliminary documentation](https://dxinteractive.github.io/immutable-recursive/) | ||
## Development tasks | ||
| Function | Plan | Write | Tests | Document | Examples | | ||
| -------- | ---- | ----- | ----- | -------- | -------- | | ||
| deepGet | Done | Done | Done | Done | | | ||
| deepGetChildren | Done | Done | Done | Done | | | ||
| deepSet | Done | Done | | | | | ||
| deepSetChildren | Done | Done | | | | | ||
| deepUpdate | | | | | | | ||
| deepUpdateChildren | | | | | | | ||
| deepDelete | Done | | | | | | ||
| deepDeleteChildren | Done | | | | | | ||
| deepDeleteCollapse | In progress | | | | | | ||
| deepMap | Done | Done | | In progress | | | ||
| deepMapLeaves | Done | Done | | In progress | | | ||
| deepMapParents | Done | Done | | In progress | | | ||
| deepMapOutward | In progress | | | | | | ||
| deepMapParentsOutward | In progress | | | | | | ||
| deepReduce | In progress | | | | | | ||
| deepFilter | In progress | | | | | | ||
| deepFilterCollapse | In progress | | | | | | ||
| deepSortBy | Done | In progress | | | | | ||
| deconstruct | Done | In progress | | | | | ||
| reconstruct | In progress | | | | | | ||
| flatCollapse | | | | | | | ||
| flatPrune | | | | | | | ||
| asList | Done | Done | Done | Done | Done | | ||
| nodePathToKeys | Done | Done | Done | Done | Done | | ||
| nodePathToKeysChildren | Done | Done | Done | Done | Done | | ||
| isLeaf | Done | Done | Done | Done | Done | | ||
| isSiblingOf | Done | | | | | | ||
| isParentOf | Done | | | | | | ||
| isAncestorOf | Done | | | | | | ||
| commonAncestor | | | | | | | ||
| Function | Plan | Write | Tests | Document | Examples | | ||
| -------- | ---- | ----- | ----- | -------- | -------- | | ||
| deepGet | Done | Done | Done | Done | | | ||
| deepGetChildren | Done | Done | Done | Done | | | ||
| deepSet | Done | Done | Done | Done | | | ||
| deepSetChildren | Done | Done | Done | Done | | | ||
| deepUpdate | Done | Done | Done | Done | | | ||
| deepUpdateChildren | Done | Done | Done | Done | | | ||
| deepDelete | Done | Done | Done | Done | | | ||
| deepDeleteChildren | Done | Done | Done | Done | | | ||
| deepDeleteCollapse | In progress | | | | | | ||
| deepMap | Done | Done | In progress | In progress | | | ||
| deepMapLeaves | Done | Done | In progress | In progress | | | ||
| deepMapParents | Done | Done | In progress | In progress | | | ||
| deepMapOutward | In progress | | | | | | ||
| deepMapParentsOutward | In progress | | | | | | ||
| deepReduce | In progress | | | | | | ||
| deepFilter | In progress | | | | | | ||
| deepFilterCollapse | In progress | | | | | | ||
| deepSortBy | Done | In progress | | | | | ||
| deconstruct | Done | In progress | | | | | ||
| reconstruct | In progress | | | | | | ||
| flatCollapse | | | | | | | ||
| flatPrune | | | | | | | ||
| asList | Done | Done | Done | Done | Done | | ||
| nodePathToKeys | Done | Done | Done | Done | Done | | ||
| nodePathToKeysChildren | Done | Done | Done | Done | Done | | ||
| isLeaf | Done | Done | Done | Done | Done | | ||
| isSiblingOf | Done | | | | | | ||
| isParentOf | Done | | | | | | ||
| isAncestorOf | Done | | | | | | ||
| getCommonAncestor | | | | | | | ||
| Typedef | Plan | Document | Examples | ||
@@ -59,6 +63,8 @@ | ------- | ---- | -------- | -------- | | ||
- Reconsider paramaters passed to mappers / updaters etc. and which children, parents or ancestors should be accessible | ||
- Test mapper iteration order | ||
- Test mapper / filter / reducer argument lists | ||
- Try adding @externals for JS and Immutable, try grouping under different modules | ||
- Allow functions to be passsed into ChildPath and modify all affected library functions so they can use it | ||
- Add a 'thinking in trees and nodes' style intro | ||
- Add documentation about deep data manipulation pitfalls, avoiding killing children | ||
- Add documentation about deep data manipulation pitfalls, avoiding killing children, limitation of child-collection-less nodes | ||
- Add build process with Travis | ||
@@ -65,0 +71,0 @@ - Add coverage reporting and build failing |
@@ -11,3 +11,3 @@ import { | ||
/** | ||
* Returns a specific node from the tree. | ||
* Once fully applied, this returns a specific node from the tree. | ||
* When no `childPath` is provided then this is functionally equivalent to Immutable's `getIn()` function. | ||
@@ -17,3 +17,3 @@ * | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
* @param [notSetValue=null] A value to return when there is no node corresponding to `nodePath`. | ||
* @param {*} [notSetValue=null] A value to return when there is no node corresponding to `nodePath`. | ||
* @return {InputFunction} A partially applied function which accepts a single tree `Iterable`. `InputFunction` will return the node at the specified `nodePath`, or if no node exists then `notSetValue` will be returned. | ||
@@ -27,8 +27,10 @@ */ | ||
/** | ||
* Returns the children of a specific node from the tree. | ||
* When no `childPat`h is provided then this is functionally equivalent to Immutable's `getIn()` function or `deepMap()`. | ||
* Once fully applied, this returns the children of a specific node from the tree. | ||
* | ||
* This is intended to be used with a `childPath`, but if no `childPath` is provided | ||
* then this is functionally equivalent to Immutable's `getIn()` function or `deepMap()`. | ||
* | ||
* @param {NodePath} nodePath A `NodePath` used to identify the node to return. | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
* @param [notSetValue=null] A value to return when there is no node corresponding to `nodePath`, or if the node doesn't have any children. | ||
* @param {*} [notSetValue=null] A value to return when there is no node corresponding to `nodePath`, or if the node doesn't have any children. | ||
* @return {InputFunction} A partially applied function which accepts a single tree `Iterable`. `InputFunction` will return the children of the node at the specified `nodePath`, or if no node or children exist then `notSetValue` will be returned | ||
@@ -35,0 +37,0 @@ */ |
@@ -145,3 +145,3 @@ | ||
* @callback Mapper | ||
* @param {*} value The value of the current node. | ||
* @param {*} value The value to map. | ||
* @param {List} nodePath The current node's `NodePath`, a `List` of keys used to uniquely identify the current node. | ||
@@ -152,2 +152,11 @@ * @param {List} children A `List` of the current node's children. | ||
/** | ||
* A function required as an argument for the `deepUpdate` functions. | ||
* | ||
* @callback Updater | ||
* @param {*} value The value to update. | ||
* @return {*} The replacement value. | ||
*/ | ||
export { | ||
@@ -159,2 +168,7 @@ deepGet, | ||
export { | ||
deepUpdate, | ||
deepUpdateChildren | ||
} from './update'; | ||
export { | ||
deepSet, | ||
@@ -165,2 +179,7 @@ deepSetChildren | ||
export { | ||
deepDelete, | ||
deepDeleteChildren | ||
} from './delete'; | ||
export { | ||
deepMap, | ||
@@ -167,0 +186,0 @@ deepMapLeaves, |
@@ -22,3 +22,3 @@ import { | ||
* @param {NodePath} nodePath A NodePath used to uniquely identify the node to set. | ||
* @param value The value to set the node to. | ||
* @param {*} value The value to set the node to. | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
@@ -28,3 +28,3 @@ * @return {InputFunction} A partially applied function which accepts a single tree `Iterable`, and returns the modified tree `Iterable`. | ||
function deepSet(nodePath, value, childPath) { | ||
function deepSet(nodePath, value, childPath=null) { | ||
return (tree) => tree.setIn(nodePathToKeys(nodePath, childPath), value); | ||
@@ -39,3 +39,3 @@ } | ||
* @param {NodePath} nodePath A `NodePath` used to uniquely identify a node whose children will be set. | ||
* @param value The value to set the node to. | ||
* @param {*} value The value to set the node to. | ||
* @param {ChildPath} [childPath=null] An `Array` or `List` of keys indicating where to find each node's children from within each node. | ||
@@ -45,3 +45,3 @@ * @return {InputFunction} A partially applied function which accepts a single tree `Iterable`, and returns the modified tree `Iterable`. | ||
function deepSetChildren(nodePath, value, childPath) { | ||
function deepSetChildren(nodePath, value, childPath=null) { | ||
return (tree) => tree.setIn(nodePathToKeysChildren(nodePath, childPath), value); | ||
@@ -48,0 +48,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
272800
58
2853
71