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 - npm Package Compare versions

Comparing version 2.2.9 to 2.2.10

762

index.d.ts

@@ -23,2 +23,26 @@ declare module "extra-lists" {

* @param fm map function (vs, i)
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* var y = [['d', 'e'], [10, 20]];
* [...cartesianProduct([x, y])].map(a => [[...a[0]], [...a[1]]]);
* // [
* // [ [ 'a', 'd' ], [ 1, 10 ] ],
* // [ [ 'a', 'e' ], [ 1, 20 ] ],
* // [ [ 'b', 'd' ], [ 2, 10 ] ],
* // [ [ 'b', 'e' ], [ 2, 20 ] ],
* // [ [ 'c', 'd' ], [ 3, 10 ] ],
* // [ [ 'c', 'e' ], [ 3, 20 ] ]
* // ]
*
* [...cartesianProduct([x, y], a => max(a))];
* // [
* // [ 'd', 10 ],
* // [ 'e', 20 ],
* // [ 'd', 10 ],
* // [ 'e', 20 ],
* // [ 'd', 10 ],
* // [ 'e', 20 ]
* // ]
* ```
*/

@@ -32,2 +56,29 @@ export function cartesianProduct<T, U, V = U>(xs: Lists<T, U>[], fm?: mapFn<number, Lists<T, U>, Lists<T, U> | V>): Iterable<Lists<T, U> | V>;

* @param s chunk step (n)
* @example
* ```javascript
* var x = [
* ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
* [1, 2, 3, 4, 5, 6, 7, 8]
* ];
* chunk(x, 3);
* // [
* // [ [ 'a', 'b', 'c' ], [ 1, 2, 3 ] ],
* // [ [ 'd', 'e', 'f' ], [ 4, 5, 6 ] ],
* // [ [ 'g', 'h' ], [ 7, 8 ] ]
* // ]
*
* chunk(x, 2, 3);
* // [
* // [ [ 'a', 'b' ], [ 1, 2 ] ],
* // [ [ 'd', 'e' ], [ 4, 5 ] ],
* // [ [ 'g', 'h' ], [ 7, 8 ] ]
* // ]
*
* chunk(x, 4, 3);
* // [
* // [ [ 'a', 'b', 'c', 'd' ], [ 1, 2, 3, 4 ] ],
* // [ [ 'd', 'e', 'f', 'g' ], [ 4, 5, 6, 7 ] ],
* // [ [ 'g', 'h' ], [ 7, 8 ] ]
* // ]
* ```
*/

@@ -43,2 +94,23 @@ export function chunk<T, U>(x: Lists<T, U>, n?: number, s?: number): Lists<T, U>[];

* @returns x=y: 0, otherwise: -ve/+ve
* @example
* ```javascript
* var x = [['a', 'b'], [1, 2]];
* var y = [['a', 'b', 'c'], [1, 2, 3]];
* compare(x, y);
* // -1
*
* var y = [['a', 'b'], [1, 2]];
* compare(x, y);
* // 0
*
* var y = [['a', 'b'], [1, -2]];
* compare(x, y);
* // 1
*
* compare(x, y, (a, b) => Math.abs(a) - Math.abs(b));
* // 0
*
* compare(x, y, null, v => Math.abs(v));
* // 0
* ```
*/

@@ -50,2 +122,12 @@ export function compare<T, U, V = U>(x: Lists<T, U>, y: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): number;

* @param xs n lists
* @example
* ```javascript
* var x = [['a', 'b'], [1, 2]];
* var y = [['c', 'd'], [3, 4]];
* concat(x, y).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'd' ], [ 1, 2, 3, 4 ] ]
*
* var z = [['d', 'e'], [40, 50]];
* // [ [ 'a', 'b', 'c', 'd', 'd', 'e' ], [ 1, 2, 3, 4, 40, 50 ] ]
* ```
*/

@@ -58,2 +140,11 @@ export function concat<T, U>(...xs: Lists<T, U>[]): Lists<T, U>;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 1, 2, 2, 4]];
* count(x, v => v % 2 === 1);
* // 2
*
* count(x, v => v % 2 === 0);
* // 3
* ```
*/

