@augment-vir/common 29.2.0 → 30.0.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/LICENSE-CC0 +121 -0
- package/LICENSE-MIT +21 -0
- package/dist/augments/array/array-map.d.ts +6 -0
- package/dist/augments/array/array-map.js +4 -0
- package/dist/augments/array/array-to-object.d.ts +17 -0
- package/dist/augments/array/array-to-object.js +31 -0
- package/dist/augments/array/awaited/awaited-filter.d.ts +7 -0
- package/dist/augments/array/awaited/awaited-filter.js +7 -0
- package/dist/augments/array/awaited/awaited-for-each.d.ts +6 -0
- package/dist/augments/array/awaited/awaited-for-each.js +9 -0
- package/dist/augments/array/awaited/awaited-map.d.ts +1 -0
- package/dist/augments/array/awaited/awaited-map.js +8 -0
- package/dist/augments/array/filter.d.ts +3 -0
- package/dist/augments/array/filter.js +13 -0
- package/dist/augments/array/repeat-array.d.ts +1 -0
- package/dist/augments/array/repeat-array.js +3 -0
- package/dist/augments/array/shuffle-array.d.ts +2 -0
- package/dist/augments/array/shuffle-array.js +10 -0
- package/dist/augments/array/string-array.d.ts +1 -0
- package/dist/augments/array/string-array.js +3 -0
- package/dist/augments/boolean/if-truthy.d.ts +2 -0
- package/dist/{esm/augments/boolean.js → augments/boolean/if-truthy.js} +2 -7
- package/dist/augments/core-exports.d.ts +1 -0
- package/dist/augments/core-exports.js +1 -0
- package/dist/augments/enum/enum-value-check.d.ts +2 -0
- package/dist/augments/enum/enum-value-check.js +4 -0
- package/dist/augments/error/combine-errors.d.ts +3 -0
- package/dist/augments/error/combine-errors.js +12 -0
- package/dist/augments/function/call-asynchronously.d.ts +6 -0
- package/dist/augments/function/call-asynchronously.js +7 -0
- package/dist/augments/function/call-with-retries.d.ts +4 -0
- package/dist/augments/function/call-with-retries.js +27 -0
- package/dist/augments/function/debounce.d.ts +22 -0
- package/dist/augments/function/debounce.js +50 -0
- package/dist/augments/function/execution-duration.d.ts +8 -0
- package/dist/{esm/augments/time.js → augments/function/execution-duration.js} +7 -12
- package/dist/{types/augments → augments/function}/wrap-in-try.d.ts +2 -3
- package/dist/{esm/augments → augments/function}/wrap-in-try.js +4 -4
- package/dist/augments/json/append-json.d.ts +5 -0
- package/dist/augments/json/append-json.js +26 -0
- package/dist/augments/json/copy-through-json.d.ts +3 -0
- package/dist/augments/json/copy-through-json.js +11 -0
- package/dist/augments/json/jsonify.d.ts +2 -0
- package/dist/augments/json/jsonify.js +4 -0
- package/dist/augments/log/log-colors.d.ts +23 -0
- package/dist/augments/log/log-colors.js +116 -0
- package/dist/augments/log/log-string.d.ts +14 -0
- package/dist/augments/log/log-string.js +66 -0
- package/dist/augments/log/log-writer.d.ts +8 -0
- package/dist/augments/log/log.d.ts +13 -0
- package/dist/augments/log/log.js +42 -0
- package/dist/augments/log/logger.d.ts +11 -0
- package/dist/augments/log/logger.js +38 -0
- package/dist/augments/number/clamp.d.ts +7 -0
- package/dist/augments/number/clamp.js +8 -0
- package/dist/augments/number/coords.d.ts +19 -0
- package/dist/augments/number/digit.d.ts +1 -0
- package/dist/augments/number/dimensions.d.ts +19 -0
- package/dist/augments/number/min-max.d.ts +11 -0
- package/dist/augments/number/min-max.js +14 -0
- package/dist/augments/number/number-conversion.d.ts +23 -0
- package/dist/augments/number/number-conversion.js +50 -0
- package/dist/augments/number/round.d.ts +3 -0
- package/dist/augments/number/round.js +5 -0
- package/dist/augments/number/scientific.d.ts +1 -0
- package/dist/augments/number/scientific.js +3 -0
- package/dist/{esm/augments → augments/number}/truncate-number.js +14 -12
- package/dist/augments/number/wrap-number.d.ts +13 -0
- package/dist/augments/number/wrap-number.js +22 -0
- package/dist/augments/object/diff.d.ts +29 -0
- package/dist/augments/object/diff.js +133 -0
- package/dist/augments/object/empty.d.ts +3 -0
- package/dist/augments/object/get-or-set.d.ts +31 -0
- package/dist/{esm/augments → augments}/object/get-or-set.js +5 -3
- package/dist/{types/augments → augments}/object/key-count.d.ts +9 -5
- package/dist/augments/object/map-entries.d.ts +13 -0
- package/dist/augments/object/map-entries.js +57 -0
- package/dist/augments/object/map-enum.d.ts +4 -0
- package/dist/augments/object/map-enum.js +21 -0
- package/dist/{types/augments/object/map-object.d.ts → augments/object/map-values.d.ts} +6 -3
- package/dist/{esm/augments/object/map-object.js → augments/object/map-values.js} +9 -9
- package/dist/{esm/augments → augments}/object/merge-deep.js +5 -6
- package/dist/augments/object/merge-defined-properties.d.ts +6 -0
- package/dist/augments/object/merge-defined-properties.js +19 -0
- package/dist/{esm/augments → augments}/object/merge-property-arrays.js +1 -1
- package/dist/augments/object/object-entries.d.ts +4 -0
- package/dist/augments/object/object-entries.js +13 -0
- package/dist/augments/object/object-filter.d.ts +2 -0
- package/dist/augments/object/object-filter.js +7 -0
- package/dist/augments/object/object-keys.d.ts +2 -0
- package/dist/augments/object/object-keys.js +11 -0
- package/dist/augments/object/object-values.d.ts +2 -0
- package/dist/augments/object/object-values.js +4 -0
- package/dist/augments/prisma/prisma-models.d.ts +106 -0
- package/dist/augments/prisma/prisma-models.js +1 -0
- package/dist/augments/promise/timed-promise.d.ts +7 -0
- package/dist/augments/promise/timed-promise.js +36 -0
- package/dist/augments/random/random-boolean.d.ts +18 -0
- package/dist/augments/random/random-boolean.js +26 -0
- package/dist/augments/random/random-integer.d.ts +12 -0
- package/dist/augments/random/random-integer.js +32 -0
- package/dist/augments/random/random-string.d.ts +14 -0
- package/dist/augments/random/random-string.js +63 -0
- package/dist/{types/augments/regexp.d.ts → augments/regexp/regexp-flags.d.ts} +1 -1
- package/dist/augments/regexp/regexp-flags.js +18 -0
- package/dist/augments/regexp/regexp-string.d.ts +5 -0
- package/dist/augments/regexp/regexp-string.js +7 -0
- package/dist/augments/regexp/safe-match.d.ts +1 -0
- package/dist/augments/regexp/safe-match.js +4 -0
- package/dist/augments/selection-set/select-collapsed.d.ts +11 -0
- package/dist/augments/selection-set/select-collapsed.js +25 -0
- package/dist/augments/selection-set/select-from.d.ts +3 -0
- package/dist/augments/selection-set/select-from.js +25 -0
- package/dist/augments/selection-set/selection-set.d.ts +18 -0
- package/dist/augments/selection-set/selection-set.js +4 -0
- package/dist/augments/string/casing/capitalization.d.ts +3 -0
- package/dist/augments/string/casing/capitalization.js +11 -0
- package/dist/augments/string/casing/casing.d.ts +27 -0
- package/dist/augments/string/casing/casing.js +40 -0
- package/dist/augments/string/casing/kebab-and-camel.d.ts +3 -0
- package/dist/augments/string/casing/kebab-and-camel.js +42 -0
- package/dist/augments/string/commas.d.ts +7 -0
- package/dist/augments/string/commas.js +29 -0
- package/dist/augments/string/join.d.ts +10 -0
- package/dist/augments/string/join.js +23 -0
- package/dist/{types/augments/string/prefixes.d.ts → augments/string/prefix.d.ts} +16 -1
- package/dist/{esm/augments/string/prefixes.js → augments/string/prefix.js} +11 -1
- package/dist/augments/string/replace.d.ts +1 -0
- package/dist/augments/string/replace.js +5 -0
- package/dist/augments/string/split.d.ts +4 -0
- package/dist/augments/string/split.js +28 -0
- package/dist/augments/string/substring-index.d.ts +13 -0
- package/dist/augments/string/substring-index.js +38 -0
- package/dist/augments/string/suffix.d.ts +74 -0
- package/dist/augments/string/suffix.js +73 -0
- package/dist/augments/string/white-space.d.ts +5 -0
- package/dist/augments/string/white-space.js +12 -0
- package/dist/augments/string/wrap-string.d.ts +4 -0
- package/dist/augments/string/wrap-string.js +5 -0
- package/dist/augments/type/ensure-type.d.ts +8 -0
- package/dist/augments/type/ensure-type.js +10 -0
- package/dist/augments/type/readonly.d.ts +2 -0
- package/dist/augments/type/readonly.js +3 -0
- package/dist/augments/type/type-recursion.js +1 -0
- package/dist/augments/type/void-type.d.ts +5 -0
- package/dist/augments/type/void-type.js +1 -0
- package/dist/augments/type/writable.d.ts +3 -0
- package/dist/augments/type/writable.js +3 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +81 -0
- package/package.json +33 -15
- package/README.md +0 -7
- package/dist/cjs/augments/ansi.js +0 -27
- package/dist/cjs/augments/array/array.js +0 -68
- package/dist/cjs/augments/array/remove-duplicates.js +0 -16
- package/dist/cjs/augments/async.js +0 -28
- package/dist/cjs/augments/boolean.js +0 -19
- package/dist/cjs/augments/common-number.js +0 -112
- package/dist/cjs/augments/common-string.js +0 -245
- package/dist/cjs/augments/debounce.js +0 -38
- package/dist/cjs/augments/environment.js +0 -6
- package/dist/cjs/augments/error.js +0 -52
- package/dist/cjs/augments/esm-path.js +0 -11
- package/dist/cjs/augments/function.js +0 -2
- package/dist/cjs/augments/json-compatible.js +0 -2
- package/dist/cjs/augments/json.js +0 -28
- package/dist/cjs/augments/object/any-object.js +0 -2
- package/dist/cjs/augments/object/enum.js +0 -48
- package/dist/cjs/augments/object/filter-object.js +0 -26
- package/dist/cjs/augments/object/get-or-set.js +0 -40
- package/dist/cjs/augments/object/has-key.js +0 -6
- package/dist/cjs/augments/object/jsonify.js +0 -6
- package/dist/cjs/augments/object/key-count.js +0 -2
- package/dist/cjs/augments/object/map-object.js +0 -61
- package/dist/cjs/augments/object/merge-deep.js +0 -52
- package/dist/cjs/augments/object/merge-property-arrays.js +0 -14
- package/dist/cjs/augments/object/object-entries.js +0 -40
- package/dist/cjs/augments/object/object.js +0 -18
- package/dist/cjs/augments/object/pick-deep.js +0 -2
- package/dist/cjs/augments/object/selection-set.js +0 -56
- package/dist/cjs/augments/object/typed-has-property.js +0 -29
- package/dist/cjs/augments/promise/deferred-promise.js +0 -31
- package/dist/cjs/augments/promise/promise.js +0 -79
- package/dist/cjs/augments/promise/wait.js +0 -66
- package/dist/cjs/augments/random.js +0 -123
- package/dist/cjs/augments/regexp.js +0 -19
- package/dist/cjs/augments/string/prefixes.js +0 -20
- package/dist/cjs/augments/string/suffixes.js +0 -40
- package/dist/cjs/augments/string/uuid.js +0 -7
- package/dist/cjs/augments/time.js +0 -35
- package/dist/cjs/augments/truncate-number.js +0 -153
- package/dist/cjs/augments/tuple.js +0 -20
- package/dist/cjs/augments/type-recursion.js +0 -2
- package/dist/cjs/augments/type.js +0 -36
- package/dist/cjs/augments/union.js +0 -2
- package/dist/cjs/augments/wrap-in-try.js +0 -37
- package/dist/cjs/index.js +0 -60
- package/dist/esm/augments/ansi.js +0 -24
- package/dist/esm/augments/array/array.js +0 -57
- package/dist/esm/augments/async.js +0 -23
- package/dist/esm/augments/common-number.js +0 -100
- package/dist/esm/augments/common-string.js +0 -227
- package/dist/esm/augments/debounce.js +0 -34
- package/dist/esm/augments/environment.js +0 -3
- package/dist/esm/augments/error.js +0 -45
- package/dist/esm/augments/json.js +0 -24
- package/dist/esm/augments/object/enum.js +0 -41
- package/dist/esm/augments/object/filter-object.js +0 -21
- package/dist/esm/augments/object/has-key.js +0 -3
- package/dist/esm/augments/object/jsonify.js +0 -3
- package/dist/esm/augments/object/object-entries.js +0 -32
- package/dist/esm/augments/object/object.js +0 -14
- package/dist/esm/augments/object/selection-set.js +0 -52
- package/dist/esm/augments/object/typed-has-property.js +0 -25
- package/dist/esm/augments/promise/deferred-promise.js +0 -28
- package/dist/esm/augments/promise/promise.js +0 -71
- package/dist/esm/augments/promise/wait.js +0 -60
- package/dist/esm/augments/random.js +0 -117
- package/dist/esm/augments/regexp.js +0 -14
- package/dist/esm/augments/string/suffixes.js +0 -31
- package/dist/esm/augments/string/uuid.js +0 -4
- package/dist/esm/augments/tuple.js +0 -16
- package/dist/esm/augments/type.js +0 -30
- package/dist/esm/index.js +0 -44
- package/dist/types/augments/ansi.d.ts +0 -1
- package/dist/types/augments/array/array.d.ts +0 -26
- package/dist/types/augments/async.d.ts +0 -14
- package/dist/types/augments/boolean.d.ts +0 -6
- package/dist/types/augments/common-number.d.ts +0 -52
- package/dist/types/augments/common-string.d.ts +0 -74
- package/dist/types/augments/debounce.d.ts +0 -15
- package/dist/types/augments/environment.d.ts +0 -1
- package/dist/types/augments/error.d.ts +0 -9
- package/dist/types/augments/function.d.ts +0 -25
- package/dist/types/augments/json.d.ts +0 -9
- package/dist/types/augments/object/any-object.d.ts +0 -2
- package/dist/types/augments/object/enum.d.ts +0 -8
- package/dist/types/augments/object/filter-object.d.ts +0 -4
- package/dist/types/augments/object/get-or-set.d.ts +0 -26
- package/dist/types/augments/object/has-key.d.ts +0 -1
- package/dist/types/augments/object/jsonify.d.ts +0 -2
- package/dist/types/augments/object/object-entries.d.ts +0 -8
- package/dist/types/augments/object/object.d.ts +0 -21
- package/dist/types/augments/object/pick-deep.d.ts +0 -14
- package/dist/types/augments/object/selection-set.d.ts +0 -27
- package/dist/types/augments/object/typed-has-property.d.ts +0 -7
- package/dist/types/augments/promise/deferred-promise.d.ts +0 -8
- package/dist/types/augments/promise/promise.d.ts +0 -15
- package/dist/types/augments/promise/wait.d.ts +0 -18
- package/dist/types/augments/random.d.ts +0 -39
- package/dist/types/augments/string/suffixes.d.ts +0 -17
- package/dist/types/augments/string/uuid.d.ts +0 -1
- package/dist/types/augments/time.d.ts +0 -14
- package/dist/types/augments/tuple.d.ts +0 -17
- package/dist/types/augments/type.d.ts +0 -69
- package/dist/types/augments/union.d.ts +0 -5
- package/dist/types/index.d.ts +0 -44
- /package/dist/{types/augments → augments}/array/remove-duplicates.d.ts +0 -0
- /package/dist/{esm/augments → augments}/array/remove-duplicates.js +0 -0
- /package/dist/{types/augments → augments/file}/esm-path.d.ts +0 -0
- /package/dist/{esm/augments → augments/file}/esm-path.js +0 -0
- /package/dist/{types/augments → augments/json}/json-compatible.d.ts +0 -0
- /package/dist/{esm/augments → augments/json}/json-compatible.js +0 -0
- /package/dist/{esm/augments/function.js → augments/log/log-writer.js} +0 -0
- /package/dist/{esm/augments/object/any-object.js → augments/number/coords.js} +0 -0
- /package/dist/{esm/augments/object/key-count.js → augments/number/digit.js} +0 -0
- /package/dist/{esm/augments/object/pick-deep.js → augments/number/dimensions.js} +0 -0
- /package/dist/{types/augments → augments/number}/truncate-number.d.ts +0 -0
- /package/dist/{esm/augments/type-recursion.js → augments/object/empty.js} +0 -0
- /package/dist/{esm/augments/union.js → augments/object/key-count.js} +0 -0
- /package/dist/{types/augments → augments}/object/merge-deep.d.ts +0 -0
- /package/dist/{types/augments → augments}/object/merge-property-arrays.d.ts +0 -0
- /package/dist/{types/augments → augments/type}/type-recursion.d.ts +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { PartialAndUndefined } from './object/object';
|
|
2
|
-
import { AtLeastTuple } from './tuple';
|
|
3
|
-
/**
|
|
4
|
-
* Join elements into a string with commas separating each value. Add a conjunction before the final
|
|
5
|
-
* item in the list. If the array has a length < 2, the conjunction is not added. If the list is
|
|
6
|
-
* only of length 2, then no commas are added.
|
|
7
|
-
*
|
|
8
|
-
* @param list Array of items to be converted into strings. Works best if these are simply strings
|
|
9
|
-
* to begin with.
|
|
10
|
-
* @param conjunction Defaults to 'and'. The conjunction to be used before the final element.
|
|
11
|
-
*/
|
|
12
|
-
export declare function joinWithFinalConjunction(list: ReadonlyArray<any>, conjunction?: string): string;
|
|
13
|
-
/** Wraps `value` on both sides with `wrapper`. */
|
|
14
|
-
export declare function wrapString({ value, wrapper }: {
|
|
15
|
-
value: string;
|
|
16
|
-
wrapper: string;
|
|
17
|
-
}): string;
|
|
18
|
-
export declare function removeAnsiEscapeCodes(input: string): string;
|
|
19
|
-
export declare const removeColor: typeof removeAnsiEscapeCodes;
|
|
20
|
-
export declare function removeCommasFromNumberString(numberString: string): string;
|
|
21
|
-
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */
|
|
22
|
-
export declare function collapseWhiteSpace(input: string, { keepNewLines }?: PartialAndUndefined<{
|
|
23
|
-
keepNewLines: boolean;
|
|
24
|
-
}>): string;
|
|
25
|
-
/** Same as String.prototype.split but includes the delimiter to split by in the output array. */
|
|
26
|
-
export declare function splitIncludeSplit(original: string, splitterInput: string | RegExp, caseSensitive: boolean): readonly string[];
|
|
27
|
-
export type CasingOptions = {
|
|
28
|
-
capitalizeFirstLetter: boolean;
|
|
29
|
-
};
|
|
30
|
-
export declare function capitalizeFirstLetter<InputGeneric extends string>(input: InputGeneric): Capitalize<InputGeneric>;
|
|
31
|
-
export declare function kebabCaseToCamelCase(rawKebabCase: string, casingOptions?: Partial<CasingOptions> | undefined): string;
|
|
32
|
-
export declare enum StringCaseEnum {
|
|
33
|
-
Upper = "upper",
|
|
34
|
-
Lower = "lower"
|
|
35
|
-
}
|
|
36
|
-
/** Indicates whether the given string has different lower and upper case variants. */
|
|
37
|
-
export declare function hasCase(input: string): boolean;
|
|
38
|
-
export type IsCaseOptions = {
|
|
39
|
-
/**
|
|
40
|
-
* Block characters that don't have different upper and lower case versions (such as
|
|
41
|
-
* punctuation).
|
|
42
|
-
*/
|
|
43
|
-
blockNoCaseCharacters: boolean;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Checks if the given string is exclusively of the specific case.
|
|
47
|
-
*
|
|
48
|
-
* Note that some characters have no casing, such as punctuation (they have no difference between
|
|
49
|
-
* upper and lower casings). By default, those letters always return `true` for this function,
|
|
50
|
-
* regardless of which `caseType` is provided. To instead return `false` for any such characters,
|
|
51
|
-
* pass in an options object and set blockNoCaseCharacters to true.
|
|
52
|
-
*/
|
|
53
|
-
export declare function isCase(input: string, caseType: StringCaseEnum, options?: PartialAndUndefined<IsCaseOptions>): boolean;
|
|
54
|
-
export declare function camelCaseToKebabCase(rawCamelCase: string): string;
|
|
55
|
-
export declare function replaceStringAtIndex(originalString: string, start: number, newString: string, length?: number): string;
|
|
56
|
-
/**
|
|
57
|
-
* Escapes characters from the given string so that it can be used within a RegExp without being
|
|
58
|
-
* parsed as RegExp syntax.
|
|
59
|
-
*/
|
|
60
|
-
export declare function escapeStringForRegExp(input: string): string;
|
|
61
|
-
export declare function getAllIndexesOf<IncludeLength extends boolean | undefined>({ searchIn, searchFor, caseSensitive, includeLength, }: {
|
|
62
|
-
searchIn: string;
|
|
63
|
-
searchFor: string | RegExp;
|
|
64
|
-
/**
|
|
65
|
-
* CaseSensitive only applies when the input is a string. Otherwise, the RegExp's "i" flag is
|
|
66
|
-
* used to determine case sensitivity.
|
|
67
|
-
*/
|
|
68
|
-
caseSensitive: boolean;
|
|
69
|
-
includeLength?: IncludeLength;
|
|
70
|
-
}): IncludeLength extends true ? {
|
|
71
|
-
index: number;
|
|
72
|
-
length: number;
|
|
73
|
-
}[] : number[];
|
|
74
|
-
export declare function typedSplit(input: string, splitString: string): AtLeastTuple<string, 1>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare enum DebounceStyle {
|
|
2
|
-
/**
|
|
3
|
-
* Fires on the first call, then waits the given amount of milliseconds until a subsequent call
|
|
4
|
-
* can be made.
|
|
5
|
-
*/
|
|
6
|
-
FirstThenWait = "first-then-wait",
|
|
7
|
-
/**
|
|
8
|
-
* Waits the given amount of milliseconds after the first call and then fires the latest
|
|
9
|
-
* assigned callback.
|
|
10
|
-
*/
|
|
11
|
-
AfterWait = "after-wait"
|
|
12
|
-
}
|
|
13
|
-
export declare function createDebounce(debounceStyle: DebounceStyle, debounceDuration: {
|
|
14
|
-
milliseconds: number;
|
|
15
|
-
}): (callback: () => void) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isBrowser(): boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AtLeastTuple } from './tuple';
|
|
2
|
-
export declare function combineErrors(errors: AtLeastTuple<Error, 1>): Error;
|
|
3
|
-
export declare function combineErrors(errors: ReadonlyArray<never>): undefined;
|
|
4
|
-
export declare function combineErrors(errors: ReadonlyArray<Error>): Error | undefined;
|
|
5
|
-
export declare function combineErrors(errors?: undefined): undefined;
|
|
6
|
-
export declare function combineErrorMessages(errors?: ReadonlyArray<Error | string | undefined> | undefined): string;
|
|
7
|
-
export declare function extractErrorMessage(maybeError: unknown): string;
|
|
8
|
-
export declare function ensureError(maybeError: unknown): Error;
|
|
9
|
-
export declare function ensureErrorAndPrependMessage(maybeError: unknown, prependMessage: string): Error;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ArrayElement } from './type';
|
|
2
|
-
export type AnyFunction<ReturnGeneric = any> = (...args: any[]) => ReturnGeneric;
|
|
3
|
-
export type NoInputsFunction<ReturnGeneric = any> = () => ReturnGeneric;
|
|
4
|
-
/**
|
|
5
|
-
* Accepts an "Arguments" and "Return" generic to quickly make a function type. If "Arguments" is an
|
|
6
|
-
* array, it is spread into the full function's Parameters list. If any argument should be an array,
|
|
7
|
-
* instead of a rest parameter, put it inside of a tuple. If no arguments should be possible, pass
|
|
8
|
-
* void to "Arguments". If you need an optional argument, pass it inside of a tuple.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* TypedFunction<string, number>; // (input: string) => number
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* TypedFunction<string[], number>; // (...inputs: string[]) => number
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* TypedFunction<[string[]], number>; // (input: string[]) => number
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* TypedFunction<[string, number], number>; // (input1: string, input2: number) => number
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* TypedFunction<[string | undefined], number>; // (input1: string|undefined) => number
|
|
24
|
-
*/
|
|
25
|
-
export type TypedFunction<Arguments, Return> = Arguments extends readonly any[] ? number extends Arguments['length'] ? (...args: ArrayElement<Arguments>[]) => Return : (...args: Arguments) => Return : void extends Arguments ? () => Return : (arg: Arguments) => Return;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { JsonCompatibleValue } from './json-compatible';
|
|
2
|
-
import { WrapInTryOptions } from './wrap-in-try';
|
|
3
|
-
export declare function parseJson<ParsedJsonGeneric>({ jsonString, errorHandler, }: {
|
|
4
|
-
jsonString: string;
|
|
5
|
-
errorHandler?: (error: unknown) => never | ParsedJsonGeneric;
|
|
6
|
-
}): ParsedJsonGeneric;
|
|
7
|
-
export declare function stringifyJson(jsonValue: JsonCompatibleValue, { whitespace, ...tryOptions }?: {
|
|
8
|
-
whitespace?: number;
|
|
9
|
-
} & WrapInTryOptions<string>): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type EnumBaseType = Record<string, number | string>;
|
|
2
|
-
export declare function getEnumTypedKeys<T extends EnumBaseType>(input: T): (keyof T)[];
|
|
3
|
-
export declare function getEnumTypedValues<T extends EnumBaseType>(input: T): T[keyof T][];
|
|
4
|
-
/** Check if the given value is within the given enum. */
|
|
5
|
-
export declare function isEnumValue<T extends EnumBaseType>(input: unknown, checkEnum: T): input is T[keyof T];
|
|
6
|
-
/** Interpret a primitive as an enum value with type safety. */
|
|
7
|
-
export declare function ensureEnum<const ValueType extends `${EnumType[keyof EnumType]}`, const EnumType extends EnumBaseType>(value: ValueType, checkEnum: EnumType): EnumType[keyof EnumType];
|
|
8
|
-
export declare function filterToEnumValues<T extends EnumBaseType>(inputs: ReadonlyArray<unknown>, checkEnum: T, caseInsensitive?: boolean): T[keyof T][];
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PropertyValueType } from './object';
|
|
2
|
-
export declare function filterObject<ObjectGeneric>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: PropertyValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
3
|
-
export declare function omitObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, omitTheseKeys: ReadonlyArray<KeyGeneric>): Omit<ObjectGeneric, KeyGeneric>;
|
|
4
|
-
export declare function pickObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, pickTheseKeys: ReadonlyArray<KeyGeneric>): Pick<ObjectGeneric, KeyGeneric>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { MaybePromise } from '../promise/promise';
|
|
2
|
-
/**
|
|
3
|
-
* Get a value from a map or call the callback and return its result and store the result in the
|
|
4
|
-
* map.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getOrSetFromMap<MapKey extends object, MapValue>(map: WeakMap<MapKey, MapValue>, key: MapKey, createNewValueCallback: () => MapValue): MapValue;
|
|
7
|
-
export declare function getOrSetFromMap<MapKey, MapValue>(map: Map<MapKey, MapValue>, key: MapKey, createNewValueCallback: () => MapValue): MapValue;
|
|
8
|
-
/**
|
|
9
|
-
* Given an object, tries to get the given key in that object. If the key is not in that object,
|
|
10
|
-
* then the given `createCallback` is used to create a new value which is then stored in the given
|
|
11
|
-
* object and returned. Automatically handles `createCallback` returning a promise, if it does.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // instead of doing this
|
|
15
|
-
* if (!myObject[myKey]) {
|
|
16
|
-
* myObject[myKey] = myValue;
|
|
17
|
-
* }
|
|
18
|
-
* // notice the not null assertion here
|
|
19
|
-
* retrievedValue![nextKey] = 'some value';
|
|
20
|
-
*
|
|
21
|
-
* // do this
|
|
22
|
-
* getOrSetInObject(myObject, myKey, () => myValue);
|
|
23
|
-
*/
|
|
24
|
-
export declare function getOrSet<OriginalObject extends object, Key extends keyof OriginalObject>(originalObject: OriginalObject, key: Key, createCallback: () => OriginalObject[Key]): Required<OriginalObject>[Key];
|
|
25
|
-
export declare function getOrSet<OriginalObject extends object, Key extends keyof OriginalObject>(originalObject: OriginalObject, key: Key, createCallback: () => Promise<OriginalObject[Key]>): Promise<Required<OriginalObject>[Key]>;
|
|
26
|
-
export declare function getOrSet<OriginalObject extends object, Key extends keyof OriginalObject>(originalObject: OriginalObject, key: Key, createCallback: () => MaybePromise<OriginalObject[Key]>): MaybePromise<Required<OriginalObject>[Key]>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function hasKey<ParentType>(parent: ParentType, property: PropertyKey): property is keyof ParentType;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RemovePartial } from './object';
|
|
2
|
-
/** @deprecated This is the same as hasKey */
|
|
3
|
-
export declare function isKeyof<ObjectGeneric>(key: PropertyKey, object: ObjectGeneric): key is keyof ObjectGeneric;
|
|
4
|
-
export declare function getObjectTypedKeys<ObjectGeneric>(input: ObjectGeneric): Array<keyof ObjectGeneric>;
|
|
5
|
-
export declare function getObjectTypedValues<ObjectGeneric>(input: ObjectGeneric): RemovePartial<ObjectGeneric>[keyof RemovePartial<ObjectGeneric>][];
|
|
6
|
-
export declare function getObjectTypedEntries<ObjectGeneric>(input: ObjectGeneric): [keyof ObjectGeneric, RemovePartial<ObjectGeneric>[keyof RemovePartial<ObjectGeneric>]][];
|
|
7
|
-
export declare function getEntriesSortedByKey(input: object): [string, unknown][];
|
|
8
|
-
export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { RequireAtLeastOne, Writable } from 'type-fest';
|
|
2
|
-
export type PartialAndNullable<T extends object> = {
|
|
3
|
-
[Prop in keyof T]?: T[Prop] | null | undefined;
|
|
4
|
-
};
|
|
5
|
-
export type PartialAndUndefined<T extends object> = {
|
|
6
|
-
[Prop in keyof T]?: T[Prop] | undefined;
|
|
7
|
-
};
|
|
8
|
-
/** Checks if the input is non-null and an object. Includes arrays. */
|
|
9
|
-
export declare function isObject(input: any): input is NonNullable<object>;
|
|
10
|
-
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
11
|
-
export declare function copyThroughJson<T>(input: Readonly<T>): Writable<T>;
|
|
12
|
-
export type PropertyValueType<T> = T[keyof T];
|
|
13
|
-
export type ExtractKeysWithMatchingValues<OriginalObject extends object, Matcher> = keyof {
|
|
14
|
-
[Prop in keyof OriginalObject as OriginalObject[Prop] extends Matcher ? Prop : never]: Prop;
|
|
15
|
-
};
|
|
16
|
-
export type ExcludeKeysWithMatchingValues<OriginalObject extends object, Matcher> = keyof {
|
|
17
|
-
[Prop in keyof OriginalObject as OriginalObject[Prop] extends Matcher ? never : Prop]: Prop;
|
|
18
|
-
};
|
|
19
|
-
export type RemovePartial<Input> = Input extends Partial<Record<infer K extends PropertyKey, infer V>> ? Required<Record<K, V>> : Required<Input>;
|
|
20
|
-
/** Excludes empty objects from a union. */
|
|
21
|
-
export type ExcludeEmpty<T> = T extends RequireAtLeastOne<T> ? T : never;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { OptionalKeysOf, RequiredKeysOf } from 'type-fest';
|
|
2
|
-
import { AnyFunction } from '../function';
|
|
3
|
-
import { ArrayElement } from '../type';
|
|
4
|
-
import { TsRecurse, TsRecursionStart, TsRecursionTracker } from '../type-recursion';
|
|
5
|
-
import { AnyObject } from './any-object';
|
|
6
|
-
export type InnerPickDeep<OriginalObject extends AnyObject, DeepKeys extends any[], Depth extends TsRecursionTracker> = DeepKeys extends [infer CurrentLevelPick, ...infer RemainingKeys] ? Extract<CurrentLevelPick, keyof OriginalObject> extends never ? OriginalObject : {
|
|
7
|
-
[CurrentProp in Extract<CurrentLevelPick, RequiredKeysOf<OriginalObject>>]: InnerPickDeepValue<OriginalObject, CurrentProp, RemainingKeys, Depth>;
|
|
8
|
-
} & {
|
|
9
|
-
[CurrentProp in Extract<CurrentLevelPick, OptionalKeysOf<OriginalObject>>]?: InnerPickDeepValue<OriginalObject, CurrentProp, RemainingKeys, Depth>;
|
|
10
|
-
} : DeepKeys extends [] ? OriginalObject : DeepKeys extends [infer CurrentLevelPick] ? CurrentLevelPick extends keyof OriginalObject ? Pick<OriginalObject, CurrentLevelPick> : never : never;
|
|
11
|
-
type InnerPickDeepValue<OriginalObject, CurrentProp extends keyof OriginalObject, RemainingKeys extends any[], Depth extends TsRecursionTracker> = AnyFunction extends Extract<OriginalObject[CurrentProp], AnyFunction> ? OriginalObject[CurrentProp] | Exclude<OriginalObject[CurrentProp], AnyFunction> : Array<any> extends Extract<OriginalObject[CurrentProp], Array<any>> ? Array<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], Array<any>>>, RemainingKeys, TsRecurse<Depth>>> | Exclude<OriginalObject[CurrentProp], Array<any>> : ReadonlyArray<any> extends Extract<OriginalObject[CurrentProp], ReadonlyArray<any>> ? ReadonlyArray<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], ReadonlyArray<any>>>, RemainingKeys, TsRecurse<Depth>>> | Exclude<OriginalObject[CurrentProp], ReadonlyArray<any>> : Extract<OriginalObject[CurrentProp], Record<any, any>> extends never ? OriginalObject[CurrentProp] : InnerPickDeep<Extract<OriginalObject[CurrentProp], Record<any, any>>, RemainingKeys, TsRecurse<Depth>> | Exclude<OriginalObject[CurrentProp], Record<any, any>>;
|
|
12
|
-
/** Pick nested keys. */
|
|
13
|
-
export type PickDeep<OriginalObject extends object, DeepKeys extends PropertyKey[]> = InnerPickDeep<OriginalObject, DeepKeys, TsRecursionStart>;
|
|
14
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { IsAny, IsNever, Primitive } from 'type-fest';
|
|
2
|
-
import { TsRecurse, TsRecursionStart, TsRecursionTracker, TsTooMuchRecursion } from '../type-recursion';
|
|
3
|
-
import { UnionToIntersection } from '../union';
|
|
4
|
-
import { AnyObject } from './any-object';
|
|
5
|
-
import { KeyCount } from './key-count';
|
|
6
|
-
import { ExcludeEmpty, PropertyValueType } from './object';
|
|
7
|
-
/** All types that won't be recursed into when defining a {@link SelectionSet}. */
|
|
8
|
-
export type SelectionTypesToPreserve = Primitive | RegExp | Promise<any>;
|
|
9
|
-
/** A generic selection set without specific keys. */
|
|
10
|
-
export type GenericSelectionSet = {
|
|
11
|
-
[Key in PropertyKey]: boolean | GenericSelectionSet | unknown;
|
|
12
|
-
};
|
|
13
|
-
/** Masks an object value with the given {@link SelectionSet}. */
|
|
14
|
-
export type PickSelection<Full extends Readonly<AnyObject>, Selection extends GenericSelectionSet, Depth extends TsRecursionTracker = TsRecursionStart> = Depth extends TsTooMuchRecursion ? ['Error: recursive object depth is too deep.'] : Full extends ReadonlyArray<infer Element extends any> ? (PickSelection<Extract<Element, AnyObject>, Selection, TsRecurse<Depth>> | Exclude<Element, AnyObject>)[] : {
|
|
15
|
-
-readonly [Key in keyof Selection as Selection[Key] extends false ? never : Key extends keyof Full ? Key : never]: (Selection[Key] extends GenericSelectionSet ? PickSelection<NonNullable<Extract<Full[Key], AnyObject>>, Selection[Key], TsRecurse<Depth>> : Full[Key]) | Exclude<Full[Key], AnyObject>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Collapses a selected value to the first part of the selection that contains more than 1 key or
|
|
19
|
-
* that is not an object.
|
|
20
|
-
*/
|
|
21
|
-
export type PickCollapsedSelection<Full extends Readonly<AnyObject>, Selection extends GenericSelectionSet, Depth extends TsRecursionTracker = TsRecursionStart> = Depth extends TsTooMuchRecursion ? 'Error: recursive object depth is too deep.' : KeyCount<ExcludeEmpty<NonNullable<PickSelection<Full, Selection, Depth>>>> extends 1 ? Selection[keyof PickSelection<Full, Selection, Depth>] extends GenericSelectionSet ? PickCollapsedSelection<NonNullable<Full[keyof PickSelection<Full, Selection, Depth>]>, Selection[keyof PickSelection<Full, Selection, Depth>], TsRecurse<Depth>> | Extract<Full[keyof PickSelection<Full, Selection, Depth>], undefined | null> : PropertyValueType<PickSelection<Full, Selection, Depth>> : PickSelection<Full, Selection, Depth>;
|
|
22
|
-
/** Defines a selection set for the given object. */
|
|
23
|
-
export type SelectionSet<Full extends Readonly<AnyObject>, Depth extends TsRecursionTracker = TsRecursionStart> = IsAny<Full> extends true ? any : Depth extends TsTooMuchRecursion ? boolean : Full extends ReadonlyArray<infer FullChild extends AnyObject> ? SelectionSet<FullChild, TsRecurse<Depth>> : Partial<{
|
|
24
|
-
[Key in keyof Full]: IsNever<Exclude<Full[Key], SelectionTypesToPreserve>> extends true ? boolean : UnionToIntersection<SelectionSet<NonNullable<Required<Full>[Key]>, TsRecurse<Depth>>> | boolean;
|
|
25
|
-
}>;
|
|
26
|
-
export declare function selectFrom<Full extends AnyObject, const Selection extends SelectionSet<NoInfer<Full>>>(originalObject: Readonly<Full>, selectionSet: Readonly<Selection>): PickSelection<Full, Selection>;
|
|
27
|
-
export declare function selectCollapsedFrom<Full extends AnyObject, const Selection extends SelectionSet<NoInfer<Full>>>(originalObject: Readonly<Full>, selectionSet: Readonly<Selection>): PickCollapsedSelection<Full, Selection>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RequiredBy } from '../type';
|
|
2
|
-
type ExtractValue<KeyGeneric extends PropertyKey, ParentGeneric> = KeyGeneric extends keyof ParentGeneric ? RequiredBy<ParentGeneric, KeyGeneric>[KeyGeneric] : KeyGeneric extends keyof Extract<ParentGeneric, Record<KeyGeneric, any>> ? RequiredBy<Extract<ParentGeneric, Record<KeyGeneric, any>>, KeyGeneric>[KeyGeneric] : never;
|
|
3
|
-
type CombinedParentValue<KeyGeneric extends PropertyKey, ParentGeneric> = ExtractValue<KeyGeneric, ParentGeneric> extends never ? unknown : ExtractValue<KeyGeneric, ParentGeneric>;
|
|
4
|
-
type CombineTypeWithKey<KeyGeneric extends PropertyKey, ParentGeneric> = ParentGeneric & Record<KeyGeneric, CombinedParentValue<KeyGeneric, ParentGeneric>>;
|
|
5
|
-
export declare function typedHasProperty<KeyGeneric extends PropertyKey, ParentGeneric>(inputObject: ParentGeneric, inputKey: KeyGeneric): inputObject is CombineTypeWithKey<KeyGeneric, ParentGeneric>;
|
|
6
|
-
export declare function typedHasProperties<KeyGeneric extends PropertyKey, ParentGeneric>(inputObject: ParentGeneric, inputKeys: ReadonlyArray<KeyGeneric>): inputObject is CombineTypeWithKey<KeyGeneric, ParentGeneric>;
|
|
7
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** A promise which can be resolved or rejected by external code. */
|
|
2
|
-
export type DeferredPromiseWrapper<T> = {
|
|
3
|
-
promise: Promise<T>;
|
|
4
|
-
resolve: (value: T | PromiseLike<T>) => void;
|
|
5
|
-
reject: (reason?: any) => void;
|
|
6
|
-
isSettled: () => boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function createDeferredPromiseWrapper<T = void>(): DeferredPromiseWrapper<T>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
|
|
2
|
-
export type MaybePromise<T> = Promise<T> | T;
|
|
3
|
-
export declare class PromiseTimeoutError extends Error {
|
|
4
|
-
readonly durationMs: number;
|
|
5
|
-
readonly message: string;
|
|
6
|
-
readonly name = "PromiseTimeoutError";
|
|
7
|
-
constructor(durationMs: number, message?: string);
|
|
8
|
-
}
|
|
9
|
-
export declare function wrapPromiseInTimeout<PromiseValueType>(durationMs: number, originalPromise: PromiseLike<PromiseValueType>): Promise<PromiseValueType>;
|
|
10
|
-
/**
|
|
11
|
-
* Call a function asynchronously without interrupting current synchronous execution, even if the
|
|
12
|
-
* function was originally synchronous.
|
|
13
|
-
*/
|
|
14
|
-
export declare function callAsynchronously<T>(callback: () => MaybePromise<T>): Promise<T>;
|
|
15
|
-
export declare function executeWithRetries<T>(retryCount: number, callback: () => T): Promise<T>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FalsyTypes } from '../boolean';
|
|
2
|
-
export declare function wait(delayMs: number): Promise<void>;
|
|
3
|
-
export declare function waitValue<ResolutionValue>(delayMs: number, returnValue: ResolutionValue): Promise<ResolutionValue>;
|
|
4
|
-
export type WaitUntilTruthyOptions = {
|
|
5
|
-
interval: {
|
|
6
|
-
milliseconds: number;
|
|
7
|
-
};
|
|
8
|
-
timeout: {
|
|
9
|
-
milliseconds: number;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export declare const defaultWaitUntilDefinedOptions: WaitUntilTruthyOptions;
|
|
13
|
-
/**
|
|
14
|
-
* Runs the predicate until it returns a truthy value, then returns that value. Use the options
|
|
15
|
-
* input to modify the timeout and interval durations. Automatically catches errors and handles
|
|
16
|
-
* async predicates.
|
|
17
|
-
*/
|
|
18
|
-
export declare function waitUntilTruthy<Value>(predicate: () => Value | Promise<Value> | FalsyTypes, failureMessage?: string | undefined, optionsInput?: Partial<WaitUntilTruthyOptions>): Promise<Awaited<Value>>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a random integer (decimal points are all cut off) between the given min and max
|
|
3
|
-
* (inclusive).
|
|
4
|
-
*
|
|
5
|
-
* This function uses cryptographically secure randomness.
|
|
6
|
-
*/
|
|
7
|
-
export declare function randomInteger({ min: rawMin, max: rawMax }: {
|
|
8
|
-
min: number;
|
|
9
|
-
max: number;
|
|
10
|
-
}): number;
|
|
11
|
-
/**
|
|
12
|
-
* Returns true at rate of the percentLikelyToBeTrue input. Inputs should be whole numbers which
|
|
13
|
-
* will be treated like percents. Anything outside of 0-100 inclusively will be clamped. An input 0
|
|
14
|
-
* will always return true. An input of 100 will always return true. Decimals on the input will be
|
|
15
|
-
* chopped off, use whole numbers.
|
|
16
|
-
*
|
|
17
|
-
* This function uses cryptographically secure randomness.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* randomBoolean(50); // 50% chance to return true
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* randomBoolean(0); // always false, 0% chance of being true
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* randomBoolean(100); // always true, 100% chance of being true
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* randomBoolean(59.67; // 59% chance of being true
|
|
30
|
-
*/
|
|
31
|
-
export declare function randomBoolean(percentLikelyToBeTrue?: number): boolean;
|
|
32
|
-
/** Creates a cryptographically secure uuid. */
|
|
33
|
-
export declare function createUuid(): `${string}-${string}-${string}-${string}-${string}`;
|
|
34
|
-
/**
|
|
35
|
-
* Creates a random string (including letters and numbers) of a given length.
|
|
36
|
-
*
|
|
37
|
-
* This function uses cryptographically secure randomness.
|
|
38
|
-
*/
|
|
39
|
-
export declare function randomString(inputLength?: number): string;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type WithSuffix<Suffix extends string> = `${string}${Suffix}`;
|
|
2
|
-
export declare const percentSuffix: "%";
|
|
3
|
-
export declare const pxSuffix: "px";
|
|
4
|
-
export type WithPx = WithSuffix<typeof pxSuffix>;
|
|
5
|
-
export type WithPercent = WithSuffix<typeof percentSuffix>;
|
|
6
|
-
export declare function addPx(input: number | string): WithPx;
|
|
7
|
-
export declare function removePx(input: string): number;
|
|
8
|
-
export declare function addPercent(input: number | string): WithPercent;
|
|
9
|
-
export declare function removePercent(input: string): number;
|
|
10
|
-
export declare function addSuffix<const Suffix extends string>({ value, suffix, }: {
|
|
11
|
-
value: unknown;
|
|
12
|
-
suffix: Suffix;
|
|
13
|
-
}): WithSuffix<Suffix>;
|
|
14
|
-
export declare function removeSuffix<const Suffix extends string>({ value, suffix, }: {
|
|
15
|
-
value: WithSuffix<Suffix> | string;
|
|
16
|
-
suffix: Suffix;
|
|
17
|
-
}): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isUuid(maybeUuid: string): boolean;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
3
|
-
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
4
|
-
* purely synchronous).
|
|
5
|
-
*/
|
|
6
|
-
export declare function timeCallback<T>(callback: () => T): T extends Promise<any> ? Promise<number> : number;
|
|
7
|
-
/**
|
|
8
|
-
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
9
|
-
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
10
|
-
* purely synchronous).
|
|
11
|
-
*
|
|
12
|
-
* Alias of timeCallback.
|
|
13
|
-
*/
|
|
14
|
-
export declare const measureCallbackDuration: typeof timeCallback;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type Tuple<ArrayElementGeneric, LengthGeneric extends number> = LengthGeneric extends LengthGeneric ? number extends LengthGeneric ? ArrayElementGeneric[] : _TupleOf<ArrayElementGeneric, LengthGeneric, []> : never;
|
|
2
|
-
type _TupleOf<ArrayElementGeneric, LengthGeneric extends number, FullArrayGeneric extends unknown[]> = FullArrayGeneric['length'] extends LengthGeneric ? FullArrayGeneric : _TupleOf<ArrayElementGeneric, LengthGeneric, [ArrayElementGeneric, ...FullArrayGeneric]>;
|
|
3
|
-
export type AtLeastTuple<ArrayElementGeneric, LengthGeneric extends number> = readonly [
|
|
4
|
-
...Tuple<ArrayElementGeneric, LengthGeneric>,
|
|
5
|
-
...ArrayElementGeneric[]
|
|
6
|
-
];
|
|
7
|
-
export declare function isLengthAtLeast<ArrayElementGeneric, LengthGeneric extends number>(array: ReadonlyArray<ArrayElementGeneric | undefined>, length: LengthGeneric): array is AtLeastTuple<ArrayElementGeneric, LengthGeneric>;
|
|
8
|
-
export declare function assertLengthAtLeast<ArrayElementGeneric, LengthGeneric extends number>(array: ReadonlyArray<ArrayElementGeneric | undefined>, length: LengthGeneric, arrayName?: string): asserts array is AtLeastTuple<ArrayElementGeneric, LengthGeneric>;
|
|
9
|
-
export type MappedTuple<Tuple extends ReadonlyArray<any>, NewValueType> = {
|
|
10
|
-
[I in keyof Tuple]: NewValueType;
|
|
11
|
-
};
|
|
12
|
-
export type MaybeTuple<T> = T | AtLeastTuple<T, 1>;
|
|
13
|
-
export type RemoveFirstTupleEntry<T extends ReadonlyArray<unknown>> = T extends readonly [
|
|
14
|
-
firstArg: unknown,
|
|
15
|
-
...theRest: infer TheRest
|
|
16
|
-
] ? TheRest : T;
|
|
17
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Except, Simplify } from 'type-fest';
|
|
2
|
-
/** Makes all properties in an object writable. This is the opposite of Readonly<> */
|
|
3
|
-
export type Writeable<T> = {
|
|
4
|
-
-readonly [P in keyof T]: T[P];
|
|
5
|
-
};
|
|
6
|
-
/** Makes all property values in an object also readonly. Can cause issues on primitive. */
|
|
7
|
-
export type DeepWriteable<T> = {
|
|
8
|
-
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
9
|
-
};
|
|
10
|
-
/** Replace properties in T with properties in U. */
|
|
11
|
-
export type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
12
|
-
/**
|
|
13
|
-
* Require that the NonVoid parameter is not void. If it is void, the ErrorType or an error string
|
|
14
|
-
* type is returned. If it not void, the given SuccessType is returned.
|
|
15
|
-
*/
|
|
16
|
-
export type RequireNonVoid<NonVoid, SuccessType, ErrorType = 'Input should not be void'> = void extends NonVoid ? (NonVoid extends void ? ErrorType : SuccessType) : SuccessType;
|
|
17
|
-
/** Extract the element type out of an array type. */
|
|
18
|
-
export type ArrayElement<ArrayType extends ReadonlyArray<any>> = ArrayType[number];
|
|
19
|
-
/**
|
|
20
|
-
* Same as the Required<> built-in type helper but this requires that each property be present and
|
|
21
|
-
* be not null.
|
|
22
|
-
*/
|
|
23
|
-
export type RequiredAndNotNull<T> = {
|
|
24
|
-
[P in keyof T]-?: NonNullable<T[P]>;
|
|
25
|
-
};
|
|
26
|
-
export type SetOptionalAndNullable<OriginalObjectGeneric, OptionalKeysGeneric extends keyof OriginalObjectGeneric> = Simplify<Except<OriginalObjectGeneric, OptionalKeysGeneric> & {
|
|
27
|
-
[PropKey in OptionalKeysGeneric]?: OriginalObjectGeneric[PropKey] | null | undefined;
|
|
28
|
-
}>;
|
|
29
|
-
/** Require only a subset of object properties. */
|
|
30
|
-
export type RequiredBy<T, K extends keyof T> = Overwrite<T, Required<Pick<T, K>>>;
|
|
31
|
-
export declare function makeWritable<T>(input: T): Writeable<T>;
|
|
32
|
-
export declare function makeReadonly<T>(input: T): Readonly<T>;
|
|
33
|
-
/**
|
|
34
|
-
* Require only a subset of object properties and require that they be not null. This is
|
|
35
|
-
* particularly useful in conjunction with the "exactOptionalPropertyTypes" tsconfig flag.
|
|
36
|
-
*/
|
|
37
|
-
export type RequiredAndNotNullBy<T, K extends keyof T> = Omit<T, K> & Required<{
|
|
38
|
-
[PropertyName in K]: NonNullable<T[PropertyName]>;
|
|
39
|
-
}>;
|
|
40
|
-
/** If type T = type U, then type Y. Else type N. */
|
|
41
|
-
export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
|
|
42
|
-
/**
|
|
43
|
-
* This function returns another function that simply returns whatever input it's given. However, it
|
|
44
|
-
* also checks that the input matches the original wrapNarrowTypeWithTypeCheck's generic, while
|
|
45
|
-
* maintaining strict "const" like typing.
|
|
46
|
-
*
|
|
47
|
-
* Use like this: wrapNarrowTypeWithTypeCheck<EnforcedTypeHere>()(valueToEnforceTypeOn as const)
|
|
48
|
-
*
|
|
49
|
-
* Sometimes "as const" isn't required, usually it is for any object or array though.
|
|
50
|
-
*/
|
|
51
|
-
export declare function wrapNarrowTypeWithTypeCheck<P>(): <T extends P>(input: T) => Readonly<T>;
|
|
52
|
-
/**
|
|
53
|
-
* This type helper is useful for forcing function generics to be explicitly provided, rather than
|
|
54
|
-
* inferring them from the given inputs. See the test file for examples.
|
|
55
|
-
*/
|
|
56
|
-
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
57
|
-
/**
|
|
58
|
-
* This is a type helper that ensures the given input matches the given generic type. The generic is
|
|
59
|
-
* setup in such a way that if it is omitted (which is typically allowed in TypeScript, resulting in
|
|
60
|
-
* the generic being inferred from the inputs), there will actually be a type error. This forces
|
|
61
|
-
* each usage of this function to explicitly specify the generic, thus giving us type safety for the
|
|
62
|
-
* input.
|
|
63
|
-
*/
|
|
64
|
-
export declare function ensureType<ExpectedType = never>(input: NoInfer<ExpectedType>): NoInfer<ExpectedType>;
|
|
65
|
-
/** Picks only the public properties of a type. */
|
|
66
|
-
export type Public<T> = {
|
|
67
|
-
[P in keyof T]: T[P];
|
|
68
|
-
};
|
|
69
|
-
export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the version of UnionToIntersection from type-fest v4.3.3. In version 4.4.0 type-fest
|
|
3
|
-
* changed this type helper and it broke how we're using it.
|
|
4
|
-
*/
|
|
5
|
-
export type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection : never;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export * from './augments/ansi';
|
|
2
|
-
export * from './augments/array/array';
|
|
3
|
-
export * from './augments/array/remove-duplicates';
|
|
4
|
-
export * from './augments/async';
|
|
5
|
-
export * from './augments/boolean';
|
|
6
|
-
export * from './augments/common-number';
|
|
7
|
-
export * from './augments/common-string';
|
|
8
|
-
export * from './augments/debounce';
|
|
9
|
-
export * from './augments/environment';
|
|
10
|
-
export * from './augments/error';
|
|
11
|
-
export * from './augments/esm-path';
|
|
12
|
-
export * from './augments/function';
|
|
13
|
-
export * from './augments/json';
|
|
14
|
-
export * from './augments/json-compatible';
|
|
15
|
-
export * from './augments/object/any-object';
|
|
16
|
-
export * from './augments/object/enum';
|
|
17
|
-
export * from './augments/object/filter-object';
|
|
18
|
-
export * from './augments/object/get-or-set';
|
|
19
|
-
export * from './augments/object/has-key';
|
|
20
|
-
export * from './augments/object/jsonify';
|
|
21
|
-
export * from './augments/object/key-count';
|
|
22
|
-
export * from './augments/object/map-object';
|
|
23
|
-
export * from './augments/object/merge-deep';
|
|
24
|
-
export * from './augments/object/merge-property-arrays';
|
|
25
|
-
export * from './augments/object/object';
|
|
26
|
-
export * from './augments/object/object-entries';
|
|
27
|
-
export * from './augments/object/pick-deep';
|
|
28
|
-
export * from './augments/object/selection-set';
|
|
29
|
-
export * from './augments/object/typed-has-property';
|
|
30
|
-
export * from './augments/promise/deferred-promise';
|
|
31
|
-
export * from './augments/promise/promise';
|
|
32
|
-
export * from './augments/promise/wait';
|
|
33
|
-
export * from './augments/random';
|
|
34
|
-
export * from './augments/regexp';
|
|
35
|
-
export * from './augments/string/prefixes';
|
|
36
|
-
export * from './augments/string/suffixes';
|
|
37
|
-
export * from './augments/string/uuid';
|
|
38
|
-
export * from './augments/time';
|
|
39
|
-
export * from './augments/truncate-number';
|
|
40
|
-
export * from './augments/tuple';
|
|
41
|
-
export * from './augments/type';
|
|
42
|
-
export * from './augments/type-recursion';
|
|
43
|
-
export * from './augments/union';
|
|
44
|
-
export * from './augments/wrap-in-try';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|