functionalscript 0.1.609 → 0.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/com/cpp/module.f.mjs +20 -25
- package/com/cpp/testlib.f.mjs +3 -4
- package/com/cs/module.f.mjs +18 -23
- package/com/cs/testlib.f.mjs +3 -5
- package/com/rust/module.f.mjs +25 -30
- package/com/rust/testlib.f.mjs +3 -5
- package/com/test/build.f.mjs +2 -2
- package/com/test/build.mjs +4 -4
- package/com/types/module.f.mjs +5 -12
- package/commonjs/build/module.f.mjs +23 -28
- package/commonjs/build/test.f.mjs +4 -4
- package/commonjs/module/function/module.f.mjs +0 -2
- package/commonjs/module/module.f.mjs +2 -9
- package/commonjs/module.f.mjs +0 -2
- package/commonjs/module.mjs +2 -7
- package/commonjs/package/dependencies/module.f.mjs +5 -10
- package/commonjs/package/dependencies/test.f.mjs +1 -1
- package/commonjs/package/module.f.mjs +6 -13
- package/commonjs/package/test.f.mjs +1 -1
- package/commonjs/path/module.f.mjs +12 -23
- package/commonjs/path/test.f.mjs +11 -11
- package/commonjs/test.mjs +1 -1
- package/dev/module.f.mjs +1 -4
- package/dev/module.mjs +1 -1
- package/dev/test/module.f.mjs +4 -6
- package/djs/module.f.mjs +12 -19
- package/djs/parser/module.f.mjs +18 -24
- package/djs/parser/test.f.mjs +9 -9
- package/djs/test.f.mjs +4 -4
- package/djs/tokenizer/module.f.mjs +18 -23
- package/djs/tokenizer/test.f.mjs +6 -6
- package/fsc/module.f.mjs +17 -24
- package/fsc/test.f.mjs +3 -3
- package/fsm/module.f.mjs +27 -38
- package/fsm/test.f.mjs +8 -8
- package/html/module.f.mjs +14 -23
- package/html/test.f.mjs +4 -4
- package/js/tokenizer/module.f.mjs +55 -62
- package/js/tokenizer/test.f.mjs +6 -6
- package/json/module.f.mjs +18 -31
- package/json/parser/module.f.mjs +9 -14
- package/json/parser/test.f.mjs +7 -7
- package/json/serializer/module.f.mjs +14 -29
- package/json/serializer/test.f.mjs +2 -2
- package/json/test.f.mjs +3 -3
- package/json/tokenizer/module.f.mjs +14 -19
- package/json/tokenizer/test.f.mjs +6 -6
- package/jsr.json +59 -59
- package/nodejs/version/main.mjs +1 -1
- package/nodejs/version/module.f.mjs +2 -7
- package/nodejs/version/test.f.mjs +3 -3
- package/out/com/cpp/module.f.d.mts +4 -0
- package/out/com/cpp/module.f.mjs +123 -0
- package/out/com/cpp/test.f.mjs +40 -0
- package/out/com/cpp/testlib.f.mjs +7 -0
- package/out/com/cs/module.f.d.mts +4 -0
- package/out/com/cs/module.f.mjs +95 -0
- package/out/com/cs/test.f.mjs +43 -0
- package/out/com/cs/testlib.f.mjs +7 -0
- package/{com → out/com}/rust/module.f.d.mts +3 -7
- package/out/com/rust/module.f.mjs +213 -0
- package/out/com/rust/test.f.mjs +123 -0
- package/out/com/rust/testlib.f.mjs +7 -0
- package/{com → out/com}/test/build.f.d.mts +2 -2
- package/out/com/test/build.f.mjs +98 -0
- package/out/com/test/build.mjs +40 -0
- package/{com → out/com}/types/module.f.d.mts +5 -10
- package/out/com/types/module.f.mjs +51 -0
- package/out/com/types/testlib.f.mjs +30 -0
- package/out/commonjs/build/module.f.d.mts +20 -0
- package/out/commonjs/build/module.f.mjs +107 -0
- package/out/commonjs/build/test.f.mjs +102 -0
- package/{commonjs → out/commonjs}/module/function/module.f.d.mts +0 -2
- package/out/commonjs/module/function/module.f.mjs +15 -0
- package/{commonjs → out/commonjs}/module/module.f.d.mts +16 -21
- package/out/commonjs/module/module.f.mjs +48 -0
- package/out/commonjs/module.d.mts +3 -0
- package/{commonjs → out/commonjs}/module.f.d.mts +0 -2
- package/out/commonjs/module.f.mjs +10 -0
- package/out/commonjs/module.mjs +26 -0
- package/out/commonjs/package/dependencies/module.f.d.mts +6 -0
- package/out/commonjs/package/dependencies/module.f.mjs +21 -0
- package/out/commonjs/package/dependencies/test.f.mjs +15 -0
- package/out/commonjs/package/module.f.d.mts +21 -0
- package/out/commonjs/package/module.f.mjs +40 -0
- package/out/commonjs/package/test.f.mjs +27 -0
- package/{commonjs → out/commonjs}/path/module.f.d.mts +25 -32
- package/out/commonjs/path/module.f.mjs +171 -0
- package/out/commonjs/path/test.f.mjs +231 -0
- package/out/commonjs/test.mjs +87 -0
- package/out/dev/index.mjs +2 -0
- package/out/dev/module.f.d.mts +1 -0
- package/out/dev/module.f.mjs +2 -0
- package/out/dev/module.mjs +167 -0
- package/{dev → out/dev}/test/module.f.d.mts +2 -3
- package/out/dev/test/module.f.mjs +134 -0
- package/out/dev/test.f.mjs +58 -0
- package/out/dev/test.mjs +52 -0
- package/{djs → out/djs}/module.f.d.mts +13 -18
- package/out/djs/module.f.mjs +75 -0
- package/{djs → out/djs}/parser/module.f.d.mts +11 -15
- package/out/djs/parser/module.f.mjs +432 -0
- package/out/djs/parser/test.f.mjs +535 -0
- package/out/djs/test.f.mjs +84 -0
- package/out/djs/tokenizer/module.f.d.mts +13 -0
- package/out/djs/tokenizer/module.f.mjs +87 -0
- package/out/djs/tokenizer/test.f.mjs +480 -0
- package/out/fsc/module.f.d.mts +7 -0
- package/out/fsc/module.f.mjs +105 -0
- package/out/fsc/test.f.mjs +19 -0
- package/out/fsm/module.f.d.mts +14 -0
- package/out/fsm/module.f.mjs +80 -0
- package/out/fsm/test.f.mjs +138 -0
- package/out/html/module.f.d.mts +15 -0
- package/out/html/module.f.mjs +94 -0
- package/out/html/test.f.mjs +45 -0
- package/out/issues/test.f.mjs +66 -0
- package/{js → out/js}/tokenizer/module.f.d.mts +10 -15
- package/out/js/tokenizer/module.f.mjs +686 -0
- package/out/js/tokenizer/test.f.mjs +844 -0
- package/out/json/module.f.d.mts +33 -0
- package/out/json/module.f.mjs +89 -0
- package/{json → out/json}/parser/module.f.d.mts +9 -13
- package/out/json/parser/module.f.mjs +224 -0
- package/out/json/parser/test.f.mjs +321 -0
- package/out/json/serializer/module.f.d.mts +36 -0
- package/out/json/serializer/module.f.mjs +67 -0
- package/out/json/serializer/test.f.mjs +87 -0
- package/out/json/test.f.mjs +61 -0
- package/out/json/tokenizer/module.f.d.mts +13 -0
- package/out/json/tokenizer/module.f.mjs +78 -0
- package/out/json/tokenizer/test.f.mjs +420 -0
- package/out/nanvm-lib/tests/test.f.mjs +87 -0
- package/out/nodejs/version/main.mjs +3 -0
- package/{nodejs → out/nodejs}/version/module.f.d.mts +4 -9
- package/out/nodejs/version/module.f.mjs +34 -0
- package/out/nodejs/version/test.f.mjs +97 -0
- package/{prime_field → out/prime_field}/module.f.d.mts +20 -23
- package/out/prime_field/module.f.mjs +87 -0
- package/out/prime_field/test.f.mjs +145 -0
- package/{secp → out/secp}/module.f.d.mts +27 -28
- package/out/secp/module.f.mjs +113 -0
- package/out/secp/test.f.mjs +63 -0
- package/out/sha2/module.f.d.mts +15 -0
- package/out/sha2/module.f.mjs +172 -0
- package/out/sha2/test.f.mjs +86 -0
- package/out/text/ascii/module.f.d.mts +70 -0
- package/out/text/ascii/module.f.mjs +154 -0
- package/out/text/ascii/test.f.mjs +14 -0
- package/out/text/module.f.d.mts +13 -0
- package/out/text/module.f.mjs +19 -0
- package/out/text/sgr/module.f.d.mts +12 -0
- package/out/text/sgr/module.f.mjs +17 -0
- package/out/text/test.f.mjs +19 -0
- package/out/text/utf16/module.f.d.mts +12 -0
- package/out/text/utf16/module.f.mjs +86 -0
- package/out/text/utf16/test.f.mjs +145 -0
- package/out/text/utf8/module.f.d.mts +10 -0
- package/out/text/utf8/module.f.mjs +126 -0
- package/out/text/utf8/test.f.mjs +175 -0
- package/{types → out/types}/array/module.f.d.mts +14 -24
- package/out/types/array/module.f.mjs +95 -0
- package/out/types/array/test.f.mjs +116 -0
- package/out/types/bigfloat/module.f.d.mts +6 -0
- package/out/types/bigfloat/module.f.mjs +77 -0
- package/out/types/bigfloat/test.f.mjs +349 -0
- package/out/types/bigint/module.f.d.mts +29 -0
- package/{types/bigint/module.f.d.mts → out/types/bigint/module.f.mjs} +64 -27
- package/out/types/bigint/test.f.mjs +192 -0
- package/{types → out/types}/btree/find/module.f.d.mts +20 -26
- package/out/types/btree/find/module.f.mjs +137 -0
- package/out/types/btree/find/test.f.mjs +156 -0
- package/out/types/btree/module.f.d.mts +5 -0
- package/out/types/btree/module.f.mjs +34 -0
- package/{types → out/types}/btree/remove/module.f.d.mts +7 -12
- package/out/types/btree/remove/module.f.mjs +209 -0
- package/out/types/btree/remove/test.f.mjs +638 -0
- package/{types → out/types}/btree/set/module.f.d.mts +3 -7
- package/out/types/btree/set/module.f.mjs +114 -0
- package/out/types/btree/set/test.f.mjs +390 -0
- package/out/types/btree/test.f.mjs +83 -0
- package/{types → out/types}/btree/types/module.f.d.mts +0 -2
- package/out/types/btree/types/module.f.mjs +50 -0
- package/out/types/byte_set/module.f.d.mts +25 -0
- package/out/types/byte_set/module.f.mjs +42 -0
- package/out/types/byte_set/test.f.mjs +123 -0
- package/{types → out/types}/function/compare/module.f.d.mts +9 -15
- package/out/types/function/compare/module.f.mjs +22 -0
- package/out/types/function/compare/test.f.mjs +8 -0
- package/{types → out/types}/function/module.f.d.mts +20 -27
- package/out/types/function/module.f.mjs +44 -0
- package/{types → out/types}/function/operator/module.f.d.mts +28 -43
- package/out/types/function/operator/module.f.mjs +60 -0
- package/out/types/function/test.f.mjs +15 -0
- package/out/types/list/module.f.d.mts +82 -0
- package/out/types/list/module.f.mjs +269 -0
- package/out/types/list/test.f.mjs +401 -0
- package/out/types/map/module.f.d.mts +21 -0
- package/out/types/map/module.f.mjs +54 -0
- package/out/types/map/test.f.mjs +115 -0
- package/out/types/nibble_set/module.f.d.mts +16 -0
- package/out/types/nibble_set/module.f.mjs +19 -0
- package/out/types/nibble_set/test.f.mjs +90 -0
- package/out/types/nullable/module.f.d.mts +9 -0
- package/out/types/nullable/module.f.mjs +9 -0
- package/out/types/nullable/test.f.mjs +12 -0
- package/out/types/number/module.f.d.mts +7 -0
- package/out/types/number/module.f.mjs +12 -0
- package/out/types/number/test.f.mjs +126 -0
- package/out/types/object/module.f.d.mts +22 -0
- package/out/types/object/module.f.mjs +27 -0
- package/out/types/object/test.f.mjs +17 -0
- package/out/types/range/module.f.d.mts +6 -0
- package/out/types/range/module.f.mjs +6 -0
- package/out/types/range/test.f.mjs +18 -0
- package/{types → out/types}/range_map/module.f.d.mts +9 -15
- package/out/types/range_map/module.f.mjs +84 -0
- package/out/types/range_map/test.f.mjs +201 -0
- package/out/types/result/module.d.mts +7 -0
- package/{types → out/types}/result/module.f.d.mts +6 -12
- package/out/types/result/module.f.mjs +25 -0
- package/out/types/result/module.mjs +16 -0
- package/{types → out/types}/sorted_list/module.f.d.mts +22 -28
- package/out/types/sorted_list/module.f.mjs +102 -0
- package/out/types/sorted_list/test.f.mjs +66 -0
- package/{types → out/types}/sorted_set/module.f.d.mts +6 -12
- package/out/types/sorted_set/module.f.mjs +29 -0
- package/out/types/sorted_set/test.f.mjs +80 -0
- package/out/types/string/module.f.d.mts +9 -0
- package/out/types/string/module.f.mjs +17 -0
- package/out/types/string/test.f.mjs +58 -0
- package/out/types/string_set/module.f.d.mts +13 -0
- package/out/types/string_set/module.f.mjs +29 -0
- package/out/types/string_set/test.f.mjs +65 -0
- package/package.json +5 -4
- package/prime_field/module.f.mjs +9 -12
- package/prime_field/test.f.mjs +1 -1
- package/secp/module.f.mjs +38 -39
- package/secp/test.f.mjs +4 -4
- package/sha2/module.f.mjs +7 -20
- package/sha2/test.f.mjs +4 -4
- package/text/ascii/module.f.mjs +5 -10
- package/text/ascii/test.f.mjs +3 -3
- package/text/module.f.mjs +7 -14
- package/text/sgr/module.f.mjs +2 -4
- package/text/test.f.mjs +3 -3
- package/text/utf16/module.f.mjs +17 -28
- package/text/utf16/test.f.mjs +5 -5
- package/text/utf8/module.f.mjs +9 -16
- package/text/utf8/test.f.mjs +4 -4
- package/tsconfig.json +2 -2
- package/types/array/module.f.mjs +8 -25
- package/types/array/test.f.mjs +3 -3
- package/types/bigfloat/module.f.mjs +3 -10
- package/types/bigfloat/test.f.mjs +1 -1
- package/types/bigint/module.f.mjs +11 -30
- package/types/bigint/test.f.mjs +1 -1
- package/types/btree/find/module.f.mjs +8 -17
- package/types/btree/find/test.f.mjs +7 -7
- package/types/btree/module.f.mjs +6 -11
- package/types/btree/remove/module.f.mjs +10 -17
- package/types/btree/remove/test.f.mjs +5 -5
- package/types/btree/set/module.f.mjs +4 -9
- package/types/btree/set/test.f.mjs +4 -4
- package/types/btree/test.f.mjs +9 -9
- package/types/btree/types/module.f.mjs +0 -2
- package/types/byte_set/module.f.mjs +14 -39
- package/types/byte_set/test.f.mjs +5 -5
- package/types/function/compare/module.f.mjs +3 -12
- package/types/function/compare/test.f.mjs +1 -1
- package/types/function/module.f.mjs +4 -15
- package/types/function/operator/module.f.mjs +14 -41
- package/types/function/test.f.mjs +1 -1
- package/types/list/module.f.mjs +45 -114
- package/types/list/test.f.mjs +10 -10
- package/types/map/module.f.mjs +15 -30
- package/types/map/test.f.mjs +2 -2
- package/types/nibble_set/module.f.mjs +7 -24
- package/types/nibble_set/test.f.mjs +2 -2
- package/types/nullable/module.f.mjs +2 -9
- package/types/nullable/test.f.mjs +1 -1
- package/types/number/module.f.mjs +8 -19
- package/types/number/test.f.mjs +1 -1
- package/types/object/module.f.mjs +9 -20
- package/types/object/test.f.mjs +1 -1
- package/types/range/module.f.mjs +2 -9
- package/types/range/test.f.mjs +1 -1
- package/types/range_map/module.f.mjs +9 -18
- package/types/range_map/test.f.mjs +32 -32
- package/types/result/module.f.mjs +3 -12
- package/types/result/module.mjs +2 -2
- package/types/sorted_list/module.f.mjs +10 -19
- package/types/sorted_list/test.f.mjs +7 -7
- package/types/sorted_set/module.f.mjs +7 -16
- package/types/sorted_set/test.f.mjs +7 -7
- package/types/string/module.f.mjs +10 -21
- package/types/string/test.f.mjs +2 -2
- package/types/string_set/module.f.mjs +12 -27
- package/types/string_set/test.f.mjs +1 -1
- package/com/cpp/module.f.d.mts +0 -8
- package/com/cs/module.f.d.mts +0 -8
- package/commonjs/build/module.f.d.mts +0 -24
- package/commonjs/module.d.mts +0 -7
- package/commonjs/package/dependencies/module.f.d.mts +0 -10
- package/commonjs/package/module.f.d.mts +0 -27
- package/dev/module.f.d.mts +0 -4
- package/djs/tokenizer/module.f.d.mts +0 -17
- package/fsc/module.f.d.mts +0 -12
- package/fsm/module.f.d.mts +0 -21
- package/html/module.f.d.mts +0 -20
- package/json/module.f.d.mts +0 -41
- package/json/serializer/module.f.d.mts +0 -45
- package/json/tokenizer/module.f.d.mts +0 -17
- package/sha2/module.f.d.mts +0 -23
- package/text/ascii/module.f.d.mts +0 -73
- package/text/module.f.d.mts +0 -18
- package/text/sgr/module.f.d.mts +0 -14
- package/text/utf16/module.f.d.mts +0 -19
- package/text/utf8/module.f.d.mts +0 -15
- package/types/bigfloat/module.f.d.mts +0 -11
- package/types/btree/module.f.d.mts +0 -9
- package/types/byte_set/module.f.d.mts +0 -38
- package/types/list/module.f.d.mts +0 -117
- package/types/map/module.f.d.mts +0 -30
- package/types/nibble_set/module.f.d.mts +0 -26
- package/types/nullable/module.f.d.mts +0 -14
- package/types/number/module.f.d.mts +0 -13
- package/types/object/module.f.d.mts +0 -29
- package/types/range/module.f.d.mts +0 -11
- package/types/result/module.d.mts +0 -7
- package/types/string/module.f.d.mts +0 -15
- package/types/string_set/module.f.d.mts +0 -21
- /package/{com → out/com}/cpp/test.f.d.mts +0 -0
- /package/{com → out/com}/cpp/testlib.f.d.mts +0 -0
- /package/{com → out/com}/cs/test.f.d.mts +0 -0
- /package/{com → out/com}/cs/testlib.f.d.mts +0 -0
- /package/{com → out/com}/rust/test.f.d.mts +0 -0
- /package/{com → out/com}/rust/testlib.f.d.mts +0 -0
- /package/{com → out/com}/test/build.d.mts +0 -0
- /package/{com → out/com}/types/testlib.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/build/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/package/dependencies/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/package/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/path/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/test.d.mts +0 -0
- /package/{dev → out/dev}/index.d.mts +0 -0
- /package/{dev → out/dev}/module.d.mts +0 -0
- /package/{dev → out/dev}/test.d.mts +0 -0
- /package/{dev → out/dev}/test.f.d.mts +0 -0
- /package/{djs → out/djs}/parser/test.f.d.mts +0 -0
- /package/{djs → out/djs}/test.f.d.mts +0 -0
- /package/{djs → out/djs}/tokenizer/test.f.d.mts +0 -0
- /package/{fsc → out/fsc}/test.f.d.mts +0 -0
- /package/{fsm → out/fsm}/test.f.d.mts +0 -0
- /package/{html → out/html}/test.f.d.mts +0 -0
- /package/{issues → out/issues}/test.f.d.mts +0 -0
- /package/{js → out/js}/tokenizer/test.f.d.mts +0 -0
- /package/{json → out/json}/parser/test.f.d.mts +0 -0
- /package/{json → out/json}/serializer/test.f.d.mts +0 -0
- /package/{json → out/json}/test.f.d.mts +0 -0
- /package/{json → out/json}/tokenizer/test.f.d.mts +0 -0
- /package/{nanvm-lib → out/nanvm-lib}/tests/test.f.d.mts +0 -0
- /package/{nodejs → out/nodejs}/version/main.d.mts +0 -0
- /package/{nodejs → out/nodejs}/version/test.f.d.mts +0 -0
- /package/{prime_field → out/prime_field}/test.f.d.mts +0 -0
- /package/{secp → out/secp}/test.f.d.mts +0 -0
- /package/{sha2 → out/sha2}/test.f.d.mts +0 -0
- /package/{text → out/text}/ascii/test.f.d.mts +0 -0
- /package/{text → out/text}/test.f.d.mts +0 -0
- /package/{text → out/text}/utf16/test.f.d.mts +0 -0
- /package/{text → out/text}/utf8/test.f.d.mts +0 -0
- /package/{types → out/types}/array/test.f.d.mts +0 -0
- /package/{types → out/types}/bigfloat/test.f.d.mts +0 -0
- /package/{types → out/types}/bigint/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/find/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/remove/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/set/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/test.f.d.mts +0 -0
- /package/{types → out/types}/byte_set/test.f.d.mts +0 -0
- /package/{types → out/types}/function/compare/test.f.d.mts +0 -0
- /package/{types → out/types}/function/test.f.d.mts +0 -0
- /package/{types → out/types}/list/test.f.d.mts +0 -0
- /package/{types → out/types}/map/test.f.d.mts +0 -0
- /package/{types → out/types}/nibble_set/test.f.d.mts +0 -0
- /package/{types → out/types}/nullable/test.f.d.mts +0 -0
- /package/{types → out/types}/number/test.f.d.mts +0 -0
- /package/{types → out/types}/object/test.f.d.mts +0 -0
- /package/{types → out/types}/range/test.f.d.mts +0 -0
- /package/{types → out/types}/range_map/test.f.d.mts +0 -0
- /package/{types → out/types}/sorted_list/test.f.d.mts +0 -0
- /package/{types → out/types}/sorted_set/test.f.d.mts +0 -0
- /package/{types → out/types}/string/test.f.d.mts +0 -0
- /package/{types → out/types}/string_set/test.f.d.mts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
import * as BtreeTypes from '../btree/types/module.f.mjs';
|
|
3
|
+
import * as btf from '../btree/find/module.f.mjs';
|
|
4
|
+
const { value, find } = btf;
|
|
5
|
+
import * as bts from '../btree/set/module.f.mjs';
|
|
6
|
+
const { set } = bts;
|
|
7
|
+
import * as btr from '../btree/remove/module.f.mjs';
|
|
8
|
+
const { remove: btreeRemove } = btr;
|
|
9
|
+
import * as bt from '../btree/module.f.mjs';
|
|
10
|
+
const { values } = bt;
|
|
11
|
+
import * as Compare from '../function/compare/module.f.mjs';
|
|
12
|
+
import * as s from '../string/module.f.mjs';
|
|
13
|
+
const { cmp } = s;
|
|
14
|
+
import * as list from '../list/module.f.mjs';
|
|
15
|
+
const { fold } = list;
|
|
16
|
+
import * as Operator from '../function/operator/module.f.mjs';
|
|
17
|
+
/** @typedef {Compare.Sign} Sign */
|
|
18
|
+
/**
|
|
19
|
+
* @template T
|
|
20
|
+
* @typedef {Compare.Compare<T>} Cmp
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @template T
|
|
24
|
+
* @typedef {readonly[string, T]} Entry
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @template T
|
|
28
|
+
* @typedef {BtreeTypes.Tree<Entry<T>>} Map
|
|
29
|
+
*/
|
|
30
|
+
/** @type {(a: string) => <T>(b: Entry<T>) => Sign} */
|
|
31
|
+
const keyCmp = a => ([b]) => cmp(a)(b);
|
|
32
|
+
/** @type {(name: string) => <T>(map: Map<T>) => T|null} */
|
|
33
|
+
export const at = name => map => {
|
|
34
|
+
if (map === null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const result = value(find(keyCmp(name))(map).first);
|
|
38
|
+
return result === null ? null : result[1];
|
|
39
|
+
};
|
|
40
|
+
/** @type {<T>(reduce: Operator.Reduce<T>) => (entry: Entry<T>) => (map: Map<T>) => Map<T>} */
|
|
41
|
+
const setReduceEntry = reduce => entry => set(keyCmp(entry[0]))(old => old === null ? entry : [old[0], reduce(old[1])(entry[1])]);
|
|
42
|
+
/** @type {<T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>} */
|
|
43
|
+
export const setReduce = reduce => name => value => setReduceEntry(reduce)([name, value]);
|
|
44
|
+
/** @type {<T>(a: T) => (b: T) => T} */
|
|
45
|
+
const replace = () => b => b;
|
|
46
|
+
/** @type {(name: string) => <T>(value: T) => (map: Map<T>) => Map<T>} */
|
|
47
|
+
export const setReplace = name => value => setReduceEntry(replace)([name, value]);
|
|
48
|
+
/** @type {<T>(map: Map<T>) => list.List<Entry<T>>} */
|
|
49
|
+
export const entries = values;
|
|
50
|
+
/** @type {<T>(entries: list.List<Entry<T>>) => Map<T>} */
|
|
51
|
+
export const fromEntries = fold(setReduceEntry(replace))(null);
|
|
52
|
+
/** @type {(name: string) => <T>(map: Map<T>) => Map<T>} */
|
|
53
|
+
export const remove = name => btreeRemove(keyCmp(name));
|
|
54
|
+
export const empty = null;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as _ from './module.f.mjs';
|
|
2
|
+
const { at, setReplace, setReduce, empty, entries, remove } = _;
|
|
3
|
+
import * as seq from '../list/module.f.mjs';
|
|
4
|
+
export default {
|
|
5
|
+
main: [
|
|
6
|
+
() => {
|
|
7
|
+
let m = setReplace('a')(1)(null);
|
|
8
|
+
if (at('a')(m) !== 1) {
|
|
9
|
+
throw 'error';
|
|
10
|
+
}
|
|
11
|
+
if (at('b')(m) !== null) {
|
|
12
|
+
throw 'error';
|
|
13
|
+
}
|
|
14
|
+
m = setReplace('b')(2)(m);
|
|
15
|
+
if (at('a')(m) !== 1) {
|
|
16
|
+
throw 'error';
|
|
17
|
+
}
|
|
18
|
+
if (at('b')(m) !== 2) {
|
|
19
|
+
throw 'error';
|
|
20
|
+
}
|
|
21
|
+
if (at('c')(m) !== null) {
|
|
22
|
+
throw 'error';
|
|
23
|
+
}
|
|
24
|
+
m = setReplace('z')(3)(m);
|
|
25
|
+
if (at('a')(m) !== 1) {
|
|
26
|
+
throw 'error';
|
|
27
|
+
}
|
|
28
|
+
if (at('b')(m) !== 2) {
|
|
29
|
+
throw 'error';
|
|
30
|
+
}
|
|
31
|
+
if (at('z')(m) !== 3) {
|
|
32
|
+
throw 'error';
|
|
33
|
+
}
|
|
34
|
+
if (at('')(m) !== null) {
|
|
35
|
+
throw 'error';
|
|
36
|
+
}
|
|
37
|
+
m = setReplace('')(4)(m);
|
|
38
|
+
if (at('a')(m) !== 1) {
|
|
39
|
+
throw 'error';
|
|
40
|
+
}
|
|
41
|
+
if (at('b')(m) !== 2) {
|
|
42
|
+
throw 'error';
|
|
43
|
+
}
|
|
44
|
+
if (at('z')(m) !== 3) {
|
|
45
|
+
throw 'error';
|
|
46
|
+
}
|
|
47
|
+
if (at('')(m) !== 4) {
|
|
48
|
+
throw 'error';
|
|
49
|
+
}
|
|
50
|
+
if (at('Hello world!')(m) !== null) {
|
|
51
|
+
throw 'error';
|
|
52
|
+
}
|
|
53
|
+
m = setReplace('Hello world!')(42)(m);
|
|
54
|
+
if (at('a')(m) !== 1) {
|
|
55
|
+
throw 'error';
|
|
56
|
+
}
|
|
57
|
+
if (at('b')(m) !== 2) {
|
|
58
|
+
throw 'error';
|
|
59
|
+
}
|
|
60
|
+
if (at('z')(m) !== 3) {
|
|
61
|
+
throw 'error';
|
|
62
|
+
}
|
|
63
|
+
if (at('')(m) !== 4) {
|
|
64
|
+
throw 'error';
|
|
65
|
+
}
|
|
66
|
+
if (at('Hello world!')(m) !== 42) {
|
|
67
|
+
throw 'error';
|
|
68
|
+
}
|
|
69
|
+
if (at('x')(m) !== null) {
|
|
70
|
+
throw 'error';
|
|
71
|
+
}
|
|
72
|
+
// console.log(Array.from(m.entries()))
|
|
73
|
+
m = remove('Hello world!')(m);
|
|
74
|
+
if (at('Hello world!')(m) !== null) {
|
|
75
|
+
throw m;
|
|
76
|
+
}
|
|
77
|
+
m = setReduce(a => b => a + b)('a')(43)(m);
|
|
78
|
+
if (at('a')(m) !== 44) {
|
|
79
|
+
throw 'error';
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
() => {
|
|
83
|
+
let m = setReplace('x')(12)(null);
|
|
84
|
+
m = setReplace('y')(44)(m);
|
|
85
|
+
if (at('x')(m) !== 12) {
|
|
86
|
+
throw 'error';
|
|
87
|
+
}
|
|
88
|
+
if (at('y')(m) !== 44) {
|
|
89
|
+
throw 'error';
|
|
90
|
+
}
|
|
91
|
+
if (at('a')(m) !== null) {
|
|
92
|
+
throw 'error';
|
|
93
|
+
}
|
|
94
|
+
const e = seq.toArray(entries(m));
|
|
95
|
+
if (e.length !== 2) {
|
|
96
|
+
throw 'error';
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
stress: () => {
|
|
101
|
+
/** @type {import('./module.f.mjs').Map<number>} */
|
|
102
|
+
let m = empty;
|
|
103
|
+
for (let i = 0; i < 100_000; ++i) {
|
|
104
|
+
m = setReplace((i * i).toString())(i)(m);
|
|
105
|
+
/*
|
|
106
|
+
console.log()
|
|
107
|
+
console.log(`# ${i}`)
|
|
108
|
+
console.log()
|
|
109
|
+
for (const e of m.struct()) {
|
|
110
|
+
console.log(e)
|
|
111
|
+
}
|
|
112
|
+
*/
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @typedef {number} NibbleSet */
|
|
2
|
+
/** @typedef {number} Nibble */
|
|
3
|
+
export const empty: 0;
|
|
4
|
+
export const universe: 65535;
|
|
5
|
+
/** @type {(n: Nibble) => (s: NibbleSet) => boolean} */
|
|
6
|
+
export const has: (n: Nibble) => (s: NibbleSet) => boolean;
|
|
7
|
+
/** @type {(n: Nibble) => (s: NibbleSet) => NibbleSet} */
|
|
8
|
+
export const set: (n: Nibble) => (s: NibbleSet) => NibbleSet;
|
|
9
|
+
/** @type {(n: NibbleSet) => NibbleSet} */
|
|
10
|
+
export const complement: (n: NibbleSet) => NibbleSet;
|
|
11
|
+
/** @type {(n: Nibble) => (s: NibbleSet) => NibbleSet} */
|
|
12
|
+
export const unset: (n: Nibble) => (s: NibbleSet) => NibbleSet;
|
|
13
|
+
/** @type {(r: readonly[number, number]) => (s: NibbleSet) => NibbleSet} */
|
|
14
|
+
export const setRange: (r: readonly [number, number]) => (s: NibbleSet) => NibbleSet;
|
|
15
|
+
export type NibbleSet = number;
|
|
16
|
+
export type Nibble = number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
/** @typedef {number} NibbleSet */
|
|
3
|
+
/** @typedef {number} Nibble */
|
|
4
|
+
export const empty = 0;
|
|
5
|
+
export const universe = 0xFFFF;
|
|
6
|
+
/** @type {(n: Nibble) => NibbleSet} */
|
|
7
|
+
const one = n => 1 << n;
|
|
8
|
+
/** @type {(n: Nibble) => (s: NibbleSet) => boolean} */
|
|
9
|
+
export const has = n => s => ((s >> n) & 1) === 1;
|
|
10
|
+
/** @type {(n: Nibble) => (s: NibbleSet) => NibbleSet} */
|
|
11
|
+
export const set = n => s => s | one(n);
|
|
12
|
+
/** @type {(n: NibbleSet) => NibbleSet} */
|
|
13
|
+
export const complement = s => universe ^ s;
|
|
14
|
+
/** @type {(n: Nibble) => (s: NibbleSet) => NibbleSet} */
|
|
15
|
+
export const unset = n => s => s & complement(one(n));
|
|
16
|
+
/** @type {(r: readonly[number, number]) => NibbleSet} */
|
|
17
|
+
const range = ([a, b]) => one(b - a + 1) - 1 << a;
|
|
18
|
+
/** @type {(r: readonly[number, number]) => (s: NibbleSet) => NibbleSet} */
|
|
19
|
+
export const setRange = r => s => s | range(r);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as list from '../list/module.f.mjs';
|
|
2
|
+
const { every, map, countdown } = list;
|
|
3
|
+
import * as _ from './module.f.mjs';
|
|
4
|
+
export default {
|
|
5
|
+
has: () => {
|
|
6
|
+
if (_.has(0)(_.empty)) {
|
|
7
|
+
throw _.empty;
|
|
8
|
+
}
|
|
9
|
+
if (_.has(1)(_.empty)) {
|
|
10
|
+
throw _.empty;
|
|
11
|
+
}
|
|
12
|
+
if (_.has(15)(_.empty)) {
|
|
13
|
+
throw _.empty;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
set: [
|
|
17
|
+
() => {
|
|
18
|
+
const s = _.set(0)(_.empty);
|
|
19
|
+
if (s !== 1) {
|
|
20
|
+
throw s;
|
|
21
|
+
}
|
|
22
|
+
if (!_.has(0)(s)) {
|
|
23
|
+
throw s;
|
|
24
|
+
}
|
|
25
|
+
if (_.has(1)(s)) {
|
|
26
|
+
throw s;
|
|
27
|
+
}
|
|
28
|
+
if (_.has(15)(s)) {
|
|
29
|
+
throw s;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
() => {
|
|
33
|
+
const s = _.set(15)(_.empty);
|
|
34
|
+
if (s !== 0x8000) {
|
|
35
|
+
throw s;
|
|
36
|
+
}
|
|
37
|
+
if (_.has(0)(s)) {
|
|
38
|
+
throw s;
|
|
39
|
+
}
|
|
40
|
+
if (_.has(1)(s)) {
|
|
41
|
+
throw s;
|
|
42
|
+
}
|
|
43
|
+
if (!_.has(15)(s)) {
|
|
44
|
+
throw s;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
unset: () => [
|
|
49
|
+
() => {
|
|
50
|
+
const a = _.set(0)(_.empty);
|
|
51
|
+
const result = _.unset(0)(a);
|
|
52
|
+
if (result !== 0) {
|
|
53
|
+
throw result;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
() => {
|
|
57
|
+
const a = _.set(15)(_.empty);
|
|
58
|
+
const result = _.unset(15)(a);
|
|
59
|
+
if (result !== 0) {
|
|
60
|
+
throw result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
setRange: () => {
|
|
65
|
+
const result = _.setRange([2, 5])(_.empty);
|
|
66
|
+
if (result !== 60) {
|
|
67
|
+
throw result;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
universe: () => {
|
|
71
|
+
const x = every(map(v => _.has(v)(_.universe))(countdown(16)));
|
|
72
|
+
if (!x) {
|
|
73
|
+
throw x;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
compliment: {
|
|
77
|
+
empty: () => {
|
|
78
|
+
const r = _.complement(_.empty);
|
|
79
|
+
if (r !== _.universe) {
|
|
80
|
+
throw r;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
universe: () => {
|
|
84
|
+
const r = _.complement(_.universe);
|
|
85
|
+
if (r !== _.empty) {
|
|
86
|
+
throw r;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @typedef {T|null} Nullable
|
|
4
|
+
*/
|
|
5
|
+
/** @type {<T, R>(f: (value: T) => R) => (value: Nullable<T>) => Nullable<R>} */
|
|
6
|
+
export const map: <T, R>(f: (value: T) => R) => (value: Nullable<T>) => Nullable<R>;
|
|
7
|
+
/** @type {<T, R>(f: (_: T) => R) => (none: () => R) => (_: Nullable<T>) => Nullable<R>} */
|
|
8
|
+
export const match: <T, R>(f: (_: T) => R) => (none: () => R) => (_: Nullable<T>) => Nullable<R>;
|
|
9
|
+
export type Nullable<T> = T | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
/**
|
|
3
|
+
* @template T
|
|
4
|
+
* @typedef {T|null} Nullable
|
|
5
|
+
*/
|
|
6
|
+
/** @type {<T, R>(f: (value: T) => R) => (value: Nullable<T>) => Nullable<R>} */
|
|
7
|
+
export const map = f => value => value === null ? null : f(value);
|
|
8
|
+
/** @type {<T, R>(f: (_: T) => R) => (none: () => R) => (_: Nullable<T>) => Nullable<R>} */
|
|
9
|
+
export const match = f => none => value => value === null ? none() : f(value);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const sum: (input: list.List<number>) => number;
|
|
2
|
+
export const min: (input: list.List<number>) => number | null;
|
|
3
|
+
export const max: (input: list.List<number>) => number | null;
|
|
4
|
+
/** @type {(a: number) => (b: number) => compare.Sign} */
|
|
5
|
+
export const cmp: (a: number) => (b: number) => compare.Sign;
|
|
6
|
+
import * as list from '../list/module.f.mjs';
|
|
7
|
+
import * as compare from '../function/compare/module.f.mjs';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
import * as list from '../list/module.f.mjs';
|
|
3
|
+
const { reduce } = list;
|
|
4
|
+
import * as operator from '../function/operator/module.f.mjs';
|
|
5
|
+
const { addition, min: minOp, max: maxOp } = operator;
|
|
6
|
+
import * as compare from '../function/compare/module.f.mjs';
|
|
7
|
+
const { unsafeCmp } = compare;
|
|
8
|
+
export const sum = reduce(addition)(0);
|
|
9
|
+
export const min = reduce(minOp)(null);
|
|
10
|
+
export const max = reduce(maxOp)(null);
|
|
11
|
+
/** @type {(a: number) => (b: number) => compare.Sign} */
|
|
12
|
+
export const cmp = unsafeCmp;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as _ from './module.f.mjs';
|
|
2
|
+
const { sum, min, max, cmp } = _;
|
|
3
|
+
export default {
|
|
4
|
+
sum: () => {
|
|
5
|
+
const result = sum([2, 3, 4, 5]);
|
|
6
|
+
if (result !== 14) {
|
|
7
|
+
throw result;
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
min: {
|
|
11
|
+
empty: () => {
|
|
12
|
+
const result = min([]);
|
|
13
|
+
if (result !== null) {
|
|
14
|
+
throw result;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
multi: () => {
|
|
18
|
+
const result = min([1, 2, 12, -4, 8]);
|
|
19
|
+
if (result !== -4) {
|
|
20
|
+
throw result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
max: () => {
|
|
25
|
+
const result = max([1, 2, 12, -4, 8]);
|
|
26
|
+
if (result !== 12) {
|
|
27
|
+
throw result;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
cmp: () => {
|
|
31
|
+
const result = cmp(4)(5);
|
|
32
|
+
if (result !== -1) {
|
|
33
|
+
throw result;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
standard: () => {
|
|
37
|
+
/** @type {(a: bigint) => (a: bigint) => void} */
|
|
38
|
+
const check = a => b => {
|
|
39
|
+
if (BigInt(Number(a)) != b) {
|
|
40
|
+
throw [a, b];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** @type {(v: bigint) => void} */
|
|
44
|
+
const eq = v => check(v)(v);
|
|
45
|
+
// 53, 0x35 bits.
|
|
46
|
+
// 3 2 1 0
|
|
47
|
+
// 4_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210
|
|
48
|
+
eq(4503599627370496n);
|
|
49
|
+
eq(4503599627370497n);
|
|
50
|
+
eq(4503599627370498n);
|
|
51
|
+
eq(4503599627370499n);
|
|
52
|
+
eq(4503599627370500n);
|
|
53
|
+
//
|
|
54
|
+
eq(8205552883602248n);
|
|
55
|
+
eq(6023495077481713n);
|
|
56
|
+
eq(7655550916643882n);
|
|
57
|
+
eq(7408615831253283n);
|
|
58
|
+
eq(5372046171422892n);
|
|
59
|
+
//
|
|
60
|
+
eq(9007199254740991n);
|
|
61
|
+
eq(9007199254740990n);
|
|
62
|
+
eq(9007199254740989n);
|
|
63
|
+
eq(9007199254740988n);
|
|
64
|
+
eq(9007199254740987n);
|
|
65
|
+
eq(9007199254740986n);
|
|
66
|
+
eq(9007199254740985n);
|
|
67
|
+
eq(9007199254740984n);
|
|
68
|
+
// 54, 0x35+1 bits.
|
|
69
|
+
// 3 2 1 0
|
|
70
|
+
// 4_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210_1
|
|
71
|
+
check(9007199254740992n)(9007199254740992n);
|
|
72
|
+
check(16585805050637558n)(16585805050637558n);
|
|
73
|
+
check(18014398509481982n)(18014398509481982n);
|
|
74
|
+
// round down
|
|
75
|
+
check(9007199254740993n)(9007199254740992n);
|
|
76
|
+
check(9007199254740997n)(9007199254740996n);
|
|
77
|
+
check(11727370849309157n)(11727370849309156n);
|
|
78
|
+
check(18014398509481981n)(18014398509481980n);
|
|
79
|
+
// round up
|
|
80
|
+
check(9007199254740995n)(9007199254740996n);
|
|
81
|
+
check(15679542343753527n)(15679542343753528n);
|
|
82
|
+
check(18014398509481983n)(18014398509481984n);
|
|
83
|
+
// 55, 0x35+2 bits.
|
|
84
|
+
// 3 2 1 0
|
|
85
|
+
// 4_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210_12
|
|
86
|
+
// 0_xx: down, down, up
|
|
87
|
+
// 0_00
|
|
88
|
+
check(18014398509481984n)(18014398509481984n);
|
|
89
|
+
check(31009640954244032n)(31009640954244032n);
|
|
90
|
+
check(36028797018963960n)(36028797018963960n);
|
|
91
|
+
// 0_01 round down
|
|
92
|
+
check(18014398509481985n)(18014398509481984n);
|
|
93
|
+
check(35865859090492321n)(35865859090492320n);
|
|
94
|
+
check(36028797018963961n)(36028797018963960n);
|
|
95
|
+
// 0_10 round down
|
|
96
|
+
check(18014398509481986n)(18014398509481984n);
|
|
97
|
+
check(20537830900813786n)(20537830900813784n);
|
|
98
|
+
check(36028797018963962n)(36028797018963960n);
|
|
99
|
+
// 0_11 round up
|
|
100
|
+
check(18014398509481987n)(18014398509481988n);
|
|
101
|
+
check(20762549594556867n)(20762549594556868n);
|
|
102
|
+
check(36028797018963963n)(36028797018963964n);
|
|
103
|
+
// 1_xx: down, up, up
|
|
104
|
+
// 1_00
|
|
105
|
+
check(18014398509481988n)(18014398509481988n);
|
|
106
|
+
check(27158415062912468n)(27158415062912468n);
|
|
107
|
+
check(36028797018963963n)(36028797018963964n);
|
|
108
|
+
// 1_01 round down
|
|
109
|
+
check(18014398509481989n)(18014398509481988n);
|
|
110
|
+
check(23136524663958789n)(23136524663958788n);
|
|
111
|
+
check(36028797018963965n)(36028797018963964n);
|
|
112
|
+
// 1_10 round up
|
|
113
|
+
check(18014398509481990n)(18014398509481992n);
|
|
114
|
+
check(35732739218314830n)(35732739218314832n);
|
|
115
|
+
check(36028797018963966n)(36028797018963968n);
|
|
116
|
+
// 1_11 round up
|
|
117
|
+
check(18014398509481991n)(18014398509481992n);
|
|
118
|
+
check(35015291789494295n)(35015291789494296n);
|
|
119
|
+
check(36028797018963967n)(36028797018963968n);
|
|
120
|
+
// 57, 0x35+4 bits.
|
|
121
|
+
// 3 2 1 0
|
|
122
|
+
// 4_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210_FEDC_BA98_7654_3210_1234
|
|
123
|
+
check(104002482718319358n)(104002482718319360n);
|
|
124
|
+
check(142693895881191444n)(142693895881191440n);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @typedef {{
|
|
4
|
+
* readonly [k in string]: T
|
|
5
|
+
* }} Map
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @template T
|
|
9
|
+
* @typedef {readonly[string, T]} Entry
|
|
10
|
+
*/
|
|
11
|
+
/** @type {(name: string) => <T>(object: Map<T>) => T|null} */
|
|
12
|
+
export const at: (name: string) => <T>(object: Map<T>) => T | null;
|
|
13
|
+
/** @type {<T>(e: list.List<Entry<T>>) => list.List<Entry<T>>} */
|
|
14
|
+
export const sort: <T>(e: list.List<Entry<T>>) => list.List<Entry<T>>;
|
|
15
|
+
/** @type {<T>(e: list.List<Entry<T>>) => Map<T>} */
|
|
16
|
+
export const fromEntries: <T>(e: list.List<Entry<T>>) => Map<T>;
|
|
17
|
+
/** @type {<T>(m: btMap.Map<T>) => Map<T>} */
|
|
18
|
+
export const fromMap: <T>(m: btMap.Map<T>) => Map<T>;
|
|
19
|
+
export type Map<T> = { readonly [k in string]: T; };
|
|
20
|
+
export type Entry<T> = readonly [string, T];
|
|
21
|
+
import * as list from '../list/module.f.mjs';
|
|
22
|
+
import * as btMap from '../map/module.f.mjs';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
import * as list from '../list/module.f.mjs';
|
|
3
|
+
const { iterable } = list;
|
|
4
|
+
import * as btMap from '../map/module.f.mjs';
|
|
5
|
+
const { entries: mapEntries, fromEntries: mapFromEntries } = btMap;
|
|
6
|
+
const { getOwnPropertyDescriptor, fromEntries: objectFromEntries } = Object;
|
|
7
|
+
/**
|
|
8
|
+
* @template T
|
|
9
|
+
* @typedef {{
|
|
10
|
+
* readonly [k in string]: T
|
|
11
|
+
* }} Map
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @template T
|
|
15
|
+
* @typedef {readonly[string, T]} Entry
|
|
16
|
+
*/
|
|
17
|
+
/** @type {(name: string) => <T>(object: Map<T>) => T|null} */
|
|
18
|
+
export const at = name => object => {
|
|
19
|
+
const r = getOwnPropertyDescriptor(object, name);
|
|
20
|
+
return r === void 0 ? null : r.value;
|
|
21
|
+
};
|
|
22
|
+
/** @type {<T>(e: list.List<Entry<T>>) => list.List<Entry<T>>} */
|
|
23
|
+
export const sort = e => mapEntries(mapFromEntries(e));
|
|
24
|
+
/** @type {<T>(e: list.List<Entry<T>>) => Map<T>} */
|
|
25
|
+
export const fromEntries = e => objectFromEntries(iterable(e));
|
|
26
|
+
/** @type {<T>(m: btMap.Map<T>) => Map<T>} */
|
|
27
|
+
export const fromMap = m => fromEntries(mapEntries(m));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as _ from './module.f.mjs';
|
|
2
|
+
export default {
|
|
3
|
+
ctor: () => {
|
|
4
|
+
const a = {};
|
|
5
|
+
const value = _.at('constructor')(a);
|
|
6
|
+
if (value !== null) {
|
|
7
|
+
throw value;
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
property: () => {
|
|
11
|
+
const a = { constructor: 42 };
|
|
12
|
+
const value = _.at('constructor')(a);
|
|
13
|
+
if (value !== 42) {
|
|
14
|
+
throw value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** @typedef {readonly[number,number]} Range */
|
|
2
|
+
/** @type {(range: Range) => (i: number) => boolean} */
|
|
3
|
+
export const contains: (range: Range) => (i: number) => boolean;
|
|
4
|
+
/** @type {(i: number) => Range} */
|
|
5
|
+
export const one: (i: number) => Range;
|
|
6
|
+
export type Range = readonly [number, number];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @ts-self-types="./module.f.d.mts"
|
|
2
|
+
/** @typedef {readonly[number,number]} Range */
|
|
3
|
+
/** @type {(range: Range) => (i: number) => boolean} */
|
|
4
|
+
export const contains = ([b, e]) => i => b <= i && i <= e;
|
|
5
|
+
/** @type {(i: number) => Range} */
|
|
6
|
+
export const one = a => [a, a];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as _ from './module.f.mjs';
|
|
2
|
+
export default () => {
|
|
3
|
+
if (!_.contains([0, 5])(1)) {
|
|
4
|
+
throw 1;
|
|
5
|
+
}
|
|
6
|
+
if (!_.contains([0, 5])(0)) {
|
|
7
|
+
throw 0;
|
|
8
|
+
}
|
|
9
|
+
if (!_.contains([0, 5])(5)) {
|
|
10
|
+
throw 5;
|
|
11
|
+
}
|
|
12
|
+
if (_.contains([0, 5])(-1)) {
|
|
13
|
+
throw -1;
|
|
14
|
+
}
|
|
15
|
+
if (_.contains([0, 5])(6)) {
|
|
16
|
+
throw 6;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export
|
|
1
|
+
/** @type {<T>(op: Operators<T>) => RangeMerge<T>} */
|
|
2
|
+
export const merge: <T>(op: Operators<T>) => RangeMerge<T>;
|
|
3
|
+
/** @type {<T>(def: T) => (value: number) => (rm: RangeMapArray<T>) => T} */
|
|
4
|
+
export const get: <T>(def: T) => (value: number) => (rm: RangeMapArray<T>) => T;
|
|
5
|
+
/** @type {<T>(def: T) => (r: Range.Range) => (value: T) => RangeMapArray<T>} */
|
|
6
|
+
export const fromRange: <T>(def: T) => (r: Range.Range) => (value: T) => RangeMapArray<T>;
|
|
7
7
|
export type Entry<T> = [T, number];
|
|
8
|
-
export type RangeMap<T> =
|
|
8
|
+
export type RangeMap<T> = sortedList.SortedList<Entry<T>>;
|
|
9
9
|
export type RangeMapArray<T> = readonly Entry<T>[];
|
|
10
10
|
export type Operators<T> = {
|
|
11
11
|
readonly union: O.Reduce<T>;
|
|
@@ -13,13 +13,7 @@ export type Operators<T> = {
|
|
|
13
13
|
};
|
|
14
14
|
export type RangeState<T> = Option.Nullable<Entry<T>>;
|
|
15
15
|
export type RangeMerge<T> = O.Reduce<RangeMap<T>>;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** @type {<T>(def: T) => (value: number) => (rm: RangeMapArray<T>) => T} */
|
|
19
|
-
declare const get: <T>(def: T) => (value: number) => (rm: RangeMapArray<T>) => T;
|
|
20
|
-
/** @type {<T>(def: T) => (r: Range.Range) => (value: T) => RangeMapArray<T>} */
|
|
21
|
-
declare const fromRange: <T>(def: T) => (r: Range.Range) => (value: T) => RangeMapArray<T>;
|
|
22
|
-
import * as SortedList from '../sorted_list/module.f.mjs';
|
|
16
|
+
import * as Range from '../range/module.f.mjs';
|
|
17
|
+
import * as sortedList from '../sorted_list/module.f.mjs';
|
|
23
18
|
import * as O from '../function/operator/module.f.mjs';
|
|
24
19
|
import * as Option from '../nullable/module.f.mjs';
|
|
25
|
-
import * as Range from '../range/module.f.mjs';
|