shape-array

1.0.11 • Public • Published

Build Status

Install

Using npm:

npm install shape-array

Usage

Shape array to a json object:

'use strict';
const shape = require('shape-array');
const personify = shape.scheme(['id', 'name', 'address.street', 'address.zip']);
 
let data = [1, 'John', 'github', '1234'];
let person = personify(data);
//person equals:
{
  id: 1,
  name: 'John',
  address: {
    street: 'github',
    zip: '1234'
  }
}

Reverse json to array:

const reverse = shape.reverse(['id', 'name', 'address.street', 'address.zip']);
 
let json = {
  id: 1,
  name: 'John',
  address: {
    street: 'github',
    zip: '1234'
  }
};
let array = reverse(json);
//array equals:
[1, 'John', 'github', '1234']

Related

License

MIT © Andre Stehle

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.118latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.118
1.0.101
1.0.90
1.0.81
1.0.71
1.0.61
1.0.51
1.0.40
1.0.31
1.0.20
1.0.10
1.0.00
0.0.60
0.0.50
0.0.40
0.0.30
0.0.10

Package Sidebar

Install

npm i shape-array

Weekly Downloads

14

Version

1.0.11

License

MIT

Last publish

Collaborators

  • ansteh