JSPM

obj-from-arr

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q14803F
  • License MIT

Convert an array to an object based on the return value of an iteratee.

Package Exports

  • obj-from-arr

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (obj-from-arr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Create object from array Travis CI Build Status

Convert an array to an object based on the return value of an iteratee.

NPM Badge

Install

npm install obj-from-arr

Usage

const objFromArr = require("obj-from-arr");

objFromArr(["a", "b", "c"], val => {
    // Handle array here. I'm going to use some simple handling logic as an example.
    if (val === "a") return 1;
    if (val === "b") return 2;
    if (val === "c") return 3;
});
//=> { "a": 1, "b": 2, "c": 3 }

API

objFromArr(array, iteratee)

arr

Type: array

The array to convert.

iteratee

Type: function<Array.map>

The iteratee to use when iterating through the array.