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

@depax/data

v1.0.6

Published

Provides an Async/Promise Data object.

Downloads

22

Readme

Data

CircleCI

Installation

Install the package normally using NPM or Yarn.

# Npm
npm i @depax/data

# Yarn
yarn add @depax/data

Usage

import Data from "@depax/data";

const myData = new Data({
    value1: "hello",
    value2: { value3: "world" }
});

// "hello"
console.info(myData.get("value1"));

// "world"
console.info(myData.get("value2.value3"));

// null
console.info(myData.get("value3"));

// "hello world"
console.info(myData.get("value3", "hello world"));

The Data class provides get, set, del and has methods to get, set, delete and check for properties.

import Data from "@depax/data";

// Create the Data object, and use '.' for the deliminator.
const myData = new Data({}, ".");

// false
myData.has("value1");

// null
myData.get("value1");
myData.set("value1", "hello world");

// true
myData.has("value1");

// "hello world"
myData.get("value1");
myData.del("value1");

// false
myData.has("value1");

// null
myData.get("value1");

// false
myData.has("value2.something");
myData.set("value2.something", "foo");

// { "something": "foo" }
myData.get("value2");

Setting the data using the Data object also updates the provided data object, for example:

import Data from "@depax/data";

const data = {};
const myData = new Data(data);

myData.set("value1.value2", "hello world");

// { "value1": { "value2": "hello world" } }
console.dir(data);

Finally, you can also create references from a larger data object, which will kepp each other updated:

import Data from "@depax/data";

const data = {
    "settings": {
        "module1": {
            "value1": "hello world"
        },
        "module2": {
            "value1": "foo bar"
        }
    }
};
const myData = new Data(data);

let ref1 = myData.ref("settings.module1");
let ref2 = myData.ref("settings.module2");

// "hello world"
console.info(myData.get("settings.module1.value1"));
console.info(ref1.get("value1"));

// "foo bar"
console.info(myData.get("settings.module2.value1"));
console.info(ref2.get("value1"));

ref1.set("value1", "foo bar");

// "foo bar"
console.info(myData.get("settings.module1.value1"));
console.info(ref1.get("value1"));

// "foo bar"
console.info(myData.get("settings.module2.value1"));
console.info(ref2.get("value1"));

// {"settings": {"module1": {"value1": "foo bar"}}, "module2": {"value1": "foo bar"}}}
console.dir(data);

Config: Loading and saving

There is also a Config class which provides a means to load and save the data to a JSON or YAML file.

Note: Comments are supported in the JSON file, however they will not be restored when the config file is saved again.

import { Config } from "@depax/data";

const data = new Config("path/to/config-file.json");
// or, for YAML;
// const data = new Config("path/to/config-file.yaml");

await config.load();

config.set("value1", "hello");
await config.save();