@augment-vir/common 30.0.0 → 30.0.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/README.md +11 -0
- package/dist/augments/array/array-map.d.ts +29 -1
- package/dist/augments/array/array-map.js +29 -1
- package/dist/augments/array/array-to-object.d.ts +27 -9
- package/dist/augments/array/array-to-object.js +96 -12
- package/dist/augments/array/awaited/awaited-filter.d.ts +29 -0
- package/dist/augments/array/awaited/awaited-filter.js +29 -0
- package/dist/augments/array/awaited/awaited-for-each.d.ts +28 -3
- package/dist/augments/array/awaited/awaited-for-each.js +28 -3
- package/dist/augments/array/awaited/awaited-map.d.ts +32 -0
- package/dist/augments/array/awaited/awaited-map.js +32 -0
- package/dist/augments/array/filter.d.ts +29 -0
- package/dist/augments/array/filter.js +61 -0
- package/dist/augments/array/remove-duplicates.d.ts +60 -1
- package/dist/augments/array/remove-duplicates.js +61 -2
- package/dist/augments/array/repeat-array.d.ts +22 -0
- package/dist/augments/array/repeat-array.js +22 -0
- package/dist/augments/array/shuffle-array.d.ts +8 -1
- package/dist/augments/array/shuffle-array.js +8 -1
- package/dist/augments/array/string-array.d.ts +8 -0
- package/dist/augments/array/string-array.js +8 -0
- package/dist/augments/enum/enum-value-check.d.ts +30 -0
- package/dist/augments/enum/enum-value-check.js +30 -0
- package/dist/augments/error/combine-errors.d.ts +24 -3
- package/dist/augments/error/combine-errors.js +26 -4
- package/dist/augments/function/call-asynchronously.d.ts +19 -0
- package/dist/augments/function/call-asynchronously.js +19 -0
- package/dist/augments/function/call-with-retries.d.ts +23 -3
- package/dist/augments/function/call-with-retries.js +23 -0
- package/dist/augments/function/debounce.d.ts +71 -4
- package/dist/augments/function/debounce.js +66 -4
- package/dist/augments/function/execution-duration.d.ts +17 -5
- package/dist/augments/function/execution-duration.js +16 -3
- package/dist/augments/function/if-truthy.d.ts +28 -0
- package/dist/augments/function/if-truthy.js +35 -0
- package/dist/augments/function/wrap-in-try.d.ts +12 -4
- package/dist/augments/function/wrap-in-try.js +64 -0
- package/dist/augments/json/append-json.d.ts +3 -3
- package/dist/augments/json/append-json.js +33 -0
- package/dist/augments/json/copy-through-json.d.ts +32 -1
- package/dist/augments/json/copy-through-json.js +32 -1
- package/dist/augments/json/json-compatible.d.ts +37 -9
- package/dist/augments/json/jsonify.d.ts +30 -1
- package/dist/augments/json/jsonify.js +31 -2
- package/dist/augments/log/log-colors.d.ts +41 -0
- package/dist/augments/log/log-colors.js +43 -2
- package/dist/augments/log/log-string.d.ts +21 -0
- package/dist/augments/log/log-string.js +9 -2
- package/dist/augments/log/log-writer.d.ts +22 -0
- package/dist/augments/log/log.d.ts +44 -1
- package/dist/augments/log/log.js +46 -3
- package/dist/augments/log/logger.d.ts +49 -0
- package/dist/augments/log/logger.js +21 -0
- package/dist/augments/number/clamp.d.ts +13 -2
- package/dist/augments/number/clamp.js +12 -1
- package/dist/augments/number/coords.d.ts +6 -2
- package/dist/augments/number/digit.d.ts +7 -0
- package/dist/augments/number/dimensions.d.ts +6 -2
- package/dist/augments/number/min-max.d.ts +9 -2
- package/dist/augments/number/min-max.js +4 -2
- package/dist/augments/number/number-conversion.d.ts +9 -3
- package/dist/augments/number/number-conversion.js +10 -4
- package/dist/augments/number/round.d.ts +19 -0
- package/dist/augments/number/round.js +19 -0
- package/dist/augments/number/scientific.d.ts +18 -1
- package/dist/augments/number/scientific.js +18 -1
- package/dist/augments/number/truncate-number.d.ts +24 -3
- package/dist/augments/number/truncate-number.js +28 -8
- package/dist/augments/number/wrap-number.d.ts +9 -3
- package/dist/augments/number/wrap-number.js +8 -2
- package/dist/augments/object/diff.d.ts +27 -5
- package/dist/augments/object/diff.js +20 -4
- package/dist/augments/object/empty.d.ts +7 -1
- package/dist/augments/object/get-or-set.d.ts +6 -27
- package/dist/augments/object/get-or-set.js +66 -4
- package/dist/augments/object/key-count.d.ts +4 -0
- package/dist/augments/object/map-entries.js +23 -0
- package/dist/augments/object/map-enum.d.ts +7 -0
- package/dist/augments/object/map-enum.js +24 -0
- package/dist/augments/object/map-values.d.ts +25 -13
- package/dist/augments/object/map-values.js +29 -21
- package/dist/augments/object/merge-deep.d.ts +4 -0
- package/dist/augments/object/merge-deep.js +4 -0
- package/dist/augments/object/merge-defined-properties.d.ts +13 -0
- package/dist/augments/object/merge-defined-properties.js +13 -0
- package/dist/augments/object/merge-property-arrays.d.ts +28 -0
- package/dist/augments/object/merge-property-arrays.js +28 -0
- package/dist/augments/object/object-entries.d.ts +27 -0
- package/dist/augments/object/object-entries.js +27 -0
- package/dist/augments/object/object-filter.d.ts +20 -0
- package/dist/augments/object/object-filter.js +20 -0
- package/dist/augments/object/object-keys.d.ts +32 -0
- package/dist/augments/object/object-keys.js +32 -0
- package/dist/augments/object/object-values.d.ts +9 -0
- package/dist/augments/object/object-values.js +9 -0
- package/dist/augments/path/esm-path.d.ts +26 -0
- package/dist/augments/path/esm-path.js +31 -0
- package/dist/augments/prisma/base-prisma-types.d.ts +38 -0
- package/dist/augments/prisma/prisma-basic-model.d.ts +29 -0
- package/dist/augments/prisma/prisma-basic-model.js +1 -0
- package/dist/augments/prisma/prisma-full-model.d.ts +37 -0
- package/dist/augments/prisma/prisma-full-model.js +1 -0
- package/dist/augments/prisma/prisma-model-create.d.ts +159 -0
- package/dist/augments/prisma/prisma-model-create.js +58 -0
- package/dist/augments/prisma/prisma-model-name.d.ts +18 -0
- package/dist/augments/prisma/prisma-model-name.js +1 -0
- package/dist/augments/promise/timed-promise.d.ts +15 -0
- package/dist/augments/promise/timed-promise.js +15 -0
- package/dist/augments/random/random-boolean.d.ts +6 -0
- package/dist/augments/random/random-boolean.js +6 -0
- package/dist/augments/random/random-integer.d.ts +3 -1
- package/dist/augments/random/random-integer.js +3 -1
- package/dist/augments/random/random-string.d.ts +6 -2
- package/dist/augments/random/random-string.js +6 -2
- package/dist/augments/regexp/match.d.ts +10 -0
- package/dist/augments/regexp/match.js +13 -0
- package/dist/augments/regexp/regexp-flags.d.ts +56 -3
- package/dist/augments/regexp/regexp-flags.js +71 -14
- package/dist/augments/regexp/regexp-string.d.ts +4 -0
- package/dist/augments/regexp/regexp-string.js +5 -1
- package/dist/augments/selection-set/select-collapsed.d.ts +46 -3
- package/dist/augments/selection-set/select-collapsed.js +40 -2
- package/dist/augments/selection-set/select-from.d.ts +47 -2
- package/dist/augments/selection-set/select-from.js +48 -1
- package/dist/augments/selection-set/selection-set.d.ts +26 -7
- package/dist/augments/selection-set/selection-set.js +1 -4
- package/dist/augments/string/casing/capitalization.d.ts +15 -1
- package/dist/augments/string/casing/capitalization.js +14 -0
- package/dist/augments/string/casing/casing.d.ts +53 -7
- package/dist/augments/string/casing/casing.js +36 -11
- package/dist/augments/string/casing/kebab-and-camel.d.ts +14 -0
- package/dist/augments/string/casing/kebab-and-camel.js +20 -5
- package/dist/augments/string/comma.d.ts +26 -0
- package/dist/augments/string/{commas.js → comma.js} +21 -2
- package/dist/augments/string/join.d.ts +15 -4
- package/dist/augments/string/join.js +15 -4
- package/dist/augments/string/prefix.d.ts +6 -0
- package/dist/augments/string/prefix.js +4 -0
- package/dist/augments/string/remove-duplicate-characters.d.ts +17 -0
- package/dist/augments/string/remove-duplicate-characters.js +22 -0
- package/dist/augments/string/replace.d.ts +17 -0
- package/dist/augments/string/replace.js +17 -0
- package/dist/augments/string/split.d.ts +29 -2
- package/dist/augments/string/split.js +32 -7
- package/dist/augments/string/substring-index.d.ts +11 -5
- package/dist/augments/string/substring-index.js +12 -3
- package/dist/augments/string/suffix.d.ts +22 -0
- package/dist/augments/string/suffix.js +16 -0
- package/dist/augments/string/white-space.d.ts +8 -1
- package/dist/augments/string/white-space.js +8 -1
- package/dist/augments/string/wrap-string.d.ts +15 -0
- package/dist/augments/string/wrap-string.js +15 -0
- package/dist/augments/type/ensure-type.d.ts +4 -0
- package/dist/augments/type/ensure-type.js +4 -0
- package/dist/augments/type/readonly.d.ts +7 -0
- package/dist/augments/type/readonly.js +7 -0
- package/dist/augments/type/type-recursion.d.ts +93 -1
- package/dist/augments/type/union.d.ts +1 -0
- package/dist/augments/type/union.js +1 -0
- package/dist/augments/type/void-type.d.ts +6 -2
- package/dist/augments/type/writable.d.ts +7 -0
- package/dist/augments/type/writable.js +7 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +11 -5
- package/package.json +19 -9
- package/dist/augments/boolean/if-truthy.d.ts +0 -2
- package/dist/augments/boolean/if-truthy.js +0 -9
- package/dist/augments/file/esm-path.d.ts +0 -4
- package/dist/augments/file/esm-path.js +0 -8
- package/dist/augments/prisma/prisma-models.d.ts +0 -106
- package/dist/augments/regexp/safe-match.d.ts +0 -1
- package/dist/augments/regexp/safe-match.js +0 -4
- package/dist/augments/string/commas.d.ts +0 -7
- /package/dist/augments/prisma/{prisma-models.js → base-prisma-types.js} +0 -0
|
@@ -3,18 +3,24 @@ import { toEnsuredNumber } from '../number/number-conversion.js';
|
|
|
3
3
|
* Suffix for {@link addPercent} and {@link removePercent}.
|
|
4
4
|
*
|
|
5
5
|
* @category String
|
|
6
|
+
* @category Package : @augment-vir/common
|
|
7
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
6
8
|
*/
|
|
7
9
|
export const percentSuffix = '%';
|
|
8
10
|
/**
|
|
9
11
|
* Suffix for {@link addPx} and {@link removePx}.
|
|
10
12
|
*
|
|
11
13
|
* @category String
|
|
14
|
+
* @category Package : @augment-vir/common
|
|
15
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
12
16
|
*/
|
|
13
17
|
export const pxSuffix = 'px';
|
|
14
18
|
/**
|
|
15
19
|
* Adds the `'px'` suffix to a string if it does not already exist.
|
|
16
20
|
*
|
|
17
21
|
* @category String
|
|
22
|
+
* @category Package : @augment-vir/common
|
|
23
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
18
24
|
*/
|
|
19
25
|
export function addPx(input) {
|
|
20
26
|
return addSuffix({ value: input, suffix: pxSuffix });
|
|
@@ -23,7 +29,9 @@ export function addPx(input) {
|
|
|
23
29
|
* Removes the `'px'` suffix from a string if it exists.
|
|
24
30
|
*
|
|
25
31
|
* @category String
|
|
32
|
+
* @category Package : @augment-vir/common
|
|
26
33
|
* @throws `TypeError` if the input can't be converted into a number.
|
|
34
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
27
35
|
*/
|
|
28
36
|
export function removePx(input) {
|
|
29
37
|
return toEnsuredNumber(removeSuffix({ value: input, suffix: pxSuffix }));
|
|
@@ -32,6 +40,8 @@ export function removePx(input) {
|
|
|
32
40
|
* Adds the `'%'` suffix to a string if it does not already exist.
|
|
33
41
|
*
|
|
34
42
|
* @category String
|
|
43
|
+
* @category Package : @augment-vir/common
|
|
44
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
35
45
|
*/
|
|
36
46
|
export function addPercent(input) {
|
|
37
47
|
return addSuffix({ value: input, suffix: percentSuffix });
|
|
@@ -40,7 +50,9 @@ export function addPercent(input) {
|
|
|
40
50
|
* Removes the `'%'` suffix from a string if it exists.
|
|
41
51
|
*
|
|
42
52
|
* @category String
|
|
53
|
+
* @category Package : @augment-vir/common
|
|
43
54
|
* @throws `TypeError` if the input can't be converted into a number.
|
|
55
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
44
56
|
*/
|
|
45
57
|
export function removePercent(input) {
|
|
46
58
|
return toEnsuredNumber(removeSuffix({ value: input, suffix: percentSuffix }));
|
|
@@ -49,6 +61,8 @@ export function removePercent(input) {
|
|
|
49
61
|
* Adds a suffix to a string if it does not already exist.
|
|
50
62
|
*
|
|
51
63
|
* @category String
|
|
64
|
+
* @category Package : @augment-vir/common
|
|
65
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
52
66
|
*/
|
|
53
67
|
export function addSuffix({ value, suffix, }) {
|
|
54
68
|
if (String(value).endsWith(suffix)) {
|
|
@@ -62,6 +76,8 @@ export function addSuffix({ value, suffix, }) {
|
|
|
62
76
|
* Removes a suffix from a string if it exists.
|
|
63
77
|
*
|
|
64
78
|
* @category String
|
|
79
|
+
* @category Package : @augment-vir/common
|
|
80
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
65
81
|
*/
|
|
66
82
|
export function removeSuffix({ value, suffix, }) {
|
|
67
83
|
if (value.endsWith(suffix)) {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { PartialWithUndefined } from '@augment-vir/core';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Collapse all consecutive white space into just one space and trim surrounding whitespace.
|
|
4
|
+
* Optionally, collapsed newlines can be preserved.
|
|
5
|
+
*
|
|
6
|
+
* @category String
|
|
7
|
+
* @category Package : @augment-vir/common
|
|
8
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
9
|
+
*/
|
|
3
10
|
export declare function collapseWhiteSpace(input: string, { keepNewLines }?: PartialWithUndefined<{
|
|
4
11
|
keepNewLines: boolean;
|
|
5
12
|
}>): string;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Collapse all consecutive white space into just one space and trim surrounding whitespace.
|
|
3
|
+
* Optionally, collapsed newlines can be preserved.
|
|
4
|
+
*
|
|
5
|
+
* @category String
|
|
6
|
+
* @category Package : @augment-vir/common
|
|
7
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
8
|
+
*/
|
|
2
9
|
export function collapseWhiteSpace(input, { keepNewLines } = {}) {
|
|
3
10
|
if (keepNewLines) {
|
|
4
11
|
return input
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a string in another string.
|
|
3
|
+
*
|
|
4
|
+
* @category String
|
|
5
|
+
* @category Package : @augment-vir/common
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import {wrapString} from '@augment-vir/common';
|
|
10
|
+
*
|
|
11
|
+
* wrapString({value: 'some words', wrapper: '"'}); // outputs `'"some words"'`
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
15
|
+
*/
|
|
1
16
|
export declare function wrapString({ value, wrapper }: {
|
|
2
17
|
value: string;
|
|
3
18
|
wrapper: string;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { addPrefix } from './prefix.js';
|
|
2
2
|
import { addSuffix } from './suffix.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a string in another string.
|
|
5
|
+
*
|
|
6
|
+
* @category String
|
|
7
|
+
* @category Package : @augment-vir/common
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {wrapString} from '@augment-vir/common';
|
|
12
|
+
*
|
|
13
|
+
* wrapString({value: 'some words', wrapper: '"'}); // outputs `'"some words"'`
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
17
|
+
*/
|
|
3
18
|
export function wrapString({ value, wrapper }) {
|
|
4
19
|
return addPrefix({ value: addSuffix({ value, suffix: wrapper }), prefix: wrapper });
|
|
5
20
|
}
|
|
@@ -4,5 +4,9 @@
|
|
|
4
4
|
* the generic being inferred from the inputs), there will actually be a type error. This forces
|
|
5
5
|
* each usage of this function to explicitly specify the generic, thus giving us type safety for the
|
|
6
6
|
* input.
|
|
7
|
+
*
|
|
8
|
+
* @category Type
|
|
9
|
+
* @category Package : @augment-vir/common
|
|
10
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
7
11
|
*/
|
|
8
12
|
export declare function ensureType<ExpectedType = never>(input: NoInfer<ExpectedType>): NoInfer<ExpectedType>;
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* the generic being inferred from the inputs), there will actually be a type error. This forces
|
|
5
5
|
* each usage of this function to explicitly specify the generic, thus giving us type safety for the
|
|
6
6
|
* input.
|
|
7
|
+
*
|
|
8
|
+
* @category Type
|
|
9
|
+
* @category Package : @augment-vir/common
|
|
10
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
7
11
|
*/
|
|
8
12
|
export function ensureType(input) {
|
|
9
13
|
return input;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export type { ReadonlyDeep } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* This function does nothing but return the input as a readonly typed version of itself.
|
|
4
|
+
*
|
|
5
|
+
* @category Type
|
|
6
|
+
* @category Package : @augment-vir/common
|
|
7
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
8
|
+
*/
|
|
2
9
|
export declare function makeReadonly<T>(input: T): Readonly<T>;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function does nothing but return the input as a readonly typed version of itself.
|
|
3
|
+
*
|
|
4
|
+
* @category Type
|
|
5
|
+
* @category Package : @augment-vir/common
|
|
6
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
7
|
+
*/
|
|
1
8
|
export function makeReadonly(input) {
|
|
2
9
|
return input;
|
|
3
10
|
}
|
|
@@ -150,12 +150,104 @@ type TsRecursionArray = [
|
|
|
150
150
|
149,
|
|
151
151
|
150
|
|
152
152
|
];
|
|
153
|
+
/**
|
|
154
|
+
* This is used as the baseline type for TypeScript recursion tracking indexes. Use this to manually
|
|
155
|
+
* abort a type's recursion to prevent it from going too deep and throwing an error in TypeScript's
|
|
156
|
+
* language server.
|
|
157
|
+
*
|
|
158
|
+
* @category Type
|
|
159
|
+
* @category Package : @augment-vir/common
|
|
160
|
+
* @example
|
|
161
|
+
*
|
|
162
|
+
* ```ts
|
|
163
|
+
* import type {
|
|
164
|
+
* TsRecursionTracker,
|
|
165
|
+
* TsRecursionStart,
|
|
166
|
+
* TsRecurse,
|
|
167
|
+
* TsTooMuchRecursion,
|
|
168
|
+
* } from '@augment-vir/common';
|
|
169
|
+
*
|
|
170
|
+
* export type SomeType<Depth extends TsRecursionTracker = TsRecursionStart> =
|
|
171
|
+
* Depth extends TsTooMuchRecursion
|
|
172
|
+
* ? 'Error: recursive object depth is too deep.'
|
|
173
|
+
* : SomeType<TsRecurse<Depth>>;
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
177
|
+
*/
|
|
153
178
|
export type TsRecursionTracker = keyof TsRecursionArray;
|
|
154
179
|
/**
|
|
155
180
|
* Through experimentation on Typescript version 5.4.5, this is the maximum recursion depth we can
|
|
156
|
-
* go to before TypeScript will block recursive types.
|
|
181
|
+
* go to before TypeScript will block recursive types. Use this as the limit to type recursion.
|
|
182
|
+
*
|
|
183
|
+
* @category Type
|
|
184
|
+
* @category Package : @augment-vir/common
|
|
185
|
+
* @example
|
|
186
|
+
*
|
|
187
|
+
* ```ts
|
|
188
|
+
* import type {
|
|
189
|
+
* TsRecursionTracker,
|
|
190
|
+
* TsRecursionStart,
|
|
191
|
+
* TsRecurse,
|
|
192
|
+
* TsTooMuchRecursion,
|
|
193
|
+
* } from '@augment-vir/common';
|
|
194
|
+
*
|
|
195
|
+
* export type SomeType<Depth extends TsRecursionTracker = TsRecursionStart> =
|
|
196
|
+
* Depth extends TsTooMuchRecursion
|
|
197
|
+
* ? 'Error: recursive object depth is too deep.'
|
|
198
|
+
* : SomeType<TsRecurse<Depth>>;
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
157
202
|
*/
|
|
158
203
|
export type TsTooMuchRecursion = 91;
|
|
204
|
+
/**
|
|
205
|
+
* This is the default starting recursion depth needed to get the full tested allowed recursion
|
|
206
|
+
* depth.
|
|
207
|
+
*
|
|
208
|
+
* @category Type
|
|
209
|
+
* @category Package : @augment-vir/common
|
|
210
|
+
* @example
|
|
211
|
+
*
|
|
212
|
+
* ```ts
|
|
213
|
+
* import type {
|
|
214
|
+
* TsRecursionTracker,
|
|
215
|
+
* TsRecursionStart,
|
|
216
|
+
* TsRecurse,
|
|
217
|
+
* TsTooMuchRecursion,
|
|
218
|
+
* } from '@augment-vir/common';
|
|
219
|
+
*
|
|
220
|
+
* export type SomeType<Depth extends TsRecursionTracker = TsRecursionStart> =
|
|
221
|
+
* Depth extends TsTooMuchRecursion
|
|
222
|
+
* ? 'Error: recursive object depth is too deep.'
|
|
223
|
+
* : SomeType<TsRecurse<Depth>>;
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
227
|
+
*/
|
|
159
228
|
export type TsRecursionStart = 0;
|
|
229
|
+
/**
|
|
230
|
+
* Increments a TypeScript recursion depth tracker.
|
|
231
|
+
*
|
|
232
|
+
* @category Type
|
|
233
|
+
* @category Package : @augment-vir/common
|
|
234
|
+
* @example
|
|
235
|
+
*
|
|
236
|
+
* ```ts
|
|
237
|
+
* import type {
|
|
238
|
+
* TsRecursionTracker,
|
|
239
|
+
* TsRecursionStart,
|
|
240
|
+
* TsRecurse,
|
|
241
|
+
* TsTooMuchRecursion,
|
|
242
|
+
* } from '@augment-vir/common';
|
|
243
|
+
*
|
|
244
|
+
* export type SomeType<Depth extends TsRecursionTracker = TsRecursionStart> =
|
|
245
|
+
* Depth extends TsTooMuchRecursion
|
|
246
|
+
* ? 'Error: recursive object depth is too deep.'
|
|
247
|
+
* : SomeType<TsRecurse<Depth>>;
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
251
|
+
*/
|
|
160
252
|
export type TsRecurse<CurrentRecursion extends TsRecursionTracker> = TsRecursionArray[CurrentRecursion] extends TsRecursionTracker ? TsRecursionArray[CurrentRecursion] : TsTooMuchRecursion;
|
|
161
253
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { UnionToIntersection } from 'type-fest';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Require that the NonVoid parameter is not void. If it is void, the ErrorType or an
|
|
3
|
-
* type is returned. If it not void, the given SuccessType is returned.
|
|
2
|
+
* Require that the given `NonVoid` parameter is not void. If it is void, the `ErrorType` or an
|
|
3
|
+
* error string type is returned. If it not void, the given `SuccessType` is returned.
|
|
4
|
+
*
|
|
5
|
+
* @category Type
|
|
6
|
+
* @category Package : @augment-vir/common
|
|
7
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
4
8
|
*/
|
|
5
9
|
export type RequireNonVoid<NonVoid, SuccessType, ErrorType = 'Input should not be void'> = void extends NonVoid ? (NonVoid extends void ? ErrorType : SuccessType) : SuccessType;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { Writable } from 'type-fest';
|
|
2
2
|
export type { Writable, WritableDeep } from 'type-fest';
|
|
3
|
+
/**
|
|
4
|
+
* This function does nothing but return the input as a writable typed version of itself.
|
|
5
|
+
*
|
|
6
|
+
* @category Type
|
|
7
|
+
* @category Package : @augment-vir/common
|
|
8
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
9
|
+
*/
|
|
3
10
|
export declare function makeWritable<T>(input: T): Writable<T>;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function does nothing but return the input as a writable typed version of itself.
|
|
3
|
+
*
|
|
4
|
+
* @category Type
|
|
5
|
+
* @category Package : @augment-vir/common
|
|
6
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
7
|
+
*/
|
|
1
8
|
export function makeWritable(input) {
|
|
2
9
|
return input;
|
|
3
10
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,15 +8,14 @@ export * from './augments/array/remove-duplicates.js';
|
|
|
8
8
|
export * from './augments/array/repeat-array.js';
|
|
9
9
|
export * from './augments/array/shuffle-array.js';
|
|
10
10
|
export * from './augments/array/string-array.js';
|
|
11
|
-
export * from './augments/boolean/if-truthy.js';
|
|
12
11
|
export * from './augments/core-exports.js';
|
|
13
12
|
export * from './augments/enum/enum-value-check.js';
|
|
14
13
|
export * from './augments/error/combine-errors.js';
|
|
15
|
-
export * from './augments/file/esm-path.js';
|
|
16
14
|
export * from './augments/function/call-asynchronously.js';
|
|
17
15
|
export * from './augments/function/call-with-retries.js';
|
|
18
16
|
export * from './augments/function/debounce.js';
|
|
19
17
|
export * from './augments/function/execution-duration.js';
|
|
18
|
+
export * from './augments/function/if-truthy.js';
|
|
20
19
|
export * from './augments/function/wrap-in-try.js';
|
|
21
20
|
export * from './augments/json/append-json.js';
|
|
22
21
|
export * from './augments/json/copy-through-json.js';
|
|
@@ -51,23 +50,29 @@ export * from './augments/object/object-entries.js';
|
|
|
51
50
|
export * from './augments/object/object-filter.js';
|
|
52
51
|
export * from './augments/object/object-keys.js';
|
|
53
52
|
export * from './augments/object/object-values.js';
|
|
54
|
-
export * from './augments/
|
|
53
|
+
export * from './augments/path/esm-path.js';
|
|
54
|
+
export * from './augments/prisma/base-prisma-types.js';
|
|
55
|
+
export * from './augments/prisma/prisma-basic-model.js';
|
|
56
|
+
export * from './augments/prisma/prisma-full-model.js';
|
|
57
|
+
export * from './augments/prisma/prisma-model-create.js';
|
|
58
|
+
export * from './augments/prisma/prisma-model-name.js';
|
|
55
59
|
export * from './augments/promise/timed-promise.js';
|
|
56
60
|
export * from './augments/random/random-boolean.js';
|
|
57
61
|
export * from './augments/random/random-integer.js';
|
|
58
62
|
export * from './augments/random/random-string.js';
|
|
63
|
+
export * from './augments/regexp/match.js';
|
|
59
64
|
export * from './augments/regexp/regexp-flags.js';
|
|
60
65
|
export * from './augments/regexp/regexp-string.js';
|
|
61
|
-
export * from './augments/regexp/safe-match.js';
|
|
62
66
|
export * from './augments/selection-set/select-collapsed.js';
|
|
63
67
|
export * from './augments/selection-set/select-from.js';
|
|
64
68
|
export * from './augments/selection-set/selection-set.js';
|
|
65
69
|
export * from './augments/string/casing/capitalization.js';
|
|
66
70
|
export * from './augments/string/casing/casing.js';
|
|
67
71
|
export * from './augments/string/casing/kebab-and-camel.js';
|
|
68
|
-
export * from './augments/string/
|
|
72
|
+
export * from './augments/string/comma.js';
|
|
69
73
|
export * from './augments/string/join.js';
|
|
70
74
|
export * from './augments/string/prefix.js';
|
|
75
|
+
export * from './augments/string/remove-duplicate-characters.js';
|
|
71
76
|
export * from './augments/string/replace.js';
|
|
72
77
|
export * from './augments/string/split.js';
|
|
73
78
|
export * from './augments/string/substring-index.js';
|
|
@@ -77,5 +82,6 @@ export * from './augments/string/wrap-string.js';
|
|
|
77
82
|
export * from './augments/type/ensure-type.js';
|
|
78
83
|
export * from './augments/type/readonly.js';
|
|
79
84
|
export * from './augments/type/type-recursion.js';
|
|
85
|
+
export * from './augments/type/union.js';
|
|
80
86
|
export * from './augments/type/void-type.js';
|
|
81
87
|
export * from './augments/type/writable.js';
|
package/dist/index.js
CHANGED
|
@@ -8,15 +8,14 @@ export * from './augments/array/remove-duplicates.js';
|
|
|
8
8
|
export * from './augments/array/repeat-array.js';
|
|
9
9
|
export * from './augments/array/shuffle-array.js';
|
|
10
10
|
export * from './augments/array/string-array.js';
|
|
11
|
-
export * from './augments/boolean/if-truthy.js';
|
|
12
11
|
export * from './augments/core-exports.js';
|
|
13
12
|
export * from './augments/enum/enum-value-check.js';
|
|
14
13
|
export * from './augments/error/combine-errors.js';
|
|
15
|
-
export * from './augments/file/esm-path.js';
|
|
16
14
|
export * from './augments/function/call-asynchronously.js';
|
|
17
15
|
export * from './augments/function/call-with-retries.js';
|
|
18
16
|
export * from './augments/function/debounce.js';
|
|
19
17
|
export * from './augments/function/execution-duration.js';
|
|
18
|
+
export * from './augments/function/if-truthy.js';
|
|
20
19
|
export * from './augments/function/wrap-in-try.js';
|
|
21
20
|
export * from './augments/json/append-json.js';
|
|
22
21
|
export * from './augments/json/copy-through-json.js';
|
|
@@ -51,23 +50,29 @@ export * from './augments/object/object-entries.js';
|
|
|
51
50
|
export * from './augments/object/object-filter.js';
|
|
52
51
|
export * from './augments/object/object-keys.js';
|
|
53
52
|
export * from './augments/object/object-values.js';
|
|
54
|
-
export * from './augments/
|
|
53
|
+
export * from './augments/path/esm-path.js';
|
|
54
|
+
export * from './augments/prisma/base-prisma-types.js';
|
|
55
|
+
export * from './augments/prisma/prisma-basic-model.js';
|
|
56
|
+
export * from './augments/prisma/prisma-full-model.js';
|
|
57
|
+
export * from './augments/prisma/prisma-model-create.js';
|
|
58
|
+
export * from './augments/prisma/prisma-model-name.js';
|
|
55
59
|
export * from './augments/promise/timed-promise.js';
|
|
56
60
|
export * from './augments/random/random-boolean.js';
|
|
57
61
|
export * from './augments/random/random-integer.js';
|
|
58
62
|
export * from './augments/random/random-string.js';
|
|
63
|
+
export * from './augments/regexp/match.js';
|
|
59
64
|
export * from './augments/regexp/regexp-flags.js';
|
|
60
65
|
export * from './augments/regexp/regexp-string.js';
|
|
61
|
-
export * from './augments/regexp/safe-match.js';
|
|
62
66
|
export * from './augments/selection-set/select-collapsed.js';
|
|
63
67
|
export * from './augments/selection-set/select-from.js';
|
|
64
68
|
export * from './augments/selection-set/selection-set.js';
|
|
65
69
|
export * from './augments/string/casing/capitalization.js';
|
|
66
70
|
export * from './augments/string/casing/casing.js';
|
|
67
71
|
export * from './augments/string/casing/kebab-and-camel.js';
|
|
68
|
-
export * from './augments/string/
|
|
72
|
+
export * from './augments/string/comma.js';
|
|
69
73
|
export * from './augments/string/join.js';
|
|
70
74
|
export * from './augments/string/prefix.js';
|
|
75
|
+
export * from './augments/string/remove-duplicate-characters.js';
|
|
71
76
|
export * from './augments/string/replace.js';
|
|
72
77
|
export * from './augments/string/split.js';
|
|
73
78
|
export * from './augments/string/substring-index.js';
|
|
@@ -77,5 +82,6 @@ export * from './augments/string/wrap-string.js';
|
|
|
77
82
|
export * from './augments/type/ensure-type.js';
|
|
78
83
|
export * from './augments/type/readonly.js';
|
|
79
84
|
export * from './augments/type/type-recursion.js';
|
|
85
|
+
export * from './augments/type/union.js';
|
|
80
86
|
export * from './augments/type/void-type.js';
|
|
81
87
|
export * from './augments/type/writable.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/common",
|
|
3
|
-
"version": "30.0.
|
|
3
|
+
"version": "30.0.2",
|
|
4
|
+
"description": "A collection of augments, helpers types, functions, and classes for any JavaScript environment.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"augment",
|
|
7
|
+
"helper",
|
|
8
|
+
"util",
|
|
9
|
+
"node",
|
|
10
|
+
"browser",
|
|
11
|
+
"backend",
|
|
12
|
+
"frontend",
|
|
13
|
+
"vir",
|
|
14
|
+
"augment-vir"
|
|
15
|
+
],
|
|
4
16
|
"homepage": "https://github.com/electrovir/augment-vir",
|
|
5
17
|
"bugs": {
|
|
6
18
|
"url": "https://github.com/electrovir/augment-vir/issues"
|
|
@@ -20,29 +32,27 @@
|
|
|
20
32
|
"types": "dist/index.d.ts",
|
|
21
33
|
"scripts": {
|
|
22
34
|
"compile": "virmator compile",
|
|
23
|
-
"docs": "virmator docs",
|
|
24
35
|
"test": "concurrently --colors --kill-others-on-fail -c red,blue --names node,web \"npm run test:node\" \"npm run test:web\"",
|
|
25
36
|
"test:coverage": "virmator --no-deps test web coverage",
|
|
26
|
-
"test:docs": "virmator docs check",
|
|
27
37
|
"test:node": "virmator --no-deps test node",
|
|
28
38
|
"test:update": "npm test",
|
|
29
39
|
"test:web": "virmator --no-deps test web"
|
|
30
40
|
},
|
|
31
41
|
"dependencies": {
|
|
32
|
-
"@augment-vir/assert": "^30.0.
|
|
33
|
-
"@augment-vir/core": "^30.0.
|
|
42
|
+
"@augment-vir/assert": "^30.0.2",
|
|
43
|
+
"@augment-vir/core": "^30.0.2",
|
|
34
44
|
"@date-vir/duration": "^6.0.0",
|
|
35
45
|
"ansi-styles": "^6.2.1",
|
|
36
46
|
"json5": "^2.2.3",
|
|
37
|
-
"type-fest": "^4.
|
|
47
|
+
"type-fest": "^4.26.1"
|
|
38
48
|
},
|
|
39
49
|
"devDependencies": {
|
|
40
50
|
"@web/dev-server-esbuild": "^1.0.2",
|
|
41
|
-
"@web/test-runner": "^0.
|
|
51
|
+
"@web/test-runner": "^0.19.0",
|
|
42
52
|
"@web/test-runner-commands": "^0.9.0",
|
|
43
53
|
"@web/test-runner-playwright": "^0.11.0",
|
|
44
|
-
"@web/test-runner-visual-regression": "^0.
|
|
45
|
-
"concurrently": "^
|
|
54
|
+
"@web/test-runner-visual-regression": "^0.10.0",
|
|
55
|
+
"concurrently": "^9.0.0",
|
|
46
56
|
"execute-in-browser": "^1.0.3",
|
|
47
57
|
"istanbul-smart-text-reporter": "^1.1.4"
|
|
48
58
|
},
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { type Falsy, type Truthy } from '@augment-vir/assert';
|
|
2
|
-
export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { AnyFunction, AnyObject } from '@augment-vir/core';
|
|
2
|
-
/**
|
|
3
|
-
* Extracts all model names from a generated `Prisma` object.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* import type {Prisma} from '@prisma/client';
|
|
9
|
-
*
|
|
10
|
-
* function doThing(modelName: ModelNameFromPrismaTypeMap<Prisma.TypeMap>) {}
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export type ModelNameFromPrismaTypeMap<PrismaTypeMap extends BasePrismaTypeMap> = PrismaTypeMap['meta']['modelProps'];
|
|
14
|
-
/**
|
|
15
|
-
* Extracts all model names from a generated `PrismaClient`.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* import type {PrismaClient} from '@prisma/client';
|
|
21
|
-
*
|
|
22
|
-
* function doThing(modelName: ModelNameFromPrismaClient<PrismaClient>) {}
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export type ModelNameFromPrismaClient<PrismaClient extends AnyObject> = keyof {
|
|
26
|
-
[Model in Extract<keyof PrismaClient, string> as PrismaClient[Model] extends {
|
|
27
|
-
findFirst: AnyFunction;
|
|
28
|
-
} ? Model : never]: boolean;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Extracts the creation data for a model from the given `PrismaClient` type.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
*
|
|
35
|
-
* ```ts
|
|
36
|
-
* import type {PrismaClient} from '@prisma/client';
|
|
37
|
-
*
|
|
38
|
-
* function doThing(entry: ModelCreationEntry<PrismaClient, 'User'>) {}
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export type PrismaModelCreationEntry<PrismaClient extends AnyObject, Model extends ModelNameFromPrismaClient<PrismaClient>> = NonNullable<Parameters<PrismaClient[Model]['create']>[0]> extends {
|
|
42
|
-
data?: infer Data;
|
|
43
|
-
} ? NonNullable<Data> : `ERROR: failed to infer creation entry for model '${Model}'`;
|
|
44
|
-
/**
|
|
45
|
-
* A base type for `Prisma.TypeMap` because Prisma doesn't give us one. This currently only includes
|
|
46
|
-
* the properties that are used within `@augment-vir/prisma-node-js`.
|
|
47
|
-
*/
|
|
48
|
-
export type BasePrismaTypeMap = {
|
|
49
|
-
meta: {
|
|
50
|
-
modelProps: string;
|
|
51
|
-
};
|
|
52
|
-
model: Record<string, {
|
|
53
|
-
payload: BasePrismaPayload;
|
|
54
|
-
}>;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* A base type for Prisma model payloads because Prisma doesn't give us one. This currently only
|
|
58
|
-
* includes the properties that are used within this package.
|
|
59
|
-
*
|
|
60
|
-
* Note: this omits the `composites` property because I don't have any examples of what those
|
|
61
|
-
* actually are.
|
|
62
|
-
*/
|
|
63
|
-
export type BasePrismaPayload = {
|
|
64
|
-
name: string;
|
|
65
|
-
objects: Record<string, BasePrismaPayload | BasePrismaPayload[] | null>;
|
|
66
|
-
scalars: AnyObject;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* A full model entry with all relations from the given Prisma type map and model name.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
*
|
|
73
|
-
* ```ts
|
|
74
|
-
* import type {Prisma} from '@prisma/client';
|
|
75
|
-
*
|
|
76
|
-
* function doThing(fullModel: FullModel<Prisma.TypeMap, 'User'>) {}
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
export type FullPrismaModel<PrismaTypeMap extends BasePrismaTypeMap, Model extends ModelNameFromPrismaTypeMap<PrismaTypeMap>> = ExpandPrismaTypeMapPayload<PrismaTypeMap['model'][Model]['payload']>;
|
|
80
|
-
/**
|
|
81
|
-
* A base model entry with only its immediate properties from the given Prisma type map and model
|
|
82
|
-
* name.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
*
|
|
86
|
-
* ```ts
|
|
87
|
-
* import type {Prisma} from '@prisma/client';
|
|
88
|
-
*
|
|
89
|
-
* function doThing(fullModel: BaseModel<Prisma.TypeMap, 'User'>) {}
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export type BasePrismaModel<PrismaTypeMap extends BasePrismaTypeMap, Model extends ModelNameFromPrismaTypeMap<PrismaTypeMap>> = PrismaTypeMap['model'][Model]['payload']['scalars'];
|
|
93
|
-
/**
|
|
94
|
-
* Expand a Prisma payload into its scalars and recursive relations.
|
|
95
|
-
*
|
|
96
|
-
* @category Internals
|
|
97
|
-
*/
|
|
98
|
-
export type ExpandPrismaTypeMapPayload<Payload extends BasePrismaPayload> = Payload['scalars'] & {
|
|
99
|
-
[Key in keyof Payload['objects']]: ExpandPotentialArrayPrismaTypeMapPayload<NonNullable<Payload['objects'][Key]>> | (null extends Payload['objects'][Key] ? null : never);
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Expand a payload that might be inside of an array, keeping it inside of an array if it is.
|
|
103
|
-
*
|
|
104
|
-
* @category Internals
|
|
105
|
-
*/
|
|
106
|
-
export type ExpandPotentialArrayPrismaTypeMapPayload<PayloadWrapper extends BasePrismaPayload | BasePrismaPayload[]> = PayloadWrapper extends (infer ActualPayload extends BasePrismaPayload)[] ? ExpandPrismaTypeMapPayload<ActualPayload>[] : PayloadWrapper extends BasePrismaPayload ? ExpandPrismaTypeMapPayload<PayloadWrapper> : never;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function safeMatch(input: string, regExp: RegExp): string[];
|