functionalscript 0.0.592 → 0.1.594
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 +3 -3
- package/README.md +1 -0
- package/com/cpp/{module.f.cjs → module.f.mjs} +22 -21
- package/com/cpp/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.mjs +9 -0
- package/com/cs/{module.f.cjs → module.f.mjs} +20 -19
- package/com/cs/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cs/testlib.f.mjs +10 -0
- package/com/rust/{module.f.cjs → module.f.mjs} +37 -35
- package/com/rust/{test.f.cjs → test.f.mjs} +2 -2
- package/com/rust/testlib.f.mjs +10 -0
- package/com/test/{build.f.cjs → build.f.mjs} +6 -6
- package/com/test/{build.cjs → build.mjs} +16 -8
- package/com/types/{module.f.cjs → module.f.mjs} +9 -8
- package/com/types/{testlib.f.cjs → testlib.f.mjs} +2 -2
- package/commonjs/build/{module.f.cjs → module.f.mjs} +23 -23
- package/commonjs/build/{test.f.cjs → test.f.mjs} +13 -12
- package/commonjs/module/function/{module.f.cjs → module.f.mjs} +4 -4
- package/commonjs/module/{module.f.cjs → module.f.mjs} +3 -5
- package/commonjs/module.f.mjs +11 -0
- package/commonjs/{module.cjs → module.mjs} +8 -6
- package/commonjs/package/dependencies/{module.f.cjs → module.f.mjs} +5 -5
- package/commonjs/package/dependencies/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/package/{module.f.cjs → module.f.mjs} +7 -6
- package/commonjs/package/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/path/{module.f.cjs → module.f.mjs} +15 -14
- package/commonjs/path/{test.f.cjs → test.f.mjs} +16 -14
- package/commonjs/{test.cjs → test.mjs} +4 -4
- package/dev/{module.f.cjs → module.f.mjs} +1 -1
- package/dev/module.mjs +5 -3
- package/dev/test/{module.f.cjs → module.f.mjs} +21 -9
- package/dev/{test.f.cjs → test.f.mjs} +1 -1
- package/dev/test.mjs +1 -1
- package/djs/{module.f.cjs → module.f.mjs} +18 -15
- package/djs/parser/{module.f.cjs → module.f.mjs} +29 -28
- package/djs/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/djs/{test.f.cjs → test.f.mjs} +7 -5
- package/djs/tokenizer/{module.f.cjs → module.f.mjs} +19 -18
- package/djs/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/fsc/{module.f.cjs → module.f.mjs} +17 -16
- package/fsc/{test.f.cjs → test.f.mjs} +6 -4
- package/fsm/{module.f.cjs → module.f.mjs} +28 -24
- package/fsm/{test.f.cjs → test.f.mjs} +13 -9
- package/html/{module.f.cjs → module.f.mjs} +16 -13
- package/html/{test.f.cjs → test.f.mjs} +5 -5
- package/index.f.mjs +45 -35
- package/issues/README.md +15 -0
- package/js/tokenizer/{module.f.cjs → module.f.mjs} +52 -51
- package/js/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/json/{module.f.cjs → module.f.mjs} +18 -17
- package/json/parser/{module.f.cjs → module.f.mjs} +27 -26
- package/json/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/json/serializer/{module.f.cjs → module.f.mjs} +12 -12
- package/json/serializer/{test.f.cjs → test.f.mjs} +4 -3
- package/json/{test.f.cjs → test.f.mjs} +6 -4
- package/json/tokenizer/{module.f.cjs → module.f.mjs} +16 -15
- package/json/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/jsr.json +1 -1
- package/nodejs/version/main.mjs +5 -0
- package/nodejs/version/{module.f.cjs → module.f.mjs} +2 -2
- package/nodejs/version/{test.f.cjs → test.f.mjs} +5 -5
- package/package.json +3 -3
- package/prime_field/{module.f.cjs → module.f.mjs} +6 -5
- package/prime_field/{test.f.cjs → test.f.mjs} +3 -2
- package/secp/{module.f.cjs → module.f.mjs} +7 -6
- package/secp/{test.f.cjs → test.f.mjs} +6 -6
- package/sha2/{module.f.cjs → module.f.mjs} +5 -5
- package/sha2/{test.f.cjs → test.f.mjs} +7 -6
- package/text/ascii/{module.f.cjs → module.f.mjs} +3 -3
- package/text/ascii/test.f.mjs +14 -0
- package/text/{module.f.cjs → module.f.mjs} +6 -6
- package/text/sgr/{module.f.cjs → module.f.mjs} +1 -1
- package/text/{test.f.cjs → test.f.mjs} +5 -4
- package/text/utf16/{module.f.cjs → module.f.mjs} +16 -14
- package/text/utf16/{test.f.cjs → test.f.mjs} +7 -6
- package/text/utf8/{module.f.cjs → module.f.mjs} +11 -11
- package/text/utf8/{test.f.cjs → test.f.mjs} +6 -5
- package/tsconfig.json +2 -2
- package/types/array/{module.f.cjs → module.f.mjs} +2 -2
- package/types/array/{test.f.cjs → test.f.mjs} +5 -4
- package/types/bigfloat/{module.f.cjs → module.f.mjs} +3 -3
- package/types/bigfloat/{test.f.cjs → test.f.mjs} +3 -2
- package/types/bigint/{module.f.cjs → module.f.mjs} +8 -7
- package/types/bigint/{test.f.cjs → test.f.mjs} +3 -2
- package/types/btree/find/{module.f.cjs → module.f.mjs} +12 -12
- package/types/btree/find/{test.f.cjs → test.f.mjs} +11 -9
- package/types/btree/{module.f.cjs → module.f.mjs} +7 -12
- package/types/btree/remove/{module.f.cjs → module.f.mjs} +17 -16
- package/types/btree/remove/{test.f.cjs → test.f.mjs} +9 -7
- package/types/btree/set/{module.f.cjs → module.f.mjs} +9 -9
- package/types/btree/set/{test.f.cjs → test.f.mjs} +8 -6
- package/types/btree/{test.f.cjs → test.f.mjs} +23 -20
- package/types/btree/types/{module.f.cjs → module.f.mjs} +1 -1
- package/types/byte_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/byte_set/{test.f.cjs → test.f.mjs} +8 -7
- package/types/function/compare/{module.f.cjs → module.f.mjs} +2 -2
- package/types/function/compare/{test.f.cjs → test.f.mjs} +3 -2
- package/types/function/{module.f.cjs → module.f.mjs} +1 -5
- package/types/function/operator/{module.f.cjs → module.f.mjs} +1 -1
- package/types/function/{test.f.cjs → test.f.mjs} +4 -2
- package/types/list/{module.f.cjs → module.f.mjs} +12 -12
- package/types/list/{test.f.cjs → test.f.mjs} +13 -11
- package/types/map/{module.f.cjs → module.f.mjs} +21 -18
- package/types/map/{test.f.cjs → test.f.mjs} +5 -4
- package/types/nibble_set/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nibble_set/{test.f.cjs → test.f.mjs} +4 -3
- package/types/nullable/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nullable/{test.f.cjs → test.f.mjs} +2 -2
- package/types/number/module.f.mjs +26 -0
- package/types/number/{test.f.cjs → test.f.mjs} +3 -2
- package/types/object/{module.f.cjs → module.f.mjs} +6 -6
- package/types/object/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range/{module.f.cjs → module.f.mjs} +1 -1
- package/types/range/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range_map/{module.f.cjs → module.f.mjs} +16 -15
- package/types/range_map/{test.f.cjs → test.f.mjs} +35 -33
- package/types/result/{module.f.cjs → module.f.mjs} +1 -1
- package/types/result/{module.cjs → module.mjs} +3 -3
- package/types/sorted_list/{module.f.cjs → module.f.mjs} +11 -10
- package/types/sorted_list/{test.f.cjs → test.f.mjs} +14 -10
- package/types/sorted_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/sorted_set/{test.f.cjs → test.f.mjs} +14 -10
- package/types/string/{module.f.cjs → module.f.mjs} +8 -7
- package/types/string/{test.f.cjs → test.f.mjs} +5 -3
- package/types/string_set/{module.f.cjs → module.f.mjs} +15 -10
- package/types/string_set/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.cjs +0 -6
- package/com/cs/testlib.f.cjs +0 -6
- package/com/module.f.cjs +0 -6
- package/com/rust/testlib.f.cjs +0 -6
- package/commonjs/module.f.cjs +0 -20
- package/nodejs/module.f.cjs +0 -4
- package/nodejs/version/main.cjs +0 -6
- package/text/ascii/test.f.cjs +0 -12
- package/types/number/module.f.cjs +0 -24
- package/types/object/test.html +0 -9
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import parser from './module.f.mjs'
|
|
2
|
+
import tokenizer, * as tokenizerT from '../tokenizer/module.f.mjs'
|
|
3
|
+
import list from '../../types/list/module.f.mjs'
|
|
4
|
+
const { toArray } = list
|
|
5
|
+
import json from '../module.f.mjs'
|
|
6
|
+
import o from '../../types/object/module.f.mjs'
|
|
7
|
+
const { sort } = o
|
|
8
|
+
import encoding from '../../text/utf16/module.f.mjs'
|
|
7
9
|
|
|
8
|
-
/** @type {(s: string) => readonly
|
|
10
|
+
/** @type {(s: string) => readonly tokenizerT.JsonToken[]} */
|
|
9
11
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
10
12
|
|
|
11
13
|
const stringify = json.stringify(sort)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
export default {
|
|
14
16
|
valid: [
|
|
15
17
|
() => {
|
|
16
18
|
const tokenList = tokenizeString('null')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import list, * as List from '../../types/list/module.f.mjs'
|
|
2
2
|
const { flat, reduce, empty } = list
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import object, * as O from '../../types/object/module.f.mjs'
|
|
4
|
+
import operator, * as Operator from '../../types/function/operator/module.f.mjs'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @template T
|
|
@@ -36,10 +36,10 @@ const operator = require('../../types/function/operator/module.f.cjs')
|
|
|
36
36
|
|
|
37
37
|
const jsonStringify = JSON.stringify
|
|
38
38
|
|
|
39
|
-
/** @type {(_: string) =>
|
|
39
|
+
/** @type {(_: string) => List.List<string>} */
|
|
40
40
|
const stringSerialize = input => [jsonStringify(input)]
|
|
41
41
|
|
|
42
|
-
/** @type {(_: number) =>
|
|
42
|
+
/** @type {(_: number) => List.List<string>} */
|
|
43
43
|
const numberSerialize = input => [jsonStringify(input)]
|
|
44
44
|
|
|
45
45
|
const nullSerialize = ['null']
|
|
@@ -48,18 +48,18 @@ const trueSerialize = ['true']
|
|
|
48
48
|
|
|
49
49
|
const falseSerialize = ['false']
|
|
50
50
|
|
|
51
|
-
/** @type {(_: boolean) =>
|
|
51
|
+
/** @type {(_: boolean) => List.List<string>} */
|
|
52
52
|
const boolSerialize = value => value ? trueSerialize : falseSerialize
|
|
53
53
|
|
|
54
54
|
const comma = [',']
|
|
55
55
|
|
|
56
|
-
/** @type {
|
|
56
|
+
/** @type {Operator.Reduce<List.List<string>>} */
|
|
57
57
|
const joinOp = b => prior => flat([prior, comma, b])
|
|
58
58
|
|
|
59
|
-
/** @type {(input:
|
|
59
|
+
/** @type {(input: List.List<List.List<string>>) => List.List<string>} */
|
|
60
60
|
const join = reduce(joinOp)(empty)
|
|
61
61
|
|
|
62
|
-
/** @type {(open: string) => (close: string) => (input:
|
|
62
|
+
/** @type {(open: string) => (close: string) => (input: List.List<List.List<string>>) => List.List<string>} */
|
|
63
63
|
const wrap = open => close => {
|
|
64
64
|
const seqOpen = [open]
|
|
65
65
|
const seqClose = [close]
|
|
@@ -72,12 +72,12 @@ const arrayWrap = wrap('[')(']')
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* @template T
|
|
75
|
-
* @typedef {
|
|
75
|
+
* @typedef {O.Entry<Unknown<T>>} Entry<T>
|
|
76
76
|
*/
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* @template T
|
|
80
|
-
* @typedef {(
|
|
80
|
+
* @typedef {(List.List<Entry<T>>)} Entries<T>
|
|
81
81
|
*/
|
|
82
82
|
|
|
83
83
|
/**
|
|
@@ -85,7 +85,7 @@ const arrayWrap = wrap('[')(']')
|
|
|
85
85
|
* @typedef {(entries: Entries<T>) => Entries<T>} MapEntries<T>
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
export default {
|
|
89
89
|
/** @readonly */
|
|
90
90
|
objectWrap,
|
|
91
91
|
/** @readonly */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _, * as T from './module.f.mjs'
|
|
2
|
+
import list from '../../types/list/module.f.mjs'
|
|
3
|
+
const { toArray } = list
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export default {
|
|
5
6
|
arrayWrap: [
|
|
6
7
|
() => {
|
|
7
8
|
const result = JSON.stringify(toArray(_.arrayWrap(null)))
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import json from './module.f.mjs'
|
|
2
|
+
import o from '../types/object/module.f.mjs'
|
|
3
|
+
const { sort } = o
|
|
4
|
+
import f from '../types/function/module.f.mjs'
|
|
5
|
+
const { identity } = f
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
export default {
|
|
6
8
|
setProperty: () => {
|
|
7
9
|
if (json.setProperty("Hello")([])({}) !== "Hello") { throw 'error' }
|
|
8
10
|
},
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import operator, * as Operator from '../../types/function/operator/module.f.mjs'
|
|
2
|
+
import list, * as List from '../../types/list/module.f.mjs'
|
|
3
3
|
const { empty, flat, stateScan } = list
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
import bf from '../../types/bigfloat/module.f.mjs'
|
|
5
|
+
const { multiply } = bf
|
|
6
|
+
import jsTokenizer, * as jsTokenizerT from '../../js/tokenizer/module.f.mjs'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @typedef {|
|
|
9
10
|
* {readonly kind: 'true' | 'false' | 'null' } |
|
|
10
11
|
* {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' } |
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* jsTokenizerT.StringToken |
|
|
13
|
+
* jsTokenizerT.NumberToken |
|
|
14
|
+
* jsTokenizerT.ErrorToken
|
|
14
15
|
* } JsonToken
|
|
15
16
|
*/
|
|
16
17
|
|
|
@@ -22,11 +23,11 @@ const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
|
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* @typedef {|
|
|
25
|
-
*
|
|
26
|
+
* jsTokenizerT.JsToken | null
|
|
26
27
|
* } ScanInput
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
|
-
/** @type {(input:
|
|
30
|
+
/** @type {(input: jsTokenizerT.JsToken) => List.List<JsonToken>} */
|
|
30
31
|
const mapToken = input =>
|
|
31
32
|
{
|
|
32
33
|
switch(input.kind)
|
|
@@ -48,7 +49,7 @@ const mapToken = input =>
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
/** @type {(input: ScanInput) => readonly [
|
|
52
|
+
/** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
|
|
52
53
|
const parseDefaultState = input =>
|
|
53
54
|
{
|
|
54
55
|
if (input === null) return [empty, { kind: 'def'}]
|
|
@@ -59,7 +60,7 @@ const parseDefaultState = input =>
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
/** @type {(input: ScanInput) => readonly [
|
|
63
|
+
/** @type {(input: ScanInput) => readonly [List.List<JsonToken>, ScanState]} */
|
|
63
64
|
const parseMinusState = input =>
|
|
64
65
|
{
|
|
65
66
|
if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def'}]
|
|
@@ -71,7 +72,7 @@ const parseMinusState = input =>
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
/** @type {
|
|
75
|
+
/** @type {Operator.StateScan<ScanInput, ScanState, List.List<JsonToken>>} */
|
|
75
76
|
const scanToken = state => input => {
|
|
76
77
|
switch(state.kind)
|
|
77
78
|
{
|
|
@@ -80,15 +81,15 @@ const scanToken = state => input => {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
/** @type {(input:
|
|
84
|
+
/** @type {(input: List.List<number>) => List.List<JsonToken>} */
|
|
84
85
|
const tokenize = input =>
|
|
85
86
|
{
|
|
86
|
-
/** @type {
|
|
87
|
+
/** @type {List.List<ScanInput>} */
|
|
87
88
|
const jsTokens = jsTokenizer.tokenize(input)
|
|
88
89
|
return flat(stateScan(scanToken)({ kind: 'def' })(list.concat(jsTokens)([null])))
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
export default {
|
|
92
93
|
/** @readonly */
|
|
93
94
|
tokenize
|
|
94
95
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import tokenizer, * as tokenizerT from './module.f.mjs'
|
|
2
|
+
import list from '../../types/list/module.f.mjs'
|
|
3
|
+
const { toArray, countdown } = list
|
|
4
|
+
import djs from '../../djs/module.f.mjs'
|
|
5
|
+
import o from '../../types/object/module.f.mjs'
|
|
6
|
+
const { sort } = o
|
|
7
|
+
import encoding from '../../text/utf16/module.f.mjs'
|
|
6
8
|
|
|
7
|
-
/** @type {(s: string) => readonly
|
|
9
|
+
/** @type {(s: string) => readonly tokenizerT.JsonToken[]} */
|
|
8
10
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
9
11
|
|
|
10
12
|
const stringify = djs.stringify(sort)
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
export default {
|
|
13
15
|
json: [
|
|
14
16
|
() => {
|
|
15
17
|
const result = tokenizeString('')
|
package/jsr.json
CHANGED
|
@@ -26,7 +26,7 @@ const { stringify, parse } = JSON
|
|
|
26
26
|
|
|
27
27
|
/** @type {<T>(node: Node<T>) => readonly[T, T]} */
|
|
28
28
|
const version = ({ child_process, fs }) => {
|
|
29
|
-
const version = `0.
|
|
29
|
+
const version = `0.1.${child_process.execSync('git log --oneline').toString().split('\n').length - 1}`
|
|
30
30
|
const f = (/** @type {string} */jsonFile) => {
|
|
31
31
|
const file = `${jsonFile}.json`
|
|
32
32
|
return fs.writeFileSync(
|
|
@@ -45,7 +45,7 @@ const version = ({ child_process, fs }) => {
|
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
export default {
|
|
49
49
|
/** @readonly */
|
|
50
50
|
version,
|
|
51
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import _, * as T from './module.f.mjs'
|
|
2
2
|
|
|
3
3
|
const x = {
|
|
4
4
|
"name": "functionalscript",
|
|
@@ -38,7 +38,7 @@ const x = {
|
|
|
38
38
|
|
|
39
39
|
const e = '{\n' +
|
|
40
40
|
' "name": "functionalscript",\n' +
|
|
41
|
-
' "version": "0.
|
|
41
|
+
' "version": "0.1.2",\n' +
|
|
42
42
|
' "description": "FunctionalScript is a functional subset of JavaScript",\n' +
|
|
43
43
|
' "main": "module.f.cjs",\n' +
|
|
44
44
|
' "scripts": {\n' +
|
|
@@ -72,13 +72,13 @@ const e = '{\n' +
|
|
|
72
72
|
' }\n' +
|
|
73
73
|
'}'
|
|
74
74
|
|
|
75
|
-
/** @type {(s: string) =>
|
|
75
|
+
/** @type {(s: string) => T.Buffer} */
|
|
76
76
|
const buffer = s => ({
|
|
77
77
|
toString: () => s
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
/** @type {
|
|
80
|
+
export default () => {
|
|
81
|
+
/** @type {T.Node<string>} */
|
|
82
82
|
const node = {
|
|
83
83
|
child_process: { execSync: () => buffer("123\n456\n") },
|
|
84
84
|
fs: {
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.594",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "index.f.mjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"tsc": "tsc",
|
|
8
8
|
"test": "tsc && npm run test-only",
|
|
9
9
|
"index": "node ./dev/index.mjs",
|
|
10
|
-
"version": "node ./nodejs/version/main.
|
|
10
|
+
"version": "node ./nodejs/version/main.mjs",
|
|
11
11
|
"test-only": "node --trace-uncaught ./dev/test.mjs",
|
|
12
|
-
"comtest": "node ./com/test/build.
|
|
12
|
+
"comtest": "node ./com/test/build.mjs"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as Operator from '../types/function/operator/module.f.mjs'
|
|
2
|
+
import bi from '../types/bigint/module.f.mjs'
|
|
3
|
+
const { scalar_mul } = bi
|
|
3
4
|
|
|
4
|
-
/** @typedef {
|
|
5
|
+
/** @typedef {Operator.Reduce<bigint>} Reduce */
|
|
5
6
|
|
|
6
|
-
/** @typedef {
|
|
7
|
+
/** @typedef {Operator.Unary<bigint, bigint>} Unary*/
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @typedef {{
|
|
@@ -75,7 +76,7 @@ const prime_field = p => {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
export default {
|
|
79
80
|
prime_field,
|
|
80
81
|
/** @type {(f: PrimeField) => (a: bigint) => bigint|null} */
|
|
81
82
|
sqrt: ({p, mul, pow }) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
const { prime_field, sqrt } = _
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export default {
|
|
4
5
|
prime_field_test: () => {
|
|
5
6
|
const p = 0xffffffff_ffffffff_ffffffff_ffffffff_ffffffff_ffffffff_fffffffe_fffffc2fn;
|
|
6
7
|
const f = prime_field(p)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as op from '../types/function/operator/module.f.mjs'
|
|
2
|
+
import pf, * as pfT from '../prime_field/module.f.mjs'
|
|
3
|
+
import bi from '../types/bigint/module.f.mjs'
|
|
4
|
+
const { scalar_mul } = bi
|
|
4
5
|
const { prime_field, sqrt } = pf
|
|
5
6
|
|
|
6
7
|
/** @typedef {readonly[bigint, bigint]} Point2D */
|
|
@@ -18,8 +19,8 @@ const { prime_field, sqrt } = pf
|
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* @typedef {{
|
|
21
|
-
* readonly pf:
|
|
22
|
-
* readonly nf:
|
|
22
|
+
* readonly pf: pfT.PrimeField
|
|
23
|
+
* readonly nf: pfT.PrimeField
|
|
23
24
|
* readonly y2: (x: bigint) => bigint
|
|
24
25
|
* readonly y: (x: bigint) => bigint|null
|
|
25
26
|
* readonly neg: (a: Point) => Point
|
|
@@ -83,7 +84,7 @@ const curve = ({ p, a: [a0, a1], n }) => {
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
export default {
|
|
87
88
|
curve,
|
|
88
89
|
/** @type {(a: Point) => (b: Point) => boolean} */
|
|
89
90
|
eq: a => b => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
const { curve, secp256k1, secp192r1, eq } =
|
|
1
|
+
import mt, * as mT from './module.f.mjs'
|
|
2
|
+
const { curve, secp256k1, secp192r1, eq } = mt
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default {
|
|
5
5
|
test: () => {
|
|
6
|
-
/** @type {(c:
|
|
6
|
+
/** @type {(c: mT.Init) => void} */
|
|
7
7
|
const test_curve = c => {
|
|
8
8
|
const { g } = c
|
|
9
9
|
const { mul, neg, pf: { abs }, y: yf, nf: { p: n } } = curve(c)
|
|
10
|
-
/** @type {(p:
|
|
10
|
+
/** @type {(p: mT.Point) => void} */
|
|
11
11
|
const point_check = p => {
|
|
12
12
|
if (p === null) { throw 'null' }
|
|
13
13
|
const [x, y] = p
|
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
|
17
17
|
}
|
|
18
18
|
point_check(g)
|
|
19
19
|
point_check(neg(g))
|
|
20
|
-
/** @type {(p:
|
|
20
|
+
/** @type {(p: mT.Point) => void} */
|
|
21
21
|
const test_mul = p => {
|
|
22
22
|
if (mul(p)(0n) !== null) { throw 'O' }
|
|
23
23
|
if (mul(p)(1n) !== p) { throw 'p' }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import array, * as arrayT from '../types/array/module.f.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {{
|
|
@@ -7,9 +7,9 @@ const array = require('../types/array/module.f.cjs')
|
|
|
7
7
|
* }} HashInput
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
/** @typedef {
|
|
10
|
+
/** @typedef {arrayT.Array8<number>} Hash8 */
|
|
11
11
|
|
|
12
|
-
/** @typedef {
|
|
12
|
+
/** @typedef {arrayT.Array16<number>} Array16 */
|
|
13
13
|
|
|
14
14
|
/** @type {(input: number) => (pos: number) => number} */
|
|
15
15
|
const appendOneWithZeros = input => pos => (input >> pos << pos) | (1 << pos)
|
|
@@ -73,7 +73,7 @@ const smallSigma0 = smallSigma(7)(18)(3)
|
|
|
73
73
|
|
|
74
74
|
const smallSigma1 = smallSigma(17)(19)(10)
|
|
75
75
|
|
|
76
|
-
/** @type {(a:
|
|
76
|
+
/** @type {(a: arrayT.Array4<number>) => number} */
|
|
77
77
|
const wi = ([a0, a1, a2, a3]) => (smallSigma1(a0) + a1 + smallSigma0(a2) + a3) | 0
|
|
78
78
|
|
|
79
79
|
/** @type {(w: Array16) => Array16} */
|
|
@@ -194,7 +194,7 @@ const compress256 = compress(init256)
|
|
|
194
194
|
|
|
195
195
|
const compress224 = compress(init224)
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
export default {
|
|
198
198
|
/** @readonly */
|
|
199
199
|
padding,
|
|
200
200
|
/** @readonly */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
import json, * as jsonT from '../json/module.f.mjs'
|
|
3
|
+
import o from '../types/object/module.f.mjs'
|
|
4
|
+
const { sort } = o
|
|
5
|
+
import list from '../types/list/module.f.mjs'
|
|
5
6
|
|
|
6
7
|
/** @type {(a: number) => number} */
|
|
7
8
|
const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
|
|
@@ -9,7 +10,7 @@ const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
|
|
|
9
10
|
/** @type {(a: number) => string} */
|
|
10
11
|
const toHexString = x => toU32(x).toString(16).padStart(8, '0')
|
|
11
12
|
|
|
12
|
-
/** @type {(a: readonly
|
|
13
|
+
/** @type {(a: readonly jsonT.Unknown[]) => string} */
|
|
13
14
|
const stringify = a => json.stringify(sort)(a)
|
|
14
15
|
|
|
15
16
|
// {
|
|
@@ -32,7 +33,7 @@ const stringify = a => json.stringify(sort)(a)
|
|
|
32
33
|
// console.log(result.map(toHexString))
|
|
33
34
|
// }
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
export default {
|
|
36
37
|
empty: {
|
|
37
38
|
sha256: () => {
|
|
38
39
|
const hash = _.computeSha256([])(0)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import _range, * as Range from '../../types/range/module.f.mjs'
|
|
2
2
|
|
|
3
3
|
/** @type {(s: string) => (i: number) => number} */
|
|
4
4
|
const at = s => i => {
|
|
@@ -10,7 +10,7 @@ const at = s => i => {
|
|
|
10
10
|
/** @type {(s: string) => number} */
|
|
11
11
|
const one = s => at(s)(0)
|
|
12
12
|
|
|
13
|
-
/** @type {(s: string) =>
|
|
13
|
+
/** @type {(s: string) => Range.Range} */
|
|
14
14
|
const range = s => {
|
|
15
15
|
const f = at(s)
|
|
16
16
|
const f0 = f(0)
|
|
@@ -18,7 +18,7 @@ const range = s => {
|
|
|
18
18
|
return [f0, f(1)]
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export default {
|
|
22
22
|
/** @readonly */
|
|
23
23
|
one,
|
|
24
24
|
/** @readonly */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
const { range } = _
|
|
3
|
+
import json from '../../json/module.f.mjs'
|
|
4
|
+
import o from '../../types/object/module.f.mjs'
|
|
5
|
+
const { sort } = o
|
|
6
|
+
|
|
7
|
+
const stringify = json.stringify(sort)
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
range: () => {
|
|
11
|
+
const r = stringify(range("A"))
|
|
12
|
+
if (r !== '[65,65]') { throw r }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import list, * as List from '../types/list/module.f.mjs'
|
|
2
2
|
const { flatMap } = list
|
|
3
3
|
|
|
4
4
|
/** @typedef {ItemThunk|ItemArray} Block */
|
|
5
5
|
|
|
6
6
|
/** @typedef {readonly Item[]} ItemArray */
|
|
7
7
|
|
|
8
|
-
/** @typedef {() =>
|
|
8
|
+
/** @typedef {() => List.List<Item>} ItemThunk */
|
|
9
9
|
|
|
10
10
|
/** @typedef {string|ItemArray|ItemThunk} Item */
|
|
11
11
|
|
|
12
|
-
/** @type {(indent: string) => (text: Block) =>
|
|
12
|
+
/** @type {(indent: string) => (text: Block) => List.List<string>} */
|
|
13
13
|
const flat = indent => {
|
|
14
14
|
|
|
15
|
-
/** @type {(prefix: string) => (text: Block) =>
|
|
15
|
+
/** @type {(prefix: string) => (text: Block) => List.List<string>} */
|
|
16
16
|
const f = prefix => {
|
|
17
|
-
/** @type {(item: Item) =>
|
|
17
|
+
/** @type {(item: Item) => List.List<string>} */
|
|
18
18
|
const g = item => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item)
|
|
19
19
|
return flatMap(g)
|
|
20
20
|
}
|
|
@@ -25,7 +25,7 @@ const flat = indent => {
|
|
|
25
25
|
/** @type {(type: string) => (name: string) => (body: Block) => Block} */
|
|
26
26
|
const curly = type => name => body => [`${type} ${name}`, '{', body, '}']
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
export default {
|
|
29
29
|
/** @readonly */
|
|
30
30
|
flat,
|
|
31
31
|
/** @readonly */
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _, * as T from './module.f.mjs'
|
|
2
|
+
import string from '../types/string/module.f.mjs'
|
|
3
|
+
const { join } = string
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
/** @type {
|
|
5
|
+
export default () => {
|
|
6
|
+
/** @type {T.Block} */
|
|
6
7
|
const text = [
|
|
7
8
|
'a',
|
|
8
9
|
'b',
|