As

as

Convert easily, back and forth between array and object.

A sweet and simple util that help you to convert array to object and vise versa, it also:

  • Brings all functional goodness of arrays to objects.

  • Brings the flexibility of objects to arrays.

  • Works well with a functional programming library.

Get it: npm install --save as

Usage:

1
2
3
4
5
6
7
8
var asArray = require("as/array");

asArray(
  {a: 1, b: 2}
  );
// [ {key: "a", value: 1} 
// , {key: "b", value: 2} 
// ] 
1
2
3
4
5
6
var asObject = require("as/object");
asObject(
  [ {key: "a", value: 1}
  , {key: "b", value: 2}
  ]);
// {a: 1, b: 2} 

GIF FTW!

Thanks for

Suggest a module

Comments