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

filejson

v1.0.15

Published

Seamlessly syncs a JavaScript value to a JSON file in the background whenever that value changes.

Downloads

27

Readme

filejson

NPM

Seamlessly sync a JavaScript value to a JSON encoded file automatically in the background whenever that value changes. A value can be a Javascript: string, number, boolean, null, object, or an array. The value can be structured in an array or an object to allow for more complex data stores. These structures can also be nested. As a result, you can use this module as a simple document store for storing semi structured data.

Requirements

ECMAScript 6 Reflect and Proxy objects support, which is found natively in Node.js >= 6. If you are using a version of Node.js < 6, use a polyfill, such as harmony-reflect. Proxy support is key for this module working so eloquently. Other non-Proxy based modules require function calls each time you wish to save an object. Unlike those, filejson is as easy as file.contents = "my new value" or file.contents = {"msg": "Hello World"} and the changes are automatically saved to disk.

Installation

npm install filejson --save

If you are using Node.js 5 or earlier, some additional installation and usage steps are needed. Click here.

Example usage

var Filejson = require("filejson");
var file1 = new Filejson();

file1.load("file1.json", proceed); // file1.json contains {"abc": "123"}

function proceed(error, file) {
    if(error) {
        console.error(error);
        return;
    }

    console.log(file.contents); // outputs {"abc": "123"}

    file.contents.msg = "Hello World"; // saves {"abc": "123", "msg": "Hello World"} to file1.json.

    console.log(file.contents); // outputs {"abc": "123", "msg": "Hello World"}

}

Additional installation and usage steps for those using Node.js 5 or earlier

npm install harmony-reflect --save
  • In addition to requiring filejson, you will need to require harmony-reflect at the top of your app, like this:
var Reflect = require('harmony-reflect');
  • Lastly, every time you run your app you will need to use the node --harmony_proxies flag, like this:
node --harmony_proxies index.js