functionalscript 0.1.599 → 0.1.600

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/issues/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Issues
2
2
 
3
3
  1. [X] [test-debug](./test-debug.md).
4
- 2. [ ] [esm](./esm.md)
4
+ 2. [X] [esm](./esm.md)
5
5
  3. [ ] [publish](publish.md)
6
6
  4. [ ] fix index generation by including sub modules `{ ...m, add: mAdd, remove: mRemove}`.
7
7
  5. [ ] Conventions:
@@ -10,7 +10,7 @@
10
10
  // list is for objects.
11
11
  // List is for types and should be ignored by FJS or errored if used in code.
12
12
  ```
13
- 6. [ ] PoC: Replace `while` with recursive generators
13
+ 6. [X] PoC: Replace `while` with recursive generators. **Result:** doesn't work.
14
14
  7. Two sets of property filters:
15
15
  - usage `.b`:
16
16
  - `constructor`
package/jsr.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@functionalscript/functionalscript",
3
- "version": "0.1.599",
3
+ "version": "0.1.600",
4
4
  "exports": "./index.f.mjs"
5
5
  }
@@ -1,5 +1,4 @@
1
1
  import _ from './module.f.mjs'
2
- import child_process from 'node:child_process'
3
2
  import fs from 'node:fs'
4
3
 
5
- _.version({ child_process, fs })
4
+ _.updateVersion({ fs })
@@ -1,18 +1,17 @@
1
1
  declare namespace _default {
2
- export { version };
2
+ export { getVersion };
3
+ export { updateVersion };
3
4
  }
4
5
  export default _default;
5
- export type ChildProcess = {
6
- readonly execSync: (cmd: string) => Buffer;
7
- };
8
6
  export type Buffer = {};
9
7
  export type Fs<T> = {
10
8
  readonly readFileSync: (name: string) => Buffer;
11
9
  readonly writeFileSync: (name: string, content: string) => T;
12
10
  };
13
11
  export type Node<T> = {
14
- readonly child_process: ChildProcess;
15
12
  readonly fs: Fs<T>;
16
13
  };
14
+ /** @type {<T>(fs: Fs<T>) => string} */
15
+ declare const getVersion: <T>(fs: Fs<T>) => string;
17
16
  /** @type {<T>(node: Node<T>) => readonly[T, T]} */
18
- declare const version: <T>(node: Node<T>) => readonly [T, T];
17
+ declare const updateVersion: <T>(node: Node<T>) => readonly [T, T];
@@ -1,9 +1,3 @@
1
- /**
2
- * @typedef {{
3
- * readonly execSync: (cmd: string) => Buffer
4
- * }} ChildProcess
5
- */
6
-
7
1
  /** @typedef {{}} Buffer */
8
2
 
9
3
  /**
@@ -17,24 +11,29 @@
17
11
  /**
18
12
  * @template T
19
13
  * @typedef {{
20
- * readonly child_process: ChildProcess
21
14
  * readonly fs: Fs<T>
22
15
  * }} Node
23
16
  */
24
17
 
25
18
  const { stringify, parse } = JSON
26
19
 
20
+ /** @type {<T>(fs: Fs<T>) => string} */
21
+ const getVersion = fs => readJson(fs)('package').version
22
+
23
+ const jsonFile = (/** @type {string} */jsonFile) => `${jsonFile}.json`
24
+
25
+ /** @type {<T>(node: Fs<T>) => (name: string) => any} */
26
+ const readJson = fs => name => parse(fs.readFileSync(jsonFile(name)).toString())
27
+
27
28
  /** @type {<T>(node: Node<T>) => readonly[T, T]} */
28
- const version = ({ child_process, fs }) => {
29
- const version = `0.1.${child_process.execSync('git log --oneline').toString().split('\n').length - 1}`
30
- const f = (/** @type {string} */jsonFile) => {
31
- const file = `${jsonFile}.json`
29
+ const updateVersion = ({ fs }) => {
30
+ const f = (/** @type {string} */name) => {
32
31
  return fs.writeFileSync(
33
- file,
32
+ jsonFile(name),
34
33
  stringify(
35
34
  {
36
- ...parse(fs.readFileSync(file).toString()),
37
- version
35
+ ...readJson(fs)(name),
36
+ version: getVersion(fs)
38
37
  },
39
38
  null,
40
39
  2))
@@ -46,6 +45,6 @@ const version = ({ child_process, fs }) => {
46
45
  }
47
46
 
48
47
  export default {
49
- /** @readonly */
50
- version,
48
+ getVersion,
49
+ updateVersion,
51
50
  }
@@ -1,44 +1,54 @@
1
1
  import _, * as T from './module.f.mjs'
2
2
 
3
+ const version = '0.3.0'
4
+
5
+ /**
6
+ * @type {{
7
+ * readonly[k in string]: unknown
8
+ * }}
9
+ */
3
10
  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"
11
+ 'package.json': {
12
+ "name": "functionalscript",
13
+ version,
14
+ "description": "FunctionalScript is a functional subset of JavaScript",
15
+ "main": "module.f.cjs",
16
+ "scripts": {
17
+ "tsc": "tsc",
18
+ "test": "tsc && npm run test-only",
19
+ "version": "node ./nodejs/version/main.cjs",
20
+ "test-only": "node --trace-uncaught ./test.f.cjs"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/functionalscript/functionalscript.git"
25
+ },
26
+ "author": "NatFoam",
27
+ "license": "MIT",
28
+ "keywords": [
29
+ "lambda",
30
+ "functional-programming",
31
+ "closure",
32
+ "pure-functional",
33
+ "typescript",
34
+ "programming-language",
35
+ "lazy-evaluation"
36
+ ],
37
+ "bugs": {
38
+ "url": "https://github.com/functionalscript/functionalscript/issues"
39
+ },
40
+ "homepage": "https://github.com/functionalscript/functionalscript#readme",
41
+ "devDependencies": {
42
+ "@types/node": "^18.6.2",
43
+ "typescript": "^4.7.4"
44
+ }
31
45
  },
32
- "homepage": "https://github.com/functionalscript/functionalscript#readme",
33
- "devDependencies": {
34
- "@types/node": "^18.6.2",
35
- "typescript": "^4.7.4"
36
- }
46
+ "jsr.json": {}
37
47
  }
38
48
 
39
49
  const e = '{\n' +
40
50
  ' "name": "functionalscript",\n' +
41
- ' "version": "0.1.2",\n' +
51
+ ` "version": "${version}",\n` +
42
52
  ' "description": "FunctionalScript is a functional subset of JavaScript",\n' +
43
53
  ' "main": "module.f.cjs",\n' +
44
54
  ' "scripts": {\n' +
@@ -80,12 +90,11 @@ const buffer = s => ({
80
90
  export default () => {
81
91
  /** @type {T.Node<string>} */
82
92
  const node = {
83
- child_process: { execSync: () => buffer("123\n456\n") },
84
93
  fs: {
85
- readFileSync: () => buffer(JSON.stringify(x)),
94
+ readFileSync: n => buffer(JSON.stringify(x[n])),
86
95
  writeFileSync: (_, content) => content
87
96
  }
88
97
  }
89
- const [n, d] = _.version(node)
98
+ const [n, d] = _.updateVersion(node)
90
99
  if (n !== e) { throw [n, e] }
91
100
  }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.1.599",
3
+ "version": "0.1.600",
4
+ "type": "module",
4
5
  "description": "FunctionalScript is a functional subset of JavaScript",
5
6
  "main": "index.f.mjs",
6
7
  "scripts": {
@@ -200,7 +200,8 @@ const stress = () => ({
200
200
  /** @type {T.List<number>} */
201
201
  let sequence = []
202
202
  // 20_000_000 is too much
203
- for (let i = 0; i < 10_000_000; ++i) {
203
+ // 10_000_000 is too much for Deno 1
204
+ for (let i = 0; i < 5_000_000; ++i) {
204
205
  sequence = _.concat(sequence)([i])
205
206
  }
206
207
  const r = _.toArray(sequence)
@@ -316,5 +317,5 @@ export default {
316
317
  if (_.length(null) !== 0) { throw 0 }
317
318
  if (_.length(_.flat([[1, 3], null, () => [3], _.concat([12])([4, 89])])) !== 6) { throw 6 }
318
319
  },
319
- //stress
320
+ // stress
320
321
  }