Socket
Socket
Sign inDemoInstall

array-indexofobject

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    array-indexofobject

Like Array#indexOf but for objects used like hashes


Version published
Weekly downloads
11K
increased by12.95%
Maintainers
1
Install size
3.55 kB
Created
Weekly downloads
 

Readme

Source

array-indexofobject

Like Array#indexOf but for objects used like hashes

Examples:

    var arr = [];
    var obj = { a: 1, b: 2, c: 'a b c'};
    var obj2 = { a: 1, b: 2, c: 'a b c'}; // same key/value pairs
    arr.push(obj);
    arr.indexOf(obj); // 0
    arr.indexOf(obj2); // -1
    indexOfObject = require('array-indexofobject');
    indexOfObject(arr, obj); // 0
    indexOfObject(arr, obj2); // 0

By default, all properties in the object must match. Optionally, you can instead pass one or more keys to use for comparison.

    var arr = [];
    var obj = { a: 1, b: 2, c: 'a b c', d: 'something'};
    var obj2 = { a: 1, b: 2, c: 'a b c', d: 'this key is not important'};
    arr.push(obj);
    indexOfObject(arr, obj2); // -1
    indexOfObject(arr, obj2, 'a'); // 0
    indexOfObject(arr, obj2, ['a', 'b', 'c']); // 0

Keywords

FAQs

Last updated on 02 Feb 2013

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