@pawells/typescript-common 2.0.0 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +350 -224
- package/{build → dist}/array/array-chunk.d.ts +1 -1
- package/{build → dist}/array/array-chunk.js +2 -3
- package/{build → dist}/array/array-compact.d.ts +1 -1
- package/{build → dist}/array/array-compact.js +1 -2
- package/{build → dist}/array/array-contains.d.ts +1 -1
- package/{build → dist}/array/array-contains.js +2 -3
- package/{build → dist}/array/array-count-by.d.ts +1 -1
- package/{build → dist}/array/array-count-by.js +2 -3
- package/{build → dist}/array/array-difference.d.ts +12 -5
- package/dist/array/array-difference.d.ts.map +1 -0
- package/dist/array/array-difference.js +70 -0
- package/dist/array/array-element.js +1 -0
- package/{build → dist}/array/array-filter.d.ts +1 -1
- package/{build → dist}/array/array-filter.js +1 -2
- package/{build → dist}/array/array-flatten.d.ts +2 -2
- package/{build → dist}/array/array-flatten.d.ts.map +1 -1
- package/{build → dist}/array/array-flatten.js +1 -2
- package/{build → dist}/array/array-group-by.d.ts +1 -1
- package/{build → dist}/array/array-group-by.d.ts.map +1 -1
- package/{build → dist}/array/array-group-by.js +10 -9
- package/{build → dist}/array/array-intersection.d.ts +12 -5
- package/dist/array/array-intersection.d.ts.map +1 -0
- package/dist/array/array-intersection.js +79 -0
- package/{build → dist}/array/array-partition.d.ts +1 -1
- package/{build → dist}/array/array-partition.js +2 -3
- package/{build → dist}/array/array-range.d.ts +1 -1
- package/{build → dist}/array/array-range.js +1 -2
- package/{build → dist}/array/array-sample.d.ts +2 -2
- package/{build → dist}/array/array-sample.js +3 -5
- package/{build → dist}/array/array-shuffle.d.ts +1 -1
- package/{build → dist}/array/array-shuffle.js +1 -2
- package/{build → dist}/array/array-sort-by.d.ts +1 -1
- package/{build → dist}/array/array-sort-by.js +1 -2
- package/{build → dist}/array/array-zip.d.ts +1 -1
- package/{build → dist}/array/array-zip.js +1 -2
- package/{build → dist}/array/assert.d.ts +5 -5
- package/{build → dist}/array/assert.d.ts.map +1 -1
- package/{build → dist}/array/assert.js +13 -14
- package/{build → dist}/array/index.js +0 -1
- package/{build → dist}/array/types.d.ts +20 -2
- package/{build → dist}/array/types.d.ts.map +1 -1
- package/dist/array/types.js +1 -0
- package/{build → dist}/array/unique.d.ts +1 -1
- package/{build → dist}/array/unique.js +1 -2
- package/dist/asserts/errors.d.ts.map +1 -0
- package/{build → dist}/asserts/errors.js +5 -3
- package/{build → dist}/asserts/generic.d.ts +23 -3
- package/dist/asserts/generic.d.ts.map +1 -0
- package/{build → dist}/asserts/generic.js +33 -7
- package/dist/asserts/index.d.ts +47 -0
- package/dist/asserts/index.d.ts.map +1 -0
- package/dist/asserts/index.js +46 -0
- package/{build → dist}/asserts/internal-utils.d.ts.map +1 -1
- package/{build → dist}/asserts/internal-utils.js +0 -1
- package/{build → dist}/asserts/types.d.ts +56 -17
- package/dist/asserts/types.d.ts.map +1 -0
- package/dist/asserts/types.js +1 -0
- package/{build → dist}/asserts/utils.d.ts +5 -21
- package/dist/asserts/utils.d.ts.map +1 -0
- package/{build → dist}/asserts/utils.js +12 -36
- package/{build → dist}/boolean/assert.d.ts +1 -2
- package/{build → dist}/boolean/assert.d.ts.map +1 -1
- package/{build → dist}/boolean/assert.js +1 -3
- package/dist/boolean/index.d.ts +13 -0
- package/dist/boolean/index.d.ts.map +1 -0
- package/dist/boolean/index.js +12 -0
- package/{build → dist}/enum/enum-entries.d.ts +1 -1
- package/dist/enum/enum-entries.d.ts.map +1 -0
- package/{build → dist}/enum/enum-entries.js +0 -1
- package/{build → dist}/enum/enum-key-by-value.d.ts +1 -1
- package/dist/enum/enum-key-by-value.d.ts.map +1 -0
- package/{build → dist}/enum/enum-key-by-value.js +0 -1
- package/{build → dist}/enum/enum-keys.js +0 -1
- package/{build → dist}/enum/enum-safe-value.d.ts +1 -1
- package/dist/enum/enum-safe-value.d.ts.map +1 -0
- package/{build → dist}/enum/enum-safe-value.js +0 -1
- package/{build → dist}/enum/enum-values.js +0 -1
- package/{build → dist}/enum/index.d.ts +1 -1
- package/dist/enum/index.d.ts.map +1 -0
- package/{build → dist}/enum/index.js +1 -2
- package/dist/enum/types.js +1 -0
- package/{build → dist}/enum/validate-enum-value.d.ts +1 -1
- package/dist/enum/validate-enum-value.d.ts.map +1 -0
- package/{build → dist}/enum/validate-enum-value.js +0 -1
- package/{build → dist}/function/compose.d.ts +6 -0
- package/dist/function/compose.d.ts.map +1 -0
- package/{build → dist}/function/compose.js +0 -1
- package/{build → dist}/function/debounce.d.ts +6 -0
- package/dist/function/debounce.d.ts.map +1 -0
- package/{build → dist}/function/debounce.js +6 -1
- package/{build → dist}/function/index.js +0 -1
- package/dist/function/memoize.d.ts +43 -0
- package/dist/function/memoize.d.ts.map +1 -0
- package/dist/function/memoize.js +59 -0
- package/{build → dist}/function/once.d.ts.map +1 -1
- package/{build → dist}/function/once.js +1 -1
- package/{build → dist}/function/sleep.js +0 -1
- package/{build → dist}/function/throttle.d.ts +7 -0
- package/dist/function/throttle.d.ts.map +1 -0
- package/{build → dist}/function/throttle.js +7 -1
- package/dist/function/types.d.ts +18 -0
- package/dist/function/types.d.ts.map +1 -0
- package/dist/function/types.js +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/{build → dist}/lru-cache.d.ts +19 -0
- package/dist/lru-cache.d.ts.map +1 -0
- package/{build → dist}/lru-cache.js +24 -2
- package/{build → dist}/number/assert.js +0 -1
- package/dist/number/index.d.ts +13 -0
- package/dist/number/index.d.ts.map +1 -0
- package/dist/number/index.js +12 -0
- package/{build → dist}/object/assert-object.d.ts +5 -1
- package/{build → dist}/object/assert-object.d.ts.map +1 -1
- package/{build → dist}/object/assert-object.js +4 -1
- package/{build → dist}/object/assert.d.ts +1 -1
- package/dist/object/assert.d.ts.map +1 -0
- package/{build → dist}/object/assert.js +7 -29
- package/{build → dist}/object/clone.d.ts.map +1 -1
- package/{build → dist}/object/clone.js +8 -5
- package/{build → dist}/object/equals.d.ts.map +1 -1
- package/{build → dist}/object/equals.js +3 -7
- package/dist/object/filter-cached.d.ts +44 -0
- package/{build → dist}/object/filter-cached.d.ts.map +1 -1
- package/{build → dist}/object/filter-cached.js +41 -2
- package/{build → dist}/object/filter.d.ts.map +1 -1
- package/{build → dist}/object/filter.js +12 -5
- package/{build → dist}/object/has-circular-reference.d.ts.map +1 -1
- package/{build → dist}/object/has-circular-reference.js +4 -2
- package/{build → dist}/object/hash.d.ts +4 -0
- package/dist/object/hash.d.ts.map +1 -0
- package/{build → dist}/object/hash.js +20 -7
- package/{build → dist}/object/index.d.ts +2 -2
- package/{build → dist}/object/index.d.ts.map +1 -1
- package/{build → dist}/object/index.js +1 -2
- package/{build → dist}/object/json-circular-replacer.d.ts.map +1 -1
- package/{build → dist}/object/json-circular-replacer.js +0 -1
- package/{build → dist}/object/key-value-pairs.js +0 -1
- package/dist/object/map-cached.d.ts +31 -0
- package/dist/object/map-cached.d.ts.map +1 -0
- package/{build → dist}/object/map-cached.js +34 -6
- package/{build → dist}/object/map.js +0 -1
- package/{build → dist}/object/merge.d.ts.map +1 -1
- package/{build → dist}/object/merge.js +7 -7
- package/{build → dist}/object/object-diff.d.ts +2 -2
- package/{build → dist}/object/object-diff.d.ts.map +1 -1
- package/{build → dist}/object/object-diff.js +11 -5
- package/{build → dist}/object/object-flatten.d.ts +1 -1
- package/{build → dist}/object/object-flatten.d.ts.map +1 -1
- package/{build → dist}/object/object-flatten.js +6 -4
- package/{build → dist}/object/object-invert.js +0 -1
- package/{build → dist}/object/omit.js +0 -1
- package/{build → dist}/object/pick.js +0 -1
- package/{build → dist}/object/property-paths.js +6 -7
- package/dist/object/security-utils.d.ts +193 -0
- package/dist/object/security-utils.d.ts.map +1 -0
- package/dist/object/security-utils.js +297 -0
- package/{build → dist}/object/sort-keys.d.ts +1 -1
- package/{build → dist}/object/sort-keys.d.ts.map +1 -1
- package/{build → dist}/object/sort-keys.js +18 -11
- package/{build → dist}/object/types.d.ts +60 -19
- package/dist/object/types.d.ts.map +1 -0
- package/dist/object/types.js +1 -0
- package/{build → dist}/string/assert.d.ts +5 -0
- package/dist/string/assert.d.ts.map +1 -0
- package/{build → dist}/string/assert.js +11 -1
- package/{build → dist}/string/case-conversion.js +0 -1
- package/{build → dist}/string/comparison.d.ts.map +1 -1
- package/{build → dist}/string/comparison.js +3 -1
- package/{build → dist}/string/formatting.d.ts.map +1 -1
- package/{build → dist}/string/formatting.js +5 -3
- package/{build → dist}/string/index.js +0 -1
- package/{build → dist}/string/transformation.js +0 -1
- package/dist/string/types.d.ts +118 -0
- package/dist/string/types.d.ts.map +1 -0
- package/dist/string/types.js +1 -0
- package/{build → dist}/string/validation.js +0 -1
- package/dist/time/elapsed-time/constants.d.ts +36 -0
- package/{build → dist}/time/elapsed-time/constants.d.ts.map +1 -1
- package/{build → dist}/time/elapsed-time/constants.js +32 -3
- package/{build → dist}/time/elapsed-time/elapsed-time.d.ts +67 -15
- package/dist/time/elapsed-time/elapsed-time.d.ts.map +1 -0
- package/{build → dist}/time/elapsed-time/elapsed-time.js +172 -78
- package/dist/time/elapsed-time/types.d.ts +336 -0
- package/dist/time/elapsed-time/types.d.ts.map +1 -0
- package/dist/time/elapsed-time/types.js +1 -0
- package/{build → dist}/time/elapsed-time/utils.d.ts +1 -1
- package/dist/time/elapsed-time/utils.d.ts.map +1 -0
- package/{build → dist}/time/elapsed-time/utils.js +0 -1
- package/{build → dist}/time/index.d.ts +0 -2
- package/{build → dist}/time/index.d.ts.map +1 -1
- package/{build → dist}/time/index.js +0 -2
- package/{build → dist}/time/stopwatch/entry.d.ts +1 -1
- package/dist/time/stopwatch/entry.d.ts.map +1 -0
- package/{build → dist}/time/stopwatch/entry.js +0 -1
- package/{build → dist}/time/stopwatch/stopwatch.d.ts +9 -3
- package/dist/time/stopwatch/stopwatch.d.ts.map +1 -0
- package/{build → dist}/time/stopwatch/stopwatch.js +9 -4
- package/package.json +58 -81
- package/LICENSE +0 -21
- package/build/array/array-chunk.js.map +0 -1
- package/build/array/array-compact.js.map +0 -1
- package/build/array/array-contains.js.map +0 -1
- package/build/array/array-count-by.js.map +0 -1
- package/build/array/array-difference.d.ts.map +0 -1
- package/build/array/array-difference.js +0 -51
- package/build/array/array-difference.js.map +0 -1
- package/build/array/array-element.js +0 -2
- package/build/array/array-element.js.map +0 -1
- package/build/array/array-filter.js.map +0 -1
- package/build/array/array-flatten.js.map +0 -1
- package/build/array/array-group-by.js.map +0 -1
- package/build/array/array-intersection.d.ts.map +0 -1
- package/build/array/array-intersection.js +0 -57
- package/build/array/array-intersection.js.map +0 -1
- package/build/array/array-partition.js.map +0 -1
- package/build/array/array-range.js.map +0 -1
- package/build/array/array-sample.js.map +0 -1
- package/build/array/array-shuffle.js.map +0 -1
- package/build/array/array-sort-by.js.map +0 -1
- package/build/array/array-zip.js.map +0 -1
- package/build/array/assert.js.map +0 -1
- package/build/array/index.js.map +0 -1
- package/build/array/types.js +0 -2
- package/build/array/types.js.map +0 -1
- package/build/array/unique.js.map +0 -1
- package/build/asserts/errors.d.ts.map +0 -1
- package/build/asserts/errors.js.map +0 -1
- package/build/asserts/generic.d.ts.map +0 -1
- package/build/asserts/generic.js.map +0 -1
- package/build/asserts/index.d.ts +0 -41
- package/build/asserts/index.d.ts.map +0 -1
- package/build/asserts/index.js +0 -41
- package/build/asserts/index.js.map +0 -1
- package/build/asserts/internal-utils.js.map +0 -1
- package/build/asserts/types.d.ts.map +0 -1
- package/build/asserts/types.js +0 -2
- package/build/asserts/types.js.map +0 -1
- package/build/asserts/utils.d.ts.map +0 -1
- package/build/asserts/utils.js.map +0 -1
- package/build/boolean/assert.js.map +0 -1
- package/build/boolean/index.d.ts +0 -9
- package/build/boolean/index.d.ts.map +0 -1
- package/build/boolean/index.js +0 -9
- package/build/boolean/index.js.map +0 -1
- package/build/enum/enum-entries.d.ts.map +0 -1
- package/build/enum/enum-entries.js.map +0 -1
- package/build/enum/enum-key-by-value.d.ts.map +0 -1
- package/build/enum/enum-key-by-value.js.map +0 -1
- package/build/enum/enum-keys.js.map +0 -1
- package/build/enum/enum-safe-value.d.ts.map +0 -1
- package/build/enum/enum-safe-value.js.map +0 -1
- package/build/enum/enum-values.js.map +0 -1
- package/build/enum/index.d.ts.map +0 -1
- package/build/enum/index.js.map +0 -1
- package/build/enum/types.js +0 -2
- package/build/enum/types.js.map +0 -1
- package/build/enum/validate-enum-value.d.ts.map +0 -1
- package/build/enum/validate-enum-value.js.map +0 -1
- package/build/function/compose.d.ts.map +0 -1
- package/build/function/compose.js.map +0 -1
- package/build/function/debounce.d.ts.map +0 -1
- package/build/function/debounce.js.map +0 -1
- package/build/function/index.js.map +0 -1
- package/build/function/memoize.d.ts +0 -30
- package/build/function/memoize.d.ts.map +0 -1
- package/build/function/memoize.js +0 -44
- package/build/function/memoize.js.map +0 -1
- package/build/function/once.js.map +0 -1
- package/build/function/sleep.js.map +0 -1
- package/build/function/throttle.d.ts.map +0 -1
- package/build/function/throttle.js.map +0 -1
- package/build/function/types.d.ts +0 -5
- package/build/function/types.d.ts.map +0 -1
- package/build/function/types.js +0 -2
- package/build/function/types.js.map +0 -1
- package/build/index.d.ts +0 -38
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -64
- package/build/index.js.map +0 -1
- package/build/lru-cache.d.ts.map +0 -1
- package/build/lru-cache.js.map +0 -1
- package/build/number/assert.js.map +0 -1
- package/build/number/index.d.ts +0 -9
- package/build/number/index.d.ts.map +0 -1
- package/build/number/index.js +0 -9
- package/build/number/index.js.map +0 -1
- package/build/object/assert-object.js.map +0 -1
- package/build/object/assert.d.ts.map +0 -1
- package/build/object/assert.js.map +0 -1
- package/build/object/clone.js.map +0 -1
- package/build/object/equals.js.map +0 -1
- package/build/object/filter-cached.d.ts +0 -21
- package/build/object/filter-cached.js.map +0 -1
- package/build/object/filter.js.map +0 -1
- package/build/object/has-circular-reference.js.map +0 -1
- package/build/object/hash.d.ts.map +0 -1
- package/build/object/hash.js.map +0 -1
- package/build/object/index.js.map +0 -1
- package/build/object/json-circular-replacer.js.map +0 -1
- package/build/object/key-value-pairs.js.map +0 -1
- package/build/object/map-cached.d.ts +0 -20
- package/build/object/map-cached.d.ts.map +0 -1
- package/build/object/map-cached.js.map +0 -1
- package/build/object/map.js.map +0 -1
- package/build/object/merge.js.map +0 -1
- package/build/object/object-diff.js.map +0 -1
- package/build/object/object-flatten.js.map +0 -1
- package/build/object/object-invert.js.map +0 -1
- package/build/object/omit.js.map +0 -1
- package/build/object/pick.js.map +0 -1
- package/build/object/property-paths.js.map +0 -1
- package/build/object/security-utils.d.ts +0 -59
- package/build/object/security-utils.d.ts.map +0 -1
- package/build/object/security-utils.js +0 -161
- package/build/object/security-utils.js.map +0 -1
- package/build/object/sort-keys.js.map +0 -1
- package/build/object/types.d.ts.map +0 -1
- package/build/object/types.js +0 -6
- package/build/object/types.js.map +0 -1
- package/build/string/assert.d.ts.map +0 -1
- package/build/string/assert.js.map +0 -1
- package/build/string/case-conversion.js.map +0 -1
- package/build/string/comparison.js.map +0 -1
- package/build/string/formatting.js.map +0 -1
- package/build/string/index.js.map +0 -1
- package/build/string/transformation.js.map +0 -1
- package/build/string/types.d.ts +0 -44
- package/build/string/types.d.ts.map +0 -1
- package/build/string/types.js +0 -2
- package/build/string/types.js.map +0 -1
- package/build/string/validation.js.map +0 -1
- package/build/time/elapsed-time/constants.d.ts +0 -10
- package/build/time/elapsed-time/constants.js.map +0 -1
- package/build/time/elapsed-time/elapsed-time.d.ts.map +0 -1
- package/build/time/elapsed-time/elapsed-time.js.map +0 -1
- package/build/time/elapsed-time/types.d.ts +0 -150
- package/build/time/elapsed-time/types.d.ts.map +0 -1
- package/build/time/elapsed-time/types.js +0 -2
- package/build/time/elapsed-time/types.js.map +0 -1
- package/build/time/elapsed-time/utils.d.ts.map +0 -1
- package/build/time/elapsed-time/utils.js.map +0 -1
- package/build/time/index.js.map +0 -1
- package/build/time/stopwatch/entry-types.d.ts +0 -13
- package/build/time/stopwatch/entry-types.d.ts.map +0 -1
- package/build/time/stopwatch/entry-types.js +0 -2
- package/build/time/stopwatch/entry-types.js.map +0 -1
- package/build/time/stopwatch/entry.d.ts.map +0 -1
- package/build/time/stopwatch/entry.js.map +0 -1
- package/build/time/stopwatch/stopwatch.d.ts.map +0 -1
- package/build/time/stopwatch/stopwatch.js.map +0 -1
- /package/{build → dist}/array/array-chunk.d.ts.map +0 -0
- /package/{build → dist}/array/array-compact.d.ts.map +0 -0
- /package/{build → dist}/array/array-contains.d.ts.map +0 -0
- /package/{build → dist}/array/array-count-by.d.ts.map +0 -0
- /package/{build → dist}/array/array-element.d.ts +0 -0
- /package/{build → dist}/array/array-element.d.ts.map +0 -0
- /package/{build → dist}/array/array-filter.d.ts.map +0 -0
- /package/{build → dist}/array/array-partition.d.ts.map +0 -0
- /package/{build → dist}/array/array-range.d.ts.map +0 -0
- /package/{build → dist}/array/array-sample.d.ts.map +0 -0
- /package/{build → dist}/array/array-shuffle.d.ts.map +0 -0
- /package/{build → dist}/array/array-sort-by.d.ts.map +0 -0
- /package/{build → dist}/array/array-zip.d.ts.map +0 -0
- /package/{build → dist}/array/index.d.ts +0 -0
- /package/{build → dist}/array/index.d.ts.map +0 -0
- /package/{build → dist}/array/unique.d.ts.map +0 -0
- /package/{build → dist}/asserts/errors.d.ts +0 -0
- /package/{build → dist}/asserts/internal-utils.d.ts +0 -0
- /package/{build → dist}/enum/enum-keys.d.ts +0 -0
- /package/{build → dist}/enum/enum-keys.d.ts.map +0 -0
- /package/{build → dist}/enum/enum-values.d.ts +0 -0
- /package/{build → dist}/enum/enum-values.d.ts.map +0 -0
- /package/{build → dist}/enum/types.d.ts +0 -0
- /package/{build → dist}/enum/types.d.ts.map +0 -0
- /package/{build → dist}/function/index.d.ts +0 -0
- /package/{build → dist}/function/index.d.ts.map +0 -0
- /package/{build → dist}/function/once.d.ts +0 -0
- /package/{build → dist}/function/sleep.d.ts +0 -0
- /package/{build → dist}/function/sleep.d.ts.map +0 -0
- /package/{build → dist}/number/assert.d.ts +0 -0
- /package/{build → dist}/number/assert.d.ts.map +0 -0
- /package/{build → dist}/object/clone.d.ts +0 -0
- /package/{build → dist}/object/equals.d.ts +0 -0
- /package/{build → dist}/object/filter.d.ts +0 -0
- /package/{build → dist}/object/has-circular-reference.d.ts +0 -0
- /package/{build → dist}/object/json-circular-replacer.d.ts +0 -0
- /package/{build → dist}/object/key-value-pairs.d.ts +0 -0
- /package/{build → dist}/object/key-value-pairs.d.ts.map +0 -0
- /package/{build → dist}/object/map.d.ts +0 -0
- /package/{build → dist}/object/map.d.ts.map +0 -0
- /package/{build → dist}/object/merge.d.ts +0 -0
- /package/{build → dist}/object/object-invert.d.ts +0 -0
- /package/{build → dist}/object/object-invert.d.ts.map +0 -0
- /package/{build → dist}/object/omit.d.ts +0 -0
- /package/{build → dist}/object/omit.d.ts.map +0 -0
- /package/{build → dist}/object/pick.d.ts +0 -0
- /package/{build → dist}/object/pick.d.ts.map +0 -0
- /package/{build → dist}/object/property-paths.d.ts +0 -0
- /package/{build → dist}/object/property-paths.d.ts.map +0 -0
- /package/{build → dist}/string/case-conversion.d.ts +0 -0
- /package/{build → dist}/string/case-conversion.d.ts.map +0 -0
- /package/{build → dist}/string/comparison.d.ts +0 -0
- /package/{build → dist}/string/formatting.d.ts +0 -0
- /package/{build → dist}/string/index.d.ts +0 -0
- /package/{build → dist}/string/index.d.ts.map +0 -0
- /package/{build → dist}/string/transformation.d.ts +0 -0
- /package/{build → dist}/string/transformation.d.ts.map +0 -0
- /package/{build → dist}/string/validation.d.ts +0 -0
- /package/{build → dist}/string/validation.d.ts.map +0 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single time unit with its numeric value.
|
|
3
|
+
* Used internally for formatting operations to map unit names to their calculated values.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const hour: ITimeUnitValue = { unit: 'hour', value: 2 };
|
|
8
|
+
* const minutes: ITimeUnitValue = { unit: 'minute', value: 30 };
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export interface ITimeUnitValue {
|
|
12
|
+
/** The time unit type (week, day, hour, minute, second, millisecond) */
|
|
13
|
+
unit: TTimeUnit;
|
|
14
|
+
/** The numeric value for this time unit */
|
|
15
|
+
value: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Complete formatting options for elapsed time output.
|
|
19
|
+
* Controls how time values are displayed, including negative value handling, unit visibility, and label customization.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Show at most 2 units, hide zero-valued units, wrap negative values in parentheses
|
|
24
|
+
* const options: ITimeElapsedFormatOptions = {
|
|
25
|
+
* maxUnits: 2,
|
|
26
|
+
* showZeroValues: false,
|
|
27
|
+
* negativeValueFormat: 'Parenthesis'
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* const elapsed = new ElapsedTime(-3661000);
|
|
31
|
+
* elapsed.Format('medium', options); // "(1 hour 1 min)"
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export interface ITimeElapsedFormatOptions {
|
|
35
|
+
/** How to format negative values: 'Empty' (no indicator), 'NegativeSign' (prefix with -), 'Parenthesis' (wrap in parentheses), or 'Brackets' (wrap in brackets) */
|
|
36
|
+
negativeValueFormat?: 'Empty' | 'NegativeSign' | 'Parenthesis' | 'Brackets' | undefined;
|
|
37
|
+
/** Show zero value units in formatter output (default: false) */
|
|
38
|
+
showZeroValues?: boolean | undefined;
|
|
39
|
+
/** Maximum number of units to include in formatter output (default: unlimited) */
|
|
40
|
+
maxUnits?: number | undefined;
|
|
41
|
+
/** Custom unit labels for formatter */
|
|
42
|
+
unitLabels?: {
|
|
43
|
+
week?: string | ((_value: number) => string) | undefined;
|
|
44
|
+
day?: string | ((_value: number) => string) | undefined;
|
|
45
|
+
hour?: string | ((_value: number) => string) | undefined;
|
|
46
|
+
minute?: string | ((_value: number) => string) | undefined;
|
|
47
|
+
second?: string | ((_value: number) => string) | undefined;
|
|
48
|
+
millisecond?: string | ((_value: number) => string) | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Predefined time format styles for elapsed time display.
|
|
53
|
+
*
|
|
54
|
+
* - `concise` - Ultra-compact single-letter units: "1h 30m 45s"
|
|
55
|
+
* - `short` - Abbreviated readable units: "1hr 30min 45sec"
|
|
56
|
+
* - `medium` - Balanced readability: "1 hour 30 min 45 sec"
|
|
57
|
+
* - `long` - Full English words with pluralization: "1 hour 30 minutes 45 seconds"
|
|
58
|
+
* - `mostSignificant` - Only the 2 most significant units: "1 hour 30 min"
|
|
59
|
+
* - `time` - Clock format with hours and minutes: "1:30"
|
|
60
|
+
* - `timeWithSeconds` - Extended clock format: "1:30:45"
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const elapsed = new ElapsedTime(5425000); // 1h 30m 25s
|
|
65
|
+
*
|
|
66
|
+
* elapsed.Format('concise'); // "1h 30m 25s"
|
|
67
|
+
* elapsed.Format('short'); // "1hr 30min 25sec"
|
|
68
|
+
* elapsed.Format('medium'); // "1 hour 30 min 25 sec"
|
|
69
|
+
* elapsed.Format('long'); // "1 hour 30 minutes 25 seconds"
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export type TTimeElapsedFormats = 'concise' | 'short' | 'medium' | 'long' | 'mostSignificant' | 'time' | 'timeWithSeconds';
|
|
73
|
+
/**
|
|
74
|
+
* Available time unit types for elapsed time calculations and formatting.
|
|
75
|
+
* Each unit represents a standard time component used in duration decomposition.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const units: TTimeUnit[] = ['week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export type TTimeUnit = 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
|
83
|
+
/**
|
|
84
|
+
* Static string label for a time unit.
|
|
85
|
+
* Used for format styles that use fixed labels regardless of value (e.g., "h", "min", "sec").
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const label: TUnitLabelString = "h";
|
|
90
|
+
* const label2: TUnitLabelString = "hour";
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export type TUnitLabelString = string;
|
|
94
|
+
/**
|
|
95
|
+
* Function that generates a time unit label with support for pluralization.
|
|
96
|
+
* Accepts the numeric value and returns the appropriate label string.
|
|
97
|
+
*
|
|
98
|
+
* @param value - The numeric value to determine singular/plural form
|
|
99
|
+
* @returns The appropriate label string (e.g., "hour" or "hours")
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const pluralize: TUnitLabelFunction = (value: number) =>
|
|
104
|
+
* value === 1 ? 'hour' : 'hours';
|
|
105
|
+
*
|
|
106
|
+
* console.log(pluralize(1)); // "hour"
|
|
107
|
+
* console.log(pluralize(2)); // "hours"
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export type TUnitLabelFunction = (value: number) => string;
|
|
111
|
+
/**
|
|
112
|
+
* Unit label as either a static string or a function with pluralization support.
|
|
113
|
+
* Allows flexible label definitions for different formatting styles.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // Static string label
|
|
118
|
+
* const label1: TUnitLabel = "h";
|
|
119
|
+
*
|
|
120
|
+
* // Function-based label with pluralization
|
|
121
|
+
* const label2: TUnitLabel = (value: number) => value === 1 ? 'hour' : 'hours';
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export type TUnitLabel = TUnitLabelString | TUnitLabelFunction;
|
|
125
|
+
/**
|
|
126
|
+
* Mapping of time units to their corresponding labels.
|
|
127
|
+
* Base interface that all unit label configurations implement.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const labels: IUnitLabelMap = {
|
|
132
|
+
* millisecond: 'ms',
|
|
133
|
+
* second: 's',
|
|
134
|
+
* minute: 'm',
|
|
135
|
+
* hour: 'h',
|
|
136
|
+
* day: 'd',
|
|
137
|
+
* week: 'w'
|
|
138
|
+
* };
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export interface IUnitLabelMap {
|
|
142
|
+
/** Label for milliseconds */
|
|
143
|
+
millisecond: TUnitLabel;
|
|
144
|
+
/** Label for seconds */
|
|
145
|
+
second: TUnitLabel;
|
|
146
|
+
/** Label for minutes */
|
|
147
|
+
minute: TUnitLabel;
|
|
148
|
+
/** Label for hours */
|
|
149
|
+
hour: TUnitLabel;
|
|
150
|
+
/** Label for days */
|
|
151
|
+
day: TUnitLabel;
|
|
152
|
+
/** Label for weeks */
|
|
153
|
+
week: TUnitLabel;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Concise format style with single-character unit labels.
|
|
157
|
+
* Used for ultra-compact time representations (e.g., "1h 30m 45s").
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const labels: IConciseUnitLabels = {
|
|
162
|
+
* style: 'concise',
|
|
163
|
+
* millisecond: 'ms',
|
|
164
|
+
* second: 's',
|
|
165
|
+
* minute: 'm',
|
|
166
|
+
* hour: 'h',
|
|
167
|
+
* day: 'd',
|
|
168
|
+
* week: 'w'
|
|
169
|
+
* };
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export interface IConciseUnitLabels extends IUnitLabelMap {
|
|
173
|
+
readonly style?: 'concise';
|
|
174
|
+
millisecond: 'ms';
|
|
175
|
+
second: 's';
|
|
176
|
+
minute: 'm';
|
|
177
|
+
hour: 'h';
|
|
178
|
+
day: 'd';
|
|
179
|
+
week: 'w';
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Long format style with full English words and proper pluralization support.
|
|
183
|
+
* Used for readable time representations (e.g., "1 hour 30 minutes 45 seconds").
|
|
184
|
+
* All labels are functions that handle singular/plural forms based on the value.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const labels: ILongUnitLabels = {
|
|
189
|
+
* style: 'long',
|
|
190
|
+
* hour: (value) => value === 1 ? 'hour' : 'hours',
|
|
191
|
+
* minute: (value) => value === 1 ? 'minute' : 'minutes'
|
|
192
|
+
* };
|
|
193
|
+
*
|
|
194
|
+
* labels.hour(1); // "hour"
|
|
195
|
+
* labels.hour(2); // "hours"
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export interface ILongUnitLabels extends IUnitLabelMap {
|
|
199
|
+
readonly style?: 'long';
|
|
200
|
+
millisecond: TUnitLabelFunction;
|
|
201
|
+
second: TUnitLabelFunction;
|
|
202
|
+
minute: TUnitLabelFunction;
|
|
203
|
+
hour: TUnitLabelFunction;
|
|
204
|
+
day: TUnitLabelFunction;
|
|
205
|
+
week: TUnitLabelFunction;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Medium format style with abbreviated but readable unit labels.
|
|
209
|
+
* Provides a balanced middle ground between concise and long formats.
|
|
210
|
+
* Used for moderately compact time representations (e.g., "1 hour 30 min 45 sec").
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const labels: IMediumUnitLabels = {
|
|
215
|
+
* style: 'medium',
|
|
216
|
+
* millisecond: 'ms',
|
|
217
|
+
* second: 'sec',
|
|
218
|
+
* minute: 'min',
|
|
219
|
+
* hour: 'hour',
|
|
220
|
+
* day: 'day',
|
|
221
|
+
* week: 'week'
|
|
222
|
+
* };
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
export interface IMediumUnitLabels extends IUnitLabelMap {
|
|
226
|
+
readonly style?: 'medium';
|
|
227
|
+
millisecond: 'ms';
|
|
228
|
+
second: 'sec';
|
|
229
|
+
minute: 'min';
|
|
230
|
+
hour: 'hour';
|
|
231
|
+
day: 'day';
|
|
232
|
+
week: 'week';
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Short format style with short but readable abbreviations.
|
|
236
|
+
* Provides compact labels that remain more readable than concise format.
|
|
237
|
+
* Used for semi-compact time representations (e.g., "1hr 30min 45sec").
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* const labels: IShortUnitLabels = {
|
|
242
|
+
* style: 'short',
|
|
243
|
+
* millisecond: 'ms',
|
|
244
|
+
* second: 'sec',
|
|
245
|
+
* minute: 'min',
|
|
246
|
+
* hour: 'hr',
|
|
247
|
+
* day: 'd',
|
|
248
|
+
* week: 'wk'
|
|
249
|
+
* };
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export interface IShortUnitLabels extends IUnitLabelMap {
|
|
253
|
+
readonly style?: 'short';
|
|
254
|
+
millisecond: 'ms';
|
|
255
|
+
second: 'sec';
|
|
256
|
+
minute: 'min';
|
|
257
|
+
hour: 'hr';
|
|
258
|
+
day: 'd';
|
|
259
|
+
week: 'wk';
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Complete set of default unit label configurations for all predefined formatting styles.
|
|
263
|
+
* Maps format style names to their corresponding unit label sets.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const conciseLabels = {
|
|
268
|
+
* concise: { style: 'concise', hour: 'h', minute: 'm', second: 's' },
|
|
269
|
+
* long: { style: 'long', hour: (v) => v === 1 ? 'hour' : 'hours' },
|
|
270
|
+
* medium: { style: 'medium', hour: 'hour', minute: 'min', second: 'sec' },
|
|
271
|
+
* short: { style: 'short', hour: 'hr', minute: 'min', second: 'sec' }
|
|
272
|
+
* };
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
export interface IDefaultUnitLabels {
|
|
276
|
+
concise: IConciseUnitLabels;
|
|
277
|
+
long: ILongUnitLabels;
|
|
278
|
+
medium: IMediumUnitLabels;
|
|
279
|
+
short: IShortUnitLabels;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Configuration options for the FormatElapsedTime convenience function.
|
|
283
|
+
* Allows customization of the output format through maxUnits and custom unit labels.
|
|
284
|
+
* Always formats using the 'concise' style with optional overrides.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* // Limit to 2 units
|
|
289
|
+
* const config1: IFormatConfig = { maxUnits: 2 };
|
|
290
|
+
* FormatElapsedTime(5425000, config1); // "1h 30m"
|
|
291
|
+
*
|
|
292
|
+
* // Custom labels
|
|
293
|
+
* const config2: IFormatConfig = {
|
|
294
|
+
* unitLabels: { hour: 'hrs', minute: 'mins', second: 'secs' }
|
|
295
|
+
* };
|
|
296
|
+
* FormatElapsedTime(3661000, config2); // "1 hrs 1 mins 1 secs"
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
export interface IFormatConfig {
|
|
300
|
+
/** Maximum number of units to display */
|
|
301
|
+
maxUnits?: number;
|
|
302
|
+
/** Unit labels to use for formatting. When omitted, the format's default labels are used. */
|
|
303
|
+
unitLabels?: Partial<IUnitLabelMap>;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Mapping of all predefined elapsed time format styles to their configurations.
|
|
307
|
+
* Each format provides a complete IFormatConfig with specific unitLabels and optional settings.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* const config: IFormatConfig = {
|
|
312
|
+
* unitLabels: { hour: 'h', minute: 'm', second: 's' },
|
|
313
|
+
* maxUnits: undefined
|
|
314
|
+
* };
|
|
315
|
+
*
|
|
316
|
+
* const elapsed = new ElapsedTime(5425000);
|
|
317
|
+
* elapsed.Format('concise'); // Uses FORMATS.concise configuration
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
export interface IFormats {
|
|
321
|
+
/** Format like "1h 30m 45s" */
|
|
322
|
+
concise: IFormatConfig;
|
|
323
|
+
/** Format like "1 hour 30 minutes 45 seconds" with proper pluralization */
|
|
324
|
+
long: IFormatConfig;
|
|
325
|
+
/** Format like "1 hour 30 min 45 sec" */
|
|
326
|
+
medium: IFormatConfig;
|
|
327
|
+
/** Format showing only the most significant 2 units */
|
|
328
|
+
mostSignificant: IFormatConfig;
|
|
329
|
+
/** Format like "1hr 30min 45sec" */
|
|
330
|
+
short: IFormatConfig;
|
|
331
|
+
/** Format showing only hours and minutes like "1:30" */
|
|
332
|
+
time: IFormatConfig;
|
|
333
|
+
/** Format showing hours, minutes and seconds like "1:30:45" */
|
|
334
|
+
timeWithSeconds: IFormatConfig;
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/time/elapsed-time/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC9B,wEAAwE;IACxE,IAAI,EAAE,SAAS,CAAC;IAChB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,yBAAyB;IACzC,mKAAmK;IACnK,mBAAmB,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;IACxF,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,uCAAuC;IACvC,UAAU,CAAC,EAAE;QACZ,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;QACz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AED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -13,6 +13,4 @@ export * from './elapsed-time/constants.js';
|
|
|
13
13
|
export * from './elapsed-time/utils.js';
|
|
14
14
|
export * from './stopwatch/stopwatch.js';
|
|
15
15
|
export * from './stopwatch/entry.js';
|
|
16
|
-
export * from './stopwatch/entry-types.js';
|
|
17
|
-
export type { TUnitLabel, TUnitLabelString, TUnitLabelFunction, IUnitLabelMap, IConciseUnitLabels, ILongUnitLabels, IMediumUnitLabels, IShortUnitLabels, IDefaultUnitLabels, IFormatConfig, IFormats, } from './elapsed-time/types.js';
|
|
18
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/time/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/time/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../../src/time/stopwatch/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,cAAc;IAed,OAAO,CAAC,QAAQ,CAAC,UAAU;IAdvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0B;IAErD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IAErC;;;;;;;;;OASG;gBAC0B,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM;IAOtF;;;;;;;;;OASG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAW,OAAO,IAAI,WAAW,CAUhC;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAW,YAAY,IAAI,WAAW,CAUrC;CACD"}
|
|
@@ -117,11 +117,12 @@ export declare class Stopwatch {
|
|
|
117
117
|
/**
|
|
118
118
|
* Starts the stopwatch by recording an initial timestamp entry.
|
|
119
119
|
*
|
|
120
|
-
* If the stopwatch has already been started, this is
|
|
120
|
+
* If the stopwatch has already been started, this is idempotent and the
|
|
121
121
|
* existing latest entry is returned without creating a new one.
|
|
122
122
|
*
|
|
123
|
-
* @returns The start
|
|
124
|
-
*
|
|
123
|
+
* @returns The new start entry if the stopwatch was not running,
|
|
124
|
+
* or the existing latest entry if `Start()` was called while already running.
|
|
125
|
+
* Check `this.Running` before calling to distinguish the two cases.
|
|
125
126
|
*
|
|
126
127
|
* @example
|
|
127
128
|
* ```typescript
|
|
@@ -181,6 +182,11 @@ export declare class Stopwatch {
|
|
|
181
182
|
* After resuming, elapsed-time calculations continue to accumulate from where
|
|
182
183
|
* they left off.
|
|
183
184
|
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* Calling `Resume()` after {@link Stop} has no effect and returns `null`, since
|
|
187
|
+
* `Stop()` sets the internal `_pausedAt` flag to a non-null value. The stopwatch
|
|
188
|
+
* must be explicitly {@link Reset} and {@link Start}ed again to begin timing anew.
|
|
189
|
+
*
|
|
184
190
|
* @returns A new {@link StopwatchEntry} recording the resume time, or `null`
|
|
185
191
|
* if the stopwatch was not paused.
|
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G;IACI,KAAK,IAAI,cAAc;IAW9B;;;;;;;;;;;;;;;;;;OAkBG;IACI,GAAG,IAAI,WAAW;IAUzB;;;;;;;;;;;;;;;OAeG;IACI,KAAK,IAAI,IAAI;CAKpB"}
|
|
@@ -144,11 +144,12 @@ export class Stopwatch {
|
|
|
144
144
|
/**
|
|
145
145
|
* Starts the stopwatch by recording an initial timestamp entry.
|
|
146
146
|
*
|
|
147
|
-
* If the stopwatch has already been started, this is
|
|
147
|
+
* If the stopwatch has already been started, this is idempotent and the
|
|
148
148
|
* existing latest entry is returned without creating a new one.
|
|
149
149
|
*
|
|
150
|
-
* @returns The start
|
|
151
|
-
*
|
|
150
|
+
* @returns The new start entry if the stopwatch was not running,
|
|
151
|
+
* or the existing latest entry if `Start()` was called while already running.
|
|
152
|
+
* Check `this.Running` before calling to distinguish the two cases.
|
|
152
153
|
*
|
|
153
154
|
* @example
|
|
154
155
|
* ```typescript
|
|
@@ -238,6 +239,11 @@ export class Stopwatch {
|
|
|
238
239
|
* After resuming, elapsed-time calculations continue to accumulate from where
|
|
239
240
|
* they left off.
|
|
240
241
|
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* Calling `Resume()` after {@link Stop} has no effect and returns `null`, since
|
|
244
|
+
* `Stop()` sets the internal `_pausedAt` flag to a non-null value. The stopwatch
|
|
245
|
+
* must be explicitly {@link Reset} and {@link Start}ed again to begin timing anew.
|
|
246
|
+
*
|
|
241
247
|
* @returns A new {@link StopwatchEntry} recording the resume time, or `null`
|
|
242
248
|
* if the stopwatch was not paused.
|
|
243
249
|
*
|
|
@@ -334,4 +340,3 @@ export class Stopwatch {
|
|
|
334
340
|
this._stopped = false;
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
|
-
//# sourceMappingURL=stopwatch.js.map
|
package/package.json
CHANGED
|
@@ -1,83 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"author": "Phillip Aaron Wells",
|
|
61
|
-
"license": "MIT",
|
|
62
|
-
"repository": {
|
|
63
|
-
"type": "git",
|
|
64
|
-
"url": "git+https://github.com/PhillipAWells/typescript-common.git"
|
|
65
|
-
},
|
|
66
|
-
"bugs": {
|
|
67
|
-
"url": "https://github.com/PhillipAWells/typescript-common/issues"
|
|
68
|
-
},
|
|
69
|
-
"homepage": "https://github.com/PhillipAWells/typescript-common#readme",
|
|
70
|
-
"engines": {
|
|
71
|
-
"node": ">=22.0.0"
|
|
72
|
-
},
|
|
73
|
-
"packageManager": "yarn@4.12.0",
|
|
74
|
-
"files": [
|
|
75
|
-
"build/",
|
|
76
|
-
"README.md",
|
|
77
|
-
"LICENSE",
|
|
78
|
-
".env.example"
|
|
79
|
-
],
|
|
80
|
-
"publishConfig": {
|
|
81
|
-
"access": "public"
|
|
82
|
-
}
|
|
2
|
+
"name": "@pawells/typescript-common",
|
|
3
|
+
"displayName": "TypeScript Common Library",
|
|
4
|
+
"description": "Shared TypeScript utility library",
|
|
5
|
+
"version": "2.1.5",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Phillip Aaron Wells",
|
|
9
|
+
"email": "phillip.aaron.wells@gmail.com"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/PhillipAWells/typescript-common",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/PhillipAWells/typescript-common.git"
|
|
15
|
+
},
|
|
16
|
+
"funding": {
|
|
17
|
+
"type": "github",
|
|
18
|
+
"url": "https://github.com/sponsors/PhillipAWells"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
"./package.json": "./package.json",
|
|
25
|
+
".": {
|
|
26
|
+
"@pawells/typescript-common-workspace": "./src/index.ts",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"!**/*.tsbuildinfo"
|
|
35
|
+
],
|
|
36
|
+
"keywords": [
|
|
37
|
+
"typescript",
|
|
38
|
+
"utilities",
|
|
39
|
+
"common",
|
|
40
|
+
"library"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22.0.0"
|
|
44
|
+
},
|
|
45
|
+
"nx": {
|
|
46
|
+
"name": "@pawells/typescript-common",
|
|
47
|
+
"tags": [
|
|
48
|
+
"npm:public"
|
|
49
|
+
],
|
|
50
|
+
"targets": {
|
|
51
|
+
"clean": {
|
|
52
|
+
"executor": "nx:run-commands",
|
|
53
|
+
"options": {
|
|
54
|
+
"command": "rm -rf dist tsconfig.*.tsbuildinfo",
|
|
55
|
+
"cwd": "packages/typescript-common"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
83
60
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Phillip Aaron Wells
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-chunk.js","sourceRoot":"","sources":["../../src/array/array-chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAI,KAAmB,EAAE,IAAY;IAC9D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,MAAM,GAAU,EAAE,CAAC;IAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-compact.js","sourceRoot":"","sources":["../../src/array/array-compact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAI,KAA+B;IAC9D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAa,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-contains.js","sourceRoot":"","sources":["../../src/array/array-contains.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAI,KAAmB,EAAE,SAAwB;IAC7E,uEAAuE;IACvE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-count-by.js","sourceRoot":"","sources":["../../src/array/array-count-by.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,YAAY,CAC3B,KAAmB,EACnB,KAAuB;IAEvB,gEAAgE;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,EAAuB,CAAC;IAE3C,MAAM,MAAM,GAAG,EAAuB,CAAC;IAEvC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE,MAAM,CAAC,GAAG,CAAwB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-difference.d.ts","sourceRoot":"","sources":["../../src/array/array-difference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAClC,CAAC,EAAE,CAiBL"}
|