Skip to content

DylanPiercey/q-flat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

🍽 Flatten a nested object using query string syntax.

Resources

Stars

Watchers

Forks

Packages

No packages published