functionalscript 0.0.374 → 0.0.377

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.
@@ -1,15 +1,6 @@
1
- const cp = require('child_process')
2
- const fs = require('fs')
3
- const package_json = require('../../package.json')
1
+ const { version } = require('./module.f.cjs')
2
+
3
+ const child_process = require('node:child_process')
4
+ const fs = require('node:fs')
4
5
 
5
- const b =cp.execSync('git log --oneline')
6
-
7
- const r = b.toString().split('\n').length
8
-
9
- const v = `0.0.${r}`
10
-
11
- console.log(`version: ${v}`)
12
-
13
- const x = { ...package_json, version: v }
14
-
15
- fs.writeFileSync('package.json', JSON.stringify(x, null, 2))
6
+ version({ child_process, fs })
@@ -0,0 +1,40 @@
1
+ const pack = require('../../commonjs/package/module.f.cjs')
2
+
3
+ /**
4
+ * @typedef {{
5
+ * readonly execSync: (cmd: string) => Buffer
6
+ * }} ChildProcess
7
+ */
8
+
9
+ /**
10
+ * @template T
11
+ * @typedef {{
12
+ * readonly readFileSync: (name: string) => Buffer
13
+ * readonly writeFileSync: (name: string, content: string) => T
14
+ * }} Fs
15
+ */
16
+
17
+ /**
18
+ * @template T
19
+ * @typedef {{
20
+ * readonly child_process: ChildProcess
21
+ * readonly fs: Fs<T>
22
+ * }} Node
23
+ */
24
+
25
+ /** @type {<T>(node: Node<T>) => T} */
26
+ const version = ({ child_process, fs }) =>
27
+ fs.writeFileSync(
28
+ 'package.json',
29
+ JSON.stringify(
30
+ {
31
+ ...JSON.parse(fs.readFileSync('package.json').toString()),
32
+ version: `0.0.${child_process.execSync('git log --oneline').toString().split('\n').length - 1}`
33
+ },
34
+ null,
35
+ 2))
36
+
37
+ module.exports = {
38
+ /** @readonly */
39
+ version,
40
+ }
@@ -0,0 +1,88 @@
1
+ const _ = require('./module.f.cjs')
2
+
3
+ const x = {
4
+ "name": "functionalscript",
5
+ "version": "0.1.0",
6
+ "description": "FunctionalScript is a functional subset of JavaScript",
7
+ "main": "module.f.cjs",
8
+ "scripts": {
9
+ "tsc": "tsc",
10
+ "test": "tsc && npm run test-only",
11
+ "version": "node ./nodejs/version/main.cjs",
12
+ "test-only": "node --trace-uncaught ./test.f.cjs"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/functionalscript/functionalscript.git"
17
+ },
18
+ "author": "NatFoam",
19
+ "license": "MIT",
20
+ "keywords": [
21
+ "lambda",
22
+ "functional-programming",
23
+ "closure",
24
+ "pure-functional",
25
+ "typescript",
26
+ "programming-language",
27
+ "lazy-evaluation"
28
+ ],
29
+ "bugs": {
30
+ "url": "https://github.com/functionalscript/functionalscript/issues"
31
+ },
32
+ "homepage": "https://github.com/functionalscript/functionalscript#readme",
33
+ "devDependencies": {
34
+ "@types/node": "^18.6.2",
35
+ "typescript": "^4.7.4"
36
+ }
37
+ }
38
+
39
+ const e = '{\n' +
40
+ ' "name": "functionalscript",\n' +
41
+ ' "version": "0.0.2",\n' +
42
+ ' "description": "FunctionalScript is a functional subset of JavaScript",\n' +
43
+ ' "main": "module.f.cjs",\n' +
44
+ ' "scripts": {\n' +
45
+ ' "tsc": "tsc",\n' +
46
+ ' "test": "tsc && npm run test-only",\n' +
47
+ ' "version": "node ./nodejs/version/main.cjs",\n' +
48
+ ' "test-only": "node --trace-uncaught ./test.f.cjs"\n' +
49
+ ' },\n' +
50
+ ' "repository": {\n' +
51
+ ' "type": "git",\n' +
52
+ ' "url": "git+https://github.com/functionalscript/functionalscript.git"\n' +
53
+ ' },\n' +
54
+ ' "author": "NatFoam",\n' +
55
+ ' "license": "MIT",\n' +
56
+ ' "keywords": [\n' +
57
+ ' "lambda",\n' +
58
+ ' "functional-programming",\n' +
59
+ ' "closure",\n' +
60
+ ' "pure-functional",\n' +
61
+ ' "typescript",\n' +
62
+ ' "programming-language",\n' +
63
+ ' "lazy-evaluation"\n' +
64
+ ' ],\n' +
65
+ ' "bugs": {\n' +
66
+ ' "url": "https://github.com/functionalscript/functionalscript/issues"\n' +
67
+ ' },\n' +
68
+ ' "homepage": "https://github.com/functionalscript/functionalscript#readme",\n' +
69
+ ' "devDependencies": {\n' +
70
+ ' "@types/node": "^18.6.2",\n' +
71
+ ' "typescript": "^4.7.4"\n' +
72
+ ' }\n' +
73
+ '}'
74
+
75
+ {
76
+ /** @type {_.Node<string>} */
77
+ const node = {
78
+ child_process: { execSync: () => Buffer.from("123\n456\n") },
79
+ fs: {
80
+ readFileSync: () => Buffer.from(JSON.stringify(x)),
81
+ writeFileSync: (_, content) => content
82
+ }
83
+ }
84
+ const v = _.version(node)
85
+ if (v !== e) { throw [v, e] }
86
+ }
87
+
88
+ module.exports = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.374",
3
+ "version": "0.0.377",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "homepage": "https://github.com/functionalscript/functionalscript#readme",
31
31
  "devDependencies": {
32
- "@types/node": "^18.6.2",
32
+ "@types/node": "^18.6.3",
33
33
  "typescript": "^4.7.4"
34
34
  }
35
35
  }
package/test.f.cjs CHANGED
@@ -21,6 +21,7 @@ require('./text/test.f.cjs')
21
21
  require('./text/encoding/test.f.cjs')
22
22
  require('./com/cs/test.f.cjs')
23
23
  require('./com/cpp/test.f.cjs')
24
+ require('./nodejs/version/test.f.cjs')
24
25
 
25
26
  /** @type {() => never} */
26
27
  const assert = () => { throw 'assert' }
@@ -0,0 +1,90 @@
1
+ # UNICODE
2
+
3
+ ## UTF-8
4
+
5
+ Requirement: no loss for UTF8 => codepoint => UTF8
6
+
7
+ |utf8 |codepoint |size |
8
+ |---------|---------------------------------------|---------|
9
+ |[a] |0xxx_xxxx |7 bit |
10
+ |[b,a] |110x_xxxx 10xx_xxxx |11 bit |
11
+ |[c,b,a] |1110_xxxx 10xx_xxxx 10xx_xxxx |16 bit |
12
+ |[d,c,b,a]|1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx|21 bit |
13
+
14
+ |utf8 error|codepoint |size |
15
+ |----------|-----------------------------|------|
16
+ |[e] |10xx_xxxx |6 bit |
17
+ |[e] |1111_1xxx |3 bit |
18
+ |[b,] |110x_xxxx |5 bit |
19
+ |[c,] |1110_xxxx |4 bit |
20
+ |[c,b,] |1110_xxxx 10xx_xxxx |10 bit|
21
+ |[d,] |1111_0xxx |3 bit |
22
+ |[d,c,] |1111_0xxx 10xx_xxxx |9 bit |
23
+ |[d,c,b] |1111_0xxx 10xx_xxxx 10xx_xxxx|15 bit|
24
+
25
+ Total error states:
26
+
27
+ - 2^6 + 2^3 + 2^5 + 2^4 + 2^10 + 2^3 + + 2^9 + 2^15
28
+ - 2^4 + 2^6 + 2^5 + 2^4 + 2^10 + 2^9 + 2^15
29
+ - 2^5 + 2^6 + 2^5 + 2^10 + 2^9 + 2^15
30
+ - 2^6 + 2^6 + 2^10 + 2^9 + 2^15
31
+ - 2^7 + 2^9 + 2^10 + 2^15
32
+ - < 2^16
33
+
34
+ |utf8 error|codepoint |size |map |
35
+ |----------|-----------------------------|------|-------------------|
36
+ |[e] |1111_1xxx | 3 bit| |
37
+ |[d,] |1111_0xxx | 3 bit| |
38
+ |[c,] |1110_xxxx | 4 bit| |
39
+ |[b,] |110x_xxxx | 5 bit| |
40
+ |[e] |10xx_xxxx | 6 bit|1111_1111 1xxx_xxxx|
41
+ |[d,c,] |1111_0xxx 10xx_xxxx | 9 bit|1111_0xxx 10xx_xxxx|
42
+ |[c,b,] |1110_xxxx 10xx_xxxx |10 bit|1110_xxxx 10xx_xxxx|
43
+ |[d,c,b] |1111_0xxx 10xx_xxxx 10xx_xxxx|15 bit|0xxx_xxxx xxxx_xxxx|
44
+
45
+ ```js
46
+ /** @type {(input: List<u8|undefined>) => List<i32>} */
47
+ const utf8ToCodePoint
48
+
49
+ /** @type {(input: List<i32>) => List<u8>} */
50
+ const codePointToUtf8
51
+ ```
52
+
53
+ ## UTF-16
54
+
55
+ Requirement: no loss for UTF16 => codepoint => UTF16
56
+
57
+ 0xD800..0xDFFF
58
+ 0b_1101_1000_0000_0000
59
+ 0b_1101_1111_1111_1111
60
+
61
+ 0b_1101_1xxx_xxxx_xxxx : 11 bits
62
+
63
+ - first : 0xD800: 0b_1101_10xx_xxxx_xxxx : 10 bit
64
+ - second: 0xDC00: 0b_1101_11xx_xxxx_xxxx : 10 bit
65
+
66
+ |utf16 |codepoint |size |
67
+ |---------|---------------------------------------|------|
68
+ |[a] |xxxx_xxxx_xxxx_xxxx |16 bit|
69
+ |[b,a] |1101_10xx_xxxx_xxxx 1101_11xx_xxxx_xxxx|20 bit|
70
+
71
+ |utf16 error|codepoint |size |
72
+ |-----------|-------------------|------|
73
+ |[e] |1101_11xx_xxxx_xxxx|10 bit|
74
+ |[b,] |1101_10xx_xxxx_xxxx|10 bit|
75
+
76
+ Total error states: 11 bit
77
+
78
+ ```js
79
+ /** @type {(input: List<u16|undefined>) => List<i32>} */
80
+ const utf16ListToCodePointList
81
+
82
+ /** @type {(input: List<i32>) => List<u16>} */
83
+ const codePointListToUtf16List
84
+
85
+ /** @type {(input: string) => List<u16> */
86
+ const stringToUtf16List
87
+
88
+ /** @type {(input: List<u16>) => string} */
89
+ const utf16ListToString
90
+ ```