functionalscript 0.0.355 → 0.0.358
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/deno.yml +17 -0
- package/commonjs/path/README.md +17 -0
- package/commonjs/path/main.f.js +18 -11
- package/package.json +1 -1
- package/test.f.js +1 -0
- package/text/encoding/main.f.js +40 -0
- package/text/encoding/test.f.js +119 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: Deno CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v2
|
|
14
|
+
- uses: denoland/setup-deno@v1
|
|
15
|
+
with:
|
|
16
|
+
deno-version: v1.x
|
|
17
|
+
- run: deno run --unstable --compat --allow-read --allow-env ./test.f.js
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Path
|
|
2
|
+
|
|
3
|
+
## Simplified Common.js
|
|
4
|
+
|
|
5
|
+
A path should be disambiguous.
|
|
6
|
+
|
|
7
|
+
Path limitations:
|
|
8
|
+
|
|
9
|
+
- Accepted file extensions: `.f.js`, `.json`.
|
|
10
|
+
- A file path should be fully specified. For example `../package/dependencies/test.f.js`.
|
|
11
|
+
- A package name can't contain `/`. For example
|
|
12
|
+
- `functionalscript/main.f.js` is allowed.
|
|
13
|
+
- `functionalscript/functionalscript/main.f.js` is not allowed.
|
|
14
|
+
|
|
15
|
+
`package.json` limitations:
|
|
16
|
+
|
|
17
|
+
- Only GitHub packages can be referenced. In the future, we may add generic Git repositories.
|
package/commonjs/path/main.f.js
CHANGED
|
@@ -98,11 +98,15 @@ const mapDependency = d => ([external, internal]) => {
|
|
|
98
98
|
* (items: list.List<string>) =>
|
|
99
99
|
* Path|undefined}
|
|
100
100
|
*/
|
|
101
|
-
const parseGlobal =
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
const parseGlobal = dependencies =>
|
|
102
|
+
{
|
|
103
|
+
const filterMap = list.filterMap(mapDependency(dependencies))
|
|
104
|
+
return dir => items => {
|
|
105
|
+
const v = variants([undefined, items])
|
|
106
|
+
const r = list.first(undefined)(filterMap(v))
|
|
107
|
+
if (r === undefined) { return undefined }
|
|
108
|
+
return { package: r[0], items: list.toArray(r[1]), dir }
|
|
109
|
+
}
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
/**
|
|
@@ -112,12 +116,15 @@ const parseGlobal = d => dir => items => {
|
|
|
112
116
|
* (path: string) =>
|
|
113
117
|
* Path|undefined }
|
|
114
118
|
*/
|
|
115
|
-
const parse = packageId => dependencies =>
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
const parse = packageId => dependencies => {
|
|
120
|
+
const pg = parseGlobal(dependencies)
|
|
121
|
+
return local => path => {
|
|
122
|
+
const parsed = parseLocal(local)(path)
|
|
123
|
+
if (parsed === undefined) { return undefined }
|
|
124
|
+
const {external, dir, items } = parsed
|
|
125
|
+
if (!external) { return { package: packageId, items, dir } }
|
|
126
|
+
return pg(dir)(items)
|
|
127
|
+
}
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
/**
|
package/package.json
CHANGED
package/test.f.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const result = require('../../types/result/main.f.js')
|
|
2
|
+
const list = require('../../types/list/main.f.js')
|
|
3
|
+
const { ok, error } = result
|
|
4
|
+
|
|
5
|
+
/** @typedef {result.Result<number,number>} Utf8Result */
|
|
6
|
+
|
|
7
|
+
/** @type {(input:number) => list.List<Utf8Result>} */
|
|
8
|
+
const codePointToUtf8 = input =>
|
|
9
|
+
{
|
|
10
|
+
if (input >= 0x0000 && input <= 0x007f) { return [ok(input & 0x7f)] }
|
|
11
|
+
if (input >= 0x0080 && input <= 0x07ff) { return [ok(input >> 6 | 0xc0), ok(input & 0x3f | 0x80)] }
|
|
12
|
+
if (input >= 0x0800 && input <= 0xffff) { return [ok(input >> 12 | 0xe0), ok(input >> 6 & 0x3f | 0x80), ok(input & 0x3f | 0x80)] }
|
|
13
|
+
if (input >= 0x10000 && input <= 0x10ffff) { return [ok(input >> 18 | 0xf0), ok(input >> 12 & 0x3f | 0x80), ok(input >> 6 & 0x3f | 0x80), ok(input & 0x3f | 0x80)] }
|
|
14
|
+
return [error(input)]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** @type {(input:number) => list.List<Utf8Result>} */
|
|
18
|
+
const codePointToUtf16 = input =>
|
|
19
|
+
{
|
|
20
|
+
if (input >= 0x0000 && input <= 0xd7ff || input >= 0xe000 && input <= 0xffff) { return [ok(input >> 8), ok(input & 0xff)] }
|
|
21
|
+
if (input >= 0x010000 && input <= 0x10ffff) {
|
|
22
|
+
const high = ((input - 0x10000) >> 10) + 0xd800
|
|
23
|
+
const low = ((input - 0x10000) & 0x3ff) + 0xdc00
|
|
24
|
+
return [ok(high >> 8), ok(high & 0xff), ok(low >> 8), ok(low & 0xff)]
|
|
25
|
+
}
|
|
26
|
+
return [error(input)]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** @type {(input: list.List<number>) => list.List<Utf8Result>} */
|
|
30
|
+
const codePointListToUtf8 = list.flatMap(codePointToUtf8)
|
|
31
|
+
|
|
32
|
+
/** @type {(input: list.List<number>) => list.List<Utf8Result>} */
|
|
33
|
+
const codePointListToUtf16 = list.flatMap(codePointToUtf16)
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
/** @readonly */
|
|
37
|
+
codePointListToUtf8,
|
|
38
|
+
/** @readonly */
|
|
39
|
+
codePointListToUtf16,
|
|
40
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const encoding = require('./main.f.js')
|
|
2
|
+
const json = require('../../json/main.f')
|
|
3
|
+
const { sort } = require('../../types/object/main.f.js')
|
|
4
|
+
const { list } = require('../../types/main.f.js')
|
|
5
|
+
|
|
6
|
+
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
7
|
+
const stringify = a => json.stringify(sort)(a)
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0,1,0x7F])))
|
|
11
|
+
if (result !== '[["ok",0],["ok",1],["ok",127]]') { throw result }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0x80])))
|
|
16
|
+
if (result !== '[["ok",194],["ok",128]]') { throw result }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0xa9])))
|
|
21
|
+
if (result !== '[["ok",194],["ok",169]]') { throw result }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
{
|
|
25
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0x7ff])))
|
|
26
|
+
if (result !== '[["ok",223],["ok",191]]') { throw result }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0x800])))
|
|
31
|
+
if (result !== '[["ok",224],["ok",160],["ok",128]]') { throw result }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0x801])))
|
|
36
|
+
if (result !== '[["ok",224],["ok",160],["ok",129]]') { throw result }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0xffff])))
|
|
41
|
+
if (result !== '[["ok",239],["ok",191],["ok",191]]') { throw result }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0x10000])))
|
|
46
|
+
if (result !== '[["ok",240],["ok",144],["ok",128],["ok",128]]') { throw result }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0x10001])))
|
|
51
|
+
if (result !== '[["ok",240],["ok",144],["ok",128],["ok",129]]') { throw result }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([0x10FFFF])))
|
|
56
|
+
if (result !== '[["ok",244],["ok",143],["ok",191],["ok",191]]') { throw result }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf8([-1,0x110000])))
|
|
61
|
+
if (result !== '[["error",-1],["error",1114112]]') { throw result }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
{
|
|
65
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0])))
|
|
66
|
+
if (result !== '[["ok",0],["ok",0]]') { throw result }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0x24])))
|
|
71
|
+
if (result !== '[["ok",0],["ok",36]]') { throw result }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0x20AC])))
|
|
76
|
+
if (result !== '[["ok",32],["ok",172]]') { throw result }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0xd7ff])))
|
|
81
|
+
if (result !== '[["ok",215],["ok",255]]') { throw result }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
{
|
|
85
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0xe000])))
|
|
86
|
+
if (result !== '[["ok",224],["ok",0]]') { throw result }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
{
|
|
90
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0xffff])))
|
|
91
|
+
if (result !== '[["ok",255],["ok",255]]') { throw result }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
{
|
|
95
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0x10000])))
|
|
96
|
+
if (result !== '[["ok",216],["ok",0],["ok",220],["ok",0]]') { throw result }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
{
|
|
100
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0x10437])))
|
|
101
|
+
if (result !== '[["ok",216],["ok",1],["ok",220],["ok",55]]') { throw result }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0x24B62])))
|
|
106
|
+
if (result !== '[["ok",216],["ok",82],["ok",223],["ok",98]]') { throw result }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
{
|
|
110
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([0x10ffff])))
|
|
111
|
+
if (result !== '[["ok",219],["ok",255],["ok",223],["ok",255]]') { throw result }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
{
|
|
115
|
+
const result = stringify(list.toArray(encoding.codePointListToUtf16([-1, 0xd800, 0xdfff, 0x110000])))
|
|
116
|
+
if (result !== '[["error",-1],["error",55296],["error",57343],["error",1114112]]') { throw result }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = {}
|