Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Iterate all properties of object or array

NotificationsYou must be signed in to change notification settings

darekf77/lodash-walk-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This library let you go deep through allproperties in your javascript object withnice possibility to change theirs valueswithout confusion.

WALK OBJECT

walk.Object( myJSObject, iteratorFunction )

walk.ObjectBy( myObjectPropert, contextObject , iteratorFunction )

There are both similar... the difference isthat, with second function you main objectis also included in iteration and can be changed.

Example

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: {}}*/

About

Iterate all properties of object or array

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp