New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

flatten-object

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatten-object

Flatten a nested object

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

build status

flatten-object

Flattens nested javascript objects into a single level. Enumerates keys that collide.

Usage

npm install flatten-object

> var flattenObject = require('flatten-object');
> var nested  = {foo: 'bar', baz: {foo: 'bar'}};
> flattenObject(nested):
{
    foo_0: 'bar',
    foo_1: 'bar'
};
> var flattenObject = require('flatten-object');
> var nested  = {foo: 'bar', baz: {foo: 'bar'}};
> flattenObject(nested, 0, '-'):
{
    foo-0: 'bar',
    foo-1: 'bar'
};

API

flattenObject(object, maxDepth, separator)

/**
 * Flatten an object down to a optionally specified maximum depth
 * @method  exports
 * @param   {object} obj Object to flatten
 * @param   {integer} [maxDepth=0] Maximum depth to recurse to. Zero is unlimited.
 * @param   {string}  [sep=_] Separator for keys. If you use this, you must specify maxDepth. It's just how javascript is
 * @returns {object} flattened object
 */

License

MIT license, Copyright © 2015 Todd Kennedy

Keywords

flatten

FAQs

Package last updated on 25 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts