extra-lists
Advanced tools
Comparing version 2.0.74 to 2.0.75
371
index.d.ts
declare module 'extra-lists' { | ||
export type Lists<T, U> = [Iterable<T>, Iterable<U>]; | ||
export type reduceFn<T, U, V> = (acc: V, v: U, k: T, x: Lists<T, U>) => V; | ||
@@ -7,7 +6,32 @@ export type calledFn<T, U> = (v: U, k: T, x: Lists<T, U>) => void; | ||
export type mapFn<T, U, V> = (v: U, k: T, x: Lists<T, U>) => V; | ||
export type combineFn<T> = (a: T, b: T) => T; | ||
export type compareFn<T> = (a: T, b: T) => number; | ||
export type Entries<T, U> = Iterable<[T, U]>; | ||
export type Lists<T, U> = [Iterable<T>, Iterable<U>]; | ||
/** | ||
* Appends lists' together. | ||
* @param xs lists' | ||
* Lists cartesian product of maps. | ||
* @param xs maps | ||
* @param fn map function (vs, i) | ||
*/ | ||
export function cartesianProduct<T, U, V = U>(xs: Map<T, U>[], fn?: mapFn<number, Map<T, U>, Map<T, U> | V>): IterableIterator<Map<T, U> | V>; | ||
/** | ||
* Breaks lists into chunks of given size. | ||
* @param x lists | ||
* @param n chunk size (1) | ||
* @param s chunk step (n) | ||
*/ | ||
export function chunk<T, U>(x: Lists<T, U>, n?: number, s?: number): Lists<T, U>[]; | ||
/** | ||
* Compares two lists. | ||
* @param x lists | ||
* @param y another lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
* @returns x=y: 0, otherwise: -ve/+ve | ||
*/ | ||
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; | ||
/** | ||
* Appends entries from all lists. | ||
* @param xs n lists | ||
*/ | ||
export function concat<T, U>(...xs: Lists<T, U>[]): Lists<T, U>; | ||
@@ -17,47 +41,92 @@ /** | ||
* @param x lists | ||
* @param fn test function (v, k, x) | ||
* @param ths this argument | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function count<T, U>(x: Lists<T, U>, fn: testFn<T, U>, ths?: object): number; | ||
export function count<T, U>(x: Lists<T, U>, ft: testFn<T, U>): number; | ||
/** | ||
* Counts occurrences of values. | ||
* @param x lists | ||
* @param fn map function (v, k, x) | ||
* @param ths this argument | ||
* @param fm map function (v, k, x) | ||
* @returns Map {value => count} | ||
*/ | ||
export function countAs<T, U, V = U>(x: Lists<T, U>, fn?: mapFn<T, U, U | V>, ths?: object): Map<U | V, number>; | ||
export function countAs<T, U, V = U>(x: Lists<T, U>, fm?: mapFn<T, U, U | V>): Map<U | V, number>; | ||
/** | ||
* Gives entries of lists not present in another. | ||
* @param x lists | ||
* @param y another lists | ||
*/ | ||
export function difference<T, U>(x: Lists<T, U>, y: Lists<T, U>): Lists<T, U>; | ||
/** | ||
* Removes first n entries. | ||
* @param x lists | ||
* @param n number of entries (1) | ||
*/ | ||
export function drop<T, U>(x: Lists<T, U>, n?: number): Lists<T, U>; | ||
/** | ||
* Lists all key-value pairs. | ||
* @param x lists | ||
*/ | ||
export function entries<T, U>(x: Lists<T, U>): Iterable<[T, U]>; | ||
export function entries<T, U>(x: Lists<T, U>): Entries<T, U>; | ||
/** | ||
* Picks an arbitrary entry. | ||
* @param x lists | ||
* @param r random seed 0->1 | ||
*/ | ||
export function entry<T, U>(x: Lists<T, U>, r?: number): [T, U]; | ||
/** | ||
* Checks if all values satisfy a test. | ||
* @param x lists | ||
* @param fn test function (v, k ,x) | ||
* @param ths this argument | ||
* @param ft test function (v, k ,x) | ||
*/ | ||
export function every<T, U>(x: Lists<T, U>, fn: testFn<T, U>, ths?: object): boolean; | ||
export function every<T, U>(x: Lists<T, U>, ft: testFn<T, U>): boolean; | ||
/** | ||
* Fills with given value. | ||
* Keeps entries which pass a test. | ||
* @param x lists | ||
* @param v value | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function fill<T, U>(x: Lists<T, U>, v: U): Lists<T, U>; | ||
export function filter<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Lists<T, U>; | ||
/** | ||
* Finds first value passing a test. | ||
* Gets lists with given keys. | ||
* @param x lists | ||
* @param fn test function (v, k, x) | ||
* @param ths this argument | ||
* @param ks keys | ||
*/ | ||
export function find<T, U>(x: Lists<T, U>, fn: testFn<T, U>, ths?: object): U; | ||
export function filterAt<T, U>(x: Lists<T, U>, ks: T[]): Lists<T, U>; | ||
/** | ||
* Finds a value passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function find<T, U>(x: Lists<T, U>, ft: testFn<T, U>): U; | ||
/** | ||
* Finds values passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function findAll<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Iterable<U>; | ||
/** | ||
* Flattens nested lists to given depth. | ||
* @param x nested lists | ||
* @param n maximum depth (-1) | ||
* @param fm map function (v, k, x) | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function flat<T>(x: Lists<T, any>, n?: number, fm?: mapFn<T, any, any>, ft?: testFn<T, any>): Lists<T, any>; | ||
/** | ||
* Flattens nested lists, using map function. | ||
* @param x nested lists | ||
* @param fm map function (v, k, x) | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function flatMap<T>(x: Lists<T, any>, fm?: mapFn<T, any, any>, ft?: testFn<T, any>): Lists<T, any>; | ||
/** | ||
* Calls a function for each value. | ||
* @param x lists | ||
* @param fn called function (v, k, x) | ||
* @param ths this argument | ||
* @param fc called function (v, k, x) | ||
*/ | ||
export function forEach<T, U>(x: Lists<T, U>, fn: calledFn<T, U>, ths?: object): void; | ||
export function forEach<T, U>(x: Lists<T, U>, fc: calledFn<T, U>): void; | ||
/** | ||
* Creates lists from entries. | ||
* @param es entries | ||
*/ | ||
export function fromEntries<T, U>(es: Entries<T, U>): Lists<T, U>; | ||
/** | ||
* Gets value at key. | ||
@@ -73,4 +142,17 @@ * @param x lists | ||
*/ | ||
export function getAll<T, U>(x: Lists<T, U>, ks: Iterable<T>): IterableIterator<U>; | ||
export function getAll<T, U>(x: Lists<T, U>, ks: T[]): Iterable<U>; | ||
/** | ||
* Gets first entry. | ||
* @param x lists | ||
* @param ed default entry | ||
*/ | ||
export function head<T, U>(x: Lists<T, U>, ed?: [T, U]): [T, U]; | ||
/** | ||
* Gives entries present in both lists. | ||
* @param x lists | ||
* @param y another lists | ||
* @param fc combine function (a, b) | ||
*/ | ||
export function intersection<T, U>(x: Lists<T, U>, y: Lists<T, U>, fc?: combineFn<U>): Lists<T, U>; | ||
/** | ||
* Checks if value is lists. | ||
@@ -81,19 +163,64 @@ * @param v value | ||
/** | ||
* Checks if value is many iterable. | ||
* @param v a value | ||
* Checks if maps have no common keys. | ||
* @param x a map | ||
* @param y another map | ||
*/ | ||
export function isMany(v: any): boolean; | ||
export function isDisjoint<T, U>(x: Map<T, U>, y: Map<T, U>): boolean; | ||
/** | ||
* Checks if value is once iterable lists. | ||
* @param v a value | ||
* Checks if lists is empty. | ||
* @param x lists | ||
*/ | ||
export function isOnce(v: any): boolean; | ||
export function isEmpty<T, U>(x: Lists<T, U>): boolean; | ||
/** | ||
* Checks if map has an entry. | ||
* @param x a map | ||
* @param e entry? | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
export function isEntry<T, U, V = U>(x: Lists<T, U>, e: [T, U], fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean; | ||
/** | ||
* Checks if two lists are equal. | ||
* @param x lists | ||
* @param y another lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
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; | ||
/** | ||
* Checks if lists has a key. | ||
* @param x lists | ||
* @param k key? | ||
*/ | ||
export function isKey<T, U>(x: Lists<T, U>, k: T): boolean; | ||
/** | ||
* Checks if lists has a submap. | ||
* @param x lists | ||
* @param y submap? | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
export function isSubmap<T, U, V = U>(x: Lists<T, U>, y: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean; | ||
/** | ||
* Checks if lists has a value. | ||
* @param x lists | ||
* @param v value? | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
export function isValue<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean; | ||
/** | ||
* Joins values together. | ||
* @param x lists | ||
* @param sep separator (,) | ||
* @param asc associator | ||
* @param asc associator (=) | ||
*/ | ||
export function join<T, U>(x: Lists<T, U>, sep?: string, asc?: string): string; | ||
/** | ||
* Picks an arbitrary key. | ||
* @param x lists | ||
* @param r random seed 0->1 | ||
*/ | ||
export function key<T, U>(x: Lists<T, U>, r?: number): T; | ||
/** | ||
* Lists all keys. | ||
@@ -104,8 +231,6 @@ * @param x lists | ||
/** | ||
* Counts the number of values. | ||
* Gets size of lists. | ||
* @param x lists | ||
* @param i start index (0) | ||
* @param I end index (end) | ||
*/ | ||
export function length<T, U>(x: Lists<T, U>, i?: number, I?: number): number; | ||
export function length<T, U>(x: Lists<T, U>): number; | ||
/** | ||
@@ -115,30 +240,101 @@ * Updates values based on map function. | ||
* @param fn map function (v, k, x) | ||
* @param ths this argument | ||
*/ | ||
export function map<T, U, V>(x: Lists<T, U>, fn: mapFn<T, U, V>, ths?: object): Generator<never, void, unknown>; | ||
s */ | ||
export function map<T, U, V>(x: Lists<T, U>, fn: mapFn<T, U, V>): Generator<never, void, unknown>; | ||
/** | ||
* Finds largest value. | ||
* @param x an iterable | ||
* @param x lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, i, x) | ||
* @param fm map function (v, k, x) | ||
* @returns [key, value] | ||
*/ | ||
export function max<T, U, V = U>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): U; | ||
export function max<T, U, V = U>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [T, U]; | ||
/** | ||
* Finds smallest entry. | ||
* @param x lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
* @returns [key, value] | ||
*/ | ||
export function min<T, U, V = U>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [T, U]; | ||
/** | ||
* Segregates values by test result. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
* @returns [satisfies, doesnt] | ||
*/ | ||
export function partition<T, U>(x: Lists<T, U>, ft: testFn<T, U>): [Lists<T, U>, Lists<T, U>]; | ||
/** | ||
* Segregates values by similarity. | ||
* @param x lists | ||
* @param fm map function (v, k, x) | ||
* @returns Map {key => values} | ||
*/ | ||
export function partitionAs<T, U, V = U>(x: Lists<T, U>, fm?: mapFn<T, U, U | V>): Map<U | V, Lists<T, U>>; | ||
/** | ||
* Finds smallest and largest entries. | ||
* @param x lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
* @returns [smallest, largest] | ||
*/ | ||
export function range<T, U, V = U>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [[T, U], [T, U]]; | ||
/** | ||
* Reduces values to a single value. | ||
* @param x lists | ||
* @param fn reduce function (acc, v, k, x) | ||
* @param fr reduce function (acc, v, k, x) | ||
* @param acc initial value | ||
*/ | ||
export function reduce<T, U, V>(x: Lists<T, U>, fn: reduceFn<T, U, V>, acc?: V): V; | ||
export function reduce<T, U, V = U>(x: Lists<T, U>, fr: reduceFn<T, U, U | V>, acc?: U | V): U | V; | ||
/** | ||
* Searches a value. | ||
* Discards entries which pass a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function reject<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Lists<T, U>; | ||
/** | ||
* Gets lists without given keys. | ||
* @param x lists | ||
* @param ks keys | ||
*/ | ||
export function rejectAt<T, U>(x: Lists<T, U>, ks: T[]): Lists<T, U>; | ||
/** | ||
* Deletes an entry. | ||
* @param x lists | ||
* @param k key | ||
*/ | ||
export function remove<T, U>(x: Lists<T, U>, k: T): Lists<T, U>; | ||
/** | ||
* Finds key of first entry not passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function scanUntil<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T; | ||
/** | ||
* Finds key of first entry not passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function scanWhile<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T; | ||
/** | ||
* Finds key of an entry passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function search<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T; | ||
/** | ||
* Finds keys of entries passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function searchAll<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Iterable<T>; | ||
/** | ||
* Finds key with given value. | ||
* @param x lists | ||
* @param v search value | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
* @returns key of value | ||
*/ | ||
export function search<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): T; | ||
export function searchValue<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): T; | ||
/** | ||
* Searches a value throughout. | ||
* Finds keys with given value. | ||
* @param x lists | ||
@@ -148,20 +344,83 @@ * @param v search value | ||
* @param fm map function (v, k, x) | ||
* @returns keys of value | ||
*/ | ||
export function searchAll<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): IterableIterator<T>; | ||
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>; | ||
/** | ||
* Gets size of part of lists. | ||
* Sets value at key. | ||
* @param x lists | ||
* @param i start index (-ve: from right) (0) | ||
* @param I end index (-ve: from right) (end) | ||
* @param k key | ||
* @param v value | ||
*/ | ||
export function size<T, U>(x: Lists<T, U>, i?: number, I?: number): number; | ||
export function set<T, U>(x: Lists<T, U>, k: T, v: U): Lists<T, U>; | ||
/** | ||
* Removes first entry. | ||
* @param x lists | ||
*/ | ||
export function shift<T, U>(x: Lists<T, U>): Lists<T, U>; | ||
/** | ||
* Gets size of lists. | ||
* @param x lists | ||
*/ | ||
export function size<T, U>(x: Lists<T, U>): number; | ||
/** | ||
* Checks if any value satisfies a test. | ||
* @param x lists | ||
* @param fn test function (v, k ,x) | ||
* @param ths this argument | ||
* @param ft test function (v, k, x) | ||
*/ | ||
export function some<T, U>(x: Lists<T, U>, fn?: testFn<T, U>, ths?: object): boolean; | ||
export function some<T, U>(x: Lists<T, U>, ft?: testFn<T, U>): boolean; | ||
/** | ||
* Picks an arbitrary submap. | ||
* @param x lists | ||
* @param n number of entries (-1 => any) | ||
* @param r random seed 0->1 | ||
*/ | ||
export function submap<T, U>(x: Lists<T, U>, n?: number, r?: number): Lists<T, U>; | ||
/** | ||
* Lists all possible submaps. | ||
* @param x lists | ||
* @param n number of entries (-1 => any) | ||
*/ | ||
export function submaps<T, U>(x: Lists<T, U>, n?: number): Iterable<Lists<T, U>>; | ||
/** | ||
* Exchanges two values. | ||
* @param x lists | ||
* @param k a key | ||
* @param l another key | ||
*/ | ||
export function swap<T, U>(x: Lists<T, U>, k: T, l: T): Lists<T, U>; | ||
/** | ||
* Gives entries not present in both lists. | ||
* @param x lists | ||
* @param y another lists | ||
*/ | ||
export function symmetricDifference<T, U>(x: Lists<T, U>, y: Lists<T, U>): Lists<T, U>; | ||
/** | ||
* Gets lists without the first entry. | ||
* @param x lists | ||
*/ | ||
export function tail<T, U>(x: Lists<T, U>): Lists<T, U>; | ||
/** | ||
* Keeps first n entries only. | ||
* @param x lists | ||
* @param n number of entries (1) | ||
*/ | ||
export function take<T, U>(x: Lists<T, U>, n?: number): Lists<T, U>; | ||
/** | ||
* Gives lists present in any lists. | ||
* @param x lists | ||
* @param y another lists | ||
* @param fc combine function (a, b) | ||
*/ | ||
export function union<T, U>(x: Lists<T, U>, y: Lists<T, U>, fc?: combineFn<U>): Lists<T, U>; | ||
/** | ||
* Gives keys present in any lists. | ||
* @param xs n lists | ||
*/ | ||
export function unionKeys<T, U>(...xs: Lists<T, U>[]): Set<T>; | ||
/** | ||
* Picks an arbitrary value. | ||
* @param x lists | ||
* @param r random seed 0->1 | ||
*/ | ||
export function value<T, U>(x: Lists<T, U>, r?: number): U; | ||
/** | ||
* Lists all values. | ||
@@ -168,0 +427,0 @@ * @param x lists |
2123
index.js
@@ -5,16 +5,114 @@ 'use strict'; | ||
const END = Number.MAX_SAFE_INTEGER; | ||
function id(v) { | ||
return v; | ||
} | ||
function is(v) { | ||
return v != null && typeof v[Symbol.iterator] === 'function'; | ||
function* cartesianProduct(xs, fn = null) { | ||
var fn = fn || id; | ||
var XS = xs.length; | ||
var kss = xs.map(x => [...x.keys()]); | ||
var ls = kss.map(ks => ks.length); | ||
var is = kss.map(ks => 0); | ||
for (var j = 0;; j++) { | ||
var a = new Map(); | ||
for (var n = 0; n < XS; n++) { | ||
var i = is[n], x = xs[n]; | ||
var ks = kss[n], k = ks[i]; | ||
a.set(k, x.get(k)); | ||
} | ||
yield fn(a, j, null); | ||
for (var r = XS - 1; r >= 0; r--) { | ||
is[r]++; | ||
if (is[r] < ls[r]) | ||
break; | ||
is[r] = 0; | ||
} | ||
if (r < 0) | ||
break; | ||
} | ||
} | ||
function isOnce(v) { | ||
return is(v) && v === v[Symbol.iterator](); | ||
function keys(x) { | ||
return x[0]; | ||
} | ||
function id(v) { | ||
function values(x) { | ||
return x[1]; | ||
} | ||
function someIf(x) { | ||
for (var v of x) | ||
if (v) | ||
return true; | ||
return false; | ||
} | ||
function someTest(x, fn) { | ||
var i = -1; | ||
for (var v of x) | ||
if (fn(v, ++i, x)) | ||
return true; | ||
return false; | ||
} | ||
function some(x, fn = null) { | ||
if (fn) | ||
return someTest(x, fn); | ||
else | ||
return someIf(x); | ||
} | ||
function id$1(v) { | ||
return v; | ||
} | ||
function chunk(x, n = 1, s = n) { | ||
var a = []; | ||
for (var i = 0, I = x.length; i < I; i += s) | ||
a.push(x.slice(i, i + n)); | ||
return a; | ||
} | ||
function some$1(x, fn) { | ||
return some(x, fn); | ||
} | ||
function value(x, r = Math.random()) { | ||
var i = Math.floor(r * x.length); | ||
return x[i]; | ||
} | ||
function zip(xs, fm = null, ft = null, vd) { | ||
var fm = fm || id$1, ft = ft || some$1; | ||
var X = xs.length, a = []; | ||
if (X === 0) | ||
return a; | ||
var ds = new Array(X).fill(false); | ||
var ls = xs.map(x => x.length); | ||
for (var i = 0;; i++) { | ||
for (var j = 0, vs = []; j < X; j++) { | ||
ds[j] = i >= ls[j]; | ||
vs[j] = ds[j] ? vd : xs[j][i]; | ||
} | ||
if (ft(ds)) | ||
break; | ||
a.push(fm(vs, i, null)); | ||
} | ||
return a; | ||
} | ||
function chunk$1(x, n = 1, s = n) { | ||
var kss = chunk([...keys(x)], n, s); | ||
var vss = chunk([...values(x)], n, s); | ||
return zip([kss, vss]); | ||
} | ||
function* entries(x) { | ||
var vi = values(x)[Symbol.iterator](); | ||
for (var k of keys(x)) | ||
yield [k, vi.next().value]; | ||
} | ||
function id$2(v) { | ||
return v; | ||
} | ||
function cmp(a, b) { | ||
@@ -24,2 +122,56 @@ return a < b ? -1 : (a > b ? 1 : 0); | ||
function unionKeys(...xs) { | ||
var a = new Set(); | ||
for (var x of xs) { | ||
for (var [k] of x) | ||
a.add(k); | ||
} | ||
return a; | ||
} | ||
function compare(x, y, fc = null, fm = null) { | ||
var fc = fc || cmp, fm = fm || id$2; | ||
var ks = unionKeys(x, y); | ||
for (var k of ks) { | ||
if (!x.has(k)) | ||
return -1; | ||
if (!y.has(k)) | ||
return 1; | ||
var u = fm(x.get(k), k, x); | ||
var v = fm(y.get(k), k, y); | ||
var c = fc(u, v); | ||
if (c !== 0) | ||
return c; | ||
} | ||
return 0; | ||
} | ||
function compare$1(x, y, fc = null, fm = null) { | ||
return compare(new Map(x), new Map(y), fc, fm); | ||
} | ||
function get$1(x, k) { | ||
for (var [j, u] of x) | ||
if (k === j) | ||
return u; | ||
} | ||
function compare$2(x, y, fc, fm) { | ||
return compare$1(entries(x), entries(y), fc, fm); | ||
} | ||
const END = Number.MAX_SAFE_INTEGER; | ||
function is(v) { | ||
return v != null && typeof v[Symbol.iterator] === 'function'; | ||
} | ||
function id$3(v) { | ||
return v; | ||
} | ||
function cmp$1(a, b) { | ||
return a < b ? -1 : (a > b ? 1 : 0); | ||
} | ||
function* concat(...xs) { | ||
@@ -30,2 +182,48 @@ for (var x of xs) | ||
function* slicePos(x, i, I) { | ||
var k = -1; | ||
for (var v of x) { | ||
if (++k >= I) | ||
break; | ||
if (k >= i) | ||
yield v; | ||
} | ||
} | ||
function* slicePosNeg(x, i, I) { | ||
var j = 0, k = -1; | ||
var a = [], A = -I; | ||
for (var v of x) { | ||
if (++k < i) | ||
continue; | ||
if (a.length >= A) | ||
yield a[j]; | ||
a[j] = v; | ||
j = (j + 1) % A; | ||
} | ||
} | ||
function* sliceNeg(x, i, I) { | ||
var j = 0, n = 0; | ||
var a = [], A = -i; | ||
for (var v of x) { | ||
a[j] = v; | ||
j = (j + 1) % A; | ||
n++; | ||
} | ||
if (n < A) | ||
return; | ||
var I = I < 0 ? I : Math.min(I - n, 0); | ||
var n = Math.max(I - i, 0); | ||
var J = Math.max(j + n - A, 0); | ||
yield* a.slice(j, j + n); | ||
yield* a.slice(0, J); | ||
} | ||
function* slice(x, i = 0, I = END) { | ||
if (i >= 0 && I >= 0) | ||
yield* slicePos(x, i, I); | ||
else if (i >= 0 && I < 0) | ||
yield* slicePosNeg(x, i, I); | ||
else | ||
yield* sliceNeg(x, i, I); | ||
} | ||
function size(x, i = 0, I = END) { | ||
@@ -39,2 +237,12 @@ var j = -1, n = 0; | ||
function* map(x, fn) { | ||
var i = -1; | ||
for (var v of x) | ||
yield fn(v, ++i, x); | ||
} | ||
function* drop(x, n = 1) { | ||
yield* slice(x, n); | ||
} | ||
function isList(v) { | ||
@@ -44,27 +252,77 @@ return is(v) && typeof v !== 'string'; | ||
function max(x, fc = null, fm = null) { | ||
var fc = fc || cmp, fm = fm || id; | ||
var mk, mv, i = -1; | ||
for (var v of x) { | ||
var k = fm(v, ++i, x); | ||
if (i === 0 || fc(k, mk) > 0) { | ||
mk = k; | ||
mv = v; | ||
} | ||
function head(x, vd) { | ||
for (var v of x) | ||
return v; | ||
return vd; | ||
} | ||
function searchValue(x, v, fc = null, fm = null) { | ||
var fc = fc || cmp$1, fm = fm || id$3; | ||
var v1 = fm(v, 0, null), i = -1; | ||
for (var u of x) { | ||
var u1 = fm(u, ++i, x); | ||
if (fc(u1, v1) === 0) | ||
return i; | ||
} | ||
return mv; | ||
return -1; | ||
} | ||
function isValue(x, v, fc = null, fm = null) { | ||
return searchValue(x, v, fc, fm) >= 0; | ||
} | ||
function isEmpty(x) { | ||
for (var _ of x) | ||
return false; | ||
return true; | ||
} | ||
function* take(x, n = 1) { | ||
yield* slice(x, 0, n); | ||
} | ||
function concat$1(...xs) { | ||
var kss = xs.map(x => x[0]); | ||
var vss = xs.map(x => x[1]); | ||
return [concat(...kss), concat(...vss)]; | ||
var ks = concat(...xs.map(keys)); | ||
var vs = concat(...xs.map(values)); | ||
return [ks, vs]; | ||
} | ||
function count(x, fn, ths = null) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](), a = 0; | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
if (fn.call(ths, v, k, x)) | ||
function id$4(v) { | ||
return v; | ||
} | ||
function filterAt(x, ks) { | ||
var a = new Map(); | ||
for (var k of ks) | ||
a.set(k, x.get(k)); | ||
return a; | ||
} | ||
function cmp$2(a, b) { | ||
return a < b ? -1 : (a > b ? 1 : 0); | ||
} | ||
function concat$(x, ...ys) { | ||
for (var y of ys) { | ||
for (var [k, v] of y) | ||
x.set(k, v); | ||
} | ||
return x; | ||
} | ||
function count(x, fn) { | ||
var a = 0; | ||
for (var [k, v] of x) | ||
if (fn(v, k, x)) | ||
a++; | ||
return a; | ||
} | ||
function countAs(x, fm) { | ||
var fm = fm || id$4; | ||
var a = new Map(); | ||
for (var [k, v] of x) { | ||
var v1 = fm(v, k, x); | ||
var n = a.get(v1) || 0; | ||
a.set(v1, n + 1); | ||
} | ||
@@ -74,158 +332,1405 @@ return a; | ||
function id$1(v) { | ||
return v; | ||
function index(x, i = 0) { | ||
return i < 0 ? Math.max(x.length + i, 0) : Math.min(i, x.length); | ||
} | ||
function countAs(x, fn = null, ths = null) { | ||
var fn = fn || id$1; | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](), a = new Map(); | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
var v1 = fn.call(ths, v, k, x); | ||
a.set(v1, (a.get(v1) || 0) + 1); | ||
function fromRange(v, V = v, s = 1) { | ||
var a = []; | ||
if (s >= 0) { | ||
for (; v < V; v += s) | ||
a.push(v); | ||
} | ||
else { | ||
for (; v > V; v += s) | ||
a.push(v); | ||
} | ||
return a; | ||
} | ||
function* entries(x) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
yield [k, v]; | ||
function get(x, i) { | ||
return x[index(x, i)]; | ||
} | ||
function getAll(x, is) { | ||
var a = []; | ||
for (var i of is) | ||
a.push(get(x, i)); | ||
return a; | ||
} | ||
function random(r) { | ||
var a = Math.floor(r * 2 ** 31); | ||
return function () { | ||
var t = a += 0x6D2B79F5; | ||
t = Math.imul(t ^ t >>> 15, t | 1); | ||
t ^= t + Math.imul(t ^ t >>> 7, t | 61); | ||
return ((t ^ t >>> 14) >>> 0) / 4294967296; | ||
}; | ||
} | ||
function permutation$(x, n = -1, r = Math.random()) { | ||
if (n > x.length) | ||
return x; | ||
var X = x.length, rnd = random(r); | ||
var n = n >= 0 ? n : Math.floor((X + 1) * rnd()); | ||
for (var i = 0; i < n; i++) { | ||
var j = i + Math.floor((X - i) * rnd()); | ||
var t = x[i]; | ||
x[i] = x[j]; | ||
x[j] = t; | ||
} | ||
x.length = n; | ||
return x; | ||
} | ||
function everyIf(x) { | ||
for (var v of x[1]) | ||
if (!v) | ||
function subsequenceNum(x, n, r) { | ||
var is = fromRange(0, x.length, 1); | ||
permutation$(is, n, r).sort(); | ||
return getAll(x, is); | ||
} | ||
function subsequenceAny(x, r) { | ||
var rnd = random(r), a = []; | ||
for (var v of x) | ||
if (rnd() >= 0.5) | ||
a.push(v); | ||
return a; | ||
} | ||
function subsequence(x, n = -1, r = Math.random()) { | ||
var X = x.length; | ||
if (n >= 0) | ||
return n > X ? null : subsequenceNum(x, n, r); | ||
return subsequenceAny(x, r); | ||
} | ||
function* subsequences(x, n = -1) { | ||
var X = x.length; | ||
if (n >= X) { | ||
if (n === X) | ||
yield x; | ||
return; | ||
} | ||
if (n === 0 || X === 0) { | ||
yield []; | ||
return; | ||
} | ||
var y = x.slice(0, -1); | ||
yield* subsequences(y, n); | ||
for (var s of subsequences(y, n - 1)) { | ||
s.push(x[X - 1]); | ||
yield s; | ||
} | ||
} | ||
function scanWhile(x, ft) { | ||
for (var [k, v] of x) | ||
if (!ft(v, k, x)) | ||
return k; | ||
} | ||
function every(x, ft) { | ||
return scanWhile(x, ft) === undefined; | ||
} | ||
function find(x, ft) { | ||
for (var [k, v] of x) | ||
if (ft(v, k, x)) | ||
return v; | ||
} | ||
function findAll(x, ft) { | ||
var a = []; | ||
for (var [k, v] of x) | ||
if (ft(v, k, x)) | ||
a.push(v); | ||
return a; | ||
} | ||
function forEach(x, fc) { | ||
for (var [k, v] of x) | ||
fc(v, k, x); | ||
} | ||
function fromLists(ls) { | ||
var [ks, vs] = ls, vi = vs[Symbol.iterator](); | ||
var a = new Map(); | ||
for (var k of ks) | ||
a.set(k, vi.next().value); | ||
return a; | ||
} | ||
function getAll$1(x, ks) { | ||
return ks.map(k => x.get(k)); | ||
} | ||
function intersection(x, y, fc = null) { | ||
var fc = fc || id$4; | ||
var a = new Map(); | ||
for (var [k, v] of y) | ||
if (x.has(k)) | ||
a.set(k, fc(x.get(k), v)); | ||
return a; | ||
} | ||
function isSubmap(x, y, fc = null, fm = null) { | ||
var fc = fc || cmp$2, fm = fm || id$4; | ||
for (var [k, v] of y) { | ||
if (!x.has(k)) | ||
return false; | ||
var u1 = fm(x.get(k), k, x); | ||
var v1 = fm(v, k, y); | ||
if (fc(u1, v1) !== 0) | ||
return false; | ||
} | ||
return true; | ||
} | ||
function everyTest(x, fn, ths = null) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
if (!fn.call(ths, v, k, x)) | ||
function searchValue$1(x, v, fc = null, fm = null) { | ||
var fc = fc || cmp$2, fm = fm || id$4; | ||
var v1 = fm(v, null, null); | ||
for (var [k, u] of x) { | ||
var u1 = fm(u, k, x); | ||
if (fc(u1, v1) === 0) | ||
return k; | ||
} | ||
} | ||
function join(x, sep = ',', asc = '=') { | ||
var a = ''; | ||
for (var [k, v] of x) | ||
a += k + asc + v + sep; | ||
return a.slice(0, -sep.length); | ||
} | ||
function range(x, fc = null, fm = null) { | ||
var fc = fc || cmp$2, fm = fm || id$4; | ||
var mk, mu, mv; | ||
var nk, nu, nv; | ||
var i = 0; | ||
for (var [k, u] of x) { | ||
var v = fm(u, k, x); | ||
if (i === 0 || fc(v, mv) < 0) { | ||
mk = k; | ||
mu = u; | ||
mv = v; | ||
} | ||
if (i === 0 || fc(v, nv) > 0) { | ||
nk = k; | ||
nu = u; | ||
nv = v; | ||
} | ||
i++; | ||
} | ||
return [[mk, mu], [nk, nu]]; | ||
} | ||
function reduce(x, fr, acc) { | ||
var init = arguments.length <= 2; | ||
for (var [k, v] of x) { | ||
if (init) { | ||
acc = v; | ||
init = false; | ||
} | ||
else | ||
acc = fr(acc, v, k, x); | ||
} | ||
return acc; | ||
} | ||
function search(x, ft) { | ||
for (var [k, v] of x) | ||
if (ft(v, k, x)) | ||
return k; | ||
} | ||
function scanUntil(x, ft) { | ||
return search(x, ft); | ||
} | ||
function searchAll(x, ft) { | ||
var a = []; | ||
for (var [k, v] of x) | ||
if (ft(v, k, x)) | ||
a.push(k); | ||
return a; | ||
} | ||
function searchValueAll(x, v, fc = null, fm = null) { | ||
var fc = fc || cmp$2, fm = fm || id$4; | ||
var v1 = fm(v, null, x), a = []; | ||
for (var [k, u] of x) { | ||
var u1 = fm(u, k, x); | ||
if (fc(u1, v1) === 0) | ||
a.push(k); | ||
} | ||
return a; | ||
} | ||
function some$1$1(x, ft) { | ||
return scanUntil(x, ft) !== undefined; | ||
} | ||
function submap(x, n = -1, r = Math.random()) { | ||
var ks = subsequence([...x.keys()], n, r); | ||
return filterAt(x, ks); | ||
} | ||
function* submaps(x, n = -1) { | ||
for (var ks of subsequences([...x.keys()], n)) | ||
yield filterAt(x, ks); | ||
} | ||
function symmetricDifference$(x, y) { | ||
for (var [k, v] of y) { | ||
if (x.has(k)) | ||
x.delete(k); | ||
else | ||
x.set(k, v); | ||
} | ||
return x; | ||
} | ||
function symmetricDifference(x, y) { | ||
return symmetricDifference$(new Map(x), y); | ||
} | ||
function union$(x, y, fc = null) { | ||
var fc = fc || id$4; | ||
for (var [k, v] of y) { | ||
if (!x.has(k)) | ||
x.set(k, v); | ||
else | ||
x.set(k, fc(x.get(k), v)); | ||
} | ||
return x; | ||
} | ||
function union(x, y, fc = null) { | ||
return union$(new Map(x), y, fc); | ||
} | ||
/** | ||
* Counts values which satisfy a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function count$1(x, ft) { | ||
return count(entries(x), ft); | ||
} | ||
/** | ||
* Counts occurrences of values. | ||
* @param x lists | ||
* @param fm map function (v, k, x) | ||
* @returns Map {value => count} | ||
*/ | ||
function countAs$1(x, fm = null) { | ||
return countAs(entries(x), fm); | ||
} | ||
/** | ||
* Gives entries of lists not present in another. | ||
* @param x lists | ||
* @param y another lists | ||
*/ | ||
function difference(x, y) { | ||
var a = fromLists(x); | ||
for (var k of keys(y)) | ||
a.delete(k); | ||
return [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Removes first n entries. | ||
* @param x lists | ||
* @param n number of entries (1) | ||
*/ | ||
function drop$1(x, n = 1) { | ||
var ks = drop(keys(x), n); | ||
var vs = drop(values(x), n); | ||
return [ks, vs]; | ||
} | ||
/** | ||
* Picks an arbitrary entry. | ||
* @param x lists | ||
* @param r random seed 0->1 | ||
*/ | ||
function entry(x, r = Math.random()) { | ||
return value([...entries(x)], r); | ||
} | ||
/** | ||
* Checks if all values satisfy a test. | ||
* @param x lists | ||
* @param ft test function (v, k ,x) | ||
*/ | ||
function every$1(x, ft) { | ||
return every(entries(x), ft); | ||
} | ||
/** | ||
* Keeps entries which pass a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function filter(x, ft) { | ||
var ks = [], vs = []; | ||
for (var [k, v] of entries(x)) | ||
if (ft(v, k, x)) { | ||
ks.push(k); | ||
vs.push(v); | ||
} | ||
return [vs, ks]; | ||
} | ||
/** | ||
* Gets lists with given keys. | ||
* @param x lists | ||
* @param ks keys | ||
*/ | ||
function filterAt$1(x, ks) { | ||
var js = [], us = []; | ||
for (var [k, v] of entries(x)) | ||
if (ks.includes(k)) { | ||
js.push(k); | ||
us.push(v); | ||
} | ||
return [js, us]; | ||
} | ||
/** | ||
* Finds a value passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function find$1(x, ft) { | ||
return find(entries(x), ft); | ||
} | ||
/** | ||
* Finds values passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function findAll$1(x, ft) { | ||
return findAll(entries(x), ft); | ||
} | ||
/** | ||
* Checks if value is lists. | ||
* @param v value | ||
*/ | ||
function is$1(v) { | ||
return Array.isArray(v) && v.length === 2 && isList(v[0]) && isList(v[1]); | ||
} | ||
function flatTo(x, n, fm, ft, a) { | ||
for (var [k, v] of entries(x)) { | ||
var v1 = fm(v, k, x); | ||
if (n !== 0 && ft(v1, k, x)) | ||
flatTo(v1, n - 1, fm, ft, a); | ||
else | ||
a.set(k, v1); | ||
} | ||
return a; | ||
} | ||
/** | ||
* Flattens nested lists to given depth. | ||
* @param x nested lists | ||
* @param n maximum depth (-1) | ||
* @param fm map function (v, k, x) | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function flat(x, n = -1, fm = null, ft = null) { | ||
var fm = fm || id, ft = ft || is$1; | ||
var a = flatTo(x, n, fm, ft, new Map()); | ||
return [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Flattens nested lists, using map function. | ||
* @param x nested lists | ||
* @param fm map function (v, k, x) | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function flatMap(x, fm = null, ft = null) { | ||
var fm = fm || id, ft = ft || is$1; | ||
var a = new Map(); | ||
for (var [k, v] of entries(x)) { | ||
var v1 = fm(v, k, x); | ||
if (ft(v1, k, x)) | ||
concat$(a, entries(v1)); | ||
else | ||
a.set(k, v1); | ||
} | ||
return [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Calls a function for each value. | ||
* @param x lists | ||
* @param fc called function (v, k, x) | ||
*/ | ||
function forEach$1(x, fc) { | ||
forEach(entries(x), fc); | ||
} | ||
/** | ||
* Creates lists from entries. | ||
* @param es entries | ||
*/ | ||
function fromEntries(es) { | ||
var a = new Map(es); | ||
return [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Gets value at key. | ||
* @param x lists | ||
* @param k key | ||
*/ | ||
function get$2(x, k) { | ||
return get$1(entries(x), k); | ||
} | ||
/** | ||
* Gets values at keys. | ||
* @param x lists | ||
* @param ks keys | ||
*/ | ||
function getAll$2(x, ks) { | ||
return getAll$1(new Map(entries(x)), ks); | ||
} | ||
/** | ||
* Gets first entry. | ||
* @param x lists | ||
* @param ed default entry | ||
*/ | ||
function head$1(x, ed = []) { | ||
return head(entries(x), ed); | ||
} | ||
/** | ||
* Gives entries present in both lists. | ||
* @param x lists | ||
* @param y another lists | ||
* @param fc combine function (a, b) | ||
*/ | ||
function intersection$1(x, y, fc = null) { | ||
var a = intersection(new Map(entries(x)), entries(y), fc); | ||
return [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Checks if maps have no common keys. | ||
* @param x a map | ||
* @param y another map | ||
*/ | ||
function isDisjoint(x, y) { | ||
for (var k of x.keys()) | ||
if (y.has(k)) | ||
return false; | ||
} | ||
return true; | ||
} | ||
function every(x, fn, ths = null) { | ||
if (fn) | ||
return everyTest(x, fn, ths); | ||
else | ||
return everyIf(x); | ||
/** | ||
* Checks if lists is empty. | ||
* @param x lists | ||
*/ | ||
function isEmpty$1(x) { | ||
return isEmpty(keys(x)); | ||
} | ||
function fill(x, v) { | ||
var ks = Array.from(x[0]); | ||
var vs = Array.from(x[1]).map(_ => v); | ||
/** | ||
* Compares two values. | ||
* @param a a value | ||
* @param b another value | ||
* @returns a<b: -ve, a=b: 0, a>b: +ve | ||
*/ | ||
function cmp$3(a, b) { | ||
return a < b ? -1 : (a > b ? 1 : 0); | ||
} | ||
/** | ||
* Checks if map has an entry. | ||
* @param x a map | ||
* @param e entry? | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
function isEntry(x, e, fc = null, fm = null) { | ||
var fc = fc || cmp$3, fm = fm || id, [k, v] = e; | ||
var [k, v] = e, u = get$2(x, k); | ||
return fc(fm(u, k, x), v) === 0; | ||
} | ||
/** | ||
* Checks if two lists are equal. | ||
* @param x lists | ||
* @param y another lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
function isEqual(x, y, fc = null, fm = null) { | ||
return compare$2(x, y, fc, fm) === 0; | ||
} | ||
/** | ||
* Checks if lists has a key. | ||
* @param x lists | ||
* @param k key? | ||
*/ | ||
function isKey(x, k) { | ||
return isValue(keys(x), k); | ||
} | ||
/** | ||
* Checks if lists has a submap. | ||
* @param x lists | ||
* @param y submap? | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
function isSubmap$1(x, y, fc = null, fm = null) { | ||
return isSubmap(new Map(entries(x)), entries(y), fc, fm); | ||
} | ||
/** | ||
* Finds key with given value. | ||
* @param x lists | ||
* @param v search value | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
function searchValue$2(x, v, fc = null, fm = null) { | ||
return searchValue$1(entries(x), v, fc, fm); | ||
} | ||
/** | ||
* Checks if lists has a value. | ||
* @param x lists | ||
* @param v value? | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
function isValue$1(x, v, fc = null, fm = null) { | ||
return searchValue$2(x, v, fc, fm) !== undefined; | ||
} | ||
/** | ||
* Joins values together. | ||
* @param x lists | ||
* @param sep separator (,) | ||
* @param asc associator (=) | ||
*/ | ||
function join$1(x, sep = ',', asc = '=') { | ||
return join(entries(x), sep, asc); | ||
} | ||
/** | ||
* Picks an arbitrary key. | ||
* @param x lists | ||
* @param r random seed 0->1 | ||
*/ | ||
function key(x, r = Math.random()) { | ||
return value([...keys(x)], r); | ||
} | ||
/** | ||
* Gets size of lists. | ||
* @param x lists | ||
*/ | ||
function size$1(x) { | ||
return size(keys(x)); | ||
} | ||
/** | ||
* Gets size of lists. | ||
* @param x lists | ||
*/ | ||
function length(x) { | ||
return size$1(x); | ||
} | ||
/** | ||
* Updates values based on map function. | ||
* @param x lists | ||
* @param fn map function (v, k, x) | ||
s */ | ||
function* map$1(x, fn) { | ||
} | ||
/** | ||
* Finds smallest and largest entries. | ||
* @param x lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
* @returns [smallest, largest] | ||
*/ | ||
function range$1(x, fc = null, fm = null) { | ||
return range(entries(x), fc, fm); | ||
} | ||
/** | ||
* Finds largest value. | ||
* @param x lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
* @returns [key, value] | ||
*/ | ||
function max(x, fc = null, fm = null) { | ||
return range$1(x, fc, fm)[1]; | ||
} | ||
/** | ||
* Finds smallest entry. | ||
* @param x lists | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
* @returns [key, value] | ||
*/ | ||
function min(x, fc = null, fm = null) { | ||
return range$1(x, fc, fm)[0]; | ||
} | ||
/** | ||
* Segregates values by test result. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
* @returns [satisfies, doesnt] | ||
*/ | ||
function partition(x, ft) { | ||
var tk = [], tv = [], fk = [], fv = []; | ||
for (var [k, v] of entries(x)) { | ||
if (ft(v, k, x)) { | ||
tk.push(k); | ||
tv.push(v); | ||
} | ||
else { | ||
fk.push(k); | ||
fv.push(v); | ||
} | ||
} | ||
return [[tk, tv], [fk, fv]]; | ||
} | ||
/** | ||
* Segregates values by similarity. | ||
* @param x lists | ||
* @param fm map function (v, k, x) | ||
* @returns Map {key => values} | ||
*/ | ||
function partitionAs(x, fm = null) { | ||
var fm = fm || id, a = new Map(); | ||
for (var [k, v] of entries(x)) { | ||
var v1 = fm(v, k, x); | ||
if (!a.has(v1)) | ||
a.set(v1, [[], []]); | ||
var [ak, av] = a.get(v1); | ||
ak.push(k); | ||
av.push(v); | ||
} | ||
return a; | ||
} | ||
/** | ||
* Reduces values to a single value. | ||
* @param x lists | ||
* @param fr reduce function (acc, v, k, x) | ||
* @param acc initial value | ||
*/ | ||
function reduce$1(x, fr, acc) { | ||
var A = arguments.length, es = entries(x); | ||
return A > 2 ? reduce(es, fr, acc) : reduce(es, fr); | ||
} | ||
/** | ||
* Discards entries which pass a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function reject(x, ft) { | ||
var ks = [], vs = []; | ||
for (var [k, v] of entries(x)) | ||
if (!ft(v, k, x)) { | ||
ks.push(k); | ||
vs.push(v); | ||
} | ||
return [ks, vs]; | ||
} | ||
function find(x, fn, ths = null) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
if (fn.call(ths, v, k, x)) | ||
return v; | ||
/** | ||
* Gets lists without given keys. | ||
* @param x lists | ||
* @param ks keys | ||
*/ | ||
function rejectAt(x, ks) { | ||
var js = [], us = []; | ||
for (var [k, v] of entries(x)) | ||
if (!ks.includes(k)) { | ||
js.push(k); | ||
us.push(v); | ||
} | ||
return [js, us]; | ||
} | ||
/** | ||
* Deletes an entry. | ||
* @param x lists | ||
* @param k key | ||
*/ | ||
function remove(x, k) { | ||
var ks = [], vs = []; | ||
for (var [j, u] of entries(x)) | ||
if (j !== k) { | ||
ks.push(j); | ||
vs.push(u); | ||
} | ||
return [ks, vs]; | ||
} | ||
/** | ||
* Finds key of first entry not passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function scanUntil$1(x, ft) { | ||
return scanUntil(entries(x), ft); | ||
} | ||
/** | ||
* Finds key of first entry not passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function scanWhile$1(x, ft) { | ||
return scanWhile(entries(x), ft); | ||
} | ||
/** | ||
* Finds key of an entry passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function search$1(x, ft) { | ||
return search(entries(x), ft); | ||
} | ||
/** | ||
* Finds keys of entries passing a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function searchAll$1(x, ft) { | ||
return searchAll(entries(x), ft); | ||
} | ||
/** | ||
* Finds keys with given value. | ||
* @param x lists | ||
* @param v search value | ||
* @param fc compare function (a, b) | ||
* @param fm map function (v, k, x) | ||
*/ | ||
function searchValueAll$1(x, v, fc = null, fm = null) { | ||
return searchValueAll(entries(x), v, fc, fm); | ||
} | ||
/** | ||
* Sets value at key. | ||
* @param x lists | ||
* @param k key | ||
* @param v value | ||
*/ | ||
function set(x, k, v) { | ||
var ks = [], vs = []; | ||
for (var [j, u] of entries(x)) { | ||
ks.push(j); | ||
vs.push(j === k ? v : u); | ||
} | ||
return [ks, vs]; | ||
} | ||
function forEach(x, fn, ths = null) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
for (var v of vs) { | ||
var k = ki.next(); | ||
fn.call(ths, v, k, x); | ||
/** | ||
* Removes first entry. | ||
* @param x lists | ||
*/ | ||
function shift(x) { | ||
return drop$1(x, 1); | ||
} | ||
/** | ||
* Checks if any value satisfies a test. | ||
* @param x lists | ||
* @param ft test function (v, k, x) | ||
*/ | ||
function some$2(x, ft = null) { | ||
return some$1$1(entries(x), ft); | ||
} | ||
/** | ||
* Picks an arbitrary submap. | ||
* @param x lists | ||
* @param n number of entries (-1 => any) | ||
* @param r random seed 0->1 | ||
*/ | ||
function submap$1(x, n = -1, r = Math.random()) { | ||
var a = submap(new Map(entries(x)), n, r); | ||
return [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Lists all possible submaps. | ||
* @param x lists | ||
* @param n number of entries (-1 => any) | ||
*/ | ||
function* submaps$1(x, n = -1) { | ||
for (var a of submaps(new Map(entries(x)), n)) | ||
yield [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Exchanges two values. | ||
* @param x lists | ||
* @param k a key | ||
* @param l another key | ||
*/ | ||
function swap(x, k, l) { | ||
var ks = map(keys(x), j => j === k ? l : (j === l ? k : j)); | ||
return [ks, values(x)]; | ||
} | ||
/** | ||
* Gives entries not present in both lists. | ||
* @param x lists | ||
* @param y another lists | ||
*/ | ||
function symmetricDifference$1(x, y) { | ||
var a = symmetricDifference(entries(x), entries(y)); | ||
return [a.keys(), a.values()]; | ||
} | ||
/** | ||
* Gets lists without the first entry. | ||
* @param x lists | ||
*/ | ||
function tail(x) { | ||
return drop$1(x, 1); | ||
} | ||
/** | ||
* Keeps first n entries only. | ||
* @param x lists | ||
* @param n number of entries (1) | ||
*/ | ||
function take$1(x, n = 1) { | ||
var ks = take(keys(x), n); | ||
var vs = take(values(x), n); | ||
return [ks, vs]; | ||
} | ||
/** | ||
* Gives lists present in any lists. | ||
* @param x lists | ||
* @param y another lists | ||
* @param fc combine function (a, b) | ||
*/ | ||
function union$1(x, y, fc = null) { | ||
var a = union(entries(x), entries(y), fc); | ||
return [a.keys(), a.values()]; | ||
} | ||
function unwrapExports (x) { | ||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; | ||
} | ||
function createCommonjsModule(fn, basedir, module) { | ||
return module = { | ||
path: basedir, | ||
exports: {}, | ||
require: function (path, base) { | ||
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); | ||
} | ||
}, fn(module, module.exports), module.exports; | ||
} | ||
function get(x, k) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
for (var v of vs) { | ||
var k0 = ki.next().value; | ||
if (k === k0) | ||
return v; | ||
function commonjsRequire () { | ||
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); | ||
} | ||
var extraSet = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function add$(x, v) { | ||
return x.add(v); | ||
} | ||
function add(x, v) { | ||
return new Set(x).add(v); | ||
} | ||
function id(v) { | ||
return v; | ||
} | ||
function* cartesianProduct(xs, fn = null) { | ||
var fn = fn || id; | ||
var XS = xs.length; | ||
var vss = xs.map(x => [...x]); | ||
var ls = vss.map(vs => vs.length); | ||
var is = vss.map(vs => 0); | ||
while (true) { | ||
var a = new Set(); | ||
for (var n = 0; n < XS; n++) { | ||
var i = is[n], x = xs[n]; | ||
var vs = vss[n], v = vs[i]; | ||
a.add(v); | ||
} | ||
yield fn(a, a, null); | ||
for (var r = XS - 1; r >= 0; r--) { | ||
is[r]++; | ||
if (is[r] < ls[r]) | ||
break; | ||
is[r] = 0; | ||
} | ||
if (r < 0) | ||
break; | ||
} | ||
} | ||
function* getAll(x, ks) { | ||
var [js, vs] = x, m = new Map(); | ||
var ji = js[Symbol.iterator](); | ||
var ki = ks[Symbol.iterator](); | ||
var { value, done } = ki.next(); | ||
if (done) | ||
function chunk(x, n = 1, s = n) { | ||
var a = []; | ||
for (var i = 0, I = x.length; i < I; i += s) | ||
a.push(x.slice(i, i + n)); | ||
return a; | ||
} | ||
function index(x, i = 0) { | ||
return i < 0 ? Math.max(x.length + i, 0) : Math.min(i, x.length); | ||
} | ||
function fromRange(v, V = v, s = 1) { | ||
var a = []; | ||
if (s >= 0) { | ||
for (; v < V; v += s) | ||
a.push(v); | ||
} | ||
else { | ||
for (; v > V; v += s) | ||
a.push(v); | ||
} | ||
return a; | ||
} | ||
function get(x, i) { | ||
return x[index(x, i)]; | ||
} | ||
function getAll(x, is) { | ||
var a = []; | ||
for (var i of is) | ||
a.push(get(x, i)); | ||
return a; | ||
} | ||
function random(r) { | ||
var a = Math.floor(r * 2 ** 31); | ||
return function () { | ||
var t = a += 0x6D2B79F5; | ||
t = Math.imul(t ^ t >>> 15, t | 1); | ||
t ^= t + Math.imul(t ^ t >>> 7, t | 61); | ||
return ((t ^ t >>> 14) >>> 0) / 4294967296; | ||
}; | ||
} | ||
function permutation$(x, n = -1, r = Math.random()) { | ||
if (n > x.length) | ||
return x; | ||
var X = x.length, rnd = random(r); | ||
var n = n >= 0 ? n : Math.floor((X + 1) * rnd()); | ||
for (var i = 0; i < n; i++) { | ||
var j = i + Math.floor((X - i) * rnd()); | ||
var t = x[i]; | ||
x[i] = x[j]; | ||
x[j] = t; | ||
} | ||
x.length = n; | ||
return x; | ||
} | ||
function subsequenceNum(x, n, r) { | ||
var is = fromRange(0, x.length, 1); | ||
permutation$(is, n, r).sort(); | ||
return getAll(x, is); | ||
} | ||
function subsequenceAny(x, r) { | ||
var rnd = random(r), a = []; | ||
for (var v of x) | ||
if (rnd() >= 0.5) | ||
a.push(v); | ||
return a; | ||
} | ||
function subsequence(x, n = -1, r = Math.random()) { | ||
var X = x.length; | ||
if (n >= 0) | ||
return n > X ? null : subsequenceNum(x, n, r); | ||
return subsequenceAny(x, r); | ||
} | ||
function* subsequences(x, n = -1) { | ||
var X = x.length; | ||
if (n >= X) { | ||
if (n === X) | ||
yield x; | ||
return; | ||
for (var v of vs) { | ||
var j = ji.next().value; | ||
m.set(j, v); | ||
} | ||
if (n === 0 || X === 0) { | ||
yield []; | ||
return; | ||
} | ||
var y = x.slice(0, -1); | ||
yield* subsequences(y, n); | ||
for (var s of subsequences(y, n - 1)) { | ||
s.push(x[X - 1]); | ||
yield s; | ||
} | ||
} | ||
function is$1(v) { | ||
return Array.isArray(v) && v.length === 2 && isList(v[0]) && isList(v[1]); | ||
function value(x, r = Math.random()) { | ||
var i = Math.floor(r * x.length); | ||
return x[i]; | ||
} | ||
function isOnce$1(v) { | ||
if (!Array.isArray(v) || v.length !== 2) | ||
return false; | ||
return isOnce(v[0]) || isOnce(v[1]); | ||
function chunk$1(x, n = 1, s = n) { | ||
return chunk([...x], n, s).map(c => new Set(c)); | ||
} | ||
function isMany(v) { | ||
return !isOnce$1(v); | ||
function compare(x, y) { | ||
for (var v of x) | ||
if (!y.has(v)) | ||
return 1; | ||
for (var v of y) | ||
if (!x.has(v)) | ||
return -1; | ||
return 0; | ||
} | ||
function join(x, sep = ',', asc = null) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](), a = ''; | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
if (asc) | ||
a += k + asc; | ||
a += v + sep; | ||
function concat$(x, ...ys) { | ||
for (var y of ys) { | ||
for (var v of y) | ||
x.add(v); | ||
} | ||
return a.slice(0, -sep.length); | ||
return x; | ||
} | ||
function keys(x) { | ||
return x[0]; | ||
function concat(...xs) { | ||
return concat$(new Set(), ...xs); | ||
} | ||
function size$1(x, i = 0, I = END) { | ||
return size(x[1], i, I); | ||
function count(x, fn) { | ||
var a = 0; | ||
for (var v of x) | ||
if (fn(v, v, x)) | ||
a++; | ||
return a; | ||
} | ||
function length(x, i = 0, I = END) { | ||
return size$1(x, i, I); | ||
function countAs(x, fn) { | ||
var fn = fn || id; | ||
var a = new Map(); | ||
for (var v of x) { | ||
var v1 = fn(v, v, x); | ||
var n = a.get(v1) || 0; | ||
a.set(v1, n + 1); | ||
} | ||
return a; | ||
} | ||
function* map(x, fn, ths = null) { | ||
function difference$(x, y) { | ||
for (var v of y) | ||
x.delete(v); | ||
return x; | ||
} | ||
function max$1(x, fc = null, fm = null) { | ||
return max(x[1], fc, fm); | ||
function difference(x, y) { | ||
var a = new Set(); | ||
for (var v of x) | ||
if (!y.has(v)) | ||
a.add(v); | ||
return a; | ||
} | ||
function drop$(x, n = 1) { | ||
var i = 0; | ||
for (var v of x) { | ||
if (i++ >= n) | ||
break; | ||
x.delete(v); | ||
} | ||
return x; | ||
} | ||
function drop(x, n = 1) { | ||
var i = 0, a = new Set(); | ||
for (var v of x) | ||
if (i++ >= n) | ||
a.add(v); | ||
return a; | ||
} | ||
function* entries(x) { | ||
yield* x.entries(); | ||
} | ||
function entry(x, r = Math.random()) { | ||
return value([...x.entries()], r); | ||
} | ||
function scanWhile(x, fn) { | ||
for (var v of x) | ||
if (!fn(v, v, x)) | ||
return v; | ||
} | ||
function every(x, fn = null) { | ||
var fn = fn || id; | ||
return scanWhile(x, fn) === undefined; | ||
} | ||
function filter$(x, fn) { | ||
for (var v of x) | ||
if (!fn(v, v, x)) | ||
x.delete(v); | ||
return x; | ||
} | ||
function filter(x, fn) { | ||
var a = new Set(); | ||
for (var v of x) | ||
if (fn(v, v, x)) | ||
a.add(v); | ||
return a; | ||
} | ||
function filterAt$(x, vs) { | ||
for (var v of x) | ||
if (!vs.includes(v)) | ||
x.delete(v); | ||
return x; | ||
} | ||
function filterAt(x, vs) { | ||
var a = new Set(); | ||
for (var v of vs) | ||
if (x.has(v)) | ||
a.add(v); | ||
return a; | ||
} | ||
function find(x, fn) { | ||
for (var v of x) | ||
if (fn(v, v, x)) | ||
return v; | ||
} | ||
function findAll(x, fn) { | ||
var a = []; | ||
for (var v of x) | ||
if (fn(v, v, x)) | ||
a.push(v); | ||
return a; | ||
} | ||
function is(v) { | ||
return v instanceof Set; | ||
} | ||
function flatTo(x, dep, a) { | ||
for (var v of x) { | ||
if (dep !== 0 && is(v)) | ||
flatTo(v, dep - 1, a); | ||
else | ||
a.add(v); | ||
} | ||
return a; | ||
} | ||
function flat(x, dep = -1) { | ||
return flatTo(x, dep, new Set()); | ||
} | ||
function flatMap(x, fn = null) { | ||
var fn = fn || id; | ||
var a = new Set(); | ||
for (var v of x) { | ||
var v1 = fn(v, v, x); | ||
if (is(v1)) | ||
concat$(a, v1); | ||
else | ||
a.add(v1); | ||
} | ||
return a; | ||
} | ||
function forEach(x, fn) { | ||
for (var v of x) | ||
fn(v, v, x); | ||
} | ||
function from$(vs) { | ||
return vs instanceof Set ? vs : new Set(vs); | ||
} | ||
function from(vs) { | ||
return new Set(vs); | ||
} | ||
function head(x, vd) { | ||
for (var v of x) | ||
return v; | ||
return vd; | ||
} | ||
function intersection$(x, y) { | ||
for (var v of x) | ||
if (!y.has(v)) | ||
x.delete(v); | ||
return x; | ||
} | ||
function intersection(x, y) { | ||
var a = new Set(); | ||
for (var v of x) | ||
if (y.has(v)) | ||
a.add(v); | ||
return a; | ||
} | ||
function isDisjoint(x, y) { | ||
for (var v of y) | ||
if (x.has(v)) | ||
return false; | ||
return true; | ||
} | ||
function isEmpty(x) { | ||
return x.size === 0; | ||
} | ||
function isEqual(x, y) { | ||
return x.size === y.size && compare(x, y) === 0; | ||
} | ||
function isSubset(x, y) { | ||
for (var v of y) | ||
if (!x.has(v)) | ||
return false; | ||
return true; | ||
} | ||
function isValue(x, v) { | ||
return x.has(v); | ||
} | ||
function join(x, sep = ',') { | ||
var a = ''; | ||
for (var v of x) | ||
a += v + sep; | ||
return a.substring(0, a.length - sep.length); | ||
} | ||
/** | ||
* Joins values together. | ||
* @param x a set | ||
* @param sep separator (,) | ||
*/ | ||
function join$1(x, sep = ',') { | ||
return join(x, sep); | ||
} | ||
function length(x) { | ||
return x.size; | ||
} | ||
function map$(x, fn) { | ||
var vs = []; | ||
for (var v of x) | ||
vs.push(fn(v, v, x)); | ||
x.clear(); | ||
return concat$(x, vs); | ||
} | ||
function map(x, fn) { | ||
var a = new Set(); | ||
for (var v of x) | ||
a.add(fn(v, v, x)); | ||
return a; | ||
} | ||
function cmp(a, b) { | ||
return a < b ? -1 : (a > b ? 1 : 0); | ||
} | ||
function range(x, fc = null, fm = null) { | ||
var fc = fc || cmp, fm = fm || id; | ||
var mu, mv; | ||
var nu, nv; | ||
var i = 0; | ||
for (var u of x) { | ||
var v = fm(u, u, x); | ||
if (i === 0 || fc(v, mv) < 0) { | ||
mu = u; | ||
mv = v; | ||
} | ||
if (i === 0 || fc(v, nv) > 0) { | ||
nu = u; | ||
nv = v; | ||
} | ||
i++; | ||
} | ||
return [[mu, mu], [nu, nu]]; | ||
} | ||
function max(x, fc = null, fm = null) { | ||
return range(x, fc, fm)[1]; | ||
} | ||
function min(x, fc = null, fm = null) { | ||
return range(x, fc, fm)[0]; | ||
} | ||
function partition(x, fn) { | ||
var t = new Set(); | ||
var f = new Set(); | ||
for (var v of x) { | ||
if (fn(v, v, x)) | ||
t.add(v); | ||
else | ||
f.add(v); | ||
} | ||
return [t, f]; | ||
} | ||
function partitionAs(x, fn) { | ||
var fn = fn || id; | ||
var a = new Map(); | ||
for (var v of x) { | ||
var v1 = fn(v, v, x); | ||
if (!a.has(v1)) | ||
a.set(v1, new Set()); | ||
a.get(v1).add(v); | ||
} | ||
return a; | ||
} | ||
function reduce(x, fn, acc) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
var init = arguments.length <= 2; | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
for (var v of x) { | ||
if (init) { | ||
acc = v; | ||
init = false; | ||
acc = v; | ||
} | ||
else | ||
acc = fn(acc, v, k, x); | ||
acc = fn(acc, v, v, x); | ||
} | ||
@@ -235,79 +1740,351 @@ return acc; | ||
function cmp$1(a, b) { | ||
return a < b ? -1 : (a > b ? 1 : 0); | ||
function reject$(x, fn) { | ||
for (var v of x) | ||
if (fn(v, v, x)) | ||
x.delete(v); | ||
return x; | ||
} | ||
function search(x, v, fc = null, fm = null) { | ||
var fc = fc || cmp$1, fm = fm || id$1; | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
var v1 = fm(v, null, null); | ||
for (var u of vs) { | ||
var k = ki.next().value; | ||
var u1 = fm(u, k, x); | ||
if (fc(u1, v1) === 0) | ||
return k; | ||
} | ||
function reject(x, fn) { | ||
var a = new Set(); | ||
for (var v of x) | ||
if (!fn(v, v, x)) | ||
a.add(v); | ||
return a; | ||
} | ||
function* searchAll(x, v, fc = null, fm = null) { | ||
var fc = fc || cmp$1, fm = fm || id$1; | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
var v1 = fm(v, null, null); | ||
for (var u of vs) { | ||
var k = ki.next().value; | ||
var u1 = fm(u, k, x); | ||
if (fc(u1, v1) === 0) | ||
yield k; | ||
function rejectAt$(x, vs) { | ||
for (var v of vs) | ||
x.delete(v); | ||
return x; | ||
} | ||
function rejectAt(x, vs) { | ||
return rejectAt$(new Set(x), vs); | ||
} | ||
function remove$(x, v) { | ||
x.delete(v); | ||
return x; | ||
} | ||
function remove(x, v) { | ||
return remove$(new Set(x), v); | ||
} | ||
function scanUntil(x, fn) { | ||
return find(x, fn); | ||
} | ||
function search(x, fn) { | ||
return find(x, fn); | ||
} | ||
function searchAll(x, fn) { | ||
return findAll(x, fn); | ||
} | ||
function shift$(x) { | ||
return drop$(x, 1); | ||
} | ||
function shift(x) { | ||
return drop(x, 1); | ||
} | ||
function size(x) { | ||
return x.size; | ||
} | ||
function some(x, fn = null) { | ||
var fn = fn || id; | ||
return scanUntil(x, fn) !== undefined; | ||
} | ||
function subset(x, n = -1, r = Math.random()) { | ||
var vs = subsequence([...x], n, r); | ||
return new Set(vs); | ||
} | ||
function* subsets(x, n = -1) { | ||
for (var vs of subsequences([...x], n)) | ||
yield new Set(vs); | ||
} | ||
function symmetricDifference$(x, y) { | ||
for (var v of y) { | ||
if (x.has(v)) | ||
x.delete(v); | ||
else | ||
x.add(v); | ||
} | ||
return x; | ||
} | ||
function someIf(x) { | ||
for (var v of x[1]) | ||
if (v) | ||
return true; | ||
return false; | ||
function symmetricDifference(x, y) { | ||
var a = new Set(); | ||
for (var v of x) | ||
if (!y.has(v)) | ||
a.add(v); | ||
for (var v of y) | ||
if (!x.has(v)) | ||
a.add(v); | ||
return a; | ||
} | ||
function someTest(x, fn, ths = null) { | ||
var [ks, vs] = x, ki = ks[Symbol.iterator](); | ||
for (var v of vs) { | ||
var k = ki.next().value; | ||
if (fn.call(ths, v, k, x)) | ||
return true; | ||
function tail(x) { | ||
return drop(x, 1); | ||
} | ||
function take$(x, n = 1) { | ||
var i = 0; | ||
for (var v of x) | ||
if (i++ >= n) | ||
x.delete(v); | ||
return x; | ||
} | ||
function take(x, n = 1) { | ||
var i = 0, a = new Set(); | ||
for (var v of x) { | ||
if (i++ >= n) | ||
break; | ||
a.add(v); | ||
} | ||
return false; | ||
return a; | ||
} | ||
function some(x, fn = null, ths = null) { | ||
if (fn) | ||
return someTest(x, fn, ths); | ||
else | ||
return someIf(x); | ||
function union$(x, y) { | ||
return concat$(x, y); | ||
} | ||
function values(x) { | ||
return x[1]; | ||
function union(x, y) { | ||
return concat$(new Set(), x, y); | ||
} | ||
exports.concat = concat$1; | ||
function value$1(x, r = Math.random()) { | ||
return value([...x], r); | ||
} | ||
function* values(x) { | ||
yield* x; | ||
} | ||
exports.add = add; | ||
exports.add$ = add$; | ||
exports.cartesianProduct = cartesianProduct; | ||
exports.chunk = chunk$1; | ||
exports.compare = compare; | ||
exports.concat = concat; | ||
exports.concat$ = concat$; | ||
exports.count = count; | ||
exports.countAs = countAs; | ||
exports.difference = difference; | ||
exports.difference$ = difference$; | ||
exports.drop = drop; | ||
exports.drop$ = drop$; | ||
exports.entries = entries; | ||
exports.entry = entry; | ||
exports.every = every; | ||
exports.fill = fill; | ||
exports.filter = filter; | ||
exports.filter$ = filter$; | ||
exports.filterAt = filterAt; | ||
exports.filterAt$ = filterAt$; | ||
exports.find = find; | ||
exports.findAll = findAll; | ||
exports.flat = flat; | ||
exports.flatMap = flatMap; | ||
exports.forEach = forEach; | ||
exports.get = get; | ||
exports.getAll = getAll; | ||
exports.is = is$1; | ||
exports.isMany = isMany; | ||
exports.isOnce = isOnce$1; | ||
exports.join = join; | ||
exports.keys = keys; | ||
exports.from = from; | ||
exports.from$ = from$; | ||
exports.head = head; | ||
exports.intersection = intersection; | ||
exports.intersection$ = intersection$; | ||
exports.is = is; | ||
exports.isDisjoint = isDisjoint; | ||
exports.isEmpty = isEmpty; | ||
exports.isEqual = isEqual; | ||
exports.isSubset = isSubset; | ||
exports.isValue = isValue; | ||
exports.join = join$1; | ||
exports.length = length; | ||
exports.map = map; | ||
exports.max = max$1; | ||
exports.map$ = map$; | ||
exports.max = max; | ||
exports.min = min; | ||
exports.partition = partition; | ||
exports.partitionAs = partitionAs; | ||
exports.range = range; | ||
exports.reduce = reduce; | ||
exports.reject = reject; | ||
exports.reject$ = reject$; | ||
exports.rejectAt = rejectAt; | ||
exports.rejectAt$ = rejectAt$; | ||
exports.remove = remove; | ||
exports.remove$ = remove$; | ||
exports.scanUntil = scanUntil; | ||
exports.scanWhile = scanWhile; | ||
exports.search = search; | ||
exports.searchAll = searchAll; | ||
exports.size = size$1; | ||
exports.shift = shift; | ||
exports.shift$ = shift$; | ||
exports.size = size; | ||
exports.some = some; | ||
exports.subset = subset; | ||
exports.subsets = subsets; | ||
exports.symmetricDifference = symmetricDifference; | ||
exports.symmetricDifference$ = symmetricDifference$; | ||
exports.tail = tail; | ||
exports.take = take; | ||
exports.take$ = take$; | ||
exports.union = union; | ||
exports.union$ = union$; | ||
exports.value = value$1; | ||
exports.values = values; | ||
}); | ||
unwrapExports(extraSet); | ||
var extraSet_1 = extraSet.add; | ||
var extraSet_2 = extraSet.add$; | ||
var extraSet_3 = extraSet.cartesianProduct; | ||
var extraSet_4 = extraSet.chunk; | ||
var extraSet_5 = extraSet.compare; | ||
var extraSet_6 = extraSet.concat; | ||
var extraSet_7 = extraSet.concat$; | ||
var extraSet_8 = extraSet.count; | ||
var extraSet_9 = extraSet.countAs; | ||
var extraSet_10 = extraSet.difference; | ||
var extraSet_11 = extraSet.difference$; | ||
var extraSet_12 = extraSet.drop; | ||
var extraSet_13 = extraSet.drop$; | ||
var extraSet_14 = extraSet.entries; | ||
var extraSet_15 = extraSet.entry; | ||
var extraSet_16 = extraSet.every; | ||
var extraSet_17 = extraSet.filter; | ||
var extraSet_18 = extraSet.filter$; | ||
var extraSet_19 = extraSet.filterAt; | ||
var extraSet_20 = extraSet.filterAt$; | ||
var extraSet_21 = extraSet.find; | ||
var extraSet_22 = extraSet.findAll; | ||
var extraSet_23 = extraSet.flat; | ||
var extraSet_24 = extraSet.flatMap; | ||
var extraSet_25 = extraSet.forEach; | ||
var extraSet_26 = extraSet.from$; | ||
var extraSet_27 = extraSet.head; | ||
var extraSet_28 = extraSet.intersection; | ||
var extraSet_29 = extraSet.intersection$; | ||
var extraSet_30 = extraSet.is; | ||
var extraSet_31 = extraSet.isDisjoint; | ||
var extraSet_32 = extraSet.isEmpty; | ||
var extraSet_33 = extraSet.isEqual; | ||
var extraSet_34 = extraSet.isSubset; | ||
var extraSet_35 = extraSet.isValue; | ||
var extraSet_36 = extraSet.join; | ||
var extraSet_37 = extraSet.length; | ||
var extraSet_38 = extraSet.map; | ||
var extraSet_39 = extraSet.map$; | ||
var extraSet_40 = extraSet.max; | ||
var extraSet_41 = extraSet.min; | ||
var extraSet_42 = extraSet.partition; | ||
var extraSet_43 = extraSet.partitionAs; | ||
var extraSet_44 = extraSet.range; | ||
var extraSet_45 = extraSet.reduce; | ||
var extraSet_46 = extraSet.reject; | ||
var extraSet_47 = extraSet.reject$; | ||
var extraSet_48 = extraSet.rejectAt; | ||
var extraSet_49 = extraSet.rejectAt$; | ||
var extraSet_50 = extraSet.remove; | ||
var extraSet_51 = extraSet.remove$; | ||
var extraSet_52 = extraSet.scanUntil; | ||
var extraSet_53 = extraSet.scanWhile; | ||
var extraSet_54 = extraSet.search; | ||
var extraSet_55 = extraSet.searchAll; | ||
var extraSet_56 = extraSet.shift; | ||
var extraSet_57 = extraSet.shift$; | ||
var extraSet_58 = extraSet.size; | ||
var extraSet_59 = extraSet.some; | ||
var extraSet_60 = extraSet.subset; | ||
var extraSet_61 = extraSet.subsets; | ||
var extraSet_62 = extraSet.symmetricDifference; | ||
var extraSet_63 = extraSet.symmetricDifference$; | ||
var extraSet_64 = extraSet.tail; | ||
var extraSet_65 = extraSet.take; | ||
var extraSet_66 = extraSet.take$; | ||
var extraSet_67 = extraSet.union; | ||
var extraSet_68 = extraSet.union$; | ||
var extraSet_69 = extraSet.value; | ||
var extraSet_70 = extraSet.values; | ||
function unionKeys$1(...xs) { | ||
return extraSet_6(...xs.map(x => keys(x))); | ||
} | ||
function value$1(x, r = Math.random()) { | ||
return value([...values(x)], r); | ||
} | ||
exports.cartesianProduct = cartesianProduct; | ||
exports.chunk = chunk$1; | ||
exports.compare = compare$2; | ||
exports.concat = concat$1; | ||
exports.count = count$1; | ||
exports.countAs = countAs$1; | ||
exports.difference = difference; | ||
exports.drop = drop$1; | ||
exports.entries = entries; | ||
exports.entry = entry; | ||
exports.every = every$1; | ||
exports.filter = filter; | ||
exports.filterAt = filterAt$1; | ||
exports.find = find$1; | ||
exports.findAll = findAll$1; | ||
exports.flat = flat; | ||
exports.flatMap = flatMap; | ||
exports.forEach = forEach$1; | ||
exports.fromEntries = fromEntries; | ||
exports.get = get$2; | ||
exports.getAll = getAll$2; | ||
exports.head = head$1; | ||
exports.intersection = intersection$1; | ||
exports.is = is$1; | ||
exports.isDisjoint = isDisjoint; | ||
exports.isEmpty = isEmpty$1; | ||
exports.isEntry = isEntry; | ||
exports.isEqual = isEqual; | ||
exports.isKey = isKey; | ||
exports.isSubmap = isSubmap$1; | ||
exports.isValue = isValue$1; | ||
exports.join = join$1; | ||
exports.key = key; | ||
exports.keys = keys; | ||
exports.length = length; | ||
exports.map = map$1; | ||
exports.max = max; | ||
exports.min = min; | ||
exports.partition = partition; | ||
exports.partitionAs = partitionAs; | ||
exports.range = range$1; | ||
exports.reduce = reduce$1; | ||
exports.reject = reject; | ||
exports.rejectAt = rejectAt; | ||
exports.remove = remove; | ||
exports.scanUntil = scanUntil$1; | ||
exports.scanWhile = scanWhile$1; | ||
exports.search = search$1; | ||
exports.searchAll = searchAll$1; | ||
exports.searchValue = searchValue$2; | ||
exports.searchValueAll = searchValueAll$1; | ||
exports.set = set; | ||
exports.shift = shift; | ||
exports.size = size$1; | ||
exports.some = some$2; | ||
exports.submap = submap$1; | ||
exports.submaps = submaps$1; | ||
exports.swap = swap; | ||
exports.symmetricDifference = symmetricDifference$1; | ||
exports.tail = tail; | ||
exports.take = take$1; | ||
exports.union = union$1; | ||
exports.unionKeys = unionKeys$1; | ||
exports.value = value$1; | ||
exports.values = values; |
{ | ||
"name": "extra-lists", | ||
"version": "2.0.74", | ||
"version": "2.0.75", | ||
"description": "Lists is pair of list of keys, and values.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100637
4077
1