Skip to content

extra-lists 3.0.16

Install from the command line:
Learn more about npm packages
$ npm install @nodef/extra-lists@3.0.16
Install via package.json:
"@nodef/extra-lists": "3.0.16"

About this version

A collection of functions for operating upon Lists.
πŸ“¦ Node.js, 🌐 Web, πŸ“œ Files, πŸ“° Docs, πŸ“˜ Wiki.

Lists is a pair of key list and value list, with unique keys. It is an an alternative to Entries. Unless entries are implemented as structs by v8, lists should be more space efficient. This package includes common functions related to querying about lists, generating them, comparing one with another, finding their size, adding and removing entries, obtaining its properties, getting a part of it, getting a subset entries in it, finding an entry in it, performing functional operations, manipulating it in various ways, combining together lists or its sub-entries, of performing set operations upon it. All functions except fromEntries() take lists as 1st parameter.

This package is available in Node.js and Web formats. The web format is exposed as extra_lists standalone variable and can be loaded from jsDelivr CDN.

Stability: Experimental.


const lists = require('extra-lists');
// import * as lists from 'extra-lists';
// import * as lists from 'https://unpkg.com/extra-lists/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);
// β†’ -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

Method Action
is Checks if value is lists.
get Gets value at key.
set Sets value at key.
remove Deletes an entry.
swap Exchanges two values.
size Gets size of lists.
head Gets first entry.
take Keeps first n entries only.
shift Removes first entry.
fromEntries Creates lists from entries.
concat Appends entries from all lists.
flat Flattens nested lists to given depth.
chunk Breaks lists into chunks of given size.
filterAt Gets lists with given keys.
map Updates values based on map function.
filter Keeps entries which pass a test.
reduce Reduces values to a single value.
range Finds smallest and largest entries.
count Counts values which satisfy a test.
partition Segregates values by test result.
cartesianProduct Lists cartesian product of lists.
some Checks if any value satisfies a test.
zip Combines matching entries from all lists.
union Gives lists present in any lists.
intersection Gives entries present in both lists.
difference Gives entries of lists not present in another.
symmetricDifference Gives entries not present in both lists.
isDisjoint Checks if lists have no common keys.
key Picks an arbitrary key.
value Picks an arbitrary value.
entry Picks an arbitrary entry.
subset Picks an arbitrary submap.
isEmpty Checks if lists is empty.
isEqual Checks if two lists are equal.
compare Compares two lists.
find Finds a value passing a test.
search Finds key of an entry passing a test.
scanWhile Finds key of first entry not passing a test.


Details


Assets

  • extra-lists-3.0.16.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0