@develia/commons 0.4.24 → 0.4.25
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/dist/array.d.ts.map +1 -0
- package/dist/array.js.map +1 -0
- package/dist/async-pool-executor.d.ts.map +1 -0
- package/dist/async-pool-executor.js.map +1 -0
- package/dist/browser/form-utilities.d.ts.map +1 -0
- package/dist/browser/form-utilities.js.map +1 -0
- package/dist/browser/geo-location.d.ts.map +1 -0
- package/dist/browser/geo-location.js.map +1 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/native-bridge.d.ts.map +1 -0
- package/dist/browser/native-bridge.js.map +1 -0
- package/dist/cancellable-promise.d.ts.map +1 -0
- package/dist/cancellable-promise.js.map +1 -0
- package/dist/clean-url-search-params.d.ts.map +1 -0
- package/dist/clean-url-search-params.js.map +1 -0
- package/dist/collections/cache-dictionary.d.ts.map +1 -0
- package/dist/collections/cache-dictionary.js.map +1 -0
- package/dist/collections/default-map.d.ts.map +1 -0
- package/dist/collections/default-map.js.map +1 -0
- package/dist/collections/default-weak-map.d.ts.map +1 -0
- package/dist/collections/default-weak-map.js.map +1 -0
- package/dist/collections/from.d.ts.map +1 -0
- package/dist/collections/from.js.map +1 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js.map +1 -0
- package/dist/debouncer.d.ts.map +1 -0
- package/dist/debouncer.js.map +1 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js.map +1 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js.map +1 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/key-value-pair.d.ts.map +1 -0
- package/dist/key-value-pair.js.map +1 -0
- package/dist/keyed-debouncer.d.ts.map +1 -0
- package/dist/keyed-debouncer.js.map +1 -0
- package/dist/lazy.d.ts.map +1 -0
- package/dist/lazy.js.map +1 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/math.js.map +1 -0
- package/dist/order.d.ts.map +1 -0
- package/dist/order.js.map +1 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js.map +1 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js.map +1 -0
- package/dist/range.d.ts.map +1 -0
- package/dist/range.js.map +1 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js.map +1 -0
- package/dist/stopwatch.d.ts.map +1 -0
- package/dist/stopwatch.js.map +1 -0
- package/dist/string.d.ts.map +1 -0
- package/dist/string.js.map +1 -0
- package/dist/timer.d.ts.map +1 -0
- package/dist/timer.js.map +1 -0
- package/dist/timespan.d.ts.map +1 -0
- package/dist/timespan.js.map +1 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js.map +1 -0
- package/dist/type-code.d.ts.map +1 -0
- package/dist/type-code.js.map +1 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js.map +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +13 -62
- package/dist/cjs/array.js +0 -106
- package/dist/cjs/array.js.map +0 -1
- package/dist/cjs/async-pool-executor.js +0 -79
- package/dist/cjs/async-pool-executor.js.map +0 -1
- package/dist/cjs/browser/form-utilities.js +0 -162
- package/dist/cjs/browser/form-utilities.js.map +0 -1
- package/dist/cjs/browser/geo-location.js +0 -78
- package/dist/cjs/browser/geo-location.js.map +0 -1
- package/dist/cjs/browser/index.js +0 -99
- package/dist/cjs/browser/index.js.map +0 -1
- package/dist/cjs/browser/native-bridge.js +0 -81
- package/dist/cjs/browser/native-bridge.js.map +0 -1
- package/dist/cjs/cancellable-promise.js +0 -81
- package/dist/cjs/cancellable-promise.js.map +0 -1
- package/dist/cjs/clean-url-search-params.js +0 -34
- package/dist/cjs/clean-url-search-params.js.map +0 -1
- package/dist/cjs/collections/cache-dictionary.js +0 -102
- package/dist/cjs/collections/cache-dictionary.js.map +0 -1
- package/dist/cjs/collections/default-map.js +0 -45
- package/dist/cjs/collections/default-map.js.map +0 -1
- package/dist/cjs/collections/default-weak-map.js +0 -46
- package/dist/cjs/collections/default-weak-map.js.map +0 -1
- package/dist/cjs/collections/from.js +0 -778
- package/dist/cjs/collections/from.js.map +0 -1
- package/dist/cjs/collections/index.js +0 -15
- package/dist/cjs/collections/index.js.map +0 -1
- package/dist/cjs/debouncer.js +0 -121
- package/dist/cjs/debouncer.js.map +0 -1
- package/dist/cjs/draft.js +0 -225
- package/dist/cjs/draft.js.map +0 -1
- package/dist/cjs/event-bus.js +0 -71
- package/dist/cjs/event-bus.js.map +0 -1
- package/dist/cjs/functions.js +0 -262
- package/dist/cjs/functions.js.map +0 -1
- package/dist/cjs/index.js +0 -84
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/key-value-pair.js +0 -22
- package/dist/cjs/key-value-pair.js.map +0 -1
- package/dist/cjs/keyed-debouncer.js +0 -144
- package/dist/cjs/keyed-debouncer.js.map +0 -1
- package/dist/cjs/lazy.js +0 -29
- package/dist/cjs/lazy.js.map +0 -1
- package/dist/cjs/math.js +0 -37
- package/dist/cjs/math.js.map +0 -1
- package/dist/cjs/order.js +0 -9
- package/dist/cjs/order.js.map +0 -1
- package/dist/cjs/parse.js +0 -174
- package/dist/cjs/parse.js.map +0 -1
- package/dist/cjs/patch.js +0 -52
- package/dist/cjs/patch.js.map +0 -1
- package/dist/cjs/range.js +0 -154
- package/dist/cjs/range.js.map +0 -1
- package/dist/cjs/result.js +0 -3
- package/dist/cjs/result.js.map +0 -1
- package/dist/cjs/stopwatch.js +0 -46
- package/dist/cjs/stopwatch.js.map +0 -1
- package/dist/cjs/string.js +0 -154
- package/dist/cjs/string.js.map +0 -1
- package/dist/cjs/timer.js +0 -57
- package/dist/cjs/timer.js.map +0 -1
- package/dist/cjs/timespan.js +0 -367
- package/dist/cjs/timespan.js.map +0 -1
- package/dist/cjs/triggers.js +0 -103
- package/dist/cjs/triggers.js.map +0 -1
- package/dist/cjs/type-code.js +0 -18
- package/dist/cjs/type-code.js.map +0 -1
- package/dist/cjs/type.js +0 -296
- package/dist/cjs/type.js.map +0 -1
- package/dist/cjs/types.js +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utilities.js +0 -621
- package/dist/cjs/utilities.js.map +0 -1
- package/dist/esm/array.js.map +0 -1
- package/dist/esm/async-pool-executor.js.map +0 -1
- package/dist/esm/browser/form-utilities.js.map +0 -1
- package/dist/esm/browser/geo-location.js.map +0 -1
- package/dist/esm/browser/index.js.map +0 -1
- package/dist/esm/browser/native-bridge.js.map +0 -1
- package/dist/esm/cancellable-promise.js.map +0 -1
- package/dist/esm/clean-url-search-params.js.map +0 -1
- package/dist/esm/collections/cache-dictionary.js.map +0 -1
- package/dist/esm/collections/default-map.js.map +0 -1
- package/dist/esm/collections/default-weak-map.js.map +0 -1
- package/dist/esm/collections/from.js.map +0 -1
- package/dist/esm/collections/index.js.map +0 -1
- package/dist/esm/debouncer.js.map +0 -1
- package/dist/esm/draft.js.map +0 -1
- package/dist/esm/event-bus.js.map +0 -1
- package/dist/esm/functions.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/key-value-pair.js.map +0 -1
- package/dist/esm/keyed-debouncer.js.map +0 -1
- package/dist/esm/lazy.js.map +0 -1
- package/dist/esm/math.js.map +0 -1
- package/dist/esm/order.js.map +0 -1
- package/dist/esm/parse.js.map +0 -1
- package/dist/esm/patch.js.map +0 -1
- package/dist/esm/range.js.map +0 -1
- package/dist/esm/result.js.map +0 -1
- package/dist/esm/stopwatch.js.map +0 -1
- package/dist/esm/string.js.map +0 -1
- package/dist/esm/timer.js.map +0 -1
- package/dist/esm/timespan.js.map +0 -1
- package/dist/esm/triggers.js.map +0 -1
- package/dist/esm/type-code.js.map +0 -1
- package/dist/esm/type.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utilities.js.map +0 -1
- package/dist/types/array.d.ts.map +0 -1
- package/dist/types/async-pool-executor.d.ts.map +0 -1
- package/dist/types/browser/form-utilities.d.ts.map +0 -1
- package/dist/types/browser/geo-location.d.ts.map +0 -1
- package/dist/types/browser/index.d.ts.map +0 -1
- package/dist/types/browser/native-bridge.d.ts.map +0 -1
- package/dist/types/cancellable-promise.d.ts.map +0 -1
- package/dist/types/clean-url-search-params.d.ts.map +0 -1
- package/dist/types/collections/cache-dictionary.d.ts.map +0 -1
- package/dist/types/collections/default-map.d.ts.map +0 -1
- package/dist/types/collections/default-weak-map.d.ts.map +0 -1
- package/dist/types/collections/from.d.ts.map +0 -1
- package/dist/types/collections/index.d.ts.map +0 -1
- package/dist/types/debouncer.d.ts.map +0 -1
- package/dist/types/draft.d.ts.map +0 -1
- package/dist/types/event-bus.d.ts.map +0 -1
- package/dist/types/functions.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/key-value-pair.d.ts.map +0 -1
- package/dist/types/keyed-debouncer.d.ts.map +0 -1
- package/dist/types/lazy.d.ts.map +0 -1
- package/dist/types/math.d.ts.map +0 -1
- package/dist/types/order.d.ts.map +0 -1
- package/dist/types/parse.d.ts.map +0 -1
- package/dist/types/patch.d.ts.map +0 -1
- package/dist/types/range.d.ts.map +0 -1
- package/dist/types/result.d.ts.map +0 -1
- package/dist/types/stopwatch.d.ts.map +0 -1
- package/dist/types/string.d.ts.map +0 -1
- package/dist/types/timer.d.ts.map +0 -1
- package/dist/types/timespan.d.ts.map +0 -1
- package/dist/types/triggers.d.ts.map +0 -1
- package/dist/types/type-code.d.ts.map +0 -1
- package/dist/types/type.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utilities.d.ts.map +0 -1
- package/dist/web/array.js +0 -98
- package/dist/web/array.js.map +0 -1
- package/dist/web/async-pool-executor.js +0 -76
- package/dist/web/async-pool-executor.js.map +0 -1
- package/dist/web/browser/form-utilities.js +0 -155
- package/dist/web/browser/form-utilities.js.map +0 -1
- package/dist/web/browser/geo-location.js +0 -75
- package/dist/web/browser/geo-location.js.map +0 -1
- package/dist/web/browser/index.js +0 -75
- package/dist/web/browser/index.js.map +0 -1
- package/dist/web/browser/native-bridge.js +0 -78
- package/dist/web/browser/native-bridge.js.map +0 -1
- package/dist/web/cancellable-promise.js +0 -78
- package/dist/web/cancellable-promise.js.map +0 -1
- package/dist/web/clean-url-search-params.js +0 -31
- package/dist/web/clean-url-search-params.js.map +0 -1
- package/dist/web/collections/cache-dictionary.js +0 -99
- package/dist/web/collections/cache-dictionary.js.map +0 -1
- package/dist/web/collections/default-map.js +0 -42
- package/dist/web/collections/default-map.js.map +0 -1
- package/dist/web/collections/default-weak-map.js +0 -43
- package/dist/web/collections/default-weak-map.js.map +0 -1
- package/dist/web/collections/from.js +0 -770
- package/dist/web/collections/from.js.map +0 -1
- package/dist/web/collections/index.js +0 -5
- package/dist/web/collections/index.js.map +0 -1
- package/dist/web/debouncer.js +0 -118
- package/dist/web/debouncer.js.map +0 -1
- package/dist/web/draft.js +0 -222
- package/dist/web/draft.js.map +0 -1
- package/dist/web/event-bus.js +0 -66
- package/dist/web/event-bus.js.map +0 -1
- package/dist/web/functions.js +0 -251
- package/dist/web/functions.js.map +0 -1
- package/dist/web/index.js +0 -40
- package/dist/web/index.js.map +0 -1
- package/dist/web/key-value-pair.js +0 -19
- package/dist/web/key-value-pair.js.map +0 -1
- package/dist/web/keyed-debouncer.js +0 -109
- package/dist/web/keyed-debouncer.js.map +0 -1
- package/dist/web/lazy.js +0 -26
- package/dist/web/lazy.js.map +0 -1
- package/dist/web/math.js +0 -33
- package/dist/web/math.js.map +0 -1
- package/dist/web/order.js +0 -7
- package/dist/web/order.js.map +0 -1
- package/dist/web/parse.js +0 -169
- package/dist/web/parse.js.map +0 -1
- package/dist/web/patch.js +0 -48
- package/dist/web/patch.js.map +0 -1
- package/dist/web/range.js +0 -151
- package/dist/web/range.js.map +0 -1
- package/dist/web/result.js +0 -2
- package/dist/web/result.js.map +0 -1
- package/dist/web/stopwatch.js +0 -40
- package/dist/web/stopwatch.js.map +0 -1
- package/dist/web/string.js +0 -142
- package/dist/web/string.js.map +0 -1
- package/dist/web/timer.js +0 -54
- package/dist/web/timer.js.map +0 -1
- package/dist/web/timespan.js +0 -365
- package/dist/web/timespan.js.map +0 -1
- package/dist/web/triggers.js +0 -99
- package/dist/web/triggers.js.map +0 -1
- package/dist/web/type-code.js +0 -16
- package/dist/web/type-code.js.map +0 -1
- package/dist/web/type.js +0 -292
- package/dist/web/type.js.map +0 -1
- package/dist/web/types.js +0 -2
- package/dist/web/types.js.map +0 -1
- package/dist/web/utilities.js +0 -590
- package/dist/web/utilities.js.map +0 -1
- /package/dist/{types/array.d.ts → array.d.ts} +0 -0
- /package/dist/{esm/array.js → array.js} +0 -0
- /package/dist/{types/async-pool-executor.d.ts → async-pool-executor.d.ts} +0 -0
- /package/dist/{esm/async-pool-executor.js → async-pool-executor.js} +0 -0
- /package/dist/{types/browser → browser}/form-utilities.d.ts +0 -0
- /package/dist/{esm/browser → browser}/form-utilities.js +0 -0
- /package/dist/{types/browser → browser}/geo-location.d.ts +0 -0
- /package/dist/{esm/browser → browser}/geo-location.js +0 -0
- /package/dist/{types/browser → browser}/index.d.ts +0 -0
- /package/dist/{esm/browser → browser}/index.js +0 -0
- /package/dist/{types/browser → browser}/native-bridge.d.ts +0 -0
- /package/dist/{esm/browser → browser}/native-bridge.js +0 -0
- /package/dist/{types/cancellable-promise.d.ts → cancellable-promise.d.ts} +0 -0
- /package/dist/{esm/cancellable-promise.js → cancellable-promise.js} +0 -0
- /package/dist/{types/clean-url-search-params.d.ts → clean-url-search-params.d.ts} +0 -0
- /package/dist/{esm/clean-url-search-params.js → clean-url-search-params.js} +0 -0
- /package/dist/{types/collections → collections}/cache-dictionary.d.ts +0 -0
- /package/dist/{esm/collections → collections}/cache-dictionary.js +0 -0
- /package/dist/{types/collections → collections}/default-map.d.ts +0 -0
- /package/dist/{esm/collections → collections}/default-map.js +0 -0
- /package/dist/{types/collections → collections}/default-weak-map.d.ts +0 -0
- /package/dist/{esm/collections → collections}/default-weak-map.js +0 -0
- /package/dist/{types/collections → collections}/from.d.ts +0 -0
- /package/dist/{esm/collections → collections}/from.js +0 -0
- /package/dist/{types/collections → collections}/index.d.ts +0 -0
- /package/dist/{esm/collections → collections}/index.js +0 -0
- /package/dist/{types/debouncer.d.ts → debouncer.d.ts} +0 -0
- /package/dist/{esm/debouncer.js → debouncer.js} +0 -0
- /package/dist/{types/draft.d.ts → draft.d.ts} +0 -0
- /package/dist/{esm/draft.js → draft.js} +0 -0
- /package/dist/{types/event-bus.d.ts → event-bus.d.ts} +0 -0
- /package/dist/{esm/event-bus.js → event-bus.js} +0 -0
- /package/dist/{types/functions.d.ts → functions.d.ts} +0 -0
- /package/dist/{esm/functions.js → functions.js} +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{esm/index.js → index.js} +0 -0
- /package/dist/{types/key-value-pair.d.ts → key-value-pair.d.ts} +0 -0
- /package/dist/{esm/key-value-pair.js → key-value-pair.js} +0 -0
- /package/dist/{types/keyed-debouncer.d.ts → keyed-debouncer.d.ts} +0 -0
- /package/dist/{esm/keyed-debouncer.js → keyed-debouncer.js} +0 -0
- /package/dist/{types/lazy.d.ts → lazy.d.ts} +0 -0
- /package/dist/{esm/lazy.js → lazy.js} +0 -0
- /package/dist/{types/math.d.ts → math.d.ts} +0 -0
- /package/dist/{esm/math.js → math.js} +0 -0
- /package/dist/{types/order.d.ts → order.d.ts} +0 -0
- /package/dist/{esm/order.js → order.js} +0 -0
- /package/dist/{types/parse.d.ts → parse.d.ts} +0 -0
- /package/dist/{esm/parse.js → parse.js} +0 -0
- /package/dist/{types/patch.d.ts → patch.d.ts} +0 -0
- /package/dist/{esm/patch.js → patch.js} +0 -0
- /package/dist/{types/range.d.ts → range.d.ts} +0 -0
- /package/dist/{esm/range.js → range.js} +0 -0
- /package/dist/{types/result.d.ts → result.d.ts} +0 -0
- /package/dist/{esm/result.js → result.js} +0 -0
- /package/dist/{types/stopwatch.d.ts → stopwatch.d.ts} +0 -0
- /package/dist/{esm/stopwatch.js → stopwatch.js} +0 -0
- /package/dist/{types/string.d.ts → string.d.ts} +0 -0
- /package/dist/{esm/string.js → string.js} +0 -0
- /package/dist/{types/timer.d.ts → timer.d.ts} +0 -0
- /package/dist/{esm/timer.js → timer.js} +0 -0
- /package/dist/{types/timespan.d.ts → timespan.d.ts} +0 -0
- /package/dist/{esm/timespan.js → timespan.js} +0 -0
- /package/dist/{types/triggers.d.ts → triggers.d.ts} +0 -0
- /package/dist/{esm/triggers.js → triggers.js} +0 -0
- /package/dist/{types/type-code.d.ts → type-code.d.ts} +0 -0
- /package/dist/{esm/type-code.js → type-code.js} +0 -0
- /package/dist/{types/type.d.ts → type.d.ts} +0 -0
- /package/dist/{esm/type.js → type.js} +0 -0
- /package/dist/{types/types.d.ts → types.d.ts} +0 -0
- /package/dist/{esm/types.js → types.js} +0 -0
- /package/dist/{types/utilities.d.ts → utilities.d.ts} +0 -0
- /package/dist/{esm/utilities.js → utilities.js} +0 -0
package/dist/cjs/math.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/math.ts"],"names":[],"mappings":";;AAWA,oBAKC;AAUD,sBAMC;AAhCD;;;;;;;;;;GAUG;AACH,SAAgB,IAAI,CAAC,CAAS,EAAE,KAAa,EAAE,KAAa,EAAE,MAAc,EAAE,MAAc;IACxF,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAA;AACvE,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IACrD,IAAI,CAAC,IAAI,GAAG;QACR,OAAO,GAAG,CAAC;IACf,IAAI,CAAC,IAAI,GAAG;QACR,OAAO,GAAG,CAAC;IACf,OAAO,CAAC,CAAA;AACZ,CAAC","sourcesContent":["/**\n * Linearly interpolates a number between two ranges.\n *\n * @param {number} n - The number to interpolate.\n * @param {number} inMin - The minimum value of the input range.\n * @param {number} inMax - The maximum value of the input range.\n * @param {number} outMin - The minimum value of the output range.\n * @param {number} outMax - The maximum value of the output range.\n *\n * @return {number} - The interpolated value.\n */\nexport function lerp(n: number, inMin: number, inMax: number, outMin: number, outMax: number): number {\n if (inMax === inMin) {\n throw new Error(\"Input range cannot be zero\");\n }\n return outMin + (outMax - outMin) * ((n - inMin) / (inMax - inMin))\n}\n\n/**\n * Clamps a number between a minimum and maximum value.\n *\n * @param {number} n - The value to be clamped.\n * @param {number} min - The minimum value.\n * @param {number} max - The maximum value.\n * @return {number} The clamped value.\n */\nexport function clamp(n: number, min: number, max: number): number {\n if (n <= min)\n return min;\n if (n >= max)\n return max;\n return n\n}\n"]}
|
package/dist/cjs/order.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Order;
|
|
4
|
-
(function (Order) {
|
|
5
|
-
Order["Ascending"] = "asc";
|
|
6
|
-
Order["Descending"] = "desc";
|
|
7
|
-
})(Order || (Order = {}));
|
|
8
|
-
exports.default = Order;
|
|
9
|
-
//# sourceMappingURL=order.js.map
|
package/dist/cjs/order.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/order.ts"],"names":[],"mappings":";;AAAA,IAAK,KAGJ;AAHD,WAAK,KAAK;IACN,0BAAiB,CAAA;IACjB,4BAAmB,CAAA;AACvB,CAAC,EAHI,KAAK,KAAL,KAAK,QAGT;AAED,kBAAe,KAAK,CAAC","sourcesContent":["enum Order {\n Ascending = \"asc\",\n Descending = \"desc\"\n}\n\nexport default Order;"]}
|
package/dist/cjs/parse.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseInteger = parseInteger;
|
|
4
|
-
exports.parseDecimal = parseDecimal;
|
|
5
|
-
exports.parseBoolean = parseBoolean;
|
|
6
|
-
// ============================================
|
|
7
|
-
// HELPERS
|
|
8
|
-
// ============================================
|
|
9
|
-
function stripThousands(value, separator) {
|
|
10
|
-
if (!separator)
|
|
11
|
-
return value;
|
|
12
|
-
return value.split(separator).join("");
|
|
13
|
-
}
|
|
14
|
-
function isValidInteger(value, radix) {
|
|
15
|
-
if (!Number.isInteger(radix) || radix < 2 || radix > 36)
|
|
16
|
-
return false;
|
|
17
|
-
const signless = value.replace(/^[+-]/, "");
|
|
18
|
-
if (signless === "")
|
|
19
|
-
return false;
|
|
20
|
-
const digits = "0123456789abcdefghijklmnopqrstuvwxyz".slice(0, radix);
|
|
21
|
-
return [...signless.toLowerCase()].every((char) => digits.includes(char));
|
|
22
|
-
}
|
|
23
|
-
// ============================================
|
|
24
|
-
// parseInteger
|
|
25
|
-
// ============================================
|
|
26
|
-
/**
|
|
27
|
-
* Safely parses a value into an integer.
|
|
28
|
-
* Returns `null` if the value cannot be parsed.
|
|
29
|
-
*
|
|
30
|
-
* - `null` or `undefined` → `null`
|
|
31
|
-
* - `number` → returned as-is (floats are truncated)
|
|
32
|
-
* - `string` → parsed with the given options
|
|
33
|
-
*
|
|
34
|
-
* @param value - The value to parse.
|
|
35
|
-
* @param options - Optional parsing configuration.
|
|
36
|
-
* @returns The parsed integer, or `null` on failure.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* parseInteger(42) // 42
|
|
41
|
-
* parseInteger(3.7) // 3
|
|
42
|
-
* parseInteger(null) // null
|
|
43
|
-
* parseInteger(undefined) // null
|
|
44
|
-
* parseInteger("42") // 42
|
|
45
|
-
* parseInteger("1.234.567", { thousandsSeparator: "." }) // 1234567
|
|
46
|
-
* parseInteger("FF", { radix: 16 }) // 255
|
|
47
|
-
* parseInteger("abc") // null
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
function parseInteger(value, options = {}) {
|
|
51
|
-
if (value === null || value === undefined)
|
|
52
|
-
return null;
|
|
53
|
-
if (typeof value === "number") {
|
|
54
|
-
return Number.isFinite(value) ? Math.trunc(value) : null;
|
|
55
|
-
}
|
|
56
|
-
const { radix = 10, thousandsSeparator } = options;
|
|
57
|
-
const cleaned = stripThousands(value.trim(), thousandsSeparator);
|
|
58
|
-
if (cleaned === "")
|
|
59
|
-
return null;
|
|
60
|
-
if (!isValidInteger(cleaned, radix))
|
|
61
|
-
return null;
|
|
62
|
-
const parsed = Number.parseInt(cleaned, radix);
|
|
63
|
-
return Number.isNaN(parsed) ? null : parsed;
|
|
64
|
-
}
|
|
65
|
-
// ============================================
|
|
66
|
-
// parseDecimal
|
|
67
|
-
// ============================================
|
|
68
|
-
/**
|
|
69
|
-
* Safely parses a value into a floating-point number.
|
|
70
|
-
* Returns `null` if the value cannot be parsed.
|
|
71
|
-
*
|
|
72
|
-
* - `null` or `undefined` → `null`
|
|
73
|
-
* - `number` → returned as-is (if finite)
|
|
74
|
-
* - `string` → parsed with the given options
|
|
75
|
-
*
|
|
76
|
-
* Supports custom decimal and thousands separators, making it suitable
|
|
77
|
-
* for both US (`1,234.56`) and EU (`1.234,56`) number formats.
|
|
78
|
-
*
|
|
79
|
-
* @param value - The value to parse.
|
|
80
|
-
* @param options - Optional parsing configuration.
|
|
81
|
-
* @returns The parsed float, or `null` on failure.
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* parseDecimal(3.14) // 3.14
|
|
86
|
-
* parseDecimal(null) // null
|
|
87
|
-
* parseDecimal(undefined) // null
|
|
88
|
-
* parseDecimal("3.14") // 3.14
|
|
89
|
-
* parseDecimal("3,14", { decimalSeparator: "," }) // 3.14
|
|
90
|
-
* parseDecimal("1.234,56", { decimalSeparator: ",", thousandsSeparator: "." }) // 1234.56
|
|
91
|
-
* parseDecimal("abc") // null
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
function parseDecimal(value, options = {}) {
|
|
95
|
-
if (value === null || value === undefined)
|
|
96
|
-
return null;
|
|
97
|
-
if (typeof value === "number") {
|
|
98
|
-
return Number.isFinite(value) ? value : null;
|
|
99
|
-
}
|
|
100
|
-
const { decimalSeparator = ".", thousandsSeparator } = options;
|
|
101
|
-
let cleaned = stripThousands(value.trim(), thousandsSeparator);
|
|
102
|
-
if (cleaned === "")
|
|
103
|
-
return null;
|
|
104
|
-
if (decimalSeparator === ",") {
|
|
105
|
-
const commaCount = (cleaned.match(/,/g) || []).length;
|
|
106
|
-
if (commaCount > 1)
|
|
107
|
-
return null;
|
|
108
|
-
cleaned = cleaned.replace(",", ".");
|
|
109
|
-
}
|
|
110
|
-
if (!/^[+-]?\d+(\.\d+)?$/.test(cleaned))
|
|
111
|
-
return null;
|
|
112
|
-
const parsed = Number.parseFloat(cleaned);
|
|
113
|
-
return Number.isNaN(parsed) || !Number.isFinite(parsed) ? null : parsed;
|
|
114
|
-
}
|
|
115
|
-
// ============================================
|
|
116
|
-
// parseBoolean
|
|
117
|
-
// ============================================
|
|
118
|
-
const DEFAULT_TRUTHY = ["true", "1", "yes", "si", "sí", "on"];
|
|
119
|
-
const DEFAULT_FALSY = ["false", "0", "no", "off"];
|
|
120
|
-
/**
|
|
121
|
-
* Safely parses a value into a boolean.
|
|
122
|
-
* Returns `null` if the value cannot be interpreted as boolean.
|
|
123
|
-
*
|
|
124
|
-
* - `null` or `undefined` → `null`
|
|
125
|
-
* - `boolean` → returned as-is
|
|
126
|
-
* - `number` → `0` is `false`, any other finite number is `true`
|
|
127
|
-
* - `string` → matched case-insensitively against known truthy/falsy values
|
|
128
|
-
*
|
|
129
|
-
* Default truthy: `"true"`, `"1"`, `"yes"`, `"si"`, `"sí"`, `"on"`
|
|
130
|
-
* Default falsy: `"false"`, `"0"`, `"no"`, `"off"`
|
|
131
|
-
*
|
|
132
|
-
* @param value - The value to parse.
|
|
133
|
-
* @param options - Optional parsing configuration.
|
|
134
|
-
* @returns The parsed boolean, or `null` on failure.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* parseBoolean(true) // true
|
|
139
|
-
* parseBoolean(false) // false
|
|
140
|
-
* parseBoolean(1) // true
|
|
141
|
-
* parseBoolean(0) // false
|
|
142
|
-
* parseBoolean(null) // null
|
|
143
|
-
* parseBoolean(undefined) // null
|
|
144
|
-
* parseBoolean("yes") // true
|
|
145
|
-
* parseBoolean("no") // false
|
|
146
|
-
* parseBoolean("sí") // true
|
|
147
|
-
* parseBoolean("TRUE") // true
|
|
148
|
-
* parseBoolean("oui") // null
|
|
149
|
-
* parseBoolean("oui", { extraTruthy: ["oui"] }) // true
|
|
150
|
-
* parseBoolean("nein", { extraFalsy: ["nein"] }) // false
|
|
151
|
-
* parseBoolean("whatever") // null
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
function parseBoolean(value, options = {}) {
|
|
155
|
-
if (value === null || value === undefined)
|
|
156
|
-
return null;
|
|
157
|
-
if (typeof value === "boolean")
|
|
158
|
-
return value;
|
|
159
|
-
if (typeof value === "number") {
|
|
160
|
-
return Number.isFinite(value) ? value !== 0 : null;
|
|
161
|
-
}
|
|
162
|
-
const { extraTruthy = [], extraFalsy = [] } = options;
|
|
163
|
-
const normalized = value.trim().toLowerCase();
|
|
164
|
-
if (normalized === "")
|
|
165
|
-
return null;
|
|
166
|
-
const truthy = [...DEFAULT_TRUTHY, ...extraTruthy.map((s) => s.toLowerCase())];
|
|
167
|
-
const falsy = [...DEFAULT_FALSY, ...extraFalsy.map((s) => s.toLowerCase())];
|
|
168
|
-
if (truthy.includes(normalized))
|
|
169
|
-
return true;
|
|
170
|
-
if (falsy.includes(normalized))
|
|
171
|
-
return false;
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=parse.js.map
|
package/dist/cjs/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":";;AAwGA,oCAoBC;AAgCD,oCA2BC;AA2CD,oCAyBC;AAnMD,+CAA+C;AAC/C,UAAU;AACV,+CAA+C;AAE/C,SAAS,cAAc,CAAC,KAAa,EAAE,SAAkB;IACrD,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,KAAK,CAAC;IAEtE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5C,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAElC,MAAM,MAAM,GAAG,sCAAsC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAEtE,OAAO,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED,+CAA+C;AAC/C,eAAe;AACf,+CAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,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S;QAAE,OAAO,KAAK,CAAC;IAE7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;IAED,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAEtD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE9C,IAAI,UAAU,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAEnC,MAAM,MAAM,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAG,CAAC,GAAG,aAAa,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAE5E,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IAE7C,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["// parse.ts\n/**\n * Options for {@link parseBoolean}.\n */\nexport interface ParseBooleanOptions {\n /**\n * Additional strings to consider as `true`.\n * These are matched case-insensitively.\n * @example [\"oui\", \"ja\"]\n */\n extraTruthy?: string[];\n\n /**\n * Additional strings to consider as `false`.\n * These are matched case-insensitively.\n * @example [\"non\", \"nein\"]\n */\n extraFalsy?: string[];\n}\n\n/**\n * Options for {@link parseInteger}.\n */\nexport interface ParseIntegerOptions {\n /**\n * Numeric base for conversion.\n * @default 10\n */\n radix?: number;\n\n /**\n * Thousands separator to strip before parsing.\n * @example \".\" for \"1.234.567\" → 1234567\n * @example \",\" for \"1,234,567\" → 1234567\n */\n thousandsSeparator?: string;\n}\n\n/**\n * Options for {@link parseDecimal}.\n */\nexport interface ParseDecimalOptions {\n /**\n * Character used as decimal point.\n * @default \".\"\n */\n decimalSeparator?: \".\" | \",\";\n\n /**\n * Thousands separator to strip before parsing.\n * @example \".\" for \"1.234,56\" (EU format)\n * @example \",\" for \"1,234.56\" (US format)\n */\n thousandsSeparator?: string;\n}\n\n// ============================================\n// HELPERS\n// ============================================\n\nfunction stripThousands(value: string, separator?: string): string {\n if (!separator) return value;\n return value.split(separator).join(\"\");\n}\n\nfunction isValidInteger(value: string, radix: number): boolean {\n if (!Number.isInteger(radix) || radix < 2 || radix > 36) return false;\n\n const signless = value.replace(/^[+-]/, \"\");\n if (signless === \"\") return false;\n\n const digits = \"0123456789abcdefghijklmnopqrstuvwxyz\".slice(0, radix);\n\n return [...signless.toLowerCase()].every((char) => digits.includes(char));\n}\n\n// ============================================\n// parseInteger\n// ============================================\n\n/**\n * Safely parses a value into an integer.\n * Returns `null` if the value cannot be parsed.\n *\n * - `null` or `undefined` → `null`\n * - `number` → returned as-is (floats are truncated)\n * - `string` → parsed with the given options\n *\n * @param value - The value to parse.\n * @param options - Optional parsing configuration.\n * @returns The parsed integer, or `null` on failure.\n *\n * @example\n * ```ts\n * parseInteger(42) // 42\n * parseInteger(3.7) // 3\n * parseInteger(null) // null\n * parseInteger(undefined) // null\n * parseInteger(\"42\") // 42\n * parseInteger(\"1.234.567\", { thousandsSeparator: \".\" }) // 1234567\n * parseInteger(\"FF\", { radix: 16 }) // 255\n * parseInteger(\"abc\") // null\n * ```\n */\nexport function parseInteger(\n value: string | number | null | undefined,\n options: ParseIntegerOptions = {}\n): number | null {\n if (value === null || value === undefined) return null;\n\n if (typeof value === \"number\") {\n return Number.isFinite(value) ? Math.trunc(value) : null;\n }\n\n const { radix = 10, thousandsSeparator } = options;\n\n const cleaned = stripThousands(value.trim(), thousandsSeparator);\n\n if (cleaned === \"\") return null;\n if (!isValidInteger(cleaned, radix)) return null;\n\n const parsed = Number.parseInt(cleaned, radix);\n\n return Number.isNaN(parsed) ? null : parsed;\n}\n\n// ============================================\n// parseDecimal\n// ============================================\n\n/**\n * Safely parses a value into a floating-point number.\n * Returns `null` if the value cannot be parsed.\n *\n * - `null` or `undefined` → `null`\n * - `number` → returned as-is (if finite)\n * - `string` → parsed with the given options\n *\n * Supports custom decimal and thousands separators, making it suitable\n * for both US (`1,234.56`) and EU (`1.234,56`) number formats.\n *\n * @param value - The value to parse.\n * @param options - Optional parsing configuration.\n * @returns The parsed float, or `null` on failure.\n *\n * @example\n * ```ts\n * parseDecimal(3.14) // 3.14\n * parseDecimal(null) // null\n * parseDecimal(undefined) // null\n * parseDecimal(\"3.14\") // 3.14\n * parseDecimal(\"3,14\", { decimalSeparator: \",\" }) // 3.14\n * parseDecimal(\"1.234,56\", { decimalSeparator: \",\", thousandsSeparator: \".\" }) // 1234.56\n * parseDecimal(\"abc\") // null\n * ```\n */\nexport function parseDecimal(\n value: string | number | null | undefined,\n options: ParseDecimalOptions = {}\n): number | null {\n if (value === null || value === undefined) return null;\n\n if (typeof value === \"number\") {\n return Number.isFinite(value) ? value : null;\n }\n\n const { decimalSeparator = \".\", thousandsSeparator } = options;\n\n let cleaned = stripThousands(value.trim(), thousandsSeparator);\n\n if (cleaned === \"\") return null;\n\n if (decimalSeparator === \",\") {\n const commaCount = (cleaned.match(/,/g) || []).length;\n if (commaCount > 1) return null;\n cleaned = cleaned.replace(\",\", \".\");\n }\n\n if (!/^[+-]?\\d+(\\.\\d+)?$/.test(cleaned)) return null;\n\n const parsed = Number.parseFloat(cleaned);\n\n return Number.isNaN(parsed) || !Number.isFinite(parsed) ? null : parsed;\n}\n\n// ============================================\n// parseBoolean\n// ============================================\n\nconst DEFAULT_TRUTHY = [\"true\", \"1\", \"yes\", \"si\", \"sí\", \"on\"];\nconst DEFAULT_FALSY = [\"false\", \"0\", \"no\", \"off\"];\n\n/**\n * Safely parses a value into a boolean.\n * Returns `null` if the value cannot be interpreted as boolean.\n *\n * - `null` or `undefined` → `null`\n * - `boolean` → returned as-is\n * - `number` → `0` is `false`, any other finite number is `true`\n * - `string` → matched case-insensitively against known truthy/falsy values\n *\n * Default truthy: `\"true\"`, `\"1\"`, `\"yes\"`, `\"si\"`, `\"sí\"`, `\"on\"`\n * Default falsy: `\"false\"`, `\"0\"`, `\"no\"`, `\"off\"`\n *\n * @param value - The value to parse.\n * @param options - Optional parsing configuration.\n * @returns The parsed boolean, or `null` on failure.\n *\n * @example\n * ```ts\n * parseBoolean(true) // true\n * parseBoolean(false) // false\n * parseBoolean(1) // true\n * parseBoolean(0) // false\n * parseBoolean(null) // null\n * parseBoolean(undefined) // null\n * parseBoolean(\"yes\") // true\n * parseBoolean(\"no\") // false\n * parseBoolean(\"sí\") // true\n * parseBoolean(\"TRUE\") // true\n * parseBoolean(\"oui\") // null\n * parseBoolean(\"oui\", { extraTruthy: [\"oui\"] }) // true\n * parseBoolean(\"nein\", { extraFalsy: [\"nein\"] }) // false\n * parseBoolean(\"whatever\") // null\n * ```\n */\nexport function parseBoolean(\n value: string | number | boolean | null | undefined,\n options: ParseBooleanOptions = {}\n): boolean | null {\n if (value === null || value === undefined) return null;\n\n if (typeof value === \"boolean\") return value;\n\n if (typeof value === \"number\") {\n return Number.isFinite(value) ? value !== 0 : null;\n }\n\n const { extraTruthy = [], extraFalsy = [] } = options;\n\n const normalized = value.trim().toLowerCase();\n\n if (normalized === \"\") return null;\n\n const truthy = [...DEFAULT_TRUTHY, ...extraTruthy.map((s) => s.toLowerCase())];\n const falsy = [...DEFAULT_FALSY, ...extraFalsy.map((s) => s.toLowerCase())];\n\n if (truthy.includes(normalized)) return true;\n if (falsy.includes(normalized)) return false;\n\n return null;\n}"]}
|
package/dist/cjs/patch.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.patch = patch;
|
|
4
|
-
exports.unpatch = unpatch;
|
|
5
|
-
/**
|
|
6
|
-
* Devuelve un Map donde:
|
|
7
|
-
* - clave -> null (método añadido nuevo)
|
|
8
|
-
* - clave -> descriptorOriginal (método sustituido)
|
|
9
|
-
*/
|
|
10
|
-
function patch(targetOrCtor, fns) {
|
|
11
|
-
const target = typeof targetOrCtor === "function" ? targetOrCtor.prototype : targetOrCtor;
|
|
12
|
-
const result = new Map();
|
|
13
|
-
const entries = fns instanceof Map ? [...fns.entries()] : Object.entries(fns);
|
|
14
|
-
for (const [key, fn] of entries) {
|
|
15
|
-
const prev = Object.getOwnPropertyDescriptor(target, key);
|
|
16
|
-
const method = function (...args) {
|
|
17
|
-
return fn(this, ...args);
|
|
18
|
-
};
|
|
19
|
-
try {
|
|
20
|
-
Object.defineProperty(target, key, {
|
|
21
|
-
value: method,
|
|
22
|
-
writable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
enumerable: false,
|
|
25
|
-
});
|
|
26
|
-
result.set(key, prev ?? null);
|
|
27
|
-
}
|
|
28
|
-
catch { /* ignorar */
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Revierte un patch a partir del mapa devuelto por `patch`.
|
|
35
|
-
*/
|
|
36
|
-
function unpatch(targetOrCtor, changes) {
|
|
37
|
-
const target = typeof targetOrCtor === "function" ? targetOrCtor.prototype : targetOrCtor;
|
|
38
|
-
for (const [key, prev] of changes) {
|
|
39
|
-
try {
|
|
40
|
-
if (prev === null) {
|
|
41
|
-
if (Object.prototype.hasOwnProperty.call(target, key))
|
|
42
|
-
delete target[key];
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
Object.defineProperty(target, key, prev);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch { /* ignorar */
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=patch.js.map
|
package/dist/cjs/patch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../src/patch.ts"],"names":[],"mappings":";;AAyBA,sBA2BC;AAeD,0BAYC;AA3DD;;;;GAIG;AACH,SAAgB,KAAK,CACjB,YAAiB,EACjB,GAAmB;IAEnB,MAAM,MAAM,GAAG,OAAO,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;IAE1F,MAAM,MAAM,GAAG,IAAI,GAAG,EAA0C,CAAC;IACjE,MAAM,OAAO,GACT,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAQ,CAAC;IAEzE,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,UAAyB,GAAG,IAAe;YACtD,OAAQ,EAAU,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC;QACF,IAAI,CAAC;YACD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;gBAC/B,KAAK,EAAE,MAAM;gBACb,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,KAAK;aACpB,CAAC,CAAC;YACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC,CAAC,aAAa;QACvB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAYD;;GAEG;AACH,SAAgB,OAAO,CAAC,YAAiB,EAAE,OAAoD;IAC3F,MAAM,MAAM,GAAG,OAAO,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;IAC1F,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAChB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YAC7C,CAAC;QACL,CAAC;QAAC,MAAM,CAAC,CAAC,aAAa;QACvB,CAAC;IACL,CAAC;AACL,CAAC","sourcesContent":["import type {Constructor} from \"./types.js\";\n\nexport type PureMethod<T extends object, A extends any[] = any[], R = any> =\n (obj: T, ...args: A) => R;\n\nexport type PatchSpec<T extends object> =\n | Record<string, PureMethod<T, any[], any>>\n | Map<PropertyKey, PureMethod<T, any[], any>>;\n\n\nexport function patch<C extends Constructor<any>>(\n targetOrCtor: C,\n fns: PatchSpec<InstanceType<C>>\n): Map<PropertyKey, PropertyDescriptor | null>;\n\nexport function patch<T extends object>(\n targetOrCtor: T,\n fns: PatchSpec<T>\n): Map<PropertyKey, PropertyDescriptor | null>;\n\n/**\n * Devuelve un Map donde:\n * - clave -> null (método añadido nuevo)\n * - clave -> descriptorOriginal (método sustituido)\n */\nexport function patch(\n targetOrCtor: any,\n fns: PatchSpec<any>\n): Map<PropertyKey, PropertyDescriptor | null> {\n const target = typeof targetOrCtor === \"function\" ? targetOrCtor.prototype : targetOrCtor;\n\n const result = new Map<PropertyKey, PropertyDescriptor | null>();\n const entries: Array<[PropertyKey, PureMethod<any>]> =\n fns instanceof Map ? [...fns.entries()] : Object.entries(fns) as any;\n\n for (const [key, fn] of entries) {\n const prev = Object.getOwnPropertyDescriptor(target, key);\n const method = function (this: unknown, ...args: unknown[]) {\n return (fn as any)(this, ...args);\n };\n try {\n Object.defineProperty(target, key, {\n value: method,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n result.set(key, prev ?? null);\n } catch { /* ignorar */\n }\n }\n return result;\n}\n\n// Overloads unpatch\nexport function unpatch<C extends Constructor<any>>(\n targetOrCtor: C,\n changes: Map<PropertyKey, PropertyDescriptor | null>\n): void;\nexport function unpatch<T extends object>(\n targetOrCtor: T,\n changes: Map<PropertyKey, PropertyDescriptor | null>\n): void;\n\n/**\n * Revierte un patch a partir del mapa devuelto por `patch`.\n */\nexport function unpatch(targetOrCtor: any, changes: Map<PropertyKey, PropertyDescriptor | null>): void {\n const target = typeof targetOrCtor === \"function\" ? targetOrCtor.prototype : targetOrCtor;\n for (const [key, prev] of changes) {\n try {\n if (prev === null) {\n if (Object.prototype.hasOwnProperty.call(target, key)) delete target[key];\n } else {\n Object.defineProperty(target, key, prev);\n }\n } catch { /* ignorar */\n }\n }\n}"]}
|
package/dist/cjs/range.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class Range {
|
|
4
|
-
/**
|
|
5
|
-
* Range constructor.
|
|
6
|
-
* @param start
|
|
7
|
-
* @param end
|
|
8
|
-
*/
|
|
9
|
-
constructor(start, end) {
|
|
10
|
-
this.start = start;
|
|
11
|
-
this.end = end;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Finds the intersection between two ranges.
|
|
15
|
-
*
|
|
16
|
-
* @param other The Range object to intersect with.
|
|
17
|
-
* @returns The intersected Range object, or null if there is no intersection.
|
|
18
|
-
*/
|
|
19
|
-
intersect(other) {
|
|
20
|
-
const start = (this.start > other.start) ? this.start : other.start;
|
|
21
|
-
const end = (this.end < other.end) ? this.end : other.end;
|
|
22
|
-
if (start < end) {
|
|
23
|
-
return new Range(start, end);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Subtract the given range from this range.
|
|
31
|
-
*
|
|
32
|
-
* @param other The range to subtract from this range.
|
|
33
|
-
* @returns An array of Range objects representing the result of the subtraction.
|
|
34
|
-
*/
|
|
35
|
-
subtract(other) {
|
|
36
|
-
const result = [];
|
|
37
|
-
if (this.start >= other.end || this.end <= other.start) {
|
|
38
|
-
result.push(new Range(this.start, this.end));
|
|
39
|
-
}
|
|
40
|
-
else if (other.start <= this.start && other.end >= this.end) {
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
if (this.start < other.start) {
|
|
45
|
-
result.push(new Range(this.start, other.start));
|
|
46
|
-
}
|
|
47
|
-
if (this.end > other.end) {
|
|
48
|
-
result.push(new Range(other.end, this.end));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Determines if the given range overlaps with the current range.
|
|
55
|
-
*
|
|
56
|
-
* @param other The range to be checked for overlap.
|
|
57
|
-
* @returns Returns true if there is an overlap between the ranges, false otherwise.
|
|
58
|
-
*/
|
|
59
|
-
overlaps(other) {
|
|
60
|
-
const s1 = this.start;
|
|
61
|
-
const e1 = this.end;
|
|
62
|
-
const s2 = other.start;
|
|
63
|
-
const e2 = other.end;
|
|
64
|
-
return (s2 > s1 && s2 < e1 || e2 > s1 && e2 < e1) ||
|
|
65
|
-
(s1 > s2 && s1 < e2 || e1 > s2 && e1 < e2) ||
|
|
66
|
-
(s1 === s2 && e1 === e2);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Determines whether the specified value is within the range defined by the start and end values.
|
|
70
|
-
*
|
|
71
|
-
* @param obj The value to check if it is within the range.
|
|
72
|
-
* @param inclusive Optional. If set to true, the range boundaries are considered inclusive.
|
|
73
|
-
* @returns Returns true if the specified value is within the range, false otherwise.
|
|
74
|
-
*/
|
|
75
|
-
contains(obj, inclusive = true) {
|
|
76
|
-
return inclusive ?
|
|
77
|
-
(this.start <= obj && this.end >= obj) :
|
|
78
|
-
(this.start < obj && this.end > obj);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* @returns T
|
|
82
|
-
*/
|
|
83
|
-
getStart() {
|
|
84
|
-
return this.start;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* @returns T
|
|
88
|
-
*/
|
|
89
|
-
getEnd() {
|
|
90
|
-
return this.end;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Finds the intersection between two sets of ranges.
|
|
94
|
-
*
|
|
95
|
-
* @param ranges1
|
|
96
|
-
* @param ranges2
|
|
97
|
-
* @returns
|
|
98
|
-
*/
|
|
99
|
-
static intersectRanges(ranges1, ranges2) {
|
|
100
|
-
const result = [];
|
|
101
|
-
for (const r1 of ranges1) {
|
|
102
|
-
for (const r2 of ranges2) {
|
|
103
|
-
const intersection = r1.intersect(r2);
|
|
104
|
-
if (intersection !== null) {
|
|
105
|
-
result.push(intersection);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Determines if any range in the first set overlaps with any range in the second set.
|
|
113
|
-
*
|
|
114
|
-
* @param ranges1
|
|
115
|
-
* @param ranges2
|
|
116
|
-
* @returns
|
|
117
|
-
*/
|
|
118
|
-
static overlapsAny(ranges1, ranges2) {
|
|
119
|
-
for (const r1 of ranges1) {
|
|
120
|
-
for (const r2 of ranges2) {
|
|
121
|
-
if (r1.overlaps(r2)) {
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Subtracts the second set of ranges from the first set of ranges.
|
|
130
|
-
*
|
|
131
|
-
* @param ranges1
|
|
132
|
-
* @param ranges2
|
|
133
|
-
* @returns
|
|
134
|
-
*/
|
|
135
|
-
static subtractRanges(ranges1, ranges2) {
|
|
136
|
-
let currentRanges = ranges1;
|
|
137
|
-
for (const r2 of ranges2) {
|
|
138
|
-
const nextRanges = [];
|
|
139
|
-
for (const r1 of currentRanges) {
|
|
140
|
-
const subtracted = r1.subtract(r2);
|
|
141
|
-
for (const s of subtracted) {
|
|
142
|
-
nextRanges.push(s);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
currentRanges = nextRanges;
|
|
146
|
-
if (currentRanges.length === 0) {
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return currentRanges;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
exports.default = Range;
|
|
154
|
-
//# sourceMappingURL=range.js.map
|
package/dist/cjs/range.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../src/range.ts"],"names":[],"mappings":";;AAAA,MAAqB,KAAK;IAKtB;;;;OAIG;IACH,YAAY,KAAQ,EAAE,GAAM;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,KAAe;QAC5B,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;QACpE,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,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QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,WAAW,CAAI,OAAmB,EAAE,OAAmB;QACjE,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;YACvB,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;gBACvB,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;oBAClB,OAAO,IAAI,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,cAAc,CAAI,OAAmB,EAAE,OAAmB;QACpE,IAAI,aAAa,GAAG,OAAO,CAAC;QAC5B,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;YACvB,MAAM,UAAU,GAAe,EAAE,CAAC;YAClC,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;gBAC7B,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACnC,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;oBACzB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACvB,CAAC;YACL,CAAC;YACD,aAAa,GAAG,UAAU,CAAC;YAC3B,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM;YACV,CAAC;QACL,CAAC;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ;AApKD,wBAoKC","sourcesContent":["export default class Range<T> {\n\n private readonly start: T;\n private readonly end: T;\n\n /**\n * Range constructor.\n * @param start\n * @param end\n */\n constructor(start: T, end: T) {\n this.start = start;\n this.end = end;\n }\n\n /**\n * Finds the intersection between two ranges.\n *\n * @param other The Range object to intersect with.\n * @returns The intersected Range object, or null if there is no intersection.\n */\n public intersect(other: Range<T>): Range<T> | null {\n const start = (this.start > other.start) ? this.start : other.start;\n const end = (this.end < other.end) ? this.end : other.end;\n\n if (start < end) {\n return new Range(start, end);\n } else {\n return null;\n }\n }\n\n /**\n * Subtract the given range from this range.\n *\n * @param other The range to subtract from this range.\n * @returns An array of Range objects representing the result of the subtraction.\n */\n public subtract(other: Range<T>): Range<T>[] {\n const result: Range<T>[] = [];\n\n if (this.start >= other.end || this.end <= other.start) {\n result.push(new Range(this.start, this.end));\n } else if (other.start <= this.start && other.end >= this.end) {\n return result;\n } else {\n if (this.start < other.start) {\n result.push(new Range(this.start, other.start));\n }\n\n if (this.end > other.end) {\n result.push(new Range(other.end, this.end));\n }\n }\n\n return result;\n }\n\n /**\n * Determines if the given range overlaps with the current range.\n *\n * @param other The range to be checked for overlap.\n * @returns Returns true if there is an overlap between the ranges, false otherwise.\n */\n public overlaps(other: Range<T>): boolean {\n const s1 = this.start;\n const e1 = this.end;\n const s2 = other.start;\n const e2 = other.end;\n\n return (s2 > s1 && s2 < e1 || e2 > s1 && e2 < e1) ||\n (s1 > s2 && s1 < e2 || e1 > s2 && e1 < e2) ||\n (s1 === s2 && e1 === e2);\n }\n\n /**\n * Determines whether the specified value is within the range defined by the start and end values.\n *\n * @param obj The value to check if it is within the range.\n * @param inclusive Optional. If set to true, the range boundaries are considered inclusive.\n * @returns Returns true if the specified value is within the range, false otherwise.\n */\n public contains(obj: T, inclusive: boolean = true): boolean {\n return inclusive ?\n (this.start <= obj && this.end >= obj) :\n (this.start < obj && this.end > obj);\n }\n\n /**\n * @returns T\n */\n public getStart(): T {\n return this.start;\n }\n\n /**\n * @returns T\n */\n public getEnd(): T {\n return this.end;\n }\n\n /**\n * Finds the intersection between two sets of ranges.\n *\n * @param ranges1\n * @param ranges2\n * @returns\n */\n public static intersectRanges<T>(ranges1: Range<T>[], ranges2: Range<T>[]): Range<T>[] {\n const result: Range<T>[] = [];\n for (const r1 of ranges1) {\n for (const r2 of ranges2) {\n const intersection = r1.intersect(r2);\n if (intersection !== null) {\n result.push(intersection);\n }\n }\n }\n return result;\n }\n\n /**\n * Determines if any range in the first set overlaps with any range in the second set.\n *\n * @param ranges1\n * @param ranges2\n * @returns\n */\n public static overlapsAny<T>(ranges1: Range<T>[], ranges2: Range<T>[]): boolean {\n for (const r1 of ranges1) {\n for (const r2 of ranges2) {\n if (r1.overlaps(r2)) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Subtracts the second set of ranges from the first set of ranges.\n *\n * @param ranges1\n * @param ranges2\n * @returns\n */\n public static subtractRanges<T>(ranges1: Range<T>[], ranges2: Range<T>[]): Range<T>[] {\n let currentRanges = ranges1;\n for (const r2 of ranges2) {\n const nextRanges: Range<T>[] = [];\n for (const r1 of currentRanges) {\n const subtracted = r1.subtract(r2);\n for (const s of subtracted) {\n nextRanges.push(s);\n }\n }\n currentRanges = nextRanges;\n if (currentRanges.length === 0) {\n break;\n }\n }\n return currentRanges;\n }\n}\n"]}
|
package/dist/cjs/result.js
DELETED
package/dist/cjs/result.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/result.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents success and failure outputs narrowed by `success`.\n */\nexport type Result<TSuccessOutput, TFailureOutput = undefined> =\n | {readonly success: true; readonly output: TSuccessOutput}\n | {readonly success: false; readonly output?: TFailureOutput};\n"]}
|
package/dist/cjs/stopwatch.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const timespan_js_1 = __importDefault(require("./timespan.js"));
|
|
7
|
-
class Stopwatch {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.startTime = null;
|
|
10
|
-
this.elapsedTime = null;
|
|
11
|
-
}
|
|
12
|
-
/*static measure<T>(callback: () => T, measure: { value: TimeSpan | null }): T {
|
|
13
|
-
const stopwatch = new Stopwatch();
|
|
14
|
-
stopwatch.start();
|
|
15
|
-
try {
|
|
16
|
-
return callback();
|
|
17
|
-
} finally {
|
|
18
|
-
stopwatch.stop();
|
|
19
|
-
measure.value = stopwatch.getElapsedTime();
|
|
20
|
-
}
|
|
21
|
-
}*/
|
|
22
|
-
start() {
|
|
23
|
-
this.startTime = performance.now();
|
|
24
|
-
this.elapsedTime = null;
|
|
25
|
-
}
|
|
26
|
-
stop() {
|
|
27
|
-
if (this.startTime !== null) {
|
|
28
|
-
this.elapsedTime = performance.now() - this.startTime;
|
|
29
|
-
this.startTime = null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
resume() {
|
|
33
|
-
if (this.elapsedTime !== null) {
|
|
34
|
-
this.startTime = performance.now() - this.elapsedTime;
|
|
35
|
-
this.elapsedTime = null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
getElapsedTime() {
|
|
39
|
-
if (this.startTime !== null) {
|
|
40
|
-
return timespan_js_1.default.fromMilliseconds(performance.now() - this.startTime);
|
|
41
|
-
}
|
|
42
|
-
return timespan_js_1.default.fromMilliseconds(this.elapsedTime ?? 0.0);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.default = Stopwatch;
|
|
46
|
-
//# sourceMappingURL=stopwatch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stopwatch.js","sourceRoot":"","sources":["../../src/stopwatch.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AAErC,MAAqB,SAAS;IAA9B;QACY,cAAS,GAAkB,IAAI,CAAC;QAChC,gBAAW,GAAkB,IAAI,CAAC;IAsC9C,CAAC;IApCG;;;;;;;;;OASG;IAEH,KAAK;QACD,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI;QACA,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;YACtD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAC1B,CAAC;IACL,CAAC;IAED,MAAM;QACF,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;YACtD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC5B,CAAC;IACL,CAAC;IAED,cAAc;QACV,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YAC1B,OAAO,qBAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,qBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC;IAC9D,CAAC;CACJ;AAxCD,4BAwCC","sourcesContent":["import TimeSpan from \"./timespan.js\";\n\nexport default class Stopwatch {\n private startTime: number | null = null;\n private elapsedTime: number | null = null;\n\n /*static measure<T>(callback: () => T, measure: { value: TimeSpan | null }): T {\n const stopwatch = new Stopwatch();\n stopwatch.start();\n try {\n return callback();\n } finally {\n stopwatch.stop();\n measure.value = stopwatch.getElapsedTime();\n }\n }*/\n\n start(): void {\n this.startTime = performance.now();\n this.elapsedTime = null;\n }\n\n stop(): void {\n if (this.startTime !== null) {\n this.elapsedTime = performance.now() - this.startTime;\n this.startTime = null;\n }\n }\n\n resume(): void {\n if (this.elapsedTime !== null) {\n this.startTime = performance.now() - this.elapsedTime;\n this.elapsedTime = null;\n }\n }\n\n getElapsedTime(): TimeSpan {\n if (this.startTime !== null) {\n return TimeSpan.fromMilliseconds(performance.now() - this.startTime);\n }\n return TimeSpan.fromMilliseconds(this.elapsedTime ?? 0.0);\n }\n}\n"]}
|