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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nn-deep-read-write

v1.0.1

Published

Read and write values deep within an object or array.

Readme

nn-deep-read-write

Read, write, and remove values deep within an object or array.

Reading, Writing, and Removing Values

Reading Values

Reads a value nested deep inside an object. Returns the default value if no value is found.

readValue( data, selector, defaultValue, reader )
  • data: object | array - Container.
  • selector: string - Indicates where to read the value. See Selectors
  • defaultValue: any (Optional) - The default value.
  • reader: Getter( container, identifier ) (Optional) - A getter function for special identifiers. See Special Identifier & Getter for more information.

Getter function

  • container: object | array - Container.
  • identifier: string - This is the special identifier.

Writing Values

Writes a value deep inside an object. Returns true if successful.

writeValue( data, selector, value )
  • data: object | array - Container.
  • selector: string - Indicates where to write the value. See Selectors
  • value: any - The value to write.

Removing Values

Removes a value deep inside an object. Returns true if successful.

removeValue( data, selector )
  • data: object | array - Container.
  • selector: string - Indicates what value to remove. See Selectors

Container

A container is considered any object or array.

Selectors

A selector is a path to a value inside a container and is written as 1 or more identifiers separated by . character. Use a selector to indicate where to read, write, or remove a value. Characters in an identifier can also be encoded. See Encoding And Decoding and Special Identifier & Getter for more information.

Encoding And Decoding

An identifier may need to contain a . or other special characters that are not allowed in the identifier. Identifiers can be escaped using | character and the character code of the character being escaped. For example: some.identifier can be written as some|46|identifier. Text can be encoded or decoded using the functions dotDecode and dotEncode.

dotEncode( 'some.selector' ) // Returns 'some|46|selector'
dotDecode( 'some|46|selector' ) // Returns 'some.selector'

Special Identifier & Getter

A special identifier is an identifier that starts with a # character. Special identifiers can only be used for reading data. To use a special identifier, provide a getter function to the readValue function. The getter function will receive a container object and identifier. For example: the selector a.#key, the identifier #key is a special identifier.

readValue( container, 'a.#key', defaultValue, function ( container, identifier )
{
	// identifier is '#key'

	// Do some logic...

	return 'some value';
} )