@@ -67,2 +158,12 @@ export function count<T, U>(x: Lists<T, U>, ft: testFn<T, U>): number;

* @returns Map {value => count}
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 1, 2, 2, 4]];
* countAs(x);
* // Map(3) { 1 => 2, 2 => 2, 4 => 1 }
*
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* countAs(x, v => v % 2);
* // Map(2) { 1 => 2, 0 => 2 }
* ```
*/

@@ -75,2 +176,13 @@ export function countAs<T, U, V = U>(x: Lists<T, U>, fm?: mapFn<T, U, U | V>): Map<U | V, number>;

* @param y another lists
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* var y = [['b', 'd'], [2, 4]];
* difference(x, y).map(c => [...c]);
* // [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]
*
* var y = [['b', 'd'], [-2, -4]];
* difference(x, y).map(c => [...c]);
* // [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]
* ```
*/

@@ -83,2 +195,11 @@ export function difference<T, U>(x: Lists<T, U>, y: Lists<T, U>): Lists<T, U>;

* @param n number of entries (1)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* drop(x, 2).map(c => [...c]);
* // [ [ 'c', 'd', 'e' ], [ 3, 4, 5 ] ]
*
* drop(x, 3).map(c => [...c]);
* // [ [ 'd', 'e' ], [ 4, 5 ] ]
* ```
*/

@@ -90,2 +211,8 @@ export function drop<T, U>(x: Lists<T, U>, n?: number): Lists<T, U>;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* [...entries(x)];
* // [ [ 'a', 1 ], [ 'b', 2 ], [ 'c', 3 ] ]
* ```
*/

@@ -98,2 +225,11 @@ export function entries<T, U>(x: Lists<T, U>): Entries<T, U>;

* @param r random seed 0->1
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* entry(x);
* // [ 'c', 3 ]
*
* entry(x, 0.5);
* // [ 'b', 2 ]
* ```
*/

@@ -109,2 +245,11 @@ export function entry<T, U>(x: Lists<T, U>, r?: number): [

* @param ft test function (v, k ,x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
* every(x, v => v > 0);
* // false
*
* every(x, v => v > -10);
* // true
* ```
*/

@@ -117,2 +262,11 @@ export function every<T, U>(x: Lists<T, U>, ft: testFn<T, U>): boolean;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* filter(x, v => v % 2 === 1);
* // [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]
*
* filter(x, v => v % 2 === 0);
* // [ [ 'b', 'd' ], [ 2, 4 ] ]
* ```
*/

@@ -125,2 +279,11 @@ export function filter<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Lists<T, U>;

* @param ks keys
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* filterAt(x, ['a', 'c', 'e']);
* // [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]
*
* filterAt(x, ['b', 'd']);
* // [ [ 'b', 'd' ], [ 2, 4 ] ]
* ```
*/

@@ -133,2 +296,11 @@ export function filterAt<T, U>(x: Lists<T, U>, ks: T[]): Lists<T, U>;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* find(x, v => v % 2 === 0);
* // 2 ^
*
* find(x, v => v % 8 === 0);
* // undefined
* ```
*/

@@ -141,2 +313,11 @@ export function find<T, U>(x: Lists<T, U>, ft: testFn<T, U>): U;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* [...findAll(x, v => v % 2 === 0)];
* // [ 2, 4 ] ^ ^
*
* [...findAll(x, v => v % 8 === 0)];
* // []
* ```
*/

