New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flattn

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flattn

Flattens javascript objects nicely, in an entirely type-aware way.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

flattn

Travis

There are lots of flattening libraries out there, but I decided to write my own because I wanted to write my own :)

Mainly, I wanted to write it in the latest ES6 that nodejs 6.x gives us, with beautiful things like default params!

If you use this in a frontend project, make sure it gets transpiled!

Getting started

npm install flattn

Then, in your JS file:

const flattn = require('flattn');

const myCrazyDeepObject = {
  nested: {
    stuff: 'here'
  }
};

flattn(myCrazyDeepObject); // outputs a beautifully flat object

Options

flattn(object, {}) takes a couple optional params:

  • crush (array) - this will remove a nesting namespace from the final product (ie. if you crush [ 'metadata' ], then { metadata: { hello: 'world' }} will return { hello: 'world' })
  • stringifyNull (boolean) - this will turn nulls into ''
  • separator (string) - by default, this lib uses an underscore. But, if you want something else...
  • pruneFunctions (boolean) - if the value of a key is a function, then you can opt to not have those in the result

Keywords

FAQs

Package last updated on 01 Sep 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc