js-augmentations
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

JS Object Augmentations

This package adds multiple utility methods to existing JS objects.

Index

Extends Map

Instantiation

var index = new Index();

or

var index = Index.create();

Both methods of instantiation accept an array of keys and values.

var index = new Index([
	[1, 'val'],
	[2, 'val']
]);

Util Methods array(); Returns an array of the values contained in the index keyArray(); Returns an array of the keys contained in the index entryArray(); Returns an array of the entries contained in the index random(); Returns a random value from the index randomKey(); Returns a random key from the index randomEntry(); Returns a random entry from the index first(amount?: number); Returns the first value(s) contained in the index firstKey(amount?: number); Returns the first key(s) contained in the index firstEntry(amount?: number); Returns the first entry or entries contained in the index last(amount?: number); Returns the last value(s) contained in the index lastKey(amount?: number); Returns the last key(s) contained in the index lastEntry(amount?: number); Returns the last entry or entries contained in the index sort(); Sorts an Index in place. This method mutates the Index and returns a reference to the same Index.

Readme

Keywords

Package Sidebar

Install

npm i js-augmentations

Weekly Downloads

1

Version

0.0.1

License

ISC

Unpacked Size

34.1 kB

Total Files

6

Last publish

Collaborators

  • pat.npm.js