functionalscript 0.0.343 → 0.0.350
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/node.js.yml +2 -0
- package/.github/workflows/npm-publish.yml +1 -1
- package/LANGUAGE.md +40 -0
- package/commonjs/README.md +14 -8
- package/commonjs/build/{index.js → main.f.js} +14 -8
- package/commonjs/build/{test.js → test.f.js} +6 -6
- package/commonjs/main.f.js +20 -0
- package/commonjs/module/function/{index.js → main.f.js} +1 -1
- package/commonjs/module/{index.js → main.f.js} +3 -1
- package/commonjs/package/dependencies/{index.js → main.f.js} +3 -3
- package/commonjs/package/dependencies/{test.js → test.f.js} +1 -1
- package/commonjs/package/{index.js → main.f.js} +8 -3
- package/commonjs/package/{test.js → test.f.js} +2 -2
- package/commonjs/path/{index.js → main.f.js} +3 -3
- package/commonjs/path/{test.js → test.f.js} +7 -7
- package/dev/{index.js → main.f.js} +0 -0
- package/html/{index.js → main.f.js} +3 -4
- package/html/{test.js → test.f.js} +1 -1
- package/io/commonjs/{index.js → main.js} +3 -3
- package/io/commonjs/test.js +2 -2
- package/io/nodejs/version/{index.js → main.js} +0 -0
- package/io/result/{index.js → main.js} +1 -1
- package/json/{index.js → main.f.js} +31 -29
- package/json/{test.js → test.f.js} +3 -3
- package/json/tokenizer/{index.js → main.f.js} +3 -3
- package/json/tokenizer/{test.js → test.f.js} +4 -4
- package/main.f.js +14 -0
- package/package.json +6 -5
- package/sha2/{index.js → main.f.js} +1 -1
- package/sha2/{test.js → test.f.js} +4 -4
- package/test.f.js +78 -0
- package/types/array/{index.js → main.f.js} +1 -2
- package/types/array/{test.js → test.f.js} +3 -3
- package/types/btree/find/{index.js → main.f.js} +4 -4
- package/types/btree/find/{test.js → test.f.js} +7 -7
- package/types/btree/main.f.js +40 -0
- package/types/btree/remove/{index.js → main.f.js} +6 -6
- package/types/btree/remove/{test.js → test.f.js} +6 -6
- package/types/btree/set/{index.js → main.f.js} +4 -4
- package/types/btree/set/{test.js → test.f.js} +5 -5
- package/types/btree/{test.js → test.f.js} +11 -11
- package/types/btree/{index.js → types/main.f.js} +1 -33
- package/types/function/compare/{index.js → main.f.js} +1 -1
- package/types/function/compare/{test.js → test.f.js} +1 -1
- package/types/function/{index.js → main.f.js} +4 -0
- package/types/function/operator/{index.js → main.f.js} +0 -0
- package/types/list/{index.js → main.f.js} +3 -3
- package/types/list/{test.js → test.f.js} +4 -4
- package/types/main.f.js +20 -0
- package/types/map/{index.js → main.f.js} +10 -9
- package/types/map/{test.js → test.f.js} +3 -3
- package/types/object/{index.js → main.f.js} +2 -2
- package/types/object/{test.js → test.f.js} +1 -1
- package/types/option/{index.js → main.f.js} +0 -0
- package/types/range/{index.js → main.f.js} +0 -0
- package/types/range/{test.js → test.f.js} +1 -1
- package/types/result/{index.js → main.f.js} +0 -0
- package/types/{stringSet/index.js → stringset/main.f.js} +9 -10
- package/types/{stringSet/test.js → stringset/test.f.js} +1 -1
- package/commonjs/index.js +0 -11
- package/index.js +0 -76
- package/test.js +0 -125
package/LANGUAGE.md
CHANGED
|
@@ -206,3 +206,43 @@ const f = () => x // < invalid
|
|
|
206
206
|
### 9.7. Block
|
|
207
207
|
|
|
208
208
|
[Block](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block)
|
|
209
|
+
|
|
210
|
+
## 10. Generators
|
|
211
|
+
|
|
212
|
+
For compatibility reason, FunctionalScript allows to create generators as implementation of `[Symbol.iterator]` function. However, it doesn't allow to read the `[Symbol.iterator]` property. For example
|
|
213
|
+
|
|
214
|
+
This code is allowed
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
/** @type {<T>(list: List<T>) => Iterable<T>} */
|
|
218
|
+
const iterable = list => ({
|
|
219
|
+
*[Symbol.iterator]() {
|
|
220
|
+
let i = list
|
|
221
|
+
while (true) {
|
|
222
|
+
const r = next(i)
|
|
223
|
+
if (r === undefined) { return }
|
|
224
|
+
yield r.first
|
|
225
|
+
i = r.tail
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The following code is not allowed, because `iterator` is a mutated object by design in JavaScript.
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
const it = [0, 1, 2][Symbol.iterator] //< compilation error.
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Use `Iterable` instead of `Iterator`.
|
|
238
|
+
|
|
239
|
+
```js
|
|
240
|
+
const x = () => {
|
|
241
|
+
const a = [0, 1, 2] // iterable
|
|
242
|
+
let sum = 0;
|
|
243
|
+
for (let i in a) {
|
|
244
|
+
sum = sum + i
|
|
245
|
+
}
|
|
246
|
+
return sum;
|
|
247
|
+
}
|
|
248
|
+
```
|
package/commonjs/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Common.js
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## Package
|
|
4
|
+
|
|
5
|
+
[package/index.js](package/index.js)
|
|
5
6
|
|
|
7
|
+
```ts
|
|
6
8
|
// A dictionary of packages.
|
|
7
9
|
//
|
|
8
10
|
// A package contains a dictionary of dependencies and a dictionary of files.
|
|
@@ -25,9 +27,13 @@ type Package = {
|
|
|
25
27
|
// returns source of the file.
|
|
26
28
|
readonly file: (localFileId: string) => string | undefined
|
|
27
29
|
}
|
|
30
|
+
```
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
## Module
|
|
30
33
|
|
|
34
|
+
[module/index.js](module/index.js)
|
|
35
|
+
|
|
36
|
+
```ts
|
|
31
37
|
// A module map is a dictionary of modules.
|
|
32
38
|
//
|
|
33
39
|
// A module is a compiled and initialized source file.
|
|
@@ -62,9 +68,13 @@ type ModuleId = {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
const moduleIdToString: (moduleId: ModuleId) => string;
|
|
71
|
+
```
|
|
65
72
|
|
|
66
|
-
|
|
73
|
+
## Build
|
|
67
74
|
|
|
75
|
+
[build/index.js](build/index.js)
|
|
76
|
+
|
|
77
|
+
```ts
|
|
68
78
|
type BuildConfig<M> = {
|
|
69
79
|
readonly packageGet: PackageGet
|
|
70
80
|
readonly moduleMapInterface: ModuleMapInterface<M>
|
|
@@ -81,8 +91,4 @@ type BuildState<M> = {
|
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
const getOrBuild: <M>(buildConfig: BuildConfig<M>) => readonly[ModuleState, M];
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
94
|
```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const package_ = require('../package/
|
|
2
|
-
const module_ = require('../module/
|
|
3
|
-
const function_ = require('../module/function/
|
|
4
|
-
const map = require('../../types/map/
|
|
5
|
-
const object = require('../../types/object/
|
|
6
|
-
const path = require('../path/
|
|
7
|
-
const stringSet = require('../../types/
|
|
1
|
+
const package_ = require('../package/main.f.js')
|
|
2
|
+
const module_ = require('../module/main.f.js')
|
|
3
|
+
const function_ = require('../module/function/main.f.js')
|
|
4
|
+
const map = require('../../types/map/main.f.js')
|
|
5
|
+
const object = require('../../types/object/main.f.js')
|
|
6
|
+
const path = require('../path/main.f.js')
|
|
7
|
+
const stringSet = require('../../types/stringset/main.f.js')
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @template M
|
|
@@ -36,7 +36,13 @@ const notFound = moduleMap => [['error', ['file not found']], moduleMap]
|
|
|
36
36
|
const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
37
37
|
/** @typedef {typeof moduleMapInterface extends module_.MapInterface<infer M> ? M : never} M */
|
|
38
38
|
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* @type {(buildSet: stringSet.StringSet) =>
|
|
41
|
+
* (moduleId: module_.Id) =>
|
|
42
|
+
* (source: string) =>
|
|
43
|
+
* (moduleMap: M) =>
|
|
44
|
+
* Result<M>}
|
|
45
|
+
*/
|
|
40
46
|
const build = buildSet => moduleId => {
|
|
41
47
|
const moduleIdStr = module_.idToString(moduleId)
|
|
42
48
|
const buildSet1 = stringSet.set(moduleIdStr)(buildSet)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const _ = require('./
|
|
2
|
-
const map = require('../../types/map/
|
|
3
|
-
const module_ = require('../module/
|
|
4
|
-
const function_ = require('../module/function/
|
|
5
|
-
const result = require('../../types/result/
|
|
6
|
-
const package_ = require('../package/
|
|
1
|
+
const _ = require('./main.f.js')
|
|
2
|
+
const map = require('../../types/map/main.f.js')
|
|
3
|
+
const module_ = require('../module/main.f.js')
|
|
4
|
+
const function_ = require('../module/function/main.f.js')
|
|
5
|
+
const result = require('../../types/result/main.f.js')
|
|
6
|
+
const package_ = require('../package/main.f.js')
|
|
7
7
|
|
|
8
8
|
/** @type {{ readonly [k in string]?: result.Result<function_.Function_, unknown> }} */
|
|
9
9
|
const compileMap = {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @typedef {(packageName: string) => PackageMap|Package|undefined} PackageMap */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {readonly[
|
|
5
|
+
* string,
|
|
6
|
+
* PackageMap,
|
|
7
|
+
* (fileName: string) => string|undefined
|
|
8
|
+
* ]} Package
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
/** @readonly */
|
|
13
|
+
build: require('./build/main.f.js'),
|
|
14
|
+
/** @readonly */
|
|
15
|
+
module: require('./module/main.f.js'),
|
|
16
|
+
/** @readonly */
|
|
17
|
+
package: require('./package/main.f.js'),
|
|
18
|
+
/** @readonly */
|
|
19
|
+
path: require('./path/main.f.js'),
|
|
20
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* An IO interface for creating and running module functions.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
const result = require('../../../types/result/
|
|
5
|
+
const result = require('../../../types/result/main.f.js')
|
|
6
6
|
|
|
7
7
|
/** @typedef {<M>(require: Require<M>) => (prior: M) => Result<M>} Function_ */
|
|
8
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const object = require('../../types/object/
|
|
1
|
+
const object = require('../../types/object/main.f.js')
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @template M
|
|
@@ -52,6 +52,8 @@ const dir = id => {
|
|
|
52
52
|
const idToString = id => `${id.package}/${id.path.join('/')}`
|
|
53
53
|
|
|
54
54
|
module.exports = {
|
|
55
|
+
/** @readonly */
|
|
56
|
+
function: require('./function/main.f.js'),
|
|
55
57
|
/** @readonly */
|
|
56
58
|
dir,
|
|
57
59
|
/** @readonly */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const json = require('../../../json/
|
|
2
|
-
const
|
|
1
|
+
const json = require('../../../json/main.f.js')
|
|
2
|
+
const list = require('../../../types/list/main.f.js')
|
|
3
3
|
|
|
4
4
|
/** @typedef {readonly[string, string]} DependencyJson */
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ const isDependencyJson = ([, v]) => typeof v === 'string'
|
|
|
14
14
|
const isDependenciesJson = j => {
|
|
15
15
|
if (j === undefined) { return true }
|
|
16
16
|
if (!json.isObject(j)) { return false }
|
|
17
|
-
return
|
|
17
|
+
return list.every(list.map(isDependencyJson)(Object.entries(j)))
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const json = require('../../json/
|
|
2
|
-
const dependencies = require('./dependencies/
|
|
1
|
+
const json = require('../../json/main.f.js')
|
|
2
|
+
const dependencies = require('./dependencies/main.f.js')
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {{
|
|
@@ -25,9 +25,14 @@ const isPackageJson = j => {
|
|
|
25
25
|
* }} Package
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* @note Current package has an empty string '' as a packageId.
|
|
30
|
+
* @typedef {(packageId: string) => Package | undefined} Get
|
|
31
|
+
*/
|
|
29
32
|
|
|
30
33
|
module.exports = {
|
|
34
|
+
/** @readonly */
|
|
35
|
+
dependencies,
|
|
31
36
|
/** @readonly */
|
|
32
37
|
isPackageJson,
|
|
33
38
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const list = require("../../types/list/
|
|
2
|
-
const package_ = require("../package/
|
|
3
|
-
const module_ = require("../module/
|
|
1
|
+
const list = require("../../types/list/main.f.js")
|
|
2
|
+
const package_ = require("../package/main.f.js")
|
|
3
|
+
const module_ = require("../module/main.f.js")
|
|
4
4
|
|
|
5
5
|
/** @typedef {readonly string[]} Items */
|
|
6
6
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const _ = require('./
|
|
2
|
-
const { todo } = require('../../dev/
|
|
3
|
-
const json = require('../../json/
|
|
4
|
-
const { identity } = require('../../types/function/
|
|
5
|
-
const object = require('../../types/object/
|
|
6
|
-
const { at } = require('../../types/object/
|
|
7
|
-
const package_ = require('../package/
|
|
1
|
+
const _ = require('./main.f.js')
|
|
2
|
+
const { todo } = require('../../dev/main.f.js')
|
|
3
|
+
const json = require('../../json/main.f.js')
|
|
4
|
+
const { identity } = require('../../types/function/main.f.js')
|
|
5
|
+
const object = require('../../types/object/main.f.js')
|
|
6
|
+
const { at } = require('../../types/object/main.f.js')
|
|
7
|
+
const package_ = require('../package/main.f.js')
|
|
8
8
|
|
|
9
9
|
/** @type {(g: json.Unknown|undefined) => string} */
|
|
10
10
|
const stringify = g => {
|
|
File without changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const list = require('../types/list/
|
|
2
|
-
const object = require('../types/object/
|
|
3
|
-
const operator = require('../types/function/
|
|
4
|
-
const { compose } = require('../types/function/index.js')
|
|
1
|
+
const list = require('../types/list/main.f.js')
|
|
2
|
+
const object = require('../types/object/main.f.js')
|
|
3
|
+
const { operator, compose } = require('../types/function/main.f.js')
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @typedef {|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { tryCatch } = require('../result/
|
|
2
|
-
const { unwrap } = require('../../types/result/
|
|
3
|
-
const moduleFunction = require('../../commonjs/module/function/
|
|
1
|
+
const { tryCatch } = require('../result/main.js')
|
|
2
|
+
const { unwrap } = require('../../types/result/main.f.js')
|
|
3
|
+
const moduleFunction = require('../../commonjs/module/function/main.f.js')
|
|
4
4
|
|
|
5
5
|
/** @type {(f: Function) => moduleFunction.Function_} */
|
|
6
6
|
const build = f => immutableRequire => mutableData => {
|
package/io/commonjs/test.js
CHANGED
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const object = require('../types/object/
|
|
3
|
-
const
|
|
4
|
-
const { compose } = require('../types/function/
|
|
1
|
+
const list = require('../types/list/main.f.js')
|
|
2
|
+
const object = require('../types/object/main.f.js')
|
|
3
|
+
const operator = require('../types/function/operator/main.f.js')
|
|
4
|
+
const { compose } = require('../types/function/main.f.js')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {{
|
|
@@ -13,11 +13,11 @@ const { compose } = require('../types/function/index.js')
|
|
|
13
13
|
|
|
14
14
|
/** @typedef {Object|boolean|string|number|null|Array} Unknown */
|
|
15
15
|
|
|
16
|
-
/** @type {(value: Unknown) => (path:
|
|
16
|
+
/** @type {(value: Unknown) => (path: list.List<string>) => (src: Unknown|undefined) => Unknown} */
|
|
17
17
|
const setProperty = value => {
|
|
18
|
-
/** @type {(path:
|
|
18
|
+
/** @type {(path: list.List<string>) => (src: Unknown|undefined) => Unknown} */
|
|
19
19
|
const f = path => src => {
|
|
20
|
-
const result =
|
|
20
|
+
const result = list.next(path)
|
|
21
21
|
if (result === undefined) { return value }
|
|
22
22
|
const srcObject = (src === undefined || src === null || typeof src !== 'object' || src instanceof Array) ? {} : src
|
|
23
23
|
const { first, tail } = result
|
|
@@ -26,10 +26,10 @@ const setProperty = value => {
|
|
|
26
26
|
return f
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/** @type {(_: string) =>
|
|
29
|
+
/** @type {(_: string) => list.List<string>} */
|
|
30
30
|
const stringSerialize = input => [JSON.stringify(input)]
|
|
31
31
|
|
|
32
|
-
/** @type {(_: number) =>
|
|
32
|
+
/** @type {(_: number) => list.List<string>} */
|
|
33
33
|
const numberSerialize = input => [JSON.stringify(input)]
|
|
34
34
|
|
|
35
35
|
const nullSerialize = ['null']
|
|
@@ -38,46 +38,46 @@ const trueSerialize = ['true']
|
|
|
38
38
|
|
|
39
39
|
const falseSerialize = ['false']
|
|
40
40
|
|
|
41
|
-
/** @type {(_: boolean) =>
|
|
41
|
+
/** @type {(_: boolean) => list.List<string>} */
|
|
42
42
|
const boolSerialize = value => value ? trueSerialize : falseSerialize
|
|
43
43
|
|
|
44
44
|
const colon = [':']
|
|
45
45
|
const comma = [',']
|
|
46
46
|
|
|
47
|
-
/** @type {
|
|
48
|
-
const joinOp = b => prior =>
|
|
47
|
+
/** @type {operator.Fold<list.List<string>>} */
|
|
48
|
+
const joinOp = b => prior => list.flat([prior, comma, b])
|
|
49
49
|
|
|
50
|
-
/** @type {(input:
|
|
51
|
-
const join =
|
|
50
|
+
/** @type {(input: list.List<list.List<string>>) => list.List<string>} */
|
|
51
|
+
const join = list.fold(joinOp)([])
|
|
52
52
|
|
|
53
|
-
/** @type {(open: string) => (close: string) => (input:
|
|
54
|
-
const
|
|
53
|
+
/** @type {(open: string) => (close: string) => (input: list.List<list.List<string>>) => list.List<string>} */
|
|
54
|
+
const wrap = open => close => {
|
|
55
55
|
const seqOpen = [open]
|
|
56
56
|
const seqClose = [close]
|
|
57
|
-
return input =>
|
|
57
|
+
return input => list.flat([seqOpen, join(input), seqClose])
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const
|
|
60
|
+
const objectWrap = wrap('{')('}')
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const arrayWrap = wrap('[')(']')
|
|
63
63
|
|
|
64
64
|
/** @typedef {object.Entry<Unknown>} Entry*/
|
|
65
65
|
|
|
66
|
-
/** @typedef {(
|
|
66
|
+
/** @typedef {(list.List<Entry>)} Entries */
|
|
67
67
|
|
|
68
68
|
/** @typedef {(entries: Entries) => Entries} MapEntries */
|
|
69
69
|
|
|
70
|
-
/** @type {(mapEntries: MapEntries) => (value: Unknown) =>
|
|
70
|
+
/** @type {(mapEntries: MapEntries) => (value: Unknown) => list.List<string>} */
|
|
71
71
|
const serialize = sort => {
|
|
72
|
-
/** @type {(kv: readonly[string, Unknown]) =>
|
|
73
|
-
const propertySerialize = ([k, v]) =>
|
|
72
|
+
/** @type {(kv: readonly[string, Unknown]) => list.List<string>} */
|
|
73
|
+
const propertySerialize = ([k, v]) => list.flat([
|
|
74
74
|
stringSerialize(k),
|
|
75
75
|
colon,
|
|
76
76
|
f(v)
|
|
77
77
|
])
|
|
78
|
-
/** @type {(object: Object) =>
|
|
79
|
-
const objectSerialize = input =>
|
|
80
|
-
/** @type {(value: Unknown) =>
|
|
78
|
+
/** @type {(object: Object) => list.List<string>} */
|
|
79
|
+
const objectSerialize = input => objectWrap(list.map(propertySerialize)(sort(Object.entries(input))))
|
|
80
|
+
/** @type {(value: Unknown) => list.List<string>} */
|
|
81
81
|
const f = value => {
|
|
82
82
|
switch (typeof value) {
|
|
83
83
|
case 'boolean': { return boolSerialize(value) }
|
|
@@ -90,8 +90,8 @@ const serialize = sort => {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
/** @type {(input: Array) =>
|
|
94
|
-
const arraySerialize = compose(
|
|
93
|
+
/** @type {(input: Array) => list.List<string>} */
|
|
94
|
+
const arraySerialize = compose(list.map(f))(arrayWrap)
|
|
95
95
|
return f
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -101,7 +101,7 @@ const serialize = sort => {
|
|
|
101
101
|
*
|
|
102
102
|
* @type {(mapEntries: MapEntries) => (value: Unknown) => string}
|
|
103
103
|
*/
|
|
104
|
-
const stringify = sort => compose(serialize(sort))(
|
|
104
|
+
const stringify = sort => compose(serialize(sort))(list.join(''))
|
|
105
105
|
|
|
106
106
|
/** @type {(value: string) => Unknown} */
|
|
107
107
|
const parse = JSON.parse
|
|
@@ -110,6 +110,8 @@ const parse = JSON.parse
|
|
|
110
110
|
const isObject = value => typeof value === 'object' && value !== null && !(value instanceof Array)
|
|
111
111
|
|
|
112
112
|
module.exports = {
|
|
113
|
+
/** @readonly */
|
|
114
|
+
tokenizer: require('./tokenizer/main.f.js'),
|
|
113
115
|
/** @readonly */
|
|
114
116
|
setProperty,
|
|
115
117
|
/** @readonly */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const json = require('./
|
|
2
|
-
const { sort } = require('../types/object/
|
|
3
|
-
const { identity } = require('../types/function/
|
|
1
|
+
const json = require('./main.f.js')
|
|
2
|
+
const { sort } = require('../types/object/main.f.js')
|
|
3
|
+
const { identity } = require('../types/function/main.f.js')
|
|
4
4
|
|
|
5
5
|
if (json.setProperty("Hello")([])({}) !== "Hello") { throw 'error' }
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const operator = require('../../types/function/operator/
|
|
2
|
-
const list = require('../../types/list/
|
|
3
|
-
const range = require('../../types/range/
|
|
1
|
+
const operator = require('../../types/function/operator/main.f.js')
|
|
2
|
+
const list = require('../../types/list/main.f.js')
|
|
3
|
+
const range = require('../../types/range/main.f.js')
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const tokenizer = require('./
|
|
2
|
-
const list = require('../../types/list/
|
|
3
|
-
const json = require('../
|
|
4
|
-
const { sort } = require('../../types/object/
|
|
1
|
+
const tokenizer = require('./main.f.js')
|
|
2
|
+
const list = require('../../types/list/main.f.js')
|
|
3
|
+
const json = require('../main.f.js')
|
|
4
|
+
const { sort } = require('../../types/object/main.f.js')
|
|
5
5
|
|
|
6
6
|
/** @type {(s: string) => readonly tokenizer.JsonToken[]} */
|
|
7
7
|
const tokenizeString = s => list.toArray(tokenizer.tokenize(list.toCharCodes(s)))
|
package/main.f.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/** @readonly */
|
|
3
|
+
commonjs: require('./commonjs/main.f.js'),
|
|
4
|
+
/** @readonly */
|
|
5
|
+
dev: require('./dev/main.f.js'),
|
|
6
|
+
/** @readonly */
|
|
7
|
+
html: require('./html/main.f.js'),
|
|
8
|
+
/** @readonly */
|
|
9
|
+
json: require('./json/main.f.js'),
|
|
10
|
+
/** @readonly */
|
|
11
|
+
sha2: require('./sha2/main.f.js'),
|
|
12
|
+
/** @readonly */
|
|
13
|
+
types: require('./types/main.f.js'),
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.350",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "main.f.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"tsc": "tsc",
|
|
8
8
|
"test": "tsc && npm run test-only",
|
|
9
|
-
"
|
|
9
|
+
"version": "node ./io/nodejs/version/main.js",
|
|
10
|
+
"test-only": "node --trace-uncaught ./test.f.js"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
},
|
|
29
30
|
"homepage": "https://github.com/functionalscript/functionalscript#readme",
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"typescript": "^4.7.
|
|
32
|
+
"@types/node": "^18.0.0",
|
|
33
|
+
"typescript": "^4.7.4"
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const _ = require('./
|
|
2
|
-
const json = require('../json/
|
|
3
|
-
const { sort } = require('../types/object/
|
|
4
|
-
const list = require('../types/list/
|
|
1
|
+
const _ = require('./main.f.js')
|
|
2
|
+
const json = require('../json/main.f.js')
|
|
3
|
+
const { sort } = require('../types/object/main.f.js')
|
|
4
|
+
const list = require('../types/list/main.f.js')
|
|
5
5
|
|
|
6
6
|
/** @type {(a: number) => number} */
|
|
7
7
|
const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
|