@dereekb/util 13.11.14 → 13.11.15
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/eslint/index.cjs.js +10008 -394
- package/eslint/index.esm.js +9982 -392
- package/eslint/package.json +4 -4
- package/eslint/src/lib/comments.d.ts +14 -3
- package/eslint/src/lib/dbx-tag-families.d.ts +280 -0
- package/eslint/src/lib/index.d.ts +26 -3
- package/eslint/src/lib/jsdoc-parser.d.ts +116 -0
- package/eslint/src/lib/no-inline-string-empty-object-intersection.rule.d.ts +44 -0
- package/eslint/src/lib/no-inline-type-import.rule.d.ts +38 -0
- package/eslint/src/lib/no-sister-re-export.rule.d.ts +69 -0
- package/eslint/src/lib/plugin.d.ts +52 -1
- package/eslint/src/lib/prefer-canonical-jsdoc.rule.d.ts +68 -0
- package/eslint/src/lib/prefer-config-object.rule.d.ts +61 -0
- package/eslint/src/lib/prefer-maybe-type.rule.d.ts +72 -0
- package/eslint/src/lib/prefer-no-side-effects-in-jsdoc.rule.d.ts +1 -1
- package/eslint/src/lib/prefer-suggested-string.rule.d.ts +51 -0
- package/eslint/src/lib/require-constant-naming.rule.d.ts +63 -0
- package/eslint/src/lib/require-dbx-action-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-auth-companion-tags.rule.d.ts +45 -0
- package/eslint/src/lib/require-dbx-docs-ui-example-companion-tags.rule.d.ts +42 -0
- package/eslint/src/lib/require-dbx-filter-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-dbx-form-field-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-model-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-model-firebase-index-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-model-snapshot-field-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-pipe-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-dbx-rule-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-util-companion-tags.rule.d.ts +74 -0
- package/eslint/src/lib/require-dbx-web-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-default-prefix-naming.rule.d.ts +60 -0
- package/eslint/src/lib/require-deprecated-alias-placement.rule.d.ts +75 -0
- package/eslint/src/lib/require-exported-jsdoc-example.rule.d.ts +61 -0
- package/eslint/src/lib/require-no-side-effects.rule.d.ts +1 -1
- package/eslint/src/lib/require-readonly-config-params.rule.d.ts +57 -0
- package/eslint/src/lib/require-single-return.rule.d.ts +42 -0
- package/fetch/index.cjs.js +95 -80
- package/fetch/index.esm.js +95 -80
- package/fetch/package.json +2 -2
- package/fetch/src/lib/error.d.ts +2 -2
- package/fetch/src/lib/fetch.d.ts +15 -15
- package/fetch/src/lib/fetch.file.d.ts +5 -5
- package/fetch/src/lib/fetch.limit.d.ts +2 -2
- package/fetch/src/lib/fetch.page.d.ts +1 -1
- package/fetch/src/lib/fetch.page.iterate.d.ts +4 -4
- package/fetch/src/lib/fetch.type.d.ts +3 -2
- package/fetch/src/lib/fetch.url.d.ts +13 -13
- package/fetch/src/lib/json.d.ts +12 -12
- package/fetch/src/lib/timeout.d.ts +2 -2
- package/fetch/src/lib/url.d.ts +11 -11
- package/index.cjs.js +2592 -2329
- package/index.esm.js +2590 -2327
- package/package.json +1 -1
- package/src/lib/array/array.boolean.d.ts +20 -20
- package/src/lib/array/array.d.ts +73 -72
- package/src/lib/array/array.factory.d.ts +8 -5
- package/src/lib/array/array.filter.d.ts +23 -20
- package/src/lib/array/array.find.d.ts +9 -8
- package/src/lib/array/array.index.d.ts +15 -14
- package/src/lib/array/array.indexed.d.ts +22 -19
- package/src/lib/array/array.make.d.ts +3 -2
- package/src/lib/array/array.map.d.ts +5 -5
- package/src/lib/array/array.number.d.ts +27 -27
- package/src/lib/array/array.random.d.ts +11 -10
- package/src/lib/array/array.set.d.ts +14 -14
- package/src/lib/array/array.string.d.ts +31 -31
- package/src/lib/array/array.unique.d.ts +22 -20
- package/src/lib/array/array.value.d.ts +3 -2
- package/src/lib/assertion/assert.error.d.ts +8 -8
- package/src/lib/assertion/assertion.d.ts +5 -5
- package/src/lib/assertion/assertion.generic.d.ts +3 -3
- package/src/lib/assertion/assertion.number.d.ts +6 -6
- package/src/lib/auth/auth.role.claims.d.ts +12 -11
- package/src/lib/auth/auth.role.d.ts +3 -3
- package/src/lib/auth/pkce.d.ts +2 -2
- package/src/lib/boolean.d.ts +11 -11
- package/src/lib/cache/cache.memoize.d.ts +6 -6
- package/src/lib/contact/domain.d.ts +9 -9
- package/src/lib/contact/email.d.ts +11 -11
- package/src/lib/contact/phone.d.ts +12 -12
- package/src/lib/contact/random.d.ts +11 -9
- package/src/lib/date/date.d.ts +60 -59
- package/src/lib/date/date.time.d.ts +2 -2
- package/src/lib/date/date.unix.d.ts +8 -8
- package/src/lib/date/duration.d.ts +17 -17
- package/src/lib/date/expires.d.ts +29 -27
- package/src/lib/date/hour.d.ts +23 -23
- package/src/lib/date/minute.d.ts +6 -6
- package/src/lib/date/time.d.ts +10 -9
- package/src/lib/date/week.d.ts +32 -31
- package/src/lib/encryption/encryption.object.d.ts +3 -3
- package/src/lib/error/error.d.ts +13 -12
- package/src/lib/error/error.server.d.ts +4 -4
- package/src/lib/file/pdf.d.ts +4 -4
- package/src/lib/filter/filter.d.ts +3 -2
- package/src/lib/function/function.boolean.d.ts +4 -3
- package/src/lib/function/function.forward.d.ts +6 -4
- package/src/lib/getter/getter.d.ts +24 -19
- package/src/lib/getter/getter.map.d.ts +6 -5
- package/src/lib/getter/getter.util.d.ts +3 -2
- package/src/lib/grouping.d.ts +25 -24
- package/src/lib/hash.d.ts +11 -10
- package/src/lib/iterable/iterable.d.ts +39 -39
- package/src/lib/iterable/iterable.map.d.ts +3 -3
- package/src/lib/key.d.ts +16 -16
- package/src/lib/map/map.d.ts +12 -12
- package/src/lib/map/map.intersection.d.ts +3 -3
- package/src/lib/map/map.key.d.ts +16 -14
- package/src/lib/misc/host.d.ts +2 -2
- package/src/lib/model/id.batch.d.ts +4 -3
- package/src/lib/model/id.factory.d.ts +4 -3
- package/src/lib/model/model.conversion.d.ts +19 -14
- package/src/lib/model/model.conversion.field.d.ts +2 -2
- package/src/lib/model/model.copy.d.ts +5 -4
- package/src/lib/model/model.d.ts +48 -46
- package/src/lib/model/model.modify.d.ts +10 -8
- package/src/lib/nodejs/stream.d.ts +6 -5
- package/src/lib/number/bitwise.dencoder.d.ts +12 -12
- package/src/lib/number/bound.d.ts +16 -13
- package/src/lib/number/dollar.d.ts +6 -5
- package/src/lib/number/encoded.d.ts +7 -7
- package/src/lib/number/factory.d.ts +4 -3
- package/src/lib/number/number.d.ts +37 -37
- package/src/lib/number/random.d.ts +11 -10
- package/src/lib/number/round.d.ts +34 -30
- package/src/lib/number/sort.d.ts +3 -2
- package/src/lib/number/transform.d.ts +5 -4
- package/src/lib/object/object.array.d.ts +6 -6
- package/src/lib/object/object.array.delta.d.ts +3 -2
- package/src/lib/object/object.d.ts +12 -12
- package/src/lib/object/object.empty.d.ts +3 -3
- package/src/lib/object/object.equal.d.ts +11 -10
- package/src/lib/object/object.filter.pojo.d.ts +74 -74
- package/src/lib/object/object.filter.tuple.d.ts +26 -26
- package/src/lib/object/object.flatten.d.ts +4 -4
- package/src/lib/object/object.key.d.ts +6 -4
- package/src/lib/object/object.map.d.ts +15 -13
- package/src/lib/page/page.d.ts +5 -5
- package/src/lib/page/page.filter.d.ts +8 -8
- package/src/lib/path/path.d.ts +98 -88
- package/src/lib/promise/callback.d.ts +2 -2
- package/src/lib/promise/is.d.ts +6 -6
- package/src/lib/promise/poll.d.ts +9 -9
- package/src/lib/promise/promise.d.ts +33 -30
- package/src/lib/promise/promise.factory.d.ts +4 -3
- package/src/lib/promise/promise.loop.d.ts +11 -11
- package/src/lib/promise/promise.task.d.ts +6 -5
- package/src/lib/promise/promise.type.d.ts +3 -3
- package/src/lib/promise/use.d.ts +3 -3
- package/src/lib/relation/relation.d.ts +15 -15
- package/src/lib/service/handler.config.d.ts +20 -16
- package/src/lib/service/handler.d.ts +3 -2
- package/src/lib/service/typed.service.d.ts +2 -2
- package/src/lib/set/set.d.ts +62 -59
- package/src/lib/set/set.delta.d.ts +5 -4
- package/src/lib/set/set.hashset.d.ts +5 -5
- package/src/lib/set/set.selection.d.ts +5 -4
- package/src/lib/sort.d.ts +11 -11
- package/src/lib/storage/storage.d.ts +2 -1
- package/src/lib/storage/storage.error.d.ts +4 -4
- package/src/lib/storage/storage.memory.d.ts +7 -7
- package/src/lib/storage/storage.object.d.ts +5 -5
- package/src/lib/string/case.d.ts +6 -6
- package/src/lib/string/char.d.ts +30 -29
- package/src/lib/string/dencoder.d.ts +25 -20
- package/src/lib/string/factory.d.ts +11 -8
- package/src/lib/string/html.d.ts +19 -19
- package/src/lib/string/mimetype.d.ts +9 -8
- package/src/lib/string/prefix.d.ts +8 -8
- package/src/lib/string/replace.d.ts +45 -39
- package/src/lib/string/search.d.ts +5 -4
- package/src/lib/string/sort.d.ts +13 -4
- package/src/lib/string/string.d.ts +44 -43
- package/src/lib/string/transform.d.ts +32 -23
- package/src/lib/string/tree.d.ts +5 -4
- package/src/lib/string/url.d.ts +5 -4
- package/src/lib/tree/tree.array.d.ts +5 -4
- package/src/lib/tree/tree.expand.d.ts +6 -6
- package/src/lib/tree/tree.explore.d.ts +13 -10
- package/src/lib/tree/tree.flatten.d.ts +10 -10
- package/src/lib/type.d.ts +42 -12
- package/src/lib/value/address.d.ts +7 -7
- package/src/lib/value/bound.d.ts +70 -66
- package/src/lib/value/build.d.ts +6 -6
- package/src/lib/value/comparator.d.ts +19 -17
- package/src/lib/value/cron.d.ts +2 -2
- package/src/lib/value/decision.d.ts +6 -5
- package/src/lib/value/equal.d.ts +11 -9
- package/src/lib/value/indexed.d.ts +101 -85
- package/src/lib/value/label.d.ts +2 -2
- package/src/lib/value/map.d.ts +20 -16
- package/src/lib/value/maybe.d.ts +36 -36
- package/src/lib/value/modifier.d.ts +24 -23
- package/src/lib/value/point.d.ts +85 -77
- package/src/lib/value/url.d.ts +2 -2
- package/src/lib/value/use.d.ts +36 -33
- package/src/lib/value/vector.d.ts +15 -14
- package/test/index.cjs.js +41 -36
- package/test/index.esm.js +41 -36
- package/test/package.json +2 -2
- package/test/src/lib/jest/jest.fail.d.ts +2 -2
- package/test/src/lib/shared/shared.d.ts +20 -20
- package/test/src/lib/shared/shared.fail.d.ts +21 -16
- package/test/src/lib/shared/shared.function.d.ts +4 -4
- package/test/src/lib/shared/shared.wrap.d.ts +10 -10
|
@@ -30,8 +30,8 @@ export type BitwiseSetEncoder<D extends BitwiseEncodedSetIndex> = (set: Set<D>)
|
|
|
30
30
|
/**
|
|
31
31
|
* Encodes a Set of bit indices into a single {@link BitwiseEncodedSet} number using bitwise OR.
|
|
32
32
|
*
|
|
33
|
-
* @param input - Set of indices (0-31) to encode
|
|
34
|
-
* @returns
|
|
33
|
+
* @param input - Set of indices (0-31) to encode.
|
|
34
|
+
* @returns Encoded value with each requested bit position set high.
|
|
35
35
|
*/
|
|
36
36
|
export declare function encodeBitwiseSet<D extends BitwiseEncodedSetIndex>(input: Set<D>): BitwiseEncodedSet;
|
|
37
37
|
/**
|
|
@@ -41,8 +41,8 @@ export type BitwiseSetDecoder<D extends BitwiseEncodedSetIndex> = (set: BitwiseE
|
|
|
41
41
|
/**
|
|
42
42
|
* Creates a decoder that converts a {@link BitwiseEncodedSet} number back into a Set of indices by checking each bit position up to `maxIndex`.
|
|
43
43
|
*
|
|
44
|
-
* @param maxIndex - The exclusive upper bound of indices to check
|
|
45
|
-
* @returns
|
|
44
|
+
* @param maxIndex - The exclusive upper bound of indices to check.
|
|
45
|
+
* @returns Reusable decoder that materializes the set of high-bit indices below `maxIndex`.
|
|
46
46
|
*/
|
|
47
47
|
export declare function bitwiseSetDecoder<D extends BitwiseEncodedSetIndex>(maxIndex: number): BitwiseSetDecoder<D>;
|
|
48
48
|
/**
|
|
@@ -58,8 +58,8 @@ export type BitwiseSetDencoder<D extends BitwiseEncodedSetIndex> = BitwiseSetEnc
|
|
|
58
58
|
*
|
|
59
59
|
* Accepts either a Set (encodes to number) or a number (decodes to Set).
|
|
60
60
|
*
|
|
61
|
-
* @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32
|
|
62
|
-
* @returns
|
|
61
|
+
* @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32.
|
|
62
|
+
* @returns Encodes Sets to numbers and decodes numbers to Sets.
|
|
63
63
|
*/
|
|
64
64
|
export declare function bitwiseSetDencoder<D extends BitwiseEncodedSetIndex>(maxIndex?: number): BitwiseSetDencoder<D>;
|
|
65
65
|
/**
|
|
@@ -79,8 +79,8 @@ export type BitwiseObjectEncoder<T extends object> = (object: T) => BitwiseEncod
|
|
|
79
79
|
*
|
|
80
80
|
* Uses the provided `toSetFunction` to first map the object to a Set of indices, then encodes it.
|
|
81
81
|
*
|
|
82
|
-
* @param toSetFunction - Function that maps an object to a Set of bit indices
|
|
83
|
-
* @returns An encoder function that produces a bitwise-encoded number from the object
|
|
82
|
+
* @param toSetFunction - Function that maps an object to a Set of bit indices.
|
|
83
|
+
* @returns An encoder function that produces a bitwise-encoded number from the object.
|
|
84
84
|
*/
|
|
85
85
|
export declare function bitwiseObjectEncoder<T extends object, D extends BitwiseEncodedSetIndex>(toSetFunction: BitwiseObjectToSetFunction<T, D>): BitwiseObjectEncoder<T>;
|
|
86
86
|
/**
|
|
@@ -90,9 +90,9 @@ export type BitwiseObjectDecoder<T extends object> = (set: BitwiseEncodedSet) =>
|
|
|
90
90
|
/**
|
|
91
91
|
* Creates a {@link BitwiseObjectDecoder} that converts a {@link BitwiseEncodedSet} number back into an object.
|
|
92
92
|
*
|
|
93
|
-
* @param fromSetFunction - Function that maps a Set of bit indices back to an object
|
|
94
|
-
* @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32
|
|
95
|
-
* @returns A decoder function that produces an object from a bitwise-encoded number
|
|
93
|
+
* @param fromSetFunction - Function that maps a Set of bit indices back to an object.
|
|
94
|
+
* @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32.
|
|
95
|
+
* @returns A decoder function that produces an object from a bitwise-encoded number.
|
|
96
96
|
*/
|
|
97
97
|
export declare function bitwiseObjectdecoder<T extends object, D extends BitwiseEncodedSetIndex>(fromSetFunction: BitwiseObjectFromSetFunction<T, D>, maxIndex?: number): BitwiseObjectDecoder<T>;
|
|
98
98
|
/**
|
|
@@ -113,6 +113,6 @@ export interface BitwiseObjectDencoderConfig<T extends object, D extends Bitwise
|
|
|
113
113
|
* Accepts either a number (decodes to object) or an object (encodes to number). Returns 0 for null/undefined input.
|
|
114
114
|
*
|
|
115
115
|
* @param config - Configuration with `toSetFunction`, `fromSetFunction`, and optional `maxIndex`
|
|
116
|
-
* @returns
|
|
116
|
+
* @returns Encodes objects to numbers and decodes numbers to objects.
|
|
117
117
|
*/
|
|
118
118
|
export declare function bitwiseObjectDencoder<T extends object, D extends BitwiseEncodedSetIndex = BitwiseEncodedSetIndex>(config: BitwiseObjectDencoderConfig<T, D>): BitwiseObjectDencoder<T>;
|
|
@@ -12,7 +12,7 @@ export interface NumberBound<T extends number = number> {
|
|
|
12
12
|
/**
|
|
13
13
|
* Checks whether a {@link NumberBound} is valid (min is less than or equal to max).
|
|
14
14
|
*
|
|
15
|
-
* @param bounds - The bounds to validate
|
|
15
|
+
* @param bounds - The bounds to validate.
|
|
16
16
|
* @returns `true` if `min <= max`
|
|
17
17
|
*/
|
|
18
18
|
export declare function isValidNumberBound(bounds: NumberBound): boolean;
|
|
@@ -20,15 +20,16 @@ export type IsInNumberBoundFunction = (number: number) => boolean;
|
|
|
20
20
|
/**
|
|
21
21
|
* Creates a function that checks whether a number falls within the specified inclusive bounds.
|
|
22
22
|
*
|
|
23
|
+
* @param bounds - The min/max bounds to test against.
|
|
24
|
+
* @returns Returns `true` if the input number is within bounds.
|
|
25
|
+
* @throws {Error} If the bounds are invalid (min > max)
|
|
26
|
+
*
|
|
23
27
|
* @dbxUtil
|
|
24
28
|
* @dbxUtilCategory number
|
|
25
29
|
* @dbxUtilKind factory
|
|
26
30
|
* @dbxUtilTags number, bound, range, between, check, inclusive, factory
|
|
27
31
|
* @dbxUtilRelated bound-number-function, bound-number, is-valid-number-bound
|
|
28
32
|
*
|
|
29
|
-
* @param bounds - The min/max bounds to test against
|
|
30
|
-
* @returns A function that returns `true` if the input number is within bounds
|
|
31
|
-
* @throws Error if the bounds are invalid (min > max)
|
|
32
33
|
* @__NO_SIDE_EFFECTS__
|
|
33
34
|
*/
|
|
34
35
|
export declare function isInNumberBoundFunction(bounds: NumberBound): IsInNumberBoundFunction;
|
|
@@ -48,14 +49,15 @@ export type WrapNumberFunction<T extends number = number> = MapFunction<number,
|
|
|
48
49
|
*
|
|
49
50
|
* When `fencePosts` is true, wraps to the nearest "fence post" value, extending the wrap range by one in each direction.
|
|
50
51
|
*
|
|
52
|
+
* @param wrapNumberFunctionConfig - Configuration with min, max, and optional fence post behavior.
|
|
53
|
+
* @returns Wraps input numbers into the bounded range.
|
|
54
|
+
*
|
|
51
55
|
* @dbxUtil
|
|
52
56
|
* @dbxUtilCategory number
|
|
53
57
|
* @dbxUtilKind factory
|
|
54
58
|
* @dbxUtilTags number, wrap, modulo, modular, range, factory, circular
|
|
55
59
|
* @dbxUtilRelated bound-number-function, bound-number, is-in-number-bound-function
|
|
56
60
|
*
|
|
57
|
-
* @param wrapNumberFunctionConfig - Configuration with min, max, and optional fence post behavior
|
|
58
|
-
* @returns A function that wraps input numbers into the bounded range
|
|
59
61
|
* @__NO_SIDE_EFFECTS__
|
|
60
62
|
*/
|
|
61
63
|
export declare function wrapNumberFunction<T extends number = number>(wrapNumberFunctionConfig: WrapNumberFunctionConfig<T>): WrapNumberFunction<T>;
|
|
@@ -73,28 +75,29 @@ export type BoundNumberFunction<T extends number = number> = MapFunction<number,
|
|
|
73
75
|
*
|
|
74
76
|
* When `wrap` is true, uses modular wrapping. Otherwise, clamps values to the min/max range.
|
|
75
77
|
*
|
|
78
|
+
* @param boundNumberFunctionConfig - Configuration with min, max, and optional wrap behavior.
|
|
79
|
+
* @returns Bounds input numbers into the configured range.
|
|
80
|
+
*
|
|
76
81
|
* @dbxUtil
|
|
77
82
|
* @dbxUtilCategory number
|
|
78
83
|
* @dbxUtilKind factory
|
|
79
84
|
* @dbxUtilTags number, bound, clamp, wrap, range, factory, constrain
|
|
80
85
|
* @dbxUtilRelated bound-number, wrap-number-function, is-in-number-bound-function
|
|
81
86
|
*
|
|
82
|
-
* @param boundNumberFunctionConfig - Configuration with min, max, and optional wrap behavior
|
|
83
|
-
* @returns A function that bounds input numbers into the configured range
|
|
84
87
|
* @__NO_SIDE_EFFECTS__
|
|
85
88
|
*/
|
|
86
89
|
export declare function boundNumberFunction<T extends number = number>(boundNumberFunctionConfig: BoundNumberFunctionConfig<T>): BoundNumberFunction<T>;
|
|
87
90
|
/**
|
|
88
91
|
* Clamps the input number between the min and max values (inclusive).
|
|
89
92
|
*
|
|
93
|
+
* @param input - Number to clamp.
|
|
94
|
+
* @param min - Minimum allowed value.
|
|
95
|
+
* @param max - Maximum allowed value.
|
|
96
|
+
* @returns The clamped value.
|
|
97
|
+
*
|
|
90
98
|
* @dbxUtil
|
|
91
99
|
* @dbxUtilCategory number
|
|
92
100
|
* @dbxUtilTags number, clamp, bound, min, max, range, constrain
|
|
93
101
|
* @dbxUtilRelated bound-number-function, wrap-number-function, is-in-number-bound-function
|
|
94
|
-
*
|
|
95
|
-
* @param input - Number to clamp
|
|
96
|
-
* @param min - Minimum allowed value
|
|
97
|
-
* @param max - Maximum allowed value
|
|
98
|
-
* @returns The clamped value
|
|
99
102
|
*/
|
|
100
103
|
export declare function boundNumber<T extends number = number>(input: number, min: T, max: T): T;
|
|
@@ -73,8 +73,8 @@ export declare const DOLLAR_AMOUNT_PRECISION = 2;
|
|
|
73
73
|
/**
|
|
74
74
|
* Checks whether the input string matches the expected dollar amount format (e.g., "12.50" or "$12.50").
|
|
75
75
|
*
|
|
76
|
-
* @param value - String to test
|
|
77
|
-
* @returns `true` if the string matches the dollar amount regex
|
|
76
|
+
* @param value - String to test.
|
|
77
|
+
* @returns `true` if the string matches the dollar amount regex.
|
|
78
78
|
*/
|
|
79
79
|
export declare function isDollarAmountString(value: string): boolean;
|
|
80
80
|
/**
|
|
@@ -82,7 +82,7 @@ export declare function isDollarAmountString(value: string): boolean;
|
|
|
82
82
|
*
|
|
83
83
|
* Truncates (does not round) excess precision: e.g., 1.115 becomes "1.11". Returns "0.00" for null/undefined.
|
|
84
84
|
*
|
|
85
|
-
* @param number - The dollar amount to format
|
|
85
|
+
* @param number - The dollar amount to format.
|
|
86
86
|
* @returns Formatted string with two decimal places (e.g., "12.50")
|
|
87
87
|
*/
|
|
88
88
|
export declare function dollarAmountString(number: Maybe<number>): string;
|
|
@@ -98,14 +98,15 @@ export type DollarAmountStringWithUnitFunction<U extends DollarAmountUnit> = ((a
|
|
|
98
98
|
/**
|
|
99
99
|
* Creates a function that formats dollar amounts as strings with a unit prefix (e.g., "$12.50").
|
|
100
100
|
*
|
|
101
|
+
* @param unit - The unit prefix to prepend; defaults to "$".
|
|
102
|
+
* @returns Formats dollar amounts with the configured unit.
|
|
103
|
+
*
|
|
101
104
|
* @dbxUtil
|
|
102
105
|
* @dbxUtilCategory number
|
|
103
106
|
* @dbxUtilKind factory
|
|
104
107
|
* @dbxUtilTags number, dollar, currency, format, factory, unit
|
|
105
108
|
* @dbxUtilRelated dollar-amount-string
|
|
106
109
|
*
|
|
107
|
-
* @param unit - The unit prefix to prepend; defaults to "$"
|
|
108
|
-
* @returns A function that formats dollar amounts with the configured unit
|
|
109
110
|
* @__NO_SIDE_EFFECTS__
|
|
110
111
|
*/
|
|
111
112
|
export declare function dollarAmountStringWithUnitFunction<U extends DollarAmountUnit>(unit?: U): DollarAmountStringWithUnitFunction<U>;
|
|
@@ -64,6 +64,9 @@ export declare const HEX_PATTERN: RegExp;
|
|
|
64
64
|
/**
|
|
65
65
|
* Checks whether the input string contains only valid hexadecimal characters.
|
|
66
66
|
*
|
|
67
|
+
* @param value - The string to check.
|
|
68
|
+
* @returns True if the string is non-empty and contains only hex characters.
|
|
69
|
+
*
|
|
67
70
|
* @example
|
|
68
71
|
* ```ts
|
|
69
72
|
* isHex('a1b2c3'); // true
|
|
@@ -71,9 +74,6 @@ export declare const HEX_PATTERN: RegExp;
|
|
|
71
74
|
* isHex('hello'); // false
|
|
72
75
|
* isHex(''); // false
|
|
73
76
|
* ```
|
|
74
|
-
*
|
|
75
|
-
* @param value - The string to check.
|
|
76
|
-
* @returns True if the string is non-empty and contains only hex characters.
|
|
77
77
|
*/
|
|
78
78
|
export declare function isHex(value: string): value is HexString;
|
|
79
79
|
/**
|
|
@@ -92,6 +92,10 @@ export interface IsHexWithByteLengthConfig {
|
|
|
92
92
|
*
|
|
93
93
|
* Each byte is encoded as 2 hex characters, so a 32-byte value requires a 64-character hex string.
|
|
94
94
|
*
|
|
95
|
+
* @param value - The string to check.
|
|
96
|
+
* @param config - Configuration specifying the expected byte length.
|
|
97
|
+
* @returns True if the string is valid hex with exactly the expected number of bytes.
|
|
98
|
+
*
|
|
95
99
|
* @example
|
|
96
100
|
* ```ts
|
|
97
101
|
* // Ed25519 public key is 32 bytes (64 hex chars)
|
|
@@ -99,9 +103,5 @@ export interface IsHexWithByteLengthConfig {
|
|
|
99
103
|
* isHexWithByteLength('abc123', { byteLength: 32 }); // false (too short)
|
|
100
104
|
* isHexWithByteLength('placeholder', { byteLength: 32 }); // false (not hex)
|
|
101
105
|
* ```
|
|
102
|
-
*
|
|
103
|
-
* @param value - The string to check.
|
|
104
|
-
* @param config - Configuration specifying the expected byte length.
|
|
105
|
-
* @returns True if the string is valid hex with exactly the expected number of bytes.
|
|
106
106
|
*/
|
|
107
107
|
export declare function isHexWithByteLength(value: string, config: IsHexWithByteLengthConfig): value is HexString;
|
|
@@ -7,17 +7,17 @@ export interface IncrementingNumberFactoryConfig {
|
|
|
7
7
|
/**
|
|
8
8
|
* Value to start at. Defaults to 0.
|
|
9
9
|
*/
|
|
10
|
-
startAt?: number;
|
|
10
|
+
readonly startAt?: number;
|
|
11
11
|
/**
|
|
12
12
|
* Getter to increase by. Defaults to 1.
|
|
13
13
|
*/
|
|
14
|
-
increaseBy?: GetterOrValue<number>;
|
|
14
|
+
readonly increaseBy?: GetterOrValue<number>;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Creates a factory that returns sequentially increasing numbers, starting from a configurable value and incrementing by a configurable step.
|
|
18
18
|
*
|
|
19
19
|
* @param config - Configuration with optional `startAt` (default 0) and `increaseBy` (default 1)
|
|
20
|
-
* @returns A factory function that returns the next number in the sequence on each call
|
|
20
|
+
* @returns A factory function that returns the next number in the sequence on each call.
|
|
21
21
|
*
|
|
22
22
|
* @dbxUtil
|
|
23
23
|
* @dbxUtilCategory number
|
|
@@ -32,6 +32,7 @@ export interface IncrementingNumberFactoryConfig {
|
|
|
32
32
|
* factory(); // 15
|
|
33
33
|
* factory(); // 20
|
|
34
34
|
* ```
|
|
35
|
+
*
|
|
35
36
|
* @__NO_SIDE_EFFECTS__
|
|
36
37
|
*/
|
|
37
38
|
export declare function incrementingNumberFactory(config?: IncrementingNumberFactoryConfig): NumberFactory;
|
|
@@ -46,13 +46,13 @@ export type PercentDecimal = number;
|
|
|
46
46
|
*
|
|
47
47
|
* Returns 0 for null/undefined input.
|
|
48
48
|
*
|
|
49
|
+
* @param input - A percent number value (e.g., 5 means 5%)
|
|
50
|
+
* @returns The decimal equivalent.
|
|
51
|
+
*
|
|
49
52
|
* @dbxUtil
|
|
50
53
|
* @dbxUtilCategory number
|
|
51
54
|
* @dbxUtilTags number, percent, decimal, convert, ratio
|
|
52
55
|
* @dbxUtilRelated percent-number-from-decimal
|
|
53
|
-
*
|
|
54
|
-
* @param input - A percent number value (e.g., 5 means 5%)
|
|
55
|
-
* @returns The decimal equivalent
|
|
56
56
|
*/
|
|
57
57
|
export declare function percentNumberToDecimal(input: Maybe<number>): number;
|
|
58
58
|
/**
|
|
@@ -60,13 +60,13 @@ export declare function percentNumberToDecimal(input: Maybe<number>): number;
|
|
|
60
60
|
*
|
|
61
61
|
* Returns 0 for null/undefined input.
|
|
62
62
|
*
|
|
63
|
+
* @param input - A decimal percent value (e.g., 0.05 means 5%)
|
|
64
|
+
* @returns The percent number equivalent.
|
|
65
|
+
*
|
|
63
66
|
* @dbxUtil
|
|
64
67
|
* @dbxUtilCategory number
|
|
65
68
|
* @dbxUtilTags number, percent, decimal, convert, ratio
|
|
66
69
|
* @dbxUtilRelated percent-number-to-decimal
|
|
67
|
-
*
|
|
68
|
-
* @param input - A decimal percent value (e.g., 0.05 means 5%)
|
|
69
|
-
* @returns The percent number equivalent
|
|
70
70
|
*/
|
|
71
71
|
export declare function percentNumberFromDecimal(input: Maybe<number>): PercentNumber;
|
|
72
72
|
export type NumberOrNumberString = number | NumberString;
|
|
@@ -83,12 +83,12 @@ export type AsNumberInput = Maybe<NumberOrNumberString>;
|
|
|
83
83
|
*
|
|
84
84
|
* Strings are parsed via `Number()`. Null/undefined returns 0.
|
|
85
85
|
*
|
|
86
|
+
* @param input - Numeric value, numeric string, or null/undefined.
|
|
87
|
+
* @returns The numeric value, or 0 for null/undefined.
|
|
88
|
+
*
|
|
86
89
|
* @dbxUtil
|
|
87
90
|
* @dbxUtilCategory number
|
|
88
91
|
* @dbxUtilTags number, parse, convert, coerce, string, normalize
|
|
89
|
-
*
|
|
90
|
-
* @param input - A number, number string, or null/undefined
|
|
91
|
-
* @returns The numeric value, or 0 for null/undefined
|
|
92
92
|
*/
|
|
93
93
|
export declare function asNumber(input: AsNumberInput): number;
|
|
94
94
|
/**
|
|
@@ -96,14 +96,14 @@ export declare function asNumber(input: AsNumberInput): number;
|
|
|
96
96
|
*
|
|
97
97
|
* Treats null/undefined as 0.
|
|
98
98
|
*
|
|
99
|
+
* @param value - The number to check.
|
|
100
|
+
* @param divisor - The divisor to test against.
|
|
101
|
+
* @returns `true` if the remainder is zero.
|
|
102
|
+
*
|
|
99
103
|
* @dbxUtil
|
|
100
104
|
* @dbxUtilCategory number
|
|
101
105
|
* @dbxUtilTags number, divisible, modulo, division, math, check
|
|
102
106
|
* @dbxUtilRelated nearest-divisible-values, is-even-number, is-odd-number
|
|
103
|
-
*
|
|
104
|
-
* @param value - The number to check
|
|
105
|
-
* @param divisor - The divisor to test against
|
|
106
|
-
* @returns `true` if the remainder is zero
|
|
107
107
|
*/
|
|
108
108
|
export declare function isNumberDivisibleBy(value: Maybe<number>, divisor: number): boolean;
|
|
109
109
|
export interface NearestDivisibleValues {
|
|
@@ -115,38 +115,38 @@ export interface NearestDivisibleValues {
|
|
|
115
115
|
/**
|
|
116
116
|
* Finds the nearest values that are evenly divisible by the divisor, both above (ceil) and below (floor) the input value.
|
|
117
117
|
*
|
|
118
|
+
* @param value - The value to find divisible neighbors for.
|
|
119
|
+
* @param divisor - The divisor to align to.
|
|
120
|
+
* @returns Object with the input value, divisor, and the nearest ceil/floor divisible values.
|
|
121
|
+
*
|
|
118
122
|
* @dbxUtil
|
|
119
123
|
* @dbxUtilCategory number
|
|
120
124
|
* @dbxUtilTags number, divisible, nearest, ceil, floor, round, snap, math
|
|
121
125
|
* @dbxUtilRelated is-number-divisible-by
|
|
122
|
-
*
|
|
123
|
-
* @param value - The value to find divisible neighbors for
|
|
124
|
-
* @param divisor - The divisor to align to
|
|
125
|
-
* @returns Object with the input value, divisor, and the nearest ceil/floor divisible values
|
|
126
126
|
*/
|
|
127
127
|
export declare function nearestDivisibleValues(value: number, divisor: number): NearestDivisibleValues;
|
|
128
128
|
/**
|
|
129
129
|
* Checks whether the input is an even number.
|
|
130
130
|
*
|
|
131
|
+
* @param value - Number to test.
|
|
132
|
+
* @returns `true` if even.
|
|
133
|
+
*
|
|
131
134
|
* @dbxUtil
|
|
132
135
|
* @dbxUtilCategory number
|
|
133
136
|
* @dbxUtilTags number, even, parity, math, check
|
|
134
137
|
* @dbxUtilRelated is-odd-number, is-number-divisible-by
|
|
135
|
-
*
|
|
136
|
-
* @param value - Number to test
|
|
137
|
-
* @returns `true` if even
|
|
138
138
|
*/
|
|
139
139
|
export declare function isEvenNumber(value: number): boolean;
|
|
140
140
|
/**
|
|
141
141
|
* Checks whether the input is an odd number.
|
|
142
142
|
*
|
|
143
|
+
* @param value - Number to test.
|
|
144
|
+
* @returns `true` if odd.
|
|
145
|
+
*
|
|
143
146
|
* @dbxUtil
|
|
144
147
|
* @dbxUtilCategory number
|
|
145
148
|
* @dbxUtilTags number, odd, parity, math, check
|
|
146
149
|
* @dbxUtilRelated is-even-number, is-number-divisible-by
|
|
147
|
-
*
|
|
148
|
-
* @param value - Number to test
|
|
149
|
-
* @returns `true` if odd
|
|
150
150
|
*/
|
|
151
151
|
export declare function isOddNumber(value: number): boolean;
|
|
152
152
|
/**
|
|
@@ -154,46 +154,46 @@ export declare function isOddNumber(value: number): boolean;
|
|
|
154
154
|
*
|
|
155
155
|
* The `from` value is floored and the `to` value is ceiled before computation.
|
|
156
156
|
*
|
|
157
|
+
* @param from - The starting value (floored to nearest integer)
|
|
158
|
+
* @param to - The ending value (ceiled to nearest integer)
|
|
159
|
+
* @returns Sum of all integers in the range.
|
|
160
|
+
*
|
|
157
161
|
* @dbxUtil
|
|
158
162
|
* @dbxUtilCategory number
|
|
159
163
|
* @dbxUtilTags number, sum, range, integers, math, gauss, total
|
|
160
|
-
*
|
|
161
|
-
* @param from - The starting value (floored to nearest integer)
|
|
162
|
-
* @param to - The ending value (ceiled to nearest integer)
|
|
163
|
-
* @returns Sum of all integers in the range
|
|
164
164
|
*/
|
|
165
165
|
export declare function sumOfIntegersBetween(from: number, to: number): number;
|
|
166
166
|
/**
|
|
167
167
|
* A {@link SortCompareFunction} for numbers that sorts in ascending order.
|
|
168
168
|
*
|
|
169
|
-
* @param a -
|
|
170
|
-
* @param b -
|
|
171
|
-
* @returns
|
|
169
|
+
* @param a - The first number to compare.
|
|
170
|
+
* @param b - The second number to compare.
|
|
171
|
+
* @returns A negative value if `a` is less than `b`, zero if equal, or a positive value if `a` is greater.
|
|
172
172
|
*/
|
|
173
173
|
export declare const sortCompareNumberFunction: SortCompareFunction<number>;
|
|
174
174
|
/**
|
|
175
175
|
* Finds the minimum and maximum values from an iterable of numbers.
|
|
176
176
|
*
|
|
177
|
+
* @param values - Iterable of numbers to examine.
|
|
178
|
+
* @returns Object with `min` and `max` values.
|
|
179
|
+
*
|
|
177
180
|
* @dbxUtil
|
|
178
181
|
* @dbxUtilCategory number
|
|
179
182
|
* @dbxUtilTags number, min, max, range, sort, bounds, extremes
|
|
180
183
|
* @dbxUtilRelated sort-compare-number-function
|
|
181
|
-
*
|
|
182
|
-
* @param values - Iterable of numbers to examine
|
|
183
|
-
* @returns Object with `min` and `max` values
|
|
184
184
|
*/
|
|
185
185
|
export declare function minAndMaxNumber(values: Iterable<number>): MinAndMaxFunctionResult<number>;
|
|
186
186
|
/**
|
|
187
187
|
* Computes the logarithm of `y` with base `x`.
|
|
188
188
|
*
|
|
189
|
+
* @param x - The base of the logarithm.
|
|
190
|
+
* @param y - The value to compute the logarithm of.
|
|
191
|
+
* @returns The base-x logarithm of y.
|
|
192
|
+
*
|
|
189
193
|
* @dbxUtil
|
|
190
194
|
* @dbxUtilCategory number
|
|
191
195
|
* @dbxUtilTags number, log, logarithm, math, base
|
|
192
196
|
*
|
|
193
|
-
* @param x - The base of the logarithm
|
|
194
|
-
* @param y - The value to compute the logarithm of
|
|
195
|
-
* @returns The base-x logarithm of y
|
|
196
|
-
*
|
|
197
197
|
* @example
|
|
198
198
|
* ```ts
|
|
199
199
|
* getBaseLog(2, 16); // 4 (2^4 = 16)
|
|
@@ -13,15 +13,15 @@ export interface RandomNumberFactoryConfig {
|
|
|
13
13
|
*
|
|
14
14
|
* No rounding by default.
|
|
15
15
|
*/
|
|
16
|
-
round?: RoundingInput;
|
|
16
|
+
readonly round?: RoundingInput;
|
|
17
17
|
/**
|
|
18
18
|
* Minimum number (inclusive)
|
|
19
19
|
*/
|
|
20
|
-
min?: number;
|
|
20
|
+
readonly min?: number;
|
|
21
21
|
/**
|
|
22
22
|
* Max number (exclusive)
|
|
23
23
|
*/
|
|
24
|
-
max: number;
|
|
24
|
+
readonly max: number;
|
|
25
25
|
}
|
|
26
26
|
export type RandomNumberFactoryInput = number | RandomNumberFactoryConfig;
|
|
27
27
|
/**
|
|
@@ -29,28 +29,29 @@ export type RandomNumberFactoryInput = number | RandomNumberFactoryConfig;
|
|
|
29
29
|
*
|
|
30
30
|
* Accepts either a simple max number or a full config object with min, max, and rounding options.
|
|
31
31
|
*
|
|
32
|
+
* @param maxOrArgs - Maximum value (exclusive) or full configuration object.
|
|
33
|
+
* @param roundingInput - Optional rounding mode override.
|
|
34
|
+
* @returns A factory function that produces random numbers within the range.
|
|
35
|
+
*
|
|
32
36
|
* @dbxUtil
|
|
33
37
|
* @dbxUtilCategory number
|
|
34
38
|
* @dbxUtilKind factory
|
|
35
39
|
* @dbxUtilTags number, random, factory, range, min, max, generate
|
|
36
40
|
* @dbxUtilRelated random-number, rounding-function
|
|
37
41
|
*
|
|
38
|
-
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
39
|
-
* @param roundingInput - Optional rounding mode override
|
|
40
|
-
* @returns A factory function that produces random numbers within the range
|
|
41
42
|
* @__NO_SIDE_EFFECTS__
|
|
42
43
|
*/
|
|
43
44
|
export declare function randomNumberFactory(maxOrArgs: RandomNumberFactoryInput, roundingInput?: RoundingInput): RandomNumberFactory;
|
|
44
45
|
/**
|
|
45
46
|
* Generates a single random number using {@link randomNumberFactory}. Convenience function for one-off usage.
|
|
46
47
|
*
|
|
48
|
+
* @param maxOrArgs - Maximum value (exclusive) or full configuration object.
|
|
49
|
+
* @param roundingInput - Optional rounding mode.
|
|
50
|
+
* @returns A single random number.
|
|
51
|
+
*
|
|
47
52
|
* @dbxUtil
|
|
48
53
|
* @dbxUtilCategory number
|
|
49
54
|
* @dbxUtilTags number, random, range, generate
|
|
50
55
|
* @dbxUtilRelated random-number-factory
|
|
51
|
-
*
|
|
52
|
-
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
53
|
-
* @param roundingInput - Optional rounding mode
|
|
54
|
-
* @returns A single random number
|
|
55
56
|
*/
|
|
56
57
|
export declare function randomNumber(maxOrArgs: RandomNumberFactoryInput, roundingInput?: RoundingInput): number;
|
|
@@ -7,14 +7,15 @@ export type RoundingFunction = MapFunction<number, number>;
|
|
|
7
7
|
/**
|
|
8
8
|
* Returns a rounding function for the specified rounding type.
|
|
9
9
|
*
|
|
10
|
+
* @param type - The rounding strategy: 'floor', 'ceil', 'round', or 'none'.
|
|
11
|
+
* @returns The corresponding Math function, or an identity function for 'none'.
|
|
12
|
+
*
|
|
10
13
|
* @dbxUtil
|
|
11
14
|
* @dbxUtilCategory number
|
|
12
15
|
* @dbxUtilKind factory
|
|
13
16
|
* @dbxUtilTags number, round, floor, ceil, math, factory, rounding
|
|
14
17
|
* @dbxUtilRelated cut-value-to-precision-function, round-to-precision-function
|
|
15
18
|
*
|
|
16
|
-
* @param type - The rounding strategy: 'floor', 'ceil', 'round', or 'none'
|
|
17
|
-
* @returns The corresponding Math function, or an identity function for 'none'
|
|
18
19
|
* @__NO_SIDE_EFFECTS__
|
|
19
20
|
*/
|
|
20
21
|
export declare function roundingFunction(type: NumberRounding): RoundingFunction;
|
|
@@ -32,14 +33,14 @@ export type NumberPrecision = number;
|
|
|
32
33
|
*
|
|
33
34
|
* Accepts strings and null/undefined via {@link asNumber}.
|
|
34
35
|
*
|
|
36
|
+
* @param input - Number, number string, or null/undefined.
|
|
37
|
+
* @param precision - Number of decimal places to retain.
|
|
38
|
+
* @returns The truncated number value.
|
|
39
|
+
*
|
|
35
40
|
* @dbxUtil
|
|
36
41
|
* @dbxUtilCategory number
|
|
37
42
|
* @dbxUtilTags number, precision, decimal, truncate, cut, round
|
|
38
43
|
* @dbxUtilRelated cut-value-to-precision-function, cut-value-to-integer, round-to-precision
|
|
39
|
-
*
|
|
40
|
-
* @param input - Number, number string, or null/undefined
|
|
41
|
-
* @param precision - Number of decimal places to retain
|
|
42
|
-
* @returns The truncated number value
|
|
43
44
|
*/
|
|
44
45
|
export declare function cutValueToPrecision(input: AsNumberInput, precision: NumberPrecision): number;
|
|
45
46
|
/**
|
|
@@ -49,13 +50,13 @@ export declare const CUT_VALUE_TO_ZERO_PRECISION: CutValueToPrecisionFunction;
|
|
|
49
50
|
/**
|
|
50
51
|
* Truncates a value to an integer by cutting to zero decimal precision.
|
|
51
52
|
*
|
|
53
|
+
* @param input - Number, number string, or null/undefined.
|
|
54
|
+
* @returns The truncated integer value.
|
|
55
|
+
*
|
|
52
56
|
* @dbxUtil
|
|
53
57
|
* @dbxUtilCategory number
|
|
54
58
|
* @dbxUtilTags number, integer, truncate, floor, cut, parse
|
|
55
59
|
* @dbxUtilRelated cut-value-to-precision, as-number
|
|
56
|
-
*
|
|
57
|
-
* @param input - Number, number string, or null/undefined
|
|
58
|
-
* @returns The truncated integer value
|
|
59
60
|
*/
|
|
60
61
|
export declare function cutValueToInteger(input: AsNumberInput): number;
|
|
61
62
|
/**
|
|
@@ -67,15 +68,16 @@ export type CutValueToPrecisionFunction = ((input: AsNumberInput) => number) & {
|
|
|
67
68
|
/**
|
|
68
69
|
* Creates a {@link CutValueToPrecisionFunction} that truncates values to the configured precision.
|
|
69
70
|
*
|
|
71
|
+
* @param precision - Number of decimal places to retain.
|
|
72
|
+
* @param roundingType - Rounding strategy; defaults to 'cut' (truncation)
|
|
73
|
+
* @returns Accepts a number or string and returns the truncated number.
|
|
74
|
+
*
|
|
70
75
|
* @dbxUtil
|
|
71
76
|
* @dbxUtilCategory number
|
|
72
77
|
* @dbxUtilKind factory
|
|
73
78
|
* @dbxUtilTags number, precision, cut, truncate, factory, round
|
|
74
79
|
* @dbxUtilRelated round-to-precision-function, cut-to-precision
|
|
75
80
|
*
|
|
76
|
-
* @param precision - Number of decimal places to retain
|
|
77
|
-
* @param roundingType - Rounding strategy; defaults to 'cut' (truncation)
|
|
78
|
-
* @returns A function that accepts a number or string and returns the truncated number
|
|
79
81
|
* @__NO_SIDE_EFFECTS__
|
|
80
82
|
*/
|
|
81
83
|
export declare function cutValueToPrecisionFunction(precision: NumberPrecision, roundingType?: RoundToPrecisionFunctionType): CutValueToPrecisionFunction;
|
|
@@ -91,24 +93,25 @@ export type RoundToPrecisionFunctionType = NumberRounding | 'cut';
|
|
|
91
93
|
/**
|
|
92
94
|
* Creates a function that rounds numbers to the specified precision using a configurable rounding strategy.
|
|
93
95
|
*
|
|
96
|
+
* @param precision - Number of decimal places.
|
|
97
|
+
* @param roundFn - Rounding strategy; defaults to 'round'. Use 'cut' for truncation.
|
|
98
|
+
* @returns Rounds numbers to the configured precision.
|
|
99
|
+
*
|
|
94
100
|
* @dbxUtil
|
|
95
101
|
* @dbxUtilCategory number
|
|
96
102
|
* @dbxUtilKind factory
|
|
97
103
|
* @dbxUtilTags number, round, precision, factory, decimals
|
|
98
104
|
* @dbxUtilRelated cut-value-to-precision-function, round-to-precision, cut-to-precision
|
|
99
105
|
*
|
|
100
|
-
* @param precision - Number of decimal places
|
|
101
|
-
* @param roundFn - Rounding strategy; defaults to 'round'. Use 'cut' for truncation.
|
|
102
|
-
* @returns A function that rounds numbers to the configured precision
|
|
103
106
|
* @__NO_SIDE_EFFECTS__
|
|
104
107
|
*/
|
|
105
108
|
export declare function roundToPrecisionFunction(precision: NumberPrecision, roundFn?: RoundToPrecisionFunctionType): RoundToPrecisionFunction;
|
|
106
109
|
/**
|
|
107
110
|
* Rounds a number to the specified decimal precision using `Math.round`.
|
|
108
111
|
*
|
|
109
|
-
* @param value - Number to round
|
|
110
|
-
* @param precision - Number of decimal places to retain
|
|
111
|
-
* @returns The rounded number
|
|
112
|
+
* @param value - Number to round.
|
|
113
|
+
* @param precision - Number of decimal places to retain.
|
|
114
|
+
* @returns The rounded number.
|
|
112
115
|
*/
|
|
113
116
|
export declare function roundToPrecision(value: number, precision: NumberPrecision): number;
|
|
114
117
|
/**
|
|
@@ -117,9 +120,9 @@ export declare function roundToPrecision(value: number, precision: NumberPrecisi
|
|
|
117
120
|
* Uses `Math.floor` for positive numbers and `Math.ceil` for negative numbers to truncate toward zero.
|
|
118
121
|
* For example, 1.25 with precision 1 becomes 1.2 (not 1.3).
|
|
119
122
|
*
|
|
120
|
-
* @param value - Number to truncate
|
|
121
|
-
* @param precision - Number of decimal places to retain
|
|
122
|
-
* @returns The truncated number
|
|
123
|
+
* @param value - Number to truncate.
|
|
124
|
+
* @param precision - Number of decimal places to retain.
|
|
125
|
+
* @returns The truncated number.
|
|
123
126
|
*/
|
|
124
127
|
export declare function cutToPrecision(value: number, precision: NumberPrecision): number;
|
|
125
128
|
/**
|
|
@@ -139,24 +142,24 @@ export type StepOrigin = number;
|
|
|
139
142
|
/**
|
|
140
143
|
* Rounds a number up to the nearest multiple of the step size using `Math.ceil`.
|
|
141
144
|
*
|
|
142
|
-
* @param value - Input value
|
|
143
|
-
* @param step - Step size to round up to
|
|
144
|
-
* @returns The nearest multiple of step that is >= value
|
|
145
|
+
* @param value - Input value.
|
|
146
|
+
* @param step - Step size to round up to.
|
|
147
|
+
* @returns The nearest multiple of step that is >= value.
|
|
145
148
|
*/
|
|
146
149
|
export declare function roundNumberUpToStep(value: number, step: number): number;
|
|
147
150
|
/**
|
|
148
151
|
* roundNumberToStepFunction()
|
|
149
152
|
*/
|
|
150
153
|
export interface RoundNumberToStepFunctionConfig {
|
|
151
|
-
step: StepNumber;
|
|
154
|
+
readonly step: StepNumber;
|
|
152
155
|
/**
|
|
153
156
|
* Type of rounding to use.
|
|
154
157
|
*/
|
|
155
|
-
round: Omit<NumberRounding, 'none'>;
|
|
158
|
+
readonly round: Omit<NumberRounding, 'none'>;
|
|
156
159
|
/**
|
|
157
160
|
* Offset to apply to each input number. Defaults to zero.
|
|
158
161
|
*/
|
|
159
|
-
origin?: StepOrigin;
|
|
162
|
+
readonly origin?: StepOrigin;
|
|
160
163
|
}
|
|
161
164
|
export type RoundNumberToStepFunctionInput = RoundNumberToStepFunctionConfig | StepNumber;
|
|
162
165
|
/**
|
|
@@ -175,15 +178,16 @@ export type RoundNumberToStepFunction = ((input: Maybe<number>) => number) & {
|
|
|
175
178
|
*
|
|
176
179
|
* Accepts either a step number (uses 'ceil' rounding) or a full config with step, rounding type, and origin.
|
|
177
180
|
*
|
|
181
|
+
* @param input - Step size or full configuration.
|
|
182
|
+
* @returns Rounds input numbers to the nearest step.
|
|
183
|
+
* @throws {Error} If step is 0 or undefined.
|
|
184
|
+
*
|
|
178
185
|
* @dbxUtil
|
|
179
186
|
* @dbxUtilCategory number
|
|
180
187
|
* @dbxUtilKind factory
|
|
181
188
|
* @dbxUtilTags number, round, step, factory, multiple, origin
|
|
182
189
|
* @dbxUtilRelated round-number-up-to-step, round-to-precision-function
|
|
183
190
|
*
|
|
184
|
-
* @param input - Step size or full configuration
|
|
185
|
-
* @returns A function that rounds input numbers to the nearest step
|
|
186
|
-
* @throws Error if step is 0 or undefined
|
|
187
191
|
* @__NO_SIDE_EFFECTS__
|
|
188
192
|
*/
|
|
189
193
|
export declare function roundNumberToStepFunction(input: RoundNumberToStepFunctionInput): RoundNumberToStepFunction;
|
package/src/lib/number/sort.d.ts
CHANGED
|
@@ -7,14 +7,15 @@ export type SortByNumberFunction<T> = SortCompareFunction<T>;
|
|
|
7
7
|
/**
|
|
8
8
|
* Creates a {@link SortCompareFunction} that sorts values in ascending order by a numeric property.
|
|
9
9
|
*
|
|
10
|
+
* @param readNumberFn - Function that extracts the numeric value from each item.
|
|
11
|
+
* @returns A sort comparator function for ascending numeric order.
|
|
12
|
+
*
|
|
10
13
|
* @dbxUtil
|
|
11
14
|
* @dbxUtilCategory number
|
|
12
15
|
* @dbxUtilKind factory
|
|
13
16
|
* @dbxUtilTags number, sort, compare, ascending, factory
|
|
14
17
|
* @dbxUtilRelated sort-numbers-ascending-function, sort-by-string-function
|
|
15
18
|
*
|
|
16
|
-
* @param readNumberFn - Function that extracts the numeric value from each item
|
|
17
|
-
* @returns A sort comparator function for ascending numeric order
|
|
18
19
|
* @__NO_SIDE_EFFECTS__
|
|
19
20
|
*/
|
|
20
21
|
export declare function sortByNumberFunction<T>(readNumberFn: ReadNumberFunction<T>): SortByNumberFunction<T>;
|