@limitlesspc/std 0.20.2 → 0.21.1
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 +25 -3
- package/dist/array.js +3 -1
- package/dist/async/index.js +2 -2
- package/dist/{chunk-ILLWUQPY.js → chunk-65SNM7MP.js} +16 -4
- package/dist/{chunk-DO4NH5XG.js → chunk-DYKZK6B5.js} +1 -1
- package/dist/{chunk-EWSJTMH2.js → chunk-O3YCU3KN.js} +1 -1
- package/dist/{chunk-C2DS6YRJ.js → chunk-WNQNVZFS.js} +5 -5
- package/dist/events.js +3 -3
- package/dist/gfx/index.d.ts +1 -1
- package/dist/gfx/index.js +3 -3
- package/dist/math/index.d.ts +2 -2
- package/dist/math/index.js +3 -3
- package/dist/random.js +2 -2
- package/dist/structs/index.js +2 -2
- package/dist/{vec3-D7Wuy2AZ.d.ts → vec3-S_YuL-W1.d.ts} +1 -1
- package/package.json +10 -12
package/dist/array.d.ts
CHANGED
|
@@ -160,6 +160,28 @@ declare function includesAny<T, U>(a: readonly T[], b: readonly U[]): boolean;
|
|
|
160
160
|
* ```
|
|
161
161
|
*/
|
|
162
162
|
declare function includesAll<T, U>(a: readonly T[], b: readonly U[]): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Returns a new array with items with a unique key
|
|
165
|
+
* @param array
|
|
166
|
+
* @param key
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* const array = [
|
|
170
|
+
* 1,
|
|
171
|
+
* 3,
|
|
172
|
+
* 2,
|
|
173
|
+
* 4,
|
|
174
|
+
* 1,
|
|
175
|
+
* 2,
|
|
176
|
+
* ];
|
|
177
|
+
* console.log(dedupe(array)); // [
|
|
178
|
+
* // 1,
|
|
179
|
+
* // 3,
|
|
180
|
+
* // 2,
|
|
181
|
+
* // 4
|
|
182
|
+
* // ]
|
|
183
|
+
*/
|
|
184
|
+
declare function dedupe<T>(array: Iterable<T>): T[];
|
|
163
185
|
/**
|
|
164
186
|
* Returns a new array with items with a unique key
|
|
165
187
|
* @param array
|
|
@@ -174,14 +196,14 @@ declare function includesAll<T, U>(a: readonly T[], b: readonly U[]): boolean;
|
|
|
174
196
|
* { id: 2, name: "Eve" },
|
|
175
197
|
* { id: 4, name: "Frank" },
|
|
176
198
|
* ];
|
|
177
|
-
* console.log(
|
|
199
|
+
* console.log(dedupeByKey(array, "id")); // [
|
|
178
200
|
* // { id: 1, name: "Alice" },
|
|
179
201
|
* // { id: 2, name: "Bob" },
|
|
180
202
|
* // { id: 3, name: "David" },
|
|
181
203
|
* // { id: 4, name: "Frank" }
|
|
182
204
|
* // ]
|
|
183
205
|
*/
|
|
184
|
-
declare function
|
|
206
|
+
declare function dedupeByKey<T extends {
|
|
185
207
|
[K in keyof T]: T[K];
|
|
186
208
|
}>(array: Iterable<T>, key: keyof T): T[];
|
|
187
209
|
declare function filterByKey<T>(array: readonly T[], key: keyof T): T[];
|
|
@@ -206,4 +228,4 @@ declare function filterByKey<T>(array: readonly T[], key: keyof T): T[];
|
|
|
206
228
|
*/
|
|
207
229
|
declare function sortByKeys<T, K extends keyof T>(array: Iterable<T>, key: MaybeArray<K>, compare?: Compare<T[K]>): T[];
|
|
208
230
|
|
|
209
|
-
export { added, changes, dedupe, difference, equal, filterByKey, hasChange, includesAll, includesAny, intersection, remove, removed, sortByKeys, swap, union, unorderedRemove };
|
|
231
|
+
export { added, changes, dedupe, dedupeByKey, difference, equal, filterByKey, hasChange, includesAll, includesAny, intersection, remove, removed, sortByKeys, swap, union, unorderedRemove };
|
package/dist/array.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
added,
|
|
3
3
|
changes,
|
|
4
4
|
dedupe,
|
|
5
|
+
dedupeByKey,
|
|
5
6
|
difference,
|
|
6
7
|
equal,
|
|
7
8
|
filterByKey,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
swap,
|
|
16
17
|
union,
|
|
17
18
|
unorderedRemove
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-65SNM7MP.js";
|
|
19
20
|
import "./chunk-WBSY6KRH.js";
|
|
20
21
|
import "./chunk-MG5VQSTV.js";
|
|
21
22
|
import "./chunk-6F4PWJZI.js";
|
|
@@ -25,6 +26,7 @@ export {
|
|
|
25
26
|
added,
|
|
26
27
|
changes,
|
|
27
28
|
dedupe,
|
|
29
|
+
dedupeByKey,
|
|
28
30
|
difference,
|
|
29
31
|
equal,
|
|
30
32
|
filterByKey,
|
package/dist/async/index.js
CHANGED
|
@@ -89,14 +89,25 @@ function includesAny(a, b) {
|
|
|
89
89
|
function includesAll(a, b) {
|
|
90
90
|
return b.every((item) => a.includes(item));
|
|
91
91
|
}
|
|
92
|
-
function dedupe(array
|
|
92
|
+
function dedupe(array) {
|
|
93
93
|
const result = [];
|
|
94
|
-
const
|
|
94
|
+
const seen = /* @__PURE__ */ new Set();
|
|
95
|
+
for (const item of array) {
|
|
96
|
+
if (!seen.has(item)) {
|
|
97
|
+
result.push(item);
|
|
98
|
+
seen.add(item);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
function dedupeByKey(array, key) {
|
|
104
|
+
const result = [];
|
|
105
|
+
const seen = /* @__PURE__ */ new Set();
|
|
95
106
|
for (const item of array) {
|
|
96
107
|
const value = item[key];
|
|
97
|
-
if (!
|
|
108
|
+
if (!seen.has(value)) {
|
|
98
109
|
result.push(item);
|
|
99
|
-
|
|
110
|
+
seen.add(value);
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
113
|
return result;
|
|
@@ -134,6 +145,7 @@ export {
|
|
|
134
145
|
includesAny,
|
|
135
146
|
includesAll,
|
|
136
147
|
dedupe,
|
|
148
|
+
dedupeByKey,
|
|
137
149
|
filterByKey,
|
|
138
150
|
sortByKeys
|
|
139
151
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
random
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-O3YCU3KN.js";
|
|
4
4
|
import {
|
|
5
5
|
chunk,
|
|
6
6
|
collect,
|
|
@@ -915,11 +915,11 @@ var Vec2 = class _Vec2 extends Float32Array {
|
|
|
915
915
|
}
|
|
916
916
|
div(x, y) {
|
|
917
917
|
if (typeof x === "number") {
|
|
918
|
-
this.x
|
|
919
|
-
this.y
|
|
918
|
+
this.x /= x;
|
|
919
|
+
this.y /= y ?? x;
|
|
920
920
|
} else {
|
|
921
|
-
this.x
|
|
922
|
-
this.y
|
|
921
|
+
this.x /= x[0];
|
|
922
|
+
this.y /= x[1];
|
|
923
923
|
}
|
|
924
924
|
return this;
|
|
925
925
|
}
|
package/dist/events.js
CHANGED
package/dist/gfx/index.d.ts
CHANGED
package/dist/gfx/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
vec3
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-WNQNVZFS.js";
|
|
4
|
+
import "../chunk-O3YCU3KN.js";
|
|
5
|
+
import "../chunk-65SNM7MP.js";
|
|
6
6
|
import "../chunk-WBSY6KRH.js";
|
|
7
7
|
import "../chunk-MG5VQSTV.js";
|
|
8
8
|
import "../chunk-6F4PWJZI.js";
|
package/dist/math/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { int, uint } from '../types.js';
|
|
2
|
-
import {
|
|
3
|
-
export { R as ReadonlyVec3Like,
|
|
2
|
+
import { V as Vec } from '../vec3-S_YuL-W1.js';
|
|
3
|
+
export { R as ReadonlyVec3Like, b as Vec3, a as Vec3Like, v as vec3 } from '../vec3-S_YuL-W1.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Determines if a value is a number other than `NaN`
|
package/dist/math/index.js
CHANGED
|
@@ -58,9 +58,9 @@ import {
|
|
|
58
58
|
vec2,
|
|
59
59
|
vec3,
|
|
60
60
|
vec4
|
|
61
|
-
} from "../chunk-
|
|
62
|
-
import "../chunk-
|
|
63
|
-
import "../chunk-
|
|
61
|
+
} from "../chunk-WNQNVZFS.js";
|
|
62
|
+
import "../chunk-O3YCU3KN.js";
|
|
63
|
+
import "../chunk-65SNM7MP.js";
|
|
64
64
|
import "../chunk-WBSY6KRH.js";
|
|
65
65
|
import "../chunk-MG5VQSTV.js";
|
|
66
66
|
import "../chunk-6F4PWJZI.js";
|
package/dist/random.js
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
randomInt,
|
|
6
6
|
sample,
|
|
7
7
|
shuffle
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-O3YCU3KN.js";
|
|
9
|
+
import "./chunk-65SNM7MP.js";
|
|
10
10
|
import "./chunk-WBSY6KRH.js";
|
|
11
11
|
import "./chunk-MG5VQSTV.js";
|
|
12
12
|
import "./chunk-6F4PWJZI.js";
|
package/dist/structs/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
Queue,
|
|
7
7
|
SortedArray,
|
|
8
8
|
UnorderedArray
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-DYKZK6B5.js";
|
|
10
|
+
import "../chunk-65SNM7MP.js";
|
|
11
11
|
import "../chunk-WBSY6KRH.js";
|
|
12
12
|
import "../chunk-MG5VQSTV.js";
|
|
13
13
|
import "../chunk-6F4PWJZI.js";
|
|
@@ -67,4 +67,4 @@ declare class Vec3 extends Float32Array implements Vec {
|
|
|
67
67
|
}
|
|
68
68
|
declare function vec3(x?: First, y?: number, z?: number): Vec3;
|
|
69
69
|
|
|
70
|
-
export { type ReadonlyVec3Like as R,
|
|
70
|
+
export { type ReadonlyVec3Like as R, type Vec as V, type Vec3Like as a, Vec3 as b, vec3 as v };
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@limitlesspc/std",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@9.15.0",
|
|
4
|
+
"version": "0.21.1",
|
|
6
5
|
"description": "A standard library for JavaScript",
|
|
7
6
|
"license": "MIT",
|
|
8
7
|
"publishConfig": {
|
|
@@ -87,6 +86,14 @@
|
|
|
87
86
|
"dist"
|
|
88
87
|
],
|
|
89
88
|
"prettier": "@limitlesspc/prettier-config",
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@limitlesspc/eslint-config": "^0.16.2",
|
|
91
|
+
"@limitlesspc/prettier-config": "^1.1.1",
|
|
92
|
+
"bumpp": "^9.8.1",
|
|
93
|
+
"tsup": "^8.3.5",
|
|
94
|
+
"typescript": "^5.7.2",
|
|
95
|
+
"vitest": "^2.1.6"
|
|
96
|
+
},
|
|
90
97
|
"scripts": {
|
|
91
98
|
"build": "tsup",
|
|
92
99
|
"test": "vitest",
|
|
@@ -96,16 +103,7 @@
|
|
|
96
103
|
"lint:fix": "eslint --fix",
|
|
97
104
|
"lint:fix-dry": "eslint --fix-dry-run",
|
|
98
105
|
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
|
|
99
|
-
"prepack": "nr build",
|
|
100
106
|
"release": "bumpp && pnpm publish",
|
|
101
107
|
"typecheck": "tsc --noEmit"
|
|
102
|
-
},
|
|
103
|
-
"devDependencies": {
|
|
104
|
-
"@limitlesspc/eslint-config": "^0.16.2",
|
|
105
|
-
"@limitlesspc/prettier-config": "^1.1.1",
|
|
106
|
-
"bumpp": "^9.8.1",
|
|
107
|
-
"tsup": "^8.3.5",
|
|
108
|
-
"typescript": "^5.7.2",
|
|
109
|
-
"vitest": "^2.1.6"
|
|
110
108
|
}
|
|
111
|
-
}
|
|
109
|
+
}
|