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 🙏

© 2026 – Pkg Stats / Ryan Hefner

storage.json

v1.2.6

Published

NPM package providing simplified create, read, update, and delete methods for JSON files. Also provides methods which simplify using JSON files to store configuration data.

Readme

storage.json

NPM package providing simplified create, read, update, and delete methods for JSON files. Also provides methods which simplify using JSON files to store configuration data.


Installation:

Install:

npm install storage.json 

Require:

var storage = require('storage.json' );

File Names and Paths:

Storage.json accepts simplified path names and assumes that the file extension will always be ".json". Because of this, finding the correct file can be done in several ways.

Name only

"filename"

Name with extension

"filename.json"
With property
"filename.property"

With deep property

"filename.deeply.nested.property"

With extension and property

"filename.json.property"

With complete path

"/path/to/filename"

With complete path and property

"/path/to/filename.property"

Note: If your property is "json", you MUST include the extension ( e.g. "/path/to/filename.json.json" )

Usage and Examples:

For the "Finding" and "Reading" examples, assume filename.json contains :

{ "property": "This is the value of 'property' from filename.json" }

Finding Files and Data


has()


Returns TRUE if the filename and/or property exists and has been assigned a value, otherwise returns FALSE

console.log( storage.has( 'filename' )); // TRUE
console.log( storage.has( 'filename.property' )); // TRUE
console.log( storage.has( 'missing_file' )); // FALSE
console.log( storage.has( 'filename.missing' )); // FALSE  

Reading Files and Data


get()


Returns the files contents or value if found, otherwise returns undefined

    // Read entire file
    var contents = storage.get( 'filename' );
    console.log( contents ); //{ property: "This is the value of 'property' from filename.json" }
    
    // Read property within file
    var contents = storage.get( 'filename.property' );
    console.log( contents ); //"This is the value of 'property' from filename.json"
    

Writing Files and Data


set()


Merges an Object into a file, OR assigns a value to the property specified

    // Returns a boolean value asserting that the file was changed.
    var set = storage.set( 'new_file', { property: "value" });
    console.log( set ) //TRUE
    var set = storage.set( 'new_file', { property: "value" });
    console.log( set ) //FALSE
    
    // Creates a new file if the file does not exist
    console.log( storage.exists( 'new_file' )); //FALSE
    storage.set( 'new_file', { property: "value" });
    console.log( storage.exists( 'new_file' )); //TRUE
    
    // It will not overwrite existing properties, unless specified
    console.log( storage.get( 'filename' ) //{ property: "value" };
    storage.set( 'filename', {});
    console.log( storage.get( 'filename' ) //{ property: "value" };
    
    // It will overwrite existing properties, when specified
    console.log( storage.get( 'filename' ) //{ property: "value" };
    
    storage.set( 'filename', { property: "new value" });
    // OR
    storage.set( 'filename.property', "new_value" );
    
    console.log( storage.get( 'filename' ) //{ property: "new_value" };
    

insist()


Ensures that the file exists and return the filename to simplify inline calls

var file = storage.insist( 'new_file' );
console.log( storage.get( file )) //{};

update()


Overwrites the contents of an EXISTING file, with a new Object.

// Returns a boolean value
// File Missing:
console.log( storage.get( 'filename' ) //undefined
var updated = storage.update( 'filename', { property: "value" });
console.log( updated ); //FALSE

// File Exists:
console.log( storage.get( 'filename' ) //{}
var updated = storage.update( 'filename', { property: "value" });
console.log( updated ); //TRUE

It will NOT create a new file if the file does not exist

console.log( storage.get( 'filename' ) //undefined
var updated = storage.update( 'filename', { property: "value" });
console.log( updated ); //FALSE
console.log( storage.get( 'filename' ) //undefined

Configuration FIles and Data


config()

Create configuration files to store values common within an application, which may need to be changed depending upon their usage.

Examples:

// The default settings Object
var defaults = { some_prop: true, some_prop_2: false };
// A dynamic settings Object
var argument = { some_prop: false };
    
var config = storage.config( "MyConfigurationFile", argument );
console.log( config ); //{ "some_prop": "false" }
console.log( storage.get( "MyConfigurationFile" )); //{ "some_prop": "false" }
    
var config = storage.config( "MyConfigurationFile", defaults );
console.log( config ); //{ "some_prop": "true", "some_prop_2": "false" }
console.log( storage.get( "MyConfigurationFile" )); //{ "some_prop": "true", "some_prop_2": "false" }
    

If passing in two Objects, the Objects will be merged, and any overlapping properties will be assigned the first Object's assigned value.

var config = storage.config( "MyConfigurationFile", argument, defaults );
console.log( config ); //{ "some_prop": "false", "some_prop_2": "false" }
console.log( storage.get( "MyConfigurationFile" )); //{ "some_prop": "false", "some_prop_2": "false" }