q-flat
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published


Q-Flat
API Stability TypeScript Styled with prettier Build status Test Coverage NPM Version Downloads Browser Bundle Size

Flatten a nested object using query string syntax.

Installation

Npm

npm install q-flat

API

qflat.flatten(obj: any): any

  • Converts a nested object into a shallow one with keys using query string syntax.
import { flatten } from 'q-flat';
 
// Flatten nested objects.
flatten({ a: { b: { c: { 1 } } }); // -> { "a[b][c]": 1 }
 
// Even flatten arrays.
flatten({ a: [{ b: 1 }, { c: 2 }] }); // -> { 'a[0][b]': 1, 'a[1][c]': 2 }

Contributions

  • Use npm test to build and run tests.

Please feel free to create a PR!

Package Sidebar

Install

npm i q-flat

Weekly Downloads

3,776

Version

1.0.7

License

MIT

Unpacked Size

6.57 kB

Total Files

5

Last publish

Collaborators

  • dylanpiercey