@limitlesspc/std 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.d.ts +21 -4
- package/dist/array.js +5 -4
- package/dist/async/index.d.ts +1 -1
- package/dist/async/index.js +1 -13
- package/dist/{chunk-65SNM7MP.js → chunk-4POIKW4G.js} +9 -13
- package/dist/{chunk-WBSY6KRH.js → chunk-CCBSTDYA.js} +1 -1
- package/dist/{chunk-WNQNVZFS.js → chunk-ONMV3ICF.js} +219 -282
- package/dist/{chunk-O3YCU3KN.js → chunk-SSSOLDLG.js} +2 -2
- package/dist/cmath/index.js +1 -1
- package/dist/events.js +5 -6
- package/dist/fn/index.d.ts +14 -1
- package/dist/fn/index.js +1 -2
- package/dist/gfx/index.d.ts +1 -1
- package/dist/gfx/index.js +5 -6
- package/dist/iter/index.js +2 -3
- package/dist/math/index.d.ts +58 -58
- package/dist/math/index.js +7 -14
- package/dist/random.js +4 -5
- package/dist/string/index.js +5 -3
- package/dist/structs/index.d.ts +2 -75
- package/dist/structs/index.js +232 -18
- package/dist/types.js +0 -1
- package/dist/{vec3-S_YuL-W1.d.ts → vec3-BQ6mZ-wg.d.ts} +14 -24
- package/package.json +46 -50
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/chunk-DYKZK6B5.js +0 -523
- package/dist/easing.d.ts +0 -37
- package/dist/easing.js +0 -157
- /package/dist/{chunk-MG5VQSTV.js → chunk-NXILTE26.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
swap,
|
|
3
3
|
unorderedRemove
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4POIKW4G.js";
|
|
5
5
|
|
|
6
6
|
// src/random.ts
|
|
7
7
|
function random(min, max) {
|
|
@@ -21,7 +21,7 @@ function randomInt(min = 0, max) {
|
|
|
21
21
|
return Math.floor(random(min + 1));
|
|
22
22
|
}
|
|
23
23
|
function shuffle(array) {
|
|
24
|
-
for (let
|
|
24
|
+
for (let i = array.length - 1; i > 0; i--) {
|
|
25
25
|
const j = randomInt(i);
|
|
26
26
|
swap(array, i, j);
|
|
27
27
|
}
|
package/dist/cmath/index.js
CHANGED
package/dist/events.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sum
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ONMV3ICF.js";
|
|
4
|
+
import "./chunk-SSSOLDLG.js";
|
|
5
|
+
import "./chunk-4POIKW4G.js";
|
|
6
6
|
import {
|
|
7
7
|
pick
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CCBSTDYA.js";
|
|
9
9
|
import {
|
|
10
10
|
pipe
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-6F4PWJZI.js";
|
|
11
|
+
} from "./chunk-NXILTE26.js";
|
|
13
12
|
import "./chunk-TMLWLR46.js";
|
|
14
13
|
import "./chunk-LJSF3QBT.js";
|
|
15
14
|
|
package/dist/fn/index.d.ts
CHANGED
|
@@ -34,9 +34,22 @@ type ReverseCurry<Fn extends AnyFunction, Args = Parameters<Fn>> = Args extends
|
|
|
34
34
|
(...rest: Rest): (first: First) => ReturnType<Fn>;
|
|
35
35
|
} : never;
|
|
36
36
|
/**
|
|
37
|
-
* Create a function that takes in the first parameter of another
|
|
37
|
+
* Create a function that takes in the first parameter of another
|
|
38
|
+
* In other words, it gives you a function that when called with every parameter other than the first, will output a function that takes the first parameter only
|
|
38
39
|
* @param fn
|
|
39
40
|
* @returns a functions a that takes in the rest of the arguments of `fn` and returns a function that takes the first argument of `fn` to finally return the result of `fn`
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* // Fused multiply-add
|
|
44
|
+
* function fma(a: number, b: number, c: number) {
|
|
45
|
+
* return a * b + c;
|
|
46
|
+
* }
|
|
47
|
+
* const curried = reverseCurry(fma);
|
|
48
|
+
*
|
|
49
|
+
* const times3Add2Fma = curried(3, 2);
|
|
50
|
+
* times3Add2Fma(4); // 4 * 3 + 2 = 14
|
|
51
|
+
* times3Add2Fma(0); // 0 * 3 + 2 = 2
|
|
52
|
+
* ```
|
|
40
53
|
*/
|
|
41
54
|
declare const reverseCurry: <Fn extends AnyFunction>(fn: Fn) => ReverseCurry<Fn>;
|
|
42
55
|
|
package/dist/fn/index.js
CHANGED
package/dist/gfx/index.d.ts
CHANGED
package/dist/gfx/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
vec3
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-6F4PWJZI.js";
|
|
3
|
+
} from "../chunk-ONMV3ICF.js";
|
|
4
|
+
import "../chunk-SSSOLDLG.js";
|
|
5
|
+
import "../chunk-4POIKW4G.js";
|
|
6
|
+
import "../chunk-CCBSTDYA.js";
|
|
7
|
+
import "../chunk-NXILTE26.js";
|
|
9
8
|
import "../chunk-TMLWLR46.js";
|
|
10
9
|
import "../chunk-LJSF3QBT.js";
|
|
11
10
|
|
package/dist/iter/index.js
CHANGED
|
@@ -28,9 +28,8 @@ import {
|
|
|
28
28
|
uniqueBy,
|
|
29
29
|
unzip,
|
|
30
30
|
zip
|
|
31
|
-
} from "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-6F4PWJZI.js";
|
|
31
|
+
} from "../chunk-CCBSTDYA.js";
|
|
32
|
+
import "../chunk-NXILTE26.js";
|
|
34
33
|
import "../chunk-LJSF3QBT.js";
|
|
35
34
|
export {
|
|
36
35
|
associateBy,
|
package/dist/math/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { int, uint } from '../types.js';
|
|
2
|
-
|
|
3
|
-
export { R as ReadonlyVec3Like, b as Vec3, a as Vec3Like, v as vec3 } from '../vec3-S_YuL-W1.js';
|
|
2
|
+
export { R as ReadonlyVec3Like, V as Vec3, v as vec3 } from '../vec3-BQ6mZ-wg.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Determines if a value is a number other than `NaN`
|
|
@@ -8,15 +7,14 @@ export { R as ReadonlyVec3Like, b as Vec3, a as Vec3Like, v as vec3 } from '../v
|
|
|
8
7
|
*/
|
|
9
8
|
declare function isNumber(x: unknown): x is number;
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
* @param x
|
|
10
|
+
* Squares a number, or multiplies it by itself
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* sq(3) // 9
|
|
14
|
+
* sq(36) // 36
|
|
15
|
+
* ```
|
|
18
16
|
*/
|
|
19
|
-
declare function
|
|
17
|
+
declare function sq(x: number): number;
|
|
20
18
|
/**
|
|
21
19
|
* Rounds `x` to the nearest multiple of `n`
|
|
22
20
|
* @param x the number to round
|
|
@@ -37,7 +35,7 @@ declare function smootherstep(x: number, min: number, max: number): number;
|
|
|
37
35
|
declare function clamp(n: number, min: number, max: number): number;
|
|
38
36
|
declare function overlap(min1: number, max1: number, min2: number, max2: number): number;
|
|
39
37
|
/** Returns which number (a or b) is closer to x */
|
|
40
|
-
declare function closer(x: number, a:
|
|
38
|
+
declare function closer(x: number, a: number, b: number): number;
|
|
41
39
|
declare function round(n: number, precision?: int): number;
|
|
42
40
|
declare function floor(n: number, precision?: int): number;
|
|
43
41
|
declare function ceil(n: number, precision?: int): number;
|
|
@@ -45,28 +43,31 @@ declare function trunc(n: number, precision?: int): number;
|
|
|
45
43
|
declare function fract(x: number): number;
|
|
46
44
|
declare function closeTo(n: number, target: number, precision?: int): boolean;
|
|
47
45
|
declare function factorial(n: uint): number;
|
|
46
|
+
/**
|
|
47
|
+
* Logarithm using any base
|
|
48
|
+
* @param base the logarithm's base
|
|
49
|
+
* @param x the number to take the logarithm of
|
|
50
|
+
* @returns the exponent which the base is raised to, to equal x
|
|
51
|
+
*/
|
|
48
52
|
declare function log(base: number, x: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Natural logarithm, or log base e
|
|
55
|
+
* Simply an alias for `Math.log`
|
|
56
|
+
*/
|
|
49
57
|
declare const ln: (x: number) => number;
|
|
50
58
|
/**
|
|
51
|
-
* Calculates the greatest common factor between
|
|
59
|
+
* Calculates the greatest common factor between two numbers
|
|
52
60
|
* a and b using the [Euclidean algorithm](https://www.wikiwand.com/en/Euclidean_algorithm)
|
|
53
61
|
* @param a a number
|
|
54
62
|
* @param b a number
|
|
55
63
|
*/
|
|
56
|
-
declare function gcd(a: uint, b: uint):
|
|
64
|
+
declare function gcd(a: uint, b: uint): uint;
|
|
65
|
+
declare function gcd(a: bigint, b: bigint): bigint;
|
|
57
66
|
declare function fibonacci(n: uint): number;
|
|
58
67
|
/** Convert farhenheit to celsius */
|
|
59
68
|
declare const celsius: (fahrenheit: number) => number;
|
|
60
69
|
/** Convert celsius to farhenheit */
|
|
61
70
|
declare const fahrenheit: (celsius: number) => number;
|
|
62
|
-
/**
|
|
63
|
-
* @param points a list of (x,y) points
|
|
64
|
-
* @returns the line of best fit in terms of m and b in the form y = mx + b
|
|
65
|
-
*/
|
|
66
|
-
declare function lineOfBestFit(points: Array<{
|
|
67
|
-
x: number;
|
|
68
|
-
y: number;
|
|
69
|
-
}>): [m: number, b: number];
|
|
70
71
|
/**
|
|
71
72
|
* Calculates the number of ways to choose `k` items from `n` items without repeating and with ordering
|
|
72
73
|
* @param n the number of items
|
|
@@ -79,7 +80,6 @@ declare function permutations(n: uint, k: uint): number;
|
|
|
79
80
|
* @param k the number of choices being made
|
|
80
81
|
*/
|
|
81
82
|
declare function combinations(n: uint, k: uint): number;
|
|
82
|
-
declare function dot(a: Iterable<number>, b: Iterable<number>): number;
|
|
83
83
|
|
|
84
84
|
/** @unstable */
|
|
85
85
|
declare class Mat extends Float32Array {
|
|
@@ -268,9 +268,9 @@ declare function product(iter: Iterable<number>): number;
|
|
|
268
268
|
* @returns The average
|
|
269
269
|
* @example
|
|
270
270
|
* ```ts
|
|
271
|
-
* const numbers = [1, 2, 3, 4
|
|
271
|
+
* const numbers = [1, 2, 3, 4];
|
|
272
272
|
* const average = avg(numbers);
|
|
273
|
-
* console.log(average); //
|
|
273
|
+
* console.log(average); // 2.5
|
|
274
274
|
* ```
|
|
275
275
|
*/
|
|
276
276
|
declare function avg(iter: Iterable<number>): number;
|
|
@@ -307,14 +307,14 @@ declare function median(array: number[]): number;
|
|
|
307
307
|
*/
|
|
308
308
|
declare function mode<T>(iter: Iterable<T>): T[];
|
|
309
309
|
/**
|
|
310
|
-
* Returns the variance of an
|
|
310
|
+
* Returns the variance of an array of numbers
|
|
311
311
|
* @param iter The iterable of numbers
|
|
312
312
|
* @returns The variance
|
|
313
313
|
* @example
|
|
314
314
|
* ```ts
|
|
315
315
|
* const numbers = [1, 2, 3, 4, 5];
|
|
316
316
|
* const variance = variance(numbers);
|
|
317
|
-
* console.log(variance); // 2
|
|
317
|
+
* console.log(variance); // 2
|
|
318
318
|
* ```
|
|
319
319
|
*/
|
|
320
320
|
declare function variance(iter: Iterable<number>): number;
|
|
@@ -326,7 +326,7 @@ declare function variance(iter: Iterable<number>): number;
|
|
|
326
326
|
* ```ts
|
|
327
327
|
* const numbers = [1, 2, 3, 4, 5];
|
|
328
328
|
* const stddev = stddev(numbers);
|
|
329
|
-
* console.log(stddev); // 1.
|
|
329
|
+
* console.log(stddev); // 1.414
|
|
330
330
|
* ```
|
|
331
331
|
*/
|
|
332
332
|
declare function stddev(iter: Iterable<number>): number;
|
|
@@ -345,25 +345,25 @@ declare function meanAbsDev(iter: Iterable<number>): number;
|
|
|
345
345
|
|
|
346
346
|
/** The ratio to convert degrees to radians */
|
|
347
347
|
declare const DEG2RAD: number;
|
|
348
|
-
/** Converts radians to degrees */
|
|
349
|
-
declare const degrees: (radians: number) => number;
|
|
350
348
|
/** Converts degrees to radians */
|
|
351
349
|
declare const radians: (degrees: number) => number;
|
|
350
|
+
/** Converts radians to degrees */
|
|
351
|
+
declare const degrees: (radians: number) => number;
|
|
352
352
|
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
interface ReadonlyVec2Like {
|
|
354
|
+
readonly x: number;
|
|
355
|
+
readonly y: number;
|
|
356
|
+
}
|
|
355
357
|
type First$1 = ReadonlyVec2Like | number;
|
|
356
|
-
declare class Vec2
|
|
357
|
-
|
|
358
|
+
declare class Vec2 {
|
|
359
|
+
x: number;
|
|
360
|
+
y: number;
|
|
358
361
|
constructor(x?: First$1, y?: number);
|
|
359
|
-
get x(): number;
|
|
360
|
-
set x(value: number);
|
|
361
|
-
get y(): number;
|
|
362
|
-
set y(value: number);
|
|
363
362
|
toString(): string;
|
|
364
363
|
copy(): Vec2;
|
|
365
364
|
static random(mag?: number): Vec2;
|
|
366
365
|
eq(x: First$1, y?: number): boolean;
|
|
366
|
+
set(x: First$1, y?: number): this;
|
|
367
367
|
add(x: First$1, y?: number): this;
|
|
368
368
|
static add(v1: Vec2, x: First$1, y?: number): Vec2;
|
|
369
369
|
sub(x: First$1, y?: number): this;
|
|
@@ -373,10 +373,10 @@ declare class Vec2 extends Float32Array implements Vec {
|
|
|
373
373
|
div(x: First$1, y?: number): this;
|
|
374
374
|
static div(v1: Vec2, x: First$1, y?: number): Vec2;
|
|
375
375
|
static fma(a: ReadonlyVec2Like, b: ReadonlyVec2Like, c: ReadonlyVec2Like): Vec2;
|
|
376
|
-
lt(
|
|
377
|
-
lte(
|
|
378
|
-
gt(
|
|
379
|
-
gte(
|
|
376
|
+
lt(v: ReadonlyVec2Like): Vec2;
|
|
377
|
+
lte(v: ReadonlyVec2Like): Vec2;
|
|
378
|
+
gt(v: ReadonlyVec2Like): Vec2;
|
|
379
|
+
gte(v: ReadonlyVec2Like): Vec2;
|
|
380
380
|
mag(): number;
|
|
381
381
|
setMag(n: number): this;
|
|
382
382
|
magSq(): number;
|
|
@@ -403,20 +403,19 @@ declare class Vec2 extends Float32Array implements Vec {
|
|
|
403
403
|
}
|
|
404
404
|
declare function vec2(x?: First$1, y?: number): Vec2;
|
|
405
405
|
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
interface ReadonlyVec4Like {
|
|
407
|
+
readonly x: number;
|
|
408
|
+
readonly y: number;
|
|
409
|
+
readonly z: number;
|
|
410
|
+
readonly w: number;
|
|
411
|
+
}
|
|
408
412
|
type First = ReadonlyVec4Like | number;
|
|
409
|
-
declare class Vec4
|
|
410
|
-
|
|
413
|
+
declare class Vec4 {
|
|
414
|
+
x: number;
|
|
415
|
+
y: number;
|
|
416
|
+
z: number;
|
|
417
|
+
w: number;
|
|
411
418
|
constructor(x?: First, y?: number, z?: number, w?: number);
|
|
412
|
-
get x(): number;
|
|
413
|
-
set x(value: number);
|
|
414
|
-
get y(): number;
|
|
415
|
-
set y(value: number);
|
|
416
|
-
get z(): number;
|
|
417
|
-
set z(value: number);
|
|
418
|
-
get w(): number;
|
|
419
|
-
set w(value: number);
|
|
420
419
|
get r(): number;
|
|
421
420
|
set r(value: number);
|
|
422
421
|
get g(): number;
|
|
@@ -428,6 +427,7 @@ declare class Vec4 extends Float32Array implements Vec {
|
|
|
428
427
|
toString(): string;
|
|
429
428
|
copy(): Vec4;
|
|
430
429
|
eq(x: First, y?: number, z?: number, w?: number): boolean;
|
|
430
|
+
set(x: First, y?: number, z?: number, w?: number): this;
|
|
431
431
|
add(x: First, y?: number, z?: number, w?: number): this;
|
|
432
432
|
static add(v1: Vec4, x: First, y?: number, z?: number, w?: number): Vec4;
|
|
433
433
|
sub(x: First, y?: number, z?: number, w?: number): this;
|
|
@@ -437,10 +437,10 @@ declare class Vec4 extends Float32Array implements Vec {
|
|
|
437
437
|
div(x: First, y?: number, z?: number, w?: number): this;
|
|
438
438
|
static div(v1: Vec4, x: First, y?: number, z?: number, w?: number): Vec4;
|
|
439
439
|
static fma(a: ReadonlyVec4Like, b: ReadonlyVec4Like, c: ReadonlyVec4Like): Vec4;
|
|
440
|
-
lt(
|
|
441
|
-
lte(
|
|
442
|
-
gt(
|
|
443
|
-
gte(
|
|
440
|
+
lt(v: ReadonlyVec4Like): Vec4;
|
|
441
|
+
lte(v: ReadonlyVec4Like): Vec4;
|
|
442
|
+
gt(v: ReadonlyVec4Like): Vec4;
|
|
443
|
+
gte(v: ReadonlyVec4Like): Vec4;
|
|
444
444
|
limit(max: number): this;
|
|
445
445
|
normalize(): this;
|
|
446
446
|
static normalize(v: Vec4): Vec4;
|
|
@@ -460,4 +460,4 @@ declare class Vec4 extends Float32Array implements Vec {
|
|
|
460
460
|
}
|
|
461
461
|
declare function vec4(x?: First, y?: number, z?: number, w?: number): Vec4;
|
|
462
462
|
|
|
463
|
-
export { DEG2RAD, Mat, Mat2, type Mat2Like, Mat3, type Mat3Like, Mat4, type Mat4Like, type ReadonlyMat2Like, type ReadonlyMat3Like, type ReadonlyMat4Like, type ReadonlyVec2Like, type ReadonlyVec4Like,
|
|
463
|
+
export { DEG2RAD, Mat, Mat2, type Mat2Like, Mat3, type Mat3Like, Mat4, type Mat4Like, type ReadonlyMat2Like, type ReadonlyMat3Like, type ReadonlyMat4Like, type ReadonlyVec2Like, type ReadonlyVec4Like, Vec2, Vec4, avg, ceil, celsius, clamp, closeTo, closer, combinations, degrees, factorial, fahrenheit, fibonacci, floor, fract, gcd, isNumber, lerp, ln, log, map, mat, mat2, mat3, mat4, max, meanAbsDev, median, min, minmax, mode, norm, overlap, permutations, product, radians, round, roundToEven, roundToMultiple, smootherstep, smoothstep, sq, stddev, step, sum, trunc, variance, vec2, vec4 };
|
package/dist/math/index.js
CHANGED
|
@@ -15,18 +15,14 @@ import {
|
|
|
15
15
|
closer,
|
|
16
16
|
combinations,
|
|
17
17
|
degrees,
|
|
18
|
-
dot,
|
|
19
18
|
factorial,
|
|
20
19
|
fahrenheit,
|
|
21
20
|
fibonacci,
|
|
22
21
|
floor,
|
|
23
22
|
fract,
|
|
24
23
|
gcd,
|
|
25
|
-
isInteger,
|
|
26
24
|
isNumber,
|
|
27
|
-
isReal,
|
|
28
25
|
lerp,
|
|
29
|
-
lineOfBestFit,
|
|
30
26
|
ln,
|
|
31
27
|
log,
|
|
32
28
|
map,
|
|
@@ -50,6 +46,7 @@ import {
|
|
|
50
46
|
roundToMultiple,
|
|
51
47
|
smootherstep,
|
|
52
48
|
smoothstep,
|
|
49
|
+
sq,
|
|
53
50
|
stddev,
|
|
54
51
|
step,
|
|
55
52
|
sum,
|
|
@@ -58,12 +55,11 @@ import {
|
|
|
58
55
|
vec2,
|
|
59
56
|
vec3,
|
|
60
57
|
vec4
|
|
61
|
-
} from "../chunk-
|
|
62
|
-
import "../chunk-
|
|
63
|
-
import "../chunk-
|
|
64
|
-
import "../chunk-
|
|
65
|
-
import "../chunk-
|
|
66
|
-
import "../chunk-6F4PWJZI.js";
|
|
58
|
+
} from "../chunk-ONMV3ICF.js";
|
|
59
|
+
import "../chunk-SSSOLDLG.js";
|
|
60
|
+
import "../chunk-4POIKW4G.js";
|
|
61
|
+
import "../chunk-CCBSTDYA.js";
|
|
62
|
+
import "../chunk-NXILTE26.js";
|
|
67
63
|
import "../chunk-TMLWLR46.js";
|
|
68
64
|
import "../chunk-LJSF3QBT.js";
|
|
69
65
|
export {
|
|
@@ -83,18 +79,14 @@ export {
|
|
|
83
79
|
closer,
|
|
84
80
|
combinations,
|
|
85
81
|
degrees,
|
|
86
|
-
dot,
|
|
87
82
|
factorial,
|
|
88
83
|
fahrenheit,
|
|
89
84
|
fibonacci,
|
|
90
85
|
floor,
|
|
91
86
|
fract,
|
|
92
87
|
gcd,
|
|
93
|
-
isInteger,
|
|
94
88
|
isNumber,
|
|
95
|
-
isReal,
|
|
96
89
|
lerp,
|
|
97
|
-
lineOfBestFit,
|
|
98
90
|
ln,
|
|
99
91
|
log,
|
|
100
92
|
map,
|
|
@@ -118,6 +110,7 @@ export {
|
|
|
118
110
|
roundToMultiple,
|
|
119
111
|
smootherstep,
|
|
120
112
|
smoothstep,
|
|
113
|
+
sq,
|
|
121
114
|
stddev,
|
|
122
115
|
step,
|
|
123
116
|
sum,
|
package/dist/random.js
CHANGED
|
@@ -5,11 +5,10 @@ import {
|
|
|
5
5
|
randomInt,
|
|
6
6
|
sample,
|
|
7
7
|
shuffle
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-6F4PWJZI.js";
|
|
8
|
+
} from "./chunk-SSSOLDLG.js";
|
|
9
|
+
import "./chunk-4POIKW4G.js";
|
|
10
|
+
import "./chunk-CCBSTDYA.js";
|
|
11
|
+
import "./chunk-NXILTE26.js";
|
|
13
12
|
import "./chunk-TMLWLR46.js";
|
|
14
13
|
import "./chunk-LJSF3QBT.js";
|
|
15
14
|
export {
|
package/dist/string/index.js
CHANGED
|
@@ -13,7 +13,7 @@ function listItems(items, conjunction = "and") {
|
|
|
13
13
|
return "";
|
|
14
14
|
}
|
|
15
15
|
case 1: {
|
|
16
|
-
return items[0]
|
|
16
|
+
return items[0];
|
|
17
17
|
}
|
|
18
18
|
case 2: {
|
|
19
19
|
return items.join(` ${conjunction} `);
|
|
@@ -65,14 +65,16 @@ function splitOnce(str, separator) {
|
|
|
65
65
|
return [before, after];
|
|
66
66
|
}
|
|
67
67
|
function reverse(str) {
|
|
68
|
-
|
|
68
|
+
const chars = [...str];
|
|
69
|
+
chars.reverse();
|
|
70
|
+
return chars.join("");
|
|
69
71
|
}
|
|
70
72
|
function replace(str, replacements) {
|
|
71
73
|
const regex = new RegExp(
|
|
72
74
|
Object.keys(replacements).map(escapeRegex).join("|"),
|
|
73
75
|
"g"
|
|
74
76
|
);
|
|
75
|
-
return str.replace(regex, (matched) => replacements[matched]
|
|
77
|
+
return str.replace(regex, (matched) => replacements[matched]);
|
|
76
78
|
}
|
|
77
79
|
var escapeInRegexRegex = /[$()*+./?[\\\]^{|}-]/g;
|
|
78
80
|
function escapeRegex(regexStr) {
|
package/dist/structs/index.d.ts
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import { uint, int } from '../types.js';
|
|
2
1
|
import { Compare } from '../cmp.js';
|
|
3
|
-
|
|
4
|
-
interface Node$1<T> {
|
|
5
|
-
value: T;
|
|
6
|
-
next?: Node$1<T>;
|
|
7
|
-
prev?: Node$1<T>;
|
|
8
|
-
}
|
|
9
|
-
declare class DoublyLinkedList<T> implements Iterable<T> {
|
|
10
|
-
private head?;
|
|
11
|
-
private tail?;
|
|
12
|
-
private size;
|
|
13
|
-
static from<T>(values: Iterable<T>): DoublyLinkedList<T>;
|
|
14
|
-
get length(): uint;
|
|
15
|
-
[Symbol.iterator](): Iterator<T>;
|
|
16
|
-
getNode(index: uint): Node$1<T> | undefined;
|
|
17
|
-
get(index: uint): T | undefined;
|
|
18
|
-
set(index: uint, value: T): T | undefined;
|
|
19
|
-
push(value: T): uint;
|
|
20
|
-
pop(): T | undefined;
|
|
21
|
-
unshift(value: T): uint;
|
|
22
|
-
shift(): T | undefined;
|
|
23
|
-
reverse(): this;
|
|
24
|
-
remove(index: uint): T | undefined;
|
|
25
|
-
splice(index: uint, count: uint, ...values: T[]): T[];
|
|
26
|
-
}
|
|
2
|
+
import { uint, int } from '../types.js';
|
|
27
3
|
|
|
28
4
|
/**
|
|
29
5
|
* ## Binary Heap
|
|
@@ -64,55 +40,6 @@ declare class Heap<T> implements Iterable<T> {
|
|
|
64
40
|
protected heapify(i?: number): void;
|
|
65
41
|
}
|
|
66
42
|
|
|
67
|
-
declare class MaxHeap<T> extends Heap<T> {
|
|
68
|
-
constructor(data?: T[], heapify?: boolean);
|
|
69
|
-
copy(): MaxHeap<T>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
declare class MinHeap<T> extends Heap<T> {
|
|
73
|
-
constructor(data?: T[], heapify?: boolean);
|
|
74
|
-
copy(): MinHeap<T>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
interface Node<T> {
|
|
78
|
-
value: T;
|
|
79
|
-
next?: Node<T>;
|
|
80
|
-
}
|
|
81
|
-
declare class LinkedList<T> implements Iterable<T> {
|
|
82
|
-
node?: Node<T>;
|
|
83
|
-
static from<T>(values: Iterable<T>): LinkedList<T>;
|
|
84
|
-
get length(): uint;
|
|
85
|
-
[Symbol.iterator](): Iterator<T>;
|
|
86
|
-
get tail(): Node<T> | undefined;
|
|
87
|
-
getNode(index: uint): Node<T> | undefined;
|
|
88
|
-
get(index: uint): T | undefined;
|
|
89
|
-
set(index: uint, value: T): T | undefined;
|
|
90
|
-
push(value: T): void;
|
|
91
|
-
pop(): Node<T> | undefined;
|
|
92
|
-
unshift(value: T): void;
|
|
93
|
-
shift(): Node<T> | undefined;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* ## Queue
|
|
98
|
-
* A data structure that follows a first-in-first-out (FIFO) order
|
|
99
|
-
*
|
|
100
|
-
* | Method | Average Case | Worst Case |
|
|
101
|
-
* | ----------- | ------------ | ---------- |
|
|
102
|
-
* | enqueue() | O(1) | O(1) |
|
|
103
|
-
* | dequeue() | O(1) | O(1) |
|
|
104
|
-
*
|
|
105
|
-
* @see https://en.wikipedia.org/wiki/Queue_(abstract_data_type)
|
|
106
|
-
*/
|
|
107
|
-
declare class Queue<T> implements Iterable<T> {
|
|
108
|
-
protected items: T[];
|
|
109
|
-
constructor(items?: T[]);
|
|
110
|
-
get size(): uint;
|
|
111
|
-
enqueue(item: T): uint;
|
|
112
|
-
dequeue(): T | undefined;
|
|
113
|
-
[Symbol.iterator](): Iterator<T>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
43
|
/**
|
|
117
44
|
* ## Sorted Array
|
|
118
45
|
* An array that maintains sorted order
|
|
@@ -181,4 +108,4 @@ declare class UnorderedArray<T> extends Array<T> {
|
|
|
181
108
|
toSpliced(start: uint, deleteCount?: number, ...items: T[]): T[];
|
|
182
109
|
}
|
|
183
110
|
|
|
184
|
-
export {
|
|
111
|
+
export { Heap, SortedArray, UnorderedArray };
|