-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
1,113 additions
and
1,398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
node_modules | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,139 +1,15 @@ | ||
/** | ||
* @file | ||
* @copyright 2020 Aleksej Komarov | ||
* @license MIT | ||
*/ | ||
const y = (t, n) => { | ||
if (t == null) | ||
return t; | ||
if (Array.isArray(t)) { | ||
const s = []; | ||
for (let e = 0; e < t.length; e++) { | ||
const r = t[e]; | ||
n(r, e, t) && s.push(r); | ||
} | ||
return s; | ||
} | ||
throw new Error(`filter() can't iterate on type ${typeof t}`); | ||
}, d = (t, n) => { | ||
if (t == null) | ||
return t; | ||
if (Array.isArray(t)) { | ||
const s = []; | ||
for (let e = 0; e < t.length; e++) | ||
s.push(n(t[e], e, t)); | ||
return s; | ||
} | ||
if (typeof t == "object") { | ||
const s = []; | ||
for (let e in t) | ||
Object.prototype.hasOwnProperty.call(t, e) && s.push(n(t[e], e, t)); | ||
return s; | ||
} | ||
throw new Error(`map() can't iterate on type ${typeof t}`); | ||
}, p = (t, n) => { | ||
const s = t.criteria, e = n.criteria, r = s.length; | ||
for (let u = 0; u < r; u++) { | ||
const i = s[u], f = e[u]; | ||
if (i < f) | ||
return -1; | ||
if (i > f) | ||
return 1; | ||
} | ||
return 0; | ||
}, l = (t, ...n) => { | ||
if (!Array.isArray(t)) | ||
return t; | ||
let s = t.length, e = []; | ||
for (let u = 0; u < s; u++) { | ||
const i = t[u]; | ||
e.push({ | ||
criteria: n.map((f) => f(i)), | ||
value: i | ||
}); | ||
} | ||
e.sort(p); | ||
const r = []; | ||
for (; s--; ) | ||
r[s] = e[s].value; | ||
return r; | ||
}, A = (t) => l(t), m = (t, n) => new Array(n - t).fill(null).map((s, e) => e + t), w = (t, n, s) => { | ||
const e = t.length; | ||
let r, u; | ||
for (s === void 0 ? (r = 1, u = t[0]) : (r = 0, u = s); r < e; r++) | ||
u = n(u, t[r], r, t); | ||
return u; | ||
}, c = (t, n) => { | ||
const { length: s } = t, e = [], r = n ? [] : e; | ||
let u = -1; | ||
t: | ||
for (; ++u < s; ) { | ||
let i = t[u]; | ||
const f = n ? n(i) : i; | ||
if (f === f) { | ||
let o = r.length; | ||
for (; o--; ) | ||
if (r[o] === f) | ||
continue t; | ||
n && r.push(f), e.push(i); | ||
} else | ||
r.includes(f) || (r !== e && r.push(f), e.push(i)); | ||
} | ||
return e; | ||
}, b = (t) => c(t), v = (...t) => { | ||
if (t.length === 0) | ||
function s(...n) { | ||
if (n.length === 0) | ||
return []; | ||
const n = t.length, s = t[0].length, e = []; | ||
for (let r = 0; r < s; r++) { | ||
const u = []; | ||
for (let i = 0; i < n; i++) | ||
u.push(t[i][r]); | ||
e.push(u); | ||
const o = n.length, r = n[0].length, u = []; | ||
for (let t = 0; t < r; t++) { | ||
const l = []; | ||
for (let e = 0; e < o; e++) | ||
l.push(n[e][t]); | ||
u.push(l); | ||
} | ||
return e; | ||
}, g = (t, n, s) => { | ||
if (n.length === 0) | ||
return 0; | ||
const e = t(s); | ||
let [r, u] = [0, n.length], i, f = 0; | ||
for (; r < u; ) | ||
if (f = r + u >> 1, i = t(n[f]), i < e) | ||
r = f + 1; | ||
else { | ||
if (i === e) | ||
return f; | ||
u = f; | ||
} | ||
return i > e ? f : f + 1; | ||
}, j = (t, n, s) => { | ||
const e = [...t]; | ||
return e.splice(g(s, t, n), 0, n), e; | ||
}, O = (t, n) => { | ||
const s = []; | ||
let e = [], r = n; | ||
for (const u of t) | ||
e.push(u), r--, r || (r = n, s.push(e), e = []); | ||
return e.length && s.push(e), s; | ||
}, h = (t) => typeof t == "object" && t !== null, a = (...t) => { | ||
const n = {}; | ||
for (const s of t) | ||
for (const e of Object.keys(s)) { | ||
const r = n[e], u = s[e]; | ||
Array.isArray(r) && Array.isArray(u) ? n[e] = [...r, ...u] : h(r) && h(u) ? n[e] = a(r, u) : n[e] = u; | ||
} | ||
return n; | ||
}; | ||
return u; | ||
} | ||
export { | ||
j as binaryInsertWith, | ||
a as deepMerge, | ||
y as filter, | ||
d as map, | ||
O as paginate, | ||
m as range, | ||
w as reduce, | ||
A as sort, | ||
l as sortBy, | ||
b as uniq, | ||
c as uniqBy, | ||
v as zip | ||
s as zip | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const r = (e) => { | ||
function n(e) { | ||
throw new Error(`Unhandled case: ${e}`); | ||
}; | ||
} | ||
export { | ||
r as exhaustiveCheck | ||
n as exhaustiveCheck | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
/** | ||
* @file | ||
* @copyright 2020 Aleksej Komarov | ||
* @license MIT | ||
*/ | ||
const l = (...t) => (e, ...o) => { | ||
let r = e; | ||
for (let f of t) | ||
Array.isArray(f) ? r = l(...f)(r, ...o) : f && (r = f(r, ...o)); | ||
return r; | ||
const n = (...t) => (e, ...f) => { | ||
let o = e; | ||
for (const r of t) | ||
Array.isArray(r) ? o = n(...r)(o, ...f) : r && (o = r(o, ...f)); | ||
return o; | ||
}; | ||
export { | ||
l as flow | ||
n as flow | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,39 @@ | ||
/** | ||
* @file | ||
* @copyright 2020 Aleksej Komarov | ||
* @license MIT | ||
*/ | ||
/** | ||
* Limits a number to the range between 'min' and 'max'. | ||
*/ | ||
export declare const clamp: (value: any, min: any, max: any) => any; | ||
export declare function clamp(value: any, min: any, max: any): any; | ||
/** | ||
* Limits a number between 0 and 1. | ||
*/ | ||
export declare const clamp01: (value: any) => any; | ||
export declare function clamp01(value: any): any; | ||
/** | ||
* Scales a number to fit into the range between min and max. | ||
*/ | ||
export declare const scale: (value: any, min: any, max: any) => number; | ||
export declare function scale(value: any, min: any, max: any): number; | ||
/** | ||
* Robust number rounding. | ||
* | ||
* Adapted from Locutus, see: http://locutus.io/php/math/round/ | ||
* Robust number rounding, similar to PHP's round() function. | ||
* | ||
* @param {number} value | ||
* @param {number} precision | ||
* @return {number} | ||
* @url https://stackoverflow.com/questions/53450248/how-to-round-in-javascript-like-php-do/54721202#54721202 | ||
*/ | ||
export declare const round: (value: any, precision: any) => any; | ||
export declare function round(num: any, dec: any): number; | ||
/** | ||
* Returns a string representing a number in fixed point notation. | ||
*/ | ||
export declare const toFixed: (value: any, fractionDigits?: number) => string; | ||
export declare function toFixed(value: any, fractionDigits?: number): string; | ||
/** | ||
* Checks whether a value is within the provided range. | ||
* | ||
* Range is an array of two numbers, for example: [0, 15]. | ||
*/ | ||
export declare const inRange: (value: any, range: any) => any; | ||
export declare function inRange(value: any, range: any): any; | ||
/** | ||
* Walks over the object with ranges, comparing value against every range, | ||
* and returns the key of the first matching range. | ||
* | ||
* Range is an array of two numbers, for example: [0, 15]. | ||
*/ | ||
export declare const keyOfMatchingRange: (value: any, ranges: any) => string | undefined; | ||
export declare function keyOfMatchingRange(value: any, ranges: any): string | undefined; | ||
/** | ||
* Get number of digits following the decimal point in a number | ||
*/ | ||
export declare const numberOfDecimalDigits: (value: any) => any; | ||
export declare function numberOfDecimalDigits(value: any): any; |
Oops, something went wrong.