Skip to content

extra-entries 3.0.34

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

About this version

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

Entries is a list of key-value pairs, with unique keys. This package includes common functions related to querying about entries, 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 entries or its sub-entries, of performing set operations upon it.

All functions except from*() take entries as 1st parameter, and expect it to be iterable. It does not need to be an array. Entries are returned by Array, Object, Set, Map.

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

Stability: Experimental.


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

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

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

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

var x = [['a', 1], ['b', 2], ['c', 3]];
[...entries.subsets(x)].map(a => [...a]);
// β†’ [
// β†’   [],
// β†’   [ [ 'a', 1 ] ],
// β†’   [ [ 'b', 2 ] ],
// β†’   [ [ 'a', 1 ], [ 'b', 2 ] ],
// β†’   [ [ 'c', 3 ] ],
// β†’   [ [ 'a', 1 ], [ 'c', 3 ] ],
// β†’   [ [ 'b', 2 ], [ 'c', 3 ] ],
// β†’   [ [ 'a', 1 ], [ 'b', 2 ], [ 'c', 3 ] ]
// β†’ ]


Index

Property Description
is Check if value is a map.
[keys] List all keys.
[values] List all values.
fromLists Convert lists to map.
compare Compare two maps.
isEqual Check if two maps are equal.
size Find the size of a map.
isEmpty Check if a map is empty.
get Get value at key.
[getAll] Get values at keys.
[getPath] Get value at path in a nested map.
[hasPath] Check if nested map has a path.
set Set value at key.
swap Exchange two values.
remove Remove value at key.
count Count values which satisfy a test.
[countAs] Count occurrences of values.
[min] Find smallest value.
[minEntry] Find smallest entry.
[max] Find largest value.
[maxEntry] Find largest entry.
range Find smallest and largest values.
[rangeEntries] Find smallest and largest entries.
head Get first entry from map (default order).
[tail] Get a map without its first entry (default order).
take Keep first n entries only (default order).
[drop] Remove first n entries (default order).
[subsets] List all possible subsets.
[randomKey] Pick an arbitrary key.
[randomEntry] Pick an arbitrary entry.
[randomSubset] Pick an arbitrary subset.
[has] Check if map has a key.
[hasValue] Check if map has a value.
[hasEntry] Check if map has an entry.
[hasSubset] Check if map has a subset.
find Find first value passing a test (default order).
[findAll] Find values passing a test.
search Find key of an entry passing a test.
[searchAll] Find keys of entries passing a test.
[searchValue] Find a key with given value.
[searchValueAll] Find keys with given value.
[forEach] Call a function for each value.
some Check if any value satisfies a test.
[every] Check if all values satisfy a test.
map Transform values of a map.
reduce Reduce values of set to a single value.
filter Keep entries which pass a test.
filterAt Keep values at given keys.
[reject] Discard entries which pass a test.
[rejectAt] Discard values at given keys.
flat Flatten nested map to given depth.
[flatMap] Flatten nested map, based on map function.
zip Combine matching entries from maps.
partition Segregate entries by test result.
[partitionAs] Segregate entries by similarity.
chunk Break map into chunks of given size.
concat Append entries from maps, preferring last.
[join] Join entries together into a string.
isDisjoint Check if maps have no common keys.
[unionKeys] Obtain keys present in any map.
union Obtain entries present in any map.
intersection Obtain entries present in both maps.
difference Obtain entries not present in another map.
symmetricDifference Obtain entries not present in both maps.



Details


Assets

  • extra-entries-3.0.34.tgz

Download activity

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