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

object-flatten-unflatten

v1.0.4

Published

A simple utility for flattening and unflattening JavaScript objects. This package provides functions to convert deeply nested objects into flat objects with keys and vice versa.

Readme

flatten-unflatten

A simple utility for flattening and unflattening JavaScript objects. This package provides functions to convert deeply nested objects into flat objects with keys and vice versa.

Installation

To install the package, use npm or yarn:

install:

npm install flatten-unflatten\

flatten(object, options)

Flattens a nested object into a single-level object.

Arguments

object: The object to flatten (can be nested). options (optional): Configuration options (see below). Returns: A flattened object with dot-separated keys.

Available Options: delimiter (default: '.'): The delimiter to use between nested keys. For example, use '_' to flatten keys like user_name instead of user.name.

safe (default: false): If true, arrays will be flattened without modifying their structure. For example, ['a', 'b'] will become 0: 'a', 1: 'b' instead of 0.a: 'a', 0.b: 'b'.

overwrite (default: false): If true, existing keys in the flattened object will be overwritten if there are duplicate keys.

maxDepth (default: Infinity): Limits the depth of nested objects to flatten. Setting this to a number (e.g., 2) will only flatten objects up to the second level of nesting.

transformKey (default: (key) => key): A function that allows you to transform keys as they're being flattened. This can be useful for renaming or sanitizing keys.

unflatten(object, options)

Converts a flattened object back into a nested object.

Arguments

object: The flattened object (with dot-separated keys). options (optional): Configuration options (see below). Returns: The unflattened object with nested structures restored.

Available Options: delimiter (default: .): The delimiter used in the flattened object to separate keys.

safe (default: false): If true, the function will avoid merging arrays into objects.

transformKey (default: (key) => key): A function to transform keys as they are unflattened.

Default Options

If you don’t provide any options, the following default settings will be used:

const defaultOptions = {
  delimiter: '.',
  safe: false,
  overwrite: false,
  maxDepth: Infinity,
  transformKey: (key) => key,
};

Contributions

Feel free to submit issues, pull requests, or suggestions! All contributions are welcome.