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

yadeep

v1.0.8

Published

Yet another deep JSON getter and setter

Downloads

6

Readme

yadeep

Build Status version dependencies devDependencies

Yet another deep JSON getter/setter module

Why?

Several libraries already exist for getting and setting fields in deep JSON objects. However, none had the flexibility we needed for building an enterprise-quality ETL solution.

A key differentiator is that yadeep builds on top of terrain-keypath. This means:

  • We can work with any field name in a JSON document. Do you have field names like '*', '.', etc.? yadeep has you covered. Most libraries sacrifice this generality to use characters like those as waypoint delimiters, wildcards, etc.
  • We can get and set on wildcard keypaths. Do you want to increment the values of all children of an object? Or are you writing some aggregation function on deeply-nested sub-documents? yadeep will help.
  • We can also handle some level of nested wildcards. Keypath expressions with multiple wildcard tokens will try to behave in a semantically intuitive way (though expressions with more than two wildcard tokens are quite exotic in the real world and hence not well-tested).

yadeep also aims to provide the simplest syntax it can while still supporting this level of generality. If you accept our keypath conventions, you can immediately use yadeep.get(object, keypath) and yadeep.set(object, keypath, value); the aim is to make the API human readable and somewhat self-documenting.

Additional functions for searching in and traversing deep JSON objects can be found in the code.

TypeScript definitions included!

Installation

npm install yadeep

Basic Usage

const { KeyPath } = require('terrain-keypath');
const yadeep = require('yadeep');

const doc = {
  name: 'Bob',
  hardarr: [['a'], ['b', [{count: 1}, {count: 2}]]]
};

yadeep.get(doc, KeyPath(['hardarr', '1', '0'])); // 'b'
yadeep.get(doc, KeyPath(['hardarr', '1', '1', -1, 'count'])); // [1, 2]

yadeep.set(doc, KeyPath(['hardarr', '0', '0']), 'not a'); // changes 'a' -> 'not a'
yadeep.set(doc, KeyPath(['hardarr', '1', '1', -1, 'count']), 17); // changes both 'counts's to 17

See yadeepTests.ts for a battery of additional tests and usages.