@limitlesspc/std 0.20.2 → 0.21.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 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(dedupe(array, "id")); // [
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 dedupe<T extends {
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-ILLWUQPY.js";
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,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Queue
3
- } from "../chunk-DO4NH5XG.js";
4
- import "../chunk-ILLWUQPY.js";
3
+ } from "../chunk-DYKZK6B5.js";
4
+ import "../chunk-65SNM7MP.js";
5
5
  import "../chunk-WBSY6KRH.js";
6
6
  import "../chunk-MG5VQSTV.js";
7
7
  import "../chunk-6F4PWJZI.js";
@@ -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, key) {
92
+ function dedupe(array) {
93
93
  const result = [];
94
- const values = /* @__PURE__ */ new Set();
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 (!values.has(value)) {
108
+ if (!seen.has(value)) {
98
109
  result.push(item);
99
- values.add(value);
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-EWSJTMH2.js";
3
+ } from "./chunk-O3YCU3KN.js";
4
4
  import {
5
5
  chunk,
6
6
  collect,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  swap
3
- } from "./chunk-ILLWUQPY.js";
3
+ } from "./chunk-65SNM7MP.js";
4
4
  import {
5
5
  ascend,
6
6
  descend
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  swap,
3
3
  unorderedRemove
4
- } from "./chunk-ILLWUQPY.js";
4
+ } from "./chunk-65SNM7MP.js";
5
5
 
6
6
  // src/random.ts
7
7
  function random(min, max) {
package/dist/events.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  sum
3
- } from "./chunk-C2DS6YRJ.js";
4
- import "./chunk-EWSJTMH2.js";
5
- import "./chunk-ILLWUQPY.js";
3
+ } from "./chunk-AZEZMYQ5.js";
4
+ import "./chunk-O3YCU3KN.js";
5
+ import "./chunk-65SNM7MP.js";
6
6
  import {
7
7
  pick
8
8
  } from "./chunk-WBSY6KRH.js";
@@ -1,4 +1,4 @@
1
- import { V as Vec3 } from '../vec3-D7Wuy2AZ.js';
1
+ import { b as Vec3 } from '../vec3-S_YuL-W1.js';
2
2
 
3
3
  declare function hsv2rgb(h: number, s: number, v: number): Vec3;
4
4
  /**
package/dist/gfx/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  vec3
3
- } from "../chunk-C2DS6YRJ.js";
4
- import "../chunk-EWSJTMH2.js";
5
- import "../chunk-ILLWUQPY.js";
3
+ } from "../chunk-AZEZMYQ5.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";
@@ -1,6 +1,6 @@
1
1
  import { int, uint } from '../types.js';
2
- import { a as Vec } from '../vec3-D7Wuy2AZ.js';
3
- export { R as ReadonlyVec3Like, V as Vec3, b as Vec3Like, v as vec3 } from '../vec3-D7Wuy2AZ.js';
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`
@@ -58,9 +58,9 @@ import {
58
58
  vec2,
59
59
  vec3,
60
60
  vec4
61
- } from "../chunk-C2DS6YRJ.js";
62
- import "../chunk-EWSJTMH2.js";
63
- import "../chunk-ILLWUQPY.js";
61
+ } from "../chunk-AZEZMYQ5.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-EWSJTMH2.js";
9
- import "./chunk-ILLWUQPY.js";
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";
@@ -6,8 +6,8 @@ import {
6
6
  Queue,
7
7
  SortedArray,
8
8
  UnorderedArray
9
- } from "../chunk-DO4NH5XG.js";
10
- import "../chunk-ILLWUQPY.js";
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, Vec3 as V, type Vec as a, type Vec3Like as b, vec3 as v };
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.20.2",
5
- "packageManager": "pnpm@9.15.0",
4
+ "version": "0.21.0",
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
+ }