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
Lists is a pair of key list and value list, with unique keys.
All functions except from*()
take lists as 1st parameter. Lists are an
an alternative to entries, represented as a pair of keys, values. Unless
entries are implemented as structs by v8, lists should be more efficient.
Methods as separate packages:
@extra-lists/find
: use rollup to bundle this es module.@extra-lists/find.min
: use in browser (browserify, uglify-js).Stability: Experimental.
const lists = require('extra-lists');
// import * as lists from 'extra-lists';
// import * as lists from 'https://unpkg.com/extra-lists@2.2.2/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);
// [ 'd', -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 ] ]
// ]
Method | Action |
---|---|
is | Checks if value is lists. |
get | Gets value at key. |
set | Sets value at key. |
remove | Deletes an entry. |
swap | Exchanges two values. |
size | Gets size of lists. |
head | Gets first entry. |
take | Keeps first n entries only. |
shift | Removes first entry. |
fromEntries | Creates lists from entries. |
concat | Appends entries from all lists. |
flat | Flattens nested lists to given depth. |
chunk | Breaks lists into chunks of given size. |
filterAt | Gets lists with given keys. |
map | Updates values based on map function. |
filter | Keeps entries which pass a test. |
reduce | Reduces values to a single value. |
range | Finds smallest and largest entries. |
count | Counts values which satisfy a test. |
partition | Segregates values by test result. |
cartesianProduct | Lists cartesian product of lists. |
some | Checks if any value satisfies a test. |
zip | Combines matching entries from all lists. |
union | Gives lists present in any lists. |
intersection | Gives entries present in both lists. |
difference | Gives entries of lists not present in another. |
symmetricDifference | Gives entries not present in both lists. |
isDisjoint | Checks if lists have no common keys. |
key | Picks an arbitrary key. |
value | Picks an arbitrary value. |
entry | Picks an arbitrary entry. |
subset | Picks an arbitrary submap. |
isEmpty | Checks if lists is empty. |
isEqual | Checks if two lists are equal. |
compare | Compares two lists. |
find | Finds a value passing a test. |
search | Finds key of an entry passing a test. |
scanWhile | Finds key of first entry not passing a test. |
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.