@pawells/typescript-common 1.4.1 → 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 -223
- 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 +4 -1
- package/{build → dist}/array/array-contains.d.ts.map +1 -1
- package/{build → dist}/array/array-contains.js +6 -3
- package/{build → dist}/array/array-count-by.d.ts +3 -1
- package/dist/array/array-count-by.d.ts.map +1 -0
- package/{build → dist}/array/array-count-by.js +4 -2
- package/dist/array/array-difference.d.ts +43 -0
- 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 +3 -1
- package/{build → dist}/array/array-filter.d.ts.map +1 -1
- package/{build → dist}/array/array-filter.js +5 -3
- 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 +3 -1
- package/dist/array/array-group-by.d.ts.map +1 -0
- package/{build → dist}/array/array-group-by.js +12 -8
- package/dist/array/array-intersection.d.ts +43 -0
- 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 +3 -1
- package/{build → dist}/array/array-partition.d.ts.map +1 -1
- package/{build → dist}/array/array-partition.js +4 -2
- 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 +4 -4
- package/dist/array/array-sample.d.ts.map +1 -0
- package/{build → dist}/array/array-sample.js +4 -14
- 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 +27 -23
- package/dist/array/assert.d.ts.map +1 -0
- package/{build → dist}/array/assert.js +40 -37
- package/{build → dist}/array/index.js +0 -1
- package/{build → dist}/array/types.d.ts +29 -0
- package/dist/array/types.d.ts.map +1 -0
- package/dist/array/types.js +1 -0
- package/{build → dist}/array/unique.d.ts +3 -1
- package/{build → dist}/array/unique.d.ts.map +1 -1
- package/{build → dist}/array/unique.js +5 -3
- package/dist/asserts/errors.d.ts.map +1 -0
- package/{build → dist}/asserts/errors.js +5 -3
- package/{build → dist}/asserts/generic.d.ts +32 -3
- package/dist/asserts/generic.d.ts.map +1 -0
- package/{build → dist}/asserts/generic.js +63 -15
- 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 +18 -2
- package/dist/asserts/utils.d.ts.map +1 -0
- package/{build → dist}/asserts/utils.js +56 -1
- 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 +3 -8
- 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 +9 -2
- package/dist/function/compose.d.ts.map +1 -0
- package/{build → dist}/function/compose.js +0 -1
- package/{build → dist}/function/debounce.d.ts +8 -1
- 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 +1 -0
- package/{build → dist}/function/once.d.ts.map +1 -1
- package/{build → dist}/function/once.js +2 -1
- package/{build → dist}/function/sleep.js +0 -1
- package/dist/function/throttle.d.ts +25 -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.d.ts.map +1 -1
- package/{build → dist}/number/assert.js +38 -43
- 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 +11 -5
- package/{build → dist}/object/equals.d.ts +1 -1
- package/{build → dist}/object/equals.d.ts.map +1 -1
- package/{build → dist}/object/equals.js +12 -9
- 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 +1 -1
- package/{build → dist}/object/filter.d.ts.map +1 -1
- package/{build → dist}/object/filter.js +38 -70
- 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 +5 -1
- package/dist/object/hash.d.ts.map +1 -0
- package/{build → dist}/object/hash.js +20 -6
- 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.d.ts +2 -2
- package/{build → dist}/object/property-paths.d.ts.map +1 -1
- package/{build → dist}/object/property-paths.js +13 -9
- 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 +61 -20
- 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 +14 -10
- package/dist/string/case-conversion.d.ts +79 -0
- package/dist/string/case-conversion.d.ts.map +1 -0
- package/{build → dist}/string/case-conversion.js +59 -30
- package/dist/string/comparison.d.ts +20 -0
- package/dist/string/comparison.d.ts.map +1 -0
- package/dist/string/comparison.js +27 -0
- package/{build → dist}/string/formatting.d.ts +35 -22
- package/dist/string/formatting.d.ts.map +1 -0
- package/{build → dist}/string/formatting.js +40 -25
- package/{build → dist}/string/index.d.ts +1 -0
- package/{build → dist}/string/index.d.ts.map +1 -1
- package/{build → dist}/string/index.js +1 -1
- package/dist/string/transformation.d.ts +28 -0
- package/dist/string/transformation.d.ts.map +1 -0
- package/dist/string/transformation.js +42 -0
- 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/dist/string/validation.d.ts +30 -0
- package/dist/string/validation.d.ts.map +1 -0
- package/dist/string/validation.js +38 -0
- 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.d.ts.map +0 -1
- package/build/array/array-count-by.js.map +0 -1
- package/build/array/array-difference.d.ts +0 -25
- package/build/array/array-difference.d.ts.map +0 -1
- package/build/array/array-difference.js +0 -34
- 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.d.ts.map +0 -1
- package/build/array/array-group-by.js.map +0 -1
- package/build/array/array-intersection.d.ts +0 -25
- package/build/array/array-intersection.d.ts.map +0 -1
- package/build/array/array-intersection.js +0 -39
- 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.d.ts.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.d.ts.map +0 -1
- package/build/array/assert.js.map +0 -1
- package/build/array/index.js.map +0 -1
- package/build/array/types.d.ts.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 +0 -17
- 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.d.ts +0 -50
- package/build/string/case-conversion.d.ts.map +0 -1
- package/build/string/case-conversion.js.map +0 -1
- package/build/string/formatting.d.ts.map +0 -1
- package/build/string/formatting.js.map +0 -1
- package/build/string/index.js.map +0 -1
- package/build/string/transformation.d.ts +0 -18
- package/build/string/transformation.d.ts.map +0 -1
- package/build/string/transformation.js +0 -32
- 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.d.ts +0 -18
- package/build/string/validation.d.ts.map +0 -1
- package/build/string/validation.js +0 -26
- 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-element.d.ts +0 -0
- /package/{build → dist}/array/array-element.d.ts.map +0 -0
- /package/{build → dist}/array/array-range.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}/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/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}/object/clone.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
|
@@ -1,17 +1,61 @@
|
|
|
1
1
|
import { ObjectEquals } from './internal-utils.js';
|
|
2
2
|
import { SetExceptionClass, SetExceptionMessage, ThrowException } from './utils.js';
|
|
3
3
|
import { AssertionError, SimpleError } from './errors.js';
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Serializes a value to a human-readable string, safe for any value type.
|
|
6
|
+
*
|
|
7
|
+
* Prevents sensitive data exposure in error messages by:
|
|
8
|
+
* - Masking object contents (shows type name only, not property values)
|
|
9
|
+
* - Truncating long strings with a clear indication
|
|
10
|
+
* - Handling non-serializable values gracefully
|
|
11
|
+
*
|
|
12
|
+
* @param value - The value to serialize for display
|
|
13
|
+
* @param maxLength - Maximum characters to display for primitives (default: 50, capped at 10,000)
|
|
14
|
+
* @returns A safe string representation (at most maxLength chars plus "[truncated]" suffix)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* safeDisplay({ apiKey: 'secret123', username: 'john' }); // '[Object]'
|
|
18
|
+
* safeDisplay('x'.repeat(100)); // 'xxx....[truncated]'
|
|
19
|
+
* safeDisplay(circularRef); // '[non-serializable]'
|
|
20
|
+
*
|
|
21
|
+
* @internal Used internally by assertion functions to safely display values in error messages
|
|
22
|
+
*/
|
|
23
|
+
export function safeDisplay(value, maxLength = 50) {
|
|
24
|
+
// Cap maxLength to prevent memory exhaustion from extremely large values
|
|
25
|
+
const effectiveMaxLength = Math.min(maxLength, 10_000);
|
|
26
|
+
// For objects, use type name instead of full serialization to avoid leaking structure
|
|
27
|
+
if (typeof value === 'object' && value !== null) {
|
|
28
|
+
return `[${Object.getPrototypeOf(value)?.constructor?.name ?? 'Object'}]`;
|
|
29
|
+
}
|
|
30
|
+
// For primitives, truncate with clear indication
|
|
8
31
|
try {
|
|
9
|
-
|
|
32
|
+
const serialized = JSON.stringify(value) ?? String(value);
|
|
33
|
+
return serialized.length > effectiveMaxLength
|
|
34
|
+
? serialized.slice(0, effectiveMaxLength) + '...[truncated]'
|
|
35
|
+
: serialized;
|
|
10
36
|
}
|
|
11
37
|
catch {
|
|
12
|
-
return
|
|
38
|
+
return '[non-serializable]';
|
|
13
39
|
}
|
|
14
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the display type of a value including null and undefined.
|
|
43
|
+
* Used for error messages in null/undefined assertions and type checking.
|
|
44
|
+
*
|
|
45
|
+
* @param value - The value to get the type of
|
|
46
|
+
* @returns A string representation of the value's type ('null', 'undefined', 'array', 'object', or typeof)
|
|
47
|
+
* @internal Used internally by assertion functions for consistent type messages
|
|
48
|
+
*/
|
|
49
|
+
export function GetValueType(value) {
|
|
50
|
+
if (value === null)
|
|
51
|
+
return 'null';
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return 'undefined';
|
|
54
|
+
if (typeof value === 'object') {
|
|
55
|
+
return Array.isArray(value) ? 'array' : 'object';
|
|
56
|
+
}
|
|
57
|
+
return typeof value;
|
|
58
|
+
}
|
|
15
59
|
/**
|
|
16
60
|
* Error thrown when a nullish assertion fails — the value is not null or undefined
|
|
17
61
|
* but was expected to be. Used by {@link AssertNull} when the provided value is a
|
|
@@ -270,7 +314,8 @@ export function AssertNotEquals(value, expected, exception = {}) {
|
|
|
270
314
|
export function AssertNull(value, exception = {}) {
|
|
271
315
|
SetExceptionClass(exception, NullError);
|
|
272
316
|
if (value !== null && value !== undefined) {
|
|
273
|
-
|
|
317
|
+
const actualType = GetValueType(value);
|
|
318
|
+
SetExceptionMessage(exception, `Expected null or undefined but received ${actualType}: ${safeDisplay(value)}`);
|
|
274
319
|
ThrowException(exception);
|
|
275
320
|
}
|
|
276
321
|
}
|
|
@@ -309,8 +354,8 @@ export function AssertNull(value, exception = {}) {
|
|
|
309
354
|
export function AssertNotNull(value, exception = {}) {
|
|
310
355
|
SetExceptionClass(exception, NotNullError);
|
|
311
356
|
if (value === null || value === undefined) {
|
|
312
|
-
const
|
|
313
|
-
SetExceptionMessage(exception, `Expected non-null/non-undefined value but received ${
|
|
357
|
+
const actualType = GetValueType(value);
|
|
358
|
+
SetExceptionMessage(exception, `Expected non-null/non-undefined value but received ${actualType}`);
|
|
314
359
|
ThrowException(exception);
|
|
315
360
|
}
|
|
316
361
|
}
|
|
@@ -398,8 +443,8 @@ export function AssertPredicate(value, predicate, exception = {}) {
|
|
|
398
443
|
export function AssertIsType(value, typeGuard, exception = {}) {
|
|
399
444
|
SetExceptionClass(exception, TypeGuardError);
|
|
400
445
|
if (!typeGuard(value)) {
|
|
401
|
-
const actualType = value
|
|
402
|
-
SetExceptionMessage(exception, `Expected value to conform to required type but received ${actualType}: ${
|
|
446
|
+
const actualType = GetValueType(value);
|
|
447
|
+
SetExceptionMessage(exception, `Expected value to conform to required type but received ${actualType}: ${safeDisplay(value)}`);
|
|
403
448
|
ThrowException(exception);
|
|
404
449
|
}
|
|
405
450
|
}
|
|
@@ -440,7 +485,10 @@ export function AssertIsType(value, typeGuard, exception = {}) {
|
|
|
440
485
|
export function AssertInstanceOf(value, constructor, exception = {}) {
|
|
441
486
|
SetExceptionClass(exception, InstanceOfError);
|
|
442
487
|
if (!(value instanceof constructor)) {
|
|
443
|
-
|
|
488
|
+
let actualType = GetValueType(value);
|
|
489
|
+
if (actualType === 'object' && value !== null && typeof value === 'object') {
|
|
490
|
+
actualType = value.constructor?.name ?? 'object';
|
|
491
|
+
}
|
|
444
492
|
SetExceptionMessage(exception, `Expected instance of ${constructor.name} but received ${actualType}`);
|
|
445
493
|
ThrowException(exception);
|
|
446
494
|
}
|
|
@@ -465,7 +513,7 @@ export function AssertInstanceOf(value, constructor, exception = {}) {
|
|
|
465
513
|
export function AssertFunction(value, exception = {}) {
|
|
466
514
|
SetExceptionClass(exception, FunctionError);
|
|
467
515
|
if (typeof value !== 'function') {
|
|
468
|
-
const actualType = value
|
|
516
|
+
const actualType = GetValueType(value);
|
|
469
517
|
SetExceptionMessage(exception, `Expected function but received ${actualType}`);
|
|
470
518
|
ThrowException(exception);
|
|
471
519
|
}
|
|
@@ -490,7 +538,7 @@ export function AssertFunction(value, exception = {}) {
|
|
|
490
538
|
export function AssertSymbol(value, exception = {}) {
|
|
491
539
|
SetExceptionClass(exception, SymbolError);
|
|
492
540
|
if (typeof value !== 'symbol') {
|
|
493
|
-
const actualType = value
|
|
541
|
+
const actualType = GetValueType(value);
|
|
494
542
|
SetExceptionMessage(exception, `Expected symbol but received ${actualType}`);
|
|
495
543
|
ThrowException(exception);
|
|
496
544
|
}
|
|
@@ -513,6 +561,7 @@ export function AssertSymbol(value, exception = {}) {
|
|
|
513
561
|
* AssertExtends(Derived, Base); // ✓ Valid
|
|
514
562
|
* AssertExtends(Base, Derived); // ✗ Throws ExtendsError
|
|
515
563
|
*/
|
|
564
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
516
565
|
export function AssertExtends(derived, base, exception = {}) {
|
|
517
566
|
SetExceptionClass(exception, ExtendsError);
|
|
518
567
|
if (typeof derived !== 'function' || typeof base !== 'function') {
|
|
@@ -534,4 +583,3 @@ export function AssertExtends(derived, base, exception = {}) {
|
|
|
534
583
|
ThrowException(exception);
|
|
535
584
|
}
|
|
536
585
|
}
|
|
537
|
-
//# sourceMappingURL=generic.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module asserts
|
|
3
|
+
* @description Aggregation barrel for all assertion functions.
|
|
4
|
+
* Exports both generic assertion primitives (like AssertNull, AssertNotNull, AssertEquals, etc.)
|
|
5
|
+
* and domain-specific validators (AssertArray, AssertBoolean, AssertNumber, AssertObject, AssertString).
|
|
6
|
+
*
|
|
7
|
+
* Domain-specific assertions are re-exported here as a convenience so callers can import
|
|
8
|
+
* all assertion functions from a single entry point. They originate from their respective
|
|
9
|
+
* domain modules (array/, boolean/, number/, object/, string/).
|
|
10
|
+
*
|
|
11
|
+
* Note: Internal utility functions (SetExceptionClass, SetExceptionMessage, ThrowException,
|
|
12
|
+
* AssertValueType, safeDisplay, GetValueType) are NOT exported from this barrel as they are
|
|
13
|
+
* part of the internal assertion implementation contract and should not be relied upon by external code.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Export all array assertion functions and types
|
|
17
|
+
*/
|
|
18
|
+
export * from '../array/assert.js';
|
|
19
|
+
/**
|
|
20
|
+
* Export all boolean assertion functions and types
|
|
21
|
+
*/
|
|
22
|
+
export * from '../boolean/assert.js';
|
|
23
|
+
/**
|
|
24
|
+
* Export generic assertion functions (but not internal utilities)
|
|
25
|
+
*/
|
|
26
|
+
export { AssertEquals, AssertNotEquals, AssertNull, AssertNotNull, AssertPredicate, AssertIsType, AssertInstanceOf, AssertFunction, AssertSymbol, AssertExtends, NullError, NotNullError, PredicateError, TypeGuardError, InstanceOfError, FunctionError, SymbolError, ExtendsError, type TConstructorFunction, } from './generic.js';
|
|
27
|
+
/**
|
|
28
|
+
* Export all number assertion functions and types
|
|
29
|
+
*/
|
|
30
|
+
export * from '../number/assert.js';
|
|
31
|
+
/**
|
|
32
|
+
* Export all object assertion functions and types
|
|
33
|
+
*/
|
|
34
|
+
export * from '../object/assert.js';
|
|
35
|
+
/**
|
|
36
|
+
* Export all string assertion functions and types
|
|
37
|
+
*/
|
|
38
|
+
export * from '../string/assert.js';
|
|
39
|
+
/**
|
|
40
|
+
* Export type definitions and interfaces
|
|
41
|
+
*/
|
|
42
|
+
export * from './types.js';
|
|
43
|
+
/**
|
|
44
|
+
* Export error classes for standardized error handling
|
|
45
|
+
*/
|
|
46
|
+
export * from './errors.js';
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/asserts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,cAAc,oBAAoB,CAAC;AAEnC;;GAEG;AACH,cAAc,sBAAsB,CAAC;AAErC;;GAEG;AACH,OAAO,EACN,YAAY,EACZ,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,EACZ,KAAK,oBAAoB,GACzB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,cAAc,qBAAqB,CAAC;AAEpC;;GAEG;AACH,cAAc,qBAAqB,CAAC;AAEpC;;GAEG;AACH,cAAc,qBAAqB,CAAC;AAEpC;;GAEG;AACH,cAAc,YAAY,CAAC;AAE3B;;GAEG;AACH,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module asserts
|
|
3
|
+
* @description Aggregation barrel for all assertion functions.
|
|
4
|
+
* Exports both generic assertion primitives (like AssertNull, AssertNotNull, AssertEquals, etc.)
|
|
5
|
+
* and domain-specific validators (AssertArray, AssertBoolean, AssertNumber, AssertObject, AssertString).
|
|
6
|
+
*
|
|
7
|
+
* Domain-specific assertions are re-exported here as a convenience so callers can import
|
|
8
|
+
* all assertion functions from a single entry point. They originate from their respective
|
|
9
|
+
* domain modules (array/, boolean/, number/, object/, string/).
|
|
10
|
+
*
|
|
11
|
+
* Note: Internal utility functions (SetExceptionClass, SetExceptionMessage, ThrowException,
|
|
12
|
+
* AssertValueType, safeDisplay, GetValueType) are NOT exported from this barrel as they are
|
|
13
|
+
* part of the internal assertion implementation contract and should not be relied upon by external code.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Export all array assertion functions and types
|
|
17
|
+
*/
|
|
18
|
+
export * from '../array/assert.js';
|
|
19
|
+
/**
|
|
20
|
+
* Export all boolean assertion functions and types
|
|
21
|
+
*/
|
|
22
|
+
export * from '../boolean/assert.js';
|
|
23
|
+
/**
|
|
24
|
+
* Export generic assertion functions (but not internal utilities)
|
|
25
|
+
*/
|
|
26
|
+
export { AssertEquals, AssertNotEquals, AssertNull, AssertNotNull, AssertPredicate, AssertIsType, AssertInstanceOf, AssertFunction, AssertSymbol, AssertExtends, NullError, NotNullError, PredicateError, TypeGuardError, InstanceOfError, FunctionError, SymbolError, ExtendsError, } from './generic.js';
|
|
27
|
+
/**
|
|
28
|
+
* Export all number assertion functions and types
|
|
29
|
+
*/
|
|
30
|
+
export * from '../number/assert.js';
|
|
31
|
+
/**
|
|
32
|
+
* Export all object assertion functions and types
|
|
33
|
+
*/
|
|
34
|
+
export * from '../object/assert.js';
|
|
35
|
+
/**
|
|
36
|
+
* Export all string assertion functions and types
|
|
37
|
+
*/
|
|
38
|
+
export * from '../string/assert.js';
|
|
39
|
+
/**
|
|
40
|
+
* Export type definitions and interfaces
|
|
41
|
+
*/
|
|
42
|
+
export * from './types.js';
|
|
43
|
+
/**
|
|
44
|
+
* Export error classes for standardized error handling
|
|
45
|
+
*/
|
|
46
|
+
export * from './errors.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-utils.d.ts","sourceRoot":"","sources":["../../src/asserts/internal-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;
|
|
1
|
+
{"version":3,"file":"internal-utils.d.ts","sourceRoot":"","sources":["../../src/asserts/internal-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AAEH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAGxF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import { TConstructableObject } from './internal-utils.js';
|
|
2
|
-
/**
|
|
3
|
-
* Type alias for constraint union patterns.
|
|
4
|
-
* Represents common constraint combinations used across assertion modules.
|
|
5
|
-
*/
|
|
6
|
-
export type TConstraintValue = string | number | boolean | null | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Type alias for comparison operators.
|
|
9
|
-
* Represents the various comparison operations available in constraint validation.
|
|
10
|
-
*/
|
|
11
|
-
export type TComparisonOperator = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
12
|
-
/**
|
|
13
|
-
* Type alias for validation result patterns.
|
|
14
|
-
* Represents the union of possible validation outcomes.
|
|
15
|
-
*/
|
|
16
|
-
export type TValidationResult = true | Error;
|
|
1
|
+
import type { TConstructableObject } from './internal-utils.js';
|
|
17
2
|
/**
|
|
18
3
|
* Configuration interface for assertion exception handling.
|
|
19
4
|
*
|
|
@@ -27,7 +12,6 @@ export type TValidationResult = true | Error;
|
|
|
27
12
|
* defaults for unconfigured options.
|
|
28
13
|
*
|
|
29
14
|
* @interface IAssertException
|
|
30
|
-
* @since 1.0.0
|
|
31
15
|
*
|
|
32
16
|
* @example
|
|
33
17
|
* Basic usage with custom messages:
|
|
@@ -139,6 +123,14 @@ export interface IAssertException {
|
|
|
139
123
|
* @template T - The type being guarded
|
|
140
124
|
* @param value - The value to check
|
|
141
125
|
* @returns true if value is of type T, false otherwise
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const isString: TGuard<string> = (value): value is string => typeof value === 'string';
|
|
130
|
+
* if (isString(input)) {
|
|
131
|
+
* // input is now typed as string
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
142
134
|
*/
|
|
143
135
|
export type TGuard<T> = (value: unknown) => value is T;
|
|
144
136
|
/**
|
|
@@ -146,6 +138,14 @@ export type TGuard<T> = (value: unknown) => value is T;
|
|
|
146
138
|
* @template T - The type of value being validated
|
|
147
139
|
* @param value - The value to validate
|
|
148
140
|
* @returns true if valid, false otherwise
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const isPositive: TValidationPredicate<number> = (value) => value > 0;
|
|
145
|
+
* if (isPositive(count)) {
|
|
146
|
+
* // count is valid
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
149
|
*/
|
|
150
150
|
export type TValidationPredicate<T = unknown> = (value: T) => boolean;
|
|
151
151
|
/**
|
|
@@ -153,6 +153,15 @@ export type TValidationPredicate<T = unknown> = (value: T) => boolean;
|
|
|
153
153
|
* @template T - The element type
|
|
154
154
|
* @param value - The value to check
|
|
155
155
|
* @returns true if value is an array of type T[], false otherwise
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const isStringArray: TArrayTypeGuard<string> = (value): value is string[] =>
|
|
160
|
+
* Array.isArray(value) && value.every(item => typeof item === 'string');
|
|
161
|
+
* if (isStringArray(items)) {
|
|
162
|
+
* // items is now typed as string[]
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
156
165
|
*/
|
|
157
166
|
export type TArrayTypeGuard<T> = (value: unknown) => value is T[];
|
|
158
167
|
/**
|
|
@@ -160,6 +169,16 @@ export type TArrayTypeGuard<T> = (value: unknown) => value is T[];
|
|
|
160
169
|
* @template T - The object type
|
|
161
170
|
* @param value - The value to check
|
|
162
171
|
* @returns true if value is of object type T, false otherwise
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* interface User { id: number; name: string; }
|
|
176
|
+
* const isUser: TObjectTypeGuard<User> = (value): value is User =>
|
|
177
|
+
* typeof value === 'object' && value !== null && 'id' in value && 'name' in value;
|
|
178
|
+
* if (isUser(data)) {
|
|
179
|
+
* // data is now typed as User
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
163
182
|
*/
|
|
164
183
|
export type TObjectTypeGuard<T extends object> = (value: unknown) => value is T;
|
|
165
184
|
/**
|
|
@@ -167,6 +186,15 @@ export type TObjectTypeGuard<T extends object> = (value: unknown) => value is T;
|
|
|
167
186
|
* @template T - The non-null type
|
|
168
187
|
* @param value - The value to check
|
|
169
188
|
* @returns true if value is not null or undefined, false otherwise
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const isDefined: TNonNullableGuard<string> = (value): value is string =>
|
|
193
|
+
* value !== null && value !== undefined;
|
|
194
|
+
* if (isDefined(maybeString)) {
|
|
195
|
+
* // maybeString is now typed as string
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
170
198
|
*/
|
|
171
199
|
export type TNonNullableGuard<T> = (value: T | null | undefined) => value is T;
|
|
172
200
|
/**
|
|
@@ -175,6 +203,17 @@ export type TNonNullableGuard<T> = (value: T | null | undefined) => value is T;
|
|
|
175
203
|
* @param value - The value to assert
|
|
176
204
|
* @param message - Optional error message
|
|
177
205
|
* @throws IAssertException if assertion fails
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* const AssertNumber: TAssertFunction<number> = (value, message) => {
|
|
210
|
+
* if (typeof value !== 'number') {
|
|
211
|
+
* throw new Error(message || 'Expected a number');
|
|
212
|
+
* }
|
|
213
|
+
* };
|
|
214
|
+
* AssertNumber(input);
|
|
215
|
+
* // input is now typed as number
|
|
216
|
+
* ```
|
|
178
217
|
*/
|
|
179
218
|
export type TAssertFunction<T = unknown> = (value: unknown, message?: string) => asserts value is T;
|
|
180
219
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/asserts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,EAAE,CAAC;AAElE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,KAAK,KAAK,IAAI,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TConstructableObject } from './internal-utils.js';
|
|
2
|
-
import { IAssertException } from './types.js';
|
|
1
|
+
import type { TConstructableObject } from './internal-utils.js';
|
|
2
|
+
import type { IAssertException } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Throws an exception using the configured error class and message.
|
|
5
5
|
*
|
|
@@ -10,6 +10,7 @@ import { IAssertException } from './types.js';
|
|
|
10
10
|
*
|
|
11
11
|
* @param exception - Exception configuration containing error class and/or message
|
|
12
12
|
* @throws {Error} The configured error class with the specified message, or generic Error if no class specified
|
|
13
|
+
* @internal
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```typescript
|
|
@@ -40,6 +41,7 @@ export declare function ThrowException(exception: IAssertException): void;
|
|
|
40
41
|
* @param exception - Exception configuration object to modify
|
|
41
42
|
* @param errorClass - The error class constructor to set as default
|
|
42
43
|
* @param force - Whether to override existing error class configuration (default: false)
|
|
44
|
+
* @internal
|
|
43
45
|
*
|
|
44
46
|
* @example
|
|
45
47
|
* ```typescript
|
|
@@ -70,6 +72,7 @@ export declare function SetExceptionClass(exception: IAssertException, errorClas
|
|
|
70
72
|
* @param exception - Exception configuration object to modify
|
|
71
73
|
* @param message - The error message to set as default
|
|
72
74
|
* @param force - Whether to override existing error message configuration (default: false)
|
|
75
|
+
* @internal
|
|
73
76
|
*
|
|
74
77
|
* @example
|
|
75
78
|
* ```typescript
|
|
@@ -89,4 +92,17 @@ export declare function SetExceptionClass(exception: IAssertException, errorClas
|
|
|
89
92
|
* ```
|
|
90
93
|
*/
|
|
91
94
|
export declare function SetExceptionMessage(exception: IAssertException, message: string, force?: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* Assert that a value matches an expected type, throwing if it doesn't.
|
|
97
|
+
* Handles primitives (string, number, boolean), arrays, and objects.
|
|
98
|
+
* Delegates type checking logic to a single source of truth for consistent
|
|
99
|
+
* error messages and behavior across all type assertion functions.
|
|
100
|
+
*
|
|
101
|
+
* @param value - The value to check
|
|
102
|
+
* @param expectedType - Expected type string ('string', 'number', 'boolean', 'array', 'object')
|
|
103
|
+
* @param exception - Exception object to populate on failure
|
|
104
|
+
* @throws Throws the exception if type check fails
|
|
105
|
+
* @internal Used internally by type-specific assertion functions
|
|
106
|
+
*/
|
|
107
|
+
export declare function AssertValueType(value: unknown, expectedType: 'string' | 'number' | 'boolean' | 'array' | 'object', exception: IAssertException): asserts value;
|
|
92
108
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/asserts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAInD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAKhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,UAAQ,GAAG,IAAI,CAGpH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,IAAI,CAGrG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,EAClE,SAAS,EAAE,gBAAgB,GACzB,OAAO,CAAC,KAAK,CAuCf"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { safeDisplay, GetValueType } from './generic.js';
|
|
1
2
|
/**
|
|
2
3
|
* Throws an exception using the configured error class and message.
|
|
3
4
|
*
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
*
|
|
9
10
|
* @param exception - Exception configuration containing error class and/or message
|
|
10
11
|
* @throws {Error} The configured error class with the specified message, or generic Error if no class specified
|
|
12
|
+
* @internal
|
|
11
13
|
*
|
|
12
14
|
* @example
|
|
13
15
|
* ```typescript
|
|
@@ -43,6 +45,7 @@ export function ThrowException(exception) {
|
|
|
43
45
|
* @param exception - Exception configuration object to modify
|
|
44
46
|
* @param errorClass - The error class constructor to set as default
|
|
45
47
|
* @param force - Whether to override existing error class configuration (default: false)
|
|
48
|
+
* @internal
|
|
46
49
|
*
|
|
47
50
|
* @example
|
|
48
51
|
* ```typescript
|
|
@@ -77,6 +80,7 @@ export function SetExceptionClass(exception, errorClass, force = false) {
|
|
|
77
80
|
* @param exception - Exception configuration object to modify
|
|
78
81
|
* @param message - The error message to set as default
|
|
79
82
|
* @param force - Whether to override existing error message configuration (default: false)
|
|
83
|
+
* @internal
|
|
80
84
|
*
|
|
81
85
|
* @example
|
|
82
86
|
* ```typescript
|
|
@@ -100,4 +104,55 @@ export function SetExceptionMessage(exception, message, force = false) {
|
|
|
100
104
|
return;
|
|
101
105
|
exception.message = message;
|
|
102
106
|
}
|
|
103
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Assert that a value matches an expected type, throwing if it doesn't.
|
|
109
|
+
* Handles primitives (string, number, boolean), arrays, and objects.
|
|
110
|
+
* Delegates type checking logic to a single source of truth for consistent
|
|
111
|
+
* error messages and behavior across all type assertion functions.
|
|
112
|
+
*
|
|
113
|
+
* @param value - The value to check
|
|
114
|
+
* @param expectedType - Expected type string ('string', 'number', 'boolean', 'array', 'object')
|
|
115
|
+
* @param exception - Exception object to populate on failure
|
|
116
|
+
* @throws Throws the exception if type check fails
|
|
117
|
+
* @internal Used internally by type-specific assertion functions
|
|
118
|
+
*/
|
|
119
|
+
export function AssertValueType(value, expectedType, exception) {
|
|
120
|
+
if (value === null) {
|
|
121
|
+
SetExceptionMessage(exception, `Expected ${expectedType} but received null`);
|
|
122
|
+
ThrowException(exception);
|
|
123
|
+
}
|
|
124
|
+
if (value === undefined) {
|
|
125
|
+
SetExceptionMessage(exception, `Expected ${expectedType} but received undefined`);
|
|
126
|
+
ThrowException(exception);
|
|
127
|
+
}
|
|
128
|
+
if (expectedType === 'array') {
|
|
129
|
+
if (!Array.isArray(value)) {
|
|
130
|
+
const actualType = GetValueType(value);
|
|
131
|
+
SetExceptionMessage(exception, `Expected array but received ${actualType}: ${safeDisplay(value)}`);
|
|
132
|
+
ThrowException(exception);
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (expectedType === 'object') {
|
|
137
|
+
if (typeof value !== 'object') {
|
|
138
|
+
const actualType = GetValueType(value);
|
|
139
|
+
SetExceptionMessage(exception, `Expected object but received ${actualType}: ${safeDisplay(value)}`);
|
|
140
|
+
ThrowException(exception);
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (expectedType === 'number') {
|
|
145
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
146
|
+
const actualType = typeof value === 'number' ? 'NaN' : GetValueType(value);
|
|
147
|
+
SetExceptionMessage(exception, `Expected number but received ${actualType}: ${safeDisplay(value)}`);
|
|
148
|
+
ThrowException(exception);
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// For string and boolean
|
|
153
|
+
const actualType = GetValueType(value);
|
|
154
|
+
if (actualType !== expectedType) {
|
|
155
|
+
SetExceptionMessage(exception, `Expected ${expectedType} but received ${actualType}: ${safeDisplay(value)}`);
|
|
156
|
+
ThrowException(exception);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -24,8 +24,7 @@ export declare class BooleanError extends SimpleError {
|
|
|
24
24
|
* @param value - The value to validate and assert as a boolean primitive
|
|
25
25
|
* @param exception - Optional exception configuration for custom error handling.
|
|
26
26
|
* Can include custom error message, error type, or other metadata.
|
|
27
|
-
* @throws {
|
|
28
|
-
* depends on the exception configuration provided.
|
|
27
|
+
* @throws {BooleanError} When value is not a boolean primitive
|
|
29
28
|
*
|
|
30
29
|
* @example
|
|
31
30
|
* Basic usage with valid boolean values:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/boolean/assert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,WAAW;gBAChC,OAAO,CAAC,EAAE,MAAM;CAG5B;AAED
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/boolean/assert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,WAAW;gBAChC,OAAO,CAAC,EAAE,MAAM;CAG5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,GAAE,gBAAqB,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAGxG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SetExceptionClass,
|
|
1
|
+
import { SetExceptionClass, AssertValueType } from '../asserts/utils.js';
|
|
2
2
|
import { SimpleError } from '../asserts/errors.js';
|
|
3
3
|
/**
|
|
4
4
|
* Error thrown when a value is not a valid boolean or fails a boolean assertion.
|
|
@@ -26,8 +26,7 @@ export class BooleanError extends SimpleError {
|
|
|
26
26
|
* @param value - The value to validate and assert as a boolean primitive
|
|
27
27
|
* @param exception - Optional exception configuration for custom error handling.
|
|
28
28
|
* Can include custom error message, error type, or other metadata.
|
|
29
|
-
* @throws {
|
|
30
|
-
* depends on the exception configuration provided.
|
|
29
|
+
* @throws {BooleanError} When value is not a boolean primitive
|
|
31
30
|
*
|
|
32
31
|
* @example
|
|
33
32
|
* Basic usage with valid boolean values:
|
|
@@ -67,9 +66,5 @@ export class BooleanError extends SimpleError {
|
|
|
67
66
|
*/
|
|
68
67
|
export function AssertBoolean(value, exception = {}) {
|
|
69
68
|
SetExceptionClass(exception, BooleanError);
|
|
70
|
-
|
|
71
|
-
SetExceptionMessage(exception, `Expected boolean but received ${typeof value}: ${String(value)}`);
|
|
72
|
-
ThrowException(exception);
|
|
73
|
-
}
|
|
69
|
+
AssertValueType(value, 'boolean', exception);
|
|
74
70
|
}
|
|
75
|
-
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boolean assertion functions and types.
|
|
3
|
+
*
|
|
4
|
+
* Provides assertion helpers for validating boolean values at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Currently contains only assertion utilities. This module structure is designed
|
|
7
|
+
* to accommodate additional boolean utilities in the future (e.g., conversion,
|
|
8
|
+
* parsing functions).
|
|
9
|
+
*
|
|
10
|
+
* @module boolean
|
|
11
|
+
*/
|
|
12
|
+
export * from './assert.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/boolean/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boolean assertion functions and types.
|
|
3
|
+
*
|
|
4
|
+
* Provides assertion helpers for validating boolean values at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Currently contains only assertion utilities. This module structure is designed
|
|
7
|
+
* to accommodate additional boolean utilities in the future (e.g., conversion,
|
|
8
|
+
* parsing functions).
|
|
9
|
+
*
|
|
10
|
+
* @module boolean
|
|
11
|
+
*/
|
|
12
|
+
export * from './assert.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum-entries.d.ts","sourceRoot":"","sources":["../../src/enum/enum-entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAIzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum-key-by-value.d.ts","sourceRoot":"","sources":["../../src/enum/enum-key-by-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAQ3G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum-safe-value.d.ts","sourceRoot":"","sources":["../../src/enum/enum-safe-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,UAAU,CAExH"}
|