Package Exports
- super-array
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 (super-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
super-array
Just like a normal JavaScript Array but enhanced with constant O(1) access time for properties by unique key!
Install
$ npm install --save super-arrayUsage
const SuperArray = require('super-array');
const myArray = new SuperArray([
{id: 'ab1', name: 'John'},
{id: 'ab2', name: 'Peter'},
]);
myArray.get('ab1') // {id: 'ab1', name: 'John'}
myArray.get('ab2') // {id: 'ab2', name: 'Peter'}or you can use a custom identifier function: (please note that the identifier has to be unique)
const SuperArray = require('super-array');
const myArray = new SuperArray([
{id: 'ab1', name: 'John'},
{id: 'ab2', name: 'Peter'},
], function(item) { return item.name });
myArray.get('John') // {id: 'ab1', name: 'John'}
myArray.get('Peter') // {id: 'ab2', name: 'Peter'}API
SuperArray(arr, identifyFn)
arr (optional):
- Type:
<Array> - Default:
[]
identifyFn (optional):
- Type:
<Function(item):identifier> - Default:
function(item) { return item.id }
Returns SuperArray instance.
License
MIT © Patrik Toma