@@ -151,2 +332,25 @@ export function findAll<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Iterable<U>;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['ab', 'cde'], [
* [['a', 'b'], [1, 2]],
* [['c', 'de'], [
* 3,
* [['d', 'e'], [
* 3,
* [['e'], [
* 5
* ]]
* ]]
* ]]
* ]];
* flat(x).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'd', 'e' ], [ 1, 2, 3, 3, 5 ] ]
*
* flat(x, 1).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'de' ], [ 1, 2, 3, [ [Array], [Array] ] ] ]
*
* flat(x, 2).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'd', 'e' ], [ 1, 2, 3, 3, [ [Array], [Array] ] ] ]
* ```
*/

@@ -160,2 +364,25 @@ export function flat<T>(x: Lists<T, any>, n?: number, fm?: mapFn<T, any, any>, ft?: testFn<T, any>): Lists<T, any>;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['ab', 'cde'], [
* [['a', 'b'], [1, 2]],
* [['c', 'de'], [
* 3,
* [['d', 'e'], [
* 3,
* [['e'], [
* 5
* ]]
* ]]
* ]]
* ]];
* flatMap(x).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'de' ], [ 1, 2, 3, [ [Array], [Array] ] ] ]
*
* flatMap(x, v => flat(v, 1)).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'd', 'e' ], [ 1, 2, 3, 3, [ [Array], [Array] ] ] ]
*
* flatMap(x, v => flat(v)).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'd', 'e' ], [ 1, 2, 3, 3, 5 ] ]
* ```
*/

@@ -168,2 +395,11 @@ export function flatMap<T>(x: Lists<T, any>, fm?: mapFn<T, any, any>, ft?: testFn<T, any>): Lists<T, any>;

* @param fc called function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
* forEach(x, v => console.log(v));
* // 1
* // 2
* // -3
* // -4
* ```
*/

@@ -175,2 +411,8 @@ export function forEach<T, U>(x: Lists<T, U>, fc: calledFn<T, U>): void;

* @param es entries
* @example
* ```javascript
* var es = [['a', 1], ['b', 2], ['c', 3]];
* fromEntries(es).map(c => [...c]);
* // [ [ 'a', 'b', 'c' ], [ 1, 2, 3 ] ]
* ```
*/

@@ -183,2 +425,11 @@ export function fromEntries<T, U>(es: Entries<T, U>): Lists<T, U>;

* @param k key
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [2, 4, 6, 8]];
* get(x, 'b');
* // 4
*
* get(x, 'd');
* // 8
* ```
*/

@@ -191,2 +442,11 @@ export function get<T, U>(x: Lists<T, U>, k: T): U;

* @param ks keys
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [2, 4, 6, 8]];
* getAll(x, ['b', 'd']);
* // [ 4, 8 ]
*
* getAll(x, ['e']);
* // [ undefined ]
* ```
*/

@@ -199,2 +459,15 @@ export function getAll<T, U>(x: Lists<T, U>, ks: T[]): Iterable<U>;

* @param p path
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [2, 4, 6]];
* var y = [['x', 'e', 'f'], [x, 10, 12]];
* getPath(y, ['e']);
* // 10
*
* getPath(y, ['x', 'b']);
* // 4
*
* getPath(y, ['x', 'b', 'c']);
* // undefined
* ```
*/

@@ -207,2 +480,11 @@ export function getPath<T>(x: Lists<T, any>, p: T[]): any;

* @param k key?
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, -3]];
* has(x, 'd');
* // false
*
* has(x, 'c');
* // true
* ```
*/

@@ -217,2 +499,14 @@ export function has<T, U>(x: Lists<T, U>, k: T): boolean;

* @param fm map function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, -3]];
* hasEntry(x, ['c', 3]);
* // false
*
* hasEntry(x, ['c', 3], (a, b) => Math.abs(a) - Math.abs(b));
* // true
*
* hasEntry(x, ['c', 3], null, v => Math.abs(v));
* // true
* ```
*/

@@ -228,2 +522,15 @@ export function hasEntry<T, U, V = U>(x: Lists<T, U>, e: [

* @param p path
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [2, 4, 6]];
* var y = [['x', 'e', 'f'], [x, 10, 12]];
* hasPath(y, ['e']);
* // true
*
* hasPath(y, ['x', 'b']);
* // true
*
* hasPath(y, ['x', 'b', 'c']);
* // false
* ```
*/

@@ -238,2 +545,19 @@ export function hasPath<T>(x: Lists<T, any>, p: T[]): boolean;

* @param fm map function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* var y = [['b', 'd'], [2, 4]];
* hasSubset(x, y);
* // true
*
* var y = [['b', 'd'], [-2, -4]];
* hasSubset(x, y);
* // false
*
* hasSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
* // true
*
* hasSubset(x, y, null, v => Math.abs(v));
* // true
* ```
*/

@@ -248,2 +572,14 @@ export function hasSubset<T, U, V = U>(x: Lists<T, U>, y: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean;

* @param fm map function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, -3]];
* hasValue(x, 3);
* // false
*
* hasValue(x, 3, (a, b) => Math.abs(a) - Math.abs(b));
* // true
*
* hasValue(x, 3, null, v => Math.abs(v));
* // true
* ```
*/

@@ -256,2 +592,12 @@ export function hasValue<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean;

* @param ed default entry
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* head(x);
* // [ 'a', 1 ]
*
* var x = [[], []];
* head(x, ['', -1]);
* // [ '', -1 ]
* ```
*/

