npm.io
1.0.0 • Published 8 years ago

key-for-id

Licence
MIT
Version
1.0.0
Deps
0
Size
4 kB
Vulns
0
Weekly
0

key-for-id

travis npm version npm downloads Standard - JavaScript Style Guide

Find the key for a specific value in an array

Table of Contents

Install

Add key-for-id to your project using npm or yarn.

Install (NPM):

$ npm install key-for-id --save

Install (Yarn):

$ yarn add key-for-id

Usage

Import KeyForID into Your Project

import KeyForID from 'key-for-id'

Pass An Array as the first parameter, the key as the second and the value your searching for as the third.

let people = [{name: 'Josh'}, {name: 'Steven'}, {name: 'Sarah'}]
let index = KeyForID(people, 'name', 'Sarah') // 2

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome!

License

MIT