Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-2-object

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-2-object

Returns a new object from a given array

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

array-2-object

CircleCI Codecov npm

Returns an object from a given array

Table of Contents

Install

Using npm

npm install --save array-2-object

Usage

Signature

array2object (array: Array, [options: Object], [callback: Function]): Object

Default options

{
  base: {},
  value: null
}
const array2object = require('array-2-object')

Examples given the following array

const array = [
  'V', 'version',
  'n', 'name'
]
const object = array2object(array)

/* object
 * {
 *   "version": null,
 *   "name": null,
 *   "V": null,
 *   "n": null
 * }
 */

With a different initial value

const options = {value: "foo"}
const object = array2object(array, options)

/* object
 * {
 *   "version": "foo",
 *   "name": "foo",
 *   "V": "foo",
 *   "n": "foo"
 * }
 */

With a different initial value and a base object

const base = {
  "dependencies": "bar",
  "S": "bar"
}

const options = {
  value: "foo",
  base: base
}

const object = array2object(array, options)

/* object
 * {
 *   "dependencies": "bar",
 *   "version": "foo",
 *   "name": "foo",
 *   "S": "bar",
 *   "V": "foo",
 *   "n": "foo"
 * }
 */

standard-readme compliant David David

Contribute

PRs accepted & greatly appreciated.

Tests

npm install
npm test

Dependencies

None

Dev Dependencies

  • codecov: Uploading report to Codecov: https://codecov.io
  • nyc: the Istanbul command line interface
  • rimraf: A deep deletion module for node (like rm -rf)
  • tape: tap-producing test harness for node and browsers

License

MIT

Keywords

FAQs

Package last updated on 09 Feb 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc