Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
extra-lists
Advanced tools
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 ] ]
// ā ]
Property | Description |
---|---|
is | Check if value is lists. |
keys | List all keys. |
values | List all values. |
entries | List all key-value pairs. |
fromEntries | Convert lists to entries. |
size | Find the size of lists. |
isEmpty | Check if lists is empty. |
compare | Compare two lists. |
isEqual | Check if two lists are equal. |
get | Get value at key. |
getAll | Gets values at keys. |
getPath | Get value at path in nested lists. |
hasPath | Check if nested lists has a path. |
set | Set value at key. |
swap | Exchange two values. |
remove | Remove value at key. |
head | Get first entry from lists (default order). |
tail | Get lists without its first entry (default order). |
take | Keep first n entries only (default order). |
drop | Remove first n entries (default order). |
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. |
subsets | List all possible subsets. |
randomKey | Pick an arbitrary key. |
randomValue | Pick an arbitrary value. |
randomEntry | Pick an arbitrary entry. |
randomSubset | Pick an arbitrary subset. |
has | Check if lists has a key. |
hasValue | Check if lists has a value. |
hasEntry | Check if lists has an entry. |
hasSubset | Check if lists has a subset. |
find | Find first value passing a test (default order). |
findAll | Find values passing a test. |
search | Finds 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 entries. |
reduce | Reduce values of entries to a single value. |
filter | Keep entries which pass a test. |
filterAt | Keep entries with given keys. |
reject | Discard entries which pass a test. |
rejectAt | Discard entries with given keys. |
flat | Flatten nested lists to given depth. |
flatMap | Flatten nested lists, based on map function. |
zip | Combine matching entries from all lists. |
partition | Segregate values by test result. |
partitionAs | Segregate entries by similarity. |
chunk | Break lists into chunks of given size. |
concat | Append entries from all lists, preferring last. |
join | Join lists together into a string. |
isDisjoint | Check if lists have no common keys. |
unionKeys | Obtain keys present in any lists. |
union | Obtain entries present in any lists. |
intersection | Obtain entries present in both lists. |
difference | Obtain entries not present in another lists. |
symmetricDifference | Obtain entries not present in both lists. |
FAQs
A collection of functions for operating upon Lists.
The npm package extra-lists receives a total of 15 weekly downloads. As such, extra-lists popularity was classified as not popular.
We found that extra-lists demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 1 open source maintainer collaborating on the project.
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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.