@@ -271,2 +617,12 @@ export function head<T, U>(x: Lists<T, U>, ed?: [

* @param fc combine function (a, b)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* var y = [['b', 'c', 'e'], [20, 30, 50]];
* intersection(x, y).map(c => [...c]);
* // [ [ 'b', 'c' ], [ 2, 3 ] ]
*
* intersection(x, y, (a, b) => b).map(c => [...c]);
* // [ [ 'b', 'c' ], [ 20, 30 ] ]
* ```
*/

@@ -278,2 +634,13 @@ export function intersection<T, U>(x: Lists<T, U>, y: Lists<T, U>, fc?: combineFn<U>): Lists<T, U>;

* @param v value
* @example
* ```javascript
* is([['a', 'b'], [1, 2]]);
* // true
*
* is([[], []]);
* // true
*
* is(1);
* // false
* ```
*/

@@ -286,2 +653,13 @@ export function is<T, U>(v: any): v is Lists<T, U>;

* @param y another lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* var x = [['c', 'd'], [3, 4]];
* isDisjoint(x, y);
* // false
*
* var x = [['d'], [4]];
* isDisjoint(x, y);
* // true
* ```
*/

@@ -293,2 +671,12 @@ export function isDisjoint<T, U>(x: Lists<T, U>, y: Lists<T, U>): boolean;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* isEmpty(x);
* // false
*
* var x = [[], []];
* isEmpty(x);
* // true
* ```
*/

@@ -303,2 +691,19 @@ export function isEmpty<T, U>(x: Lists<T, U>): boolean;

* @param fm map function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b'], [1, 2]];
* var y = [['a', 'b'], [1, 2]];
* isEqual(x, y);
* // true
*
* var y = [['a', 'b'], [11, 12]];
* isEqual(x, y);
* // false
*
* isEqual(x, y, (a, b) => (a % 10) - (b % 10));
* // true
*
* isEqual(x, y, null, v => v % 10);
* // true
* ```
*/

@@ -312,2 +717,11 @@ export function isEqual<T, U, V = U>(x: Lists<T, U>, y: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean;

* @param asc associator (=)
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* join(x);
* // 'a=1,b=2,c=3'
*
* join(x, ', ', ' => ');
* // 'a => 1, b => 2, c => 3'
* ```
*/

@@ -320,2 +734,11 @@ export function join<T, U>(x: Lists<T, U>, sep?: string, asc?: string): string;

* @param r random seed 0->1
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* key(x);
* // 'c'
*
* key(x, 0.5);
* // 'b'
* ```
*/

@@ -327,2 +750,8 @@ export function key<T, U>(x: Lists<T, U>, r?: number): T;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* [...keys(x)];
* // [ 'a', 'b', 'c' ]
* ```
*/

@@ -334,2 +763,8 @@ export function keys<T, U>(x: Lists<T, U>): Iterable<T>;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* length(x);
* // 3
* ```
*/

@@ -342,3 +777,10 @@ export function length<T, U>(x: Lists<T, U>): number;

* @param fm map function (v, k, x)
s */
* s
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* map(x, v => v * 2);
* // [ [ 'a', 'b', 'c', 'd' ], [ 2, 4, 6, 8 ] ]
* ```
*/
export function map<T, U, V>(x: Lists<T, U>, fm: mapFn<T, U, V>): any[][];

@@ -352,2 +794,14 @@ /**

* @returns [key, value]
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
* max(x);
* // [ 'b', 2 ]
*
* max(x, (a, b) => Math.abs(a) - Math.abs(b));
* // [ 'd', -4 ]
*
* max(x, null, v => Math.abs(v));
* // [ 'd', -4 ]
* ```
*/

@@ -365,2 +819,14 @@ export function max<T, U, V = U>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [

* @returns [key, value]
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
* min(x);
* // [ 'd', -4 ]
*
* min(x, (a, b) => Math.abs(a) - Math.abs(b));
* // [ 'a', 1 ]
*
* min(x, null, v => Math.abs(v));
* // [ 'a', 1 ]
* ```
*/

@@ -377,2 +843,12 @@ export function min<T, U, V = U>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [

* @returns [satisfies, doesnt]
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* partition(x, v => v % 2 == 0).map(x => [...x]);
* // [ [ [ 'b', 'd' ], [ 2, 4 ] ], [ [ 'a', 'c' ], [ 1, 3 ] ] ]
*
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* partition(x, v => v % 2 == 1).map(x => [...x]);
* // [ [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ], [ [ 'b', 'd' ], [ 2, 4 ] ] ]
* ```
*/

@@ -389,2 +865,19 @@ export function partition<T, U>(x: Lists<T, U>, ft: testFn<T, U>): [

* @returns Map {key => values}
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* partitionAs(x, v => v % 2 == 0);
* // Map(2) {
* // false => [ [ 'a', 'c' ], [ 1, 3 ] ],
* // true => [ [ 'b', 'd' ], [ 2, 4 ] ]
* // }
*
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* partitionAs(x, v => v % 3);
* // Map(3) {
* // 1 => [ [ 'a', 'd' ], [ 1, 4 ] ],
* // 2 => [ [ 'b', 'e' ], [ 2, 5 ] ],
* // 0 => [ [ 'c' ], [ 3 ] ]
* // }
* ```
*/

@@ -399,2 +892,14 @@ export function partitionAs<T, U, V = U>(x: Lists<T, U>, fm?: mapFn<T, U, U | V>): Map<U | V, Lists<T, U>>;

* @returns [smallest, largest]
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
* range(x);
* // [ [ 'd', -4 ], [ 'b', 2 ] ]
*
* range(x, (a, b) => Math.abs(a) - Math.abs(b));
* // [ [ 'a', 1 ], [ 'd', -4 ] ]
*
* range(x, null, v => Math.abs(v));
* // [ [ 'a', 1 ], [ 'd', -4 ] ]
* ```
*/

@@ -417,2 +922,11 @@ export function range<T, U, V = U>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [

* @param acc initial value
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* reduce(x, (acc, v) => acc+v);
* // 10
*
* reduce(x, (acc, v) => acc+v, 100);
* // 110
* ```
*/

@@ -425,2 +939,11 @@ export function reduce<T, U, V = U>(x: Lists<T, U>, fr: reduceFn<T, U, U | V>, acc?: U | V): U | V;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* reject(x, v => v % 2 === 1);
* // [ [ 'b', 'd' ], [ 2, 4 ] ]
*
* reject(x, v => v % 2 === 0);
* // [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]
* ```
*/

@@ -433,2 +956,11 @@ export function reject<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Lists<T, U>;

* @param ks keys
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
* rejectAt(x, ['a', 'c', 'e']);
* // [ [ 'b', 'd' ], [ 2, 4 ] ]
*
* rejectAt(x, ['b', 'd']);
* // [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]
* ```
*/

@@ -441,2 +973,11 @@ export function rejectAt<T, U>(x: Lists<T, U>, ks: T[]): Lists<T, U>;

* @param k key
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [2, 4, 6, 8]];
* remove(x, 'b');
* // [ [ 'a', 'c', 'd' ], [ 2, 6, 8 ] ]
*
* remove(x, 'd');
* // [ [ 'a', 'b', 'c' ], [ 2, 4, 6 ] ]
* ```
*/

@@ -449,2 +990,11 @@ export function remove<T, U>(x: Lists<T, U>, k: T): Lists<T, U>;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 2]];
* scanUntil(x, v => v % 2 === 0);
* // 'b' ^
*
* scanUntil(x, v => v % 8 === 0);
* // undefined
* ```
*/

@@ -457,2 +1007,11 @@ export function scanUntil<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 2]];
* scanWhile(x, v => v % 2 !== 0);
* // 'b' ^
*
* scanWhile(x, v => v % 8 !== 0);
* // undefined
* ```
*/

@@ -465,2 +1024,11 @@ export function scanWhile<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 2]];
* search(x, v => v === 2);
* // 'b' ^
*
* search(x, v => v === 4);
* // undefined
* ```
*/

@@ -473,2 +1041,11 @@ export function search<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, -2]];
* [...searchAll(x, v => v === 2)];
* // [ 'b' ] ^
*
* [...searchAll(x, v => Math.abs(v) === 2)];
* // [ 'b', 'd' ] ^ ^
* ```
*/

@@ -483,2 +1060,14 @@ export function searchAll<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Iterable<T>;

* @param fm map function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, -2, 3, 2, 5]];
* searchValue(x, 2);
* // 'd' ^
*
* searchValue(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
* // 'b' ^
*
* searchValue(x, 2, null, v => Math.abs(v));
* // 'b' ^
* ```
*/

@@ -493,2 +1082,14 @@ export function searchValue<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): T;

* @param fm map function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd', 'e'], [1, -2, 3, 2, 5]];
* [...searchValueAll(x, 2)];
* // [ 'd' ] ^
*
* [...searchValueAll(x, 2, (a, b) => Math.abs(a) - Math.abs(b))];
* // [ 'b', 'd' ] ^ ^
*
* [...searchValueAll(x, 2, null, v => Math.abs(v))];
* // [ 'b', 'd' ] ^ ^
* ```
*/

@@ -502,2 +1103,11 @@ export function searchValueAll<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): Iterable<T>;

