npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

obj-traverse-lite

v1.0.4

Published

Small and lightweight library that enables you to traverse deep nested objects and edit them

Downloads

13

Readme

obj-traverse

Small and lightweight library that enables you to traverse deep nested objects and edit them

Getting Started

  1. Run npm i obj-traverse --save
  2. Import library: a) var objTraverse = require('obj-traverse/lib/obj-traverse'); (look at 3a) b) ES6: import * as objTraverse from 'obj-traverse/lib/obj-traverse'; (look at 3a) c) ES6: import { findAll } from 'obj-traverse/lib/obj-traverse'; (look at 3b)
  3. Use it: a) objTraverse.findAll(...) b) findAll(...)

Demo

You can visit http://dominik791.github.io/obj-traverse-demo and play with the library

API

  1. findFirst(tree, childrenKey, objToFindBy)

    It iterates through each deep nested object and if finds object that has prop and value specified in objToFindBy argument, it stops the walk and returns reference to this object. If none is found, it returns false.

    findFirst

    Please note that the method checks all children on current level and then it deepens to the next level - grandchildren.

  2. findAll(tree, childrenKey, objToFindBy)

    It iterates through each deep nested object and for every found object that has prop and value specified in objToFindBy argument, it pushes reference of this object to the result array. When it finishes the walk, it returns the array. If none is found, it returns false.

    findAll

  3. findAndModifyFirst(tree, childrenKey, objToFindBy, replacementObj)

    It iterates through each deep nested object and if finds object that has prop and value specified in objToFindBy argument, it replaces the current object with replacementObj, stops recursive walk and returns reference to the root object. If none is found, it returns false.

    findAndModifyFirst

    Please note that the method checks all children on current level and then it deepens to the next level - grandchildren.

  4. findAndModifyAll(tree, childrenKey, objToFindBy, replacementObj)

    It iterates through each deep nested object and for every found object that has prop and value specified in objToFindBy argument, it replaces the current object with replacementObj and returns reference to the root object. If none is found, it returns false.

    findAndModifyAll

  5. findAndDeleteFirst(tree, childrenKey, objToFindBy)

    It iterates through each deep nested object and if finds object that has prop and value specified in objToFindBy argument, it deletes it, stops the walk and returns reference to the root object. If none is found, it returns false.

    findAndDeleteFirst

    Please note that the method checks all children on current level and then it deepens to the next level - grandchildren.

  6. findAndDeleteAll(tree, childrenKey, objToFindBy)

    It iterates through each deep nested object and if finds object that has prop and value specified in objToFindBy argument, it deletes it, continue the walk and returns reference to the root object once finished. If none of objects is found, it returns false.

    findAndDeleteAll

Licence

MIT

Author

  • Dominik Broj