Socket
Book a DemoInstallSign in
Socket

object-map-to-array

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-map-to-array

Map an object to an array

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

object-map-to-array

Build Status

Map an object to an array.

Usage

var assert = require('assert');
var objMapToArr = require('object-map-to-array');

var o1 = {
  a: 1,
  b: -1,
  c: 0,
  d: 42
};

objMapToArr(o1, function (n) {
  return { id: k, value: n };
}); /* => `[
  [ id: 'a', value: 1 ],
  [ id: 'b', value: -1 ],
  [ id: 'c', value: 0 ],
  [ id: 'd', value: 42 ]
]` */

API

objMapToArr(obj, iterator, this)

  • obj (object) - object to map on
  • iterator (function, required) - iterator function
  • this (optional) - this for iterator

Creates a new array with all the items returned by iterator.

Keywords

object

FAQs

Package last updated on 29 Nov 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts