functionalscript 0.3.3 → 0.3.5
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.d.ts +10 -0
- package/com/cpp/module.f.js +107 -0
- package/com/cpp/test.f.d.ts +2 -0
- package/com/cpp/{test.f.ts → test.f.js} +9 -11
- package/com/cpp/testlib.f.d.ts +2 -0
- package/com/cpp/testlib.f.js +5 -0
- package/com/cs/module.f.d.ts +12 -0
- package/com/cs/module.f.js +80 -0
- package/com/cs/test.f.d.ts +2 -0
- package/com/cs/{test.f.ts → test.f.js} +9 -11
- package/com/cs/testlib.f.d.ts +2 -0
- package/com/cs/testlib.f.js +5 -0
- package/com/rust/module.f.d.ts +15 -0
- package/com/rust/module.f.js +169 -0
- package/com/rust/test.f.d.ts +2 -0
- package/com/rust/{test.f.ts → test.f.js} +7 -7
- package/com/rust/testlib.f.d.ts +2 -0
- package/com/rust/testlib.f.js +5 -0
- package/com/test/build.f.d.ts +20 -0
- package/com/test/build.f.js +58 -0
- package/com/types/module.f.d.ts +28 -0
- package/com/types/module.f.js +8 -0
- package/com/types/testlib.f.d.ts +44 -0
- package/com/types/{testlib.f.ts → testlib.f.js} +2 -3
- package/commonjs/build/module.f.d.ts +6 -0
- package/commonjs/build/module.f.js +69 -0
- package/commonjs/build/test.f.d.ts +2 -0
- package/commonjs/build/test.f.js +96 -0
- package/commonjs/module/function/{module.f.ts → module.f.d.ts} +5 -10
- package/commonjs/module/function/module.f.js +4 -0
- package/commonjs/module/module.f.d.ts +18 -0
- package/commonjs/module/module.f.js +12 -0
- package/commonjs/module.f.d.ts +6 -0
- package/commonjs/module.f.js +1 -0
- package/commonjs/package/dependencies/module.f.d.ts +7 -0
- package/commonjs/package/dependencies/module.f.js +13 -0
- package/commonjs/package/dependencies/test.f.d.ts +2 -0
- package/commonjs/package/dependencies/test.f.js +15 -0
- package/commonjs/package/module.f.d.ts +17 -0
- package/commonjs/package/module.f.js +18 -0
- package/commonjs/package/test.f.d.ts +2 -0
- package/commonjs/package/test.f.js +27 -0
- package/commonjs/path/module.f.d.ts +24 -0
- package/commonjs/path/module.f.js +114 -0
- package/commonjs/path/test.f.d.ts +25 -0
- package/commonjs/path/{test.f.ts → test.f.js} +123 -89
- package/crypto/prime_field/module.f.d.ts +43 -0
- package/crypto/prime_field/module.f.js +78 -0
- package/crypto/prime_field/test.f.d.ts +13 -0
- package/crypto/prime_field/test.f.js +149 -0
- package/crypto/secp/module.f.d.ts +68 -0
- package/crypto/secp/module.f.js +127 -0
- package/crypto/secp/test.f.d.ts +5 -0
- package/crypto/secp/test.f.js +72 -0
- package/crypto/sha2/module.f.d.ts +13 -0
- package/crypto/sha2/module.f.js +145 -0
- package/crypto/sha2/test.f.d.ts +9 -0
- package/crypto/sha2/test.f.js +82 -0
- package/dev/module.f.d.ts +1 -0
- package/dev/module.f.js +1 -0
- package/dev/test/module.f.d.ts +20 -0
- package/dev/test/module.f.js +75 -0
- package/dev/test.f.d.ts +9 -0
- package/dev/{test.f.ts → test.f.js} +22 -24
- package/djs/module.f.d.ts +17 -0
- package/djs/module.f.js +63 -0
- package/djs/parser/module.f.d.ts +12 -0
- package/djs/parser/module.f.js +333 -0
- package/djs/parser/test.f.d.ts +12 -0
- package/djs/parser/test.f.js +717 -0
- package/djs/serializer/module.f.d.ts +9 -0
- package/djs/serializer/module.f.js +81 -0
- package/djs/test/input.f.d.ts +2 -0
- package/djs/test/input.f.js +4 -0
- package/djs/test/m.f.d.ts +2 -0
- package/djs/test/m.f.js +1 -0
- package/djs/test.f.d.ts +12 -0
- package/djs/test.f.js +84 -0
- package/djs/tokenizer/module.f.d.ts +8 -0
- package/djs/tokenizer/module.f.js +60 -0
- package/djs/tokenizer/test.f.d.ts +7 -0
- package/djs/tokenizer/test.f.js +529 -0
- package/fsc/module.f.d.ts +5 -0
- package/fsc/module.f.js +75 -0
- package/fsc/test.f.d.ts +4 -0
- package/fsc/test.f.js +19 -0
- package/fsm/module.f.d.ts +13 -0
- package/fsm/module.f.js +59 -0
- package/fsm/test.f.d.ts +5 -0
- package/fsm/test.f.js +137 -0
- package/html/module.f.d.ts +13 -0
- package/html/module.f.js +58 -0
- package/html/test.f.d.ts +9 -0
- package/html/test.f.js +42 -0
- package/issues/test.f.d.ts +16 -0
- package/issues/test.f.js +70 -0
- package/js/tokenizer/module.f.d.ts +86 -0
- package/js/tokenizer/module.f.js +503 -0
- package/js/tokenizer/test.f.d.ts +9 -0
- package/js/tokenizer/test.f.js +905 -0
- package/json/module.f.d.ts +20 -0
- package/json/module.f.js +68 -0
- package/json/parser/module.f.d.ts +5 -0
- package/json/parser/module.f.js +155 -0
- package/json/parser/test.f.d.ts +5 -0
- package/json/parser/test.f.js +328 -0
- package/json/serializer/module.f.d.ts +7 -0
- package/json/serializer/module.f.js +21 -0
- package/json/serializer/test.f.d.ts +8 -0
- package/json/serializer/test.f.js +87 -0
- package/json/test.f.d.ts +8 -0
- package/json/test.f.js +61 -0
- package/json/tokenizer/module.f.d.ts +8 -0
- package/json/tokenizer/module.f.js +52 -0
- package/json/tokenizer/test.f.d.ts +6 -0
- package/json/tokenizer/test.f.js +419 -0
- package/nanvm-lib/tests/test.f.d.ts +27 -0
- package/nanvm-lib/tests/test.f.js +84 -0
- package/nodejs/version/module.f.d.ts +11 -0
- package/nodejs/version/module.f.js +16 -0
- package/nodejs/version/test.f.d.ts +2 -0
- package/nodejs/version/{test.f.ts → test.f.js} +13 -22
- package/package.json +9 -5
- package/text/ascii/module.f.d.ts +129 -0
- package/text/ascii/module.f.js +148 -0
- package/text/ascii/test.f.d.ts +4 -0
- package/text/ascii/test.f.js +14 -0
- package/text/module.f.d.ts +8 -0
- package/text/module.f.js +10 -0
- package/text/sgr/module.f.d.ts +8 -0
- package/text/sgr/module.f.js +8 -0
- package/text/test.f.d.ts +2 -0
- package/text/test.f.js +18 -0
- package/text/utf16/module.f.d.ts +9 -0
- package/text/utf16/module.f.js +66 -0
- package/text/utf16/test.f.d.ts +6 -0
- package/text/utf16/test.f.js +144 -0
- package/text/utf8/module.f.d.ts +6 -0
- package/text/utf8/module.f.js +112 -0
- package/text/utf8/test.f.d.ts +6 -0
- package/text/utf8/test.f.js +175 -0
- package/types/array/module.f.d.ts +21 -0
- package/types/array/module.f.js +23 -0
- package/types/array/test.f.d.ts +10 -0
- package/types/array/test.f.js +116 -0
- package/types/bigfloat/module.f.d.ts +3 -0
- package/types/bigfloat/module.f.js +66 -0
- package/types/bigfloat/test.f.d.ts +6 -0
- package/types/bigfloat/test.f.js +349 -0
- package/types/bigint/module.f.d.ts +54 -0
- package/types/bigint/{module.f.ts → module.f.js} +42 -65
- package/types/bigint/test.f.d.ts +16 -0
- package/types/bigint/test.f.js +199 -0
- package/types/bit_vec/module.f.d.ts +134 -0
- package/types/bit_vec/{module.f.ts → module.f.js} +47 -65
- package/types/bit_vec/test.f.d.ts +22 -0
- package/types/bit_vec/test.f.js +210 -0
- package/types/btree/find/module.f.d.ts +20 -0
- package/types/btree/find/module.f.js +84 -0
- package/types/btree/find/test.f.d.ts +2 -0
- package/types/btree/find/test.f.js +152 -0
- package/types/btree/module.f.d.ts +4 -0
- package/types/btree/module.f.js +31 -0
- package/types/btree/remove/module.f.d.ts +4 -0
- package/types/btree/remove/module.f.js +174 -0
- package/types/btree/remove/test.f.d.ts +5 -0
- package/types/btree/remove/test.f.js +634 -0
- package/types/btree/set/module.f.d.ts +3 -0
- package/types/btree/set/module.f.js +103 -0
- package/types/btree/set/test.f.d.ts +2 -0
- package/types/btree/set/test.f.js +360 -0
- package/types/btree/test.f.d.ts +8 -0
- package/types/btree/test.f.js +75 -0
- package/types/btree/types/module.f.d.ts +11 -0
- package/types/btree/types/module.f.js +1 -0
- package/types/byte_set/module.f.d.ts +16 -0
- package/types/byte_set/module.f.js +28 -0
- package/types/byte_set/test.f.d.ts +12 -0
- package/types/byte_set/test.f.js +122 -0
- package/types/function/compare/module.f.d.ts +10 -0
- package/types/function/compare/module.f.js +7 -0
- package/types/function/compare/test.f.d.ts +2 -0
- package/types/function/compare/test.f.js +8 -0
- package/types/function/module.f.d.ts +28 -0
- package/types/function/module.f.js +19 -0
- package/types/function/operator/module.f.d.ts +20 -0
- package/types/function/operator/module.f.js +18 -0
- package/types/function/test.f.d.ts +2 -0
- package/types/function/test.f.js +12 -0
- package/types/list/module.f.d.ts +50 -0
- package/types/list/module.f.js +171 -0
- package/types/list/test.f.d.ts +22 -0
- package/types/list/test.f.js +395 -0
- package/types/map/module.f.d.ts +14 -0
- package/types/map/module.f.js +31 -0
- package/types/map/test.f.d.ts +5 -0
- package/types/map/test.f.js +114 -0
- package/types/nibble_set/module.f.d.ts +10 -0
- package/types/nibble_set/module.f.js +9 -0
- package/types/nibble_set/test.f.d.ts +12 -0
- package/types/nibble_set/test.f.js +90 -0
- package/types/nullable/module.f.d.ts +3 -0
- package/types/nullable/module.f.js +2 -0
- package/types/nullable/test.f.d.ts +2 -0
- package/types/nullable/test.f.js +12 -0
- package/types/number/module.f.d.ts +6 -0
- package/types/number/module.f.js +8 -0
- package/types/number/test.f.d.ts +11 -0
- package/types/number/test.f.js +124 -0
- package/types/object/module.f.d.ts +10 -0
- package/types/object/module.f.js +12 -0
- package/types/object/test.f.d.ts +5 -0
- package/types/object/test.f.js +17 -0
- package/types/range/module.f.d.ts +3 -0
- package/types/range/module.f.js +2 -0
- package/types/range/test.f.d.ts +2 -0
- package/types/range/test.f.js +18 -0
- package/types/range_map/module.f.d.ts +14 -0
- package/types/range_map/module.f.js +51 -0
- package/types/range_map/test.f.d.ts +6 -0
- package/types/range_map/test.f.js +176 -0
- package/types/result/module.f.d.ts +7 -0
- package/types/result/module.f.js +8 -0
- package/types/sorted_list/module.f.d.ts +16 -0
- package/types/sorted_list/module.f.js +56 -0
- package/types/sorted_list/test.f.d.ts +5 -0
- package/types/sorted_list/test.f.js +64 -0
- package/types/sorted_set/module.f.d.ts +7 -0
- package/types/sorted_set/module.f.js +14 -0
- package/types/sorted_set/test.f.d.ts +6 -0
- package/types/sorted_set/test.f.js +78 -0
- package/types/string/module.f.d.ts +6 -0
- package/types/string/module.f.js +11 -0
- package/types/string/test.f.d.ts +15 -0
- package/types/string/test.f.js +58 -0
- package/types/string_set/module.f.d.ts +9 -0
- package/types/string_set/module.f.js +22 -0
- package/types/string_set/test.f.d.ts +5 -0
- package/types/string_set/test.f.js +65 -0
- package/.github/FUNDING.yml +0 -12
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/ci.yml +0 -88
- package/.github/workflows/npm-publish.yml +0 -53
- package/CHANGELOG.md +0 -29
- package/Cargo.lock +0 -18
- package/Cargo.toml +0 -7
- package/com/README.md +0 -3
- package/com/cpp/README.md +0 -80
- package/com/cpp/module.f.ts +0 -180
- package/com/cpp/nanocom.hpp +0 -195
- package/com/cpp/testlib.f.ts +0 -8
- package/com/cs/module.f.ts +0 -145
- package/com/cs/testlib.f.ts +0 -8
- package/com/proposals.md +0 -28
- package/com/rust/module.f.ts +0 -287
- package/com/rust/nanocom/Cargo.lock +0 -7
- package/com/rust/nanocom/Cargo.toml +0 -15
- package/com/rust/nanocom/README.md +0 -56
- package/com/rust/nanocom/src/class.rs +0 -6
- package/com/rust/nanocom/src/cobject.rs +0 -90
- package/com/rust/nanocom/src/guid.rs +0 -15
- package/com/rust/nanocom/src/hresult.rs +0 -7
- package/com/rust/nanocom/src/interface.rs +0 -9
- package/com/rust/nanocom/src/iunknown.rs +0 -13
- package/com/rust/nanocom/src/lib.rs +0 -20
- package/com/rust/nanocom/src/object.rs +0 -34
- package/com/rust/nanocom/src/ref.rs +0 -57
- package/com/rust/nanocom/src/vmt.rs +0 -7
- package/com/rust/nanocom/tests/it.rs +0 -186
- package/com/rust/nanocom/tests/itmod.rs +0 -195
- package/com/rust/testlib.f.ts +0 -8
- package/com/test/build.f.ts +0 -111
- package/com/test/build.ts +0 -45
- package/com/test/cpp/main.cpp +0 -74
- package/com/test/cs/Program.cs +0 -31
- package/com/test/cs/cs.csproj +0 -16
- package/com/test/rust/Cargo.toml +0 -12
- package/com/test/rust/src/lib.rs +0 -56
- package/com/types/module.f.ts +0 -62
- package/commonjs/README.md +0 -94
- package/commonjs/build/module.f.ts +0 -100
- package/commonjs/build/test.f.ts +0 -107
- package/commonjs/module/module.f.ts +0 -41
- package/commonjs/module.f.ts +0 -7
- package/commonjs/module.ts +0 -31
- package/commonjs/package/dependencies/module.f.ts +0 -22
- package/commonjs/package/dependencies/test.f.ts +0 -8
- package/commonjs/package/module.f.ts +0 -31
- package/commonjs/package/test.f.ts +0 -12
- package/commonjs/path/README.md +0 -17
- package/commonjs/path/module.f.ts +0 -171
- package/commonjs/test.ts +0 -64
- package/crypto/README.md +0 -3
- package/crypto/prime_field/module.f.ts +0 -114
- package/crypto/prime_field/test.f.ts +0 -95
- package/crypto/secp/module.f.ts +0 -182
- package/crypto/secp/test.f.ts +0 -68
- package/crypto/sha2/module.f.ts +0 -215
- package/crypto/sha2/test.f.ts +0 -83
- package/deno.json +0 -71
- package/dev/README.md +0 -8
- package/dev/index.ts +0 -3
- package/dev/module.f.ts +0 -1
- package/dev/module.ts +0 -196
- package/dev/test/module.f.ts +0 -135
- package/dev/test.ts +0 -53
- package/djs/README.md +0 -54
- package/djs/module.f.ts +0 -76
- package/djs/parser/module.f.ts +0 -509
- package/djs/parser/test.f.ts +0 -461
- package/djs/serializer/module.f.ts +0 -90
- package/djs/test.f.ts +0 -67
- package/djs/tokenizer/module.f.ts +0 -99
- package/djs/tokenizer/test.f.ts +0 -364
- package/doc/LANGUAGE.md +0 -255
- package/doc/README.md +0 -61
- package/doc/byte-code.md +0 -59
- package/doc/fa.md +0 -174
- package/doc/predefined.md +0 -143
- package/doc/proposals.md +0 -21
- package/doc/vm/README.md +0 -24
- package/doc/vm-rearchitecture.md +0 -129
- package/doc/vm.md +0 -150
- package/fsc/README.md +0 -111
- package/fsc/module.f.ts +0 -122
- package/fsc/test.f.ts +0 -21
- package/fsm/README.md +0 -113
- package/fsm/module.f.ts +0 -107
- package/fsm/test.f.ts +0 -139
- package/funding.json +0 -61
- package/html/README.md +0 -32
- package/html/module.f.ts +0 -109
- package/html/test.f.ts +0 -37
- package/issues/01-test-debug.md +0 -3
- package/issues/02-esm.md +0 -8
- package/issues/03-djs.md +0 -57
- package/issues/05-publish.md +0 -40
- package/issues/11-fs-load.md +0 -13
- package/issues/17-djs-extension.md +0 -6
- package/issues/README.md +0 -42
- package/issues/lang/1000-json.md +0 -50
- package/issues/lang/2110-default-export.md +0 -11
- package/issues/lang/2120-const.md +0 -14
- package/issues/lang/2130-default-import.md +0 -10
- package/issues/lang/2210-block-comment.md +0 -12
- package/issues/lang/2220-namespace-import.md +0 -25
- package/issues/lang/2310-undefined.md +0 -7
- package/issues/lang/2320-bigint.md +0 -7
- package/issues/lang/2330-property-accessor.md +0 -225
- package/issues/lang/2340-operators.md +0 -41
- package/issues/lang/2350-grouping.md +0 -11
- package/issues/lang/2360-built-in.md +0 -81
- package/issues/lang/2410-identifier-property.md +0 -9
- package/issues/lang/2420-line-comment.md +0 -10
- package/issues/lang/2430-trailing-comma.md +0 -13
- package/issues/lang/2440-shorthand.md +0 -8
- package/issues/lang/2450-destructuring.md +0 -12
- package/issues/lang/3110-function.md +0 -35
- package/issues/lang/3120-parameters.md +0 -9
- package/issues/lang/3130-body-const.md +0 -12
- package/issues/lang/3220-let.md +0 -11
- package/issues/lang/3240-export.md +0 -44
- package/issues/lang/3370-type-inference.md +0 -69
- package/issues/lang/3380-promise.md +0 -22
- package/issues/lang/3390-class.md +0 -3
- package/issues/lang/3410-expression.md +0 -12
- package/issues/lang/3420-one-parameter.md +0 -10
- package/issues/lang/3430-assignments.md +0 -23
- package/issues/lang/README.md +0 -193
- package/issues/test.f.ts +0 -58
- package/js/tokenizer/module.f.ts +0 -882
- package/js/tokenizer/test.f.ts +0 -617
- package/json/html/README.md +0 -49
- package/json/module.f.ts +0 -94
- package/json/parser/module.f.ts +0 -221
- package/json/parser/test.f.ts +0 -255
- package/json/serializer/module.f.ts +0 -74
- package/json/serializer/test.f.ts +0 -64
- package/json/test.f.ts +0 -48
- package/json/tokenizer/module.f.ts +0 -85
- package/json/tokenizer/test.f.ts +0 -290
- package/nanvm-lib/Cargo.toml +0 -6
- package/nanvm-lib/src/extension.rs +0 -130
- package/nanvm-lib/src/interface.rs +0 -133
- package/nanvm-lib/src/lib.rs +0 -7
- package/nanvm-lib/src/naive.rs +0 -236
- package/nanvm-lib/src/nanenum.rs +0 -236
- package/nanvm-lib/src/nullish.rs +0 -7
- package/nanvm-lib/src/sign.rs +0 -5
- package/nanvm-lib/src/simple.rs +0 -32
- package/nanvm-lib/tests/test.f.ts +0 -80
- package/nanvm-lib/tests/test.rs +0 -108
- package/nodejs/version/main.ts +0 -4
- package/nodejs/version/module.f.ts +0 -42
- package/text/README.md +0 -110
- package/text/ascii/module.f.ts +0 -222
- package/text/ascii/test.f.ts +0 -14
- package/text/module.f.ts +0 -30
- package/text/sgr/README.md +0 -3
- package/text/sgr/module.f.ts +0 -13
- package/text/test.f.ts +0 -19
- package/text/utf16/module.f.ts +0 -120
- package/text/utf16/test.f.ts +0 -107
- package/text/utf8/module.f.ts +0 -116
- package/text/utf8/test.f.ts +0 -125
- package/tsconfig.json +0 -104
- package/types/array/module.f.ts +0 -89
- package/types/array/test.f.ts +0 -88
- package/types/bigfloat/module.f.ts +0 -93
- package/types/bigfloat/test.f.ts +0 -218
- package/types/bigint/README.md +0 -35
- package/types/bigint/test.f.ts +0 -144
- package/types/bit_vec/README.md +0 -18
- package/types/bit_vec/test.f.ts +0 -129
- package/types/btree/README.md +0 -160
- package/types/btree/find/module.f.ts +0 -92
- package/types/btree/find/test.f.ts +0 -122
- package/types/btree/module.f.ts +0 -35
- package/types/btree/remove/module.f.ts +0 -151
- package/types/btree/remove/test.f.ts +0 -498
- package/types/btree/set/module.f.ts +0 -89
- package/types/btree/set/test.f.ts +0 -415
- package/types/btree/test.f.ts +0 -92
- package/types/btree/types/module.f.ts +0 -27
- package/types/byte_set/module.f.ts +0 -73
- package/types/byte_set/test.f.ts +0 -84
- package/types/function/compare/module.f.ts +0 -26
- package/types/function/compare/test.f.ts +0 -7
- package/types/function/module.f.ts +0 -43
- package/types/function/operator/module.f.ts +0 -65
- package/types/function/test.f.ts +0 -20
- package/types/list/module.f.ts +0 -350
- package/types/list/test.f.ts +0 -327
- package/types/map/module.f.ts +0 -65
- package/types/map/test.f.ts +0 -76
- package/types/nibble_set/module.f.ts +0 -34
- package/types/nibble_set/test.f.ts +0 -57
- package/types/nullable/module.f.ts +0 -9
- package/types/nullable/test.f.ts +0 -9
- package/types/number/module.f.ts +0 -20
- package/types/number/test.f.ts +0 -194
- package/types/object/module.f.ts +0 -30
- package/types/object/test.f.ts +0 -14
- package/types/range/module.f.ts +0 -10
- package/types/range/test.f.ts +0 -9
- package/types/range_map/module.f.ts +0 -70
- package/types/range_map/test.f.ts +0 -189
- package/types/result/module.f.ts +0 -20
- package/types/result/module.ts +0 -18
- package/types/sorted_list/module.f.ts +0 -83
- package/types/sorted_list/test.f.ts +0 -57
- package/types/sorted_set/module.f.ts +0 -36
- package/types/sorted_set/test.f.ts +0 -67
- package/types/string/module.f.ts +0 -26
- package/types/string/test.f.ts +0 -43
- package/types/string_set/module.f.ts +0 -37
- package/types/string_set/test.f.ts +0 -34
package/crypto/sha2/module.f.ts
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import * as array from '../../types/array/module.f.ts'
|
|
2
|
-
|
|
3
|
-
type HashInput = {
|
|
4
|
-
readonly f: (i: number) => number
|
|
5
|
-
readonly length: number
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
type Hash8 = array.Array8<number>
|
|
9
|
-
|
|
10
|
-
type Array16 = array.Array16<number>
|
|
11
|
-
|
|
12
|
-
const appendOneWithZeros
|
|
13
|
-
: (input: number) => (pos: number) => number
|
|
14
|
-
= input => pos => (input >> pos << pos) | (1 << pos)
|
|
15
|
-
|
|
16
|
-
const mod
|
|
17
|
-
: (input: number) => (pos: number) => number
|
|
18
|
-
= a => b => (a % b + b) % b
|
|
19
|
-
|
|
20
|
-
export const padding
|
|
21
|
-
: (input: readonly number[]) => (bits: number) => HashInput
|
|
22
|
-
= input => bitsCount => {
|
|
23
|
-
const appendBlockIndex = (bitsCount / 32) | 0
|
|
24
|
-
const length = (bitsCount + mod(447 - bitsCount)(512) + 65) / 32
|
|
25
|
-
const f
|
|
26
|
-
: (i: number) => number
|
|
27
|
-
= i => {
|
|
28
|
-
if (i < appendBlockIndex) { return input[i] }
|
|
29
|
-
if (i === appendBlockIndex) {
|
|
30
|
-
return appendBlockIndex >= input.length ? 0x8000_0000 : appendOneWithZeros(input[appendBlockIndex])(31 - bitsCount % 32)
|
|
31
|
-
}
|
|
32
|
-
if (i === length - 2) { return (bitsCount / 0x1_0000_0000) | 0 }
|
|
33
|
-
if (i === length - 1) { return bitsCount % 0x1_0000_0000 }
|
|
34
|
-
return 0
|
|
35
|
-
}
|
|
36
|
-
return ({ f, length })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const rotr
|
|
40
|
-
: (d: number) => (n: number) => number
|
|
41
|
-
= d => {
|
|
42
|
-
const r = 32 - d
|
|
43
|
-
return n => n >>> d | n << r
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const ch
|
|
47
|
-
: (x: number) => (y: number) => (z: number) => number
|
|
48
|
-
= x => y => z => x & y ^ ~x & z
|
|
49
|
-
|
|
50
|
-
const maj
|
|
51
|
-
: (x: number) => (y: number) => (z: number) => number
|
|
52
|
-
= x => y => z => x & y ^ x & z ^ y & z
|
|
53
|
-
|
|
54
|
-
const shr
|
|
55
|
-
: (d: number) => (n: number) => number
|
|
56
|
-
= d => n => n >>> d
|
|
57
|
-
|
|
58
|
-
const bigSigma
|
|
59
|
-
: (a: number) => (b: number) => (c: number) => (x: number) => number
|
|
60
|
-
= a => b => c => {
|
|
61
|
-
const ra = rotr(a)
|
|
62
|
-
const rb = rotr(b)
|
|
63
|
-
const rc = rotr(c)
|
|
64
|
-
return x => ra(x) ^ rb(x) ^ rc(x)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const bigSigma0 = bigSigma(2)(13)(22)
|
|
68
|
-
|
|
69
|
-
const bigSigma1 = bigSigma(6)(11)(25)
|
|
70
|
-
|
|
71
|
-
const smallSigma
|
|
72
|
-
: (a: number) => (b: number) => (c: number) => (x: number) => number
|
|
73
|
-
= a => b => c => {
|
|
74
|
-
const ra = rotr(a)
|
|
75
|
-
const rb = rotr(b)
|
|
76
|
-
const sc = shr(c)
|
|
77
|
-
return x => ra(x) ^ rb(x) ^ sc(x)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const smallSigma0 = smallSigma(7)(18)(3)
|
|
81
|
-
|
|
82
|
-
const smallSigma1 = smallSigma(17)(19)(10)
|
|
83
|
-
|
|
84
|
-
const wi
|
|
85
|
-
: (a: array.Array4<number>) => number
|
|
86
|
-
= ([a0, a1, a2, a3]) => (smallSigma1(a0) + a1 + smallSigma0(a2) + a3) | 0
|
|
87
|
-
|
|
88
|
-
const nextW
|
|
89
|
-
: (w: Array16) => Array16
|
|
90
|
-
= ([w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF]) => {
|
|
91
|
-
w0 = wi([wE, w9, w1, w0])
|
|
92
|
-
w1 = wi([wF, wA, w2, w1])
|
|
93
|
-
w2 = wi([w0, wB, w3, w2])
|
|
94
|
-
w3 = wi([w1, wC, w4, w3])
|
|
95
|
-
w4 = wi([w2, wD, w5, w4])
|
|
96
|
-
w5 = wi([w3, wE, w6, w5])
|
|
97
|
-
w6 = wi([w4, wF, w7, w6])
|
|
98
|
-
w7 = wi([w5, w0, w8, w7])
|
|
99
|
-
w8 = wi([w6, w1, w9, w8])
|
|
100
|
-
w9 = wi([w7, w2, wA, w9])
|
|
101
|
-
wA = wi([w8, w3, wB, wA])
|
|
102
|
-
wB = wi([w9, w4, wC, wB])
|
|
103
|
-
wC = wi([wA, w5, wD, wC])
|
|
104
|
-
wD = wi([wB, w6, wE, wD])
|
|
105
|
-
wE = wi([wC, w7, wF, wE])
|
|
106
|
-
wF = wi([wD, w8, w0, wF])
|
|
107
|
-
return [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, wA, wB, wC, wD, wE, wF]
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const k = [
|
|
111
|
-
[
|
|
112
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
113
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
114
|
-
],
|
|
115
|
-
[
|
|
116
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
117
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
121
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
122
|
-
],
|
|
123
|
-
[
|
|
124
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
125
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
126
|
-
],
|
|
127
|
-
];
|
|
128
|
-
|
|
129
|
-
const compress
|
|
130
|
-
: (init: Hash8) => (data: Array16) => Hash8
|
|
131
|
-
= ([a0, b0, c0, d0, e0, f0, g0, h0]) => data => {
|
|
132
|
-
let w = data
|
|
133
|
-
|
|
134
|
-
let a = a0
|
|
135
|
-
let b = b0
|
|
136
|
-
let c = c0
|
|
137
|
-
let d = d0
|
|
138
|
-
let e = e0
|
|
139
|
-
let f = f0
|
|
140
|
-
let g = g0
|
|
141
|
-
let h = h0
|
|
142
|
-
|
|
143
|
-
let i = 0;
|
|
144
|
-
while (true) {
|
|
145
|
-
const ki = k[i]
|
|
146
|
-
for (let j = 0; j < 16; ++j) {
|
|
147
|
-
const t1 = h + bigSigma1(e) + ch(e)(f)(g) + ki[j] + w[j]
|
|
148
|
-
const t2 = bigSigma0(a) + maj(a)(b)(c)
|
|
149
|
-
h = g
|
|
150
|
-
g = f
|
|
151
|
-
f = e
|
|
152
|
-
e = (d + t1) | 0
|
|
153
|
-
d = c
|
|
154
|
-
c = b
|
|
155
|
-
b = a
|
|
156
|
-
a = (t1 + t2) | 0
|
|
157
|
-
}
|
|
158
|
-
if (i === 3) { break }
|
|
159
|
-
++i;
|
|
160
|
-
w = nextW(w)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return [
|
|
164
|
-
(a0 + a) | 0,
|
|
165
|
-
(b0 + b) | 0,
|
|
166
|
-
(c0 + c) | 0,
|
|
167
|
-
(d0 + d) | 0,
|
|
168
|
-
(e0 + e) | 0,
|
|
169
|
-
(f0 + f) | 0,
|
|
170
|
-
(g0 + g) | 0,
|
|
171
|
-
(h0 + h) | 0,
|
|
172
|
-
]
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const compute
|
|
176
|
-
: (init: Hash8) => (input: readonly number[]) => (bitsCount: number) => Hash8
|
|
177
|
-
= init => input => bitsCount => {
|
|
178
|
-
const { f, length } = padding(input)(bitsCount)
|
|
179
|
-
|
|
180
|
-
let result = init
|
|
181
|
-
|
|
182
|
-
const chunkCount = length / 16
|
|
183
|
-
for (let i = 0; i < chunkCount; i++) {
|
|
184
|
-
const s = i * 16
|
|
185
|
-
result = compress(result)([
|
|
186
|
-
f(s + 0), f(s + 1), f(s + 2), f(s + 3), f(s + 4), f(s + 5), f(s + 6), f(s + 7),
|
|
187
|
-
f(s + 8), f(s + 9), f(s + 10), f(s + 11), f(s + 12), f(s + 13), f(s + 14), f(s + 15)])
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return result
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const init256
|
|
194
|
-
: Hash8
|
|
195
|
-
= [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]
|
|
196
|
-
|
|
197
|
-
export const computeSha256
|
|
198
|
-
: (input: readonly number[]) => (bitsCount: number) => Hash8
|
|
199
|
-
= compute(init256)
|
|
200
|
-
|
|
201
|
-
const init224
|
|
202
|
-
: Hash8
|
|
203
|
-
= [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4]
|
|
204
|
-
|
|
205
|
-
export const computeSha224
|
|
206
|
-
: (input: readonly number[]) => (bitsCount: number) => Hash8
|
|
207
|
-
= compute(init224)
|
|
208
|
-
|
|
209
|
-
export const compress256
|
|
210
|
-
: (data: Array16) => Hash8
|
|
211
|
-
= compress(init256)
|
|
212
|
-
|
|
213
|
-
export const compress224
|
|
214
|
-
: (data: Array16) => Hash8
|
|
215
|
-
= compress(init224)
|
package/crypto/sha2/test.f.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as _ from './module.f.ts'
|
|
2
|
-
import * as json from '../../json/module.f.ts'
|
|
3
|
-
import * as o from '../../types/object/module.f.ts'
|
|
4
|
-
const { sort } = o
|
|
5
|
-
|
|
6
|
-
const toU32
|
|
7
|
-
: (a: number) => number
|
|
8
|
-
= x => (x + 0x1_0000_0000) % 0x1_0000_0000
|
|
9
|
-
|
|
10
|
-
const toHexString
|
|
11
|
-
: (a: number) => string
|
|
12
|
-
= x => toU32(x).toString(16).padStart(8, '0')
|
|
13
|
-
|
|
14
|
-
const stringify
|
|
15
|
-
: (a: readonly json.Unknown[]) => string
|
|
16
|
-
= a => json.stringify(sort)(a)
|
|
17
|
-
|
|
18
|
-
// {
|
|
19
|
-
// const result = _.padding([])(0)
|
|
20
|
-
// console.log(result.map(toHexString))
|
|
21
|
-
// }
|
|
22
|
-
|
|
23
|
-
// {
|
|
24
|
-
// const result = _.padding([0x61626364, 0x65000000])(40)
|
|
25
|
-
// console.log(result.map(toHexString))
|
|
26
|
-
// }
|
|
27
|
-
|
|
28
|
-
// {
|
|
29
|
-
// const result = _.padding([0x11111110])(31)
|
|
30
|
-
// console.log(result.map(toHexString))
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
|
-
// {
|
|
34
|
-
// const result = _.padding([0x11111110])(32)
|
|
35
|
-
// console.log(result.map(toHexString))
|
|
36
|
-
// }
|
|
37
|
-
|
|
38
|
-
export default {
|
|
39
|
-
empty: {
|
|
40
|
-
sha256: () => {
|
|
41
|
-
const hash = _.computeSha256([])(0)
|
|
42
|
-
const result = stringify(hash.map(toHexString))
|
|
43
|
-
if (result !== '["e3b0c442","98fc1c14","9afbf4c8","996fb924","27ae41e4","649b934c","a495991b","7852b855"]') { throw result }
|
|
44
|
-
},
|
|
45
|
-
sha224: () => {
|
|
46
|
-
const hash = _.computeSha224([])(0)
|
|
47
|
-
const result = stringify(hash.map(toHexString))
|
|
48
|
-
if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') { throw result }
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
sha224compress: [
|
|
52
|
-
() => {
|
|
53
|
-
const hash = _.compress224([0x8000_0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
|
54
|
-
const result = stringify(hash.map(toHexString))
|
|
55
|
-
if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') { throw result }
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
sha256: [
|
|
59
|
-
() => {
|
|
60
|
-
//[0x68656C6C, 0x6F20776F, 0x726C6400] represents phrase 'hello world'
|
|
61
|
-
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C6400])(88)
|
|
62
|
-
const result = stringify(hash.map(toHexString))
|
|
63
|
-
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') { throw result }
|
|
64
|
-
},
|
|
65
|
-
() => {
|
|
66
|
-
//[0x68656C6C, 0x6F20776F, 0x726C6488] represents phrase 'hello world' with 1's at the end
|
|
67
|
-
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C64FF])(88)
|
|
68
|
-
const result = stringify(hash.map(toHexString))
|
|
69
|
-
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') { throw result }
|
|
70
|
-
},
|
|
71
|
-
() => {
|
|
72
|
-
const input = Array(8).fill(0x31313131)
|
|
73
|
-
const result = _.computeSha256(input)(256)
|
|
74
|
-
if (toU32(result[0]) !== 0x8a83665f) { throw result[0] }
|
|
75
|
-
},
|
|
76
|
-
() => {
|
|
77
|
-
const input = Array(16).fill(0x31313131)
|
|
78
|
-
const hash = _.computeSha256(input)(512)
|
|
79
|
-
const result = stringify(hash.map(toHexString))
|
|
80
|
-
if (result !== '["3138bb9b","c78df27c","473ecfd1","410f7bd4","5ebac1f5","9cf3ff9c","fe4db77a","ab7aedd3"]') { throw result }
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
}
|
package/deno.json
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@functionalscript/functionalscript",
|
|
3
|
-
"version": "0.3.3",
|
|
4
|
-
"license": "AGPL-3.0-only",
|
|
5
|
-
"exports": {
|
|
6
|
-
"./com/cpp": "./com/cpp/module.f.ts",
|
|
7
|
-
"./com/cs": "./com/cs/module.f.ts",
|
|
8
|
-
"./com/rust": "./com/rust/module.f.ts",
|
|
9
|
-
"./com/types": "./com/types/module.f.ts",
|
|
10
|
-
"./commonjs/build": "./commonjs/build/module.f.ts",
|
|
11
|
-
"./commonjs": "./commonjs/module.f.ts",
|
|
12
|
-
"./commonjs/module/function": "./commonjs/module/function/module.f.ts",
|
|
13
|
-
"./commonjs/module": "./commonjs/module/module.f.ts",
|
|
14
|
-
"./commonjs/package/dependencies": "./commonjs/package/dependencies/module.f.ts",
|
|
15
|
-
"./commonjs/package": "./commonjs/package/module.f.ts",
|
|
16
|
-
"./commonjs/path": "./commonjs/path/module.f.ts",
|
|
17
|
-
"./crypto/prime_field": "./crypto/prime_field/module.f.ts",
|
|
18
|
-
"./crypto/secp": "./crypto/secp/module.f.ts",
|
|
19
|
-
"./crypto/sha2": "./crypto/sha2/module.f.ts",
|
|
20
|
-
"./dev": "./dev/module.f.ts",
|
|
21
|
-
"./dev/test": "./dev/test/module.f.ts",
|
|
22
|
-
"./djs": "./djs/module.f.ts",
|
|
23
|
-
"./djs/parser": "./djs/parser/module.f.ts",
|
|
24
|
-
"./djs/serializer": "./djs/serializer/module.f.ts",
|
|
25
|
-
"./djs/tokenizer": "./djs/tokenizer/module.f.ts",
|
|
26
|
-
"./fsc": "./fsc/module.f.ts",
|
|
27
|
-
"./fsm": "./fsm/module.f.ts",
|
|
28
|
-
"./html": "./html/module.f.ts",
|
|
29
|
-
"./js/tokenizer": "./js/tokenizer/module.f.ts",
|
|
30
|
-
"./json": "./json/module.f.ts",
|
|
31
|
-
"./json/parser": "./json/parser/module.f.ts",
|
|
32
|
-
"./json/serializer": "./json/serializer/module.f.ts",
|
|
33
|
-
"./json/tokenizer": "./json/tokenizer/module.f.ts",
|
|
34
|
-
"./nodejs/version": "./nodejs/version/module.f.ts",
|
|
35
|
-
"./text/ascii": "./text/ascii/module.f.ts",
|
|
36
|
-
"./text": "./text/module.f.ts",
|
|
37
|
-
"./text/sgr": "./text/sgr/module.f.ts",
|
|
38
|
-
"./text/utf16": "./text/utf16/module.f.ts",
|
|
39
|
-
"./text/utf8": "./text/utf8/module.f.ts",
|
|
40
|
-
"./types/array": "./types/array/module.f.ts",
|
|
41
|
-
"./types/bigfloat": "./types/bigfloat/module.f.ts",
|
|
42
|
-
"./types/bigint": "./types/bigint/module.f.ts",
|
|
43
|
-
"./types/bit_vec": "./types/bit_vec/module.f.ts",
|
|
44
|
-
"./types/btree/find": "./types/btree/find/module.f.ts",
|
|
45
|
-
"./types/btree": "./types/btree/module.f.ts",
|
|
46
|
-
"./types/btree/remove": "./types/btree/remove/module.f.ts",
|
|
47
|
-
"./types/btree/set": "./types/btree/set/module.f.ts",
|
|
48
|
-
"./types/btree/types": "./types/btree/types/module.f.ts",
|
|
49
|
-
"./types/byte_set": "./types/byte_set/module.f.ts",
|
|
50
|
-
"./types/function/compare": "./types/function/compare/module.f.ts",
|
|
51
|
-
"./types/function": "./types/function/module.f.ts",
|
|
52
|
-
"./types/function/operator": "./types/function/operator/module.f.ts",
|
|
53
|
-
"./types/list": "./types/list/module.f.ts",
|
|
54
|
-
"./types/map": "./types/map/module.f.ts",
|
|
55
|
-
"./types/nibble_set": "./types/nibble_set/module.f.ts",
|
|
56
|
-
"./types/nullable": "./types/nullable/module.f.ts",
|
|
57
|
-
"./types/number": "./types/number/module.f.ts",
|
|
58
|
-
"./types/object": "./types/object/module.f.ts",
|
|
59
|
-
"./types/range": "./types/range/module.f.ts",
|
|
60
|
-
"./types/range_map": "./types/range_map/module.f.ts",
|
|
61
|
-
"./types/result": "./types/result/module.f.ts",
|
|
62
|
-
"./types/sorted_list": "./types/sorted_list/module.f.ts",
|
|
63
|
-
"./types/sorted_set": "./types/sorted_set/module.f.ts",
|
|
64
|
-
"./types/string": "./types/string/module.f.ts",
|
|
65
|
-
"./types/string_set": "./types/string_set/module.f.ts"
|
|
66
|
-
},
|
|
67
|
-
"tasks": {
|
|
68
|
-
"doc": "deno doc --html **/module.f.ts",
|
|
69
|
-
"test": "deno run --quiet --allow-read --allow-env --allow-net ./dev/test.ts"
|
|
70
|
-
}
|
|
71
|
-
}
|
package/dev/README.md
DELETED
package/dev/index.ts
DELETED
package/dev/module.f.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const todo = (): never => { throw 'not implemented' }
|
package/dev/module.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs'
|
|
2
|
-
import { readdir, writeFile, readFile } from 'node:fs/promises'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {{
|
|
6
|
-
* readonly withFileTypes: true
|
|
7
|
-
* }} Options
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {{
|
|
12
|
-
* readonly name: string
|
|
13
|
-
* readonly isDirectory: () => boolean
|
|
14
|
-
* }} Dirent
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @typedef {{
|
|
19
|
-
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
20
|
-
* readonly readFile: (path: string, options: 'utf8') => Promise<string>
|
|
21
|
-
* }} FsPromises
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
type Module = {
|
|
25
|
-
readonly default?: unknown
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** @typedef {(name: string) => unknown} Require */
|
|
29
|
-
|
|
30
|
-
type UnknownMap = {
|
|
31
|
-
readonly[k in string]: unknown
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type Entry<T> = readonly[string, T]
|
|
35
|
-
|
|
36
|
-
const cmp
|
|
37
|
-
: (a: Entry<unknown>, b: Entry<unknown>) => number
|
|
38
|
-
= ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
39
|
-
|
|
40
|
-
type MutableModuleMap = {
|
|
41
|
-
[k in string]: Module
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type ModuleMap = {
|
|
45
|
-
readonly[k in string]: Module
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const remove_tail
|
|
49
|
-
: (v: readonly string[]) => (dif: number) => readonly string[]
|
|
50
|
-
= v => dif => v.slice(0, v.length - dif)
|
|
51
|
-
|
|
52
|
-
const self: any = globalThis
|
|
53
|
-
|
|
54
|
-
export const exit
|
|
55
|
-
: (code: number) => never
|
|
56
|
-
= self.Deno ? self.Deno.exit : process.exit
|
|
57
|
-
|
|
58
|
-
export const env
|
|
59
|
-
: (v: string) => string|undefined
|
|
60
|
-
= self.Deno ? self.Deno.env.get :
|
|
61
|
-
a => {
|
|
62
|
-
const r = Object.getOwnPropertyDescriptor(process.env, a)
|
|
63
|
-
return r === undefined ? undefined :
|
|
64
|
-
typeof r.get === 'function' ? r.get() :
|
|
65
|
-
r.value
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const loadModuleMap = async () => {
|
|
69
|
-
const load
|
|
70
|
-
: () => Promise<UnknownMap>
|
|
71
|
-
= async () => {
|
|
72
|
-
const map
|
|
73
|
-
: (readonly[string, unknown])[]
|
|
74
|
-
= []
|
|
75
|
-
/** @type {} */
|
|
76
|
-
const f
|
|
77
|
-
: (path: string) => Promise<void>
|
|
78
|
-
= async p => {
|
|
79
|
-
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
80
|
-
const { name } = i
|
|
81
|
-
if (!name.startsWith('.')) {
|
|
82
|
-
const file = `${p}/${name}`
|
|
83
|
-
if (i.isDirectory()) {
|
|
84
|
-
await f(file)
|
|
85
|
-
continue
|
|
86
|
-
}
|
|
87
|
-
if (name.endsWith('.f.mjs') ||
|
|
88
|
-
name.endsWith('.f.js') ||
|
|
89
|
-
(name.endsWith('.f.ts') && !existsSync(file.substring(0, file.length - 3) + '.js'))
|
|
90
|
-
) {
|
|
91
|
-
console.log(file)
|
|
92
|
-
const source = await import(`../${file}`)
|
|
93
|
-
map.push([file, source.default])
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
await f('.')
|
|
99
|
-
map.sort(cmp)
|
|
100
|
-
return Object.fromEntries(map)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const map = await load()
|
|
104
|
-
|
|
105
|
-
const build
|
|
106
|
-
: () => ModuleMap
|
|
107
|
-
= () => {
|
|
108
|
-
const d
|
|
109
|
-
: MutableModuleMap
|
|
110
|
-
= {}
|
|
111
|
-
const getModule
|
|
112
|
-
: (base: readonly string[]) => (k: string) => readonly[string, Module]
|
|
113
|
-
= base => k => {
|
|
114
|
-
const relativePath = k.split('/')
|
|
115
|
-
const dif = relativePath.filter(v => v === '..').length
|
|
116
|
-
const path = [remove_tail(base)(dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
117
|
-
.flat()
|
|
118
|
-
const pathStr = path.join('/')
|
|
119
|
-
{
|
|
120
|
-
const module = d[pathStr]
|
|
121
|
-
if (module !== void 0) {
|
|
122
|
-
return [pathStr, module]
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
{
|
|
126
|
-
/** @type {Module} */
|
|
127
|
-
const module = { default: map[pathStr] }
|
|
128
|
-
d[pathStr] = module
|
|
129
|
-
return [pathStr, module]
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
{
|
|
133
|
-
const get = getModule(['.'])
|
|
134
|
-
for (const k of Object.keys(map)) {
|
|
135
|
-
get(k)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return d
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return build()
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
type FolderMap = {
|
|
145
|
-
readonly[k in string]: string | FolderMap
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const folderMapAdd
|
|
149
|
-
: (m: FolderMap) => (s: readonly string[]) => FolderMap
|
|
150
|
-
= m => s => {
|
|
151
|
-
const [first, ...rest] = s
|
|
152
|
-
const firstResult = m[first]
|
|
153
|
-
return typeof firstResult === 'string'
|
|
154
|
-
? m
|
|
155
|
-
: {
|
|
156
|
-
...m,
|
|
157
|
-
[first]: rest.length === 1
|
|
158
|
-
? rest[0]
|
|
159
|
-
: folderMapAdd(firstResult === undefined ? {} : firstResult)(rest)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const indent = ' '
|
|
164
|
-
|
|
165
|
-
const codeAdd
|
|
166
|
-
: (i: string) => (p: string) => (m: FolderMap) => readonly[string,string]
|
|
167
|
-
= i => p => m => {
|
|
168
|
-
let result = ''
|
|
169
|
-
let im = ''
|
|
170
|
-
for (const [k, v] of Object.entries(m)) {
|
|
171
|
-
const np = `${p}${k}`
|
|
172
|
-
if (typeof v === 'string') {
|
|
173
|
-
result += `${i}${k}: ${np},\n`
|
|
174
|
-
im += `import ${np} from './${np.replaceAll('$', '/')}/${v}'\n`
|
|
175
|
-
} else {
|
|
176
|
-
const [r, x] = codeAdd(i + indent)(`${np}\$`)(v)
|
|
177
|
-
result += `${i}${k}: \{\n`
|
|
178
|
-
result += r
|
|
179
|
-
result += `${i}\},\n`
|
|
180
|
-
im += x
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return [result, im]
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export const index = async () => {
|
|
187
|
-
const jj = './deno.json'
|
|
188
|
-
const n = '/module.f.ts'
|
|
189
|
-
const jsr_json = JSON.parse(await readFile(jj, { encoding: 'utf8' }))
|
|
190
|
-
const list = Object.keys(await loadModuleMap()).filter(v => v.endsWith(n))
|
|
191
|
-
const exportsA = list.filter(v => !v.startsWith('./out')).map(v => [v.replace(n, ''), `./${v.substring(2)}`])
|
|
192
|
-
const exports = Object.fromEntries(exportsA)
|
|
193
|
-
await writeFile(
|
|
194
|
-
jj,
|
|
195
|
-
JSON.stringify({ ...jsr_json, exports }, null, 2))
|
|
196
|
-
}
|