Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)
```