Socket
Socket
Sign inDemoInstall

extra-entries

Package Overview
Dependencies
0
Maintainers
1
Versions
193
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    extra-entries

A collection of functions for operating upon Entries.


Version published
Weekly downloads
25
decreased by-67.95%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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 fromLists() 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

PropertyDescription
isCheck if value is an iterable.
keysList all keys.
valuesList all values.
fromListsConvert lists to entries.
compareCompare two entries.
isEqualCheck if two entries are equal.
sizeFind the length of an iterable.
isEmptyCheck if an iterable is empty.
getGet value at key.
getAllGet values at keys.
getPathGet value at path in nested entries.
hasPathCheck if nested entries has a path.
setSet value at key.
swapExchange two values.
removeRemove value at key.
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.
headGet first value.
tailGet values except first.
takeKeep first n values only.
dropDiscard first n values only.
subsetsList all possible subsets.
randomKeyPick an arbitrary key.
randomEntryPick an arbitrary entry.
randomSubsetPick an arbitrary subset.
hasCheck if entries has a key.
hasValueCheck if entries has a value.
hasEntryCheck if entries has an entry.
hasSubsetCheck if entries 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.
searchValueAllFinds 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 entries to given depth.
flatMapFlatten nested entries, based on map function.
zipCombine matching entries from all entries.
partitionSegregate values by test result.
partitionAsSegregate entries by similarity.
chunkBreak entries into chunks of given size.
concatAppend entries from all entries, preferring last.
joinJoin entries together into a string.
isDisjointCheck if entries have no common keys.
unionKeysObtain keys present in any entries.
unionObtain entries present in any entries.
intersectionObtain entries present in both entries.
differenceObtain entries not present in another entries.
symmetricDifferenceObtain entries not present in both entries.
randomValuePick an arbitrary value.



ORG DOI Coverage Status Test Coverage Maintainability

Keywords

FAQs

Last updated on 19 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc