2.2.18 • Published 4 years ago

extra-entries.min v2.2.18

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

Entries is a list of key-value pairs, 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 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.

Methods as separate packages:

Stability: Experimental.

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

const entries = require("extra-entries");
// import * as entries from "extra-entries";
// import * as entries from "https://unpkg.com/extra-entries@2.2.10/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);
// [ "d", -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

MethodAction
isChecks if value is entries.
getGets value at key.
setSets value at key.
removeDeletes an entry.
swapExchanges two values.
sizeGets size of entries.
headGets first entry.
takeKeeps first n entries only.
shiftRemoves first entry.
fromListsCreates entries from lists.
concatAppends entries from maps, preferring last.
flatFlattens nested entries to given depth.
chunkBreaks entries into chunks of given size.
filterAtGets entries 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 entries.
someChecks if any value satisfies a test.
zipCombines matching entries from all entries.
unionGives entries present in any entries.
intersectionGives entries present in both entries.
differenceGives entries not present in another.
symmetricDifferenceGives entries not present in both entries.
isDisjointChecks if entries have no common keys.
keyPicks an arbitrary key.
valuePicks an arbitrary value.
entryPicks an arbitrary entry.
subsetGives an arbitrary subset.
isEmptyChecks if entries is empty.
isEqualChecks if two maps are equal.
compareCompares two entries.
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