Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darekf77/lodash-walk-object
Iterate all properties of object or array
https://github.com/darekf77/lodash-walk-object
data-manipulation iterator-pattern
Last synced: about 2 months ago
JSON representation
Iterate all properties of object or array
- Host: GitHub
- URL: https://github.com/darekf77/lodash-walk-object
- Owner: darekf77
- Created: 2019-01-01T22:17:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-22T04:36:29.000Z (8 months ago)
- Last Synced: 2024-05-22T12:39:43.777Z (8 months ago)
- Topics: data-manipulation, iterator-pattern
- Language: TypeScript
- Homepage:
- Size: 6.03 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WALK ALL PROPERTIES DEEP IN OBJECT
This library let you go deep through all
properties in your javascript object with
nice possibility to change theirs values
without confusion.# WALK OBJECT
**walk.Object( myJSObject, iteratorFunction )**
**walk.ObjectBy( myObjectPropert, contextObject , iteratorFunction )**
There are both similar... the difference is
that, with second function you main object
is also included in iteration and can be changed.# Example
```ts
import { walk } from 'lodash-walk-object'
let = yourJSObject = {
isGood: true,
arr = [
{ insideObjectValue: 1 }
{ insideObjectValue: 1 }
],
testObject: {}
}walk.Object(yourJSObject, (value, lodashPath, changeValue) => {
if(lodashPath === 'arr[0].insideObjectValue') {
changeValue(2)
}
} )console.log(yourJSObject)
// RESULT
/*
{
isGood: true,
arr = [
{ insideObjectValue: 2 }
{ insideObjectValue: 1 }
],
testObject: {}
}
*/```