Socket
Socket
Sign inDemoInstall

npm-indexofkey

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    npm-indexofkey

Which receives array, (key, value) object pair and returns the index of that particular {key,value} pair in that array and also it is flexible enough to return the first index , last index and also an array of multilple indexes.


Version published
Weekly downloads
8
increased by14.29%
Maintainers
1
Install size
7.18 kB
Created
Weekly downloads
 

Readme

Source

npm-indexofkey NPM version

Which receives array, (key, value) object pair and returns the index of that particular {key,value} pair in that array and also it is flexible enough to return the first index , last index and also an array of multiple indexes.

Installation

npm i npm-indexofkey

Usage

var indexOfkey = require('npm-indexofkey');

getIndex(array, {key, value})

Receives the input array, (key, value) object pair and returns the first index of that particular {key,value} pair.


  var indexOfkey = require('npm-indexofkey')
  var inputArray = [{"id":null,"number":7},{"isValid":false,"number":362},{"isValid":true,"count":126},{"isValid":false,"number":10}];
 
  indexOfkey.getIndex(inputArray, {"isValid": false});
  // 1
  

getIndexLast(array, {key, value})

Receives the input array, (key, value) object pair and returns the last index of that particular {key,value} pair.


  var indexOfkey = require('npm-indexofkey')
  var inputArray = [{"id":null,"number":7},{"isValid":false,"number":362},{"isValid":true,"count":126},{"isValid":false,"number":10}];
 
  indexOfkey.getIndexLast(inputArray, {"isValid": false});
  // 3
  

getAll(array, {key, value})

Receives the input array, (key, value) object pair and returns the array of all indexes of that particular {key,value} pair.


  var indexOfkey = require('npm-indexofkey')
  var inputArray = [{"id":null,"number":7},{"isValid":false,"number":362},{"isValid":true,"count":126},{"isValid":false,"number":10}];
 
  indexOfkey.getAll(inputArray, {"isValid": false});
  // [1,3]
  

Demo

Demo @npm-array-unique | https://tonicdev.com/npm/npm-indexofkey

Author

Krishcdbry [krishcdbry@gmail.com]

Licence

MIT @krishcdbry

Keywords

FAQs

Last updated on 12 Sep 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc