ctx-core 2.1.0 → 2.2.1
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/all/LessThan/index.d.ts +10 -0
- package/all/LessThan/index.js +1 -0
- package/all/MAX_INT/index.d.ts +1 -0
- package/all/MAX_INT/index.js +1 -0
- package/all/MIN_INT/index.d.ts +1 -0
- package/all/MIN_INT/index.js +1 -0
- package/all/Map__object/index.d.ts +5 -0
- package/all/Map__object/index.js +9 -0
- package/all/Map__object/index.test.ts +7 -0
- package/all/NoRepetition/index.d.ts +6 -0
- package/all/NoRepetition/index.js +1 -0
- package/all/NumericRange/index.d.ts +8 -0
- package/all/NumericRange/index.js +1 -0
- package/all/NumericUnit/index.d.ts +4 -0
- package/all/NumericUnit/index.js +1 -0
- package/all/PHI/index.d.ts +1 -0
- package/all/PHI/index.js +2 -0
- package/all/Request/index.d.ts +2 -0
- package/all/Request/index.js +2 -0
- package/all/Response/index.d.ts +1 -0
- package/all/Response/index.js +2 -0
- package/all/TagType/index.d.ts +2 -0
- package/all/TagType/index.js +1 -0
- package/all/Timeout/index.d.ts +1 -0
- package/all/Timeout/index.js +1 -0
- package/all/UnorderedTuple/index.d.ts +4 -0
- package/all/UnorderedTuple/index.js +1 -0
- package/all/a/index.d.ts +1 -0
- package/all/a/index.js +3 -0
- package/all/a_assign/index.d.ts +7 -0
- package/all/a_assign/index.js +12 -0
- package/all/a_in_idx_a_map/index.d.ts +12 -0
- package/all/a_in_idx_a_map/index.js +13 -0
- package/all/a_item/index.d.ts +12 -0
- package/all/a_item/index.js +1 -0
- package/all/a_length/index.d.ts +18 -0
- package/all/a_length/index.js +21 -0
- package/all/a_nowrap/index.d.ts +7 -0
- package/all/a_nowrap/index.js +1 -0
- package/all/a_present/index.d.ts +19 -0
- package/all/a_present/index.js +24 -0
- package/all/a_some/index.d.ts +13 -0
- package/all/a_some/index.js +20 -0
- package/all/abbrev_month_a/index.d.ts +2 -0
- package/all/abbrev_month_a/index.js +15 -0
- package/all/abbreviate_number_str/index.d.ts +10 -0
- package/all/abbreviate_number_str/index.js +28 -0
- package/all/acronym/index.d.ts +2 -0
- package/all/acronym/index.js +8 -0
- package/all/add/index.d.ts +11 -0
- package/all/add/index.js +24 -0
- package/all/add/index.test.ts +14 -0
- package/all/all_union_a/index.d.ts +10 -0
- package/all/all_union_a/index.js +8 -0
- package/all/and/index.d.ts +29 -0
- package/all/and/index.js +45 -0
- package/all/and/index.test.ts +10 -0
- package/all/and_call/index.d.ts +16 -0
- package/all/and_call/index.js +20 -0
- package/all/andand/index.d.ts +14 -0
- package/all/andand/index.js +19 -0
- package/all/andand_or/index.d.ts +13 -0
- package/all/andand_or/index.js +14 -0
- package/all/andandfn/index.d.ts +26 -0
- package/all/andandfn/index.js +39 -0
- package/all/apply/index.d.ts +14 -0
- package/all/apply/index.js +14 -0
- package/all/arg_i0_a/index.d.ts +11 -0
- package/all/arg_i0_a/index.js +11 -0
- package/all/array_types/index.d.ts +134 -0
- package/all/array_types/index.js +1 -0
- package/all/assign/index.d.ts +4 -0
- package/all/assign/index.js +5 -0
- package/all/assign_fn_key_a/index.d.ts +15 -0
- package/all/assign_fn_key_a/index.js +24 -0
- package/all/assign_unless_null/index.d.ts +7 -0
- package/all/assign_unless_null/index.js +11 -0
- package/all/async_gen_a/index.d.ts +3 -0
- package/all/async_gen_a/index.js +9 -0
- package/all/async_gen_a/index.test.ts +12 -0
- package/all/at_date/index.d.ts +1 -0
- package/all/at_date/index.js +9 -0
- package/all/atob/index.d.ts +3 -0
- package/all/atob/index.js +16 -0
- package/all/atob_Uint32Array/index.d.ts +5 -0
- package/all/atob_Uint32Array/index.js +16 -0
- package/all/bad_credentials/index.d.ts +30 -0
- package/all/bad_credentials/index.js +44 -0
- package/all/bad_gateway/index.d.ts +20 -0
- package/all/bad_gateway/index.js +45 -0
- package/all/bad_request/index.d.ts +20 -0
- package/all/bad_request/index.js +45 -0
- package/all/base16_random/index.d.ts +2 -0
- package/all/base16_random/index.js +14 -0
- package/all/base64__buffer/index.d.ts +6 -0
- package/all/base64__buffer/index.js +15 -0
- package/all/batch_queue/index.d.ts +5 -0
- package/all/batch_queue/index.js +44 -0
- package/all/batch_queue/index.test.ts +149 -0
- package/all/be/index.d.ts +5 -0
- package/all/be/index.js +11 -0
- package/all/be_/index.d.ts +124 -0
- package/all/be_/index.js +272 -0
- package/all/be_/index.test.ts +251 -0
- package/all/be_arg_triple/index.d.ts +21 -0
- package/all/be_arg_triple/index.js +41 -0
- package/all/be_prop_pair/index.d.ts +36 -0
- package/all/be_prop_pair/index.js +54 -0
- package/all/be_prop_pair/index.test.ts +137 -0
- package/all/binary_sort_rank/index.d.ts +12 -0
- package/all/binary_sort_rank/index.js +30 -0
- package/all/bind_apply/index.d.ts +17 -0
- package/all/bind_apply/index.js +18 -0
- package/all/bind_call/index.d.ts +21 -0
- package/all/bind_call/index.js +18 -0
- package/all/bind_map_apply/index.d.ts +17 -0
- package/all/bind_map_apply/index.js +19 -0
- package/all/bind_map_call/index.d.ts +18 -0
- package/all/bind_map_call/index.js +21 -0
- package/all/btoa/index.d.ts +3 -0
- package/all/btoa/index.js +18 -0
- package/all/btoa/index.test.ts +7 -0
- package/all/btoa_Uint32Array/index.d.ts +8 -0
- package/all/btoa_Uint32Array/index.js +20 -0
- package/all/buffer__base64/index.d.ts +6 -0
- package/all/buffer__base64/index.js +22 -0
- package/all/buffer__hex/index.d.ts +1 -0
- package/all/buffer__hex/index.js +14 -0
- package/all/call/index.d.ts +22 -0
- package/all/call/index.js +23 -0
- package/all/call_assign/index.d.ts +13 -0
- package/all/call_assign/index.js +18 -0
- package/all/call_fn_a/index.d.ts +7 -0
- package/all/call_fn_a/index.js +14 -0
- package/all/call_or_fn/index.d.ts +13 -0
- package/all/call_or_fn/index.js +20 -0
- package/all/case_insensitive_eql/index.d.ts +1 -0
- package/all/case_insensitive_eql/index.js +14 -0
- package/all/chain/index.d.ts +22 -0
- package/all/chain/index.js +48 -0
- package/all/chunk_aa/index.d.ts +35 -0
- package/all/chunk_aa/index.js +20 -0
- package/all/chunk_aa/index.test.ts +11 -0
- package/all/circular_idx/index.d.ts +10 -0
- package/all/circular_idx/index.js +13 -0
- package/all/clear_ctx/index.d.ts +10 -0
- package/all/clear_ctx/index.js +19 -0
- package/all/clone/index.d.ts +6 -0
- package/all/clone/index.js +9 -0
- package/all/clone_assign_fn_key_a/index.d.ts +14 -0
- package/all/clone_assign_fn_key_a/index.js +18 -0
- package/all/color_hex_rgb__comma_delim_str/index.d.ts +11 -0
- package/all/color_hex_rgb__comma_delim_str/index.js +16 -0
- package/all/color_hsv/index.d.ts +18 -0
- package/all/color_hsv/index.js +36 -0
- package/all/color_hsv_phi_rgb_a/index.d.ts +19 -0
- package/all/color_hsv_phi_rgb_a/index.js +32 -0
- package/all/color_invert_rgb_a/index.d.ts +12 -0
- package/all/color_invert_rgb_a/index.js +18 -0
- package/all/color_rgb/index.d.ts +7 -0
- package/all/color_rgb/index.js +22 -0
- package/all/color_rgb/index.test.ts +12 -0
- package/all/columns_nansum_matrix/index.d.ts +4 -0
- package/all/columns_nansum_matrix/index.js +17 -0
- package/all/combinators/index.d.ts +52 -0
- package/all/combinators/index.js +48 -0
- package/all/combinators/index.test.ts +8 -0
- package/all/comma_number_str/index.d.ts +2 -0
- package/all/comma_number_str/index.js +8 -0
- package/all/compact/index.d.ts +15 -0
- package/all/compact/index.js +27 -0
- package/all/compact_a_ctx/index.d.ts +11 -0
- package/all/compact_a_ctx/index.js +21 -0
- package/all/compare/index.d.ts +23 -0
- package/all/compare/index.js +32 -0
- package/all/compose/index.d.ts +9 -0
- package/all/compose/index.js +17 -0
- package/all/concat/index.d.ts +9 -0
- package/all/concat/index.js +17 -0
- package/all/concat_truthy_a/index.d.ts +15 -0
- package/all/concat_truthy_a/index.js +19 -0
- package/all/console__error/index.d.ts +7 -0
- package/all/console__error/index.js +18 -0
- package/all/crypto/index.d.ts +1 -0
- package/all/crypto/index.js +11 -0
- package/all/crypto__sign/index.d.ts +13 -0
- package/all/crypto__sign/index.js +18 -0
- package/all/ctx/index.d.ts +4 -0
- package/all/ctx/index.js +25 -0
- package/all/ctx/index.test.ts +16 -0
- package/all/currencies/index.d.ts +3 -0
- package/all/currencies/index.js +120 -0
- package/all/currency_code/index.d.ts +4 -0
- package/all/currency_code/index.js +1 -0
- package/all/currency_str/index.d.ts +23 -0
- package/all/currency_str/index.js +38 -0
- package/all/currency_symbol/index.d.ts +8 -0
- package/all/currency_symbol/index.js +19 -0
- package/all/curry/index.d.ts +14 -0
- package/all/curry/index.js +32 -0
- package/all/date/index.d.ts +15 -0
- package/all/date/index.js +5 -0
- package/all/date_append_local_tz/index.d.ts +2 -0
- package/all/date_append_local_tz/index.js +9 -0
- package/all/day/index.d.ts +7 -0
- package/all/day/index.js +8 -0
- package/all/day_seconds/index.d.ts +2 -0
- package/all/day_seconds/index.js +2 -0
- package/all/debounce/index.d.ts +22 -0
- package/all/debounce/index.js +44 -0
- package/all/debounce_mapreduce/index.d.ts +6 -0
- package/all/debounce_mapreduce/index.js +18 -0
- package/all/debounce_mapreduce/index.test.ts +26 -0
- package/all/deep_clone/index.d.ts +5 -0
- package/all/deep_clone/index.js +10 -0
- package/all/defaults/index.d.ts +6 -0
- package/all/defaults/index.js +14 -0
- package/all/deg_rad/index.d.ts +5 -0
- package/all/deg_rad/index.js +7 -0
- package/all/diff_date/index.d.ts +1 -0
- package/all/diff_date/index.js +9 -0
- package/all/difference_a/index.d.ts +12 -0
- package/all/difference_a/index.js +15 -0
- package/all/difference_by/index.d.ts +9 -0
- package/all/difference_by/index.js +30 -0
- package/all/difference_set/index.d.ts +13 -0
- package/all/difference_set/index.js +23 -0
- package/all/digest__algorithm/index.d.ts +1 -0
- package/all/digest__algorithm/index.js +1 -0
- package/all/distribution_random_float/index.d.ts +4 -0
- package/all/distribution_random_float/index.js +12 -0
- package/all/distribution_random_int/index.d.ts +4 -0
- package/all/distribution_random_int/index.js +12 -0
- package/all/div/index.d.ts +4 -0
- package/all/div/index.js +10 -0
- package/all/each/index.d.ts +14 -0
- package/all/each/index.js +23 -0
- package/all/ensure/index.d.ts +11 -0
- package/all/ensure/index.js +26 -0
- package/all/ensure__refresh/index.d.ts +20 -0
- package/all/ensure__refresh/index.js +23 -0
- package/all/entries_gen/index.d.ts +5 -0
- package/all/entries_gen/index.js +12 -0
- package/all/entries_gen/index.test.ts +20 -0
- package/all/eq/index.d.ts +21 -0
- package/all/eq/index.js +28 -0
- package/all/eql/index.d.ts +23 -0
- package/all/eql/index.js +37 -0
- package/all/eql_a/index.d.ts +11 -0
- package/all/eql_a/index.js +20 -0
- package/all/eql_fn_a/index.d.ts +16 -0
- package/all/eql_fn_a/index.js +22 -0
- package/all/equidistant_segment_point_a/index.d.ts +14 -0
- package/all/equidistant_segment_point_a/index.js +25 -0
- package/all/error__print/index.d.ts +5 -0
- package/all/error__print/index.js +18 -0
- package/all/error_o/index.d.ts +27 -0
- package/all/error_o/index.js +25 -0
- package/all/every/index.d.ts +33 -0
- package/all/every/index.js +43 -0
- package/all/every_arg/index.d.ts +15 -0
- package/all/every_arg/index.js +15 -0
- package/all/every_arg/index.test.ts +37 -0
- package/all/exclude/index.d.ts +7 -0
- package/all/exclude/index.js +17 -0
- package/all/extract/index.d.ts +14 -0
- package/all/extract/index.js +24 -0
- package/all/extract/index.test.ts +18 -0
- package/all/falsy/index.d.ts +7 -0
- package/all/falsy/index.js +1 -0
- package/all/falsy__none/index.d.ts +9 -0
- package/all/falsy__none/index.js +23 -0
- package/all/falsy__none/index.test.ts +58 -0
- package/all/falsy_async_guard/index.d.ts +7 -0
- package/all/falsy_async_guard/index.js +13 -0
- package/all/falsy_guard/index.d.ts +5 -0
- package/all/falsy_guard/index.js +13 -0
- package/all/fetch/index.d.ts +5 -0
- package/all/fetch/index.js +2 -0
- package/all/fetch__template_pair/index.d.ts +40 -0
- package/all/fetch__template_pair/index.js +20 -0
- package/all/fetch__template_pair/index.test.ts +46 -0
- package/all/fetch_method/index.d.ts +5 -0
- package/all/fetch_method/index.js +8 -0
- package/all/fetch_response__throw/index.d.ts +7 -0
- package/all/fetch_response__throw/index.js +15 -0
- package/all/fetch_response__throw/index.test.ts +19 -0
- package/all/fetch_response_pair/index.d.ts +5 -0
- package/all/fetch_response_pair/index.js +13 -0
- package/all/fibonacci_number/index.d.ts +5 -0
- package/all/fibonacci_number/index.js +11 -0
- package/all/filter/index.d.ts +35 -0
- package/all/filter/index.js +55 -0
- package/all/filter_o/index.d.ts +31 -0
- package/all/filter_o/index.js +39 -0
- package/all/find/index.d.ts +30 -0
- package/all/find/index.js +51 -0
- package/all/first/index.d.ts +17 -0
- package/all/first/index.js +23 -0
- package/all/flatten/index.d.ts +14 -0
- package/all/flatten/index.js +28 -0
- package/all/flip/index.d.ts +5 -0
- package/all/flip/index.js +10 -0
- package/all/float_isNaN/index.d.ts +2 -0
- package/all/float_isNaN/index.js +9 -0
- package/all/fn_mean/index.d.ts +13 -0
- package/all/fn_mean/index.js +21 -0
- package/all/fn_mean/index.test.ts +13 -0
- package/all/fn_pipe/index.d.ts +70 -0
- package/all/fn_pipe/index.js +11 -0
- package/all/fn_pipe/index.test.ts +18 -0
- package/all/fn_sum/index.d.ts +12 -0
- package/all/fn_sum/index.js +17 -0
- package/all/fn_sum/index.test.ts +13 -0
- package/all/format_date_prose/index.d.ts +1 -0
- package/all/format_date_prose/index.js +10 -0
- package/all/format_utc_date_prose/index.d.ts +1 -0
- package/all/format_utc_date_prose/index.js +10 -0
- package/all/globalThis__prop__ensure/index.d.ts +4 -0
- package/all/globalThis__prop__ensure/index.js +10 -0
- package/all/globalThis__prop__ensure/index.test.ts +22 -0
- package/all/gte_0_a/index.d.ts +11 -0
- package/all/gte_0_a/index.js +21 -0
- package/all/hasOwnProperty_pick/index.d.ts +9 -0
- package/all/hasOwnProperty_pick/index.js +17 -0
- package/all/has_key/index.d.ts +15 -0
- package/all/has_key/index.js +38 -0
- package/all/has_multiple/index.d.ts +9 -0
- package/all/has_multiple/index.js +14 -0
- package/all/has_some_key/index.d.ts +5 -0
- package/all/has_some_key/index.js +12 -0
- package/all/head_arg_a/index.d.ts +12 -0
- package/all/head_arg_a/index.js +15 -0
- package/all/headers/index.d.ts +2 -0
- package/all/headers/index.js +10 -0
- package/all/hex__digest/index.d.ts +5 -0
- package/all/hex__digest/index.js +24 -0
- package/all/hex_int/index.d.ts +5 -0
- package/all/hex_int/index.js +7 -0
- package/all/hmac/index.d.ts +6 -0
- package/all/hmac/index.js +32 -0
- package/all/hmac_key/index.d.ts +5 -0
- package/all/hmac_key/index.js +30 -0
- package/all/hostname/index.d.ts +2 -0
- package/all/hostname/index.js +9 -0
- package/all/hour/index.d.ts +7 -0
- package/all/hour/index.js +8 -0
- package/all/hour_seconds/index.d.ts +2 -0
- package/all/hour_seconds/index.js +2 -0
- package/all/http_error/index.d.ts +20 -0
- package/all/http_error/index.js +35 -0
- package/all/idx/index.d.ts +11 -0
- package/all/idx/index.js +17 -0
- package/all/idx_a/index.d.ts +9 -0
- package/all/idx_a/index.js +20 -0
- package/all/idx_a/index.test.ts +9 -0
- package/all/idx_filter/index.d.ts +32 -0
- package/all/idx_filter/index.js +57 -0
- package/all/idx_key_r/index.d.ts +49 -0
- package/all/idx_key_r/index.js +78 -0
- package/all/idx_reject/index.d.ts +30 -0
- package/all/idx_reject/index.js +45 -0
- package/all/idx_sort_a/index.d.ts +23 -0
- package/all/idx_sort_a/index.js +39 -0
- package/all/idx_sort_a__sort_idx_o/index.d.ts +16 -0
- package/all/idx_sort_a__sort_idx_o/index.js +21 -0
- package/all/idx_sort_r_a/index.d.ts +7 -0
- package/all/idx_sort_r_a/index.js +14 -0
- package/all/if_null_set_false/index.d.ts +7 -0
- package/all/if_null_set_false/index.js +14 -0
- package/all/ifelse/index.d.ts +6 -0
- package/all/ifelse/index.js +10 -0
- package/all/iife/index.d.ts +6 -0
- package/all/iife/index.js +9 -0
- package/all/indendation/index.d.ts +9 -0
- package/all/indendation/index.js +23 -0
- package/all/index.d.ts +408 -0
- package/all/index.js +408 -0
- package/all/indexOf/index.d.ts +6 -0
- package/all/indexOf/index.js +9 -0
- package/all/insert/index.d.ts +6 -0
- package/all/insert/index.js +10 -0
- package/all/int_hex/index.d.ts +5 -0
- package/all/int_hex/index.js +7 -0
- package/all/intersection_a/index.d.ts +15 -0
- package/all/intersection_a/index.js +15 -0
- package/all/intersection_by/index.d.ts +10 -0
- package/all/intersection_by/index.js +44 -0
- package/all/intersection_set/index.d.ts +14 -0
- package/all/intersection_set/index.js +25 -0
- package/all/invalid_argument/index.d.ts +30 -0
- package/all/invalid_argument/index.js +43 -0
- package/all/invalid_state/index.d.ts +32 -0
- package/all/invalid_state/index.js +44 -0
- package/all/invert/index.d.ts +4 -0
- package/all/invert/index.js +8 -0
- package/all/invert_idx_a/index.d.ts +12 -0
- package/all/invert_idx_a/index.js +20 -0
- package/all/invert_idx_a/index.test.ts +7 -0
- package/all/isArray/index.d.ts +5 -0
- package/all/isArray/index.js +9 -0
- package/all/isFloat/index.d.ts +1 -0
- package/all/isFloat/index.js +4 -0
- package/all/isFloat_andor/index.d.ts +3 -0
- package/all/isFloat_andor/index.js +9 -0
- package/all/isFloat_or/index.d.ts +1 -0
- package/all/isFloat_or/index.js +5 -0
- package/all/isLowerCase/index.d.ts +1 -0
- package/all/isLowerCase/index.js +7 -0
- package/all/isNumber/index.d.ts +5 -0
- package/all/isNumber/index.js +5 -0
- package/all/isNumber_andor/index.d.ts +3 -0
- package/all/isNumber_andor/index.js +8 -0
- package/all/isNumber_or/index.d.ts +1 -0
- package/all/isNumber_or/index.js +5 -0
- package/all/isObject/index.d.ts +8 -0
- package/all/isObject/index.js +12 -0
- package/all/isPromise/index.d.ts +1 -0
- package/all/isPromise/index.js +7 -0
- package/all/isString/index.d.ts +1 -0
- package/all/isString/index.js +7 -0
- package/all/isUpperCase/index.d.ts +1 -0
- package/all/isUpperCase/index.js +7 -0
- package/all/item_r_idx/index.d.ts +27 -0
- package/all/item_r_idx/index.js +38 -0
- package/all/json/index.d.ts +2 -0
- package/all/json/index.js +1 -0
- package/all/key_compare/index.d.ts +14 -0
- package/all/key_compare/index.js +19 -0
- package/all/key_r/index.d.ts +48 -0
- package/all/key_r/index.js +63 -0
- package/all/key_r_a/index.d.ts +15 -0
- package/all/key_r_a/index.js +26 -0
- package/all/keyof/index.d.ts +1 -0
- package/all/keyof/index.js +1 -0
- package/all/keys/index.d.ts +4 -0
- package/all/keys/index.js +5 -0
- package/all/lPad/index.d.ts +1 -0
- package/all/lPad/index.js +11 -0
- package/all/last/index.d.ts +18 -0
- package/all/last/index.js +22 -0
- package/all/left_and/index.d.ts +12 -0
- package/all/left_and/index.js +14 -0
- package/all/left_or/index.d.ts +11 -0
- package/all/left_or/index.js +14 -0
- package/all/line__parse/index.d.ts +18 -0
- package/all/line__parse/index.js +97 -0
- package/all/line__parse/index.test.ts +96 -0
- package/all/line__transform_stream/index.d.ts +8 -0
- package/all/line__transform_stream/index.js +53 -0
- package/all/line__transform_stream/index.test.ts +47 -0
- package/all/lte_0_a/index.d.ts +11 -0
- package/all/lte_0_a/index.js +20 -0
- package/all/m_m_yyyy/index.d.ts +8 -0
- package/all/m_m_yyyy/index.js +24 -0
- package/all/m_yy/index.d.ts +2 -0
- package/all/m_yy/index.js +9 -0
- package/all/m_yyyy/index.d.ts +2 -0
- package/all/m_yyyy/index.js +10 -0
- package/all/many_andand/index.d.ts +11 -0
- package/all/many_andand/index.js +12 -0
- package/all/many_andand_or/index.d.ts +17 -0
- package/all/many_andand_or/index.js +14 -0
- package/all/map/index.d.ts +42 -0
- package/all/map/index.js +45 -0
- package/all/map_andand/index.d.ts +30 -0
- package/all/map_andand/index.js +34 -0
- package/all/map_andand_or/index.d.ts +13 -0
- package/all/map_andand_or/index.js +13 -0
- package/all/map_andandfn/index.d.ts +28 -0
- package/all/map_andandfn/index.js +29 -0
- package/all/map_apply/index.d.ts +17 -0
- package/all/map_apply/index.js +15 -0
- package/all/map_call/index.d.ts +22 -0
- package/all/map_call/index.js +26 -0
- package/all/map_find/index.d.ts +32 -0
- package/all/map_find/index.js +38 -0
- package/all/map_fn/index.d.ts +4 -0
- package/all/map_fn/index.js +1 -0
- package/all/map_inverse/index.d.ts +5 -0
- package/all/map_inverse/index.js +9 -0
- package/all/map_obj/index.d.ts +30 -0
- package/all/map_obj/index.js +28 -0
- package/all/map_obj_andand/index.d.ts +28 -0
- package/all/map_obj_andand/index.js +28 -0
- package/all/matrix__dot/index.d.ts +6 -0
- package/all/matrix__dot/index.js +22 -0
- package/all/matrix__dot__scalar/index.d.ts +1 -0
- package/all/matrix__dot__scalar/index.js +9 -0
- package/all/matrix__normalize/index.d.ts +4 -0
- package/all/matrix__normalize/index.js +20 -0
- package/all/matrix__validate_length/index.d.ts +1 -0
- package/all/matrix__validate_length/index.js +13 -0
- package/all/maybe/index.d.ts +7 -0
- package/all/maybe/index.js +1 -0
- package/all/mean/index.d.ts +9 -0
- package/all/mean/index.js +17 -0
- package/all/mean/index.test.ts +10 -0
- package/all/median/index.d.ts +4 -0
- package/all/median/index.js +19 -0
- package/all/merge/index.d.ts +7 -0
- package/all/merge/index.js +25 -0
- package/all/minute/index.d.ts +7 -0
- package/all/minute/index.js +7 -0
- package/all/minute_seconds/index.d.ts +2 -0
- package/all/minute_seconds/index.js +2 -0
- package/all/missing_argument/index.d.ts +31 -0
- package/all/missing_argument/index.js +44 -0
- package/all/mixin/index.d.ts +13 -0
- package/all/mixin/index.js +34 -0
- package/all/money_str/index.d.ts +13 -0
- package/all/money_str/index.js +26 -0
- package/all/month_a/index.d.ts +5 -0
- package/all/month_a/index.js +18 -0
- package/all/month_ms/index.d.ts +5 -0
- package/all/month_ms/index.js +6 -0
- package/all/month_seconds/index.d.ts +2 -0
- package/all/month_seconds/index.js +2 -0
- package/all/ms/index.d.ts +5 -0
- package/all/ms/index.js +12 -0
- package/all/mul/index.d.ts +4 -0
- package/all/mul/index.js +12 -0
- package/all/name_sort/index.d.ts +14 -0
- package/all/name_sort/index.js +13 -0
- package/all/negative/index.d.ts +4 -0
- package/all/negative/index.js +8 -0
- package/all/neq/index.d.ts +14 -0
- package/all/neq/index.js +25 -0
- package/all/neql/index.d.ts +15 -0
- package/all/neql/index.js +24 -0
- package/all/next_idx/index.d.ts +8 -0
- package/all/next_idx/index.js +14 -0
- package/all/nf/index.d.ts +1 -0
- package/all/nf/index.js +1 -0
- package/all/no_comma_str/index.d.ts +2 -0
- package/all/no_comma_str/index.js +9 -0
- package/all/noinit/index.d.ts +9 -0
- package/all/noinit/index.js +16 -0
- package/all/noop/index.d.ts +4 -0
- package/all/noop/index.js +6 -0
- package/all/normal_random/index.d.ts +2 -0
- package/all/normal_random/index.js +19 -0
- package/all/normal_random_float/index.d.ts +2 -0
- package/all/normal_random_float/index.js +6 -0
- package/all/normal_random_int/index.d.ts +2 -0
- package/all/normal_random_int/index.js +6 -0
- package/all/not/index.d.ts +17 -0
- package/all/not/index.js +24 -0
- package/all/not_found/index.d.ts +20 -0
- package/all/not_found/index.js +44 -0
- package/all/not_nullish__query_str/index.d.ts +6 -0
- package/all/not_nullish__query_str/index.js +19 -0
- package/all/notnot/index.d.ts +12 -0
- package/all/notnot/index.js +23 -0
- package/all/null/index.d.ts +5 -0
- package/all/null/index.js +10 -0
- package/all/nullish/index.d.ts +2 -0
- package/all/nullish/index.js +1 -0
- package/all/nullish__guard/index.d.ts +10 -0
- package/all/nullish__guard/index.js +16 -0
- package/all/nullish__guard__async/index.d.ts +10 -0
- package/all/nullish__guard__async/index.js +18 -0
- package/all/nullish__none/index.d.ts +12 -0
- package/all/nullish__none/index.js +25 -0
- package/all/nullish__none/index.test.ts +58 -0
- package/all/nullish__not_all/index.d.ts +8 -0
- package/all/nullish__not_all/index.js +16 -0
- package/all/nullish__not_all/index.test.ts +70 -0
- package/all/nullish_or/index.d.ts +5 -0
- package/all/nullish_or/index.js +11 -0
- package/all/number__count/index.d.ts +4 -0
- package/all/number__count/index.js +13 -0
- package/all/number__count/index.test.ts +7 -0
- package/all/number_or_mdash_str/index.d.ts +2 -0
- package/all/number_or_mdash_str/index.js +5 -0
- package/all/numerator_or_0_avg/index.d.ts +5 -0
- package/all/numerator_or_0_avg/index.js +10 -0
- package/all/numerator_or_0_sum/index.d.ts +5 -0
- package/all/numerator_or_0_sum/index.js +10 -0
- package/all/numeric_range/index.d.ts +7 -0
- package/all/numeric_range/index.js +19 -0
- package/all/numeric_range/index.test.ts +9 -0
- package/all/o_a_present/index.d.ts +18 -0
- package/all/o_a_present/index.js +18 -0
- package/all/o_some/index.d.ts +13 -0
- package/all/o_some/index.js +16 -0
- package/all/obj_key_r/index.d.ts +10 -0
- package/all/obj_key_r/index.js +19 -0
- package/all/offset_destructure_aa/index.d.ts +13 -0
- package/all/offset_destructure_aa/index.js +22 -0
- package/all/offset_i/index.d.ts +8 -0
- package/all/offset_i/index.js +13 -0
- package/all/offset_i_slice/index.d.ts +19 -0
- package/all/offset_i_slice/index.js +26 -0
- package/all/omit/index.d.ts +15 -0
- package/all/omit/index.js +26 -0
- package/all/omit/index.test.ts +12 -0
- package/all/one_andand/index.d.ts +13 -0
- package/all/one_andand/index.js +15 -0
- package/all/one_andand_or/index.d.ts +19 -0
- package/all/one_andand_or/index.js +18 -0
- package/all/or/index.d.ts +41 -0
- package/all/or/index.js +47 -0
- package/all/or_in/index.d.ts +9 -0
- package/all/or_in/index.js +14 -0
- package/all/or_null/index.d.ts +11 -0
- package/all/or_null/index.js +10 -0
- package/all/or_property/index.d.ts +9 -0
- package/all/or_property/index.js +15 -0
- package/all/pad2/index.d.ts +1 -0
- package/all/pad2/index.js +7 -0
- package/all/parseFloat_andor/index.d.ts +3 -0
- package/all/parseFloat_andor/index.js +5 -0
- package/all/parseFloat_andor/index.test.ts +11 -0
- package/all/parseFloat_or/index.d.ts +1 -0
- package/all/parseFloat_or/index.js +5 -0
- package/all/parseFloat_or/index.test.ts +9 -0
- package/all/parseInt_andor/index.d.ts +5 -0
- package/all/parseInt_andor/index.js +5 -0
- package/all/parseInt_andor/index.test.ts +11 -0
- package/all/parseInt_or/index.d.ts +1 -0
- package/all/parseInt_or/index.js +5 -0
- package/all/parseInt_or/index.test.ts +10 -0
- package/all/pathname/index.d.ts +2 -0
- package/all/pathname/index.js +8 -0
- package/all/percentage_str/index.d.ts +2 -0
- package/all/percentage_str/index.js +9 -0
- package/all/percentage_str_float/index.d.ts +2 -0
- package/all/percentage_str_float/index.js +4 -0
- package/all/performance__now/index.d.ts +1 -0
- package/all/performance__now/index.js +32 -0
- package/all/pick/index.d.ts +18 -0
- package/all/pick/index.js +35 -0
- package/all/pick_keys/index.d.ts +8 -0
- package/all/pick_keys/index.js +12 -0
- package/all/pick_val_a/index.d.ts +14 -0
- package/all/pick_val_a/index.js +22 -0
- package/all/prev_idx/index.d.ts +8 -0
- package/all/prev_idx/index.js +14 -0
- package/all/promise/index.d.ts +2 -0
- package/all/promise/index.js +1 -0
- package/all/promise_o/index.d.ts +7 -0
- package/all/promise_o/index.js +11 -0
- package/all/promise_timeout/index.d.ts +5 -0
- package/all/promise_timeout/index.js +23 -0
- package/all/prototype_mixin/index.d.ts +8 -0
- package/all/prototype_mixin/index.js +20 -0
- package/all/push/index.d.ts +15 -0
- package/all/push/index.js +17 -0
- package/all/quantile/index.d.ts +5 -0
- package/all/quantile/index.js +16 -0
- package/all/query_str/index.d.ts +27 -0
- package/all/query_str/index.js +46 -0
- package/all/query_str/index.test.ts +43 -0
- package/all/query_str__searchParams/index.d.ts +1 -0
- package/all/query_str__searchParams/index.js +8 -0
- package/all/query_str__searchParams_o/index.d.ts +3 -0
- package/all/query_str__searchParams_o/index.js +11 -0
- package/all/queue/index.d.ts +23 -0
- package/all/queue/index.js +130 -0
- package/all/queue/index.test.ts +207 -0
- package/all/rPad/index.d.ts +1 -0
- package/all/rPad/index.js +11 -0
- package/all/r_val_a/index.d.ts +23 -0
- package/all/r_val_a/index.js +28 -0
- package/all/rad_deg/index.d.ts +5 -0
- package/all/rad_deg/index.js +7 -0
- package/all/random_idx/index.d.ts +8 -0
- package/all/random_idx/index.js +12 -0
- package/all/rank/index.d.ts +10 -0
- package/all/rank/index.js +16 -0
- package/all/rate_limit/index.d.ts +10 -0
- package/all/rate_limit/index.js +49 -0
- package/all/rc_be/index.d.ts +9 -0
- package/all/rc_be/index.js +17 -0
- package/all/rc_be_/index.d.ts +42 -0
- package/all/rc_be_/index.js +62 -0
- package/all/re_/index.d.ts +1 -0
- package/all/re_/index.js +8 -0
- package/all/readable_stream_OR_reader/index.d.ts +7 -0
- package/all/readable_stream_OR_reader/index.js +1 -0
- package/all/reduce/index.d.ts +51 -0
- package/all/reduce/index.js +51 -0
- package/all/regex_indexOf/index.d.ts +10 -0
- package/all/regex_indexOf/index.js +14 -0
- package/all/regex_lastIndexOf/index.d.ts +7 -0
- package/all/regex_lastIndexOf/index.js +25 -0
- package/all/reject/index.d.ts +39 -0
- package/all/reject/index.js +40 -0
- package/all/remove/index.d.ts +16 -0
- package/all/remove/index.js +27 -0
- package/all/remove_idx/index.d.ts +12 -0
- package/all/remove_idx/index.js +14 -0
- package/all/resolver_curry/index.d.ts +6 -0
- package/all/resolver_curry/index.js +1 -0
- package/all/response_o/index.d.ts +10 -0
- package/all/response_o/index.js +17 -0
- package/all/response_pair/index.d.ts +11 -0
- package/all/response_pair/index.js +23 -0
- package/all/response_pair/index.test.ts +30 -0
- package/all/reverse/index.d.ts +16 -0
- package/all/reverse/index.js +16 -0
- package/all/right_and/index.d.ts +14 -0
- package/all/right_and/index.js +15 -0
- package/all/right_or/index.d.ts +14 -0
- package/all/right_or/index.js +16 -0
- package/all/round/index.d.ts +4 -0
- package/all/round/index.js +14 -0
- package/all/run/index.d.ts +8 -0
- package/all/run/index.js +10 -0
- package/all/run_pipe/index.d.ts +61 -0
- package/all/run_pipe/index.js +11 -0
- package/all/run_pipe/index.test.ts +19 -0
- package/all/scalar__matrix__multiply/index.d.ts +7 -0
- package/all/scalar__matrix__multiply/index.js +16 -0
- package/all/searchParams_o/index.d.ts +3 -0
- package/all/searchParams_o/index.js +13 -0
- package/all/seconds/index.d.ts +2 -0
- package/all/seconds/index.js +10 -0
- package/all/segment_point_index/index.d.ts +5 -0
- package/all/segment_point_index/index.js +13 -0
- package/all/selector_splice/index.d.ts +13 -0
- package/all/selector_splice/index.js +17 -0
- package/all/sequence/index.d.ts +2 -0
- package/all/sequence/index.js +8 -0
- package/all/set_member/index.d.ts +6 -0
- package/all/set_member/index.js +1 -0
- package/all/since_time_text/index.d.ts +5 -0
- package/all/since_time_text/index.js +38 -0
- package/all/sleep/index.d.ts +1 -0
- package/all/sleep/index.js +7 -0
- package/all/slice/index.d.ts +38 -0
- package/all/slice/index.js +48 -0
- package/all/slice_arg_a/index.d.ts +28 -0
- package/all/slice_arg_a/index.js +17 -0
- package/all/slice_arg_spread_a/index.d.ts +29 -0
- package/all/slice_arg_spread_a/index.js +15 -0
- package/all/sort/index.d.ts +37 -0
- package/all/sort/index.js +41 -0
- package/all/sort_a/index.d.ts +24 -0
- package/all/sort_a/index.js +28 -0
- package/all/sort_idx_a/index.d.ts +21 -0
- package/all/sort_idx_a/index.js +25 -0
- package/all/sort_idx_o/index.d.ts +29 -0
- package/all/sort_idx_o/index.js +53 -0
- package/all/sort_idx_o/index.test.ts +12 -0
- package/all/sort_val_a/index.d.ts +21 -0
- package/all/sort_val_a/index.js +23 -0
- package/all/sort_val_a__transition_idx_a/index.d.ts +61 -0
- package/all/sort_val_a__transition_idx_a/index.js +108 -0
- package/all/sort_val_a__transition_idx_a/index.test.ts +99 -0
- package/all/sparse_a/index.d.ts +14 -0
- package/all/sparse_a/index.js +19 -0
- package/all/splice/index.d.ts +19 -0
- package/all/splice/index.js +23 -0
- package/all/splice_str/index.d.ts +8 -0
- package/all/splice_str/index.js +20 -0
- package/all/spread/index.d.ts +22 -0
- package/all/spread/index.js +24 -0
- package/all/spread_slice/index.d.ts +10 -0
- package/all/spread_slice/index.js +14 -0
- package/all/stacktrace/index.d.ts +5 -0
- package/all/stacktrace/index.js +42 -0
- package/all/std/index.d.ts +2 -0
- package/all/std/index.js +13 -0
- package/all/sub/index.d.ts +4 -0
- package/all/sub/index.js +10 -0
- package/all/table_txt/index.d.ts +2 -0
- package/all/table_txt/index.js +29 -0
- package/all/table_txt/index.test.ts +17 -0
- package/all/tap/index.d.ts +22 -0
- package/all/tap/index.js +26 -0
- package/all/tf/index.d.ts +2 -0
- package/all/tf/index.js +2 -0
- package/all/throttle/index.d.ts +9 -0
- package/all/throttle/index.js +26 -0
- package/all/tick/index.d.ts +8 -0
- package/all/tick/index.js +23 -0
- package/all/timedout/index.d.ts +2 -0
- package/all/timedout/index.js +9 -0
- package/all/timeout_promise/index.d.ts +10 -0
- package/all/timeout_promise/index.js +12 -0
- package/all/times/index.d.ts +8 -0
- package/all/times/index.js +13 -0
- package/all/timestamp_ms/index.d.ts +6 -0
- package/all/timestamp_ms/index.js +8 -0
- package/all/title_case_/index.d.ts +7 -0
- package/all/title_case_/index.js +24 -0
- package/all/toLocalDateString/index.d.ts +1 -0
- package/all/toLocalDateString/index.js +7 -0
- package/all/toString/index.d.ts +5 -0
- package/all/toString/index.js +5 -0
- package/all/tup/index.d.ts +13 -0
- package/all/tup/index.js +14 -0
- package/all/tuple__o/index.d.ts +7 -0
- package/all/tuple__o/index.js +1 -0
- package/all/tuple__union/index.d.ts +1 -0
- package/all/tuple__union/index.js +1 -0
- package/all/tuple_a_o/index.d.ts +10 -0
- package/all/tuple_a_o/index.js +1 -0
- package/all/unauthorized/index.d.ts +20 -0
- package/all/unauthorized/index.js +43 -0
- package/all/unformat_currency_str/index.d.ts +10 -0
- package/all/unformat_currency_str/index.js +27 -0
- package/all/uniform_random/index.d.ts +2 -0
- package/all/uniform_random/index.js +4 -0
- package/all/uniform_random_float/index.d.ts +2 -0
- package/all/uniform_random_float/index.js +6 -0
- package/all/uniform_random_int/index.d.ts +2 -0
- package/all/uniform_random_int/index.js +6 -0
- package/all/union_a/index.d.ts +14 -0
- package/all/union_a/index.js +18 -0
- package/all/union_by/index.d.ts +11 -0
- package/all/union_by/index.js +28 -0
- package/all/union_set/index.d.ts +14 -0
- package/all/union_set/index.js +18 -0
- package/all/unit_matrix/index.d.ts +1 -0
- package/all/unit_matrix/index.js +11 -0
- package/all/unpick/index.d.ts +11 -0
- package/all/unpick/index.js +28 -0
- package/all/unpick_keys/index.d.ts +8 -0
- package/all/unpick_keys/index.js +12 -0
- package/all/url__join/index.d.ts +5 -0
- package/all/url__join/index.js +24 -0
- package/all/url_basename/index.d.ts +2 -0
- package/all/url_basename/index.js +10 -0
- package/all/url_segment/index.d.ts +2 -0
- package/all/url_segment/index.js +1 -0
- package/all/urn_url/index.d.ts +11 -0
- package/all/urn_url/index.js +15 -0
- package/all/utc_MM_yyyy/index.d.ts +8 -0
- package/all/utc_MM_yyyy/index.js +24 -0
- package/all/utc_M_yyyy/index.d.ts +6 -0
- package/all/utc_M_yyyy/index.js +13 -0
- package/all/utc_m_yy/index.d.ts +5 -0
- package/all/utc_m_yy/index.js +12 -0
- package/all/utc_yyyymmdd/index.d.ts +5 -0
- package/all/utc_yyyymmdd/index.js +13 -0
- package/all/utc_yyyymmddhhmmss/index.d.ts +5 -0
- package/all/utc_yyyymmddhhmmss/index.js +18 -0
- package/all/uuid/index.d.ts +5 -0
- package/all/uuid/index.js +19 -0
- package/all/val/index.d.ts +4 -0
- package/all/val/index.js +8 -0
- package/all/value_key_aa/index.d.ts +10 -0
- package/all/value_key_aa/index.js +20 -0
- package/all/value_key_zip_r/index.d.ts +13 -0
- package/all/value_key_zip_r/index.js +20 -0
- package/all/value_r/index.d.ts +29 -0
- package/all/value_r/index.js +37 -0
- package/all/valueof/index.d.ts +1 -0
- package/all/valueof/index.js +1 -0
- package/all/values/index.d.ts +5 -0
- package/all/values/index.js +5 -0
- package/all/waitfor/index.d.ts +5 -0
- package/all/waitfor/index.js +16 -0
- package/all/waitfor_fibonacci_backoff/index.d.ts +8 -0
- package/all/waitfor_fibonacci_backoff/index.js +27 -0
- package/all/waitfor_val/index.d.ts +6 -0
- package/all/waitfor_val/index.js +20 -0
- package/all/weak_r/index.d.ts +28 -0
- package/all/weak_r/index.js +87 -0
- package/all/week/index.d.ts +1 -0
- package/all/week/index.js +2 -0
- package/all/wrap_a/index.d.ts +32 -0
- package/all/wrap_a/index.js +19 -0
- package/all/wrap_a_item/index.d.ts +5 -0
- package/all/wrap_a_item/index.js +1 -0
- package/all/wrap_aa/index.d.ts +23 -0
- package/all/wrap_aa/index.js +14 -0
- package/all/wrap_aa_item/index.d.ts +5 -0
- package/all/wrap_aa_item/index.js +1 -0
- package/all/wrap_concat/index.d.ts +11 -0
- package/all/wrap_concat/index.js +13 -0
- package/all/year_ms/index.d.ts +5 -0
- package/all/year_ms/index.js +6 -0
- package/all/year_seconds/index.d.ts +2 -0
- package/all/year_seconds/index.js +2 -0
- package/all/yyyymmdd/index.d.ts +2 -0
- package/all/yyyymmdd/index.js +10 -0
- package/all/yyyymmddhhmmss/index.d.ts +2 -0
- package/all/yyyymmddhhmmss/index.js +11 -0
- package/all/zip/index.d.ts +11 -0
- package/all/zip/index.js +17 -0
- package/all/zip__tuple_a/index.d.ts +13 -0
- package/all/zip__tuple_a/index.js +1 -0
- package/all/zip_o/index.d.ts +15 -0
- package/all/zip_o/index.js +22 -0
- package/all/zip_with/index.d.ts +43 -0
- package/all/zip_with/index.js +56 -0
- package/be/index.d.ts +5 -0
- package/be/index.js +5 -0
- package/be/index.test.ts +251 -0
- package/package.json +7 -2
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { assign } from '../assign/index.js'
|
|
2
|
+
import { HttpError } from '../http_error/index.js'
|
|
3
|
+
/** @typedef {import('../error_o/index.d.ts').argument__error_o_T} */
|
|
4
|
+
export const bad_request__default__message = 'Bad Request'
|
|
5
|
+
/**
|
|
6
|
+
* @param {string}[message]
|
|
7
|
+
* @param {argument__error_o_T}[error_o]
|
|
8
|
+
* @returns {BadRequestError}
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export function bad_request_error_(
|
|
12
|
+
message,
|
|
13
|
+
error_o
|
|
14
|
+
) {
|
|
15
|
+
return assign(
|
|
16
|
+
new BadRequestError(
|
|
17
|
+
message ?? bad_request__default__message),
|
|
18
|
+
error_o)
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Throws a bad_request error (HTTP 400)
|
|
22
|
+
* @param {string}[message]
|
|
23
|
+
* @param {argument__error_o_T}[error_o]
|
|
24
|
+
* @example
|
|
25
|
+
* bad_request__throw(ctx) // Bad Request
|
|
26
|
+
*/
|
|
27
|
+
export function bad_request__throw(
|
|
28
|
+
message,
|
|
29
|
+
error_o
|
|
30
|
+
) {
|
|
31
|
+
throw bad_request_error_(message, error_o)
|
|
32
|
+
}
|
|
33
|
+
/** @type {import('./index.d.ts').BadRequestError} */
|
|
34
|
+
export class BadRequestError extends HttpError {
|
|
35
|
+
/**
|
|
36
|
+
* @param {string}[message]
|
|
37
|
+
*/
|
|
38
|
+
constructor(message) {
|
|
39
|
+
super(message)
|
|
40
|
+
this.name = 'BadRequestError'
|
|
41
|
+
this.http__status = 400
|
|
42
|
+
this.http__message = bad_request__default__message
|
|
43
|
+
if (!this.message) this.message = this.http__message
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {number}[length]
|
|
3
|
+
* @returns {string}
|
|
4
|
+
*/
|
|
5
|
+
export function base16_random(length = 5) {
|
|
6
|
+
const value_a = []
|
|
7
|
+
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
8
|
+
const length__possible = possible.length
|
|
9
|
+
for (let i = 0; i < length; i++) {
|
|
10
|
+
value_a.push(possible.charAt(Math.floor(Math.random() * length__possible)))
|
|
11
|
+
}
|
|
12
|
+
return value_a.join('')
|
|
13
|
+
}
|
|
14
|
+
export { base16_random as random__base16 }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string}base64
|
|
3
|
+
* @return {Uint8Array}
|
|
4
|
+
*/
|
|
5
|
+
export function base64__buffer_(base64) {
|
|
6
|
+
if (globalThis['window']) {
|
|
7
|
+
return Uint8Array.from(window.atob(base64, (c)=>c.charCodeAt(0)))
|
|
8
|
+
} else {
|
|
9
|
+
return Buffer.from(base64, 'base64')
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
base64__buffer_ as base64_buffer_,
|
|
14
|
+
base64__buffer_ as _base64_buffer,
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { queue_ } from '../queue/index.js'
|
|
2
|
+
const default_queue_size = 4
|
|
3
|
+
export function batch_queue_(queue_size = default_queue_size, batch_queue_size = queue_size) {
|
|
4
|
+
if (!queue_size) queue_size = default_queue_size
|
|
5
|
+
if (!batch_queue_size) batch_queue_size = queue_size
|
|
6
|
+
const queue = queue_(queue_size)
|
|
7
|
+
const pending_set = new Set()
|
|
8
|
+
const waiting_fifo = []
|
|
9
|
+
return {
|
|
10
|
+
add(fn) {
|
|
11
|
+
if (pending_set.size < batch_queue_size) {
|
|
12
|
+
return Promise.resolve([fn, pending_promise_(fn)])
|
|
13
|
+
} else {
|
|
14
|
+
return new Promise(resolve=>{
|
|
15
|
+
waiting_fifo.push(()=>{
|
|
16
|
+
resolve([fn, pending_promise_(fn)])
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
close() {
|
|
22
|
+
return queue.close()
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function pending_promise_(fn) {
|
|
26
|
+
const pending_promise = queue.add(fn).then(v=>{
|
|
27
|
+
try {
|
|
28
|
+
return v
|
|
29
|
+
} finally {
|
|
30
|
+
next(pending_promise)
|
|
31
|
+
}
|
|
32
|
+
}).catch(()=>{
|
|
33
|
+
next(pending_promise)
|
|
34
|
+
})
|
|
35
|
+
pending_set.add(pending_promise)
|
|
36
|
+
return pending_promise
|
|
37
|
+
}
|
|
38
|
+
function next(pending_promise) {
|
|
39
|
+
pending_set.delete(pending_promise)
|
|
40
|
+
if (waiting_fifo.length) {
|
|
41
|
+
waiting_fifo.shift()()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { test } from 'uvu'
|
|
2
|
+
import { equal } from 'uvu/assert'
|
|
3
|
+
import { batch_queue_ } from '../batch_queue/index.js'
|
|
4
|
+
import { promise_o_ } from '../promise_o/index.js'
|
|
5
|
+
test('batch_queue_(1).add|enqueue 1 at a time & run 1 at a time', async ()=>{
|
|
6
|
+
const batch_queue = batch_queue_(1)
|
|
7
|
+
const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
|
|
8
|
+
const fn_a = [()=>promise_o_a[0].promise, ()=>promise_o_a[1].promise, ()=>promise_o_a[2].promise]
|
|
9
|
+
const ret0_a:any[] = [null, null, null]
|
|
10
|
+
const ret1_a:any[] = [null, null, null]
|
|
11
|
+
batch_queue.add(fn_a[0])
|
|
12
|
+
.then(([ret0, ret1_p])=>{
|
|
13
|
+
ret0_a[0] = ret0
|
|
14
|
+
ret1_p.then(ret0=>ret1_a[0] = ret0)
|
|
15
|
+
})
|
|
16
|
+
batch_queue.add(fn_a[1])
|
|
17
|
+
.then(([ret0, ret1_p])=>{
|
|
18
|
+
ret0_a[1] = ret0
|
|
19
|
+
ret1_p.then(ret1=>ret1_a[1] = ret1)
|
|
20
|
+
})
|
|
21
|
+
batch_queue.add(fn_a[2])
|
|
22
|
+
.then(([ret0, ret1_p])=>{
|
|
23
|
+
ret0_a[2] = ret0
|
|
24
|
+
ret1_p.then(ret1=>ret1_a[2] = ret1)
|
|
25
|
+
})
|
|
26
|
+
equal(ret0_a, [null, null, null])
|
|
27
|
+
equal(ret1_a, [null, null, null])
|
|
28
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
29
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
30
|
+
equal(ret0_a, [fn_a[0], null, null])
|
|
31
|
+
equal(ret1_a, [null, null, null])
|
|
32
|
+
promise_o_a[1].resolve('val1')
|
|
33
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
34
|
+
equal(ret0_a, [fn_a[0], null, null])
|
|
35
|
+
equal(ret1_a, [null, null, null])
|
|
36
|
+
promise_o_a[0].resolve('val0')
|
|
37
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
38
|
+
equal(ret0_a, [fn_a[0], null, null])
|
|
39
|
+
equal(ret1_a, [null, null, null])
|
|
40
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
41
|
+
equal(ret0_a, [fn_a[0], fn_a[1], null])
|
|
42
|
+
equal(ret1_a, ['val0', null, null])
|
|
43
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
44
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
45
|
+
equal(ret1_a, ['val0', 'val1', null])
|
|
46
|
+
promise_o_a[2].resolve('val2')
|
|
47
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
48
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
49
|
+
equal(ret1_a, ['val0', 'val1', null])
|
|
50
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
51
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
52
|
+
equal(ret1_a, ['val0', 'val1', 'val2'])
|
|
53
|
+
})
|
|
54
|
+
test('batch_queue_(1, 2).add|enqueue 2 at a time & run 1 at a time', async ()=>{
|
|
55
|
+
const batch_queue = batch_queue_(1, 2)
|
|
56
|
+
const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
|
|
57
|
+
const fn_a = [()=>promise_o_a[0].promise, ()=>promise_o_a[1].promise, ()=>promise_o_a[2].promise]
|
|
58
|
+
const ret0_a:any[] = [null, null, null]
|
|
59
|
+
const ret1_a:any[] = [null, null, null]
|
|
60
|
+
batch_queue.add(fn_a[0])
|
|
61
|
+
.then(([ret0, ret1_p])=>{
|
|
62
|
+
ret0_a[0] = ret0
|
|
63
|
+
ret1_p.then(ret0=>ret1_a[0] = ret0)
|
|
64
|
+
})
|
|
65
|
+
batch_queue.add(fn_a[1])
|
|
66
|
+
.then(([ret0, ret1_p])=>{
|
|
67
|
+
ret0_a[1] = ret0
|
|
68
|
+
ret1_p.then(ret1=>ret1_a[1] = ret1)
|
|
69
|
+
})
|
|
70
|
+
batch_queue.add(fn_a[2])
|
|
71
|
+
.then(([ret0, ret1_p])=>{
|
|
72
|
+
ret0_a[2] = ret0
|
|
73
|
+
ret1_p.then(ret1=>ret1_a[2] = ret1)
|
|
74
|
+
})
|
|
75
|
+
equal(ret0_a, [null, null, null])
|
|
76
|
+
equal(ret1_a, [null, null, null])
|
|
77
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
78
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
79
|
+
equal(ret0_a, [fn_a[0], fn_a[1], null])
|
|
80
|
+
equal(ret1_a, [null, null, null])
|
|
81
|
+
promise_o_a[1].resolve('val1')
|
|
82
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
83
|
+
equal(ret0_a, [fn_a[0], fn_a[1], null])
|
|
84
|
+
equal(ret1_a, [null, null, null])
|
|
85
|
+
promise_o_a[0].resolve('val0')
|
|
86
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
87
|
+
equal(ret0_a, [fn_a[0], fn_a[1], null])
|
|
88
|
+
equal(ret1_a, [null, null, null])
|
|
89
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
90
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
91
|
+
equal(ret1_a, ['val0', null, null])
|
|
92
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
93
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
94
|
+
equal(ret1_a, ['val0', 'val1', null])
|
|
95
|
+
promise_o_a[2].resolve('val2')
|
|
96
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
97
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
98
|
+
equal(ret1_a, ['val0', 'val1', null])
|
|
99
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
100
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
101
|
+
equal(ret1_a, ['val0', 'val1', 'val2'])
|
|
102
|
+
})
|
|
103
|
+
test('batch_queue_(2).add|enqueue 2 at a time & run 2 at a time', async ()=>{
|
|
104
|
+
const batch_queue = batch_queue_(2)
|
|
105
|
+
const promise_o_a = [promise_o_(), promise_o_(), promise_o_()]
|
|
106
|
+
const fn_a = [()=>promise_o_a[0].promise, ()=>promise_o_a[1].promise, ()=>promise_o_a[2].promise]
|
|
107
|
+
const ret0_a:any[] = [null, null, null]
|
|
108
|
+
const ret1_a:any[] = [null, null, null]
|
|
109
|
+
batch_queue.add(fn_a[0])
|
|
110
|
+
.then(([ret0, ret1_p])=>{
|
|
111
|
+
ret0_a[0] = ret0
|
|
112
|
+
ret1_p.then(ret0=>ret1_a[0] = ret0)
|
|
113
|
+
})
|
|
114
|
+
batch_queue.add(fn_a[1])
|
|
115
|
+
.then(([ret0, ret1_p])=>{
|
|
116
|
+
ret0_a[1] = ret0
|
|
117
|
+
ret1_p.then(ret1=>ret1_a[1] = ret1)
|
|
118
|
+
})
|
|
119
|
+
batch_queue.add(fn_a[2])
|
|
120
|
+
.then(([ret0, ret1_p])=>{
|
|
121
|
+
ret0_a[2] = ret0
|
|
122
|
+
ret1_p.then(ret1=>ret1_a[2] = ret1)
|
|
123
|
+
})
|
|
124
|
+
equal(ret0_a, [null, null, null])
|
|
125
|
+
equal(ret1_a, [null, null, null])
|
|
126
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
127
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
128
|
+
equal(ret0_a, [fn_a[0], fn_a[1], null])
|
|
129
|
+
equal(ret1_a, [null, null, null])
|
|
130
|
+
promise_o_a[1].resolve('val1')
|
|
131
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
132
|
+
equal(ret0_a, [fn_a[0], fn_a[1], null])
|
|
133
|
+
equal(ret1_a, [null, null, null])
|
|
134
|
+
promise_o_a[0].resolve('val0')
|
|
135
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
136
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
137
|
+
equal(ret1_a, [null, 'val1', null])
|
|
138
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
139
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
140
|
+
equal(ret1_a, ['val0', 'val1', null])
|
|
141
|
+
promise_o_a[2].resolve('val2')
|
|
142
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
143
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
144
|
+
equal(ret1_a, ['val0', 'val1', null])
|
|
145
|
+
await new Promise(res=>queueMicrotask(()=>res(null)))
|
|
146
|
+
equal(ret0_a, [fn_a[0], fn_a[1], fn_a[2]])
|
|
147
|
+
equal(ret1_a, ['val0', 'val1', 'val2'])
|
|
148
|
+
})
|
|
149
|
+
test.run()
|
package/all/be/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { be_ } from '../be_/index.js'
|
|
2
|
+
/**
|
|
3
|
+
* @param {import('../be_/index.js').Ctx}ctx
|
|
4
|
+
* @param {string}key
|
|
5
|
+
* @param {import('../be_/index.js').be__val__T}val_
|
|
6
|
+
* @returns {NonNullable<unknown>}
|
|
7
|
+
*/
|
|
8
|
+
export function be(ctx, key, val_) {
|
|
9
|
+
return be_(key, val_)(ctx)
|
|
10
|
+
}
|
|
11
|
+
export { be as b, }
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export declare const pending_symbol:unique symbol
|
|
2
|
+
export declare function globalThis__be_<
|
|
3
|
+
Val,
|
|
4
|
+
ctx_T extends Ctx = Ctx
|
|
5
|
+
>(
|
|
6
|
+
val_:be__val__T<Val, ctx_T>,
|
|
7
|
+
be__params?:be__params_T
|
|
8
|
+
):Be<Val, ctx_T>
|
|
9
|
+
export declare function globalThis__be_<
|
|
10
|
+
Val,
|
|
11
|
+
ctx_T extends Ctx = Ctx
|
|
12
|
+
>(
|
|
13
|
+
id:string,
|
|
14
|
+
val_:be__val__T<Val, ctx_T>,
|
|
15
|
+
be__params?:be__params_T
|
|
16
|
+
):Be<Val, ctx_T>
|
|
17
|
+
/**
|
|
18
|
+
* Auto-memoization function for the Ctx.
|
|
19
|
+
*
|
|
20
|
+
* Returns a function to ensure that a member id is defined on a ctx object,
|
|
21
|
+
* otherwise it creates the value using the val_ factory function.
|
|
22
|
+
*/
|
|
23
|
+
export declare function be_<
|
|
24
|
+
Val,
|
|
25
|
+
ctx_T extends Ctx = Ctx
|
|
26
|
+
>(
|
|
27
|
+
val_:be__val__T<Val, ctx_T>,
|
|
28
|
+
be__params?:be__params_T
|
|
29
|
+
):Be<Val, ctx_T>
|
|
30
|
+
export declare function be_<
|
|
31
|
+
Val,
|
|
32
|
+
ctx_T extends Ctx = Ctx
|
|
33
|
+
>(
|
|
34
|
+
id:string,
|
|
35
|
+
val_:be__val__T<Val, ctx_T>,
|
|
36
|
+
be__params?:be__params_T
|
|
37
|
+
):Be<Val, ctx_T>
|
|
38
|
+
export {
|
|
39
|
+
be_ as _be,
|
|
40
|
+
be_ as b_,
|
|
41
|
+
be_ as _b,
|
|
42
|
+
}
|
|
43
|
+
export declare function be__is_source_<
|
|
44
|
+
ctx_T extends Ctx = Ctx
|
|
45
|
+
>(be:Be<unknown>):(map_ctx:MapCtx, ctx:ctx_T)=>boolean
|
|
46
|
+
export declare function source__map_ctx_<
|
|
47
|
+
ctx_T extends Ctx = Ctx
|
|
48
|
+
>(ctx:Ctx, is_source_:is_source__T):MapCtx
|
|
49
|
+
export declare function be__set<
|
|
50
|
+
Val,
|
|
51
|
+
ctx_T extends Ctx = Ctx
|
|
52
|
+
>(
|
|
53
|
+
be:Be<Val>,
|
|
54
|
+
ctx:ctx_T,
|
|
55
|
+
val:Val
|
|
56
|
+
):void
|
|
57
|
+
export declare function ctx__set<
|
|
58
|
+
Val,
|
|
59
|
+
ctx_T extends Ctx = Ctx
|
|
60
|
+
>(
|
|
61
|
+
ctx:ctx_T,
|
|
62
|
+
be_OR_id:Be<Val>|string|symbol,
|
|
63
|
+
val:Val,
|
|
64
|
+
is_source_?:is_source__T
|
|
65
|
+
):void
|
|
66
|
+
export declare function be__delete<
|
|
67
|
+
Val,
|
|
68
|
+
ctx_T extends Ctx = Ctx
|
|
69
|
+
>(
|
|
70
|
+
be:Be<Val>,
|
|
71
|
+
ctx:ctx_T
|
|
72
|
+
):void
|
|
73
|
+
export declare function ctx__delete<
|
|
74
|
+
Val,
|
|
75
|
+
ctx_T extends Ctx = Ctx
|
|
76
|
+
>(
|
|
77
|
+
ctx:ctx_T,
|
|
78
|
+
be_OR_id:Be<Val>|string|symbol,
|
|
79
|
+
is_source_?:is_source__T
|
|
80
|
+
):void
|
|
81
|
+
export declare function be__has_<
|
|
82
|
+
ctx_T extends Ctx = Ctx
|
|
83
|
+
>(be_OR_id:Be<unknown>|string, ctx:ctx_T):boolean
|
|
84
|
+
export declare function be__has__ctx_<
|
|
85
|
+
ctx_T extends Ctx = Ctx
|
|
86
|
+
>(be_OR_id:Be<unknown>|string, ctx:ctx_T):MapCtx
|
|
87
|
+
export declare function be__val_<
|
|
88
|
+
Val,
|
|
89
|
+
ctx_T extends Ctx = Ctx
|
|
90
|
+
>(be_OR_id:Be<Val>|string, ctx:ctx_T):Val|unknown|null
|
|
91
|
+
export declare type MapCtx = Map<Be<unknown>|string|symbol, unknown>
|
|
92
|
+
export interface NestedMapCtx extends Array<NestedMapCtx|MapCtx> {
|
|
93
|
+
}
|
|
94
|
+
export type Ctx = MapCtx|NestedMapCtx
|
|
95
|
+
export declare type Be<
|
|
96
|
+
Val,
|
|
97
|
+
ctx_T extends Ctx = Ctx
|
|
98
|
+
> = ((ctx:ctx_T, params?:be_params_T)=>Val)&{
|
|
99
|
+
id?:string
|
|
100
|
+
}
|
|
101
|
+
export declare type be__return_T<
|
|
102
|
+
Val,
|
|
103
|
+
ctx_T extends Ctx = Ctx
|
|
104
|
+
> = Be<Val, ctx_T>
|
|
105
|
+
export declare type be_T<
|
|
106
|
+
Val,
|
|
107
|
+
ctx_T extends Ctx = Ctx
|
|
108
|
+
> = Be<Val, ctx_T>
|
|
109
|
+
export declare type be__val__T<
|
|
110
|
+
Val,
|
|
111
|
+
ctx_T extends Ctx = Ctx
|
|
112
|
+
> = (ctx:ctx_T, be:Be<Val, ctx_T>, params?:be_params_T)=>Val
|
|
113
|
+
export interface be__params_T {
|
|
114
|
+
is_source_?:is_source__T
|
|
115
|
+
expired_?:expired__T
|
|
116
|
+
be_?:typeof be_
|
|
117
|
+
}
|
|
118
|
+
export type be__opts_T = be__params_T
|
|
119
|
+
export interface be_params_T {
|
|
120
|
+
force?:boolean
|
|
121
|
+
}
|
|
122
|
+
export type be_opts_T = be_params_T
|
|
123
|
+
export type is_source__T = (map_ctx:MapCtx, ctx:Ctx)=>boolean
|
|
124
|
+
export type expired__T = (ctx:Ctx)=>boolean
|
package/all/be_/index.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { globalThis__prop__ensure } from '../globalThis__prop__ensure/index.js'
|
|
2
|
+
import { isArray } from '../isArray/index.js'
|
|
3
|
+
let proto_ = Object.getPrototypeOf
|
|
4
|
+
let string_proto = proto_('')
|
|
5
|
+
let _null = null
|
|
6
|
+
let pending_sym = Symbol.for('pending')
|
|
7
|
+
let be_M_is_source_ = globalThis__prop__ensure(
|
|
8
|
+
Symbol.for('be_M_is_source_'),
|
|
9
|
+
()=>new WeakMap())
|
|
10
|
+
/** @typedef {import('./index.d.ts').Be}Be */
|
|
11
|
+
/** @typedef {import('./index.d.ts').Ctx}Ctx */
|
|
12
|
+
/** @typedef {import('./index.d.ts').MapCtx}MapCtx */
|
|
13
|
+
/** @typedef {import('./index.d.ts').be__params_T}be__params_T */
|
|
14
|
+
/** @typedef {import('./index.d.ts').be__val__T}be__val__T */
|
|
15
|
+
/** @typedef {import('./index.d.ts').is_source__T}is_source__T */
|
|
16
|
+
/**
|
|
17
|
+
* Auto-memoization function for the Ctx.
|
|
18
|
+
* Memoized on globalThis to allow packages being loaded multiple times, which can happen during bundling.
|
|
19
|
+
*
|
|
20
|
+
* Returns a function to ensure that a member id_OR_val_ is defined on a ctx object,
|
|
21
|
+
* otherwise it creates the value using the val__OR_be__params factory function.
|
|
22
|
+
* @param {string|be__val__T}id_OR_val_
|
|
23
|
+
* @param {be__val__T|be__params_T}[val__OR_be__params]
|
|
24
|
+
* @param {be__params_T}[be__params]
|
|
25
|
+
* @returns {Be}
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
export function globalThis__be_(
|
|
29
|
+
id_OR_val_,
|
|
30
|
+
val__OR_be__params,
|
|
31
|
+
be__params
|
|
32
|
+
) {
|
|
33
|
+
return globalThis__prop__ensure(
|
|
34
|
+
Symbol.for(id_OR_val_),
|
|
35
|
+
()=>be_(
|
|
36
|
+
id_OR_val_,
|
|
37
|
+
val__OR_be__params,
|
|
38
|
+
be__params))
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Auto-memoization function for the Ctx.
|
|
42
|
+
*
|
|
43
|
+
* Returns a function to ensure that a member id is defined on a Ctx,
|
|
44
|
+
* otherwise it creates the value using the val_ factory function.
|
|
45
|
+
* @param {string|be__val__T}id_OR_val__new
|
|
46
|
+
* @param {be__val__T|be__params_T}[val__new_OR_be__params]
|
|
47
|
+
* @param {be__params_T}[be__params]
|
|
48
|
+
* @returns {Be}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
export function be_(
|
|
52
|
+
id_OR_val__new,
|
|
53
|
+
val__new_OR_be__params,
|
|
54
|
+
be__params = {}
|
|
55
|
+
) {
|
|
56
|
+
/** @type {string} */
|
|
57
|
+
let id =
|
|
58
|
+
proto_(id_OR_val__new) === string_proto
|
|
59
|
+
? id_OR_val__new
|
|
60
|
+
: _null
|
|
61
|
+
/** @type {be__val__T} */
|
|
62
|
+
let val__new =
|
|
63
|
+
proto_(id_OR_val__new) === string_proto
|
|
64
|
+
? val__new_OR_be__params || (()=>null)
|
|
65
|
+
: id_OR_val__new
|
|
66
|
+
be__params =
|
|
67
|
+
proto_(id_OR_val__new) === string_proto
|
|
68
|
+
? be__params
|
|
69
|
+
: val__new_OR_be__params
|
|
70
|
+
let is_source_ =
|
|
71
|
+
be__params
|
|
72
|
+
? be__params.is_source_
|
|
73
|
+
: _null
|
|
74
|
+
let expired_ =
|
|
75
|
+
be__params
|
|
76
|
+
? be__params.expired_
|
|
77
|
+
: ()=>0
|
|
78
|
+
let be = (argv__ctx, params = {})=>{
|
|
79
|
+
if (!argv__ctx) {
|
|
80
|
+
throw new Error(`be must have a Ctx passed as an argument`)
|
|
81
|
+
}
|
|
82
|
+
let saved__val = be__val_(be, argv__ctx)
|
|
83
|
+
if (
|
|
84
|
+
be__has_(be, argv__ctx)
|
|
85
|
+
&& !params.force
|
|
86
|
+
&& (!expired_ || !expired_(argv__ctx))
|
|
87
|
+
) {
|
|
88
|
+
return saved__val
|
|
89
|
+
}
|
|
90
|
+
let ctx = source__map_ctx_(argv__ctx, is_source_)
|
|
91
|
+
if (!ctx) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`be: ${
|
|
94
|
+
String(id)
|
|
95
|
+
}: is_source_ must be true for at least one Ctx`)
|
|
96
|
+
}
|
|
97
|
+
let pending = ctx.get(pending_sym)
|
|
98
|
+
if (!pending) {
|
|
99
|
+
pending = new Map()
|
|
100
|
+
ctx.set(pending_sym, pending)
|
|
101
|
+
}
|
|
102
|
+
if (pending.get(be)) {
|
|
103
|
+
let pending_value_a = []
|
|
104
|
+
for (let value of pending.values()) {
|
|
105
|
+
pending_value_a.push(value)
|
|
106
|
+
}
|
|
107
|
+
throw new Error(
|
|
108
|
+
`be_: ${
|
|
109
|
+
String(id)
|
|
110
|
+
}: circular dependency:\n${pending_value_a.map(pending_value=>
|
|
111
|
+
typeof pending_value === 'function'
|
|
112
|
+
? 'Function'
|
|
113
|
+
: pending_value).join('\n')}`)
|
|
114
|
+
}
|
|
115
|
+
pending.set(be, id || be)
|
|
116
|
+
let val = val__new(argv__ctx, be, params)
|
|
117
|
+
ctx.set(be, val)
|
|
118
|
+
if (id) {
|
|
119
|
+
ctx.set(id, val)
|
|
120
|
+
}
|
|
121
|
+
pending.delete(be)
|
|
122
|
+
return val
|
|
123
|
+
}
|
|
124
|
+
be_M_is_source_.set(be, is_source_)
|
|
125
|
+
be.id = id
|
|
126
|
+
return be
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
be_ as _be,
|
|
130
|
+
be_ as b_,
|
|
131
|
+
be_ as _b,
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @param {Be}be
|
|
135
|
+
* @returns {is_source__T}
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
export function be__is_source__(be) {
|
|
139
|
+
return be_M_is_source_.get(be)
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @param {Be}be
|
|
143
|
+
* @param {Ctx}ctx
|
|
144
|
+
* @param {unknown}val
|
|
145
|
+
* @returns {unknown}
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
export function be__set(be, ctx, val) {
|
|
149
|
+
ctx__set(ctx, be, val, be__is_source__(be))
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @param {Ctx}ctx
|
|
153
|
+
* @param {Be|string|symbol}be_OR_id
|
|
154
|
+
* @param {unknown}val
|
|
155
|
+
* @param {is_source__T}[is_source_]
|
|
156
|
+
* @returns {unknown}
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
export function ctx__set(
|
|
160
|
+
ctx,
|
|
161
|
+
be_OR_id,
|
|
162
|
+
val,
|
|
163
|
+
is_source_
|
|
164
|
+
) {
|
|
165
|
+
if (!is_source_) is_source_ = ()=>true
|
|
166
|
+
let source__map_ctx = source__map_ctx_(ctx, is_source_)
|
|
167
|
+
if (source__map_ctx) {
|
|
168
|
+
source__map_ctx.set(be_OR_id, val)
|
|
169
|
+
let { id } = be_OR_id
|
|
170
|
+
if (id) {
|
|
171
|
+
source__map_ctx.set(id, val)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @param {Be}be
|
|
177
|
+
* @param {Ctx}ctx
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
180
|
+
export function be__delete(be, ctx) {
|
|
181
|
+
ctx__delete(ctx, be)
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @param {Ctx}ctx
|
|
185
|
+
* @param {Be|string|symbol}be_OR_id
|
|
186
|
+
* @param {is_source__T}[is_source_]
|
|
187
|
+
*/
|
|
188
|
+
export function ctx__delete(
|
|
189
|
+
ctx,
|
|
190
|
+
be_OR_id,
|
|
191
|
+
) {
|
|
192
|
+
const is_source_ =
|
|
193
|
+
be__is_source__(be_OR_id)
|
|
194
|
+
|| (()=>true)
|
|
195
|
+
if (isArray(ctx)) {
|
|
196
|
+
for (let i = 0; i < ctx.length; i++) {
|
|
197
|
+
if (is_source_(ctx[i], ctx)) {
|
|
198
|
+
ctx__delete(ctx[i], be_OR_id)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
/** @type {MapCtx} */
|
|
203
|
+
let map_ctx = /** @type {any} */ctx
|
|
204
|
+
if (is_source_(map_ctx, ctx)) {
|
|
205
|
+
let { id } = be_OR_id
|
|
206
|
+
if (id) {
|
|
207
|
+
map_ctx.delete(id)
|
|
208
|
+
}
|
|
209
|
+
map_ctx.delete(be_OR_id)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* @param {Be|string}be_or_id
|
|
215
|
+
* @param {Ctx}argv__ctx
|
|
216
|
+
* @returns {boolean}
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
export function be__has_(be_or_id, argv__ctx) {
|
|
220
|
+
return !!be__has__ctx_(be_or_id, argv__ctx)
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* @param {Be|string}be_or_id
|
|
224
|
+
* @param {Ctx}argv__ctx
|
|
225
|
+
* @returns {MapCtx}
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
export function be__has__ctx_(be_or_id, argv__ctx) {
|
|
229
|
+
if (isArray(argv__ctx)) {
|
|
230
|
+
for (let i = 0; i < argv__ctx.length; i++) {
|
|
231
|
+
const be__has__ctx = be__has__ctx_(be_or_id, argv__ctx[i])
|
|
232
|
+
if (be__has__ctx) return be__has__ctx
|
|
233
|
+
}
|
|
234
|
+
return null
|
|
235
|
+
} else {
|
|
236
|
+
return argv__ctx.has(be_or_id) ? argv__ctx : null
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* @param {Be|string}be_or_id
|
|
241
|
+
* @param {Ctx}argv__ctx
|
|
242
|
+
* @returns {unknown}
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
export function be__val_(be_or_id, argv__ctx) {
|
|
246
|
+
if (isArray(argv__ctx)) {
|
|
247
|
+
for (let i = 0; i < argv__ctx.length; i++) {
|
|
248
|
+
let ctx = argv__ctx[i]
|
|
249
|
+
const be__has__ctx = be__has__ctx_(be_or_id, ctx)
|
|
250
|
+
if (be__has__ctx) return be__has__ctx.get(be_or_id)
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
return argv__ctx.get(be_or_id)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @param {Ctx}ctx
|
|
258
|
+
* @param {is_source__T}is_source_
|
|
259
|
+
* @returns {unknown}
|
|
260
|
+
* @private
|
|
261
|
+
*/
|
|
262
|
+
export function source__map_ctx_(ctx, is_source_) {
|
|
263
|
+
if (isArray(ctx)) {
|
|
264
|
+
for (let i = 0; i < ctx.length; i++) {
|
|
265
|
+
let i_ctx = ctx[i]
|
|
266
|
+
let source__map_ctx = source__map_ctx_(i_ctx, is_source_)
|
|
267
|
+
if (source__map_ctx) return source__map_ctx
|
|
268
|
+
}
|
|
269
|
+
} else if (!is_source_ || is_source_(/** @type {MapCtx} */ctx, ctx)) {
|
|
270
|
+
return ctx
|
|
271
|
+
}
|
|
272
|
+
}
|