functionalscript 0.0.433 → 0.0.435

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/Cargo.lock CHANGED
@@ -7,7 +7,7 @@ name = "nanocom"
7
7
  version = "0.1.2"
8
8
 
9
9
  [[package]]
10
- name = "rtest"
10
+ name = "testrust"
11
11
  version = "0.1.0"
12
12
  dependencies = [
13
13
  "nanocom",
package/Cargo.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [workspace]
2
2
  members = [
3
3
  "com/rust/nanocom",
4
- "com/rust/rtest"
4
+ "com/test/rust"
5
5
  ]
@@ -1,7 +1,7 @@
1
1
  const fs = require('node:fs')
2
2
  const cp = require('node:child_process')
3
3
  const os = require('node:os');
4
- const cpp = require('../test.f.cjs').result
4
+ const cpp = require('../../cpp/test.f.cjs').result
5
5
  const { string: { join }, list: { flat } } = require('../../../types/module.f.cjs')
6
6
 
7
7
  fs.writeFileSync('_result.hpp', cpp)
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  const fs = require('node:fs')
2
2
  const cp = require('node:child_process')
3
- const cs = require('../test.f.cjs').result
3
+ const cs = require('../../cs/test.f.cjs').result
4
4
 
5
5
  fs.writeFileSync('_result.cs', cs)
6
6
  try {
package/fsm/module.f.cjs CHANGED
@@ -15,7 +15,7 @@ const byteSet = require('../types/byte_set/module.f.cjs')
15
15
  */
16
16
 
17
17
  /** @type {(faId: string) => string} */
18
- const escape = faId => todo()
18
+ const escape = faId => faId.replaceAll('\\', '\\\\').replaceAll('|', '\\|')
19
19
 
20
20
  /** @type {(grammar: Grammar) => Dfa} */
21
21
  const dfa = grammar => todo()
package/fsm/test.f.cjs ADDED
@@ -0,0 +1,14 @@
1
+ const _ = require('./module.f.cjs')
2
+
3
+ module.exports = {
4
+ escape: [
5
+ () => {
6
+ const result = _.escape('abc')
7
+ if (result !== 'abc') { throw result }
8
+ },
9
+ () => {
10
+ const result = _.escape('\\a|b|c\\')
11
+ if (result !== '\\\\a\\|b\\|c\\\\') { throw result }
12
+ }
13
+ ]
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.433",
3
+ "version": "0.0.435",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -0,0 +1,38 @@
1
+ const compare = require("../function/compare/module.f.cjs")
2
+ const list = require("../list/module.f.cjs")
3
+ const { next, toArray } = list
4
+
5
+ /**
6
+ * @template T
7
+ * @typedef {list.List<T>} SortedList
8
+ */
9
+
10
+ /**
11
+ * @template T
12
+ * @typedef {(a: T) => (b: T) => compare.Sign} Cmp
13
+ */
14
+
15
+ /** @typedef {number} Byte */
16
+
17
+ /**
18
+ * @template T
19
+ * @typedef {SortedList<[Byte, readonly string[]]>} RangeMap
20
+ */
21
+
22
+ /** @type {<T>(cmp: Cmp<T>) => (a: SortedList<T>) => (b: SortedList<T>) => SortedList<T>} */
23
+ const merge = cmp => a => b => () => {
24
+ const aResult = next(a)
25
+ if (aResult === undefined) { return b }
26
+ const bResult = next(b)
27
+ if (bResult === undefined) { return a }
28
+ switch (cmp(aResult.first)(bResult.first)) {
29
+ case -1: return { first: aResult.first, tail: merge(cmp)(aResult.tail)(b) }
30
+ case 0: return { first: aResult.first, tail: merge(cmp)(aResult.tail)(bResult.tail) }
31
+ case 1: return { first: bResult.first, tail: merge(cmp)(a)(bResult.tail) }
32
+ }
33
+ }
34
+
35
+ module.exports = {
36
+ /** @readonly */
37
+ merge
38
+ }
@@ -0,0 +1,33 @@
1
+ const _ = require('./module.f.cjs')
2
+ const { unsafeCmp } = require('../function/compare/module.f.cjs')
3
+ const json = require('../../json/module.f.cjs')
4
+ const { sort } = require('../../types/object/module.f.cjs')
5
+ const { toArray, countdown, length } = require('../list/module.f.cjs')
6
+ const map = require('../map/module.f.cjs')
7
+ const { flip } = require('../function/module.f.cjs')
8
+
9
+ /** @type {(a: readonly json.Unknown[]) => string} */
10
+ const stringify = a => json.stringify(sort)(a)
11
+
12
+ /** @type {<T>(a: T) => (b: T) => map.Sign} */
13
+ const reverseCmp = flip(unsafeCmp)
14
+
15
+ module.exports = {
16
+ sortedMergre: [
17
+ () => {
18
+ const result = stringify(toArray(_.merge(unsafeCmp)([2, 3, 4])([1, 3, 5])))
19
+ if (result !== '[1,2,3,4,5]') { throw result }
20
+ },
21
+ () => {
22
+ const result = stringify(toArray(_.merge(unsafeCmp)([1, 2, 3])([])))
23
+ if (result !== '[1,2,3]') { throw result }
24
+ },
25
+ () => {
26
+ const n = 10_000
27
+ const list = countdown(n)
28
+ const result = _.merge(reverseCmp)(list)(list)
29
+ const len = length(result)
30
+ if (len != n) { throw result }
31
+ }
32
+ ]
33
+ }