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

jsonutil

v0.2.0

Published

Convenience functions for working with JSON

Downloads

87

Readme

jsonutil - Convenience functions for working with JSON

Working with JSON in Node.js is pretty straightforward, but there are a couple of things that could be a bit more convenient. Examples are copying objects, as well as reading them from, and writing them to, files. The jsonutil package addresses just those scenarios with a few handy utility functions.

Installation

Just use npm:

npm install jsonutil

Copying JSON objects

deepCopy(obj)

Makes a deep copy (a.k.a. clone) of the supplied object. This function reliably copies only what is valid for a JSON object, array, or other element.

Arguments

  • obj, the object of which a copy is to be made.

shallowCopy(obj)

Makes a shallow (i.e. top level only) copy of the supplied object. This function reliably copies only what is valid for a JSON object, array, or other element.

Arguments

  • obj, the object of which a copy is to be made.

copy(obj, shallow)

Makes a copy of the supplied object, either shallow or deep, according to the second argument. This function reliably copies only what is valid for a JSON object, array, or other element.

Arguments

  • obj, the object of which a copy is to be made.
  • shallow, a boolean indicating whether the copy should be shallow or deep.

Working with JSON files

readFile(file, cb)

Reads a JSON file and parses it, calling the callback with the resulting object.

Arguments

  • file, the file from which to read and parse JSON.
  • cb(err, obj), a callback function that will be called with either the object read from the file, or an error.

readFileSync(file)

A synchronous version of readFile (see above) that returns the parsed object or throws an error.

writeFile(file, obj, [indent], cb)

Writes a JSON file with the specified data. Serializing the data will fail if the data contains a cyclic structure.

  • file, the file to which the object will be written.
  • obj, the object to be written as JSON.
  • indent, the indentation level, in spaces, of the JSON output. [Default: no indentation]
  • cb(err), a callback function that will be called with either null on success, or an error.

writeFileSync(file, data, [indent])

A synchronous version of writeFile (see above) that throws any error.

License

jsonutil is licensed under the MIT License.