* @param v value
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [2, 4, 6, 8]];
* set(x, 'b', 40);
* // [ [ 'a', 'b', 'c', 'd' ], [ 2, 40, 6, 8 ] ]
*
* set(x, 'd', 80);
* // [ [ 'a', 'b', 'c', 'd' ], [ 2, 4, 6, 80 ] ]
* ```
*/

@@ -509,2 +1119,12 @@ export function set<T, U>(x: Lists<T, U>, k: T, v: U): Lists<T, U>;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* shift(x).map(c => [...c]);
* // [ [ 'b', 'c' ], [ 2, 3 ] ]
*
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* shift(x).map(c => [...c]);
* // [ [ 'b', 'c', 'd' ], [ 2, 3, 4 ] ]
* ```
*/

@@ -516,2 +1136,8 @@ export function shift<T, U>(x: Lists<T, U>): Lists<T, U>;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* size(x);
* // 3
* ```
*/

@@ -524,2 +1150,11 @@ export function size<T, U>(x: Lists<T, U>): number;

* @param ft test function (v, k, x)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
* some(x, v => v > 10);
* // false
*
* some(x, v => v < 0);
* // true
* ```
*/

@@ -533,2 +1168,14 @@ export function some<T, U>(x: Lists<T, U>, ft?: testFn<T, U>): boolean;

