3.1.17 ā€¢ Published 1 year ago

extra-ilists v3.1.17

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ILists is a pair of key iterable list and value iterable list, with unique keys. šŸ“¦ Node.js, šŸŒ Web, šŸ“œ Files, šŸ“° Docs, šŸ“˜ Wiki.

As mentioned above, ILists is a data structure that consists of a pair of iterable lists, one for keys and one for values. The keys are unique, meaning there are no duplicate entries. ILists is an iterable version of Lists. Use it when you don't have the keys and values as Arrays.

This package includes functions that allow you to query about, generate, compare, and manipulate the data within the ILists. You can find out its size, add and remove entries, obtain its properties, get parts or subsets of the data, find specific entries within it, perform functional operations, combine ILists or its sub-entries, or perform set operations upon it. Except fromEntries(), all functions take ILists as their first parameter.

This package is available in Node.js and Web formats. To use it on the web, simply use the extra_ilists global variable after loading with a <script> tag from the jsDelivr CDN.

Stability: Experimental.

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

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

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

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

var x = [['a', 'b', 'c'], [1, 2, 3]];
[...xilists.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

PropertyDescription
isCheck if value is ilists.
keysList all keys.
valuesList all values.
entriesList all key-value pairs.
fromEntriesConvert ilists to entries.
sizeFind the size of ilists.
isEmptyCheck if ilists is empty.
compareCompare two ilists.
isEqualCheck if two ilists are equal.
getGet value at key.
getAllGets values at keys.
getPathGet value at path in nested ilists.
hasPathCheck if nested ilists has a path.
setSet value at key.
swapExchange two values.
removeRemove value at key.
headGet first entry from ilists (default order).
tailGet ilists without its first entry (default order).
takeKeep first n entries only (default order).
dropRemove first n entries (default order).
countCount values which satisfy a test.
countAsCount occurrences of values.
minFind smallest value.
minEntryFind smallest entry.
maxFind largest value.
maxEntryFind largest entry.
rangeFind smallest and largest values.
rangeEntriesFind smallest and largest entries.
subsetsList all possible subsets.
randomKeyPick an arbitrary key.
randomValuePick an arbitrary value.
randomEntryPick an arbitrary entry.
randomSubsetPick an arbitrary subset.
hasCheck if ilists has a key.
hasValueCheck if ilists has a value.
hasEntryCheck if ilists has an entry.
hasSubsetCheck if ilists has a subset.
findFind first value passing a test (default order).
findAllFind values passing a test.
searchFinds key of an entry passing a test.
searchAllFind keys of entries passing a test.
searchValueFind a key with given value.
searchValueAllFind keys with given value.
forEachCall a function for each value.
someCheck if any value satisfies a test.
everyCheck if all values satisfy a test.
mapTransform values of entries.
reduceReduce values of entries to a single value.
filterKeep entries which pass a test.
filterAtKeep entries with given keys.
rejectDiscard entries which pass a test.
rejectAtDiscard entries with given keys.
flatFlatten nested ilists to given depth.
flatMapFlatten nested ilists, based on map function.
zipCombine matching entries from all ilists.
partitionSegregate values by test result.
partitionAsSegregate entries by similarity.
chunkBreak ilists into chunks of given size.
concatAppend entries from all ilists, preferring last.
joinJoin ilists together into a string.
isDisjointCheck if ilists have no common keys.
unionKeysObtain keys present in any ilists.
unionObtain entries present in any ilists.
intersectionObtain entries present in both ilists.
differenceObtain entries not present in another ilists.
symmetricDifferenceObtain entries not present in both ilists.

npm.io ORG Coverage Status Test Coverage Maintainability