functionalscript 0.2.6 → 0.3.0
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/.github/workflows/ci.yml +19 -4
- package/CHANGELOG.md +5 -0
- package/com/cpp/{module.f.mjs → module.f.ts} +65 -44
- package/com/cpp/{test.f.mjs → test.f.ts} +1 -1
- package/com/cpp/testlib.f.ts +8 -0
- package/com/cs/{module.f.mjs → module.f.ts} +47 -38
- package/com/cs/{test.f.mjs → test.f.ts} +2 -2
- package/com/cs/testlib.f.ts +8 -0
- package/com/rust/module.f.ts +287 -0
- package/com/rust/{test.f.mjs → test.f.ts} +1 -1
- package/com/rust/testlib.f.ts +8 -0
- package/com/test/{build.f.mjs → build.f.ts} +47 -45
- package/com/test/{build.mjs → build.ts} +7 -6
- package/com/types/module.f.ts +62 -0
- package/com/types/{testlib.f.mjs → testlib.f.ts} +2 -3
- package/commonjs/build/module.f.ts +100 -0
- package/commonjs/build/{test.f.mjs → test.f.ts} +21 -17
- package/commonjs/module/function/module.f.ts +13 -0
- package/commonjs/module/module.f.ts +41 -0
- package/commonjs/module.f.ts +7 -0
- package/commonjs/{module.mjs → module.ts} +12 -9
- package/commonjs/package/dependencies/module.f.ts +22 -0
- package/commonjs/package/dependencies/{test.f.mjs → test.f.ts} +1 -1
- package/commonjs/package/module.f.ts +31 -0
- package/commonjs/package/{test.f.mjs → test.f.ts} +1 -1
- package/commonjs/path/{module.f.mjs → module.f.ts} +72 -67
- package/commonjs/path/{test.f.mjs → test.f.ts} +25 -19
- package/commonjs/{test.mjs → test.ts} +5 -4
- package/crypto/prime_field/{module.f.mjs → module.f.ts} +40 -37
- package/crypto/prime_field/{test.f.mjs → test.f.ts} +7 -5
- package/crypto/secp/{module.f.mjs → module.f.ts} +44 -44
- package/crypto/secp/{test.f.mjs → test.f.ts} +16 -11
- package/crypto/sha2/{module.f.mjs → module.f.ts} +61 -46
- package/crypto/sha2/{test.f.mjs → test.f.ts} +12 -9
- package/deno.json +71 -0
- package/dev/README.md +8 -0
- package/dev/index.ts +3 -0
- package/dev/{module.f.mjs → module.f.ts} +0 -2
- package/dev/{module.mjs → module.ts} +65 -60
- package/dev/test/{module.f.mjs → module.f.ts} +57 -70
- package/dev/{test.f.mjs → test.f.ts} +7 -5
- package/dev/test.ts +53 -0
- package/djs/{module.f.mjs → module.f.ts} +31 -31
- package/djs/parser/{module.f.mjs → module.f.ts} +190 -182
- package/djs/parser/{test.f.mjs → test.f.ts} +173 -150
- package/djs/serializer/module.f.ts +90 -0
- package/djs/{test.f.mjs → test.f.ts} +4 -4
- package/djs/tokenizer/{module.f.mjs → module.f.ts} +35 -42
- package/djs/tokenizer/{test.f.mjs → test.f.ts} +9 -8
- package/fsc/{module.f.mjs → module.f.ts} +41 -44
- package/fsc/{test.f.mjs → test.f.ts} +8 -6
- package/fsm/module.f.ts +107 -0
- package/fsm/{test.f.mjs → test.f.ts} +10 -9
- package/html/module.f.ts +108 -0
- package/html/{test.f.mjs → test.f.ts} +10 -7
- package/issues/lang/3110-function.md +25 -1
- package/issues/{test.f.mjs → test.f.ts} +3 -2
- package/js/tokenizer/module.f.ts +882 -0
- package/js/tokenizer/{test.f.mjs → test.f.ts} +11 -10
- package/json/module.f.ts +94 -0
- package/json/parser/{module.f.mjs → module.f.ts} +113 -109
- package/json/parser/{test.f.mjs → test.f.ts} +10 -9
- package/json/serializer/module.f.ts +70 -0
- package/json/serializer/{test.f.mjs → test.f.ts} +3 -3
- package/json/{test.f.mjs → test.f.ts} +3 -3
- package/json/tokenizer/{module.f.mjs → module.f.ts} +29 -36
- package/json/tokenizer/{test.f.mjs → test.f.ts} +9 -8
- package/nanvm-lib/src/extension.rs +15 -4
- package/nanvm-lib/src/interface.rs +7 -10
- package/nanvm-lib/src/lib.rs +3 -3
- package/nanvm-lib/src/naive.rs +10 -3
- package/nanvm-lib/src/nanenum.rs +5 -1
- package/nanvm-lib/tests/{test.f.mjs → test.f.ts} +7 -6
- package/nodejs/version/{main.mjs → main.ts} +1 -1
- package/nodejs/version/module.f.ts +42 -0
- package/nodejs/version/{test.f.mjs → test.f.ts} +11 -12
- package/package.json +9 -9
- package/text/ascii/{module.f.mjs → module.f.ts} +10 -8
- package/text/ascii/{test.f.mjs → test.f.ts} +4 -4
- package/text/module.f.ts +30 -0
- package/text/sgr/{module.f.mjs → module.f.ts} +3 -5
- package/text/{test.f.mjs → test.f.ts} +5 -4
- package/text/utf16/module.f.ts +108 -0
- package/text/utf16/{test.f.mjs → test.f.ts} +7 -6
- package/text/utf8/{module.f.mjs → module.f.ts} +29 -23
- package/text/utf8/{test.f.mjs → test.f.ts} +4 -4
- package/tsconfig.json +4 -1
- package/types/array/module.f.ts +89 -0
- package/types/array/{test.f.mjs → test.f.ts} +3 -3
- package/types/bigfloat/{module.f.mjs → module.f.ts} +25 -20
- package/types/bigfloat/{test.f.mjs → test.f.ts} +1 -1
- package/types/bigint/{module.f.mjs → module.f.ts} +29 -28
- package/types/bigint/{test.f.mjs → test.f.ts} +2 -2
- package/types/bit_vec/{module.f.mjs → module.f.ts} +16 -37
- package/types/bit_vec/{test.f.mjs → test.f.ts} +1 -1
- package/types/btree/find/module.f.ts +92 -0
- package/types/btree/find/{test.f.mjs → test.f.ts} +20 -16
- package/types/btree/{module.f.mjs → module.f.ts} +9 -9
- package/types/btree/remove/{module.f.mjs → module.f.ts} +43 -53
- package/types/btree/remove/{test.f.mjs → test.f.ts} +19 -15
- package/types/btree/set/{module.f.mjs → module.f.ts} +17 -20
- package/types/btree/set/{test.f.mjs → test.f.ts} +96 -66
- package/types/btree/{test.f.mjs → test.f.ts} +34 -26
- package/types/btree/types/module.f.ts +27 -0
- package/types/byte_set/module.f.ts +70 -0
- package/types/byte_set/{test.f.mjs → test.f.ts} +8 -7
- package/types/function/compare/module.f.ts +26 -0
- package/types/function/compare/{test.f.mjs → test.f.ts} +1 -1
- package/types/function/module.f.ts +43 -0
- package/types/function/operator/module.f.ts +63 -0
- package/types/function/test.f.ts +20 -0
- package/types/list/module.f.ts +345 -0
- package/types/list/{test.f.mjs → test.f.ts} +30 -24
- package/types/map/module.f.ts +65 -0
- package/types/map/{test.f.mjs → test.f.ts} +6 -5
- package/types/nibble_set/module.f.ts +34 -0
- package/types/nibble_set/{test.f.mjs → test.f.ts} +3 -3
- package/types/nullable/module.f.ts +9 -0
- package/types/nullable/{test.f.mjs → test.f.ts} +2 -2
- package/types/number/module.f.ts +16 -0
- package/types/number/{test.f.mjs → test.f.ts} +7 -5
- package/types/object/module.f.ts +30 -0
- package/types/object/{test.f.mjs → test.f.ts} +2 -2
- package/types/range/module.f.ts +10 -0
- package/types/range/{test.f.mjs → test.f.ts} +1 -1
- package/types/range_map/module.f.ts +70 -0
- package/types/range_map/{test.f.mjs → test.f.ts} +82 -57
- package/types/result/module.f.ts +20 -0
- package/types/result/{module.mjs → module.ts} +4 -3
- package/types/sorted_list/module.f.ts +83 -0
- package/types/sorted_list/{test.f.mjs → test.f.ts} +14 -12
- package/types/sorted_set/module.f.ts +36 -0
- package/types/sorted_set/{test.f.mjs → test.f.ts} +14 -12
- package/types/string/module.f.ts +24 -0
- package/types/string/{test.f.mjs → test.f.ts} +2 -2
- package/types/string_set/module.f.ts +37 -0
- package/types/string_set/{test.f.mjs → test.f.ts} +2 -2
- package/com/cpp/testlib.f.mjs +0 -8
- package/com/cs/testlib.f.mjs +0 -8
- package/com/rust/module.f.mjs +0 -272
- package/com/rust/testlib.f.mjs +0 -8
- package/com/types/module.f.mjs +0 -67
- package/commonjs/build/module.f.mjs +0 -100
- package/commonjs/module/function/module.f.mjs +0 -21
- package/commonjs/module/module.f.mjs +0 -53
- package/commonjs/module.f.mjs +0 -11
- package/commonjs/package/dependencies/module.f.mjs +0 -22
- package/commonjs/package/module.f.mjs +0 -36
- package/dev/index.mjs +0 -3
- package/dev/test.mjs +0 -60
- package/fsm/module.f.mjs +0 -99
- package/html/module.f.mjs +0 -102
- package/js/tokenizer/module.f.mjs +0 -872
- package/json/module.f.mjs +0 -89
- package/json/serializer/module.f.mjs +0 -87
- package/jsr.json +0 -66
- package/nodejs/version/module.f.mjs +0 -47
- package/out/com/cpp/module.f.d.mts +0 -7
- package/out/com/cpp/module.f.mjs +0 -130
- package/out/com/cpp/test.f.d.mts +0 -2
- package/out/com/cpp/test.f.mjs +0 -40
- package/out/com/cpp/testlib.f.d.mts +0 -2
- package/out/com/cpp/testlib.f.mjs +0 -7
- package/out/com/cs/module.f.d.mts +0 -7
- package/out/com/cs/module.f.mjs +0 -104
- package/out/com/cs/test.f.d.mts +0 -2
- package/out/com/cs/test.f.mjs +0 -43
- package/out/com/cs/testlib.f.d.mts +0 -2
- package/out/com/cs/testlib.f.mjs +0 -7
- package/out/com/rust/module.f.d.mts +0 -23
- package/out/com/rust/module.f.mjs +0 -224
- package/out/com/rust/test.f.d.mts +0 -2
- package/out/com/rust/test.f.mjs +0 -123
- package/out/com/rust/testlib.f.d.mts +0 -2
- package/out/com/rust/testlib.f.mjs +0 -7
- package/out/com/test/build.d.mts +0 -1
- package/out/com/test/build.f.d.mts +0 -26
- package/out/com/test/build.f.mjs +0 -98
- package/out/com/test/build.mjs +0 -40
- package/out/com/types/module.f.d.mts +0 -23
- package/out/com/types/module.f.mjs +0 -51
- package/out/com/types/testlib.f.d.mts +0 -44
- package/out/com/types/testlib.f.mjs +0 -30
- package/out/commonjs/build/module.f.d.mts +0 -20
- package/out/commonjs/build/module.f.mjs +0 -107
- package/out/commonjs/build/test.f.d.mts +0 -3
- package/out/commonjs/build/test.f.mjs +0 -102
- package/out/commonjs/module/function/module.f.d.mts +0 -5
- package/out/commonjs/module/function/module.f.mjs +0 -15
- package/out/commonjs/module/module.f.d.mts +0 -52
- package/out/commonjs/module/module.f.mjs +0 -48
- package/out/commonjs/module.d.mts +0 -3
- package/out/commonjs/module.f.d.mts +0 -2
- package/out/commonjs/module.f.mjs +0 -10
- package/out/commonjs/module.mjs +0 -26
- package/out/commonjs/package/dependencies/module.f.d.mts +0 -6
- package/out/commonjs/package/dependencies/module.f.mjs +0 -21
- package/out/commonjs/package/dependencies/test.f.d.mts +0 -2
- package/out/commonjs/package/dependencies/test.f.mjs +0 -15
- package/out/commonjs/package/module.f.d.mts +0 -21
- package/out/commonjs/package/module.f.mjs +0 -40
- package/out/commonjs/package/test.f.d.mts +0 -2
- package/out/commonjs/package/test.f.mjs +0 -27
- package/out/commonjs/path/module.f.d.mts +0 -60
- package/out/commonjs/path/module.f.mjs +0 -171
- package/out/commonjs/path/test.f.d.mts +0 -25
- package/out/commonjs/path/test.f.mjs +0 -231
- package/out/commonjs/test.d.mts +0 -8
- package/out/commonjs/test.mjs +0 -87
- package/out/crypto/prime_field/module.f.d.mts +0 -67
- package/out/crypto/prime_field/module.f.mjs +0 -110
- package/out/crypto/prime_field/test.f.d.mts +0 -13
- package/out/crypto/prime_field/test.f.mjs +0 -152
- package/out/crypto/secp/module.f.d.mts +0 -110
- package/out/crypto/secp/module.f.mjs +0 -173
- package/out/crypto/secp/test.f.d.mts +0 -5
- package/out/crypto/secp/test.f.mjs +0 -78
- package/out/crypto/sha2/module.f.d.mts +0 -15
- package/out/crypto/sha2/module.f.mjs +0 -172
- package/out/crypto/sha2/test.f.d.mts +0 -10
- package/out/crypto/sha2/test.f.mjs +0 -86
- package/out/dev/index.d.mts +0 -1
- package/out/dev/index.mjs +0 -2
- package/out/dev/module.d.mts +0 -26
- package/out/dev/module.f.d.mts +0 -1
- package/out/dev/module.f.mjs +0 -2
- package/out/dev/module.mjs +0 -167
- package/out/dev/test/module.f.d.mts +0 -25
- package/out/dev/test/module.f.mjs +0 -134
- package/out/dev/test.d.mts +0 -3
- package/out/dev/test.f.d.mts +0 -9
- package/out/dev/test.f.mjs +0 -58
- package/out/dev/test.mjs +0 -52
- package/out/djs/module.f.d.mts +0 -20
- package/out/djs/module.f.mjs +0 -79
- package/out/djs/parser/module.f.d.mts +0 -56
- package/out/djs/parser/module.f.mjs +0 -448
- package/out/djs/parser/test.f.d.mts +0 -13
- package/out/djs/parser/test.f.mjs +0 -569
- package/out/djs/test.f.d.mts +0 -12
- package/out/djs/test.f.mjs +0 -84
- package/out/djs/tokenizer/module.f.d.mts +0 -13
- package/out/djs/tokenizer/module.f.mjs +0 -91
- package/out/djs/tokenizer/test.f.d.mts +0 -7
- package/out/djs/tokenizer/test.f.mjs +0 -530
- package/out/fsc/module.f.d.mts +0 -7
- package/out/fsc/module.f.mjs +0 -105
- package/out/fsc/test.f.d.mts +0 -4
- package/out/fsc/test.f.mjs +0 -19
- package/out/fsm/module.f.d.mts +0 -14
- package/out/fsm/module.f.mjs +0 -80
- package/out/fsm/test.f.d.mts +0 -5
- package/out/fsm/test.f.mjs +0 -138
- package/out/html/module.f.d.mts +0 -17
- package/out/html/module.f.mjs +0 -80
- package/out/html/test.f.d.mts +0 -10
- package/out/html/test.f.mjs +0 -45
- package/out/issues/test.f.d.mts +0 -16
- package/out/issues/test.f.mjs +0 -66
- package/out/js/tokenizer/module.f.d.mts +0 -163
- package/out/js/tokenizer/module.f.mjs +0 -729
- package/out/js/tokenizer/test.f.d.mts +0 -9
- package/out/js/tokenizer/test.f.mjs +0 -906
- package/out/json/module.f.d.mts +0 -33
- package/out/json/module.f.mjs +0 -89
- package/out/json/parser/module.f.d.mts +0 -32
- package/out/json/parser/module.f.mjs +0 -224
- package/out/json/parser/test.f.d.mts +0 -5
- package/out/json/parser/test.f.mjs +0 -329
- package/out/json/serializer/module.f.d.mts +0 -36
- package/out/json/serializer/module.f.mjs +0 -67
- package/out/json/serializer/test.f.d.mts +0 -8
- package/out/json/serializer/test.f.mjs +0 -87
- package/out/json/test.f.d.mts +0 -8
- package/out/json/test.f.mjs +0 -61
- package/out/json/tokenizer/module.f.d.mts +0 -13
- package/out/json/tokenizer/module.f.mjs +0 -78
- package/out/json/tokenizer/test.f.d.mts +0 -6
- package/out/json/tokenizer/test.f.mjs +0 -420
- package/out/nanvm-lib/tests/test.f.d.mts +0 -36
- package/out/nanvm-lib/tests/test.f.mjs +0 -87
- package/out/nodejs/version/main.d.mts +0 -1
- package/out/nodejs/version/main.mjs +0 -3
- package/out/nodejs/version/module.f.d.mts +0 -12
- package/out/nodejs/version/module.f.mjs +0 -34
- package/out/nodejs/version/test.f.d.mts +0 -2
- package/out/nodejs/version/test.f.mjs +0 -97
- package/out/text/ascii/module.f.d.mts +0 -70
- package/out/text/ascii/module.f.mjs +0 -154
- package/out/text/ascii/test.f.d.mts +0 -4
- package/out/text/ascii/test.f.mjs +0 -14
- package/out/text/module.f.d.mts +0 -13
- package/out/text/module.f.mjs +0 -19
- package/out/text/sgr/module.f.d.mts +0 -12
- package/out/text/sgr/module.f.mjs +0 -17
- package/out/text/test.f.d.mts +0 -2
- package/out/text/test.f.mjs +0 -19
- package/out/text/utf16/module.f.d.mts +0 -12
- package/out/text/utf16/module.f.mjs +0 -86
- package/out/text/utf16/test.f.d.mts +0 -6
- package/out/text/utf16/test.f.mjs +0 -145
- package/out/text/utf8/module.f.d.mts +0 -10
- package/out/text/utf8/module.f.mjs +0 -126
- package/out/text/utf8/test.f.d.mts +0 -6
- package/out/text/utf8/test.f.mjs +0 -175
- package/out/types/array/module.f.d.mts +0 -31
- package/out/types/array/module.f.mjs +0 -95
- package/out/types/array/test.f.d.mts +0 -10
- package/out/types/array/test.f.mjs +0 -116
- package/out/types/bigfloat/module.f.d.mts +0 -6
- package/out/types/bigfloat/module.f.mjs +0 -77
- package/out/types/bigfloat/test.f.d.mts +0 -6
- package/out/types/bigfloat/test.f.mjs +0 -349
- package/out/types/bigint/module.f.d.mts +0 -29
- package/out/types/bigint/module.f.mjs +0 -114
- package/out/types/bigint/test.f.d.mts +0 -16
- package/out/types/bigint/test.f.mjs +0 -199
- package/out/types/bit_vec/module.f.d.mts +0 -158
- package/out/types/bit_vec/module.f.mjs +0 -194
- package/out/types/bit_vec/test.f.d.mts +0 -23
- package/out/types/bit_vec/test.f.mjs +0 -210
- package/out/types/btree/find/module.f.d.mts +0 -36
- package/out/types/btree/find/module.f.mjs +0 -137
- package/out/types/btree/find/test.f.d.mts +0 -2
- package/out/types/btree/find/test.f.mjs +0 -156
- package/out/types/btree/module.f.d.mts +0 -5
- package/out/types/btree/module.f.mjs +0 -34
- package/out/types/btree/remove/module.f.d.mts +0 -14
- package/out/types/btree/remove/module.f.mjs +0 -209
- package/out/types/btree/remove/test.f.d.mts +0 -7
- package/out/types/btree/remove/test.f.mjs +0 -638
- package/out/types/btree/set/module.f.d.mts +0 -5
- package/out/types/btree/set/module.f.mjs +0 -114
- package/out/types/btree/set/test.f.d.mts +0 -2
- package/out/types/btree/set/test.f.mjs +0 -390
- package/out/types/btree/test.f.d.mts +0 -13
- package/out/types/btree/test.f.mjs +0 -83
- package/out/types/btree/types/module.f.d.mts +0 -14
- package/out/types/btree/types/module.f.mjs +0 -50
- package/out/types/byte_set/module.f.d.mts +0 -25
- package/out/types/byte_set/module.f.mjs +0 -42
- package/out/types/byte_set/test.f.d.mts +0 -13
- package/out/types/byte_set/test.f.mjs +0 -123
- package/out/types/function/compare/module.f.d.mts +0 -23
- package/out/types/function/compare/module.f.mjs +0 -22
- package/out/types/function/compare/test.f.d.mts +0 -2
- package/out/types/function/compare/test.f.mjs +0 -8
- package/out/types/function/module.f.d.mts +0 -51
- package/out/types/function/module.f.mjs +0 -44
- package/out/types/function/operator/module.f.d.mts +0 -60
- package/out/types/function/operator/module.f.mjs +0 -60
- package/out/types/function/test.f.d.mts +0 -2
- package/out/types/function/test.f.mjs +0 -15
- package/out/types/list/module.f.d.mts +0 -82
- package/out/types/list/module.f.mjs +0 -269
- package/out/types/list/test.f.d.mts +0 -38
- package/out/types/list/test.f.mjs +0 -401
- package/out/types/map/module.f.d.mts +0 -21
- package/out/types/map/module.f.mjs +0 -54
- package/out/types/map/test.f.d.mts +0 -5
- package/out/types/map/test.f.mjs +0 -115
- package/out/types/nibble_set/module.f.d.mts +0 -16
- package/out/types/nibble_set/module.f.mjs +0 -19
- package/out/types/nibble_set/test.f.d.mts +0 -13
- package/out/types/nibble_set/test.f.mjs +0 -90
- package/out/types/nullable/module.f.d.mts +0 -9
- package/out/types/nullable/module.f.mjs +0 -9
- package/out/types/nullable/test.f.d.mts +0 -2
- package/out/types/nullable/test.f.mjs +0 -12
- package/out/types/number/module.f.d.mts +0 -7
- package/out/types/number/module.f.mjs +0 -12
- package/out/types/number/test.f.d.mts +0 -11
- package/out/types/number/test.f.mjs +0 -126
- package/out/types/object/module.f.d.mts +0 -22
- package/out/types/object/module.f.mjs +0 -27
- package/out/types/object/test.f.d.mts +0 -5
- package/out/types/object/test.f.mjs +0 -17
- package/out/types/range/module.f.d.mts +0 -6
- package/out/types/range/module.f.mjs +0 -6
- package/out/types/range/test.f.d.mts +0 -2
- package/out/types/range/test.f.mjs +0 -18
- package/out/types/range_map/module.f.d.mts +0 -19
- package/out/types/range_map/module.f.mjs +0 -84
- package/out/types/range_map/test.f.d.mts +0 -6
- package/out/types/range_map/test.f.mjs +0 -201
- package/out/types/result/module.d.mts +0 -7
- package/out/types/result/module.f.d.mts +0 -22
- package/out/types/result/module.f.mjs +0 -25
- package/out/types/result/module.mjs +0 -16
- package/out/types/sorted_list/module.f.d.mts +0 -53
- package/out/types/sorted_list/module.f.mjs +0 -102
- package/out/types/sorted_list/test.f.d.mts +0 -5
- package/out/types/sorted_list/test.f.mjs +0 -66
- package/out/types/sorted_set/module.f.d.mts +0 -19
- package/out/types/sorted_set/module.f.mjs +0 -29
- package/out/types/sorted_set/test.f.d.mts +0 -6
- package/out/types/sorted_set/test.f.mjs +0 -80
- package/out/types/string/module.f.d.mts +0 -9
- package/out/types/string/module.f.mjs +0 -17
- package/out/types/string/test.f.d.mts +0 -15
- package/out/types/string/test.f.mjs +0 -58
- package/out/types/string_set/module.f.d.mts +0 -13
- package/out/types/string_set/module.f.mjs +0 -29
- package/out/types/string_set/test.f.d.mts +0 -5
- package/out/types/string_set/test.f.mjs +0 -65
- package/text/module.f.mjs +0 -27
- package/text/utf16/module.f.mjs +0 -96
- package/types/array/module.f.mjs +0 -119
- package/types/btree/find/module.f.mjs +0 -125
- package/types/btree/types/module.f.mjs +0 -64
- package/types/byte_set/module.f.mjs +0 -61
- package/types/function/compare/module.f.mjs +0 -29
- package/types/function/module.f.mjs +0 -50
- package/types/function/operator/module.f.mjs +0 -78
- package/types/function/test.f.mjs +0 -17
- package/types/list/module.f.mjs +0 -320
- package/types/map/module.f.mjs +0 -67
- package/types/nibble_set/module.f.mjs +0 -28
- package/types/nullable/module.f.mjs +0 -11
- package/types/number/module.f.mjs +0 -16
- package/types/object/module.f.mjs +0 -33
- package/types/range/module.f.mjs +0 -8
- package/types/range_map/module.f.mjs +0 -84
- package/types/result/module.f.mjs +0 -28
- package/types/sorted_list/module.f.mjs +0 -107
- package/types/sorted_set/module.f.mjs +0 -38
- package/types/string/module.f.mjs +0 -22
- package/types/string_set/module.f.mjs +0 -36
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import * as array from '../../types/array/module.f.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {{
|
|
5
|
-
* readonly f: (i: number) => number
|
|
6
|
-
* readonly length: number
|
|
7
|
-
* }} HashInput
|
|
8
|
-
*/
|
|
9
|
-
/** @typedef {array.Array8<number>} Hash8 */
|
|
10
|
-
/** @typedef {array.Array16<number>} Array16 */
|
|
11
|
-
/** @type {(input: number) => (pos: number) => number} */
|
|
12
|
-
const appendOneWithZeros = input => pos => (input >> pos << pos) | (1 << pos);
|
|
13
|
-
/** @type {(input: number) => (pos: number) => number} */
|
|
14
|
-
const mod = a => b => (a % b + b) % b;
|
|
15
|
-
/** @type {(input: readonly number[]) => (bits: number) => HashInput} */
|
|
16
|
-
export const padding = input => bitsCount => {
|
|
17
|
-
const appendBlockIndex = (bitsCount / 32) | 0;
|
|
18
|
-
const length = (bitsCount + mod(447 - bitsCount)(512) + 65) / 32;
|
|
19
|
-
/** @type {(i: number) => number} */
|
|
20
|
-
const f = i => {
|
|
21
|
-
if (i < appendBlockIndex) {
|
|
22
|
-
return input[i];
|
|
23
|
-
}
|
|
24
|
-
if (i === appendBlockIndex) {
|
|
25
|
-
return appendBlockIndex >= input.length ? 0x8000_0000 : appendOneWithZeros(input[appendBlockIndex])(31 - bitsCount % 32);
|
|
26
|
-
}
|
|
27
|
-
if (i === length - 2) {
|
|
28
|
-
return (bitsCount / 0x1_0000_0000) | 0;
|
|
29
|
-
}
|
|
30
|
-
if (i === length - 1) {
|
|
31
|
-
return bitsCount % 0x1_0000_0000;
|
|
32
|
-
}
|
|
33
|
-
return 0;
|
|
34
|
-
};
|
|
35
|
-
return ({ f, length });
|
|
36
|
-
};
|
|
37
|
-
/** @type {(d: number) => (n: number) => number} */
|
|
38
|
-
const rotr = d => {
|
|
39
|
-
const r = 32 - d;
|
|
40
|
-
return n => n >>> d | n << r;
|
|
41
|
-
};
|
|
42
|
-
/** @type {(x: number) => (y: number) => (z: number) => number} */
|
|
43
|
-
const ch = x => y => z => x & y ^ ~x & z;
|
|
44
|
-
/** @type {(x: number) => (y: number) => (z: number) => number} */
|
|
45
|
-
const maj = x => y => z => x & y ^ x & z ^ y & z;
|
|
46
|
-
/** @type {(d: number) => (n: number) => number} */
|
|
47
|
-
const shr = d => n => n >>> d;
|
|
48
|
-
/** @type {(a: number) => (b: number) => (c: number) => (x: number) => number} */
|
|
49
|
-
const bigSigma = a => b => c => {
|
|
50
|
-
const ra = rotr(a);
|
|
51
|
-
const rb = rotr(b);
|
|
52
|
-
const rc = rotr(c);
|
|
53
|
-
return x => ra(x) ^ rb(x) ^ rc(x);
|
|
54
|
-
};
|
|
55
|
-
const bigSigma0 = bigSigma(2)(13)(22);
|
|
56
|
-
const bigSigma1 = bigSigma(6)(11)(25);
|
|
57
|
-
/** @type {(a: number) => (b: number) => (c: number) => (x: number) => number} */
|
|
58
|
-
const smallSigma = a => b => c => {
|
|
59
|
-
const ra = rotr(a);
|
|
60
|
-
const rb = rotr(b);
|
|
61
|
-
const sc = shr(c);
|
|
62
|
-
return x => ra(x) ^ rb(x) ^ sc(x);
|
|
63
|
-
};
|
|
64
|
-
const smallSigma0 = smallSigma(7)(18)(3);
|
|
65
|
-
const smallSigma1 = smallSigma(17)(19)(10);
|
|
66
|
-
/** @type {(a: array.Array4<number>) => number} */
|
|
67
|
-
const wi = ([a0, a1, a2, a3]) => (smallSigma1(a0) + a1 + smallSigma0(a2) + a3) | 0;
|
|
68
|
-
/** @type {(w: Array16) => Array16} */
|
|
69
|
-
const nextW = ([w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF]) => {
|
|
70
|
-
w0 = wi([wE, w9, w1, w0]);
|
|
71
|
-
w1 = wi([wF, wA, w2, w1]);
|
|
72
|
-
w2 = wi([w0, wB, w3, w2]);
|
|
73
|
-
w3 = wi([w1, wC, w4, w3]);
|
|
74
|
-
w4 = wi([w2, wD, w5, w4]);
|
|
75
|
-
w5 = wi([w3, wE, w6, w5]);
|
|
76
|
-
w6 = wi([w4, wF, w7, w6]);
|
|
77
|
-
w7 = wi([w5, w0, w8, w7]);
|
|
78
|
-
w8 = wi([w6, w1, w9, w8]);
|
|
79
|
-
w9 = wi([w7, w2, wA, w9]);
|
|
80
|
-
wA = wi([w8, w3, wB, wA]);
|
|
81
|
-
wB = wi([w9, w4, wC, wB]);
|
|
82
|
-
wC = wi([wA, w5, wD, wC]);
|
|
83
|
-
wD = wi([wB, w6, wE, wD]);
|
|
84
|
-
wE = wi([wC, w7, wF, wE]);
|
|
85
|
-
wF = wi([wD, w8, w0, wF]);
|
|
86
|
-
return [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF];
|
|
87
|
-
};
|
|
88
|
-
const k = [
|
|
89
|
-
[
|
|
90
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
91
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
92
|
-
],
|
|
93
|
-
[
|
|
94
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
95
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
96
|
-
],
|
|
97
|
-
[
|
|
98
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
99
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
100
|
-
],
|
|
101
|
-
[
|
|
102
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
103
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
104
|
-
],
|
|
105
|
-
];
|
|
106
|
-
/** @type {(init: Hash8) => (data: Array16) => Hash8} */
|
|
107
|
-
const compress = ([a0, b0, c0, d0, e0, f0, g0, h0]) => data => {
|
|
108
|
-
let w = data;
|
|
109
|
-
let a = a0;
|
|
110
|
-
let b = b0;
|
|
111
|
-
let c = c0;
|
|
112
|
-
let d = d0;
|
|
113
|
-
let e = e0;
|
|
114
|
-
let f = f0;
|
|
115
|
-
let g = g0;
|
|
116
|
-
let h = h0;
|
|
117
|
-
let i = 0;
|
|
118
|
-
while (true) {
|
|
119
|
-
const ki = k[i];
|
|
120
|
-
for (let j = 0; j < 16; ++j) {
|
|
121
|
-
const t1 = h + bigSigma1(e) + ch(e)(f)(g) + ki[j] + w[j];
|
|
122
|
-
const t2 = bigSigma0(a) + maj(a)(b)(c);
|
|
123
|
-
h = g;
|
|
124
|
-
g = f;
|
|
125
|
-
f = e;
|
|
126
|
-
e = (d + t1) | 0;
|
|
127
|
-
d = c;
|
|
128
|
-
c = b;
|
|
129
|
-
b = a;
|
|
130
|
-
a = (t1 + t2) | 0;
|
|
131
|
-
}
|
|
132
|
-
if (i === 3) {
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
++i;
|
|
136
|
-
w = nextW(w);
|
|
137
|
-
}
|
|
138
|
-
return [
|
|
139
|
-
(a0 + a) | 0,
|
|
140
|
-
(b0 + b) | 0,
|
|
141
|
-
(c0 + c) | 0,
|
|
142
|
-
(d0 + d) | 0,
|
|
143
|
-
(e0 + e) | 0,
|
|
144
|
-
(f0 + f) | 0,
|
|
145
|
-
(g0 + g) | 0,
|
|
146
|
-
(h0 + h) | 0,
|
|
147
|
-
];
|
|
148
|
-
};
|
|
149
|
-
/** @type {(init: Hash8) => (input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
150
|
-
const compute = init => input => bitsCount => {
|
|
151
|
-
const { f, length } = padding(input)(bitsCount);
|
|
152
|
-
let result = init;
|
|
153
|
-
const chunkCount = length / 16;
|
|
154
|
-
for (let i = 0; i < chunkCount; i++) {
|
|
155
|
-
const s = i * 16;
|
|
156
|
-
result = compress(result)([
|
|
157
|
-
f(s + 0), f(s + 1), f(s + 2), f(s + 3), f(s + 4), f(s + 5), f(s + 6), f(s + 7),
|
|
158
|
-
f(s + 8), f(s + 9), f(s + 10), f(s + 11), f(s + 12), f(s + 13), f(s + 14), f(s + 15)
|
|
159
|
-
]);
|
|
160
|
-
}
|
|
161
|
-
return result;
|
|
162
|
-
};
|
|
163
|
-
/** @type {Hash8} */
|
|
164
|
-
const init256 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
|
|
165
|
-
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
166
|
-
export const computeSha256 = compute(init256);
|
|
167
|
-
/** @type {Hash8} */
|
|
168
|
-
const init224 = [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4];
|
|
169
|
-
/** @type {(input: readonly number[]) => (bitsCount: number) => Hash8} */
|
|
170
|
-
export const computeSha224 = compute(init224);
|
|
171
|
-
export const compress256 = compress(init256);
|
|
172
|
-
export const compress224 = compress(init224);
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import * as _ from './module.f.mjs';
|
|
2
|
-
import * as json from '../../json/module.f.mjs';
|
|
3
|
-
import * as o from '../../types/object/module.f.mjs';
|
|
4
|
-
const { sort } = o;
|
|
5
|
-
/** @type {(a: number) => number} */
|
|
6
|
-
const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000;
|
|
7
|
-
/** @type {(a: number) => string} */
|
|
8
|
-
const toHexString = x => toU32(x).toString(16).padStart(8, '0');
|
|
9
|
-
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
10
|
-
const stringify = a => json.stringify(sort)(a);
|
|
11
|
-
// {
|
|
12
|
-
// const result = _.padding([])(0)
|
|
13
|
-
// console.log(result.map(toHexString))
|
|
14
|
-
// }
|
|
15
|
-
// {
|
|
16
|
-
// const result = _.padding([0x61626364, 0x65000000])(40)
|
|
17
|
-
// console.log(result.map(toHexString))
|
|
18
|
-
// }
|
|
19
|
-
// {
|
|
20
|
-
// const result = _.padding([0x11111110])(31)
|
|
21
|
-
// console.log(result.map(toHexString))
|
|
22
|
-
// }
|
|
23
|
-
// {
|
|
24
|
-
// const result = _.padding([0x11111110])(32)
|
|
25
|
-
// console.log(result.map(toHexString))
|
|
26
|
-
// }
|
|
27
|
-
export default {
|
|
28
|
-
empty: {
|
|
29
|
-
sha256: () => {
|
|
30
|
-
const hash = _.computeSha256([])(0);
|
|
31
|
-
const result = stringify(hash.map(toHexString));
|
|
32
|
-
if (result !== '["e3b0c442","98fc1c14","9afbf4c8","996fb924","27ae41e4","649b934c","a495991b","7852b855"]') {
|
|
33
|
-
throw result;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
sha224: () => {
|
|
37
|
-
const hash = _.computeSha224([])(0);
|
|
38
|
-
const result = stringify(hash.map(toHexString));
|
|
39
|
-
if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') {
|
|
40
|
-
throw result;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
sha224compress: [
|
|
45
|
-
() => {
|
|
46
|
-
const hash = _.compress224([0x8000_0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
47
|
-
const result = stringify(hash.map(toHexString));
|
|
48
|
-
if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') {
|
|
49
|
-
throw result;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
sha256: [
|
|
54
|
-
() => {
|
|
55
|
-
//[0x68656C6C, 0x6F20776F, 0x726C6400] represents phrase 'hello world'
|
|
56
|
-
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C6400])(88);
|
|
57
|
-
const result = stringify(hash.map(toHexString));
|
|
58
|
-
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') {
|
|
59
|
-
throw result;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
() => {
|
|
63
|
-
//[0x68656C6C, 0x6F20776F, 0x726C6488] represents phrase 'hello world' with 1's at the end
|
|
64
|
-
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C64FF])(88);
|
|
65
|
-
const result = stringify(hash.map(toHexString));
|
|
66
|
-
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') {
|
|
67
|
-
throw result;
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
() => {
|
|
71
|
-
const input = Array(8).fill(0x31313131);
|
|
72
|
-
const result = _.computeSha256(input)(256);
|
|
73
|
-
if (toU32(result[0]) !== 0x8a83665f) {
|
|
74
|
-
throw result[0];
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
() => {
|
|
78
|
-
const input = Array(16).fill(0x31313131);
|
|
79
|
-
const hash = _.computeSha256(input)(512);
|
|
80
|
-
const result = stringify(hash.map(toHexString));
|
|
81
|
-
if (result !== '["3138bb9b","c78df27c","473ecfd1","410f7bd4","5ebac1f5","9cf3ff9c","fe4db77a","ab7aedd3"]') {
|
|
82
|
-
throw result;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
};
|
package/out/dev/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/out/dev/index.mjs
DELETED
package/out/dev/module.d.mts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** @type {(code: number) => never} */
|
|
2
|
-
export const exit: (code: number) => never;
|
|
3
|
-
/** @type {(v: string) => string|undefined} */
|
|
4
|
-
export const env: (v: string) => string | undefined;
|
|
5
|
-
export function loadModuleMap(): Promise<ModuleMap>;
|
|
6
|
-
export function index(): Promise<void>;
|
|
7
|
-
export type Options = {
|
|
8
|
-
readonly withFileTypes: true;
|
|
9
|
-
};
|
|
10
|
-
export type Dirent = {
|
|
11
|
-
readonly name: string;
|
|
12
|
-
readonly isDirectory: () => boolean;
|
|
13
|
-
};
|
|
14
|
-
export type FsPromises = {
|
|
15
|
-
readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>;
|
|
16
|
-
readonly readFile: (path: string, options: "utf8") => Promise<string>;
|
|
17
|
-
};
|
|
18
|
-
export type Module = {
|
|
19
|
-
readonly default?: unknown;
|
|
20
|
-
};
|
|
21
|
-
export type Require = (name: string) => unknown;
|
|
22
|
-
export type UnknownMap = { readonly [k in string]: unknown; };
|
|
23
|
-
export type Entry<T> = readonly [string, T];
|
|
24
|
-
export type MutableModuleMap = { [k in string]: Module; };
|
|
25
|
-
export type ModuleMap = { readonly [k in string]: Module; };
|
|
26
|
-
export type FolderMap = { readonly [k in string]: string | FolderMap; };
|
package/out/dev/module.f.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function todo(): never;
|
package/out/dev/module.f.mjs
DELETED
package/out/dev/module.mjs
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { readdir, writeFile, readFile } from 'node:fs/promises';
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {{
|
|
4
|
-
* readonly withFileTypes: true
|
|
5
|
-
* }} Options
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {{
|
|
9
|
-
* readonly name: string
|
|
10
|
-
* readonly isDirectory: () => boolean
|
|
11
|
-
* }} Dirent
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @typedef {{
|
|
15
|
-
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
16
|
-
* readonly readFile: (path: string, options: 'utf8') => Promise<string>
|
|
17
|
-
* }} FsPromises
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {{
|
|
21
|
-
* readonly default?: unknown
|
|
22
|
-
* }} Module
|
|
23
|
-
*/
|
|
24
|
-
/** @typedef {(name: string) => unknown} Require */
|
|
25
|
-
/**
|
|
26
|
-
* @typedef {{
|
|
27
|
-
* readonly[k in string]: unknown
|
|
28
|
-
* }} UnknownMap
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* @template T
|
|
32
|
-
* @typedef {readonly[string, T]} Entry
|
|
33
|
-
*/
|
|
34
|
-
/** @type {(a: Entry<unknown>, b: Entry<unknown>) => number} */
|
|
35
|
-
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
36
|
-
/**
|
|
37
|
-
* @typedef {{
|
|
38
|
-
* [k in string]: Module
|
|
39
|
-
* }} MutableModuleMap
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* @typedef {{
|
|
43
|
-
* readonly[k in string]: Module
|
|
44
|
-
* }} ModuleMap
|
|
45
|
-
*/
|
|
46
|
-
/** @type {(v: readonly string[]) => (dif: number) => readonly string[]} */
|
|
47
|
-
const remove_tail = v => dif => v.slice(0, v.length - dif);
|
|
48
|
-
/** @type {any} */
|
|
49
|
-
const self = globalThis;
|
|
50
|
-
/** @type {(code: number) => never} */
|
|
51
|
-
export const exit = self.Deno ? self.Deno.exit : process.exit;
|
|
52
|
-
/** @type {(v: string) => string|undefined} */
|
|
53
|
-
export const env = self.Deno ? self.Deno.env.get :
|
|
54
|
-
a => {
|
|
55
|
-
const r = Object.getOwnPropertyDescriptor(process.env, a);
|
|
56
|
-
return r === void 0 ? void 0 :
|
|
57
|
-
typeof r.get === 'function' ? r.get() :
|
|
58
|
-
r.value;
|
|
59
|
-
};
|
|
60
|
-
export const loadModuleMap = async () => {
|
|
61
|
-
/** @type {() => Promise<UnknownMap>} */
|
|
62
|
-
const load = async () => {
|
|
63
|
-
/** @type {(readonly[string, unknown])[]} */
|
|
64
|
-
const map = [];
|
|
65
|
-
/** @type {(path: string) => Promise<void>} */
|
|
66
|
-
const f = async (p) => {
|
|
67
|
-
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
68
|
-
const { name } = i;
|
|
69
|
-
if (!name.startsWith('.')) {
|
|
70
|
-
const file = `${p}/${name}`;
|
|
71
|
-
if (i.isDirectory()) {
|
|
72
|
-
await f(file);
|
|
73
|
-
}
|
|
74
|
-
else if (name.endsWith('.f.mjs') || name.endsWith('.f.js')) {
|
|
75
|
-
const source = await import(`../${file}`);
|
|
76
|
-
map.push([file, source.default]);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
await f('.');
|
|
82
|
-
map.sort(cmp);
|
|
83
|
-
return Object.fromEntries(map);
|
|
84
|
-
};
|
|
85
|
-
const map = await load();
|
|
86
|
-
/** @type {() => ModuleMap} */
|
|
87
|
-
const build = () => {
|
|
88
|
-
/** @type {MutableModuleMap} */
|
|
89
|
-
const d = {};
|
|
90
|
-
/** @type {(base: readonly string[]) => (k: string) => readonly[string, Module]} */
|
|
91
|
-
const getModule = base => k => {
|
|
92
|
-
const relativePath = k.split('/');
|
|
93
|
-
const dif = relativePath.filter(v => v === '..').length;
|
|
94
|
-
const path = [remove_tail(base)(dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
95
|
-
.flat();
|
|
96
|
-
const pathStr = path.join('/');
|
|
97
|
-
{
|
|
98
|
-
const module = d[pathStr];
|
|
99
|
-
if (module !== void 0) {
|
|
100
|
-
return [pathStr, module];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
{
|
|
104
|
-
/** @type {Module} */
|
|
105
|
-
const module = { default: map[pathStr] };
|
|
106
|
-
d[pathStr] = module;
|
|
107
|
-
return [pathStr, module];
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
{
|
|
111
|
-
const get = getModule(['.']);
|
|
112
|
-
for (const k of Object.keys(map)) {
|
|
113
|
-
get(k);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return d;
|
|
117
|
-
};
|
|
118
|
-
return build();
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* @typedef {{
|
|
122
|
-
* readonly[k in string]: string | FolderMap
|
|
123
|
-
* }} FolderMap
|
|
124
|
-
*/
|
|
125
|
-
/** @type {(m: FolderMap) => (s: readonly string[]) => FolderMap } */
|
|
126
|
-
const folderMapAdd = m => s => {
|
|
127
|
-
const [first, ...rest] = s;
|
|
128
|
-
const firstResult = m[first];
|
|
129
|
-
return typeof firstResult === 'string'
|
|
130
|
-
? m
|
|
131
|
-
: {
|
|
132
|
-
...m,
|
|
133
|
-
[first]: rest.length === 1
|
|
134
|
-
? rest[0]
|
|
135
|
-
: folderMapAdd(firstResult === undefined ? {} : firstResult)(rest)
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
const indent = ' ';
|
|
139
|
-
/** @type {(i: string) => (p: string) => (m: FolderMap) => readonly[string,string]} */
|
|
140
|
-
const codeAdd = i => p => m => {
|
|
141
|
-
let result = '';
|
|
142
|
-
let im = '';
|
|
143
|
-
for (const [k, v] of Object.entries(m)) {
|
|
144
|
-
const np = `${p}${k}`;
|
|
145
|
-
if (typeof v === 'string') {
|
|
146
|
-
result += `${i}${k}: ${np},\n`;
|
|
147
|
-
im += `import ${np} from './${np.replaceAll('$', '/')}/${v}'\n`;
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
const [r, x] = codeAdd(i + indent)(`${np}\$`)(v);
|
|
151
|
-
result += `${i}${k}: \{\n`;
|
|
152
|
-
result += r;
|
|
153
|
-
result += `${i}\},\n`;
|
|
154
|
-
im += x;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return [result, im];
|
|
158
|
-
};
|
|
159
|
-
export const index = async () => {
|
|
160
|
-
const jj = './jsr.json';
|
|
161
|
-
const n = '/module.f.mjs';
|
|
162
|
-
const jsr_json = JSON.parse(await readFile(jj, { encoding: 'utf8' }));
|
|
163
|
-
const list = Object.keys(await loadModuleMap()).filter(v => v.endsWith(n));
|
|
164
|
-
const exportsA = list.filter(v => !v.startsWith('./out')).map(v => [v.replace(n, ''), `./out/${v.substring(2)}`]);
|
|
165
|
-
const exports = Object.fromEntries(exportsA);
|
|
166
|
-
await writeFile(jj, JSON.stringify({ ...jsr_json, exports }, null, 2));
|
|
167
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
declare const _default: <T>(input: Input<T>) => readonly [number, T];
|
|
2
|
-
export default _default;
|
|
3
|
-
export type DependencyMap = { readonly [k in string]?: Module; };
|
|
4
|
-
export type Module = {
|
|
5
|
-
readonly default?: unknown;
|
|
6
|
-
};
|
|
7
|
-
export type ModuleMap = { readonly [k in string]: Module; };
|
|
8
|
-
export type Log<T> = (v: string) => (state: T) => T;
|
|
9
|
-
export type Measure<T> = <R>(f: () => R) => (state: T) => readonly [R, number, T];
|
|
10
|
-
export type Input<T> = {
|
|
11
|
-
readonly moduleMap: ModuleMap;
|
|
12
|
-
readonly log: Log<T>;
|
|
13
|
-
readonly error: Log<T>;
|
|
14
|
-
readonly measure: Measure<T>;
|
|
15
|
-
readonly state: T;
|
|
16
|
-
readonly tryCatch: <R>(f: () => R) => Result.Result<R, unknown>;
|
|
17
|
-
readonly env: (n: string) => string | undefined;
|
|
18
|
-
};
|
|
19
|
-
export type TestState = {
|
|
20
|
-
readonly time: number;
|
|
21
|
-
readonly pass: number;
|
|
22
|
-
readonly fail: number;
|
|
23
|
-
};
|
|
24
|
-
export type FullState<T> = readonly [TestState, T];
|
|
25
|
-
import * as Result from '../../types/result/module.f.mjs';
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import * as list from '../../types/list/module.f.mjs';
|
|
3
|
-
const { fold } = list;
|
|
4
|
-
import * as sgr from '../../text/sgr/module.f.mjs';
|
|
5
|
-
const { reset, fgGreen, fgRed, bold } = sgr.codes;
|
|
6
|
-
import * as Result from '../../types/result/module.f.mjs';
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {{
|
|
9
|
-
* readonly[k in string]?: Module
|
|
10
|
-
* }} DependencyMap
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {{
|
|
14
|
-
* readonly default?: unknown
|
|
15
|
-
* }} Module
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* @typedef {{
|
|
19
|
-
* readonly[k in string]: Module
|
|
20
|
-
* }} ModuleMap
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* @template T
|
|
24
|
-
* @typedef {(v: string) => (state: T) => T} Log
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* @template T
|
|
28
|
-
* @typedef {<R>(f: () => R) => (state: T) => readonly[R, number, T]} Measure
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* @template T
|
|
32
|
-
* @typedef {{
|
|
33
|
-
* readonly moduleMap: ModuleMap,
|
|
34
|
-
* readonly log: Log<T>,
|
|
35
|
-
* readonly error: Log<T>,
|
|
36
|
-
* readonly measure: Measure<T>,
|
|
37
|
-
* readonly state: T,
|
|
38
|
-
* readonly tryCatch: <R>(f: () => R) => Result.Result<R, unknown>,
|
|
39
|
-
* readonly env: (n: string) => string|undefined
|
|
40
|
-
* }} Input
|
|
41
|
-
*/
|
|
42
|
-
/** @type {(s: string) => boolean} */
|
|
43
|
-
const isTest = s => s.endsWith('test.f.mjs') || s.endsWith('test.f.js');
|
|
44
|
-
/**
|
|
45
|
-
* @typedef {{
|
|
46
|
-
* readonly time: number,
|
|
47
|
-
* readonly pass: number,
|
|
48
|
-
* readonly fail: number,
|
|
49
|
-
* }} TestState
|
|
50
|
-
*/
|
|
51
|
-
/** @type {(time: number) => (testState: TestState) => TestState} */
|
|
52
|
-
const addPass = delta => ts => ({ ...ts, time: ts.time + delta, pass: ts.pass + 1 });
|
|
53
|
-
/** @type {(time: number) => (testState: TestState) => TestState} */
|
|
54
|
-
const addFail = delta => ts => ({ ...ts, time: ts.time + delta, fail: ts.fail + 1 });
|
|
55
|
-
/**
|
|
56
|
-
* @template T
|
|
57
|
-
* @typedef {readonly[TestState, T]} FullState
|
|
58
|
-
*/
|
|
59
|
-
/** @type {(a: number) => string} */
|
|
60
|
-
const timeFormat = a => {
|
|
61
|
-
const y = Math.round(a * 10_000).toString();
|
|
62
|
-
const yl = 5 - y.length;
|
|
63
|
-
const x = '0'.repeat(yl > 0 ? yl : 0) + y;
|
|
64
|
-
const s = x.length - 4;
|
|
65
|
-
const b = x.substring(0, s);
|
|
66
|
-
const e = x.substring(s);
|
|
67
|
-
return `${b}.${e} ms`;
|
|
68
|
-
};
|
|
69
|
-
/** @type {<T>(input: Input<T>) => readonly[number, T]} */
|
|
70
|
-
export default input => {
|
|
71
|
-
let { moduleMap, log, error, measure, tryCatch, env, state } = input;
|
|
72
|
-
const isGitHub = env('GITHUB_ACTION') !== void 0;
|
|
73
|
-
/** @typedef {input extends Input<infer T> ? T : never} T */
|
|
74
|
-
/** @type {(k: readonly[string, Module]) => (fs: FullState<T>) => FullState<T>} */
|
|
75
|
-
const f = ([k, v]) => {
|
|
76
|
-
/** @type {(i: string) => (v: unknown) => (fs: FullState<T>) => FullState<T>} */
|
|
77
|
-
const test = i => v => ([ts, state]) => {
|
|
78
|
-
const next = test(`${i}| `);
|
|
79
|
-
switch (typeof v) {
|
|
80
|
-
case 'function': {
|
|
81
|
-
if (v.length === 0) {
|
|
82
|
-
const [[s, r], delta, state0] = measure(() => tryCatch(/** @type {() => unknown} */ (v)))(state);
|
|
83
|
-
state = state0;
|
|
84
|
-
if (s === 'error') {
|
|
85
|
-
ts = addFail(delta)(ts);
|
|
86
|
-
if (isGitHub) {
|
|
87
|
-
// https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
|
|
88
|
-
// https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
|
|
89
|
-
state = error(`::error file=${k},line=1,title=[3]['a']()::${r}`)(state);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
state = error(`${i}() ${fgRed}error${reset}, ${timeFormat(delta)}`)(state);
|
|
93
|
-
state = error(`${fgRed}${r}${reset}`)(state);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
ts = addPass(delta)(ts);
|
|
98
|
-
state = log(`${i}() ${fgGreen}ok${reset}, ${timeFormat(delta)}`)(state);
|
|
99
|
-
}
|
|
100
|
-
[ts, state] = next(r)([ts, state]);
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case 'object': {
|
|
105
|
-
if (v !== null) {
|
|
106
|
-
/** @type {(k: readonly[string|number, unknown]) => (fs: FullState<T>) => FullState<T>} */
|
|
107
|
-
const f = ([k, v]) => ([time, state]) => {
|
|
108
|
-
state = log(`${i}${k}:`)(state);
|
|
109
|
-
[time, state] = next(v)([time, state]);
|
|
110
|
-
return [time, state];
|
|
111
|
-
};
|
|
112
|
-
[ts, state] = fold(f)([ts, state])(v instanceof Array ? list.entries(v) : Object.entries(v));
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return [ts, state];
|
|
118
|
-
};
|
|
119
|
-
return ([ts, state]) => {
|
|
120
|
-
if (isTest(k)) {
|
|
121
|
-
state = log(`testing ${k}`)(state);
|
|
122
|
-
[ts, state] = test('| ')(v.default)([ts, state]);
|
|
123
|
-
}
|
|
124
|
-
return [ts, state];
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
/** @type {TestState} */
|
|
128
|
-
let ts = { time: 0, pass: 0, fail: 0 };
|
|
129
|
-
[ts, state] = fold(f)([ts, state])(Object.entries(moduleMap));
|
|
130
|
-
const fgFail = ts.fail === 0 ? fgGreen : fgRed;
|
|
131
|
-
state = log(`${bold}Number of tests: pass: ${fgGreen}${ts.pass}${reset}${bold}, fail: ${fgFail}${ts.fail}${reset}${bold}, total: ${ts.pass + ts.fail}${reset}`)(state);
|
|
132
|
-
state = log(`${bold}Time: ${timeFormat(ts.time)}${reset}`)(state);
|
|
133
|
-
return [ts.fail !== 0 ? 1 : 0, state];
|
|
134
|
-
};
|
package/out/dev/test.d.mts
DELETED
package/out/dev/test.f.d.mts
DELETED