0.0.1 • Published 3 years ago

js-augmentations v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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.