@limitlesspc/std 0.20.2
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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/array.d.ts +209 -0
- package/dist/array.js +41 -0
- package/dist/async/index.d.ts +48 -0
- package/dist/async/index.js +155 -0
- package/dist/bytes.d.ts +38 -0
- package/dist/bytes.js +35 -0
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/chunk-C2DS6YRJ.js +1664 -0
- package/dist/chunk-DO4NH5XG.js +523 -0
- package/dist/chunk-EWSJTMH2.js +68 -0
- package/dist/chunk-ILLWUQPY.js +139 -0
- package/dist/chunk-LJSF3QBT.js +122 -0
- package/dist/chunk-MG5VQSTV.js +89 -0
- package/dist/chunk-TMLWLR46.js +12 -0
- package/dist/chunk-WBSY6KRH.js +358 -0
- package/dist/cmath/index.d.ts +57 -0
- package/dist/cmath/index.js +187 -0
- package/dist/cmp.d.ts +11 -0
- package/dist/cmp.js +12 -0
- package/dist/csv.d.ts +3 -0
- package/dist/csv.js +16 -0
- package/dist/easing.d.ts +37 -0
- package/dist/easing.js +157 -0
- package/dist/events.d.ts +20 -0
- package/dist/events.js +67 -0
- package/dist/fn/index.d.ts +66 -0
- package/dist/fn/index.js +25 -0
- package/dist/gfx/index.d.ts +13 -0
- package/dist/gfx/index.js +68 -0
- package/dist/iter/index.d.ts +226 -0
- package/dist/iter/index.js +65 -0
- package/dist/math/index.d.ts +463 -0
- package/dist/math/index.js +129 -0
- package/dist/object.d.ts +72 -0
- package/dist/object.js +24 -0
- package/dist/random.d.ts +68 -0
- package/dist/random.js +22 -0
- package/dist/string/index.d.ts +62 -0
- package/dist/string/index.js +98 -0
- package/dist/structs/index.d.ts +184 -0
- package/dist/structs/index.js +24 -0
- package/dist/time/index.d.ts +35 -0
- package/dist/time/index.js +84 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.js +1 -0
- package/dist/vec3-D7Wuy2AZ.d.ts +70 -0
- package/package.json +111 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// src/cmath/complex.ts
|
|
2
|
+
var Complex = class {
|
|
3
|
+
constructor(r = 0, i = 0) {
|
|
4
|
+
this.r = r;
|
|
5
|
+
this.i = i;
|
|
6
|
+
}
|
|
7
|
+
toString() {
|
|
8
|
+
return `${this.r} + ${this.i}i`;
|
|
9
|
+
}
|
|
10
|
+
valueOf() {
|
|
11
|
+
return this.mag();
|
|
12
|
+
}
|
|
13
|
+
copy() {
|
|
14
|
+
return complex(this.r, this.i);
|
|
15
|
+
}
|
|
16
|
+
get conj() {
|
|
17
|
+
return complex(+this.r, -this.i);
|
|
18
|
+
}
|
|
19
|
+
static fromAngle(angle, mag = 1) {
|
|
20
|
+
return complex(Math.cos(angle), Math.sin(angle)).mul(mag);
|
|
21
|
+
}
|
|
22
|
+
isReal() {
|
|
23
|
+
return !this.i;
|
|
24
|
+
}
|
|
25
|
+
add(c) {
|
|
26
|
+
if (typeof c === "number") {
|
|
27
|
+
this.r += c;
|
|
28
|
+
} else {
|
|
29
|
+
this.r += c.r;
|
|
30
|
+
this.i += c.i;
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
static add(c1, c2) {
|
|
35
|
+
return c1.copy().add(c2);
|
|
36
|
+
}
|
|
37
|
+
sub(c) {
|
|
38
|
+
if (typeof c === "number") {
|
|
39
|
+
this.r -= c;
|
|
40
|
+
} else {
|
|
41
|
+
this.r -= c.r;
|
|
42
|
+
this.i -= c.i;
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
static sub(c1, c2) {
|
|
47
|
+
return c1.copy().sub(c2);
|
|
48
|
+
}
|
|
49
|
+
mul(c) {
|
|
50
|
+
if (typeof c === "number") {
|
|
51
|
+
this.r *= c;
|
|
52
|
+
this.i *= c;
|
|
53
|
+
} else {
|
|
54
|
+
const { r, i } = this;
|
|
55
|
+
this.r = r * c.r - i * c.i;
|
|
56
|
+
this.i = r * c.i + i * c.r;
|
|
57
|
+
}
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
static mul(c1, c2) {
|
|
61
|
+
return c1.copy().mul(c2);
|
|
62
|
+
}
|
|
63
|
+
div(c) {
|
|
64
|
+
if (typeof c === "number") {
|
|
65
|
+
this.r /= c;
|
|
66
|
+
this.i /= c;
|
|
67
|
+
} else {
|
|
68
|
+
const { conj: conjugate } = c;
|
|
69
|
+
this.mul(conjugate).div(c.mul(conjugate).r);
|
|
70
|
+
}
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
static div(c1, c2) {
|
|
74
|
+
return c1.copy().div(c2);
|
|
75
|
+
}
|
|
76
|
+
sq() {
|
|
77
|
+
const { r, i } = this;
|
|
78
|
+
this.r = r * r - i * i;
|
|
79
|
+
const i2 = r * i;
|
|
80
|
+
this.i = i2 + i2;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
mag() {
|
|
84
|
+
return Math.sqrt(this.magSq());
|
|
85
|
+
}
|
|
86
|
+
magSq() {
|
|
87
|
+
const { r, i } = this;
|
|
88
|
+
return r * r + i * i;
|
|
89
|
+
}
|
|
90
|
+
angle() {
|
|
91
|
+
return Math.atan2(this.i, this.r);
|
|
92
|
+
}
|
|
93
|
+
pow(z) {
|
|
94
|
+
const { r, i } = this;
|
|
95
|
+
const { r: r2, i: i2 } = z;
|
|
96
|
+
this.r = r ** r2 * i ** i2;
|
|
97
|
+
this.i = r ** i2 * i ** r2;
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
function complex(real, imaginary) {
|
|
102
|
+
return new Complex(real, imaginary);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/cmath/funcs.ts
|
|
106
|
+
function csqrt(z) {
|
|
107
|
+
const { r, i } = z;
|
|
108
|
+
const mag = z.mag();
|
|
109
|
+
const r2 = Math.sqrt(0.5 * (mag + r));
|
|
110
|
+
const i2 = Math.sign(i) * Math.sqrt(0.5 * (mag - r));
|
|
111
|
+
return complex(r2, i2);
|
|
112
|
+
}
|
|
113
|
+
function clog(z) {
|
|
114
|
+
return complex(Math.log(z.mag()), z.angle());
|
|
115
|
+
}
|
|
116
|
+
var cln = clog;
|
|
117
|
+
function cexp({ r, i }) {
|
|
118
|
+
const er = Math.exp(r);
|
|
119
|
+
return complex(er * Math.cos(i), er * Math.sin(i));
|
|
120
|
+
}
|
|
121
|
+
function csin({ r, i }) {
|
|
122
|
+
return complex(Math.sin(r) * Math.cosh(i), Math.cos(r) * Math.sinh(i));
|
|
123
|
+
}
|
|
124
|
+
function ccos({ r, i }) {
|
|
125
|
+
return complex(Math.cos(r) * Math.cosh(i), -Math.sin(r) * Math.sinh(i));
|
|
126
|
+
}
|
|
127
|
+
function ctan(z) {
|
|
128
|
+
return csin(z).div(ccos(z));
|
|
129
|
+
}
|
|
130
|
+
function casin({ r, i }) {
|
|
131
|
+
return complex(Math.asin(r) * Math.cosh(i), Math.acos(r) * Math.sinh(i));
|
|
132
|
+
}
|
|
133
|
+
function cacos({ r, i }) {
|
|
134
|
+
return complex(Math.acos(r) * Math.cosh(i), -Math.asin(r) * Math.sinh(i));
|
|
135
|
+
}
|
|
136
|
+
function catan({ r, i }) {
|
|
137
|
+
return complex(Math.atan(r) * Math.cosh(i), Math.atan(r) * Math.sinh(i));
|
|
138
|
+
}
|
|
139
|
+
function csinh({ r, i }) {
|
|
140
|
+
return complex(Math.sinh(r) * Math.cos(i), Math.cosh(r) * Math.sin(i));
|
|
141
|
+
}
|
|
142
|
+
function ccosh({ r, i }) {
|
|
143
|
+
return complex(Math.cosh(r) * Math.cos(i), Math.sinh(r) * Math.sin(i));
|
|
144
|
+
}
|
|
145
|
+
function ctanh(z) {
|
|
146
|
+
return csinh(z).div(ccosh(z));
|
|
147
|
+
}
|
|
148
|
+
function casinh({ r, i }) {
|
|
149
|
+
return complex(Math.asinh(r) * Math.cos(i), Math.acosh(r) * Math.sin(i));
|
|
150
|
+
}
|
|
151
|
+
function cacosh({ r, i }) {
|
|
152
|
+
return complex(Math.acosh(r) * Math.cos(i), Math.asinh(r) * Math.sin(i));
|
|
153
|
+
}
|
|
154
|
+
function catanh({ r, i }) {
|
|
155
|
+
return complex(Math.atanh(r) * Math.cos(i), Math.atanh(r) * Math.sin(i));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/cmath/algebra.ts
|
|
159
|
+
function cquadraticRoots(a, b, c) {
|
|
160
|
+
const discriminant = b * b - 4 * a * c;
|
|
161
|
+
const d = csqrt(complex(discriminant));
|
|
162
|
+
return [
|
|
163
|
+
Complex.sub(d, b).div(2 * a),
|
|
164
|
+
Complex.sub(d, b).mul(-1).div(2 * a)
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
Complex,
|
|
169
|
+
cacos,
|
|
170
|
+
cacosh,
|
|
171
|
+
casin,
|
|
172
|
+
casinh,
|
|
173
|
+
catan,
|
|
174
|
+
catanh,
|
|
175
|
+
ccos,
|
|
176
|
+
ccosh,
|
|
177
|
+
cexp,
|
|
178
|
+
cln,
|
|
179
|
+
clog,
|
|
180
|
+
complex,
|
|
181
|
+
cquadraticRoots,
|
|
182
|
+
csin,
|
|
183
|
+
csinh,
|
|
184
|
+
csqrt,
|
|
185
|
+
ctan,
|
|
186
|
+
ctanh
|
|
187
|
+
};
|
package/dist/cmp.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* Simple comparison functions
|
|
4
|
+
*/
|
|
5
|
+
type Compare<T> = (a: T, b: T) => number;
|
|
6
|
+
declare const ascend: <T>(a: T, b: T) => number;
|
|
7
|
+
declare const descend: <T>(a: T, b: T) => number;
|
|
8
|
+
declare const ascendBy: <T, U>(f: (x: T) => U) => Compare<T>;
|
|
9
|
+
declare const descendBy: <T, U>(f: (x: T) => U) => Compare<T>;
|
|
10
|
+
|
|
11
|
+
export { type Compare, ascend, ascendBy, descend, descendBy };
|
package/dist/cmp.js
ADDED
package/dist/csv.d.ts
ADDED
package/dist/csv.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/csv.ts
|
|
2
|
+
var specialCharRegex = /",\n/;
|
|
3
|
+
function formatCsv(rows) {
|
|
4
|
+
return rows.map(
|
|
5
|
+
(row) => row.map((value) => {
|
|
6
|
+
const str = `${value}`;
|
|
7
|
+
if (specialCharRegex.test(str)) {
|
|
8
|
+
return `"${str.replaceAll('"', '""')}"`;
|
|
9
|
+
}
|
|
10
|
+
return str;
|
|
11
|
+
}).join(",")
|
|
12
|
+
).join("\n");
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
formatCsv
|
|
16
|
+
};
|
package/dist/easing.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* Easing functions
|
|
4
|
+
*/
|
|
5
|
+
declare function linear(t: number): number;
|
|
6
|
+
declare function easeInQuad(t: number): number;
|
|
7
|
+
declare function easeOutQuad(t: number): number;
|
|
8
|
+
declare function easeInOutQuad(t: number): number;
|
|
9
|
+
declare function easeInCubic(t: number): number;
|
|
10
|
+
declare function easeOutCubic(t: number): number;
|
|
11
|
+
declare function easeInOutCubic(t: number): number;
|
|
12
|
+
declare function easeInQuart(t: number): number;
|
|
13
|
+
declare function easeOutQuart(t: number): number;
|
|
14
|
+
declare function easeInOutQuart(t: number): number;
|
|
15
|
+
declare function easeInQuint(t: number): number;
|
|
16
|
+
declare function easeOutQuint(t: number): number;
|
|
17
|
+
declare function easeInOutQuint(t: number): number;
|
|
18
|
+
declare function easeInSine(t: number): number;
|
|
19
|
+
declare function easeOutSine(t: number): number;
|
|
20
|
+
declare function easeInOutSine(t: number): number;
|
|
21
|
+
declare function easeInExpo(t: number): number;
|
|
22
|
+
declare function easeOutExpo(t: number): number;
|
|
23
|
+
declare function easeInOutExpo(t: number): number;
|
|
24
|
+
declare function easeInCirc(t: number): number;
|
|
25
|
+
declare function easeOutCirc(t: number): number;
|
|
26
|
+
declare function easeInOutCirc(t: number): number;
|
|
27
|
+
declare function easeInElastic(t: number): number;
|
|
28
|
+
declare function easeOutElastic(t: number): number;
|
|
29
|
+
declare function easeInOutElastic(t: number): number;
|
|
30
|
+
declare function easeInBack(t: number): number;
|
|
31
|
+
declare function easeOutBack(t: number): number;
|
|
32
|
+
declare function easeInOutBack(t: number): number;
|
|
33
|
+
declare function easeInBounce(t: number): number;
|
|
34
|
+
declare function easeOutBounce(t: number): number;
|
|
35
|
+
declare function easeInOutBounce(t: number): number;
|
|
36
|
+
|
|
37
|
+
export { easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, linear };
|
package/dist/easing.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// src/easing.ts
|
|
2
|
+
function linear(t) {
|
|
3
|
+
return t;
|
|
4
|
+
}
|
|
5
|
+
function easeInQuad(t) {
|
|
6
|
+
return t * t;
|
|
7
|
+
}
|
|
8
|
+
function easeOutQuad(t) {
|
|
9
|
+
return t * (2 - t);
|
|
10
|
+
}
|
|
11
|
+
function easeInOutQuad(t) {
|
|
12
|
+
const t2 = 2 * t;
|
|
13
|
+
return t < 0.5 ? t2 * t : -1 + (4 - t2) * t;
|
|
14
|
+
}
|
|
15
|
+
function easeInCubic(t) {
|
|
16
|
+
return t * t * t;
|
|
17
|
+
}
|
|
18
|
+
function easeOutCubic(t) {
|
|
19
|
+
return 1 + --t * t * t;
|
|
20
|
+
}
|
|
21
|
+
function easeInOutCubic(t) {
|
|
22
|
+
const a = 2 * t - 2;
|
|
23
|
+
return t < 0.5 ? 4 * t * t * t : (t - 1) * a * a + 1;
|
|
24
|
+
}
|
|
25
|
+
function easeInQuart(t) {
|
|
26
|
+
const tt = t * t;
|
|
27
|
+
return tt * tt;
|
|
28
|
+
}
|
|
29
|
+
function easeOutQuart(t) {
|
|
30
|
+
const tt = --t * t;
|
|
31
|
+
return 1 - tt * tt;
|
|
32
|
+
}
|
|
33
|
+
function easeInOutQuart(t) {
|
|
34
|
+
const firstHalf = t < 0.5;
|
|
35
|
+
const tt = t * t;
|
|
36
|
+
const a = --t * t;
|
|
37
|
+
return firstHalf ? 8 * tt * tt : 1 - 8 * a * a;
|
|
38
|
+
}
|
|
39
|
+
function easeInQuint(t) {
|
|
40
|
+
const tt = t * t;
|
|
41
|
+
return tt * tt * t;
|
|
42
|
+
}
|
|
43
|
+
function easeOutQuint(t) {
|
|
44
|
+
const tt = --t * t;
|
|
45
|
+
return 1 + tt * tt * t;
|
|
46
|
+
}
|
|
47
|
+
function easeInOutQuint(t) {
|
|
48
|
+
const firstHalf = t < 0.5;
|
|
49
|
+
const tt = t * t;
|
|
50
|
+
const a = --t * t;
|
|
51
|
+
return firstHalf ? 16 * tt * tt * t : 1 + 16 * a * a * t;
|
|
52
|
+
}
|
|
53
|
+
function easeInSine(t) {
|
|
54
|
+
return 1 - Math.cos(t * Math.PI / 2);
|
|
55
|
+
}
|
|
56
|
+
function easeOutSine(t) {
|
|
57
|
+
return Math.sin(t * Math.PI / 2);
|
|
58
|
+
}
|
|
59
|
+
function easeInOutSine(t) {
|
|
60
|
+
return -(Math.cos(t * Math.PI) - 1) / 2;
|
|
61
|
+
}
|
|
62
|
+
function easeInExpo(t) {
|
|
63
|
+
return t === 0 ? 0 : 2 ** (10 * (t - 1));
|
|
64
|
+
}
|
|
65
|
+
function easeOutExpo(t) {
|
|
66
|
+
return t === 1 ? 1 : -(2 ** (-10 * t)) + 1;
|
|
67
|
+
}
|
|
68
|
+
function easeInOutExpo(t) {
|
|
69
|
+
if (t === 0 || t === 1) {
|
|
70
|
+
return t;
|
|
71
|
+
}
|
|
72
|
+
return t < 0.5 ? 2 ** (20 * (t - 1)) / 2 : -(2 ** (-20 * t)) / 2 + 1;
|
|
73
|
+
}
|
|
74
|
+
function easeInCirc(t) {
|
|
75
|
+
return 1 - Math.sqrt(1 - t * t);
|
|
76
|
+
}
|
|
77
|
+
function easeOutCirc(t) {
|
|
78
|
+
return Math.sqrt(1 - --t * t);
|
|
79
|
+
}
|
|
80
|
+
function easeInOutCirc(t) {
|
|
81
|
+
return t < 0.5 ? (1 - Math.sqrt(1 - 2 * t)) / 2 : (Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
|
|
82
|
+
}
|
|
83
|
+
function easeInElastic(t) {
|
|
84
|
+
if (t === 0 || t === 1) {
|
|
85
|
+
return t;
|
|
86
|
+
}
|
|
87
|
+
return -(2 ** (10 * (t - 1))) * Math.sin((t - 1.1) * 5 * Math.PI);
|
|
88
|
+
}
|
|
89
|
+
function easeOutElastic(t) {
|
|
90
|
+
if (t === 0 || t === 1) {
|
|
91
|
+
return t;
|
|
92
|
+
}
|
|
93
|
+
return 2 ** (-10 * t) * Math.sin((t - 0.1) * 5 * Math.PI) + 1;
|
|
94
|
+
}
|
|
95
|
+
function easeInOutElastic(t) {
|
|
96
|
+
if (t === 0 || t === 1) {
|
|
97
|
+
return t;
|
|
98
|
+
}
|
|
99
|
+
return t < 0.5 ? -(2 ** (20 * (t - 1)) * Math.sin((t - 1.1) * 5 * Math.PI)) / 2 : 2 ** (-20 * t) * Math.sin((t - 1.1) * 5 * Math.PI) / 2 + 1;
|
|
100
|
+
}
|
|
101
|
+
function easeInBack(t) {
|
|
102
|
+
return t * t * (2.70158 * t - 1.70158);
|
|
103
|
+
}
|
|
104
|
+
function easeOutBack(t) {
|
|
105
|
+
return --t * t * (2.70158 * t + 1.70158) + 1;
|
|
106
|
+
}
|
|
107
|
+
function easeInOutBack(t) {
|
|
108
|
+
return t < 0.5 ? (2.70158 * t * t * t + 2) / 2 : (1.70158 * (t - 1) * (t - 1) * (t - 1) + 2) / 2;
|
|
109
|
+
}
|
|
110
|
+
function easeInBounce(t) {
|
|
111
|
+
return 1 - easeOutBounce(1 - t);
|
|
112
|
+
}
|
|
113
|
+
function easeOutBounce(t) {
|
|
114
|
+
if (t < 1 / 2.75) {
|
|
115
|
+
return 7.5625 * t * t;
|
|
116
|
+
}
|
|
117
|
+
if (t < 2 / 2.75) {
|
|
118
|
+
return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75;
|
|
119
|
+
}
|
|
120
|
+
return t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
|
|
121
|
+
}
|
|
122
|
+
function easeInOutBounce(t) {
|
|
123
|
+
return t < 0.5 ? (1 - easeOutBounce(1 - t * 2)) / 2 : (easeOutBounce(t * 2 - 1) + 1) / 2;
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
easeInBack,
|
|
127
|
+
easeInBounce,
|
|
128
|
+
easeInCirc,
|
|
129
|
+
easeInCubic,
|
|
130
|
+
easeInElastic,
|
|
131
|
+
easeInExpo,
|
|
132
|
+
easeInOutBack,
|
|
133
|
+
easeInOutBounce,
|
|
134
|
+
easeInOutCirc,
|
|
135
|
+
easeInOutCubic,
|
|
136
|
+
easeInOutElastic,
|
|
137
|
+
easeInOutExpo,
|
|
138
|
+
easeInOutQuad,
|
|
139
|
+
easeInOutQuart,
|
|
140
|
+
easeInOutQuint,
|
|
141
|
+
easeInOutSine,
|
|
142
|
+
easeInQuad,
|
|
143
|
+
easeInQuart,
|
|
144
|
+
easeInQuint,
|
|
145
|
+
easeInSine,
|
|
146
|
+
easeOutBack,
|
|
147
|
+
easeOutBounce,
|
|
148
|
+
easeOutCirc,
|
|
149
|
+
easeOutCubic,
|
|
150
|
+
easeOutElastic,
|
|
151
|
+
easeOutExpo,
|
|
152
|
+
easeOutQuad,
|
|
153
|
+
easeOutQuart,
|
|
154
|
+
easeOutQuint,
|
|
155
|
+
easeOutSine,
|
|
156
|
+
linear
|
|
157
|
+
};
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AnyRecord, uint } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module
|
|
5
|
+
* EventEmitter implementation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type Unsubscribe = () => void;
|
|
9
|
+
declare class EventEmitter<Events extends AnyRecord = AnyRecord> {
|
|
10
|
+
private readonly events;
|
|
11
|
+
listenersCount(event?: keyof Events): uint;
|
|
12
|
+
listeners(event: keyof Events): Array<(data: Events[keyof Events]) => any>;
|
|
13
|
+
on<EventName extends keyof Events>(event: EventName, listener: (data: Events[EventName]) => any): Unsubscribe;
|
|
14
|
+
once<EventName extends keyof Events>(event: EventName, listener: (data: Events[EventName]) => any): Unsubscribe;
|
|
15
|
+
emit<EventName extends keyof Events>(event: EventName, data: Events[EventName]): this;
|
|
16
|
+
off<EventName extends keyof Events>(event: EventName, listener: (data: Events[EventName]) => any): boolean;
|
|
17
|
+
removeAllListeners(event?: keyof Events): this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { EventEmitter };
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sum
|
|
3
|
+
} from "./chunk-C2DS6YRJ.js";
|
|
4
|
+
import "./chunk-EWSJTMH2.js";
|
|
5
|
+
import "./chunk-ILLWUQPY.js";
|
|
6
|
+
import {
|
|
7
|
+
pick
|
|
8
|
+
} from "./chunk-WBSY6KRH.js";
|
|
9
|
+
import {
|
|
10
|
+
pipe
|
|
11
|
+
} from "./chunk-MG5VQSTV.js";
|
|
12
|
+
import "./chunk-6F4PWJZI.js";
|
|
13
|
+
import "./chunk-TMLWLR46.js";
|
|
14
|
+
import "./chunk-LJSF3QBT.js";
|
|
15
|
+
|
|
16
|
+
// src/events.ts
|
|
17
|
+
var EventEmitter = class {
|
|
18
|
+
events = /* @__PURE__ */ new Map();
|
|
19
|
+
listenersCount(event) {
|
|
20
|
+
if (event) {
|
|
21
|
+
return this.events.get(event)?.size || 0;
|
|
22
|
+
}
|
|
23
|
+
return pipe(this.events.values(), pick("size"), sum);
|
|
24
|
+
}
|
|
25
|
+
listeners(event) {
|
|
26
|
+
return [...this.events.get(event) || []];
|
|
27
|
+
}
|
|
28
|
+
on(event, listener) {
|
|
29
|
+
const listeners = this.events.get(event) || /* @__PURE__ */ new Set();
|
|
30
|
+
listeners.add(listener);
|
|
31
|
+
this.events.set(event, listeners);
|
|
32
|
+
return () => {
|
|
33
|
+
listeners.delete(listener);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
once(event, listener) {
|
|
37
|
+
const unsubscribe = this.on(event, (data) => {
|
|
38
|
+
unsubscribe();
|
|
39
|
+
listener(data);
|
|
40
|
+
});
|
|
41
|
+
return unsubscribe;
|
|
42
|
+
}
|
|
43
|
+
emit(event, data) {
|
|
44
|
+
const listeners = this.events.get(event);
|
|
45
|
+
if (listeners) {
|
|
46
|
+
for (const listener of listeners) {
|
|
47
|
+
listener(data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
off(event, listener) {
|
|
53
|
+
const listeners = this.events.get(event);
|
|
54
|
+
return listeners?.delete(listener) || false;
|
|
55
|
+
}
|
|
56
|
+
removeAllListeners(event) {
|
|
57
|
+
if (event) {
|
|
58
|
+
this.events.delete(event);
|
|
59
|
+
} else {
|
|
60
|
+
this.events.clear();
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
EventEmitter
|
|
67
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Awaitable, AnyFunction, Maybe } from '../types.js';
|
|
2
|
+
|
|
3
|
+
interface Pipe {
|
|
4
|
+
<T>(x: T): T;
|
|
5
|
+
<T, R0>(x: T, fn0: (x: T) => R0): R0;
|
|
6
|
+
<T, R0, R1>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1): R1;
|
|
7
|
+
<T, R0, R1, R2>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2): R2;
|
|
8
|
+
<T, R0, R1, R2, R3>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2, fn3: (x: R2) => R3): R3;
|
|
9
|
+
<T, R0, R1, R2, R3, R4>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2, fn3: (x: R2) => R3, fn4: (x: R3) => R4): R4;
|
|
10
|
+
<T, R0, R1, R2, R3, R4, R5>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2, fn3: (x: R2) => R3, fn4: (x: R3) => R4, fn5: (x: R4) => R5): R5;
|
|
11
|
+
<T, R0, R1, R2, R3, R4, R5, R6>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2, fn3: (x: R2) => R3, fn4: (x: R3) => R4, fn5: (x: R4) => R5, fn6: (x: R5) => R6): R6;
|
|
12
|
+
<T, R0, R1, R2, R3, R4, R5, R6, R7>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2, fn3: (x: R2) => R3, fn4: (x: R3) => R4, fn5: (x: R4) => R5, fn6: (x: R5) => R6, fn7: (x: R6) => R7): R7;
|
|
13
|
+
<T, R0, R1, R2, R3, R4, R5, R6, R7, R8>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2, fn3: (x: R2) => R3, fn4: (x: R3) => R4, fn5: (x: R4) => R5, fn6: (x: R5) => R6, fn7: (x: R6) => R7, fn8: (x: R7) => R8): R8;
|
|
14
|
+
<T, R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>(x: T, fn0: (x: T) => R0, fn1: (x: R0) => R1, fn2: (x: R1) => R2, fn3: (x: R2) => R3, fn4: (x: R3) => R4, fn5: (x: R4) => R5, fn6: (x: R5) => R6, fn7: (x: R6) => R7, fn8: (x: R7) => R8, fn9: (x: R8) => R9): R9;
|
|
15
|
+
}
|
|
16
|
+
declare const pipe: Pipe;
|
|
17
|
+
interface AsyncPipe {
|
|
18
|
+
<T>(x: Awaitable<T>): Promise<T>;
|
|
19
|
+
<T, R0>(x: Awaitable<T>, fn0: (x: T) => Awaitable<R0>): Promise<R0>;
|
|
20
|
+
<T, R0, R1>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>): Promise<R1>;
|
|
21
|
+
<T, R0, R1, R2>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>): Promise<R2>;
|
|
22
|
+
<T, R0, R1, R2, R3>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>, fn3: (x: Awaited<R2>) => Awaitable<R3>): Promise<R3>;
|
|
23
|
+
<T, R0, R1, R2, R3, R4>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>, fn3: (x: Awaited<R2>) => Awaitable<R3>, fn4: (x: Awaited<R3>) => Awaitable<R4>): Promise<R4>;
|
|
24
|
+
<T, R0, R1, R2, R3, R4, R5>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>, fn3: (x: Awaited<R2>) => Awaitable<R3>, fn4: (x: Awaited<R3>) => Awaitable<R4>, fn5: (x: Awaited<R4>) => Awaitable<R5>): Promise<R5>;
|
|
25
|
+
<T, R0, R1, R2, R3, R4, R5, R6>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>, fn3: (x: Awaited<R2>) => Awaitable<R3>, fn4: (x: Awaited<R3>) => Awaitable<R4>, fn5: (x: Awaited<R4>) => Awaitable<R5>, fn6: (x: Awaited<R5>) => Awaitable<R6>): Promise<R6>;
|
|
26
|
+
<T, R0, R1, R2, R3, R4, R5, R6, R7>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>, fn3: (x: Awaited<R2>) => Awaitable<R3>, fn4: (x: Awaited<R3>) => Awaitable<R4>, fn5: (x: Awaited<R4>) => Awaitable<R5>, fn6: (x: Awaited<R5>) => Awaitable<R6>, fn7: (x: Awaited<R6>) => Awaitable<R7>): Promise<R7>;
|
|
27
|
+
<T, R0, R1, R2, R3, R4, R5, R6, R7, R8>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>, fn3: (x: Awaited<R2>) => Awaitable<R3>, fn4: (x: Awaited<R3>) => Awaitable<R4>, fn5: (x: Awaited<R4>) => Awaitable<R5>, fn6: (x: Awaited<R5>) => Awaitable<R6>, fn7: (x: Awaited<R6>) => Awaitable<R7>, fn8: (x: Awaited<R7>) => Awaitable<R8>): Promise<R8>;
|
|
28
|
+
<T, R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>(x: Awaitable<T>, fn0: (x: Awaited<T>) => Awaitable<R0>, fn1: (x: Awaited<R0>) => Awaitable<R1>, fn2: (x: Awaited<R1>) => Awaitable<R2>, fn3: (x: Awaited<R2>) => Awaitable<R3>, fn4: (x: Awaited<R3>) => Awaitable<R4>, fn5: (x: Awaited<R4>) => Awaitable<R5>, fn6: (x: Awaited<R5>) => Awaitable<R6>, fn7: (x: Awaited<R6>) => Awaitable<R7>, fn8: (x: Awaited<R7>) => Awaitable<R8>, fn9: (x: Awaited<R8>) => Awaitable<R9>): Promise<R9>;
|
|
29
|
+
}
|
|
30
|
+
declare const asyncPipe: AsyncPipe;
|
|
31
|
+
|
|
32
|
+
type ReverseCurry<Fn extends AnyFunction, Args = Parameters<Fn>> = Args extends [infer First, ...infer Rest] ? {
|
|
33
|
+
(first: First, ...rest: Rest): ReturnType<Fn>;
|
|
34
|
+
(...rest: Rest): (first: First) => ReturnType<Fn>;
|
|
35
|
+
} : never;
|
|
36
|
+
/**
|
|
37
|
+
* Create a function that takes in the first parameter of another, to be used in a pipe
|
|
38
|
+
* @param fn
|
|
39
|
+
* @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`
|
|
40
|
+
*/
|
|
41
|
+
declare const reverseCurry: <Fn extends AnyFunction>(fn: Fn) => ReverseCurry<Fn>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @module
|
|
45
|
+
* Common function wrappers and utilities
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
declare const noop: () => void;
|
|
49
|
+
declare const identity: <T>(x: T) => T;
|
|
50
|
+
declare const constant: <T>(x: T) => (() => T);
|
|
51
|
+
/**
|
|
52
|
+
* Allows a function to be called only once
|
|
53
|
+
*/
|
|
54
|
+
declare function once<T>(fn: () => T): () => Maybe<T>;
|
|
55
|
+
/**
|
|
56
|
+
* Caches the result of a function for each given parameter
|
|
57
|
+
*/
|
|
58
|
+
declare function memoize<P, R>(func: (arg: P) => R): (arg: P) => R;
|
|
59
|
+
interface Memo<Return> {
|
|
60
|
+
(): Return;
|
|
61
|
+
invalidate: () => void;
|
|
62
|
+
}
|
|
63
|
+
declare function memo<T>(fn: () => T): Memo<T>;
|
|
64
|
+
declare function ttlCache<T>(fn: () => T, ttl: number): () => T;
|
|
65
|
+
|
|
66
|
+
export { type AsyncPipe, type Memo, type Pipe, type ReverseCurry, asyncPipe, constant, identity, memo, memoize, noop, once, pipe, reverseCurry, ttlCache };
|
package/dist/fn/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asyncPipe,
|
|
3
|
+
constant,
|
|
4
|
+
identity,
|
|
5
|
+
memo,
|
|
6
|
+
memoize,
|
|
7
|
+
noop,
|
|
8
|
+
once,
|
|
9
|
+
pipe,
|
|
10
|
+
reverseCurry,
|
|
11
|
+
ttlCache
|
|
12
|
+
} from "../chunk-MG5VQSTV.js";
|
|
13
|
+
import "../chunk-6F4PWJZI.js";
|
|
14
|
+
export {
|
|
15
|
+
asyncPipe,
|
|
16
|
+
constant,
|
|
17
|
+
identity,
|
|
18
|
+
memo,
|
|
19
|
+
memoize,
|
|
20
|
+
noop,
|
|
21
|
+
once,
|
|
22
|
+
pipe,
|
|
23
|
+
reverseCurry,
|
|
24
|
+
ttlCache
|
|
25
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { V as Vec3 } from '../vec3-D7Wuy2AZ.js';
|
|
2
|
+
|
|
3
|
+
declare function hsv2rgb(h: number, s: number, v: number): Vec3;
|
|
4
|
+
/**
|
|
5
|
+
* Calculates the CIE luminance of a color
|
|
6
|
+
* @param r red
|
|
7
|
+
* @param g green
|
|
8
|
+
* @param b blue
|
|
9
|
+
* @returns the luminance of the color
|
|
10
|
+
*/
|
|
11
|
+
declare function luminance(r: number, g: number, b: number): number;
|
|
12
|
+
|
|
13
|
+
export { hsv2rgb, luminance };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
vec3
|
|
3
|
+
} from "../chunk-C2DS6YRJ.js";
|
|
4
|
+
import "../chunk-EWSJTMH2.js";
|
|
5
|
+
import "../chunk-ILLWUQPY.js";
|
|
6
|
+
import "../chunk-WBSY6KRH.js";
|
|
7
|
+
import "../chunk-MG5VQSTV.js";
|
|
8
|
+
import "../chunk-6F4PWJZI.js";
|
|
9
|
+
import "../chunk-TMLWLR46.js";
|
|
10
|
+
import "../chunk-LJSF3QBT.js";
|
|
11
|
+
|
|
12
|
+
// src/gfx/color.ts
|
|
13
|
+
function hsv2rgb(h, s, v) {
|
|
14
|
+
let r = 0;
|
|
15
|
+
let g = 0;
|
|
16
|
+
let b = 0;
|
|
17
|
+
const i = Math.floor(h * 6);
|
|
18
|
+
const f = h * 6 - i;
|
|
19
|
+
const p = v * (1 - s);
|
|
20
|
+
const q = v * (1 - f * s);
|
|
21
|
+
const t = v * (1 - (1 - f) * s);
|
|
22
|
+
switch (i % 6) {
|
|
23
|
+
case 0: {
|
|
24
|
+
r = v;
|
|
25
|
+
g = t;
|
|
26
|
+
b = p;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case 1: {
|
|
30
|
+
r = q;
|
|
31
|
+
g = v;
|
|
32
|
+
b = p;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case 2: {
|
|
36
|
+
r = p;
|
|
37
|
+
g = v;
|
|
38
|
+
b = t;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case 3: {
|
|
42
|
+
r = p;
|
|
43
|
+
g = q;
|
|
44
|
+
b = v;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 4: {
|
|
48
|
+
r = t;
|
|
49
|
+
g = p;
|
|
50
|
+
b = v;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case 5: {
|
|
54
|
+
r = v;
|
|
55
|
+
g = p;
|
|
56
|
+
b = q;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return vec3(Math.floor(r * 256), Math.floor(g * 256), Math.floor(b * 256));
|
|
61
|
+
}
|
|
62
|
+
function luminance(r, g, b) {
|
|
63
|
+
return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 256;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
hsv2rgb,
|
|
67
|
+
luminance
|
|
68
|
+
};
|