@limitlesspc/std 0.23.5 → 0.24.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 +2 -39
- package/dist/array.js +1 -10
- package/dist/bytes.js +4 -4
- package/dist/{chunk-NXILTE26.js → chunk-7LRKWWT5.js} +3 -1
- package/dist/{chunk-4POIKW4G.js → chunk-IZDNCBBO.js} +2 -25
- package/dist/{chunk-4AJ6WSEF.js → chunk-LPLI3P2H.js} +9 -9
- package/dist/{chunk-ZAXC26KZ.js → chunk-OMJMLVK3.js} +5 -5
- package/dist/{chunk-LJSF3QBT.js → chunk-XCUELLWZ.js} +5 -3
- package/dist/{chunk-CCBSTDYA.js → chunk-XEPJIWIE.js} +22 -33
- package/dist/csv.d.ts +2 -1
- package/dist/csv.js +52 -2
- package/dist/easing.d.ts +15 -0
- package/dist/easing.js +67 -0
- package/dist/events.js +6 -6
- package/dist/fn/index.js +1 -1
- package/dist/gfx/index.js +6 -6
- package/dist/iter/index.d.ts +6 -10
- package/dist/iter/index.js +3 -5
- package/dist/math/index.js +6 -6
- package/dist/object.d.ts +11 -9
- package/dist/object.js +1 -1
- package/dist/random.js +2 -5
- package/dist/string/index.d.ts +1 -1
- package/dist/structs/index.js +1 -4
- package/package.json +7 -3
package/dist/array.d.ts
CHANGED
|
@@ -124,18 +124,6 @@ declare function difference<T>(array1: readonly T[], array2: readonly T[]): T[];
|
|
|
124
124
|
* ```
|
|
125
125
|
*/
|
|
126
126
|
declare function union<T>(...arrays: Array<Iterable<T>>): T[];
|
|
127
|
-
/**
|
|
128
|
-
* Test if two arrays contain the same items in the same order
|
|
129
|
-
* @param a
|
|
130
|
-
* @param b
|
|
131
|
-
* @returns if the arrays are equal
|
|
132
|
-
* @example
|
|
133
|
-
* ```ts
|
|
134
|
-
* console.log(equal([1, 2, 3], [1, 2, 3])); // true
|
|
135
|
-
* console.log(equal([1, 2, 3], [3, 2, 1])); // false
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
declare function equal<T>(a: readonly T[], b: readonly T[]): boolean;
|
|
139
127
|
/**
|
|
140
128
|
* Check if an array contains at least one of the items in another
|
|
141
129
|
* @param a the array to check
|
|
@@ -198,32 +186,7 @@ declare function dedupe<T>(array: Iterable<T>): T[];
|
|
|
198
186
|
* // "dog",
|
|
199
187
|
* // ]
|
|
200
188
|
*/
|
|
201
|
-
declare function dedupeBy<T>(array: Iterable<T>,
|
|
202
|
-
/**
|
|
203
|
-
* Returns a new array with items with a unique key
|
|
204
|
-
* @param array
|
|
205
|
-
* @param key
|
|
206
|
-
* @example
|
|
207
|
-
* ```ts
|
|
208
|
-
* const array = [
|
|
209
|
-
* { id: 1, name: "Alice" },
|
|
210
|
-
* { id: 2, name: "Bob" },
|
|
211
|
-
* { id: 1, name: "Charlie" },
|
|
212
|
-
* { id: 3, name: "David" },
|
|
213
|
-
* { id: 2, name: "Eve" },
|
|
214
|
-
* { id: 4, name: "Frank" },
|
|
215
|
-
* ];
|
|
216
|
-
* console.log(dedupeByKey(array, "id")); // [
|
|
217
|
-
* // { id: 1, name: "Alice" },
|
|
218
|
-
* // { id: 2, name: "Bob" },
|
|
219
|
-
* // { id: 3, name: "David" },
|
|
220
|
-
* // { id: 4, name: "Frank" }
|
|
221
|
-
* // ]
|
|
222
|
-
*/
|
|
223
|
-
declare function dedupeByKey<T extends {
|
|
224
|
-
[K in keyof T]: T[K];
|
|
225
|
-
}>(array: Iterable<T>, key: keyof T): T[];
|
|
226
|
-
declare function filterByKey<T>(array: readonly T[], key: keyof T): T[];
|
|
189
|
+
declare function dedupeBy<T, U>(array: Iterable<T>, callback: (item: T) => U): T[];
|
|
227
190
|
/**
|
|
228
191
|
* Sorts an array of objects by the value of a key
|
|
229
192
|
* @param array
|
|
@@ -245,4 +208,4 @@ declare function filterByKey<T>(array: readonly T[], key: keyof T): T[];
|
|
|
245
208
|
*/
|
|
246
209
|
declare function sortByKeys<T, K extends keyof T>(array: readonly T[], key: MaybeArray<K>, compare?: Compare<T[K]>): T[];
|
|
247
210
|
|
|
248
|
-
export { added, changes, dedupe, dedupeBy,
|
|
211
|
+
export { added, changes, dedupe, dedupeBy, difference, hasChange, includesAll, includesAny, intersection, remove, removed, sortByKeys, swap, union, unorderedRemove };
|
package/dist/array.js
CHANGED
|
@@ -3,10 +3,7 @@ import {
|
|
|
3
3
|
changes,
|
|
4
4
|
dedupe,
|
|
5
5
|
dedupeBy,
|
|
6
|
-
dedupeByKey,
|
|
7
6
|
difference,
|
|
8
|
-
equal,
|
|
9
|
-
filterByKey,
|
|
10
7
|
hasChange,
|
|
11
8
|
includesAll,
|
|
12
9
|
includesAny,
|
|
@@ -17,20 +14,14 @@ import {
|
|
|
17
14
|
swap,
|
|
18
15
|
union,
|
|
19
16
|
unorderedRemove
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-CCBSTDYA.js";
|
|
22
|
-
import "./chunk-NXILTE26.js";
|
|
17
|
+
} from "./chunk-IZDNCBBO.js";
|
|
23
18
|
import "./chunk-TMLWLR46.js";
|
|
24
|
-
import "./chunk-LJSF3QBT.js";
|
|
25
19
|
export {
|
|
26
20
|
added,
|
|
27
21
|
changes,
|
|
28
22
|
dedupe,
|
|
29
23
|
dedupeBy,
|
|
30
|
-
dedupeByKey,
|
|
31
24
|
difference,
|
|
32
|
-
equal,
|
|
33
|
-
filterByKey,
|
|
34
25
|
hasChange,
|
|
35
26
|
includesAll,
|
|
36
27
|
includesAny,
|
package/dist/bytes.js
CHANGED
|
@@ -8,10 +8,10 @@ var MEBIBYTE = 1024 * KIBIBYTE;
|
|
|
8
8
|
var GIBIBYTE = 1024 * MEBIBYTE;
|
|
9
9
|
var TEBIBYTE = 1024 * GIBIBYTE;
|
|
10
10
|
function hex(buffer) {
|
|
11
|
-
const hexCodes =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const hexCodes = Array.from(
|
|
12
|
+
buffer,
|
|
13
|
+
(element) => element.toString(16).padStart(2, "0")
|
|
14
|
+
);
|
|
15
15
|
return hexCodes.join("");
|
|
16
16
|
}
|
|
17
17
|
function unhex(hex2) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
zip
|
|
3
|
-
} from "./chunk-CCBSTDYA.js";
|
|
4
1
|
import {
|
|
5
2
|
ascend
|
|
6
3
|
} from "./chunk-TMLWLR46.js";
|
|
@@ -72,17 +69,6 @@ function union(...arrays) {
|
|
|
72
69
|
}
|
|
73
70
|
return result;
|
|
74
71
|
}
|
|
75
|
-
function equal(a, b) {
|
|
76
|
-
if (a.length !== b.length) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
for (const [item1, item2] of zip(a, b)) {
|
|
80
|
-
if (item1 !== item2) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
72
|
function includesAny(a, b) {
|
|
87
73
|
return b.some((item) => a.includes(item));
|
|
88
74
|
}
|
|
@@ -92,11 +78,11 @@ function includesAll(a, b) {
|
|
|
92
78
|
function dedupe(array) {
|
|
93
79
|
return dedupeBy(array, (x) => x);
|
|
94
80
|
}
|
|
95
|
-
function dedupeBy(array,
|
|
81
|
+
function dedupeBy(array, callback) {
|
|
96
82
|
const result = [];
|
|
97
83
|
const seen = /* @__PURE__ */ new Set();
|
|
98
84
|
for (const item of array) {
|
|
99
|
-
const value =
|
|
85
|
+
const value = callback(item);
|
|
100
86
|
if (!seen.has(value)) {
|
|
101
87
|
result.push(item);
|
|
102
88
|
seen.add(value);
|
|
@@ -104,12 +90,6 @@ function dedupeBy(array, key) {
|
|
|
104
90
|
}
|
|
105
91
|
return result;
|
|
106
92
|
}
|
|
107
|
-
function dedupeByKey(array, key) {
|
|
108
|
-
return dedupeBy(array, (x) => x[key]);
|
|
109
|
-
}
|
|
110
|
-
function filterByKey(array, key) {
|
|
111
|
-
return array.filter((item) => item[key]);
|
|
112
|
-
}
|
|
113
93
|
function sortByKeys(array, key, compare = ascend) {
|
|
114
94
|
return array.toSorted((a, b) => {
|
|
115
95
|
const keys = Array.isArray(key) ? key : [key];
|
|
@@ -136,12 +116,9 @@ export {
|
|
|
136
116
|
hasChange,
|
|
137
117
|
difference,
|
|
138
118
|
union,
|
|
139
|
-
equal,
|
|
140
119
|
includesAny,
|
|
141
120
|
includesAll,
|
|
142
121
|
dedupe,
|
|
143
122
|
dedupeBy,
|
|
144
|
-
dedupeByKey,
|
|
145
|
-
filterByKey,
|
|
146
123
|
sortByKeys
|
|
147
124
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
random
|
|
3
|
-
} from "./chunk-ZAXC26KZ.js";
|
|
4
1
|
import {
|
|
5
2
|
chunk,
|
|
6
3
|
collect,
|
|
7
4
|
filter,
|
|
8
5
|
map,
|
|
9
6
|
range
|
|
10
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XEPJIWIE.js";
|
|
11
8
|
import {
|
|
12
9
|
pipe,
|
|
13
10
|
reverseCurry
|
|
14
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7LRKWWT5.js";
|
|
12
|
+
import {
|
|
13
|
+
random
|
|
14
|
+
} from "./chunk-OMJMLVK3.js";
|
|
15
15
|
|
|
16
16
|
// src/math/stats.ts
|
|
17
17
|
function min(iter) {
|
|
18
|
-
let min2 =
|
|
18
|
+
let min2 = Infinity;
|
|
19
19
|
for (const value of iter) {
|
|
20
20
|
if (value < min2) {
|
|
21
21
|
min2 = value;
|
|
@@ -24,7 +24,7 @@ function min(iter) {
|
|
|
24
24
|
return min2;
|
|
25
25
|
}
|
|
26
26
|
function max(iter) {
|
|
27
|
-
let max2 =
|
|
27
|
+
let max2 = -Infinity;
|
|
28
28
|
for (const value of iter) {
|
|
29
29
|
if (value > max2) {
|
|
30
30
|
max2 = value;
|
|
@@ -33,8 +33,8 @@ function max(iter) {
|
|
|
33
33
|
return max2;
|
|
34
34
|
}
|
|
35
35
|
function minmax(iter) {
|
|
36
|
-
let min2 =
|
|
37
|
-
let max2 =
|
|
36
|
+
let min2 = Infinity;
|
|
37
|
+
let max2 = -Infinity;
|
|
38
38
|
for (const value of iter) {
|
|
39
39
|
if (value < min2) {
|
|
40
40
|
min2 = value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
swap,
|
|
3
3
|
unorderedRemove
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IZDNCBBO.js";
|
|
5
5
|
|
|
6
6
|
// src/random.ts
|
|
7
7
|
function random(min, max) {
|
|
@@ -32,7 +32,7 @@ function choice(array) {
|
|
|
32
32
|
return array[randomInt(array.length - 1)];
|
|
33
33
|
}
|
|
34
34
|
function choices(array, n) {
|
|
35
|
-
if (
|
|
35
|
+
if (array.length === 0 || !n) {
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
38
38
|
if (typeof array === "string") {
|
|
@@ -50,9 +50,9 @@ function sample(array, n) {
|
|
|
50
50
|
const copy = [...array];
|
|
51
51
|
const results = [];
|
|
52
52
|
for (let i = 0; i < n; i++) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if (copy.length > 0) {
|
|
54
|
+
const index = randomInt(copy.length - 1);
|
|
55
|
+
const item = unorderedRemove(copy, index);
|
|
56
56
|
results.push(item);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -4,6 +4,9 @@ function shallowEquals(a, b) {
|
|
|
4
4
|
if (a === b) {
|
|
5
5
|
return true;
|
|
6
6
|
}
|
|
7
|
+
if (a == null || b == null) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
7
10
|
for (const key in a) {
|
|
8
11
|
if (hasOwn(a, key) && !hasOwn(b, key)) {
|
|
9
12
|
return false;
|
|
@@ -73,10 +76,9 @@ function value2Keys(obj) {
|
|
|
73
76
|
}
|
|
74
77
|
return result;
|
|
75
78
|
}
|
|
76
|
-
function objectMap(obj,
|
|
79
|
+
function objectMap(obj, callback) {
|
|
77
80
|
return objectFromEntries(
|
|
78
|
-
|
|
79
|
-
objectEntries(obj).map(([key, value]) => [key, fn([key, value])])
|
|
81
|
+
objectEntries(obj).map(([key, value]) => callback([key, value]))
|
|
80
82
|
);
|
|
81
83
|
}
|
|
82
84
|
function deepCopy(object) {
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
reverseCurry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7LRKWWT5.js";
|
|
4
4
|
import {
|
|
5
5
|
pickByKeys
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XCUELLWZ.js";
|
|
7
7
|
|
|
8
8
|
// src/iter/associate-by.ts
|
|
9
|
-
var associateBy = reverseCurry(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return map3;
|
|
9
|
+
var associateBy = reverseCurry((array, callback) => {
|
|
10
|
+
const map3 = /* @__PURE__ */ new Map();
|
|
11
|
+
for (const item of array) {
|
|
12
|
+
const key = callback(item);
|
|
13
|
+
map3.set(key, item);
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
return map3;
|
|
16
|
+
});
|
|
18
17
|
|
|
19
18
|
// src/iter/chain.ts
|
|
20
19
|
function* chain(...iterables) {
|
|
@@ -33,7 +32,7 @@ var chunk = reverseCurry(function* chunk2(iter, size) {
|
|
|
33
32
|
result = [];
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
if (result.length) {
|
|
35
|
+
if (result.length > 0) {
|
|
37
36
|
yield result;
|
|
38
37
|
}
|
|
39
38
|
});
|
|
@@ -59,7 +58,7 @@ function* cycle(iter) {
|
|
|
59
58
|
yield value;
|
|
60
59
|
values.push(value);
|
|
61
60
|
}
|
|
62
|
-
while (values.length) {
|
|
61
|
+
while (values.length > 0) {
|
|
63
62
|
for (const value of values) {
|
|
64
63
|
yield value;
|
|
65
64
|
}
|
|
@@ -92,13 +91,6 @@ var filter = reverseCurry(function* filter2(iter, predicate) {
|
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
});
|
|
95
|
-
var filterByKey = reverseCurry(function* filterByKey2(iter, key) {
|
|
96
|
-
for (const value of iter) {
|
|
97
|
-
if (value[key]) {
|
|
98
|
-
yield value;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
94
|
|
|
103
95
|
// src/iter/first.ts
|
|
104
96
|
function first(iter) {
|
|
@@ -109,21 +101,19 @@ function first(iter) {
|
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
// src/iter/group-by.ts
|
|
112
|
-
var groupBy = reverseCurry(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
groups.set(value, [item]);
|
|
122
|
-
}
|
|
104
|
+
var groupBy = reverseCurry((array, callback) => {
|
|
105
|
+
const groups = /* @__PURE__ */ new Map();
|
|
106
|
+
for (const item of array) {
|
|
107
|
+
const key = callback(item);
|
|
108
|
+
const group = groups.get(key);
|
|
109
|
+
if (group) {
|
|
110
|
+
group.push(item);
|
|
111
|
+
} else {
|
|
112
|
+
groups.set(key, [item]);
|
|
123
113
|
}
|
|
124
|
-
return groups;
|
|
125
114
|
}
|
|
126
|
-
|
|
115
|
+
return groups;
|
|
116
|
+
});
|
|
127
117
|
|
|
128
118
|
// src/iter/intersperse.ts
|
|
129
119
|
var intersperse = reverseCurry(function* intersperse2(iter, separator) {
|
|
@@ -335,7 +325,6 @@ export {
|
|
|
335
325
|
enumerate,
|
|
336
326
|
every,
|
|
337
327
|
filter,
|
|
338
|
-
filterByKey,
|
|
339
328
|
first,
|
|
340
329
|
groupBy,
|
|
341
330
|
intersperse,
|
package/dist/csv.d.ts
CHANGED
package/dist/csv.js
CHANGED
|
@@ -3,7 +3,7 @@ var specialCharRegex = /[\n",]/;
|
|
|
3
3
|
function formatCsv(rows) {
|
|
4
4
|
return rows.map(
|
|
5
5
|
(row) => row.map((value) => {
|
|
6
|
-
const str =
|
|
6
|
+
const str = String(value);
|
|
7
7
|
if (specialCharRegex.test(str)) {
|
|
8
8
|
return `"${str.replaceAll('"', '""')}"`;
|
|
9
9
|
}
|
|
@@ -11,6 +11,56 @@ function formatCsv(rows) {
|
|
|
11
11
|
}).join(",")
|
|
12
12
|
).join("\n");
|
|
13
13
|
}
|
|
14
|
+
function parseCsv(csv) {
|
|
15
|
+
const data = [];
|
|
16
|
+
let inStr = false;
|
|
17
|
+
let char = "";
|
|
18
|
+
let cell = "";
|
|
19
|
+
let row = [];
|
|
20
|
+
for (let i = 0; i < csv.length; i++) {
|
|
21
|
+
char = csv[i];
|
|
22
|
+
if (!inStr) {
|
|
23
|
+
switch (char) {
|
|
24
|
+
case ",": {
|
|
25
|
+
row.push(cell);
|
|
26
|
+
cell = "";
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case "\n": {
|
|
30
|
+
row.push(cell);
|
|
31
|
+
data.push(row);
|
|
32
|
+
row = [];
|
|
33
|
+
cell = "";
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case '"': {
|
|
37
|
+
inStr = true;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
default: {
|
|
41
|
+
cell += char;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} else if (char === '"') {
|
|
45
|
+
if (csv[i + 1] === '"') {
|
|
46
|
+
cell += char;
|
|
47
|
+
i++;
|
|
48
|
+
} else {
|
|
49
|
+
inStr = false;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
cell += char;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (cell.length > 0 || char === "," || char === "\n") {
|
|
56
|
+
row.push(cell);
|
|
57
|
+
}
|
|
58
|
+
if (row.length > 0) {
|
|
59
|
+
data.push(row);
|
|
60
|
+
}
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
14
63
|
export {
|
|
15
|
-
formatCsv
|
|
64
|
+
formatCsv,
|
|
65
|
+
parseCsv
|
|
16
66
|
};
|
package/dist/easing.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare function linear(t: number): number;
|
|
2
|
+
declare function quadIn(t: number): number;
|
|
3
|
+
declare function quadOut(t: number): number;
|
|
4
|
+
declare function quadInOut(t: number): number;
|
|
5
|
+
declare function cubicIn(t: number): number;
|
|
6
|
+
declare function cubicOut(t: number): number;
|
|
7
|
+
declare function cubicInOut(t: number): number;
|
|
8
|
+
declare function quartIn(t: number): number;
|
|
9
|
+
declare function quartOut(t: number): number;
|
|
10
|
+
declare function quartInOut(t: number): number;
|
|
11
|
+
declare function quintIn(t: number): number;
|
|
12
|
+
declare function quintOut(t: number): number;
|
|
13
|
+
declare function quintInOut(t: number): number;
|
|
14
|
+
|
|
15
|
+
export { cubicIn, cubicInOut, cubicOut, linear, quadIn, quadInOut, quadOut, quartIn, quartInOut, quartOut, quintIn, quintInOut, quintOut };
|
package/dist/easing.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/easing.ts
|
|
2
|
+
function linear(t) {
|
|
3
|
+
return t;
|
|
4
|
+
}
|
|
5
|
+
function quadIn(t) {
|
|
6
|
+
return t * t;
|
|
7
|
+
}
|
|
8
|
+
function quadOut(t) {
|
|
9
|
+
return t * (2 - t);
|
|
10
|
+
}
|
|
11
|
+
function quadInOut(t) {
|
|
12
|
+
if (t < 0.5) {
|
|
13
|
+
return 2 * t * t;
|
|
14
|
+
}
|
|
15
|
+
return 1 - 2 * --t * t;
|
|
16
|
+
}
|
|
17
|
+
function cubicIn(t) {
|
|
18
|
+
return t * t * t;
|
|
19
|
+
}
|
|
20
|
+
function cubicOut(t) {
|
|
21
|
+
return --t * t * t + 1;
|
|
22
|
+
}
|
|
23
|
+
function cubicInOut(t) {
|
|
24
|
+
if (t < 0.5) {
|
|
25
|
+
return 4 * t * t * t;
|
|
26
|
+
}
|
|
27
|
+
return 4 * --t * t * t + 1;
|
|
28
|
+
}
|
|
29
|
+
function quartIn(t) {
|
|
30
|
+
return t * t * t * t;
|
|
31
|
+
}
|
|
32
|
+
function quartOut(t) {
|
|
33
|
+
return 1 - --t * t * t * t;
|
|
34
|
+
}
|
|
35
|
+
function quartInOut(t) {
|
|
36
|
+
if (t < 0.5) {
|
|
37
|
+
return 8 * t * t * t * t;
|
|
38
|
+
}
|
|
39
|
+
return 1 - 8 * --t * t * t * t;
|
|
40
|
+
}
|
|
41
|
+
function quintIn(t) {
|
|
42
|
+
return t * t * t * t * t;
|
|
43
|
+
}
|
|
44
|
+
function quintOut(t) {
|
|
45
|
+
return --t * t * t * t * t + 1;
|
|
46
|
+
}
|
|
47
|
+
function quintInOut(t) {
|
|
48
|
+
if (t < 0.5) {
|
|
49
|
+
return 16 * t * t * t * t * t;
|
|
50
|
+
}
|
|
51
|
+
return 16 * --t * t * t * t * t + 1;
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
cubicIn,
|
|
55
|
+
cubicInOut,
|
|
56
|
+
cubicOut,
|
|
57
|
+
linear,
|
|
58
|
+
quadIn,
|
|
59
|
+
quadInOut,
|
|
60
|
+
quadOut,
|
|
61
|
+
quartIn,
|
|
62
|
+
quartInOut,
|
|
63
|
+
quartOut,
|
|
64
|
+
quintIn,
|
|
65
|
+
quintInOut,
|
|
66
|
+
quintOut
|
|
67
|
+
};
|
package/dist/events.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sum
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-ZAXC26KZ.js";
|
|
5
|
-
import "./chunk-4POIKW4G.js";
|
|
3
|
+
} from "./chunk-LPLI3P2H.js";
|
|
6
4
|
import {
|
|
7
5
|
pick
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XEPJIWIE.js";
|
|
9
7
|
import {
|
|
10
8
|
pipe
|
|
11
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7LRKWWT5.js";
|
|
10
|
+
import "./chunk-XCUELLWZ.js";
|
|
11
|
+
import "./chunk-OMJMLVK3.js";
|
|
12
|
+
import "./chunk-IZDNCBBO.js";
|
|
12
13
|
import "./chunk-TMLWLR46.js";
|
|
13
|
-
import "./chunk-LJSF3QBT.js";
|
|
14
14
|
|
|
15
15
|
// src/events.ts
|
|
16
16
|
var EventEmitter = class {
|
package/dist/fn/index.js
CHANGED
package/dist/gfx/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
vec3
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-LPLI3P2H.js";
|
|
4
|
+
import "../chunk-XEPJIWIE.js";
|
|
5
|
+
import "../chunk-7LRKWWT5.js";
|
|
6
|
+
import "../chunk-XCUELLWZ.js";
|
|
7
|
+
import "../chunk-OMJMLVK3.js";
|
|
8
|
+
import "../chunk-IZDNCBBO.js";
|
|
8
9
|
import "../chunk-TMLWLR46.js";
|
|
9
|
-
import "../chunk-LJSF3QBT.js";
|
|
10
10
|
|
|
11
11
|
// src/gfx/color.ts
|
|
12
12
|
function hsv2rgb(h, s, v) {
|
package/dist/iter/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uint, Repeat, NonFalsy, AnyRecord, int } from '../types.js';
|
|
2
2
|
|
|
3
3
|
declare const associateBy: {
|
|
4
|
-
<T
|
|
5
|
-
<T
|
|
4
|
+
<T, U>(first: Iterable<T>, callback: (item: T) => U): Map<U, T>;
|
|
5
|
+
<T, U>(callback: (item: T) => U): (first: Iterable<T>) => Map<U, T>;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -66,10 +66,6 @@ declare const filter: {
|
|
|
66
66
|
<T>(iter: Iterable<T>, predicate: (value: T) => unknown): Generator<T>;
|
|
67
67
|
<T>(predicate: (value: T) => unknown): (iter: Iterable<T>) => Generator<T>;
|
|
68
68
|
};
|
|
69
|
-
declare const filterByKey: {
|
|
70
|
-
<T extends AnyRecord>(iter: Iterable<T>, key: keyof T): Generator<T>;
|
|
71
|
-
<T extends AnyRecord>(key: keyof T): (iter: Iterable<T>) => Generator<T>;
|
|
72
|
-
};
|
|
73
69
|
|
|
74
70
|
/**
|
|
75
71
|
* Returns the first value of an iterable
|
|
@@ -78,8 +74,8 @@ declare const filterByKey: {
|
|
|
78
74
|
declare function first<T>(iter: Iterable<T>): T | undefined;
|
|
79
75
|
|
|
80
76
|
declare const groupBy: {
|
|
81
|
-
<T
|
|
82
|
-
<T
|
|
77
|
+
<T, U>(first: Iterable<T>, callback: (item: T) => U): Map<U, T[]>;
|
|
78
|
+
<T, U>(callback: (item: T) => U): (first: Iterable<T>) => Map<U, T[]>;
|
|
83
79
|
};
|
|
84
80
|
|
|
85
81
|
/**
|
|
@@ -223,4 +219,4 @@ declare const zip: {
|
|
|
223
219
|
<T, U>(iterable2: Iterable<U>): (iterable1: Iterable<T>) => Generator<[T, U]>;
|
|
224
220
|
};
|
|
225
221
|
|
|
226
|
-
export { associateBy, chain, chunk, collect, count, cycle, enumerate, every, filter,
|
|
222
|
+
export { associateBy, chain, chunk, collect, count, cycle, enumerate, every, filter, first, groupBy, intersperse, last, map, nth, partition, pick, range, skip, slidingWindow, some, take, tap, tee, unique, uniqueBy, unzip, zip };
|
package/dist/iter/index.js
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
enumerate,
|
|
9
9
|
every,
|
|
10
10
|
filter,
|
|
11
|
-
filterByKey,
|
|
12
11
|
first,
|
|
13
12
|
groupBy,
|
|
14
13
|
intersperse,
|
|
@@ -28,9 +27,9 @@ import {
|
|
|
28
27
|
uniqueBy,
|
|
29
28
|
unzip,
|
|
30
29
|
zip
|
|
31
|
-
} from "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
30
|
+
} from "../chunk-XEPJIWIE.js";
|
|
31
|
+
import "../chunk-7LRKWWT5.js";
|
|
32
|
+
import "../chunk-XCUELLWZ.js";
|
|
34
33
|
export {
|
|
35
34
|
associateBy,
|
|
36
35
|
chain,
|
|
@@ -41,7 +40,6 @@ export {
|
|
|
41
40
|
enumerate,
|
|
42
41
|
every,
|
|
43
42
|
filter,
|
|
44
|
-
filterByKey,
|
|
45
43
|
first,
|
|
46
44
|
groupBy,
|
|
47
45
|
intersperse,
|
package/dist/math/index.js
CHANGED
|
@@ -55,13 +55,13 @@ import {
|
|
|
55
55
|
vec2,
|
|
56
56
|
vec3,
|
|
57
57
|
vec4
|
|
58
|
-
} from "../chunk-
|
|
59
|
-
import "../chunk-
|
|
60
|
-
import "../chunk-
|
|
61
|
-
import "../chunk-
|
|
62
|
-
import "../chunk-
|
|
58
|
+
} from "../chunk-LPLI3P2H.js";
|
|
59
|
+
import "../chunk-XEPJIWIE.js";
|
|
60
|
+
import "../chunk-7LRKWWT5.js";
|
|
61
|
+
import "../chunk-XCUELLWZ.js";
|
|
62
|
+
import "../chunk-OMJMLVK3.js";
|
|
63
|
+
import "../chunk-IZDNCBBO.js";
|
|
63
64
|
import "../chunk-TMLWLR46.js";
|
|
64
|
-
import "../chunk-LJSF3QBT.js";
|
|
65
65
|
export {
|
|
66
66
|
DEG2RAD,
|
|
67
67
|
Mat,
|
package/dist/object.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Functions for working with objects
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Determines if an object has a property. This is simply a type-safe wrapper around `Object.
|
|
6
|
+
* Determines if an object has a property. This is simply a type-safe wrapper around `Object.hasOwn`
|
|
7
7
|
* @param obj The object
|
|
8
8
|
* @param key The property key
|
|
9
9
|
* @returns true if the object has the property
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* console.log(hasOwn(obj, "c")); // false
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
declare const hasOwn: <T, K extends PropertyKey>(obj: T, key: K) => obj is T & { [key in K]: unknown; };
|
|
17
|
+
declare const hasOwn: <T extends object, K extends PropertyKey>(obj: T, key: K) => obj is T & { [key in K]: unknown; };
|
|
18
18
|
/**
|
|
19
19
|
* Determines if two objects are shallowly equal, that is,
|
|
20
20
|
* if they have the same properties and the properties have the same values.
|
|
@@ -51,19 +51,21 @@ type ReadonlyEntry<T> = [key: keyof T, value: T[keyof T]];
|
|
|
51
51
|
declare const objectFromEntries: <T>(entries: Iterable<ReadonlyEntry<T>>) => T;
|
|
52
52
|
declare function value2Keys<K extends string, T extends string>(obj: Record<K, Iterable<T>>): Record<T, K[]>;
|
|
53
53
|
/**
|
|
54
|
-
* Maps the values of an object to a new object
|
|
54
|
+
* Maps the keys and values of an object to a new object
|
|
55
|
+
* Basically the equivalent of `Object.fromEntries(Object.entries(obj).map(callback))` but with
|
|
56
|
+
* more accurate typing
|
|
55
57
|
* @param obj The object
|
|
56
|
-
* @param
|
|
57
|
-
* @returns A new object with the mapped
|
|
58
|
+
* @param callback The mapping function
|
|
59
|
+
* @returns A new object with the mapped entries
|
|
58
60
|
* @example
|
|
59
61
|
* ```ts
|
|
60
62
|
* const obj = { a: 1, b: 2 };
|
|
61
|
-
* const result = objectMap(obj, ([key, value]) => [key
|
|
62
|
-
* console.log(result); // {
|
|
63
|
+
* const result = objectMap(obj, ([key, value]) => [`num${key}`, value * 2]);
|
|
64
|
+
* console.log(result); // { numa: 2, numb: 4 }
|
|
63
65
|
* ```
|
|
64
66
|
*/
|
|
65
|
-
declare function objectMap<T,
|
|
66
|
-
[K in
|
|
67
|
+
declare function objectMap<T, NewKey extends PropertyKey, NewValue>(obj: T, callback: (value: Entry<T>) => [NewKey, NewValue]): {
|
|
68
|
+
[K in NewKey]: NewValue;
|
|
67
69
|
};
|
|
68
70
|
declare function deepCopy<T>(object: T): T;
|
|
69
71
|
declare function pickByKeys<T, K extends keyof T>(object: T, key: K): T[K];
|
package/dist/object.js
CHANGED
package/dist/random.js
CHANGED
|
@@ -5,12 +5,9 @@ import {
|
|
|
5
5
|
randomInt,
|
|
6
6
|
sample,
|
|
7
7
|
shuffle
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-CCBSTDYA.js";
|
|
11
|
-
import "./chunk-NXILTE26.js";
|
|
8
|
+
} from "./chunk-OMJMLVK3.js";
|
|
9
|
+
import "./chunk-IZDNCBBO.js";
|
|
12
10
|
import "./chunk-TMLWLR46.js";
|
|
13
|
-
import "./chunk-LJSF3QBT.js";
|
|
14
11
|
export {
|
|
15
12
|
choice,
|
|
16
13
|
choices,
|
package/dist/string/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ declare const lowercase = "abcdefghijklmnopqrstuvwxyz";
|
|
|
2
2
|
declare const uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
3
3
|
declare const letters: string;
|
|
4
4
|
declare const digits = "0123456789";
|
|
5
|
-
declare const hexdigits:
|
|
5
|
+
declare const hexdigits: "0123456789abcdefABCDEF";
|
|
6
6
|
declare const octdigits = "01234567";
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/structs/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
swap
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-CCBSTDYA.js";
|
|
5
|
-
import "../chunk-NXILTE26.js";
|
|
3
|
+
} from "../chunk-IZDNCBBO.js";
|
|
6
4
|
import {
|
|
7
5
|
ascend
|
|
8
6
|
} from "../chunk-TMLWLR46.js";
|
|
9
|
-
import "../chunk-LJSF3QBT.js";
|
|
10
7
|
|
|
11
8
|
// src/structs/heap.ts
|
|
12
9
|
var Heap = class _Heap {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@limitlesspc/std",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.24.0",
|
|
5
5
|
"description": "A standard library for JavaScript",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -58,6 +58,10 @@
|
|
|
58
58
|
"types": "./dist/csv.d.ts",
|
|
59
59
|
"default": "./dist/csv.js"
|
|
60
60
|
},
|
|
61
|
+
"./easing": {
|
|
62
|
+
"types": "./dist/easing.d.ts",
|
|
63
|
+
"default": "./dist/easing.js"
|
|
64
|
+
},
|
|
61
65
|
"./events": {
|
|
62
66
|
"types": "./dist/events.d.ts",
|
|
63
67
|
"default": "./dist/events.js"
|
|
@@ -80,11 +84,11 @@
|
|
|
80
84
|
],
|
|
81
85
|
"prettier": "@limitlesspc/prettier-config",
|
|
82
86
|
"devDependencies": {
|
|
83
|
-
"@limitlesspc/eslint-config": "^0.
|
|
87
|
+
"@limitlesspc/eslint-config": "^0.24.1",
|
|
84
88
|
"@limitlesspc/prettier-config": "^1.2.1",
|
|
85
89
|
"@vitest/coverage-v8": "^4.0.16",
|
|
86
90
|
"bumpp": "^10.3.2",
|
|
87
|
-
"eslint": "^9.39.
|
|
91
|
+
"eslint": "^9.39.5",
|
|
88
92
|
"prettier": "^3.7.4",
|
|
89
93
|
"tsup": "^8.5.1",
|
|
90
94
|
"typescript": "^5.9.3",
|