Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extra-lists

Package Overview
Dependencies
Maintainers
1
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extra-lists

A collection of functions for operating upon Lists.

  • 4.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

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. To use it on the web, simply use the extra_lists global variable after loading with a <script> tag from the jsDelivr CDN.

Stability: Experimental.


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

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

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

var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
xlists.min(x);
// → -4

var x = [['a', 'b', 'c'], [1, 2, 3]];
[...xlists.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 lists.
keysList all keys.
valuesList all values.
entriesList all key-value pairs.
fromEntriesConvert lists to entries.
sizeFind the size of lists.
isEmptyCheck if lists is empty.
compareCompare two lists.
isEqualCheck if two lists are equal.
getGet value at key.
getAllGets values at keys.
getPathGet value at path in nested lists.
hasPathCheck if nested lists has a path.
setSet value at key.
swapExchange two values.
removeRemove value at key.
headGet first entry from lists (default order).
tailGet lists 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 lists has a key.
hasValueCheck if lists has a value.
hasEntryCheck if lists has an entry.
hasSubsetCheck if lists 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 lists to given depth.
flatMapFlatten nested lists, based on map function.
zipCombine matching entries from all lists.
partitionSegregate values by test result.
partitionAsSegregate entries by similarity.
chunkBreak lists into chunks of given size.
concatAppend entries from all lists, preferring last.
joinJoin lists together into a string.
isDisjointCheck if lists have no common keys.
unionKeysObtain keys present in any lists.
unionObtain entries present in any lists.
intersectionObtain entries present in both lists.
differenceObtain entries not present in another lists.
symmetricDifferenceObtain entries not present in both lists.


ORG Coverage Status Test Coverage Maintainability

Keywords

FAQs

Package last updated on 14 Apr 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc