Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reggi/lodash-recursive
:repeat: Recursive versions of lodash functions
https://github.com/reggi/lodash-recursive
Last synced: about 1 month ago
JSON representation
:repeat: Recursive versions of lodash functions
- Host: GitHub
- URL: https://github.com/reggi/lodash-recursive
- Owner: reggi
- Created: 2015-09-25T02:44:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-25T02:47:38.000Z (about 9 years ago)
- Last Synced: 2024-10-05T10:48:30.402Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lodash recursive
## map recursive
```js
var assert = require('assert')
var recursive = require('lodash-recursive')var nodes = [
{
value: 'alpha',
children: [
{
value: 'beta'
}
]
},
{
value: 'gamma'
}
]var newNodes = recursive.map(nodes, function (node, recursive, map) {
if (node.children) recursive(node.children)
return map(node)
}, function (node) {
if (node.value == 'beta') node.valid = true
return node
})var expected = [
{
"value": "alpha",
"children": [
{
"value": "beta",
"valid": true
}
]
},
{
"value": "gamma"
}
]assert.deepEqual(expected, newNodes)
```