* @param r random seed 0->1
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* subset(x).map(c => [...c]);
* // [ [ 'b', 'c' ], [ 2, 3 ] ]
*
* subset(x, 3, 0.3).map(c => [...c]);
* // [ [ 'a', 'b', 'd' ], [ 1, 2, 4 ] ]
*
* subset(x, 2, 0.3).map(c => [...c]);
* // [ [ 'b', 'd' ], [ 2, 4 ] ]
* ```
*/

@@ -541,2 +1188,26 @@ export function subset<T, U>(x: Lists<T, U>, n?: number, r?: number): Lists<T, U>;

* @param n number of entries (-1 => any)
* @example
* ```javascript
* var x = [['a', 'b'], [1, 2]];
* [...subsets(x)].map(a => [[...a[0]], [...a[1]]]);
* // [
* // [ [], [] ],
* // [ [ 'a' ], [ 1 ] ],
* // [ [ 'b' ], [ 2 ] ],
* // [ [ 'a', 'b' ], [ 1, 2 ] ]
* // ]
*
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* [...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 ] ]
* // ]
* ```
*/

@@ -550,2 +1221,11 @@ export function subsets<T, U>(x: Lists<T, U>, n?: number): Iterable<Lists<T, U>>;

* @param l another key
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* swap(x, 'a', 'b').map(c => [...c]);
* // [ [ 'b', 'a', 'c', 'd' ], [ 1, 2, 3, 4 ] ]
*
* swap(x, 'a', 'd').map(c => [...c]);
* // [ [ 'd', 'b', 'c', 'a' ], [ 1, 2, 3, 4 ] ]
* ```
*/

@@ -558,2 +1238,13 @@ export function swap<T, U>(x: Lists<T, U>, k: T, l: T): Lists<T, U>;

* @param y another lists
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* var y = [['c', 'd', 'e', 'f'], [30, 40, 50, 60]];
* symmetricDifference(x, y).map(c => [...c]);
* // [ [ 'a', 'b', 'e', 'f' ], [ 1, 2, 50, 60 ] ]
*
* var y = [['d', 'e', 'f'], [40, 50, 60]];
* symmetricDifference(x, y).map(c => [...c]);
* // [ [ 'a', 'b', 'c', 'e', 'f' ], [ 1, 2, 3, 50, 60 ] ]
* ```
*/

@@ -565,2 +1256,12 @@ export function symmetricDifference<T, U>(x: Lists<T, U>, y: Lists<T, U>): Lists<T, U>;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* tail(x).map(c => [...c]);
* // [ [ 'b', 'c' ], [ 2, 3 ] ]
*
* var x = [['a'], [1]];
* tail(x).map(c => [...c]);
* // [ [], [] ]
* ```
*/

@@ -573,2 +1274,11 @@ export function tail<T, U>(x: Lists<T, U>): Lists<T, U>;

* @param n number of entries (1)
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* take(x, 2).map(c => [...c]);
* // [ [ 'a', 'b' ], [ 1, 2 ] ]
*
* take(x, 3).map(c => [...c]);
* // [ [ 'a', 'b', 'c' ], [ 1, 2, 3 ] ]
* ```
*/

@@ -582,2 +1292,12 @@ export function take<T, U>(x: Lists<T, U>, n?: number): Lists<T, U>;

* @param fc combine function (a, b)
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* var y = [['b', 'c', 'd'], [20, 30, 40]];
* union(x, y).map(v => [...v]);
* // [ [ 'a', 'b', 'c', 'd' ], [ 1, 2, 3, 40 ] ]
*
* union(x, y, (a, b) => b).map(v => [...v]);
* // [ [ 'a', 'b', 'c', 'd' ], [ 1, 20, 30, 40 ] ]
* ```
*/

