@augment-vir/common 29.3.0 → 30.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-CC0 +121 -0
- package/LICENSE-MIT +21 -0
- package/README.md +7 -3
- package/dist/augments/array/array-map.d.ts +34 -0
- package/dist/augments/array/array-map.js +32 -0
- package/dist/augments/array/array-to-object.d.ts +53 -0
- package/dist/augments/array/array-to-object.js +67 -0
- package/dist/augments/array/awaited/awaited-filter.d.ts +36 -0
- package/dist/augments/array/awaited/awaited-filter.js +36 -0
- package/dist/augments/array/awaited/awaited-for-each.d.ts +31 -0
- package/dist/augments/array/awaited/awaited-for-each.js +34 -0
- package/dist/augments/array/awaited/awaited-map.d.ts +33 -0
- package/dist/augments/array/awaited/awaited-map.js +40 -0
- package/dist/augments/array/filter.d.ts +32 -0
- package/dist/augments/array/filter.js +74 -0
- package/dist/augments/array/remove-duplicates.d.ts +60 -0
- package/dist/augments/array/remove-duplicates.js +72 -0
- package/dist/augments/array/repeat-array.d.ts +23 -0
- package/dist/augments/array/repeat-array.js +25 -0
- package/dist/augments/array/shuffle-array.d.ts +9 -0
- package/dist/augments/array/shuffle-array.js +17 -0
- package/dist/augments/array/string-array.d.ts +9 -0
- package/dist/augments/array/string-array.js +11 -0
- 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 +32 -0
- package/dist/augments/enum/enum-value-check.js +34 -0
- package/dist/augments/error/combine-errors.d.ts +24 -0
- package/dist/augments/error/combine-errors.js +34 -0
- package/dist/augments/function/call-asynchronously.d.ts +25 -0
- package/dist/augments/function/call-asynchronously.js +26 -0
- package/dist/augments/function/call-with-retries.d.ts +24 -0
- package/dist/augments/function/call-with-retries.js +50 -0
- package/dist/augments/function/debounce.d.ts +89 -0
- package/dist/augments/function/debounce.js +112 -0
- package/dist/augments/function/execution-duration.d.ts +20 -0
- package/dist/augments/function/execution-duration.js +39 -0
- package/dist/augments/function/if-truthy.d.ts +28 -0
- package/dist/augments/function/if-truthy.js +35 -0
- package/dist/{types/augments → augments/function}/wrap-in-try.d.ts +14 -7
- package/dist/augments/function/wrap-in-try.js +98 -0
- package/dist/augments/json/append-json.d.ts +5 -0
- package/dist/augments/json/append-json.js +59 -0
- package/dist/augments/json/copy-through-json.d.ts +34 -0
- package/dist/augments/json/copy-through-json.js +42 -0
- package/dist/augments/json/json-compatible.d.ts +50 -0
- package/dist/augments/json/jsonify.d.ts +31 -0
- package/dist/augments/json/jsonify.js +33 -0
- package/dist/augments/log/log-colors.d.ts +64 -0
- package/dist/augments/log/log-colors.js +157 -0
- package/dist/augments/log/log-string.d.ts +35 -0
- package/dist/augments/log/log-string.js +73 -0
- package/dist/augments/log/log-writer.d.ts +30 -0
- package/dist/augments/log/log.d.ts +56 -0
- package/dist/augments/log/log.js +85 -0
- package/dist/augments/log/logger.d.ts +60 -0
- package/dist/augments/log/logger.js +59 -0
- package/dist/augments/number/clamp.d.ts +18 -0
- package/dist/augments/number/clamp.js +19 -0
- package/dist/augments/number/coords.d.ts +23 -0
- package/dist/augments/number/digit.d.ts +8 -0
- package/dist/augments/number/dimensions.d.ts +23 -0
- package/dist/augments/number/min-max.d.ts +18 -0
- package/dist/augments/number/min-max.js +16 -0
- package/dist/augments/number/number-conversion.d.ts +29 -0
- package/dist/augments/number/number-conversion.js +56 -0
- package/dist/augments/number/round.d.ts +22 -0
- package/dist/augments/number/round.js +24 -0
- package/dist/augments/number/scientific.d.ts +18 -0
- package/dist/augments/number/scientific.js +20 -0
- package/dist/augments/number/truncate-number.d.ts +40 -0
- package/dist/{esm/augments → augments/number}/truncate-number.js +39 -17
- package/dist/augments/number/wrap-number.d.ts +19 -0
- package/dist/augments/number/wrap-number.js +28 -0
- package/dist/augments/object/diff.d.ts +51 -0
- package/dist/augments/object/diff.js +149 -0
- package/dist/augments/object/empty.d.ts +9 -0
- package/dist/augments/object/get-or-set.d.ts +10 -0
- package/dist/augments/object/get-or-set.js +100 -0
- package/dist/augments/object/key-count.d.ts +21 -0
- package/dist/augments/object/map-entries.d.ts +13 -0
- package/dist/augments/object/map-entries.js +80 -0
- package/dist/augments/object/map-enum.d.ts +11 -0
- package/dist/augments/object/map-enum.js +45 -0
- package/dist/augments/object/map-values.d.ts +35 -0
- package/dist/augments/object/map-values.js +65 -0
- package/dist/{types/augments → augments}/object/merge-deep.d.ts +4 -0
- package/dist/{esm/augments → augments}/object/merge-deep.js +9 -6
- package/dist/augments/object/merge-defined-properties.d.ts +19 -0
- package/dist/augments/object/merge-defined-properties.js +32 -0
- package/dist/augments/object/merge-property-arrays.d.ts +29 -0
- package/dist/augments/object/merge-property-arrays.js +39 -0
- package/dist/augments/object/object-entries.d.ts +31 -0
- package/dist/augments/object/object-entries.js +40 -0
- package/dist/augments/object/object-filter.d.ts +22 -0
- package/dist/augments/object/object-filter.js +27 -0
- package/dist/augments/object/object-keys.d.ts +34 -0
- package/dist/augments/object/object-keys.js +43 -0
- package/dist/augments/object/object-values.d.ts +11 -0
- package/dist/augments/object/object-values.js +13 -0
- package/dist/augments/path/esm-path.d.ts +26 -0
- package/dist/augments/path/esm-path.js +31 -0
- package/dist/augments/prisma/prisma-models.d.ts +143 -0
- package/dist/augments/prisma/prisma-models.js +1 -0
- package/dist/augments/promise/timed-promise.d.ts +22 -0
- package/dist/augments/promise/timed-promise.js +51 -0
- package/dist/augments/random/random-boolean.d.ts +24 -0
- package/dist/augments/random/random-boolean.js +32 -0
- package/dist/augments/random/random-integer.d.ts +14 -0
- package/dist/augments/random/random-integer.js +34 -0
- package/dist/augments/random/random-string.d.ts +18 -0
- package/dist/augments/random/random-string.js +67 -0
- 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 -0
- package/dist/augments/regexp/regexp-flags.js +75 -0
- package/dist/augments/regexp/regexp-string.d.ts +9 -0
- package/dist/augments/regexp/regexp-string.js +11 -0
- package/dist/augments/selection-set/select-collapsed.d.ts +54 -0
- package/dist/augments/selection-set/select-collapsed.js +63 -0
- package/dist/augments/selection-set/select-from.d.ts +48 -0
- package/dist/augments/selection-set/select-from.js +72 -0
- package/dist/augments/selection-set/selection-set.d.ts +37 -0
- package/dist/augments/selection-set/selection-set.js +1 -0
- package/dist/augments/string/casing/capitalization.d.ts +17 -0
- package/dist/augments/string/casing/capitalization.js +25 -0
- package/dist/augments/string/casing/casing.d.ts +73 -0
- package/dist/augments/string/casing/casing.js +65 -0
- package/dist/augments/string/casing/kebab-and-camel.d.ts +17 -0
- package/dist/augments/string/casing/kebab-and-camel.js +57 -0
- package/dist/augments/string/comma.d.ts +26 -0
- package/dist/augments/string/comma.js +48 -0
- package/dist/augments/string/join.d.ts +21 -0
- package/dist/augments/string/join.js +34 -0
- package/dist/augments/string/prefix.d.ts +30 -0
- package/dist/augments/string/prefix.js +30 -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 +18 -0
- package/dist/augments/string/replace.js +22 -0
- package/dist/augments/string/split.d.ts +31 -0
- package/dist/augments/string/split.js +53 -0
- package/dist/augments/string/substring-index.d.ts +19 -0
- package/dist/augments/string/substring-index.js +47 -0
- package/dist/augments/string/suffix.d.ts +96 -0
- package/dist/augments/string/suffix.js +89 -0
- package/dist/augments/string/white-space.d.ts +12 -0
- package/dist/augments/string/white-space.js +19 -0
- package/dist/augments/string/wrap-string.d.ts +19 -0
- package/dist/augments/string/wrap-string.js +20 -0
- package/dist/augments/type/ensure-type.d.ts +12 -0
- package/dist/augments/type/ensure-type.js +14 -0
- package/dist/augments/type/readonly.d.ts +9 -0
- package/dist/augments/type/readonly.js +10 -0
- package/dist/augments/type/type-recursion.d.ts +253 -0
- package/dist/augments/type/type-recursion.js +1 -0
- 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 +9 -0
- package/dist/augments/type/void-type.js +1 -0
- package/dist/augments/type/writable.d.ts +10 -0
- package/dist/augments/type/writable.js +10 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +83 -0
- package/package.json +43 -15
- 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 -118
- 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 -13
- 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/array/remove-duplicates.js +0 -13
- package/dist/esm/augments/async.js +0 -23
- package/dist/esm/augments/boolean.js +0 -14
- 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/esm-path.js +0 -8
- 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/get-or-set.js +0 -36
- package/dist/esm/augments/object/has-key.js +0 -3
- package/dist/esm/augments/object/jsonify.js +0 -3
- package/dist/esm/augments/object/map-object.js +0 -57
- package/dist/esm/augments/object/merge-property-arrays.js +0 -11
- 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 -113
- package/dist/esm/augments/regexp.js +0 -14
- package/dist/esm/augments/string/prefixes.js +0 -16
- package/dist/esm/augments/string/suffixes.js +0 -31
- package/dist/esm/augments/string/uuid.js +0 -9
- package/dist/esm/augments/time.js +0 -31
- package/dist/esm/augments/tuple.js +0 -16
- package/dist/esm/augments/type.js +0 -30
- package/dist/esm/augments/wrap-in-try.js +0 -34
- 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/array/remove-duplicates.d.ts +0 -1
- 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/esm-path.d.ts +0 -4
- package/dist/types/augments/function.d.ts +0 -25
- package/dist/types/augments/json-compatible.d.ts +0 -22
- 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/key-count.d.ts +0 -13
- package/dist/types/augments/object/map-object.d.ts +0 -20
- package/dist/types/augments/object/merge-property-arrays.d.ts +0 -1
- 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 -37
- package/dist/types/augments/regexp.d.ts +0 -3
- package/dist/types/augments/string/prefixes.d.ts +0 -9
- package/dist/types/augments/string/suffixes.d.ts +0 -17
- package/dist/types/augments/string/uuid.d.ts +0 -5
- package/dist/types/augments/time.d.ts +0 -14
- package/dist/types/augments/truncate-number.d.ts +0 -19
- package/dist/types/augments/tuple.d.ts +0 -17
- package/dist/types/augments/type-recursion.d.ts +0 -161
- 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/{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/{esm/augments/type-recursion.js → augments/object/empty.js} +0 -0
- /package/dist/{esm/augments/union.js → augments/object/key-count.js} +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,22 +0,0 @@
|
|
|
1
|
-
import { Jsonify, Primitive } from 'type-fest';
|
|
2
|
-
/**
|
|
3
|
-
* These are similar in purpose, name, and structure to type-fest's JsonValue types but these are
|
|
4
|
-
* permissive. The goal here is to allow any types that do not get serialized into just empty
|
|
5
|
-
* objects. (For example, JSON.stringify(new Map()) returns "{}", so we don't want to allow that
|
|
6
|
-
* type.)
|
|
7
|
-
*/
|
|
8
|
-
export type JsonCompatiblePrimitiveValue = Jsonify<Primitive> | undefined;
|
|
9
|
-
export type JsonCompatibleObject = Partial<{
|
|
10
|
-
readonly [key: string | number]: JsonCompatibleValue | Readonly<JsonCompatibleValue>;
|
|
11
|
-
}> | Partial<{
|
|
12
|
-
[key: string | number]: JsonCompatibleValue | Readonly<JsonCompatibleValue>;
|
|
13
|
-
}>;
|
|
14
|
-
export type JsonCompatibleArray = JsonCompatibleValue[]
|
|
15
|
-
/**
|
|
16
|
-
* This weird readonly with object syntax for an array type is so that TypeScript doesn't
|
|
17
|
-
* complain about JsonCompatibleArray circularly referencing itself
|
|
18
|
-
*/
|
|
19
|
-
| ({
|
|
20
|
-
readonly [P in number]: JsonCompatibleValue;
|
|
21
|
-
} & ReadonlyArray<any>);
|
|
22
|
-
export type JsonCompatibleValue = JsonCompatiblePrimitiveValue | JsonCompatibleObject | JsonCompatibleArray;
|
|
@@ -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,13 +0,0 @@
|
|
|
1
|
-
import { UnionToIntersection } from '../union';
|
|
2
|
-
import { AnyObject } from './any-object';
|
|
3
|
-
/**
|
|
4
|
-
* This is not exported because its order is not stable but it's okay for our simple use case where
|
|
5
|
-
* we simply want to count the size of the union.
|
|
6
|
-
*/
|
|
7
|
-
type UnionToTuple<T> = UnionToIntersection<T extends any ? (t: T) => T : never> extends (args: any) => infer W ? [...UnionToTuple<Exclude<T, W>>, W] : [];
|
|
8
|
-
/**
|
|
9
|
-
* Counts the number of unique keys in an object type. Note that a key of just `string` will count
|
|
10
|
-
* as 1.
|
|
11
|
-
*/
|
|
12
|
-
export type KeyCount<T extends AnyObject> = UnionToTuple<keyof T>['length'];
|
|
13
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { PropertyValueType } from './object';
|
|
2
|
-
export type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {
|
|
3
|
-
[MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;
|
|
4
|
-
};
|
|
5
|
-
export type MappedValues<EntireInputGeneric extends object, MappedValueGeneric> = MappedValueGeneric extends PromiseLike<unknown> ? Promise<InnerMappedValues<EntireInputGeneric, Awaited<MappedValueGeneric>>> : InnerMappedValues<EntireInputGeneric, Awaited<MappedValueGeneric>>;
|
|
6
|
-
/**
|
|
7
|
-
* Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
|
|
8
|
-
* that this will not wrap the return value in a promise if any of the new object values are
|
|
9
|
-
* promises. This function also requires currying in order to get the types correct. This allows you
|
|
10
|
-
* to explicitly state the return type.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* mapObjectValuesSync({objectToIterateOver: 'initial value'})(callback);
|
|
14
|
-
*/
|
|
15
|
-
export declare function mapObjectValuesSync<EntireInputGeneric extends object>(inputObject: EntireInputGeneric): <OutputObjectGeneric extends object>(mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: Required<EntireInputGeneric>[typeof inputKey], fullObject: EntireInputGeneric) => never extends PropertyValueType<OutputObjectGeneric> ? any : PropertyValueType<OutputObjectGeneric>) => OutputObjectGeneric;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new object with the same properties as the input object, but with values set to the
|
|
18
|
-
* result of mapCallback for each property.
|
|
19
|
-
*/
|
|
20
|
-
export declare function mapObjectValues<EntireInputGeneric extends object, MappedValueGeneric>(inputObject: EntireInputGeneric, mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: Required<EntireInputGeneric>[typeof inputKey], fullObject: EntireInputGeneric) => MappedValueGeneric): MappedValues<EntireInputGeneric, MappedValueGeneric>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function mergePropertyArrays<T extends Record<PropertyKey, unknown[]>>(...inputs: ReadonlyArray<Readonly<T>>): T;
|
|
@@ -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,37 +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
|
-
/**
|
|
33
|
-
* Creates a random string (including letters and numbers) of a given length.
|
|
34
|
-
*
|
|
35
|
-
* This function uses cryptographically secure randomness.
|
|
36
|
-
*/
|
|
37
|
-
export declare function randomString(inputLength?: number): string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type WithPrefix<Prefix extends string> = `${Prefix}${string}`;
|
|
2
|
-
export declare function addPrefix<const Prefix extends string>({ value, prefix, }: {
|
|
3
|
-
value: unknown;
|
|
4
|
-
prefix: Prefix;
|
|
5
|
-
}): WithPrefix<Prefix>;
|
|
6
|
-
export declare function removePrefix<const Prefix extends string>({ value, prefix, }: {
|
|
7
|
-
value: WithPrefix<Prefix> | string;
|
|
8
|
-
prefix: Prefix;
|
|
9
|
-
}): 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,5 +0,0 @@
|
|
|
1
|
-
export type UuidV4 = ReturnType<typeof createUuid>;
|
|
2
|
-
/** Checks if the input string is a valid v4 UUID. */
|
|
3
|
-
export declare function isUuid(maybeUuid: string): boolean;
|
|
4
|
-
/** Creates a cryptographically secure v4 UUID using `crypto.randomUUID`. */
|
|
5
|
-
export declare function createUuid(): `${string}-${string}-${string}-${string}-${string}`;
|
|
@@ -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,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This truncates a number such that is will at a max have 6 characters including suffix, decimal
|
|
3
|
-
* point, or comma.
|
|
4
|
-
*
|
|
5
|
-
* Default suffixes are:
|
|
6
|
-
*
|
|
7
|
-
* 'k', // thousand
|
|
8
|
-
* 'M', // million
|
|
9
|
-
* 'B', // billion
|
|
10
|
-
* 'T', // trillion
|
|
11
|
-
* 'P', // peta-, quadrillion
|
|
12
|
-
* 'E', // exa- quintillion
|
|
13
|
-
* 'Z', // zetta- sextillion
|
|
14
|
-
* 'Y', // yotta- septillion
|
|
15
|
-
*/
|
|
16
|
-
export declare function truncateNumber(originalValue: Readonly<unknown>, { customSuffixes, maxLength, }?: Partial<{
|
|
17
|
-
customSuffixes: ReadonlyArray<string> | undefined;
|
|
18
|
-
maxLength: number | undefined;
|
|
19
|
-
}>): string;
|
|
@@ -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 {};
|