Package Exports
- array-indexofobject
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (array-indexofobject) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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