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

array-indexofobject

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-indexofobject

Like Array#indexOf but for objects used like hashes

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 02 Feb 2013

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