atoo

1.0.1 • Public • Published

atoo

array to object | Convert any array to object with/without given key-prefix.

arrayToObject([1, 2, 3, 'a',,,, 'b'], 'i-')
Object {i-0: 1, i-1: 2, i-2: 3, i-3: "a", i-7: "b"}

arrayToObject([1, 2, 3, 'a',,,, 'b'])
Object {0: 1, 1: 2, 2: 3, 3: "a", 7: "b"}

Note: Takes care of sparse arrays too.

How to use.

var a = require('atoo');
var obj = a.arrayToObject(array [, keyPrefix]);

license

MIT @copy; Anubhav Saini 2016

Package Sidebar

Install

npm i atoo

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • git.faf
  • anusaini
  • iamanubhavsaini