Noncollinear Perpendicular Microcrystalline
Miss any of our Open RFC calls?Watch the recordings here! »

flatten2

1.1.0 • Public • Published

flatten2

Recursively flatten JavaScript objects.

Zero dependencies.

Installation

# NPM
npm install flatten2 --save

# Yarn
yarn add flatten2

Example Input/Output

Input

{
    "team": {
        "name": "patriots",
        "coach": "bill belichick",
        "players": {
            "quarterback": "tom brady"
        }
    }
}

Output

{
    "team/name": "patriots",
    "team/coach": "bill belichick",
    "team/players/quarterback": "tom brady"
}

Getting started

Flatten a single object

import { flatten } from 'flatten2';
 
var myObject = {...}
 
var myFlattenedObject = flatten(myObject);

Flatten each object within an Array

import { flattenMany } from 'flatten2';
 
var myArrayOfObjects = [
    {...},
    {...},
    {...}
];
 
var myArrayOfFlattenedObjects = flattenMany(myArrayOfObjects);

API Reference

Coming soon..

Contributing

Coming soon..

License

MIT License Copyright (c) 2018 Joel Colucci

Install

npm i flatten2

DownloadsWeekly Downloads

4

Version

1.1.0

License

MIT

Unpacked Size

133 kB

Total Files

11

Last publish

Collaborators

  • avatar