complete-common 2.27.1 → 2.29.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/functions/array.d.cts +2 -2
- package/dist/functions/array.d.mts +2 -2
- package/dist/functions/array.d.ts +2 -2
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/types/Expect.d.cts +6 -0
- package/dist/types/Expect.d.mts +6 -0
- package/dist/types/Expect.d.ts +6 -0
- package/dist/types/Expect.d.ts.map +1 -0
- package/dist/types/KeysMatch.d.cts +25 -0
- package/dist/types/KeysMatch.d.mts +25 -0
- package/dist/types/KeysMatch.d.ts +25 -0
- package/dist/types/KeysMatch.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/functions/array.ts +8 -3
- package/src/functions/object.ts +1 -1
- package/src/index.ts +2 -0
- package/src/types/Expect.ts +5 -0
- package/src/types/KeysMatch.ts +28 -0
|
@@ -160,8 +160,8 @@ export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
|
160
160
|
/** Helper function to sum every value in an array together. */
|
|
161
161
|
export declare function sumArray(array: readonly number[]): number;
|
|
162
162
|
/**
|
|
163
|
-
* Helper function to filter out non-unique elements from an array. Under the hood, this
|
|
164
|
-
* the array to a `Set` and then back to an array.
|
|
163
|
+
* Helper function to filter out non-unique elements from an array and sort it. Under the hood, this
|
|
164
|
+
* converts the array to a `Set` and then back to an sorted array.
|
|
165
165
|
*/
|
|
166
166
|
export declare function unique<T>(array: readonly T[]): readonly T[];
|
|
167
167
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -160,8 +160,8 @@ export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
|
160
160
|
/** Helper function to sum every value in an array together. */
|
|
161
161
|
export declare function sumArray(array: readonly number[]): number;
|
|
162
162
|
/**
|
|
163
|
-
* Helper function to filter out non-unique elements from an array. Under the hood, this
|
|
164
|
-
* the array to a `Set` and then back to an array.
|
|
163
|
+
* Helper function to filter out non-unique elements from an array and sort it. Under the hood, this
|
|
164
|
+
* converts the array to a `Set` and then back to an sorted array.
|
|
165
165
|
*/
|
|
166
166
|
export declare function unique<T>(array: readonly T[]): readonly T[];
|
|
167
167
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -160,8 +160,8 @@ export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
|
160
160
|
/** Helper function to sum every value in an array together. */
|
|
161
161
|
export declare function sumArray(array: readonly number[]): number;
|
|
162
162
|
/**
|
|
163
|
-
* Helper function to filter out non-unique elements from an array. Under the hood, this
|
|
164
|
-
* the array to a `Set` and then back to an array.
|
|
163
|
+
* Helper function to filter out non-unique elements from an array and sort it. Under the hood, this
|
|
164
|
+
* converts the array to a `Set` and then back to an sorted array.
|
|
165
165
|
*/
|
|
166
166
|
export declare function unique<T>(array: readonly T[]): readonly T[];
|
|
167
167
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAK7D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GACjC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,CAQ7B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,OAAO,CAST;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,SAAS,CAAC,EAAE,EAC3B,GAA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OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAKvB;AAED,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAElE;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAO3D"}
|
package/dist/index.cjs
CHANGED
|
@@ -302,7 +302,10 @@ function sumArray(array) {
|
|
|
302
302
|
return array.reduce((accumulator, element) => accumulator + element, 0);
|
|
303
303
|
}
|
|
304
304
|
function unique(array) {
|
|
305
|
-
|
|
305
|
+
const uniqueElements = [...new Set(array)];
|
|
306
|
+
return uniqueElements.toSorted(
|
|
307
|
+
(a, b) => typeof a === "number" && typeof b === "number" ? a - b : String(a).localeCompare(String(b))
|
|
308
|
+
);
|
|
306
309
|
}
|
|
307
310
|
|
|
308
311
|
function mapFilter(map, predicate) {
|
package/dist/index.d.cts
CHANGED
|
@@ -17,8 +17,10 @@ export type * from "./interfaces/SemanticVersion.js";
|
|
|
17
17
|
export type * from "./types/AddSubtract.js";
|
|
18
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
19
19
|
export type * from "./types/ERange.js";
|
|
20
|
+
export type * from "./types/Expect.js";
|
|
20
21
|
export type * from "./types/Immutable.js";
|
|
21
22
|
export type * from "./types/IRange.js";
|
|
23
|
+
export type * from "./types/KeysMatch.js";
|
|
22
24
|
export type * from "./types/NaturalNumbersLessThan.js";
|
|
23
25
|
export type * from "./types/NaturalNumbersLessThanOrEqualTo.js";
|
|
24
26
|
export type * from "./types/ObjectValues.js";
|
package/dist/index.d.mts
CHANGED
|
@@ -17,8 +17,10 @@ export type * from "./interfaces/SemanticVersion.js";
|
|
|
17
17
|
export type * from "./types/AddSubtract.js";
|
|
18
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
19
19
|
export type * from "./types/ERange.js";
|
|
20
|
+
export type * from "./types/Expect.js";
|
|
20
21
|
export type * from "./types/Immutable.js";
|
|
21
22
|
export type * from "./types/IRange.js";
|
|
23
|
+
export type * from "./types/KeysMatch.js";
|
|
22
24
|
export type * from "./types/NaturalNumbersLessThan.js";
|
|
23
25
|
export type * from "./types/NaturalNumbersLessThanOrEqualTo.js";
|
|
24
26
|
export type * from "./types/ObjectValues.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export type * from "./interfaces/SemanticVersion.js";
|
|
|
17
17
|
export type * from "./types/AddSubtract.js";
|
|
18
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
19
19
|
export type * from "./types/ERange.js";
|
|
20
|
+
export type * from "./types/Expect.js";
|
|
20
21
|
export type * from "./types/Immutable.js";
|
|
21
22
|
export type * from "./types/IRange.js";
|
|
23
|
+
export type * from "./types/KeysMatch.js";
|
|
22
24
|
export type * from "./types/NaturalNumbersLessThan.js";
|
|
23
25
|
export type * from "./types/NaturalNumbersLessThanOrEqualTo.js";
|
|
24
26
|
export type * from "./types/ObjectValues.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC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,sBAAsB,CAAC;AAC1C,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,yBAAyB,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,sBAAsB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -300,7 +300,10 @@ function sumArray(array) {
|
|
|
300
300
|
return array.reduce((accumulator, element) => accumulator + element, 0);
|
|
301
301
|
}
|
|
302
302
|
function unique(array) {
|
|
303
|
-
|
|
303
|
+
const uniqueElements = [...new Set(array)];
|
|
304
|
+
return uniqueElements.toSorted(
|
|
305
|
+
(a, b) => typeof a === "number" && typeof b === "number" ? a - b : String(a).localeCompare(String(b))
|
|
306
|
+
);
|
|
304
307
|
}
|
|
305
308
|
|
|
306
309
|
function mapFilter(map, predicate) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Expect.d.ts","sourceRoot":"","sources":["../../src/types/Expect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to ensure that an array of keys matches an interface.
|
|
3
|
+
*
|
|
4
|
+
* For example:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* interface Foo {
|
|
8
|
+
* arg1: string;
|
|
9
|
+
* arg2: string;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* const FOO_KEYS = ["arg1", "arg2"] as const;
|
|
13
|
+
* type _ = Expect<KeysMatch<Foo, typeof FOO_KEYS>>;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type KeysMatch<T, Keys extends readonly PropertyKey[]> = [
|
|
17
|
+
keyof T
|
|
18
|
+
] extends [Keys[number]] ? [Keys[number]] extends [keyof T] ? true : {
|
|
19
|
+
error: "Extra keys not in interface";
|
|
20
|
+
extra: Exclude<Keys[number], keyof T>;
|
|
21
|
+
} : {
|
|
22
|
+
error: "Missing keys from interface";
|
|
23
|
+
missing: Exclude<keyof T, Keys[number]>;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=KeysMatch.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to ensure that an array of keys matches an interface.
|
|
3
|
+
*
|
|
4
|
+
* For example:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* interface Foo {
|
|
8
|
+
* arg1: string;
|
|
9
|
+
* arg2: string;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* const FOO_KEYS = ["arg1", "arg2"] as const;
|
|
13
|
+
* type _ = Expect<KeysMatch<Foo, typeof FOO_KEYS>>;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type KeysMatch<T, Keys extends readonly PropertyKey[]> = [
|
|
17
|
+
keyof T
|
|
18
|
+
] extends [Keys[number]] ? [Keys[number]] extends [keyof T] ? true : {
|
|
19
|
+
error: "Extra keys not in interface";
|
|
20
|
+
extra: Exclude<Keys[number], keyof T>;
|
|
21
|
+
} : {
|
|
22
|
+
error: "Missing keys from interface";
|
|
23
|
+
missing: Exclude<keyof T, Keys[number]>;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=KeysMatch.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to ensure that an array of keys matches an interface.
|
|
3
|
+
*
|
|
4
|
+
* For example:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* interface Foo {
|
|
8
|
+
* arg1: string;
|
|
9
|
+
* arg2: string;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* const FOO_KEYS = ["arg1", "arg2"] as const;
|
|
13
|
+
* type _ = Expect<KeysMatch<Foo, typeof FOO_KEYS>>;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type KeysMatch<T, Keys extends readonly PropertyKey[]> = [
|
|
17
|
+
keyof T
|
|
18
|
+
] extends [Keys[number]] ? [Keys[number]] extends [keyof T] ? true : {
|
|
19
|
+
error: "Extra keys not in interface";
|
|
20
|
+
extra: Exclude<Keys[number], keyof T>;
|
|
21
|
+
} : {
|
|
22
|
+
error: "Missing keys from interface";
|
|
23
|
+
missing: Exclude<keyof T, Keys[number]>;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=KeysMatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeysMatch.d.ts","sourceRoot":"","sources":["../../src/types/KeysMatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,IAAI,SAAS,SAAS,WAAW,EAAE,IAAI;IAC9D,MAAM,CAAC;CACR,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GACpB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAC9B,IAAI,GACJ;IACE,KAAK,EAAE,6BAA6B,CAAC;IACrC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;CACvC,GACH;IACE,KAAK,EAAE,6BAA6B,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.0",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
5
|
"homepage": "https://complete-ts.github.io/",
|
|
6
6
|
"bugs": {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"test": "bun test ./tests"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "25.
|
|
35
|
+
"@types/node": "25.6.0",
|
|
36
36
|
"complete-node": "16.4.1",
|
|
37
|
-
"typedoc": "0.28.
|
|
37
|
+
"typedoc": "0.28.19",
|
|
38
38
|
"typedoc-plugin-markdown": "4.11.0",
|
|
39
|
-
"typescript": "6.0.
|
|
39
|
+
"typescript": "6.0.3",
|
|
40
40
|
"unbuild": "3.6.1"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/functions/array.ts
CHANGED
|
@@ -383,9 +383,14 @@ export function sumArray(array: readonly number[]): number {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
/**
|
|
386
|
-
* Helper function to filter out non-unique elements from an array. Under the hood, this
|
|
387
|
-
* the array to a `Set` and then back to an array.
|
|
386
|
+
* Helper function to filter out non-unique elements from an array and sort it. Under the hood, this
|
|
387
|
+
* converts the array to a `Set` and then back to an sorted array.
|
|
388
388
|
*/
|
|
389
389
|
export function unique<T>(array: readonly T[]): readonly T[] {
|
|
390
|
-
|
|
390
|
+
const uniqueElements = [...new Set(array)];
|
|
391
|
+
return uniqueElements.toSorted((a, b) =>
|
|
392
|
+
typeof a === "number" && typeof b === "number"
|
|
393
|
+
? a - b
|
|
394
|
+
: String(a).localeCompare(String(b)),
|
|
395
|
+
);
|
|
391
396
|
}
|
package/src/functions/object.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function getWidenedObjectValue<T extends Record<string, unknown>>(
|
|
|
18
18
|
key: WidenLiteral<keyof T>,
|
|
19
19
|
): T[keyof T] | undefined {
|
|
20
20
|
const widenedObject = object as Record<PropertyKey, T[keyof T]>;
|
|
21
|
-
return widenedObject[key
|
|
21
|
+
return widenedObject[key];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
package/src/index.ts
CHANGED
|
@@ -17,8 +17,10 @@ export type * from "./interfaces/SemanticVersion.js";
|
|
|
17
17
|
export type * from "./types/AddSubtract.js";
|
|
18
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
19
19
|
export type * from "./types/ERange.js";
|
|
20
|
+
export type * from "./types/Expect.js";
|
|
20
21
|
export type * from "./types/Immutable.js";
|
|
21
22
|
export type * from "./types/IRange.js";
|
|
23
|
+
export type * from "./types/KeysMatch.js";
|
|
22
24
|
export type * from "./types/NaturalNumbersLessThan.js";
|
|
23
25
|
export type * from "./types/NaturalNumbersLessThanOrEqualTo.js";
|
|
24
26
|
export type * from "./types/ObjectValues.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to ensure that an array of keys matches an interface.
|
|
3
|
+
*
|
|
4
|
+
* For example:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* interface Foo {
|
|
8
|
+
* arg1: string;
|
|
9
|
+
* arg2: string;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* const FOO_KEYS = ["arg1", "arg2"] as const;
|
|
13
|
+
* type _ = Expect<KeysMatch<Foo, typeof FOO_KEYS>>;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type KeysMatch<T, Keys extends readonly PropertyKey[]> = [
|
|
17
|
+
keyof T,
|
|
18
|
+
] extends [Keys[number]]
|
|
19
|
+
? [Keys[number]] extends [keyof T]
|
|
20
|
+
? true
|
|
21
|
+
: {
|
|
22
|
+
error: "Extra keys not in interface";
|
|
23
|
+
extra: Exclude<Keys[number], keyof T>;
|
|
24
|
+
}
|
|
25
|
+
: {
|
|
26
|
+
error: "Missing keys from interface";
|
|
27
|
+
missing: Exclude<keyof T, Keys[number]>;
|
|
28
|
+
};
|