Socket
Book a DemoInstallSign in
Socket

keyed-array

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyed-array

Recursively add named keys to arrays of objects

latest
Source
npmnpm
Version
2.1.2
Version published
Maintainers
1
Created
Source

keyed-array Build Status

Recursively add named keys to arrays of objects

I wrote a blog post about the idea here: http://zeke.sikelianos.com/keyed-arrays-in-javascript

Installation

npm install keyed-array --save

Usage

For more extensive usage examples, see test.js

const keyedArray = require('keyed-array')

let people = [
  {id: 'bob', name: 'Bob', isCool: false},
  {id: 'sue', name: 'Sue', isCool: false},
  {id: 'hal', name: 'Hal', isCool: true},
  {id: 'ann', name: 'Ann', isCool: true}
]

people = keyedArray(people)

// `people` is still an array, but now it also has keys based on the `id`
// value of each object
people.bob
// {id: 'bob', name: 'Bob', isCool: false}

Tests

npm install
npm test

Dependencies

None

Dev Dependencies

  • standard: JavaScript Standard Style
  • tap-spec: Formatted TAP output like Mocha's spec reporter
  • tape: tap-producing test harness for node and browsers

License

MIT

Generated by package-json-to-readme

Keywords

array

FAQs

Package last updated on 15 Nov 2016

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