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

array-keys

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-keys

a simple interface to manage large arrays of objects easily

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

array-keys

Build Status Code Climate license downloads release

Very simple library to manage array elements using a key instead of array index position. When dealing with very large sets of data all organized in an object reference, if the object structure is changing a lot you can end up with memory leaks and slow performance. In these cases it's better to keep an array of objects instead of and object of objects. The cost of iterating through the array is cheaper than the lack of garbage collection which can occur in large, changing, object hashes.

environments

Should run in both node.js and browser environments.

basic usage example

var ak = new ArrayKeys({
    identifier: 'key' // defaults to `id`
});

ak.getRecord('myInvalidKey'}); // returns undefined

ak.addRecord({
    key: 'myKey1',
    value: 'hello world!'
}); // returns true

ak.getRecord('myKey1'); // returns { key: 'myKey1', value: 'hello world!' }

ak.addRecord({
    key: 'myKey2',
    value: 'hello space!'
}); // returns true


ak.forEachRecord(function (record) {
    // this function is called once for each record
}).finally(function (count) {
    // function called after the above callback is called for each record
    // count is the total number of records processed
});

ak.getIdentifiers(); // returns ['myKey1', 'myKey2']

license

array-keys is licensed under the LGPL

credits

Project developed and maintained by Nick Jennings

Keywords

FAQs

Package last updated on 11 Dec 2014

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