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
package/types/list/module.f.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import function_ from '../function/module.f.mjs'
|
|
2
|
+
import * as function_ from '../function/module.f.mjs'
|
|
3
3
|
const { identity, fn, compose } = function_
|
|
4
|
-
import
|
|
4
|
+
import * as operator from '../function/operator/module.f.mjs'
|
|
5
5
|
const {
|
|
6
6
|
addition,
|
|
7
7
|
logicalNot,
|
|
@@ -62,7 +62,7 @@ const fromArray = array => {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/** @type {<T>(head: List<T>) => (tail: List<T>) => List<T>} */
|
|
65
|
-
const concat = head => tail => tail === null ? head : ({ head, tail })
|
|
65
|
+
export const concat = head => tail => tail === null ? head : ({ head, tail })
|
|
66
66
|
|
|
67
67
|
/** @type {<T>(list: List<T>) => NotLazy<T> } */
|
|
68
68
|
const trampoline = list => {
|
|
@@ -71,7 +71,7 @@ const trampoline = list => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/** @type {<T>(list: List<T>) => Result<T>} */
|
|
74
|
-
const next = head => {
|
|
74
|
+
export const next = head => {
|
|
75
75
|
/** @type {typeof head} */
|
|
76
76
|
let tail = null
|
|
77
77
|
while (true) {
|
|
@@ -95,7 +95,7 @@ const next = head => {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/** @type {<T>(list: List<T>) => Iterable<T>} */
|
|
98
|
-
const iterable = list => ({
|
|
98
|
+
export const iterable = list => ({
|
|
99
99
|
*[Symbol.iterator]() {
|
|
100
100
|
let i = list
|
|
101
101
|
while (true) {
|
|
@@ -110,7 +110,7 @@ const iterable = list => ({
|
|
|
110
110
|
const { from } = Array
|
|
111
111
|
|
|
112
112
|
/** @type {<T>(list: List<T>) => readonly T[]} */
|
|
113
|
-
const toArray = list => {
|
|
113
|
+
export const toArray = list => {
|
|
114
114
|
const u = trampoline(list)
|
|
115
115
|
return u instanceof Array ? u : from(iterable(u))
|
|
116
116
|
}
|
|
@@ -126,16 +126,16 @@ const apply = f => input => () => {
|
|
|
126
126
|
const flatStep = ({ first, tail }) => concat(first)(flat(tail))
|
|
127
127
|
|
|
128
128
|
/** @type {<T>(list: List<List<T>>) => Thunk<T>} */
|
|
129
|
-
const flat = apply(flatStep)
|
|
129
|
+
export const flat = apply(flatStep)
|
|
130
130
|
|
|
131
131
|
/** @type {<I, O>(f: (value: I) => O) => (n: NonEmpty<I>) => List<O>} */
|
|
132
132
|
const mapStep = f => ({ first, tail }) => ({ first: f(first), tail: map(f)(tail) })
|
|
133
133
|
|
|
134
134
|
/** @type {<I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>} */
|
|
135
|
-
const map = f => apply(mapStep(f))
|
|
135
|
+
export const map = f => apply(mapStep(f))
|
|
136
136
|
|
|
137
137
|
/** @type {<I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>} */
|
|
138
|
-
const flatMap = f => compose(map(f))(flat)
|
|
138
|
+
export const flatMap = f => compose(map(f))(flat)
|
|
139
139
|
|
|
140
140
|
/** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
|
|
141
141
|
const filterStep = f => ({ first, tail }) => {
|
|
@@ -144,7 +144,7 @@ const filterStep = f => ({ first, tail }) => {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
147
|
-
const filter = f => apply(filterStep(f))
|
|
147
|
+
export const filter = f => apply(filterStep(f))
|
|
148
148
|
|
|
149
149
|
/** @type {<I, O>(f: (value: I) => O|null) => (n: NonEmpty<I>) => List<O>} */
|
|
150
150
|
const filterMapStep = f => n => {
|
|
@@ -153,40 +153,40 @@ const filterMapStep = f => n => {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/** @type {<I, O>(f: (value: I) => O|null) => (input: List<I>) => Thunk<O>} */
|
|
156
|
-
const filterMap = f => apply(filterMapStep(f))
|
|
156
|
+
export const filterMap = f => apply(filterMapStep(f))
|
|
157
157
|
|
|
158
158
|
/** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
|
|
159
159
|
const takeWhileStep = f => ({ first, tail }) => f(first) ? { first, tail: takeWhile(f)(tail) } : null
|
|
160
160
|
|
|
161
161
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
162
|
-
const takeWhile = f => apply(takeWhileStep(f))
|
|
162
|
+
export const takeWhile = f => apply(takeWhileStep(f))
|
|
163
163
|
|
|
164
164
|
/** @type {(n: number) => <T>(result: NonEmpty<T>) => List<T>} */
|
|
165
165
|
const takeStep = n => ({ first, tail }) => 0 < n ? { first: first, tail: take(n - 1)(tail) } : null
|
|
166
166
|
|
|
167
167
|
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
168
|
-
const take = n => apply(takeStep(n))
|
|
168
|
+
export const take = n => apply(takeStep(n))
|
|
169
169
|
|
|
170
170
|
/** @type {<T>(f: (value: T) => boolean) => (ne: NonEmpty<T>) => List<T>} */
|
|
171
171
|
const dropWhileStep = f => ne => f(ne.first) ? dropWhile(f)(ne.tail) : ne
|
|
172
172
|
|
|
173
173
|
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
174
|
-
const dropWhile = f => apply(dropWhileStep(f))
|
|
174
|
+
export const dropWhile = f => apply(dropWhileStep(f))
|
|
175
175
|
|
|
176
176
|
/** @type {(n: number) => <T>(ne: NonEmpty<T>) => List<T>} */
|
|
177
177
|
const dropStep = n => ne => 0 < n ? drop(n - 1)(ne.tail) : ne
|
|
178
178
|
|
|
179
179
|
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
180
|
-
const drop = n => apply(dropStep(n))
|
|
180
|
+
export const drop = n => apply(dropStep(n))
|
|
181
181
|
|
|
182
182
|
/** @type {<D>(def: D) => <T>(input: List<T>) => D|T} */
|
|
183
|
-
const first = def => input => {
|
|
183
|
+
export const first = def => input => {
|
|
184
184
|
const ne = next(input)
|
|
185
185
|
return ne === null ? def : ne.first
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/** @type {<D>(first: D) => <T>(tail: List<T>) => D|T} */
|
|
189
|
-
const last = first => tail => {
|
|
189
|
+
export const last = first => tail => {
|
|
190
190
|
/** @typedef {typeof tail extends List<infer T> ? T : never} T */
|
|
191
191
|
/** @type {NonEmpty<typeof first|T>} */
|
|
192
192
|
let i = { first, tail }
|
|
@@ -200,61 +200,61 @@ const last = first => tail => {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/** @type {<D>(def: D) => <T>(f: (value: T) => boolean) => (input: List<T>) => D|T} */
|
|
203
|
-
const find = def => f => compose(filter(f))(first(def))
|
|
203
|
+
export const find = def => f => compose(filter(f))(first(def))
|
|
204
204
|
|
|
205
205
|
/** @type {(input: List<boolean>) => boolean} */
|
|
206
|
-
const some = find(false)(identity)
|
|
206
|
+
export const some = find(false)(identity)
|
|
207
207
|
|
|
208
208
|
/** @type {<T>(input: List<T>) => boolean} */
|
|
209
|
-
const isEmpty = fn(map(() => true))
|
|
209
|
+
export const isEmpty = fn(map(() => true))
|
|
210
210
|
.then(some)
|
|
211
211
|
.then(logicalNot)
|
|
212
212
|
.result
|
|
213
213
|
|
|
214
|
-
const every = fn(map(logicalNot))
|
|
214
|
+
export const every = fn(map(logicalNot))
|
|
215
215
|
.then(some)
|
|
216
216
|
.then(logicalNot)
|
|
217
217
|
.result
|
|
218
218
|
|
|
219
219
|
/** @type {<T>(value: T) => (sequence: List<T>) => boolean} */
|
|
220
|
-
const includes = value => compose(map(strictEqual(value)))(some)
|
|
220
|
+
export const includes = value => compose(map(strictEqual(value)))(some)
|
|
221
221
|
|
|
222
222
|
/** @type {(count: number) => Thunk<number>} */
|
|
223
|
-
const countdown = count => () => {
|
|
223
|
+
export const countdown = count => () => {
|
|
224
224
|
if (count <= 0) { return null }
|
|
225
225
|
const first = count - 1
|
|
226
226
|
return { first, tail: countdown(first) }
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/** @type {<T>(v: T) => (c: number) => Thunk<T>} */
|
|
230
|
-
const repeat = v => compose(countdown)(map(() => v))
|
|
230
|
+
export const repeat = v => compose(countdown)(map(() => v))
|
|
231
231
|
|
|
232
232
|
/** @type {<T>(list: List<T>) => List<T>} */
|
|
233
|
-
const cycle = list => () => {
|
|
233
|
+
export const cycle = list => () => {
|
|
234
234
|
const i = next(list)
|
|
235
235
|
return i === null ? null : { first: i.first, tail: concat(i.tail)(cycle(list)) }
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
/** @type {<I, O>(op:
|
|
238
|
+
/** @type {<I, O>(op: operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>} */
|
|
239
239
|
const scanStep = op => ne => {
|
|
240
240
|
const [first, newOp] = op(ne.first)
|
|
241
241
|
return { first, tail: scan(newOp)(ne.tail) }
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
/** @type {<I, O>(op:
|
|
245
|
-
const scan = op => apply(scanStep(op))
|
|
244
|
+
/** @type {<I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
|
|
245
|
+
export const scan = op => apply(scanStep(op))
|
|
246
246
|
|
|
247
|
-
/** @type {<I, S, O>(op:
|
|
248
|
-
const stateScan = op => compose(stateScanToScan(op))(scan)
|
|
247
|
+
/** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
|
|
248
|
+
export const stateScan = op => compose(stateScanToScan(op))(scan)
|
|
249
249
|
|
|
250
|
-
/** @type {<I,O>(op:
|
|
251
|
-
const foldScan = op => compose(foldToScan(op))(scan)
|
|
250
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
|
|
251
|
+
export const foldScan = op => compose(foldToScan(op))(scan)
|
|
252
252
|
|
|
253
|
-
/** @type {<I,O>(op:
|
|
254
|
-
const fold = op => init => compose(foldScan(op)(init))(last(init))
|
|
253
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
|
|
254
|
+
export const fold = op => init => compose(foldScan(op)(init))(last(init))
|
|
255
255
|
|
|
256
|
-
/** @type {<T>(op:
|
|
257
|
-
const reduce = op => def => compose(scan(reduceToScan(op)))(last(def))
|
|
256
|
+
/** @type {<T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
|
|
257
|
+
export const reduce = op => def => compose(scan(reduceToScan(op)))(last(def))
|
|
258
258
|
|
|
259
259
|
/** @type {<T>(list: List<T>) => Thunk<number>} */
|
|
260
260
|
const lengthList = list => () => {
|
|
@@ -271,7 +271,7 @@ const lengthList = list => () => {
|
|
|
271
271
|
const sum = reduce(addition)(0)
|
|
272
272
|
|
|
273
273
|
/** @type {<T>(input: List<T>) => number} */
|
|
274
|
-
const length = compose(lengthList)(sum)
|
|
274
|
+
export const length = compose(lengthList)(sum)
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
277
|
* @template T
|
|
@@ -282,9 +282,9 @@ const length = compose(lengthList)(sum)
|
|
|
282
282
|
const entryOperator = index => value => [[index, value], index + 1]
|
|
283
283
|
|
|
284
284
|
/** @type {<T>(input: List<T>) => Thunk<Entry<T>>} */
|
|
285
|
-
const entries = input => {
|
|
285
|
+
export const entries = input => {
|
|
286
286
|
/** @typedef {typeof input extends List<infer T> ? T : never} T */
|
|
287
|
-
/** @type {
|
|
287
|
+
/** @type {operator.StateScan<T, Number, Entry<T>>} */
|
|
288
288
|
const o = entryOperator
|
|
289
289
|
return stateScan(o)(0)(input)
|
|
290
290
|
}
|
|
@@ -293,10 +293,10 @@ const entries = input => {
|
|
|
293
293
|
const reverseOperator = first => tail => ({ first, tail })
|
|
294
294
|
|
|
295
295
|
/** @type {<T>(input: List<T>) => List<T>} */
|
|
296
|
-
const reverse = fold(reverseOperator)(null)
|
|
296
|
+
export const reverse = fold(reverseOperator)(null)
|
|
297
297
|
|
|
298
298
|
/** @type {<A>(a: List<A>) => <B>(b: List<B>) => Thunk<readonly[A, B]>} */
|
|
299
|
-
const zip = a => b => () => {
|
|
299
|
+
export const zip = a => b => () => {
|
|
300
300
|
const aResult = next(a)
|
|
301
301
|
if (aResult === null) { return null }
|
|
302
302
|
const bResult = next(b)
|
|
@@ -304,9 +304,9 @@ const zip = a => b => () => {
|
|
|
304
304
|
return { first: [aResult.first, bResult.first], tail: zip(aResult.tail)(bResult.tail) }
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
/** @type {<T>(e:
|
|
308
|
-
const equal = e => {
|
|
309
|
-
/** @typedef {typeof e extends
|
|
307
|
+
/** @type {<T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean} */
|
|
308
|
+
export const equal = e => {
|
|
309
|
+
/** @typedef {typeof e extends operator.Equal<infer T> ? T : never} T */
|
|
310
310
|
/** @type {(a: List<T>) => (b: List<T>) => List<boolean>} */
|
|
311
311
|
const f = a => b => () => {
|
|
312
312
|
const [aResult, bResult] = [next(a), next(b)]
|
|
@@ -317,73 +317,4 @@ const equal = e => {
|
|
|
317
317
|
return a => b => every(f(a)(b))
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
export
|
|
321
|
-
/** @readonly */
|
|
322
|
-
empty: null,
|
|
323
|
-
/** @readonly */
|
|
324
|
-
concat,
|
|
325
|
-
/** @readonly */
|
|
326
|
-
next,
|
|
327
|
-
/** @readonly */
|
|
328
|
-
iterable,
|
|
329
|
-
/** @readonly */
|
|
330
|
-
toArray,
|
|
331
|
-
/** @readonly */
|
|
332
|
-
flat,
|
|
333
|
-
/** @readonly */
|
|
334
|
-
map,
|
|
335
|
-
/** @readonly */
|
|
336
|
-
flatMap,
|
|
337
|
-
/** @readonly */
|
|
338
|
-
filter,
|
|
339
|
-
/** @readonly */
|
|
340
|
-
filterMap,
|
|
341
|
-
/** @readonly */
|
|
342
|
-
takeWhile,
|
|
343
|
-
/** @readonly */
|
|
344
|
-
take,
|
|
345
|
-
/** @readonly */
|
|
346
|
-
dropWhile,
|
|
347
|
-
/** @readonly */
|
|
348
|
-
drop,
|
|
349
|
-
/** @readonly */
|
|
350
|
-
first,
|
|
351
|
-
/** @readonly */
|
|
352
|
-
last,
|
|
353
|
-
/** @readonly */
|
|
354
|
-
find,
|
|
355
|
-
/** @readonly */
|
|
356
|
-
some,
|
|
357
|
-
/** @readonly */
|
|
358
|
-
every,
|
|
359
|
-
/** @readonly */
|
|
360
|
-
isEmpty,
|
|
361
|
-
/** @readonly */
|
|
362
|
-
includes,
|
|
363
|
-
/** @readonly */
|
|
364
|
-
countdown,
|
|
365
|
-
/** @readonly */
|
|
366
|
-
repeat,
|
|
367
|
-
/** @readonly */
|
|
368
|
-
cycle,
|
|
369
|
-
/** @readonly */
|
|
370
|
-
scan,
|
|
371
|
-
/** @readonly */
|
|
372
|
-
stateScan,
|
|
373
|
-
/** @readonly */
|
|
374
|
-
foldScan,
|
|
375
|
-
/** @readonly */
|
|
376
|
-
fold,
|
|
377
|
-
/** @readonly */
|
|
378
|
-
reduce,
|
|
379
|
-
/** @readonly */
|
|
380
|
-
length,
|
|
381
|
-
/** @readonly */
|
|
382
|
-
entries,
|
|
383
|
-
/** @readonly */
|
|
384
|
-
reverse,
|
|
385
|
-
/** @readonly */
|
|
386
|
-
zip,
|
|
387
|
-
/** @readonly */
|
|
388
|
-
equal
|
|
389
|
-
}
|
|
320
|
+
export const empty = null
|
package/types/list/test.f.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import o
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
|
+
import * as json from '../../json/module.f.mjs'
|
|
3
|
+
import * as o from '../object/module.f.mjs'
|
|
4
4
|
const { sort } = o
|
|
5
|
-
import operator from '../function/operator/module.f.mjs'
|
|
5
|
+
import * as operator from '../function/operator/module.f.mjs'
|
|
6
6
|
const { addition, strictEqual, reduceToScan } = operator
|
|
7
7
|
|
|
8
|
-
/** @type {(sequence:
|
|
8
|
+
/** @type {(sequence: _.List<json.Unknown>) => string} */
|
|
9
9
|
const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
10
10
|
|
|
11
11
|
const stringifyTest = () => {
|
|
@@ -197,7 +197,7 @@ const stress = () => ({
|
|
|
197
197
|
if (first !== n - 1) { throw first }
|
|
198
198
|
},
|
|
199
199
|
concatBack: () => {
|
|
200
|
-
/** @type {
|
|
200
|
+
/** @type {_.List<number>} */
|
|
201
201
|
let sequence = []
|
|
202
202
|
// 20_000_000 is too much
|
|
203
203
|
// 10_000_000 is too much for Deno 1
|
|
@@ -207,7 +207,7 @@ const stress = () => ({
|
|
|
207
207
|
const r = _.toArray(sequence)
|
|
208
208
|
},
|
|
209
209
|
flatToArray: () => {
|
|
210
|
-
/** @type {
|
|
210
|
+
/** @type {_.List<number>} */
|
|
211
211
|
let sequence = []
|
|
212
212
|
// 4_000_000 is too much
|
|
213
213
|
for (let i = 0; i < 2_000_000; ++i) {
|
|
@@ -216,7 +216,7 @@ const stress = () => ({
|
|
|
216
216
|
const r = _.toArray(sequence)
|
|
217
217
|
},
|
|
218
218
|
flatNext: () => {
|
|
219
|
-
/** @type {
|
|
219
|
+
/** @type {_.List<number>} */
|
|
220
220
|
let sequence = []
|
|
221
221
|
// 4_000_000 is too much
|
|
222
222
|
for (let i = 0; i < 2_000_000; ++i) {
|
|
@@ -225,7 +225,7 @@ const stress = () => ({
|
|
|
225
225
|
const a = _.next(sequence)
|
|
226
226
|
},
|
|
227
227
|
concatFront: () => {
|
|
228
|
-
/** @type {
|
|
228
|
+
/** @type {_.List<number>} */
|
|
229
229
|
let sequence = []
|
|
230
230
|
// 20_000_000 is too much
|
|
231
231
|
for (let i = 0; i < 10_000_000; ++i) {
|
|
@@ -234,7 +234,7 @@ const stress = () => ({
|
|
|
234
234
|
const a = _.next(sequence)
|
|
235
235
|
},
|
|
236
236
|
flatFront: () => {
|
|
237
|
-
/** @type {
|
|
237
|
+
/** @type {_.List<number>} */
|
|
238
238
|
let sequence = []
|
|
239
239
|
// 10_000_000 is too much
|
|
240
240
|
for (let i = 0; i < 5_000_000; ++i) {
|
package/types/map/module.f.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
2
|
import * as BtreeTypes from '../btree/types/module.f.mjs'
|
|
3
|
-
import btf from '../btree/find/module.f.mjs'
|
|
3
|
+
import * as btf from '../btree/find/module.f.mjs'
|
|
4
4
|
const { value, find } = btf
|
|
5
|
-
import bts from '../btree/set/module.f.mjs'
|
|
5
|
+
import * as bts from '../btree/set/module.f.mjs'
|
|
6
6
|
const { set } = bts
|
|
7
|
-
import btr from '../btree/remove/module.f.mjs'
|
|
7
|
+
import * as btr from '../btree/remove/module.f.mjs'
|
|
8
8
|
const { remove: btreeRemove } = btr
|
|
9
|
-
import bt from '../btree/module.f.mjs'
|
|
9
|
+
import * as bt from '../btree/module.f.mjs'
|
|
10
10
|
const { values } = bt
|
|
11
11
|
import * as Compare from '../function/compare/module.f.mjs'
|
|
12
|
-
import s from '../string/module.f.mjs'
|
|
12
|
+
import * as s from '../string/module.f.mjs'
|
|
13
13
|
const { cmp } = s
|
|
14
|
-
import
|
|
14
|
+
import * as list from '../list/module.f.mjs'
|
|
15
15
|
const { fold } = list
|
|
16
16
|
import * as Operator from '../function/operator/module.f.mjs'
|
|
17
17
|
|
|
@@ -36,7 +36,7 @@ import * as Operator from '../function/operator/module.f.mjs'
|
|
|
36
36
|
const keyCmp = a => ([b]) => cmp(a)(b)
|
|
37
37
|
|
|
38
38
|
/** @type {(name: string) => <T>(map: Map<T>) => T|null} */
|
|
39
|
-
const at = name => map => {
|
|
39
|
+
export const at = name => map => {
|
|
40
40
|
if (map === null) { return null }
|
|
41
41
|
const result = value(find(keyCmp(name))(map).first)
|
|
42
42
|
return result === null ? null : result[1]
|
|
@@ -47,36 +47,21 @@ const setReduceEntry = reduce => entry =>
|
|
|
47
47
|
set(keyCmp(entry[0]))(old => old === null ? entry : [old[0], reduce(old[1])(entry[1])])
|
|
48
48
|
|
|
49
49
|
/** @type {<T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>} */
|
|
50
|
-
const setReduce = reduce => name => value => setReduceEntry(reduce)([name, value])
|
|
50
|
+
export const setReduce = reduce => name => value => setReduceEntry(reduce)([name, value])
|
|
51
51
|
|
|
52
52
|
/** @type {<T>(a: T) => (b: T) => T} */
|
|
53
53
|
const replace = () => b => b
|
|
54
54
|
|
|
55
55
|
/** @type {(name: string) => <T>(value: T) => (map: Map<T>) => Map<T>} */
|
|
56
|
-
const setReplace = name => value => setReduceEntry(replace)([name, value])
|
|
56
|
+
export const setReplace = name => value => setReduceEntry(replace)([name, value])
|
|
57
57
|
|
|
58
|
-
/** @type {<T>(map: Map<T>) =>
|
|
59
|
-
const entries = values
|
|
58
|
+
/** @type {<T>(map: Map<T>) => list.List<Entry<T>>} */
|
|
59
|
+
export const entries = values
|
|
60
60
|
|
|
61
|
-
/** @type {<T>(entries:
|
|
62
|
-
const fromEntries = fold(setReduceEntry(replace))(null)
|
|
61
|
+
/** @type {<T>(entries: list.List<Entry<T>>) => Map<T>} */
|
|
62
|
+
export const fromEntries = fold(setReduceEntry(replace))(null)
|
|
63
63
|
|
|
64
64
|
/** @type {(name: string) => <T>(map: Map<T>) => Map<T>} */
|
|
65
|
-
const remove = name => btreeRemove(keyCmp(name))
|
|
65
|
+
export const remove = name => btreeRemove(keyCmp(name))
|
|
66
66
|
|
|
67
|
-
export
|
|
68
|
-
/** @readonly */
|
|
69
|
-
empty: null,
|
|
70
|
-
/** @readonly */
|
|
71
|
-
at,
|
|
72
|
-
/** @readonly */
|
|
73
|
-
setReduce,
|
|
74
|
-
/** @readonly */
|
|
75
|
-
setReplace,
|
|
76
|
-
/** @readonly */
|
|
77
|
-
entries,
|
|
78
|
-
/** @readonly */
|
|
79
|
-
fromEntries,
|
|
80
|
-
/** @readonly */
|
|
81
|
-
remove,
|
|
82
|
-
}
|
|
67
|
+
export const empty = null
|
package/types/map/test.f.mjs
CHANGED
|
@@ -2,44 +2,27 @@
|
|
|
2
2
|
/** @typedef {number} NibbleSet */
|
|
3
3
|
/** @typedef {number} Nibble */
|
|
4
4
|
|
|
5
|
-
const empty = 0
|
|
5
|
+
export const empty = 0
|
|
6
6
|
|
|
7
|
-
const universe = 0xFFFF
|
|
7
|
+
export const universe = 0xFFFF
|
|
8
8
|
|
|
9
9
|
/** @type {(n: Nibble) => NibbleSet} */
|
|
10
10
|
const one = n => 1 << n
|
|
11
11
|
|
|
12
12
|
/** @type {(n: Nibble) => (s: NibbleSet) => boolean} */
|
|
13
|
-
const has = n => s => ((s >> n) & 1) === 1
|
|
13
|
+
export const has = n => s => ((s >> n) & 1) === 1
|
|
14
14
|
|
|
15
15
|
/** @type {(n: Nibble) => (s: NibbleSet) => NibbleSet} */
|
|
16
|
-
const set = n => s => s | one(n)
|
|
16
|
+
export const set = n => s => s | one(n)
|
|
17
17
|
|
|
18
18
|
/** @type {(n: NibbleSet) => NibbleSet} */
|
|
19
|
-
const complement = s => universe ^ s
|
|
19
|
+
export const complement = s => universe ^ s
|
|
20
20
|
|
|
21
21
|
/** @type {(n: Nibble) => (s: NibbleSet) => NibbleSet} */
|
|
22
|
-
const unset = n => s => s & complement(one(n))
|
|
22
|
+
export const unset = n => s => s & complement(one(n))
|
|
23
23
|
|
|
24
24
|
/** @type {(r: readonly[number, number]) => NibbleSet} */
|
|
25
25
|
const range = ([a, b]) => one(b - a + 1) - 1 << a
|
|
26
26
|
|
|
27
27
|
/** @type {(r: readonly[number, number]) => (s: NibbleSet) => NibbleSet} */
|
|
28
|
-
const setRange = r => s => s | range(r)
|
|
29
|
-
|
|
30
|
-
export default {
|
|
31
|
-
/** @readonly */
|
|
32
|
-
empty,
|
|
33
|
-
/** @readonly */
|
|
34
|
-
universe,
|
|
35
|
-
/** @readonly */
|
|
36
|
-
has,
|
|
37
|
-
/** @readonly */
|
|
38
|
-
complement,
|
|
39
|
-
/** @readonly */
|
|
40
|
-
set,
|
|
41
|
-
/** @readonly */
|
|
42
|
-
unset,
|
|
43
|
-
/** @readonly */
|
|
44
|
-
setRange,
|
|
45
|
-
}
|
|
28
|
+
export const setRange = r => s => s | range(r)
|
|
@@ -5,14 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/** @type {<T, R>(f: (value: T) => R) => (value: Nullable<T>) => Nullable<R>} */
|
|
8
|
-
const map = f => value => value === null ? null : f(value)
|
|
8
|
+
export const map = f => value => value === null ? null : f(value)
|
|
9
9
|
|
|
10
10
|
/** @type {<T, R>(f: (_: T) => R) => (none: () => R) => (_: Nullable<T>) => Nullable<R>} */
|
|
11
|
-
const match = f => none => value => value === null ? none() : f(value)
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
/** @readonly */
|
|
15
|
-
map,
|
|
16
|
-
/** @readonly */
|
|
17
|
-
match,
|
|
18
|
-
}
|
|
11
|
+
export const match = f => none => value => value === null ? none() : f(value)
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import list from '../list/module.f.mjs'
|
|
2
|
+
import * as list from '../list/module.f.mjs'
|
|
3
3
|
const { reduce } = list
|
|
4
|
-
import operator from '../function/operator/module.f.mjs'
|
|
4
|
+
import * as operator from '../function/operator/module.f.mjs'
|
|
5
5
|
const { addition, min: minOp, max: maxOp } = operator
|
|
6
|
-
import
|
|
6
|
+
import * as compare from '../function/compare/module.f.mjs'
|
|
7
7
|
const { unsafeCmp } = compare
|
|
8
8
|
|
|
9
|
-
const sum = reduce(addition)(0)
|
|
9
|
+
export const sum = reduce(addition)(0)
|
|
10
10
|
|
|
11
|
-
const min = reduce(minOp)(null)
|
|
11
|
+
export const min = reduce(minOp)(null)
|
|
12
12
|
|
|
13
|
-
const max = reduce(maxOp)(null)
|
|
13
|
+
export const max = reduce(maxOp)(null)
|
|
14
14
|
|
|
15
|
-
/** @type {(a: number) => (b: number) =>
|
|
16
|
-
const cmp = unsafeCmp
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
/** @readonly */
|
|
20
|
-
sum,
|
|
21
|
-
/** @readonly */
|
|
22
|
-
min,
|
|
23
|
-
/** @readonly */
|
|
24
|
-
max,
|
|
25
|
-
/** @readonly */
|
|
26
|
-
cmp,
|
|
27
|
-
}
|
|
15
|
+
/** @type {(a: number) => (b: number) => compare.Sign} */
|
|
16
|
+
export const cmp = unsafeCmp
|
package/types/number/test.f.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as list from '../list/module.f.mjs'
|
|
3
3
|
const { iterable } = list
|
|
4
|
-
import
|
|
4
|
+
import * as btMap from '../map/module.f.mjs'
|
|
5
5
|
const { entries: mapEntries, fromEntries: mapFromEntries } = btMap
|
|
6
6
|
const { getOwnPropertyDescriptor, fromEntries: objectFromEntries } = Object
|
|
7
7
|
|
|
@@ -18,27 +18,16 @@ const { getOwnPropertyDescriptor, fromEntries: objectFromEntries } = Object
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
/** @type {(name: string) => <T>(object: Map<T>) => T|null} */
|
|
21
|
-
const at = name => object => {
|
|
21
|
+
export const at = name => object => {
|
|
22
22
|
const r = getOwnPropertyDescriptor(object, name)
|
|
23
23
|
return r === void 0 ? null : r.value
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** @type {<T>(e:
|
|
27
|
-
const sort = e => mapEntries(mapFromEntries(e))
|
|
26
|
+
/** @type {<T>(e: list.List<Entry<T>>) => list.List<Entry<T>>} */
|
|
27
|
+
export const sort = e => mapEntries(mapFromEntries(e))
|
|
28
28
|
|
|
29
|
-
/** @type {<T>(e:
|
|
30
|
-
const fromEntries = e => objectFromEntries(iterable(e))
|
|
29
|
+
/** @type {<T>(e: list.List<Entry<T>>) => Map<T>} */
|
|
30
|
+
export const fromEntries = e => objectFromEntries(iterable(e))
|
|
31
31
|
|
|
32
|
-
/** @type {<T>(m:
|
|
33
|
-
const fromMap = m => fromEntries(mapEntries(m))
|
|
34
|
-
|
|
35
|
-
export default {
|
|
36
|
-
/** @readonly */
|
|
37
|
-
at,
|
|
38
|
-
/** @readonly */
|
|
39
|
-
sort,
|
|
40
|
-
/** @readonly */
|
|
41
|
-
fromEntries,
|
|
42
|
-
/** @readonly */
|
|
43
|
-
fromMap,
|
|
44
|
-
}
|
|
32
|
+
/** @type {<T>(m: btMap.Map<T>) => Map<T>} */
|
|
33
|
+
export const fromMap = m => fromEntries(mapEntries(m))
|
package/types/object/test.f.mjs
CHANGED
package/types/range/module.f.mjs
CHANGED
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
/** @typedef {readonly[number,number]} Range */
|
|
3
3
|
|
|
4
4
|
/** @type {(range: Range) => (i: number) => boolean} */
|
|
5
|
-
const contains = ([b, e]) => i => b <= i && i <= e
|
|
5
|
+
export const contains = ([b, e]) => i => b <= i && i <= e
|
|
6
6
|
|
|
7
7
|
/** @type {(i: number) => Range} */
|
|
8
|
-
const one = a => [a, a]
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
/** @readonly */
|
|
12
|
-
contains,
|
|
13
|
-
/** @readonly */
|
|
14
|
-
one,
|
|
15
|
-
}
|
|
8
|
+
export const one = a => [a, a]
|