2.2.10 • Published 3 years ago

extra-lists.min v2.2.10

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

Lists is a pair of key list and value list, with unique keys. :package: NPM, :smiley_cat: GitHub, :running: RunKit, :vhs: Asciinema, :moon: Minified, :scroll: Files, :newspaper: JSDoc, :blue_book: Wiki.

All functions except from*() take lists as 1st parameter. Lists are an an alternative to entries, represented as a pair of keys, values. Unless entries are implemented as structs by v8, lists should be more efficient.

Methods as separate packages:

Stability: Experimental.

This is browserified, minified version of extra-lists. It is exported as global variable lists. CDN: unpkg, jsDelivr.

const lists = require('extra-lists');
// import * as lists from 'extra-lists';
// import * as lists from 'https://unpkg.com/extra-lists@2.2.2/index.mjs'; (deno)

var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
lists.filter(x, v => v % 2 === 1);
// [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]

var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
lists.some(x, v => v > 10);
// false

var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
lists.min(x);
// [ 'd', -4 ]

var x = [['a', 'b', 'c'], [1, 2, 3]];
[...lists.subsets(x)].map(a => [[...a[0]], [...a[1]]]);
// [
//   [ [], [] ],
//   [ [ 'a' ], [ 1 ] ],
//   [ [ 'b' ], [ 2 ] ],
//   [ [ 'a', 'b' ], [ 1, 2 ] ],
//   [ [ 'c' ], [ 3 ] ],
//   [ [ 'a', 'c' ], [ 1, 3 ] ],
//   [ [ 'b', 'c' ], [ 2, 3 ] ],
//   [ [ 'a', 'b', 'c' ], [ 1, 2, 3 ] ]
// ]

Index

MethodAction
isChecks if value is lists.
getGets value at key.
setSets value at key.
removeDeletes an entry.
swapExchanges two values.
sizeGets size of lists.
headGets first entry.
takeKeeps first n entries only.
shiftRemoves first entry.
fromEntriesCreates lists from entries.
concatAppends entries from all lists.
flatFlattens nested lists to given depth.
chunkBreaks lists into chunks of given size.
filterAtGets lists with given keys.
mapUpdates values based on map function.
filterKeeps entries which pass a test.
reduceReduces values to a single value.
rangeFinds smallest and largest entries.
countCounts values which satisfy a test.
partitionSegregates values by test result.
cartesianProductLists cartesian product of lists.
someChecks if any value satisfies a test.
zipCombines matching entries from all lists.
unionGives lists present in any lists.
intersectionGives entries present in both lists.
differenceGives entries of lists not present in another.
symmetricDifferenceGives entries not present in both lists.
isDisjointChecks if lists have no common keys.
keyPicks an arbitrary key.
valuePicks an arbitrary value.
entryPicks an arbitrary entry.
subsetPicks an arbitrary submap.
isEmptyChecks if lists is empty.
isEqualChecks if two lists are equal.
compareCompares two lists.
findFinds a value passing a test.
searchFinds key of an entry passing a test.
scanWhileFinds key of first entry not passing a test.

npm.io