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

fatten

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fatten

restructures flat objects with dot-notation-like keys into optimised nested objects

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Transform dot-notation-like objects into optimised nested objects

npm package Build Status Downloads Issues Code Coverage

// Fatten turns flat objects
const 😡 = { id: 5, user_id: 14, user_name: 'Jane', payment_provider: 'stripe' };

// Into optimised nested objects
const 😍 = { id: 5, user: { id: 14, name: 'Jane' }, paymentProvider: 'stripe' };

// By doing this
const 🤯 = fatten(😡, { separator: '_' });

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

npm install fatten
yarn add fatten

Usage

import { fatten } from 'fatten';

const options = {
  separator: '-',
  leafKey: 'value'
};
const nestedObject = fatten(flatObject, options);

Options (optional)

separator (default: '.')

The character used to split the keys of the flat object.

leafKey (default: '_')

The key that represents a node with a value inside a deeper path.

Example:

const result = fatten({
  id: 5,
  'id.version': '2',
  type: 'mailable'
})

// is the same as
const result = {
  id: {
    _: 5,
    version: '2'
  },
  type: 'mailable'
}

Changelog

Please see releases for more information what has changed recently.

Testing

npm run test

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Keywords

FAQs

Package last updated on 02 Aug 2023

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