@@ -589,2 +1309,9 @@ export function union<T, U>(x: Lists<T, U>, y: Lists<T, U>, fc?: combineFn<U>): Lists<T, U>;

* @param xs n lists
* @example
* ```javascript
* var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
* var y = [['b', 'c', 'e'], [20, 30, 50]];
* unionKeys(x, y);
* // Set(5) { 'a', 'b', 'c', 'd', 'e' }
* ```
*/

@@ -597,2 +1324,11 @@ export function unionKeys<T, U>(...xs: Lists<T, U>[]): Set<T>;

* @param r random seed 0->1
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* value(x);
* // 3
*
* value(x, 0.5);
* // 2
* ```
*/

@@ -604,2 +1340,8 @@ export function value<T, U>(x: Lists<T, U>, r?: number): U;

* @param x lists
* @example
* ```javascript
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* [...values(x)];
* // [ 1, 2, 3 ]
* ```
*/

@@ -614,2 +1356,20 @@ export function values<T, U>(x: Lists<T, U>): Iterable<U>;

* @param vd default value
* @example
* ```javascript
* const array = require('extra-array');
*
* var x = [['a', 'b', 'c'], [1, 2, 3]];
* var y = [['a', 'b'], [10, 20]];
* zip([x, y]).map(c => [...c]);
* // [ [ 'a', 'b' ], [ [ 1, 10 ], [ 2, 20 ] ] ] (shortest)
*
* zip([x, y], ([a, b]) => a + b).map(c => [...c]);
* // [ [ 'a', 'b' ], [ 11, 22 ] ]
*
* zip([x, y], null, array.some).map(c => [...c]);
* // [ [ 'a', 'b' ], [ [ 1, 10 ], [ 2, 20 ] ] ] (shortest)
*
* zip([x, y], null, array.every, 0).map(c => [...c]);
* // [ [ 'a', 'b', 'c' ], [ [ 1, 10 ], [ 2, 20 ], [ 3, 0 ] ] ] (longest)
* ```
*/

@@ -616,0 +1376,0 @@ export function zip<T, U, V = U>(xs: Lists<T, U>[], fm?: mapFn<T, U[], U[] | V>, ft?: tillFn, vd?: U): Lists<T, U[] | V>;

4

package.json
{
"name": "extra-lists",
"version": "2.2.9",
"version": "2.2.10",
"description": "Lists is a pair of key list and value list, with unique keys.",

@@ -101,3 +101,3 @@ "main": "index.js",

"extra-array": "^2.10.16",
"extra-build": "^1.3.27",
"extra-build": "^1.3.30",
"extra-entries": "^2.2.17",

@@ -104,0 +104,0 @@ "extra-iterable": "^2.5.21",

@@ -11,8 +11,5 @@ [Lists] is a pair of key list and value list, with unique keys.<br>

In this fourth Crust of Rust video, we cover smart pointers and interior
mutability, by re-implementing the Cell, RefCell, and Rc types from the
standard library. As part of that, we cover when those types are useful,
how they work, and what the equivalent thread-safe versions of these types
are. In the process, we go over some of the finer details of Rust's
ownership model, and the UnsafeCell type. [(1)]
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.

@@ -116,4 +113,5 @@ Methods as separate packages:

[(1)]: https://www.youtube.com/watch?v=8O0Nt9qY_vo
[Lists]: https://www.npmjs.com/package/@extra-lists/is
[entries]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries
[v8]: https://v8.dev
[browserify]: https://www.npmjs.com/package/browserify

@@ -120,0 +118,0 @@ [rollup]: https://www.npmjs.com/package/rollup

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