@futdevpro/fsm-dynamo 1.14.10 → 1.14.12
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/.vscode/settings.json +11 -0
- package/build/_collections/constants/data-sizes.const.d.ts +3 -3
- package/build/_collections/constants/data-sizes.const.d.ts.map +1 -1
- package/build/_collections/constants/data-sizes.const.js +4 -3
- package/build/_collections/constants/data-sizes.const.js.map +1 -1
- package/build/_collections/utils/array.util.d.ts +189 -0
- package/build/_collections/utils/array.util.d.ts.map +1 -1
- package/build/_collections/utils/array.util.js +189 -0
- package/build/_collections/utils/array.util.js.map +1 -1
- package/build/_collections/utils/async.util.d.ts +29 -0
- package/build/_collections/utils/async.util.d.ts.map +1 -1
- package/build/_collections/utils/async.util.js +45 -3
- package/build/_collections/utils/async.util.js.map +1 -1
- package/build/_collections/utils/json-error-helper.util.d.ts +38 -0
- package/build/_collections/utils/json-error-helper.util.d.ts.map +1 -1
- package/build/_collections/utils/json-error-helper.util.js +38 -0
- package/build/_collections/utils/json-error-helper.util.js.map +1 -1
- package/build/_collections/utils/log.util.d.ts +195 -5
- package/build/_collections/utils/log.util.d.ts.map +1 -1
- package/build/_collections/utils/log.util.js +245 -53
- package/build/_collections/utils/log.util.js.map +1 -1
- package/build/_collections/utils/math/box-bounds.util.d.ts +36 -0
- package/build/_collections/utils/math/box-bounds.util.d.ts.map +1 -1
- package/build/_collections/utils/math/box-bounds.util.js +38 -6
- package/build/_collections/utils/math/box-bounds.util.js.map +1 -1
- package/build/_collections/utils/math/math.util.d.ts +48 -12
- package/build/_collections/utils/math/math.util.d.ts.map +1 -1
- package/build/_collections/utils/math/math.util.js +51 -15
- package/build/_collections/utils/math/math.util.js.map +1 -1
- package/build/_collections/utils/math/math.util.spec.js +0 -9
- package/build/_collections/utils/math/math.util.spec.js.map +1 -1
- package/build/_collections/utils/math/random.util.d.ts +30 -0
- package/build/_collections/utils/math/random.util.d.ts.map +1 -1
- package/build/_collections/utils/math/random.util.js +30 -0
- package/build/_collections/utils/math/random.util.js.map +1 -1
- package/build/_collections/utils/math/trigonometry.util.d.ts +30 -0
- package/build/_collections/utils/math/trigonometry.util.d.ts.map +1 -1
- package/build/_collections/utils/math/trigonometry.util.js +30 -0
- package/build/_collections/utils/math/trigonometry.util.js.map +1 -1
- package/build/_collections/utils/math/vector2.util.d.ts +247 -17
- package/build/_collections/utils/math/vector2.util.d.ts.map +1 -1
- package/build/_collections/utils/math/vector2.util.js +309 -79
- package/build/_collections/utils/math/vector2.util.js.map +1 -1
- package/build/_collections/utils/object.util.js +9 -7
- package/build/_collections/utils/object.util.js.map +1 -1
- package/build/_collections/utils/regex/password-regex.util.d.ts +12 -0
- package/build/_collections/utils/regex/password-regex.util.d.ts.map +1 -1
- package/build/_collections/utils/regex/password-regex.util.js +12 -0
- package/build/_collections/utils/regex/password-regex.util.js.map +1 -1
- package/build/_collections/utils/round-list.util.d.ts +39 -0
- package/build/_collections/utils/round-list.util.d.ts.map +1 -1
- package/build/_collections/utils/round-list.util.js +39 -0
- package/build/_collections/utils/round-list.util.js.map +1 -1
- package/build/_collections/utils/stack.util.d.ts +19 -0
- package/build/_collections/utils/stack.util.d.ts.map +1 -1
- package/build/_collections/utils/stack.util.js +22 -2
- package/build/_collections/utils/stack.util.js.map +1 -1
- package/build/_collections/utils/stack.util.spec.js +0 -13
- package/build/_collections/utils/stack.util.spec.js.map +1 -1
- package/build/_collections/utils/string.util.d.ts +17 -0
- package/build/_collections/utils/string.util.d.ts.map +1 -1
- package/build/_collections/utils/string.util.js +17 -0
- package/build/_collections/utils/string.util.js.map +1 -1
- package/build/_collections/utils/time.util.d.ts +136 -0
- package/build/_collections/utils/time.util.d.ts.map +1 -1
- package/build/_collections/utils/time.util.js +164 -28
- package/build/_collections/utils/time.util.js.map +1 -1
- package/build/_collections/utils/utilities.util.d.ts +17 -1
- package/build/_collections/utils/utilities.util.d.ts.map +1 -1
- package/build/_collections/utils/utilities.util.js +17 -1
- package/build/_collections/utils/utilities.util.js.map +1 -1
- package/build/_collections/utils/uuid.util.d.ts +6 -0
- package/build/_collections/utils/uuid.util.d.ts.map +1 -1
- package/build/_collections/utils/uuid.util.js +6 -0
- package/build/_collections/utils/uuid.util.js.map +1 -1
- package/build/_enums/data-model-type.enum.d.ts +6 -0
- package/build/_enums/data-model-type.enum.d.ts.map +1 -1
- package/build/_enums/data-model-type.enum.js +6 -0
- package/build/_enums/data-model-type.enum.js.map +1 -1
- package/build/_enums/http/http-call-type.enum.d.ts +8 -0
- package/build/_enums/http/http-call-type.enum.d.ts.map +1 -1
- package/build/_enums/http/http-call-type.enum.js +8 -0
- package/build/_enums/http/http-call-type.enum.js.map +1 -1
- package/build/_enums/http/http-event-type.enum.d.ts +5 -0
- package/build/_enums/http/http-event-type.enum.d.ts.map +1 -1
- package/build/_enums/http/http-event-type.enum.js +5 -0
- package/build/_enums/http/http-event-type.enum.js.map +1 -1
- package/build/_enums/time/day-of-week.enum.d.ts +14 -1
- package/build/_enums/time/day-of-week.enum.d.ts.map +1 -1
- package/build/_enums/time/day-of-week.enum.js +14 -1
- package/build/_enums/time/day-of-week.enum.js.map +1 -1
- package/build/_models/control-models/data-model-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/data-model-params.control-model.js +11 -22
- package/build/_models/control-models/data-model-params.control-model.js.map +1 -1
- package/build/_models/control-models/data-property-params.control-model.d.ts +8 -0
- package/build/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/data-property-params.control-model.js +11 -59
- package/build/_models/control-models/data-property-params.control-model.js.map +1 -1
- package/build/_models/control-models/error.control-model.js +8 -25
- package/build/_models/control-models/error.control-model.js.map +1 -1
- package/build/_models/control-models/http/http-error-response.control-model.d.ts +25 -0
- package/build/_models/control-models/http/http-error-response.control-model.d.ts.map +1 -1
- package/build/_models/control-models/http/http-error-response.control-model.js +30 -7
- package/build/_models/control-models/http/http-error-response.control-model.js.map +1 -1
- package/build/_models/control-models/http/http-headers.control-model.d.ts +8 -0
- package/build/_models/control-models/http/http-headers.control-model.d.ts.map +1 -1
- package/build/_models/control-models/http/http-headers.control-model.js +12 -17
- package/build/_models/control-models/http/http-headers.control-model.js.map +1 -1
- package/build/_models/control-models/http/http-response.model-base.d.ts +9 -0
- package/build/_models/control-models/http/http-response.model-base.d.ts.map +1 -1
- package/build/_models/control-models/http/http-response.model-base.js +23 -26
- package/build/_models/control-models/http/http-response.model-base.js.map +1 -1
- package/build/_models/control-models/poll.control-model.d.ts +18 -0
- package/build/_models/control-models/poll.control-model.d.ts.map +1 -1
- package/build/_models/control-models/poll.control-model.js +22 -26
- package/build/_models/control-models/poll.control-model.js.map +1 -1
- package/build/_models/control-models/range-value.control-model.d.ts +141 -0
- package/build/_models/control-models/range-value.control-model.d.ts.map +1 -1
- package/build/_models/control-models/range-value.control-model.js +143 -4
- package/build/_models/control-models/range-value.control-model.js.map +1 -1
- package/build/_models/control-models/server-status.control-model.d.ts +10 -0
- package/build/_models/control-models/server-status.control-model.d.ts.map +1 -1
- package/build/_models/control-models/server-status.control-model.js +10 -12
- package/build/_models/control-models/server-status.control-model.js.map +1 -1
- package/build/_models/control-models/service-endpoint-settings-base.control-model.d.ts +34 -1
- package/build/_models/control-models/service-endpoint-settings-base.control-model.d.ts.map +1 -1
- package/build/_models/control-models/service-endpoint-settings-base.control-model.js +26 -5
- package/build/_models/control-models/service-endpoint-settings-base.control-model.js.map +1 -1
- package/build/_models/data-models/errors.data-model.d.ts +10 -0
- package/build/_models/data-models/errors.data-model.d.ts.map +1 -1
- package/build/_models/data-models/errors.data-model.js +13 -18
- package/build/_models/data-models/errors.data-model.js.map +1 -1
- package/build/_models/data-models/metadata.data-model.d.ts +26 -0
- package/build/_models/data-models/metadata.data-model.d.ts.map +1 -1
- package/build/_models/data-models/metadata.data-model.js +26 -12
- package/build/_models/data-models/metadata.data-model.js.map +1 -1
- package/build/_modules/ai/_models/ai-call-settings.interface.js +46 -49
- package/build/_modules/ai/_models/ai-call-settings.interface.js.map +1 -1
- package/build/_modules/ai/_models/ai-settings.interface.js +0 -3
- package/build/_modules/ai/_models/ai-settings.interface.js.map +1 -1
- package/build/_modules/ai/_modules/anthropic/_models/aai-call-settings.control-model.js +2 -2
- package/build/_modules/ai/_modules/anthropic/_models/aai-call-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/anthropic/_models/aai-settings.control-model.js +3 -3
- package/build/_modules/ai/_modules/anthropic/_models/aai-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/google-ai/_models/gai-call-settings.control-model.js +2 -2
- package/build/_modules/ai/_modules/google-ai/_models/gai-call-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/google-ai/_models/gai-settings.control-model.js +3 -3
- package/build/_modules/ai/_modules/google-ai/_models/gai-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/local-ai/_models/lai-call-settings.control-model.js +1 -1
- package/build/_modules/ai/_modules/local-ai/_models/lai-call-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/local-ai/_models/lai-settings.control-model.js +3 -3
- package/build/_modules/ai/_modules/local-ai/_models/lai-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_models/oai-call-settings.control-model.js +2 -2
- package/build/_modules/ai/_modules/open-ai/_models/oai-call-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_models/oai-settings.control-model.js +3 -3
- package/build/_modules/ai/_modules/open-ai/_models/oai-settings.control-model.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/index.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/index.js +7 -7
- package/build/_modules/ai/_modules/open-ai/index.js.map +1 -1
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.d.ts +23 -0
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.d.ts.map +1 -1
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.js +24 -12
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto-2-non-stable.util.js +2 -2
- package/build/_modules/crypto/_collections/crypto-2-non-stable.util.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto-old.util.d.ts.map +1 -1
- package/build/_modules/crypto/_collections/crypto-old.util.js +16 -16
- package/build/_modules/crypto/_collections/crypto-old.util.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.js +9 -9
- package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
- package/build/_modules/custom-data/_models/cud.data-model.d.ts +7 -0
- package/build/_modules/custom-data/_models/cud.data-model.d.ts.map +1 -1
- package/build/_modules/custom-data/_models/cud.data-model.js +7 -1
- package/build/_modules/custom-data/_models/cud.data-model.js.map +1 -1
- package/build/_modules/data-handler/_models/data-handler-settings.control-model.d.ts +73 -0
- package/build/_modules/data-handler/_models/data-handler-settings.control-model.d.ts.map +1 -0
- package/build/_modules/data-handler/_models/data-handler-settings.control-model.js +41 -0
- package/build/_modules/data-handler/_models/data-handler-settings.control-model.js.map +1 -0
- package/build/_modules/data-handler/_models/data-handler.control-model.d.ts +136 -0
- package/build/_modules/data-handler/_models/data-handler.control-model.d.ts.map +1 -0
- package/build/_modules/data-handler/_models/data-handler.control-model.js +293 -0
- package/build/_modules/data-handler/_models/data-handler.control-model.js.map +1 -0
- package/build/_modules/data-handler/_models/data-list-handler.control-model.d.ts +111 -0
- package/build/_modules/data-handler/_models/data-list-handler.control-model.d.ts.map +1 -0
- package/build/_modules/data-handler/_models/data-list-handler.control-model.js +197 -0
- package/build/_modules/data-handler/_models/data-list-handler.control-model.js.map +1 -0
- package/build/_modules/data-handler/_models/data-search-handler.control-model.d.ts +172 -0
- package/build/_modules/data-handler/_models/data-search-handler.control-model.d.ts.map +1 -0
- package/build/_modules/data-handler/_models/data-search-handler.control-model.js +319 -0
- package/build/_modules/data-handler/_models/data-search-handler.control-model.js.map +1 -0
- package/build/_modules/data-handler/_models/list-collector-data-handler.control-model.d.ts +116 -0
- package/build/_modules/data-handler/_models/list-collector-data-handler.control-model.d.ts.map +1 -0
- package/build/_modules/data-handler/_models/list-collector-data-handler.control-model.js +220 -0
- package/build/_modules/data-handler/_models/list-collector-data-handler.control-model.js.map +1 -0
- package/build/_modules/data-handler/index.d.ts +6 -0
- package/build/_modules/data-handler/index.d.ts.map +1 -0
- package/build/_modules/data-handler/index.js +10 -0
- package/build/_modules/data-handler/index.js.map +1 -0
- package/build/_modules/location/_collections/loc-regions.util.d.ts +33 -0
- package/build/_modules/location/_collections/loc-regions.util.d.ts.map +1 -1
- package/build/_modules/location/_collections/loc-regions.util.js +37 -4
- package/build/_modules/location/_collections/loc-regions.util.js.map +1 -1
- package/build/_modules/location/_collections/loc.util.d.ts +10 -0
- package/build/_modules/location/_collections/loc.util.d.ts.map +1 -1
- package/build/_modules/location/_collections/loc.util.js +10 -0
- package/build/_modules/location/_collections/loc.util.js.map +1 -1
- package/build/_modules/messaging/_models/msg-conversation.data-model.js +0 -23
- package/build/_modules/messaging/_models/msg-conversation.data-model.js.map +1 -1
- package/build/_modules/messaging/_models/msg-message.data-model.js +0 -34
- package/build/_modules/messaging/_models/msg-message.data-model.js.map +1 -1
- package/build/_modules/socket/_models/sck-client-params.control-model.js +2 -7
- package/build/_modules/socket/_models/sck-client-params.control-model.js.map +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.js +0 -8
- package/build/_modules/socket/_models/sck-socket-event.control-model.js.map +1 -1
- package/build/_modules/socket/_services/sck-client.service-base.js +69 -72
- package/build/_modules/socket/_services/sck-client.service-base.js.map +1 -1
- package/build/_modules/usage/_models/usg-action.control-model.js +0 -4
- package/build/_modules/usage/_models/usg-action.control-model.js.map +1 -1
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.js +10 -12
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.js.map +1 -1
- package/build/_modules/usage/_models/usg-data.control-model.js +2 -8
- package/build/_modules/usage/_models/usg-data.control-model.js.map +1 -1
- package/build/_modules/usage/_models/usg-session.data-model.js +2 -18
- package/build/_modules/usage/_models/usg-session.data-model.js.map +1 -1
- package/eslint.config.js +4 -0
- package/futdevpro-fsm-dynamo-01.14.12.tgz +0 -0
- package/package.json +22 -3
- package/src/_collections/constants/data-sizes.const.ts +4 -4
- package/src/_collections/utils/array.util.ts +189 -0
- package/src/_collections/utils/async.util.ts +40 -0
- package/src/_collections/utils/json-error-helper.util.ts +43 -3
- package/src/_collections/utils/log.util.ts +194 -4
- package/src/_collections/utils/math/box-bounds.util.ts +36 -0
- package/src/_collections/utils/math/math.util.spec.ts +0 -10
- package/src/_collections/utils/math/math.util.ts +48 -16
- package/src/_collections/utils/math/random.util.ts +30 -0
- package/src/_collections/utils/math/trigonometry.util.ts +30 -0
- package/src/_collections/utils/math/vector2.util.ts +254 -24
- package/src/_collections/utils/regex/password-regex.util.ts +12 -0
- package/src/_collections/utils/round-list.util.ts +39 -0
- package/src/_collections/utils/stack.util.ts +27 -4
- package/src/_collections/utils/string.util.ts +17 -0
- package/src/_collections/utils/time.util.ts +136 -0
- package/src/_collections/utils/utilities.util.ts +17 -1
- package/src/_collections/utils/uuid.util.ts +6 -0
- package/src/_enums/data-model-type.enum.ts +6 -0
- package/src/_enums/http/http-call-type.enum.ts +8 -0
- package/src/_enums/http/http-event-type.enum.ts +5 -0
- package/src/_enums/time/day-of-week.enum.ts +14 -1
- package/src/_models/control-models/data-model-params.control-model.ts +11 -1
- package/src/_models/control-models/data-property-params.control-model.ts +8 -0
- package/src/_models/control-models/http/http-error-response.control-model.ts +25 -0
- package/src/_models/control-models/http/http-headers.control-model.ts +8 -0
- package/src/_models/control-models/http/http-response.model-base.ts +9 -0
- package/src/_models/control-models/poll.control-model.ts +18 -0
- package/src/_models/control-models/range-value.control-model.ts +141 -0
- package/src/_models/control-models/server-status.control-model.ts +10 -0
- package/src/_models/control-models/service-endpoint-settings-base.control-model.ts +53 -4
- package/src/_models/data-models/errors.data-model.ts +10 -0
- package/src/_models/data-models/metadata.data-model.ts +27 -0
- package/src/_modules/ai/_modules/open-ai/index.ts +4 -3
- package/src/_modules/ci-tools/_models/cit-ci-result-info.data-models.ts +23 -0
- package/src/_modules/crypto/_collections/crypto-old.util.ts +17 -9
- package/src/_modules/custom-data/_models/cud.data-model.ts +7 -0
- package/src/_modules/data-handler/_models/data-handler-settings.control-model.ts +110 -0
- package/src/_modules/data-handler/_models/data-handler.control-model.ts +459 -0
- package/src/_modules/data-handler/_models/data-list-handler.control-model.ts +245 -0
- package/src/_modules/data-handler/_models/data-search-handler.control-model.ts +390 -0
- package/src/_modules/data-handler/_models/list-collector-data-handler.control-model.ts +274 -0
- package/src/_modules/data-handler/index.ts +6 -0
- package/src/_modules/location/_collections/loc-regions.util.ts +34 -1
- package/src/_modules/location/_collections/loc.util.ts +10 -0
- package/src/_modules/usage/_collections/usg-module-settings.const.ts +1 -1
- package/tsconfig.json +2 -2
- package/.eslintrc.json +0 -155
- package/futdevpro-fsm-dynamo-01.14.10.tgz +0 -0
|
@@ -7,6 +7,14 @@ class DyFM_Array {
|
|
|
7
7
|
* @param list - The array to iterate over.
|
|
8
8
|
* @param func - The function to apply to each element.
|
|
9
9
|
* @returns A promise that resolves when all elements have been processed.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
14
|
+
* await DyFM_Array.asyncForEach(list, async (element: number, index?: number, array?: number[]): Promise<void> => {
|
|
15
|
+
* console.log(element, index, array);
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
10
18
|
*/
|
|
11
19
|
static async asyncForEach(list, func) {
|
|
12
20
|
for (let i = 0; i < list.length; i++) {
|
|
@@ -19,6 +27,14 @@ class DyFM_Array {
|
|
|
19
27
|
* @param list - The array to iterate over.
|
|
20
28
|
* @param func - The function to apply to each element.
|
|
21
29
|
* @returns A promise that resolves to the final result.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
34
|
+
* const result = await DyFM_Array.asyncForEachReturnToOne(0, list, async (element: number, dataCurrent: number, index?: number, array?: number[]): Promise<number> => {
|
|
35
|
+
* return dataCurrent + element;
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
22
38
|
*/
|
|
23
39
|
static async asyncForEachReturnToOne(startData, list, func) {
|
|
24
40
|
let result = startData;
|
|
@@ -32,6 +48,14 @@ class DyFM_Array {
|
|
|
32
48
|
* @param list - The array to iterate over.
|
|
33
49
|
* @param func - The function to apply to each element.
|
|
34
50
|
* @returns A promise that resolves to an array of results.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
55
|
+
* const result = await DyFM_Array.asyncForEachReturnToAll(list, async (element: number, index?: number, array?: number[]): Promise<number> => {
|
|
56
|
+
* return element * 2;
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
35
59
|
*/
|
|
36
60
|
static async asyncForEachReturnToAll(list, func) {
|
|
37
61
|
const resultList = [];
|
|
@@ -45,6 +69,15 @@ class DyFM_Array {
|
|
|
45
69
|
* @param list - The array to iterate over.
|
|
46
70
|
* @param func - The function to apply to each element.
|
|
47
71
|
* @returns A promise that resolves to an array of results.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
76
|
+
* const result = await DyFM_Array.asyncForEachAllAtOnce(list, async (element: number, index?: number, array?: number[]): Promise<number> => {
|
|
77
|
+
* return [ element * 2, element * 3 ];
|
|
78
|
+
* });
|
|
79
|
+
* console.log(result); // [ [ 2, 3 ], [ 4, 6 ], [ 6, 9 ] ]
|
|
80
|
+
* ```
|
|
48
81
|
*/
|
|
49
82
|
static async asyncForEachAllAtOnce(list, func) {
|
|
50
83
|
return await Promise.all(list.map(func));
|
|
@@ -54,6 +87,15 @@ class DyFM_Array {
|
|
|
54
87
|
* @param list - The array to filter.
|
|
55
88
|
* @param filterFunc - The function to apply to each element.
|
|
56
89
|
* @returns A promise that resolves to an array of results.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
94
|
+
* const result = await DyFM_Array.asyncFilter(list, async (element: number, index?: number, array?: number[]): Promise<boolean> => {
|
|
95
|
+
* return element % 2 === 0;
|
|
96
|
+
* });
|
|
97
|
+
* console.log(result); // [ 2 ]
|
|
98
|
+
* ```
|
|
57
99
|
*/
|
|
58
100
|
static async asyncFilter(list, filterFunc) {
|
|
59
101
|
const resultList = [];
|
|
@@ -69,6 +111,15 @@ class DyFM_Array {
|
|
|
69
111
|
* @param list - The array to map.
|
|
70
112
|
* @param mapFunc - The function to apply to each element.
|
|
71
113
|
* @returns A promise that resolves to an array of results.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
118
|
+
* const result = await DyFM_Array.asyncMap(list, async (element: number, index?: number, array?: number[]): Promise<number> => {
|
|
119
|
+
* return element * 2;
|
|
120
|
+
* });
|
|
121
|
+
* console.log(result); // [ 2, 4, 6 ]
|
|
122
|
+
* ```
|
|
72
123
|
*/
|
|
73
124
|
static async asyncMap(list, mapFunc) {
|
|
74
125
|
const resultList = [];
|
|
@@ -81,6 +132,13 @@ class DyFM_Array {
|
|
|
81
132
|
* Returns the last element of an array.
|
|
82
133
|
* @param array - The array to get the last element from.
|
|
83
134
|
* @returns The last element of the array, or null if the array is empty.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
139
|
+
* const result = DyFM_Array.last(list);
|
|
140
|
+
* console.log(result); // 3
|
|
141
|
+
* ```
|
|
84
142
|
*/
|
|
85
143
|
static last(array) {
|
|
86
144
|
return array?.length ? array[array.length - 1] : null;
|
|
@@ -90,6 +148,13 @@ class DyFM_Array {
|
|
|
90
148
|
* @param string - The string to check.
|
|
91
149
|
* @param array - The array to check.
|
|
92
150
|
* @returns True if the string is the last element of the array, false otherwise.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
155
|
+
* const result = DyFM_Array.isLast(3, list);
|
|
156
|
+
* console.log(result); // true
|
|
157
|
+
* ```
|
|
93
158
|
*/
|
|
94
159
|
static isLast(element, array) {
|
|
95
160
|
return array.indexOf(element) === array.length - 1;
|
|
@@ -99,6 +164,13 @@ class DyFM_Array {
|
|
|
99
164
|
* @param string - The string to check.
|
|
100
165
|
* @param array - The array to check.
|
|
101
166
|
* @returns True if the string is the last element of the array, false otherwise.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
171
|
+
* const result = DyFM_Array.isLastIndex(2, list);
|
|
172
|
+
* console.log(result); // true
|
|
173
|
+
* ```
|
|
102
174
|
*/
|
|
103
175
|
static isLastIndex(index, array) {
|
|
104
176
|
return index === array.length - 1;
|
|
@@ -108,6 +180,13 @@ class DyFM_Array {
|
|
|
108
180
|
* @param string - The string to check.
|
|
109
181
|
* @param array - The array to check.
|
|
110
182
|
* @returns True if the string is the first element of the array, false otherwise.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
187
|
+
* const result = DyFM_Array.isFirst(1, list);
|
|
188
|
+
* console.log(result); // true
|
|
189
|
+
* ```
|
|
111
190
|
*/
|
|
112
191
|
static isFirst(element, array) {
|
|
113
192
|
return array.indexOf(element) === 0;
|
|
@@ -116,6 +195,13 @@ class DyFM_Array {
|
|
|
116
195
|
* Returns the last character of a string.
|
|
117
196
|
* @param string - The string to get the last character from.
|
|
118
197
|
* @returns The last character of the string, or null if the string is empty.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const string = 'hello';
|
|
202
|
+
* const result = DyFM_Array.lastCharacter(string);
|
|
203
|
+
* console.log(result); // 'o'
|
|
204
|
+
* ```
|
|
119
205
|
*/
|
|
120
206
|
static lastCharacter(string) {
|
|
121
207
|
return string?.length ? string[string.length - 1] : null;
|
|
@@ -124,6 +210,13 @@ class DyFM_Array {
|
|
|
124
210
|
* Returns the first element of an array.
|
|
125
211
|
* @param array - The array to get the first element from.
|
|
126
212
|
* @returns The first element of the array, or null if the array is empty.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
217
|
+
* const result = DyFM_Array.first(list);
|
|
218
|
+
* console.log(result); // 1
|
|
219
|
+
* ```
|
|
127
220
|
*/
|
|
128
221
|
static first(array) {
|
|
129
222
|
return array?.length ? array[0] : null;
|
|
@@ -133,6 +226,13 @@ class DyFM_Array {
|
|
|
133
226
|
* @param array - The array to remove the element from.
|
|
134
227
|
* @param element - The element to remove from the array.
|
|
135
228
|
* @returns The array with the element removed.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
233
|
+
* const result = DyFM_Array.remove(list, 2);
|
|
234
|
+
* console.log(result); // [ 1, 3 ]
|
|
235
|
+
* ```
|
|
136
236
|
*/
|
|
137
237
|
static remove(array, element) {
|
|
138
238
|
const index = array.indexOf(element);
|
|
@@ -146,6 +246,15 @@ class DyFM_Array {
|
|
|
146
246
|
* @param array - The array to find and remove the element from.
|
|
147
247
|
* @param func - The function to apply to each element.
|
|
148
248
|
* @returns The array with the element removed.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
253
|
+
* const result = DyFM_Array.findNRemove(list, (element: number, index?: number, array?: number[]): boolean => {
|
|
254
|
+
* return element === 2;
|
|
255
|
+
* });
|
|
256
|
+
* console.log(result); // [ 1, 3 ]
|
|
257
|
+
* ```
|
|
149
258
|
*/
|
|
150
259
|
static findNRemove(array, func) {
|
|
151
260
|
const index = array.findIndex(func);
|
|
@@ -158,6 +267,13 @@ class DyFM_Array {
|
|
|
158
267
|
* Shuffles an array.
|
|
159
268
|
* @param array - The array to shuffle.
|
|
160
269
|
* @returns The shuffled array.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
274
|
+
* const result = DyFM_Array.shuffle(list);
|
|
275
|
+
* console.log(result); // [ 3, 1, 2 ]
|
|
276
|
+
* ```
|
|
161
277
|
*/
|
|
162
278
|
static shuffle(array) {
|
|
163
279
|
let currentIndex = array.length;
|
|
@@ -175,6 +291,13 @@ class DyFM_Array {
|
|
|
175
291
|
* @param pageIndex - The index of the page to return.
|
|
176
292
|
* @param pageSize - The size of the page.
|
|
177
293
|
* @returns The page of the array.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* const list: number[] = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
|
|
298
|
+
* const result = DyFM_Array.page(list, 0, 2);
|
|
299
|
+
* console.log(result); // [ 1, 2 ]
|
|
300
|
+
* ```
|
|
178
301
|
*/
|
|
179
302
|
static page(array, pageIndex, pageSize) {
|
|
180
303
|
return array.slice(pageIndex * pageSize, (pageIndex + 1) * pageSize);
|
|
@@ -185,6 +308,13 @@ class DyFM_Array {
|
|
|
185
308
|
* @param pageIndex - The index of the page to return.
|
|
186
309
|
* @param pageSize - The size of the page.
|
|
187
310
|
* @returns The page of the array.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* const list: number[] = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
|
|
315
|
+
* const result = DyFM_Array.paged(list, 0, 2);
|
|
316
|
+
* console.log(result); // { pageIndex: 0, pageSize: 2, total: 8, totalPageCount: 4, items: [ 1, 2 ] }
|
|
317
|
+
* ```
|
|
188
318
|
*/
|
|
189
319
|
static paged(array, pageIndex, pageSize) {
|
|
190
320
|
return {
|
|
@@ -201,6 +331,13 @@ class DyFM_Array {
|
|
|
201
331
|
* @param indexA - The index of the first element to swap.
|
|
202
332
|
* @param indexB - The index of the second element to swap.
|
|
203
333
|
* @returns The array with the elements swapped.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
338
|
+
* const result = DyFM_Array.swap(list, 0, 2);
|
|
339
|
+
* console.log(result); // [ 3, 2, 1 ]
|
|
340
|
+
* ```
|
|
204
341
|
*/
|
|
205
342
|
static swap(array, indexA, indexB) {
|
|
206
343
|
[array[indexA], array[indexB]] = [array[indexB], array[indexA]];
|
|
@@ -210,6 +347,13 @@ class DyFM_Array {
|
|
|
210
347
|
* Checks if a string list has multiplications.
|
|
211
348
|
* @param stringList - The string list to check.
|
|
212
349
|
* @returns True if the string list has multiplications, false otherwise.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* const list: string[] = [ 'a', 'b', 'c', 'a' ];
|
|
354
|
+
* const result = DyFM_Array.stringListHasMultiplications(list);
|
|
355
|
+
* console.log(result); // true
|
|
356
|
+
* ```
|
|
213
357
|
*/
|
|
214
358
|
static stringListHasMultiplications(stringList) {
|
|
215
359
|
return stringList.some((str, index) => {
|
|
@@ -220,6 +364,13 @@ class DyFM_Array {
|
|
|
220
364
|
* Filters a string list to remove multiplications.
|
|
221
365
|
* @param stringList - The string list to filter.
|
|
222
366
|
* @returns The filtered string list.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* const list: string[] = [ 'a', 'b', 'c', 'a' ];
|
|
371
|
+
* const result = DyFM_Array.filterStringMultiplications(list);
|
|
372
|
+
* console.log(result); // [ 'a', 'b', 'c' ]
|
|
373
|
+
* ```
|
|
223
374
|
*/
|
|
224
375
|
static filterStringMultiplications(stringList) {
|
|
225
376
|
return stringList.filter((str, index) => {
|
|
@@ -230,6 +381,13 @@ class DyFM_Array {
|
|
|
230
381
|
* Gathers multiplications from a string list.
|
|
231
382
|
* @param stringList - The string list to gather multiplications from.
|
|
232
383
|
* @returns The gathered multiplications.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```ts
|
|
387
|
+
* const list: string[] = [ 'a', 'b', 'c', 'a' ];
|
|
388
|
+
* const result = DyFM_Array.gatherStringMultiplications(list);
|
|
389
|
+
* console.log(result); // [ [ 'a', 'a' ] ]
|
|
390
|
+
* ```
|
|
233
391
|
*/
|
|
234
392
|
static gatherStringMultiplications(stringList) {
|
|
235
393
|
const multiplications = [];
|
|
@@ -249,6 +407,13 @@ class DyFM_Array {
|
|
|
249
407
|
* @param dataList - The data list to check.
|
|
250
408
|
* @param byKey - The key to check for multiplications.
|
|
251
409
|
* @returns True if the data list has multiplications, false otherwise.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* const list: { _id: number, name: string }[] = [ { _id: 1, name: 'John' }, { _id: 2, name: 'Jane' }, { _id: 1, name: 'Bob' } ];
|
|
414
|
+
* const result = DyFM_Array.haveMultiplications(list, '_id');
|
|
415
|
+
* console.log(result); // true
|
|
416
|
+
* ```
|
|
252
417
|
*/
|
|
253
418
|
static haveMultiplications(dataList, byKey = '_id') {
|
|
254
419
|
return dataList.some((data, index) => {
|
|
@@ -260,6 +425,13 @@ class DyFM_Array {
|
|
|
260
425
|
* @param dataList - The data list to filter.
|
|
261
426
|
* @param byKey - The key to filter for multiplications.
|
|
262
427
|
* @returns The filtered data list.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* const list: { _id: number, name: string }[] = [ { _id: 1, name: 'John' }, { _id: 2, name: 'Jane' }, { _id: 1, name: 'Bob' } ];
|
|
432
|
+
* const result = DyFM_Array.filterMultiplications(list, '_id');
|
|
433
|
+
* console.log(result); // [ { _id: 1, name: 'John' } , { _id: 2, name: 'Jane' } ]
|
|
434
|
+
* ```
|
|
263
435
|
*/
|
|
264
436
|
static filterMultiplications(dataList, byKey = '_id') {
|
|
265
437
|
return dataList.filter((data, index) => {
|
|
@@ -271,6 +443,13 @@ class DyFM_Array {
|
|
|
271
443
|
* @param dataList - The data list to gather multiplications from.
|
|
272
444
|
* @param byKey - The key to gather multiplications from.
|
|
273
445
|
* @returns The gathered multiplications.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* const list: { _id: number, name: string }[] = [ { _id: 1, name: 'John' }, { _id: 2, name: 'Jane' }, { _id: 1, name: 'Bob' } ];
|
|
450
|
+
* const result = DyFM_Array.gatherMultiplications(list, '_id');
|
|
451
|
+
* console.log(result); // [ [ { _id: 1, name: 'John' }, { _id: 1, name: 'Bob' } ] ]
|
|
452
|
+
* ```
|
|
274
453
|
*/
|
|
275
454
|
static gatherMultiplications(dataList, byKey = '_id') {
|
|
276
455
|
const multiplications = [];
|
|
@@ -290,6 +469,15 @@ class DyFM_Array {
|
|
|
290
469
|
* @param array - The array to find the element in.
|
|
291
470
|
* @param func - The function to apply to each element.
|
|
292
471
|
* @returns The element found, or null if no element is found.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* const list: number[] = [ 1, 2, 3 ];
|
|
476
|
+
* const result = DyFM_Array.findFromEnd(list, (element: number, index?: number, array?: number[]): boolean => {
|
|
477
|
+
* return element === 2;
|
|
478
|
+
* });
|
|
479
|
+
* console.log(result); // 2
|
|
480
|
+
* ```
|
|
293
481
|
*/
|
|
294
482
|
static findFromEnd(array, func) {
|
|
295
483
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
@@ -304,6 +492,7 @@ class DyFM_Array {
|
|
|
304
492
|
* sorts so that the objects that have the value true for the checkFor function are at the beginning of the array
|
|
305
493
|
* @param checkFor
|
|
306
494
|
* @returns
|
|
495
|
+
*
|
|
307
496
|
*/
|
|
308
497
|
static getSortForTrueFn(checkFor) {
|
|
309
498
|
return (a, b) => this.sortForTrue(a, b, checkFor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/array.util.ts"],"names":[],"mappings":";;;AAWA,MAAa,UAAU;IAErB
|
|
1
|
+
{"version":3,"file":"array.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/array.util.ts"],"names":[],"mappings":";;;AAWA,MAAa,UAAU;IAErB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,IAAS,EACT,IAAgE;QAEhE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAClC,SAAY,EACZ,IAAS,EACT,IAA6E;QAE7E,IAAI,MAAM,GAAM,SAAS,CAAC;QAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAClC,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ExB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAErB,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,CAAC;QACX,CAAC;aAAM,IAAI,GAAG,EAAE,CAAC;YACf,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF;AAjmBD,gCAimBC"}
|
|
@@ -4,6 +4,11 @@ export declare class DyFM_Async {
|
|
|
4
4
|
* delays the execution of a function
|
|
5
5
|
* @param ms
|
|
6
6
|
* @returns
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* await DyFM_Async.wait(1000);
|
|
11
|
+
* ```
|
|
7
12
|
*/
|
|
8
13
|
static wait(ms: number): Promise<void>;
|
|
9
14
|
static readonly sleep: typeof this.wait;
|
|
@@ -11,6 +16,11 @@ export declare class DyFM_Async {
|
|
|
11
16
|
/**
|
|
12
17
|
* WARNING: This function is recommended to use ONLY for limited instances,
|
|
13
18
|
* because it can cause performance issues.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* await DyFM_Async.waitUntil(() => check(), 100, 10000);
|
|
23
|
+
* ```
|
|
14
24
|
*/
|
|
15
25
|
static waitUntil(check: () => boolean, interval?: number, timeout?: number): Promise<void>;
|
|
16
26
|
/**
|
|
@@ -27,8 +37,27 @@ export declare class DyFM_Async {
|
|
|
27
37
|
static waitUntilAsync(check: () => Promise<boolean>, interval?: number, timeout?: number): Promise<void>;
|
|
28
38
|
/**
|
|
29
39
|
* Creates a promise that resolves when the observable emits a value that passes the check function
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const observable = new Observable<number>(observer => {
|
|
44
|
+
* setInterval(() => observer.next(Math.random()), 100);
|
|
45
|
+
* });
|
|
46
|
+
* const result = await DyFM_Async.takeUntil(observable, (value?: number) => value && value > 0.5);
|
|
47
|
+
* ```
|
|
30
48
|
*/
|
|
31
49
|
static takeUntil<T>(observable: Observable<T>, check: (value?: T) => boolean): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Waits for a given amount of time and logs the remaining time.
|
|
52
|
+
* @param totalWaitTimeMs - The total amount of time to wait.
|
|
53
|
+
* @param context - The context of the countdown.
|
|
54
|
+
* @returns A promise that resolves when the countdown is complete.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* await DyFM_Async.waitWithCountdownLogging(1000, 'Countdown');
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
32
61
|
static waitWithCountdownLogging(totalWaitTimeMs: number, context?: string): Promise<void>;
|
|
33
62
|
}
|
|
34
63
|
//# sourceMappingURL=async.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,qBAAa,UAAU;IAErB
|
|
1
|
+
{"version":3,"file":"async.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,qBAAa,UAAU;IAErB;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGtC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,IAAI,CAAa;IACpD,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,IAAI,CAAa;IAEpD;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,CACd,KAAK,EAAE,MAAM,OAAO,EACpB,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,MAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CACnB,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC7B,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,MAAc,GACtB,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,EAChB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,GAC5B,OAAO,CAAC,CAAC,CAAC;IAab;;;;;;;;;;OAUG;WACU,wBAAwB,CACnC,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE,MAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;CAkEjB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.DyFM_Async = void 0;
|
|
4
5
|
const times_const_1 = require("../constants/times.const");
|
|
@@ -9,15 +10,23 @@ class DyFM_Async {
|
|
|
9
10
|
* delays the execution of a function
|
|
10
11
|
* @param ms
|
|
11
12
|
* @returns
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* await DyFM_Async.wait(1000);
|
|
17
|
+
* ```
|
|
12
18
|
*/
|
|
13
19
|
static wait(ms) {
|
|
14
20
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
21
|
}
|
|
16
|
-
static sleep = this.wait;
|
|
17
|
-
static delay = this.wait;
|
|
18
22
|
/**
|
|
19
23
|
* WARNING: This function is recommended to use ONLY for limited instances,
|
|
20
24
|
* because it can cause performance issues.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* await DyFM_Async.waitUntil(() => check(), 100, 10000);
|
|
29
|
+
* ```
|
|
21
30
|
*/
|
|
22
31
|
static waitUntil(check, interval = 100, timeout = 10_000) {
|
|
23
32
|
const timeoutError = new Error('waitUntil timeout');
|
|
@@ -64,6 +73,14 @@ class DyFM_Async {
|
|
|
64
73
|
}
|
|
65
74
|
/**
|
|
66
75
|
* Creates a promise that resolves when the observable emits a value that passes the check function
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const observable = new Observable<number>(observer => {
|
|
80
|
+
* setInterval(() => observer.next(Math.random()), 100);
|
|
81
|
+
* });
|
|
82
|
+
* const result = await DyFM_Async.takeUntil(observable, (value?: number) => value && value > 0.5);
|
|
83
|
+
* ```
|
|
67
84
|
*/
|
|
68
85
|
static takeUntil(observable, check) {
|
|
69
86
|
return new Promise((resolve) => {
|
|
@@ -75,10 +92,32 @@ class DyFM_Async {
|
|
|
75
92
|
});
|
|
76
93
|
});
|
|
77
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Waits for a given amount of time and logs the remaining time.
|
|
97
|
+
* @param totalWaitTimeMs - The total amount of time to wait.
|
|
98
|
+
* @param context - The context of the countdown.
|
|
99
|
+
* @returns A promise that resolves when the countdown is complete.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* await DyFM_Async.waitWithCountdownLogging(1000, 'Countdown');
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
78
106
|
static async waitWithCountdownLogging(totalWaitTimeMs, context = 'Countdown') {
|
|
79
107
|
const startTime = Date.now();
|
|
80
108
|
const endTime = startTime + totalWaitTimeMs;
|
|
81
109
|
// Define logging intervals based on total duration
|
|
110
|
+
/**
|
|
111
|
+
* Gets the logging interval based on the total duration.
|
|
112
|
+
* @param totalMs - The total duration in milliseconds.
|
|
113
|
+
* @returns The logging interval in milliseconds.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const logInterval = getLogInterval(1000);
|
|
118
|
+
* console.log(logInterval); // 1000
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
82
121
|
const getLogInterval = (totalMs) => {
|
|
83
122
|
const totalSeconds = totalMs / times_const_1.second;
|
|
84
123
|
const totalMinutes = totalSeconds / 60;
|
|
@@ -129,11 +168,14 @@ class DyFM_Async {
|
|
|
129
168
|
lastLogTime = now;
|
|
130
169
|
}
|
|
131
170
|
// Wait for a short interval before checking again
|
|
132
|
-
await
|
|
171
|
+
await _a.wait(Math.min(time_util_1.DyFM_Time.second, remainingMs));
|
|
133
172
|
}
|
|
134
173
|
// Log completion
|
|
135
174
|
log_util_1.DyFM_Log.success(`✅ ${context} completed`);
|
|
136
175
|
}
|
|
137
176
|
}
|
|
138
177
|
exports.DyFM_Async = DyFM_Async;
|
|
178
|
+
_a = DyFM_Async;
|
|
179
|
+
DyFM_Async.sleep = _a.wait;
|
|
180
|
+
DyFM_Async.delay = _a.wait;
|
|
139
181
|
//# sourceMappingURL=async.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"async.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":";;;;AACA,0DAA2E;AAC3E,2CAAwC;AACxC,yCAAsC;AAGtC,MAAa,UAAU;IAErB;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,CAAC,EAAU;QACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAO,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAID;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,CACd,KAAoB,EACpB,WAAmB,GAAG,EACtB,UAAkB,MAAM;QAExB,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAEpD,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AG,CAAC;YAElC,4BAA4B;YAC5B,IAAI,GAAG,GAAG,WAAW,IAAI,WAAW,EAAE,CAAC;gBACrC,MAAM,aAAa,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;gBACvD,mBAAQ,CAAC,IAAI,CAAC,KAAK,OAAO,MAAM,aAAa,YAAY,CAAC,CAAC;gBAC3D,WAAW,GAAG,GAAG,CAAC;YACpB,CAAC;YAED,kDAAkD;YAClD,MAAM,EAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;QACjE,CAAC;QAED,iBAAiB;QACjB,mBAAQ,CAAC,OAAO,CAAC,KAAK,OAAO,YAAY,CAAC,CAAC;IAC7C,CAAC;;AA9LH,gCA+LC;;AAhLiB,gBAAK,GAAqB,EAAI,CAAC,IAAI,AAA9B,CAA+B;AACpC,gBAAK,GAAqB,EAAI,CAAC,IAAI,AAA9B,CAA+B"}
|
|
@@ -29,10 +29,26 @@ export declare class DyFM_JsonErrorHelper {
|
|
|
29
29
|
* @param jsonInput - The original JSON input string
|
|
30
30
|
* @param contextLines - Number of context lines to show before and after the error (default: 5)
|
|
31
31
|
* @returns Object containing line number, context lines, and character position, or null if parsing fails
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const lineInfo = DyFM_JsonErrorHelper.extractLineInfoFromJsonError('Expected property name or "}" in JSON at position 10', '{"name": "John", "age": 30}', 5);
|
|
36
|
+
* console.log(lineInfo); // { lineNumber: 1, contextLines: [ '{"name": "John", "age": 30}' ], characterPosition: 10 }
|
|
37
|
+
* ```
|
|
32
38
|
*/
|
|
33
39
|
static extractLineInfoFromJsonError(errorMessage: string, jsonInput: string, contextLines?: number): JsonErrorLineInfo | null;
|
|
34
40
|
/**
|
|
35
41
|
* Helper method to create line info from a character position
|
|
42
|
+
* @param jsonInput - The original JSON input string
|
|
43
|
+
* @param position - The character position where the error occurred
|
|
44
|
+
* @param contextLines - Number of context lines to show before and after the error (default: 5)
|
|
45
|
+
* @returns Object containing line number, context lines, and character position
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const lineInfo = DyFM_JsonErrorHelper.createLineInfoFromPosition('{"name": "John", "age": 30}', 10, 5);
|
|
50
|
+
* console.log(lineInfo); // { lineNumber: 1, contextLines: [ '{"name": "John", "age": 30}' ], characterPosition: 10 }
|
|
51
|
+
* ```
|
|
36
52
|
*/
|
|
37
53
|
private static createLineInfoFromPosition;
|
|
38
54
|
/**
|
|
@@ -42,6 +58,12 @@ export declare class DyFM_JsonErrorHelper {
|
|
|
42
58
|
* @param lineInfo - The line information extracted from the error
|
|
43
59
|
* @param errorMessage - The original error message
|
|
44
60
|
* @returns Formatted error string for logging
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const logLines = DyFM_JsonErrorHelper.formatJsonErrorForLogging({ lineNumber: 1, contextLines: [ '{"name": "John", "age": 30}' ], characterPosition: 10 }, 'Expected property name or "}" in JSON at position 10');
|
|
65
|
+
* console.log(logLines); // [ 'JSON parsing failed: Expected property name or "}" in JSON at position 10', 'Error at line 1, character 10:', 'Context (1 lines):', ' 1: {"name": "John", "age": 30}' ]
|
|
66
|
+
* ```
|
|
45
67
|
*/
|
|
46
68
|
static formatJsonErrorForLogging(lineInfo: JsonErrorLineInfo, errorMessage: string): string[];
|
|
47
69
|
/**
|
|
@@ -53,10 +75,26 @@ export declare class DyFM_JsonErrorHelper {
|
|
|
53
75
|
* @param contextLines - Number of context lines to show in error (default: 5)
|
|
54
76
|
* @returns Parsed JSON object
|
|
55
77
|
* @throws Error with detailed line information if parsing fails
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const json = '{"name": "John", "age": 30}';
|
|
82
|
+
* const result = DyFM_JsonErrorHelper.parseJsonWithEnhancedError(json);
|
|
83
|
+
* console.log(result); // { name: 'John', age: 30 }
|
|
84
|
+
* ```
|
|
56
85
|
*/
|
|
57
86
|
static parseJsonWithEnhancedError(jsonString: string, reviver?: (key: string, value: any) => any, contextLines?: number): any;
|
|
58
87
|
/**
|
|
59
88
|
* Formats single-line JSON with line breaks for better error reporting
|
|
89
|
+
* @param jsonString - The JSON string to format
|
|
90
|
+
* @returns The formatted JSON string
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const json = '{"name": "John", "age": 30, "city": "New York"}';
|
|
95
|
+
* const result = DyFM_JsonErrorHelper.formatJsonForBetterErrors(json);
|
|
96
|
+
* console.log(result); // '{\n "name": "John",\n "age": 30,\n "city": "New York"\n}'
|
|
97
|
+
* ```
|
|
60
98
|
*/
|
|
61
99
|
private static formatJsonForBetterErrors;
|
|
62
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-error-helper.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/json-error-helper.util.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,sEAAsE;IACtE,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAE/B
|
|
1
|
+
{"version":3,"file":"json-error-helper.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/json-error-helper.util.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,sEAAsE;IACtE,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAE/B;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,4BAA4B,CACjC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,YAAY,GAAE,MAAU,GACvB,iBAAiB,GAAG,IAAI;IA+C3B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IA0DzC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,yBAAyB,CAC9B,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,MAAM,GACnB,MAAM,EAAE;IAoBX;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,0BAA0B,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,EAC1C,YAAY,GAAE,MAAU,GACvB,GAAG;IA4CN;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;CAwBzC"}
|