functionalscript 0.13.1 → 0.14.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/{types → fs}/asn.1/module.f.d.ts +1 -1
- package/{types → fs}/asn.1/module.f.js +3 -3
- package/{types → fs}/asn.1/test.f.js +2 -2
- package/{types → fs}/base128/module.f.d.ts +1 -1
- package/{types → fs}/base128/module.f.js +1 -1
- package/{types → fs}/base128/test.f.js +2 -2
- package/{bnf → fs/bnf}/data/module.f.d.ts +1 -1
- package/{cas → fs/cas}/module.f.d.ts +4 -4
- package/{cas → fs/cas}/module.f.js +1 -1
- package/{types → fs}/cbase32/module.f.d.ts +2 -2
- package/{types → fs}/cbase32/module.f.js +1 -1
- package/{types → fs}/cbase32/test.f.js +1 -1
- package/fs/ci/bun/module.f.d.ts +2 -0
- package/fs/ci/bun/module.f.js +20 -0
- package/fs/ci/common/module.f.d.ts +43 -0
- package/fs/ci/common/module.f.js +32 -0
- package/fs/ci/config/module.f.d.ts +25 -0
- package/fs/ci/config/module.f.js +34 -0
- package/fs/ci/deno/module.f.d.ts +2 -0
- package/fs/ci/deno/module.f.js +13 -0
- package/fs/ci/module.f.js +40 -0
- package/fs/ci/node/module.f.d.ts +6 -0
- package/fs/ci/node/module.f.js +36 -0
- package/fs/ci/playwright/module.f.d.ts +2 -0
- package/fs/ci/playwright/module.f.js +23 -0
- package/fs/ci/rust/module.f.d.ts +2 -0
- package/fs/ci/rust/module.f.js +49 -0
- package/{crypto → fs/crypto}/secp/module.f.d.ts +1 -2
- package/{dev → fs/dev}/module.f.d.ts +2 -0
- package/{dev → fs/dev}/module.f.js +5 -0
- package/{dev → fs/dev}/tf/all.test.js +7 -5
- package/{dev → fs/dev}/tf/module.f.d.ts +1 -1
- package/{dev → fs/dev}/tf/module.f.js +12 -9
- package/fs/dev/tf/test.f.d.ts +16 -0
- package/fs/dev/tf/test.f.js +22 -0
- package/fs/dev/version/module.f.d.ts +3 -0
- package/{djs → fs/djs}/tokenizer/module.f.js +3 -3
- package/{djs/parser-new → fs/djs/tokenizer-new}/test.f.d.ts +2 -1
- package/fs/djs/tokenizer-new/test.f.js +894 -0
- package/{js → fs/js}/tokenizer/module.f.js +34 -34
- package/{json → fs/json}/tokenizer/module.f.js +1 -1
- package/{path → fs/path}/module.f.d.ts +1 -1
- package/fs/sul/id/module.f.d.ts +33 -0
- package/fs/sul/id/module.f.js +94 -0
- package/fs/sul/id/test.f.d.ts +21 -0
- package/fs/sul/id/test.f.js +75 -0
- package/fs/sul/level/hash/module.f.d.ts +38 -0
- package/fs/sul/level/hash/module.f.js +43 -0
- package/fs/sul/level/hash/test.f.d.ts +14 -0
- package/fs/sul/level/hash/test.f.js +112 -0
- package/fs/sul/level/literal/module.f.d.ts +64 -0
- package/fs/sul/level/literal/module.f.js +88 -0
- package/fs/sul/level/literal/test.f.d.ts +12 -0
- package/fs/sul/level/literal/test.f.js +722 -0
- package/fs/sul/module.f.d.ts +23 -0
- package/fs/sul/module.f.js +46 -0
- package/fs/sul/test.f.d.ts +10 -0
- package/fs/sul/test.f.js +47 -0
- package/{text → fs/text}/module.f.d.ts +1 -1
- package/{text → fs/text}/utf16/module.f.js +8 -8
- package/{text → fs/text}/utf8/module.f.js +2 -2
- package/{types → fs/types}/bit_vec/module.f.d.ts +13 -1
- package/{types → fs/types}/bit_vec/module.f.js +33 -15
- package/{types → fs/types}/effects/module.f.d.ts +1 -0
- package/{types → fs/types}/effects/node/virtual/module.f.d.ts +3 -3
- package/{types → fs/types}/function/operator/module.f.d.ts +1 -1
- package/{types → fs/types}/function/operator/module.f.js +1 -1
- package/{types → fs/types}/list/module.f.js +1 -1
- package/fs/types/patricia_trie/module.f.d.ts +25 -0
- package/fs/types/patricia_trie/module.f.js +35 -0
- package/fs/types/patricia_trie/test.f.d.ts +8 -0
- package/fs/types/patricia_trie/test.f.js +121 -0
- package/fs/types/rtti/parse/module.f.d.ts +32 -0
- package/fs/types/rtti/parse/module.f.js +113 -0
- package/fs/types/rtti/parse/test.f.d.ts +104 -0
- package/fs/types/rtti/parse/test.f.js +316 -0
- package/fs/types/rtti/validate/module.f.d.ts +74 -0
- package/{types → fs/types}/rtti/validate/module.f.js +26 -24
- package/{types → fs/types}/rtti/validate/test.f.d.ts +11 -0
- package/{types → fs/types}/rtti/validate/test.f.js +38 -0
- package/{types → fs/types}/uint8array/module.f.d.ts +2 -2
- package/package.json +8 -8
- package/ci/module.f.js +0 -183
- package/dev/tf/test.f.d.ts +0 -4
- package/dev/tf/test.f.js +0 -5
- package/dev/version/module.f.d.ts +0 -3
- package/djs/parser-new/test.f.js +0 -202
- package/types/rtti/validate/module.f.d.ts +0 -50
- /package/{types → fs}/asn.1/test.f.d.ts +0 -0
- /package/{cas → fs/base128}/test.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/data/module.f.js +0 -0
- /package/{bnf → fs/bnf}/data/test.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/data/test.f.js +0 -0
- /package/{bnf → fs/bnf}/module.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/module.f.js +0 -0
- /package/{bnf → fs/bnf}/test.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/test.f.js +0 -0
- /package/{bnf → fs/bnf}/testlib.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/testlib.f.js +0 -0
- /package/{types/base128 → fs/cas}/test.f.d.ts +0 -0
- /package/{cas → fs/cas}/test.f.js +0 -0
- /package/{types → fs}/cbase32/test.f.d.ts +0 -0
- /package/{ci → fs/ci}/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/hmac/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/hmac/module.f.js +0 -0
- /package/{crypto → fs/crypto}/hmac/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/hmac/test.f.js +0 -0
- /package/{crypto → fs/crypto}/secp/module.f.js +0 -0
- /package/{crypto → fs/crypto}/secp/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/secp/test.f.js +0 -0
- /package/{crypto → fs/crypto}/sha2/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sha2/module.f.js +0 -0
- /package/{crypto → fs/crypto}/sha2/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sha2/test.f.js +0 -0
- /package/{crypto → fs/crypto}/sign/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sign/module.f.js +0 -0
- /package/{crypto → fs/crypto}/sign/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sign/test.f.js +0 -0
- /package/{dev → fs/dev}/index/module.f.d.ts +0 -0
- /package/{dev → fs/dev}/index/module.f.js +0 -0
- /package/{dev → fs/dev}/test.f.d.ts +0 -0
- /package/{dev → fs/dev}/test.f.js +0 -0
- /package/{dev → fs/dev}/tf/all.test.d.ts +0 -0
- /package/{dev → fs/dev}/version/module.f.js +0 -0
- /package/{dev → fs/dev}/version/test.f.d.ts +0 -0
- /package/{dev → fs/dev}/version/test.f.js +0 -0
- /package/{djs → fs/djs}/ast/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/ast/module.f.js +0 -0
- /package/{djs → fs/djs}/ast/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/ast/test.f.js +0 -0
- /package/{djs → fs/djs}/examples/input.f.d.ts +0 -0
- /package/{djs → fs/djs}/examples/input.f.js +0 -0
- /package/{djs → fs/djs}/examples/m.f.d.ts +0 -0
- /package/{djs → fs/djs}/examples/m.f.js +0 -0
- /package/{djs → fs/djs}/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/module.f.js +0 -0
- /package/{djs → fs/djs}/parser/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/parser/module.f.js +0 -0
- /package/{djs → fs/djs}/parser/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/parser/test.f.js +0 -0
- /package/{djs → fs/djs}/serializer/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/serializer/module.f.js +0 -0
- /package/{djs → fs/djs}/serializer/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/serializer/test.f.js +0 -0
- /package/{djs → fs/djs}/tokenizer/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/tokenizer/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/tokenizer/test.f.js +0 -0
- /package/{djs/parser-new → fs/djs/tokenizer-new}/module.f.d.ts +0 -0
- /package/{djs/parser-new → fs/djs/tokenizer-new}/module.f.js +0 -0
- /package/{djs → fs/djs}/transpiler/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/transpiler/module.f.js +0 -0
- /package/{djs → fs/djs}/transpiler/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/transpiler/test.f.js +0 -0
- /package/{fjs → fs/fjs}/module.d.ts +0 -0
- /package/{fjs → fs/fjs}/module.f.d.ts +0 -0
- /package/{fjs → fs/fjs}/module.f.js +0 -0
- /package/{fjs → fs/fjs}/module.js +0 -0
- /package/{fsc → fs/fsc}/bnf.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/bnf.f.js +0 -0
- /package/{fsc → fs/fsc}/json.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/json.f.js +0 -0
- /package/{fsc → fs/fsc}/module.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/module.f.js +0 -0
- /package/{fsc → fs/fsc}/test.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/test.f.js +0 -0
- /package/{fsm → fs/fsm}/module.f.d.ts +0 -0
- /package/{fsm → fs/fsm}/module.f.js +0 -0
- /package/{fsm → fs/fsm}/test.f.d.ts +0 -0
- /package/{fsm → fs/fsm}/test.f.js +0 -0
- /package/{html → fs/html}/module.f.d.ts +0 -0
- /package/{html → fs/html}/module.f.js +0 -0
- /package/{html → fs/html}/test.f.d.ts +0 -0
- /package/{html → fs/html}/test.f.js +0 -0
- /package/{io → fs/io}/module.d.ts +0 -0
- /package/{io → fs/io}/module.f.d.ts +0 -0
- /package/{io → fs/io}/module.f.js +0 -0
- /package/{io → fs/io}/module.js +0 -0
- /package/{io → fs/io}/virtual/module.f.d.ts +0 -0
- /package/{io → fs/io}/virtual/module.f.js +0 -0
- /package/{js → fs/js}/tokenizer/module.f.d.ts +0 -0
- /package/{js → fs/js}/tokenizer/test.f.d.ts +0 -0
- /package/{js → fs/js}/tokenizer/test.f.js +0 -0
- /package/{json → fs/json}/module.f.d.ts +0 -0
- /package/{json → fs/json}/module.f.js +0 -0
- /package/{json → fs/json}/parser/module.f.d.ts +0 -0
- /package/{json → fs/json}/parser/module.f.js +0 -0
- /package/{json → fs/json}/parser/test.f.d.ts +0 -0
- /package/{json → fs/json}/parser/test.f.js +0 -0
- /package/{json → fs/json}/serializer/module.f.d.ts +0 -0
- /package/{json → fs/json}/serializer/module.f.js +0 -0
- /package/{json → fs/json}/serializer/test.f.d.ts +0 -0
- /package/{json → fs/json}/serializer/test.f.js +0 -0
- /package/{json → fs/json}/test.f.d.ts +0 -0
- /package/{json → fs/json}/test.f.js +0 -0
- /package/{json → fs/json}/tokenizer/module.f.d.ts +0 -0
- /package/{json → fs/json}/tokenizer/test.f.d.ts +0 -0
- /package/{json → fs/json}/tokenizer/test.f.js +0 -0
- /package/{path → fs/path}/module.f.js +0 -0
- /package/{path → fs/path}/test.f.d.ts +0 -0
- /package/{path → fs/path}/test.f.js +0 -0
- /package/{text → fs/text}/ascii/module.f.d.ts +0 -0
- /package/{text → fs/text}/ascii/module.f.js +0 -0
- /package/{text → fs/text}/ascii/test.f.d.ts +0 -0
- /package/{text → fs/text}/ascii/test.f.js +0 -0
- /package/{text → fs/text}/module.f.js +0 -0
- /package/{text → fs/text}/sgr/module.f.d.ts +0 -0
- /package/{text → fs/text}/sgr/module.f.js +0 -0
- /package/{text → fs/text}/sgr/test.f.d.ts +0 -0
- /package/{text → fs/text}/sgr/test.f.js +0 -0
- /package/{text → fs/text}/test.f.d.ts +0 -0
- /package/{text → fs/text}/test.f.js +0 -0
- /package/{text → fs/text}/utf16/module.f.d.ts +0 -0
- /package/{text → fs/text}/utf16/test.f.d.ts +0 -0
- /package/{text → fs/text}/utf16/test.f.js +0 -0
- /package/{text → fs/text}/utf8/module.f.d.ts +0 -0
- /package/{text → fs/text}/utf8/test.f.d.ts +0 -0
- /package/{text → fs/text}/utf8/test.f.js +0 -0
- /package/{types → fs/types}/array/module.f.d.ts +0 -0
- /package/{types → fs/types}/array/module.f.js +0 -0
- /package/{types → fs/types}/array/test.f.d.ts +0 -0
- /package/{types → fs/types}/array/test.f.js +0 -0
- /package/{types → fs/types}/bigfloat/module.f.d.ts +0 -0
- /package/{types → fs/types}/bigfloat/module.f.js +0 -0
- /package/{types → fs/types}/bigfloat/test.f.d.ts +0 -0
- /package/{types → fs/types}/bigfloat/test.f.js +0 -0
- /package/{types → fs/types}/bigint/module.f.d.ts +0 -0
- /package/{types → fs/types}/bigint/module.f.js +0 -0
- /package/{types → fs/types}/bigint/test.f.d.ts +0 -0
- /package/{types → fs/types}/bigint/test.f.js +0 -0
- /package/{types → fs/types}/bit_vec/test.f.d.ts +0 -0
- /package/{types → fs/types}/bit_vec/test.f.js +0 -0
- /package/{types → fs/types}/btree/find/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/find/module.f.js +0 -0
- /package/{types → fs/types}/btree/find/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/find/test.f.js +0 -0
- /package/{types → fs/types}/btree/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/module.f.js +0 -0
- /package/{types → fs/types}/btree/remove/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/remove/module.f.js +0 -0
- /package/{types → fs/types}/btree/remove/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/remove/test.f.js +0 -0
- /package/{types → fs/types}/btree/set/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/set/module.f.js +0 -0
- /package/{types → fs/types}/btree/set/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/set/test.f.js +0 -0
- /package/{types → fs/types}/btree/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/test.f.js +0 -0
- /package/{types → fs/types}/btree/types/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/types/module.f.js +0 -0
- /package/{types → fs/types}/byte_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/byte_set/module.f.js +0 -0
- /package/{types → fs/types}/byte_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/byte_set/test.f.js +0 -0
- /package/{types → fs/types}/effects/mock/module.f.d.ts +0 -0
- /package/{types → fs/types}/effects/mock/module.f.js +0 -0
- /package/{types → fs/types}/effects/module.d.ts +0 -0
- /package/{types → fs/types}/effects/module.f.js +0 -0
- /package/{types → fs/types}/effects/module.js +0 -0
- /package/{types → fs/types}/effects/node/module.f.d.ts +0 -0
- /package/{types → fs/types}/effects/node/module.f.js +0 -0
- /package/{types → fs/types}/effects/node/test.f.d.ts +0 -0
- /package/{types → fs/types}/effects/node/test.f.js +0 -0
- /package/{types → fs/types}/effects/node/virtual/module.f.js +0 -0
- /package/{types → fs/types}/function/compare/module.f.d.ts +0 -0
- /package/{types → fs/types}/function/compare/module.f.js +0 -0
- /package/{types → fs/types}/function/compare/test.f.d.ts +0 -0
- /package/{types → fs/types}/function/compare/test.f.js +0 -0
- /package/{types → fs/types}/function/module.f.d.ts +0 -0
- /package/{types → fs/types}/function/module.f.js +0 -0
- /package/{types → fs/types}/function/test.f.d.ts +0 -0
- /package/{types → fs/types}/function/test.f.js +0 -0
- /package/{types → fs/types}/list/module.f.d.ts +0 -0
- /package/{types → fs/types}/list/test.f.d.ts +0 -0
- /package/{types → fs/types}/list/test.f.js +0 -0
- /package/{types → fs/types}/map/module.f.d.ts +0 -0
- /package/{types → fs/types}/map/module.f.js +0 -0
- /package/{types → fs/types}/map/test.f.d.ts +0 -0
- /package/{types → fs/types}/map/test.f.js +0 -0
- /package/{types → fs/types}/monoid/module.f.d.ts +0 -0
- /package/{types → fs/types}/monoid/module.f.js +0 -0
- /package/{types → fs/types}/monoid/test.f.d.ts +0 -0
- /package/{types → fs/types}/monoid/test.f.js +0 -0
- /package/{types → fs/types}/nibble_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/nibble_set/module.f.js +0 -0
- /package/{types → fs/types}/nibble_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/nibble_set/test.f.js +0 -0
- /package/{types → fs/types}/nominal/module.f.d.ts +0 -0
- /package/{types → fs/types}/nominal/module.f.js +0 -0
- /package/{types → fs/types}/nominal/test.f.d.ts +0 -0
- /package/{types → fs/types}/nominal/test.f.js +0 -0
- /package/{types → fs/types}/nullable/module.f.d.ts +0 -0
- /package/{types → fs/types}/nullable/module.f.js +0 -0
- /package/{types → fs/types}/nullable/test.f.d.ts +0 -0
- /package/{types → fs/types}/nullable/test.f.js +0 -0
- /package/{types → fs/types}/number/module.f.d.ts +0 -0
- /package/{types → fs/types}/number/module.f.js +0 -0
- /package/{types → fs/types}/number/test.f.d.ts +0 -0
- /package/{types → fs/types}/number/test.f.js +0 -0
- /package/{types → fs/types}/object/module.f.d.ts +0 -0
- /package/{types → fs/types}/object/module.f.js +0 -0
- /package/{types → fs/types}/object/test.f.d.ts +0 -0
- /package/{types → fs/types}/object/test.f.js +0 -0
- /package/{types → fs/types}/option/module.f.d.ts +0 -0
- /package/{types → fs/types}/option/module.f.js +0 -0
- /package/{types → fs/types}/ordered_map/module.f.d.ts +0 -0
- /package/{types → fs/types}/ordered_map/module.f.js +0 -0
- /package/{types → fs/types}/ordered_map/test.f.d.ts +0 -0
- /package/{types → fs/types}/ordered_map/test.f.js +0 -0
- /package/{types → fs/types}/prime_field/module.f.d.ts +0 -0
- /package/{types → fs/types}/prime_field/module.f.js +0 -0
- /package/{types → fs/types}/prime_field/test.f.d.ts +0 -0
- /package/{types → fs/types}/prime_field/test.f.js +0 -0
- /package/{types → fs/types}/range/module.f.d.ts +0 -0
- /package/{types → fs/types}/range/module.f.js +0 -0
- /package/{types → fs/types}/range/test.f.d.ts +0 -0
- /package/{types → fs/types}/range/test.f.js +0 -0
- /package/{types → fs/types}/range_map/module.f.d.ts +0 -0
- /package/{types → fs/types}/range_map/module.f.js +0 -0
- /package/{types → fs/types}/range_map/test.f.d.ts +0 -0
- /package/{types → fs/types}/range_map/test.f.js +0 -0
- /package/{types → fs/types}/result/module.d.ts +0 -0
- /package/{types → fs/types}/result/module.f.d.ts +0 -0
- /package/{types → fs/types}/result/module.f.js +0 -0
- /package/{types → fs/types}/result/module.js +0 -0
- /package/{types → fs/types}/result/test.f.d.ts +0 -0
- /package/{types → fs/types}/result/test.f.js +0 -0
- /package/{types → fs/types}/rtti/module.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/module.f.js +0 -0
- /package/{types → fs/types}/rtti/test.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/test.f.js +0 -0
- /package/{types → fs/types}/rtti/ts/module.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/ts/module.f.js +0 -0
- /package/{types → fs/types}/rtti/ts/test.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/ts/test.f.js +0 -0
- /package/{types → fs/types}/sorted_list/module.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_list/module.f.js +0 -0
- /package/{types → fs/types}/sorted_list/test.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_list/test.f.js +0 -0
- /package/{types → fs/types}/sorted_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_set/module.f.js +0 -0
- /package/{types → fs/types}/sorted_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_set/test.f.js +0 -0
- /package/{types → fs/types}/string/module.f.d.ts +0 -0
- /package/{types → fs/types}/string/module.f.js +0 -0
- /package/{types → fs/types}/string/test.f.d.ts +0 -0
- /package/{types → fs/types}/string/test.f.js +0 -0
- /package/{types → fs/types}/string_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/string_set/module.f.js +0 -0
- /package/{types → fs/types}/string_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/string_set/test.f.js +0 -0
- /package/{types → fs/types}/ts/module.f.d.ts +0 -0
- /package/{types → fs/types}/ts/module.f.js +0 -0
- /package/{types → fs/types}/uint8array/module.f.js +0 -0
- /package/{types → fs/types}/uint8array/test.f.d.ts +0 -0
- /package/{types → fs/types}/uint8array/test.f.js +0 -0
- /package/{website → fs/website}/module.f.d.ts +0 -0
- /package/{website → fs/website}/module.f.js +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming encoder for the full SUL pipeline.
|
|
3
|
+
* Processes bits one at a time through literal levels L1→L2→L3, then through a dynamic array of hash levels.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type PipelineState } from './level/literal/module.f.ts';
|
|
8
|
+
import { type Add } from './level/hash/module.f.ts';
|
|
9
|
+
import { type Id } from './id/module.f.ts';
|
|
10
|
+
import type { InternalState } from '../types/patricia_trie/module.f.ts';
|
|
11
|
+
type HashState = InternalState<Id>;
|
|
12
|
+
export type EncodeState<S> = readonly [
|
|
13
|
+
PipelineState,
|
|
14
|
+
S,
|
|
15
|
+
readonly HashState[]
|
|
16
|
+
];
|
|
17
|
+
export type Encode<S> = {
|
|
18
|
+
readonly push: (bit: bigint, state: EncodeState<S>) => EncodeState<S>;
|
|
19
|
+
readonly end: (state: EncodeState<S>) => Id;
|
|
20
|
+
};
|
|
21
|
+
export declare const emptyEncodeState: <S>(storage: S) => EncodeState<S>;
|
|
22
|
+
export declare const encode: <S>(add: Add<S>) => Encode<S>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming encoder for the full SUL pipeline.
|
|
3
|
+
* Processes bits one at a time through literal levels L1→L2→L3, then through a dynamic array of hash levels.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { emptyPipelineState, pipelineStep } from "./level/literal/module.f.js";
|
|
8
|
+
import { encode as hashEncode } from "./level/hash/module.f.js";
|
|
9
|
+
import { level3Id } from "./id/module.f.js";
|
|
10
|
+
export const emptyEncodeState = (storage) => [emptyPipelineState, storage, []];
|
|
11
|
+
export const encode = (add) => {
|
|
12
|
+
const step = hashEncode(add);
|
|
13
|
+
const cascade = (id0, storage0, stacks0) => {
|
|
14
|
+
let id = id0, storage = storage0, stacks = stacks0;
|
|
15
|
+
for (let index = 0;; index++) {
|
|
16
|
+
if (index >= stacks.length) {
|
|
17
|
+
const [, [newStorage, newStack]] = step(id, [storage, []]);
|
|
18
|
+
return [id, newStorage, [...stacks, newStack]];
|
|
19
|
+
}
|
|
20
|
+
const [out, [newStorage, newStack]] = step(id, [storage, stacks[index]]);
|
|
21
|
+
stacks = [...stacks.slice(0, index), newStack, ...stacks.slice(index + 1)];
|
|
22
|
+
storage = newStorage;
|
|
23
|
+
if (out === undefined)
|
|
24
|
+
return [undefined, storage, stacks];
|
|
25
|
+
id = out;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const literalStep = (bit, state) => {
|
|
29
|
+
const [ps, storage, stacks] = state;
|
|
30
|
+
const [l3Out, newPs] = pipelineStep(bit, ps);
|
|
31
|
+
if (l3Out === undefined)
|
|
32
|
+
return [undefined, [newPs, storage, stacks]];
|
|
33
|
+
const [finalId, newStorage, newStacks] = cascade(level3Id(l3Out), storage, stacks);
|
|
34
|
+
return [finalId, [newPs, newStorage, newStacks]];
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
push: (bit, state) => literalStep(bit, state)[1],
|
|
38
|
+
end: state => {
|
|
39
|
+
let [id, s] = literalStep(1n, state);
|
|
40
|
+
while (id === undefined) {
|
|
41
|
+
[id, s] = literalStep(0n, s);
|
|
42
|
+
}
|
|
43
|
+
return id;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
deterministic: () => void;
|
|
3
|
+
distinct: () => void;
|
|
4
|
+
order_matters: () => void;
|
|
5
|
+
length_matters: () => void;
|
|
6
|
+
has_merges: () => void;
|
|
7
|
+
compress_correct: () => void;
|
|
8
|
+
isSymbol_terminal_only: () => void;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
package/fs/sul/test.f.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { assert, assertEq } from "../dev/module.f.js";
|
|
2
|
+
import { compress } from "./id/module.f.js";
|
|
3
|
+
import { encode, emptyEncodeState } from "./module.f.js";
|
|
4
|
+
const run = (bits) => {
|
|
5
|
+
const log = [];
|
|
6
|
+
const add = (l, r, m, isSymbol) => { log.push([l, r, m, isSymbol]); return null; };
|
|
7
|
+
const enc = encode(add);
|
|
8
|
+
let s = emptyEncodeState(null);
|
|
9
|
+
for (const b of bits) {
|
|
10
|
+
s = enc.push(b, s);
|
|
11
|
+
}
|
|
12
|
+
return [enc.end(s), log];
|
|
13
|
+
};
|
|
14
|
+
const id = (bits) => run(bits)[0];
|
|
15
|
+
const zeros = (n) => new Array(n).fill(0n);
|
|
16
|
+
export default {
|
|
17
|
+
deterministic: () => {
|
|
18
|
+
assertEq(id(zeros(16)), id(zeros(16)));
|
|
19
|
+
},
|
|
20
|
+
distinct: () => {
|
|
21
|
+
assert(id([0n]) !== id([1n]));
|
|
22
|
+
},
|
|
23
|
+
order_matters: () => {
|
|
24
|
+
assert(id([0n, 1n]) !== id([1n, 0n]));
|
|
25
|
+
},
|
|
26
|
+
length_matters: () => {
|
|
27
|
+
assert(id(zeros(8)) !== id(zeros(16)));
|
|
28
|
+
},
|
|
29
|
+
// Enough bits to trigger at least one hash merge
|
|
30
|
+
has_merges: () => {
|
|
31
|
+
const [, log] = run(zeros(16));
|
|
32
|
+
assert(log.length > 0);
|
|
33
|
+
},
|
|
34
|
+
// Every recorded merge satisfies merged === compress(left, right)
|
|
35
|
+
compress_correct: () => {
|
|
36
|
+
const [, log] = run(zeros(16));
|
|
37
|
+
for (const [l, r, m] of log) {
|
|
38
|
+
assertEq(m, compress(l, r));
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
// Patricia-trie internal merges are isSymbol=false; terminal merges are isSymbol=true
|
|
42
|
+
isSymbol_terminal_only: () => {
|
|
43
|
+
const [, log] = run(zeros(16));
|
|
44
|
+
assert(log.some(([, , , isSymbol]) => isSymbol));
|
|
45
|
+
assert(log.every(([l, r, m, isSymbol]) => !isSymbol || m === compress(l, r)));
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -150,7 +150,7 @@ const u16 = contains([0x0000, 0xFFFF]);
|
|
|
150
150
|
* ```ts
|
|
151
151
|
* const state: Utf16State = null;
|
|
152
152
|
* const word: U16 = 0xD83D; // High surrogate for 😀 emoji
|
|
153
|
-
* const [decodedCodePoints, newState] = utf16ByteToCodePointOp(state)
|
|
153
|
+
* const [decodedCodePoints, newState] = utf16ByteToCodePointOp(word, state);
|
|
154
154
|
* ```
|
|
155
155
|
*
|
|
156
156
|
* @example
|
|
@@ -158,10 +158,10 @@ const u16 = contains([0x0000, 0xFFFF]);
|
|
|
158
158
|
* ```ts
|
|
159
159
|
* const state: Utf16State = 0xD83D; // High surrogate already stored
|
|
160
160
|
* const word: U16 = 0xDC00; // Low surrogate for 😀 emoji
|
|
161
|
-
* const [decodedCodePoints, newState] = utf16ByteToCodePointOp(state)
|
|
161
|
+
* const [decodedCodePoints, newState] = utf16ByteToCodePointOp(word, state);
|
|
162
162
|
* ```
|
|
163
163
|
*/
|
|
164
|
-
const utf16ByteToCodePointOp = state =>
|
|
164
|
+
const utf16ByteToCodePointOp = (word, state) => {
|
|
165
165
|
if (!u16(word)) {
|
|
166
166
|
return [[0xffffffff], state];
|
|
167
167
|
}
|
|
@@ -233,19 +233,19 @@ const utf16EofToCodePointOp = (state) => [state === null ? empty : [state | erro
|
|
|
233
233
|
* ```ts
|
|
234
234
|
* // Example 1: Process a valid UTF-16 word
|
|
235
235
|
* const input1 = 0x0041 // 'A' (BMP code point)
|
|
236
|
-
* const result1 = utf16ByteOrEofToCodePointOp(null)
|
|
236
|
+
* const result1 = utf16ByteOrEofToCodePointOp(input1, null)
|
|
237
237
|
* console.log(result1) // [[0x0041], null]
|
|
238
238
|
* // Example 2: Process a high surrogate, followed by EOF
|
|
239
239
|
* const input2 = 0xD83D // High surrogate
|
|
240
|
-
* const result2 = utf16ByteOrEofToCodePointOp(null)
|
|
240
|
+
* const result2 = utf16ByteOrEofToCodePointOp(input2, null)
|
|
241
241
|
* console.log(result2) // [[], 0xD83D] (waiting for a low surrogate)
|
|
242
|
-
* const eofResult = utf16ByteOrEofToCodePointOp(0xD83D)
|
|
242
|
+
* const eofResult = utf16ByteOrEofToCodePointOp(null, 0xD83D)
|
|
243
243
|
* console.log(eofResult) // [[0xD83D | errorMask], null] (unpaired high surrogate)
|
|
244
244
|
* // Example 3: Handle EOF with no pending state
|
|
245
|
-
* const eofResult2 = utf16ByteOrEofToCodePointOp(null
|
|
245
|
+
* const eofResult2 = utf16ByteOrEofToCodePointOp(null, null)
|
|
246
246
|
* ```
|
|
247
247
|
*/
|
|
248
|
-
const utf16ByteOrEofToCodePointOp = state => input
|
|
248
|
+
const utf16ByteOrEofToCodePointOp = (input, state) => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(input, state);
|
|
249
249
|
/**
|
|
250
250
|
* Represents an end-of-file (EOF) indicator in a list of UTF-16 code units.
|
|
251
251
|
*
|
|
@@ -113,7 +113,7 @@ const utf8StateToError = (state) => {
|
|
|
113
113
|
* - A list of decoded Unicode code points or error codes.
|
|
114
114
|
* - The updated UTF-8 state.
|
|
115
115
|
*/
|
|
116
|
-
const utf8ByteToCodePointOp = (state) =>
|
|
116
|
+
const utf8ByteToCodePointOp = (byte, state) => {
|
|
117
117
|
if (byte < 0x00 || byte > 0xff) {
|
|
118
118
|
return [[errorMask], state];
|
|
119
119
|
}
|
|
@@ -184,7 +184,7 @@ const utf8EofToCodePointOp = (state) => [
|
|
|
184
184
|
* - A list of decoded Unicode code points or error codes.
|
|
185
185
|
* - The updated UTF-8 state.
|
|
186
186
|
*/
|
|
187
|
-
const utf8ByteOrEofToCodePointOp = (state) =>
|
|
187
|
+
const utf8ByteOrEofToCodePointOp = (input, state) => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(input, state);
|
|
188
188
|
/**
|
|
189
189
|
* A constant representing the end-of-file (EOF) marker for UTF-8 decoding.
|
|
190
190
|
*
|
|
@@ -56,6 +56,7 @@ export declare const unpack: (v: Vec) => Unpacked;
|
|
|
56
56
|
* Packs an unpacked representation back into a vector.
|
|
57
57
|
*/
|
|
58
58
|
export declare const pack: ({ length, uint }: Unpacked) => Vec;
|
|
59
|
+
export declare const unpackedUint: ({ uint }: Unpacked) => bigint;
|
|
59
60
|
type Norm = (len: bigint) => {
|
|
60
61
|
readonly a: bigint;
|
|
61
62
|
readonly b: bigint;
|
|
@@ -189,6 +190,17 @@ export declare const msb: BitOrder;
|
|
|
189
190
|
* @returns The resulting vector based on the provided bit order.
|
|
190
191
|
*/
|
|
191
192
|
export declare const u8ListToVec: ({ unpackConcat }: BitOrder) => (list: List<number>) => Vec;
|
|
193
|
+
/**
|
|
194
|
+
* Chunks an unpacked vector into fixed-size pieces of `n` bits using the provided bit order,
|
|
195
|
+
* returning each chunk as an unsigned integer.
|
|
196
|
+
* The last chunk may be smaller than `n` bits if the vector length is not a multiple of `n`.
|
|
197
|
+
*
|
|
198
|
+
* @param bitOrder The bit order for the conversion.
|
|
199
|
+
* @param n The chunk size in bits.
|
|
200
|
+
* @param u The unpacked vector to be chunked.
|
|
201
|
+
* @returns A thunk that produces a list of unsigned integers, each representing one chunk.
|
|
202
|
+
*/
|
|
203
|
+
export declare const uintChunkList: (bo: BitOrder) => (n: bigint) => (u: Unpacked) => Thunk<bigint>;
|
|
192
204
|
/**
|
|
193
205
|
* Chunks a bit vector into fixed-size pieces of `n` bits using the provided bit order.
|
|
194
206
|
* The last chunk may be smaller than `n` bits if the vector length is not a multiple of `n`.
|
|
@@ -198,7 +210,7 @@ export declare const u8ListToVec: ({ unpackConcat }: BitOrder) => (list: List<nu
|
|
|
198
210
|
* @param v The vector to be chunked.
|
|
199
211
|
* @returns A thunk that produces a list of bit vectors, each representing one chunk.
|
|
200
212
|
*/
|
|
201
|
-
export declare const chunkList: (
|
|
213
|
+
export declare const chunkList: (bo: BitOrder) => (n: bigint) => (v: Vec) => Thunk<Vec>;
|
|
202
214
|
/**
|
|
203
215
|
* Converts a bit vector to a list of unsigned 8-bit integers based on the provided bit order.
|
|
204
216
|
*
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @module
|
|
23
23
|
*/
|
|
24
24
|
import { bitLength, divUp, mask, max, min, xor } from "../bigint/module.f.js";
|
|
25
|
-
import { flip } from "../function/module.f.js";
|
|
25
|
+
import { flip, identity } from "../function/module.f.js";
|
|
26
26
|
import { fold, iterable, map } from "../list/module.f.js";
|
|
27
27
|
import { asBase, asNominal } from "../nominal/module.f.js";
|
|
28
28
|
import { repeat as mRepeat } from "../monoid/module.f.js";
|
|
@@ -97,6 +97,7 @@ export const unpack = (v) => ({
|
|
|
97
97
|
* Packs an unpacked representation back into a vector.
|
|
98
98
|
*/
|
|
99
99
|
export const pack = ({ length, uint }) => vec(length)(uint);
|
|
100
|
+
export const unpackedUint = ({ uint }) => uint;
|
|
100
101
|
/**
|
|
101
102
|
* Normalizes two vectors to the same length before applying a bigint reducer.
|
|
102
103
|
*/
|
|
@@ -234,19 +235,10 @@ export const u8ListToVec = ({ unpackConcat }) => (list) => {
|
|
|
234
235
|
}
|
|
235
236
|
return pack(result.reduce((p, c) => unpackConcat(c)(p), unpackEmpty));
|
|
236
237
|
};
|
|
237
|
-
|
|
238
|
-
* Chunks a bit vector into fixed-size pieces of `n` bits using the provided bit order.
|
|
239
|
-
* The last chunk may be smaller than `n` bits if the vector length is not a multiple of `n`.
|
|
240
|
-
*
|
|
241
|
-
* @param bitOrder The bit order for the conversion.
|
|
242
|
-
* @param n The chunk size in bits.
|
|
243
|
-
* @param v The vector to be chunked.
|
|
244
|
-
* @returns A thunk that produces a list of bit vectors, each representing one chunk.
|
|
245
|
-
*/
|
|
246
|
-
export const chunkList = ({ unpackSplit }) => (n) => {
|
|
238
|
+
const unpackChunkList = ({ unpackSplit }) => (n) => {
|
|
247
239
|
const divUpN2 = divUp(n << 1n);
|
|
248
|
-
return
|
|
249
|
-
if (
|
|
240
|
+
return u => {
|
|
241
|
+
if (u.length === 0n) {
|
|
250
242
|
return () => null;
|
|
251
243
|
}
|
|
252
244
|
const f = (stack) => () => {
|
|
@@ -254,7 +246,7 @@ export const chunkList = ({ unpackSplit }) => (n) => {
|
|
|
254
246
|
const [first, rest] = stack;
|
|
255
247
|
const { length } = first;
|
|
256
248
|
if (length <= n) {
|
|
257
|
-
return { first
|
|
249
|
+
return { first, tail: rest !== undefined ? f(rest) : null };
|
|
258
250
|
}
|
|
259
251
|
const aLength = divUpN2(length) * n;
|
|
260
252
|
const bLength = length - aLength;
|
|
@@ -265,9 +257,35 @@ export const chunkList = ({ unpackSplit }) => (n) => {
|
|
|
265
257
|
];
|
|
266
258
|
}
|
|
267
259
|
};
|
|
268
|
-
return f([
|
|
260
|
+
return f([u, undefined]);
|
|
269
261
|
};
|
|
270
262
|
};
|
|
263
|
+
const mappedChunkList = (g) => (f) => (bo) => (n) => {
|
|
264
|
+
const ucl = unpackChunkList(bo)(n);
|
|
265
|
+
const mf = map(f);
|
|
266
|
+
return i => mf(ucl(g(i)));
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Chunks an unpacked vector into fixed-size pieces of `n` bits using the provided bit order,
|
|
270
|
+
* returning each chunk as an unsigned integer.
|
|
271
|
+
* The last chunk may be smaller than `n` bits if the vector length is not a multiple of `n`.
|
|
272
|
+
*
|
|
273
|
+
* @param bitOrder The bit order for the conversion.
|
|
274
|
+
* @param n The chunk size in bits.
|
|
275
|
+
* @param u The unpacked vector to be chunked.
|
|
276
|
+
* @returns A thunk that produces a list of unsigned integers, each representing one chunk.
|
|
277
|
+
*/
|
|
278
|
+
export const uintChunkList = mappedChunkList((identity))(unpackedUint);
|
|
279
|
+
/**
|
|
280
|
+
* Chunks a bit vector into fixed-size pieces of `n` bits using the provided bit order.
|
|
281
|
+
* The last chunk may be smaller than `n` bits if the vector length is not a multiple of `n`.
|
|
282
|
+
*
|
|
283
|
+
* @param bitOrder The bit order for the conversion.
|
|
284
|
+
* @param n The chunk size in bits.
|
|
285
|
+
* @param v The vector to be chunked.
|
|
286
|
+
* @returns A thunk that produces a list of bit vectors, each representing one chunk.
|
|
287
|
+
*/
|
|
288
|
+
export const chunkList = mappedChunkList(unpack)(pack);
|
|
271
289
|
const vecToU8 = ({ unpackSplit }) => {
|
|
272
290
|
const unpackSplit8 = unpackSplit(8n);
|
|
273
291
|
return chunk => {
|
|
@@ -27,3 +27,4 @@ export type ToAsyncOperationMap<O extends Operation> = {
|
|
|
27
27
|
export type F<O extends Operation> = Pr<O, O[0]>;
|
|
28
28
|
export type Func<O extends Operation> = (_: Param<O>) => Effect<O, Return<O>>;
|
|
29
29
|
export type RestFunc<O extends Operation> = (..._: Param<O>) => Effect<O, Return<O>>;
|
|
30
|
+
export type ListEffect<O extends Operation, T> = Effect<O, readonly [T, ListEffect<O, T>] | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Vec } from
|
|
2
|
-
import { type RunInstance } from
|
|
3
|
-
import type { NodeOp } from
|
|
1
|
+
import { type Vec } from '../../../bit_vec/module.f.ts';
|
|
2
|
+
import { type RunInstance } from '../../mock/module.f.ts';
|
|
3
|
+
import type { NodeOp } from '../module.f.ts';
|
|
4
4
|
export type Dir = {
|
|
5
5
|
readonly [name in string]?: Dir | Vec;
|
|
6
6
|
};
|
|
@@ -12,7 +12,7 @@ export declare const logicalNot: Unary<boolean, boolean>;
|
|
|
12
12
|
export type Equal<T> = Binary<T, T, boolean>;
|
|
13
13
|
export declare const strictEqual: <T>(a: T) => (b: T) => boolean;
|
|
14
14
|
export type Scan<I, O> = (input: I) => readonly [O, Scan<I, O>];
|
|
15
|
-
export type StateScan<I, S, O> = (
|
|
15
|
+
export type StateScan<I, S, O> = (input: I, prior: S) => readonly [O, S];
|
|
16
16
|
export declare const stateScanToScan: <I, S, O>(op: StateScan<I, S, O>) => (prior: S) => Scan<I, O>;
|
|
17
17
|
export declare const foldToScan: <I, O>(fold: Fold<I, O>) => (prior: O) => Scan<I, O>;
|
|
18
18
|
export type Reduce<T> = Fold<T, T>;
|
|
@@ -3,7 +3,7 @@ export const concat = i => acc => `${acc}${i}`;
|
|
|
3
3
|
export const logicalNot = v => !v;
|
|
4
4
|
export const strictEqual = (a) => (b) => a === b;
|
|
5
5
|
export const stateScanToScan = (op) => (prior) => i => {
|
|
6
|
-
const [o, s] = op(prior)
|
|
6
|
+
const [o, s] = op(i, prior);
|
|
7
7
|
return [o, stateScanToScan(op)(s)];
|
|
8
8
|
};
|
|
9
9
|
export const foldToScan = (fold) => (prior) => i => {
|
|
@@ -146,7 +146,7 @@ const lengthList = list => () => {
|
|
|
146
146
|
};
|
|
147
147
|
const sum = reduce(addition)(0);
|
|
148
148
|
export const length = input => sum(lengthList(input));
|
|
149
|
-
const entryOperator = index =>
|
|
149
|
+
const entryOperator = (value, index) => [[index, value], index + 1];
|
|
150
150
|
export const entries = input => {
|
|
151
151
|
const o = entryOperator;
|
|
152
152
|
return stateScan(o)(0)(input);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Patricia trie for building content-addressed binary trees from sorted leaf sequences.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** Merges two child identities into a parent. Values first, storage last in both params and return. */
|
|
7
|
+
export type Create<S, T> = (a: T, b: T, storage: S) => readonly [T, S];
|
|
8
|
+
/** A leaf entry: `[sortKey, identity]`. The sort key is used only for XOR comparisons. */
|
|
9
|
+
export type Candidate<T> = readonly [bigint, T];
|
|
10
|
+
export type InternalState<T> = readonly Candidate<T>[];
|
|
11
|
+
/** Streaming state: `[storage, right-spine stack]`. */
|
|
12
|
+
export type State<S, T> = readonly [S, InternalState<T>];
|
|
13
|
+
export type PatriciaTrie<S, T> = {
|
|
14
|
+
/** Add one leaf. Merges any tightly-coupled stack candidates before pushing. */
|
|
15
|
+
readonly push: (c: Candidate<T>, state: State<S, T>) => State<S, T>;
|
|
16
|
+
/**
|
|
17
|
+
* Drain the stack right-to-left, returning the root identity and final storage.
|
|
18
|
+
* Returns `undefined` as the root if no leaves were pushed.
|
|
19
|
+
*/
|
|
20
|
+
readonly end: (state: State<S, T>) => readonly [T | undefined, S];
|
|
21
|
+
};
|
|
22
|
+
/** Creates a Patricia trie whose node merging is delegated to `create`. */
|
|
23
|
+
export declare const patriciaTrie: <S, T>(create: Create<S, T>) => PatriciaTrie<S, T>;
|
|
24
|
+
/** Constructs the initial state from a storage value. */
|
|
25
|
+
export declare const emptyState: <S>(storage: S) => readonly [S, readonly []];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Patricia trie for building content-addressed binary trees from sorted leaf sequences.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** Creates a Patricia trie whose node merging is delegated to `create`. */
|
|
7
|
+
export const patriciaTrie = (create) => ({
|
|
8
|
+
push: (c, [storage, stack]) => {
|
|
9
|
+
const [u] = c;
|
|
10
|
+
while (stack.length >= 2) {
|
|
11
|
+
const [rLeaf, rHash] = stack[stack.length - 1];
|
|
12
|
+
const [lLeaf, lHash] = stack[stack.length - 2];
|
|
13
|
+
if ((lLeaf ^ rLeaf) >= (rLeaf ^ u)) {
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
const [h, newS] = create(lHash, rHash, storage);
|
|
17
|
+
storage = newS;
|
|
18
|
+
stack = [...stack.slice(0, -2), [rLeaf, h]];
|
|
19
|
+
}
|
|
20
|
+
return [storage, [...stack, c]];
|
|
21
|
+
},
|
|
22
|
+
end: ([storage, stack]) => {
|
|
23
|
+
if (stack.length === 0) {
|
|
24
|
+
return [undefined, storage];
|
|
25
|
+
}
|
|
26
|
+
let h = stack[stack.length - 1][1];
|
|
27
|
+
for (let i = stack.length - 2; i >= 0; i--) {
|
|
28
|
+
const lHash = stack[i][1];
|
|
29
|
+
[h, storage] = create(lHash, h, storage);
|
|
30
|
+
}
|
|
31
|
+
return [h, storage];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
/** Constructs the initial state from a storage value. */
|
|
35
|
+
export const emptyState = (storage) => [storage, []];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { assert } from "../../dev/module.f.js";
|
|
2
|
+
import { emptyState, patriciaTrie } from "./module.f.js";
|
|
3
|
+
const combine = (a, b) => a * 1000n + b;
|
|
4
|
+
const create = (a, b, s) => {
|
|
5
|
+
const h = combine(a, b);
|
|
6
|
+
return [h, [...s, [a, b, h]]];
|
|
7
|
+
};
|
|
8
|
+
const { push, end } = patriciaTrie(create);
|
|
9
|
+
const leaves = ([, candidates]) => candidates.map(([leaf]) => leaf);
|
|
10
|
+
const runExample = (inputs, expectedLeaves, expectedNodeCounts) => {
|
|
11
|
+
let state = emptyState([]);
|
|
12
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
13
|
+
const x = inputs[i];
|
|
14
|
+
const prevCount = state[0].length;
|
|
15
|
+
state = push([x, x], state);
|
|
16
|
+
const actual = leaves(state);
|
|
17
|
+
assert(actual.length === expectedLeaves[i].length);
|
|
18
|
+
for (let j = 0; j < actual.length; j++) {
|
|
19
|
+
assert(actual[j] === expectedLeaves[i][j]);
|
|
20
|
+
}
|
|
21
|
+
const newNodes = state[0].slice(prevCount);
|
|
22
|
+
assert(newNodes.length === expectedNodeCounts[i]);
|
|
23
|
+
for (const [l, r, h] of newNodes) {
|
|
24
|
+
assert(h === combine(l, r));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const prevCount = state[0].length;
|
|
28
|
+
const [root, finalStorage] = end(state);
|
|
29
|
+
const finalNodes = finalStorage.slice(prevCount);
|
|
30
|
+
assert(finalNodes.length === expectedLeaves[expectedLeaves.length - 1].length - 1);
|
|
31
|
+
assert(root !== undefined);
|
|
32
|
+
for (const [l, r, h] of finalNodes) {
|
|
33
|
+
assert(h === combine(l, r));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const empty = () => {
|
|
37
|
+
const [root, storage] = end(emptyState([]));
|
|
38
|
+
assert(storage.length === 0);
|
|
39
|
+
assert(root === undefined);
|
|
40
|
+
};
|
|
41
|
+
const singleLeaf = () => {
|
|
42
|
+
const state = push([42n, 42n], emptyState([]));
|
|
43
|
+
assert(state[0].length === 0);
|
|
44
|
+
assert(leaves(state).length === 1);
|
|
45
|
+
assert(leaves(state)[0] === 42n);
|
|
46
|
+
const [root, finalStorage] = end(state);
|
|
47
|
+
assert(finalStorage.length === 0);
|
|
48
|
+
assert(root === 42n);
|
|
49
|
+
};
|
|
50
|
+
const twoLeaves = () => {
|
|
51
|
+
const s1 = push([7n, 7n], emptyState([]));
|
|
52
|
+
const prevCount = s1[0].length;
|
|
53
|
+
const s2 = push([3n, 3n], s1);
|
|
54
|
+
assert(s2[0].slice(prevCount).length === 0);
|
|
55
|
+
assert(leaves(s2).length === 2);
|
|
56
|
+
const prevCount2 = s2[0].length;
|
|
57
|
+
const [root, finalStorage] = end(s2);
|
|
58
|
+
const finalNodes = finalStorage.slice(prevCount2);
|
|
59
|
+
assert(finalNodes.length === 1);
|
|
60
|
+
assert(finalNodes[0][0] === 7n);
|
|
61
|
+
assert(finalNodes[0][1] === 3n);
|
|
62
|
+
assert(finalNodes[0][2] === combine(7n, 3n));
|
|
63
|
+
assert(root === combine(7n, 3n));
|
|
64
|
+
};
|
|
65
|
+
// example.md — descending
|
|
66
|
+
// merges happen at: step 2 (1), 3 (1), 4 (1), 7 (2), 8 (2), A (1), C (2), F (1)
|
|
67
|
+
const descending = () => runExample([
|
|
68
|
+
249n, 242n, 227n, 200n,
|
|
69
|
+
179n, 166n, 163n, 159n,
|
|
70
|
+
119n, 110n, 89n, 73n,
|
|
71
|
+
39n, 23n, 16n, 14n,
|
|
72
|
+
], [
|
|
73
|
+
[249n],
|
|
74
|
+
[249n, 242n],
|
|
75
|
+
[242n, 227n],
|
|
76
|
+
[227n, 200n],
|
|
77
|
+
[200n, 179n],
|
|
78
|
+
[200n, 179n, 166n],
|
|
79
|
+
[200n, 179n, 166n, 163n],
|
|
80
|
+
[200n, 163n, 159n],
|
|
81
|
+
[159n, 119n],
|
|
82
|
+
[159n, 119n, 110n],
|
|
83
|
+
[159n, 110n, 89n],
|
|
84
|
+
[159n, 110n, 89n, 73n],
|
|
85
|
+
[159n, 73n, 39n],
|
|
86
|
+
[159n, 73n, 39n, 23n],
|
|
87
|
+
[159n, 73n, 39n, 23n, 16n],
|
|
88
|
+
[159n, 73n, 39n, 16n, 14n],
|
|
89
|
+
], [0, 0, 1, 1, 1, 0, 0, 2, 2, 0, 1, 0, 2, 0, 0, 1]);
|
|
90
|
+
// example.md — ascending (same values, reversed)
|
|
91
|
+
// merges happen at: step 3 (2), 4 (1), 6 (1), 8 (3), B (1), C (2)
|
|
92
|
+
const ascending = () => runExample([
|
|
93
|
+
14n, 16n, 23n, 39n,
|
|
94
|
+
73n, 89n, 110n, 119n,
|
|
95
|
+
159n, 163n, 166n, 179n,
|
|
96
|
+
200n, 227n, 242n, 249n,
|
|
97
|
+
], [
|
|
98
|
+
[14n],
|
|
99
|
+
[14n, 16n],
|
|
100
|
+
[14n, 16n, 23n],
|
|
101
|
+
[23n, 39n],
|
|
102
|
+
[39n, 73n],
|
|
103
|
+
[39n, 73n, 89n],
|
|
104
|
+
[39n, 89n, 110n],
|
|
105
|
+
[39n, 89n, 110n, 119n],
|
|
106
|
+
[119n, 159n],
|
|
107
|
+
[119n, 159n, 163n],
|
|
108
|
+
[119n, 159n, 163n, 166n],
|
|
109
|
+
[119n, 159n, 166n, 179n],
|
|
110
|
+
[119n, 179n, 200n],
|
|
111
|
+
[119n, 179n, 200n, 227n],
|
|
112
|
+
[119n, 179n, 200n, 227n, 242n],
|
|
113
|
+
[119n, 179n, 200n, 227n, 242n, 249n],
|
|
114
|
+
], [0, 0, 0, 2, 1, 0, 1, 0, 3, 0, 0, 1, 2, 0, 0, 0]);
|
|
115
|
+
export default {
|
|
116
|
+
empty,
|
|
117
|
+
singleLeaf,
|
|
118
|
+
twoLeaves,
|
|
119
|
+
descending,
|
|
120
|
+
ascending
|
|
121
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Type } from '../module.f.ts';
|
|
2
|
+
import { type Result as ValidateResult, type Validate } from '../validate/module.f.ts';
|
|
3
|
+
export type { Path, ValidationError } from '../validate/module.f.ts';
|
|
4
|
+
/** Parse result: either the freshly constructed typed value or a `ValidationError`. */
|
|
5
|
+
export type Result<T extends Type> = ValidateResult<T>;
|
|
6
|
+
/** A function that parses an unknown value into the schema `T`. */
|
|
7
|
+
export type Parse<T extends Type> = Validate<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a parser function for the given RTTI schema.
|
|
10
|
+
*
|
|
11
|
+
* The returned function takes an unknown value and returns either
|
|
12
|
+
* `['ok', newValue]` containing a freshly constructed value matching the schema,
|
|
13
|
+
* or `['error', { path, message }]` describing the failure location.
|
|
14
|
+
*
|
|
15
|
+
* @param rtti - A schema `Type`: a `Thunk` for tag-based schemas, or a `Const`
|
|
16
|
+
* (primitive literal, tuple, or struct) for exact-value schemas.
|
|
17
|
+
* @returns A `Parse<T>` function.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const p = parse(array(number))
|
|
22
|
+
* p([1, 2, 3]) // ['ok', [1, 2, 3]] (a new array)
|
|
23
|
+
* p([1, 'two']) // ['error', { path: ['1'], message: 'unexpected value' }]
|
|
24
|
+
*
|
|
25
|
+
* // tuples are closed: extra elements are dropped
|
|
26
|
+
* parse([number, number] as const)([1, 2, 3]) // ['ok', [1, 2]]
|
|
27
|
+
*
|
|
28
|
+
* // structs drop undeclared keys
|
|
29
|
+
* parse({ a: number } as const)({ a: 1, b: 2 }) // ['ok', { a: 1 }]
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const parse: <T extends Type>(rtti: T) => Parse<T>;
|