functionalscript 0.0.432 → 0.0.434
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/dev/module.mjs +155 -0
- package/dev/test/module.f.cjs +12 -1
- package/dev/test.mjs +2 -156
- package/fsm/module.f.cjs +1 -1
- package/fsm/test.f.cjs +14 -0
- package/package.json +1 -1
- package/types/function/operator/module.f.cjs +3 -3
- package/types/list/module.f.cjs +2 -2
- package/types/sorted_list/module.f.cjs +38 -0
- package/types/sorted_list/test.f.cjs +33 -0
package/dev/module.mjs
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* readonly withFileTypes: true
|
|
4
|
+
* }} Options
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {{
|
|
9
|
+
* readonly name: string
|
|
10
|
+
* readonly isDirectory: () => boolean
|
|
11
|
+
* }} Dirent
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{
|
|
16
|
+
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
17
|
+
* readonly readFile: (path: string, options: 'utf8') => Promise<string>
|
|
18
|
+
* }} FsPromises
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* [k in string]?: MutableModule
|
|
24
|
+
* }} MutableDependencyMap
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{
|
|
29
|
+
* dependencyMap: MutableDependencyMap
|
|
30
|
+
* exports?: unknown
|
|
31
|
+
* }} MutableModule
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {{
|
|
36
|
+
* readonly dependencyMap: DependencyMap
|
|
37
|
+
* readonly exports?: unknown
|
|
38
|
+
* }} Module
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {{
|
|
43
|
+
* readonly[k in string]?: Module
|
|
44
|
+
* }} DependencyMap
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/** @typedef {(name: string) => unknown} Require */
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {{
|
|
51
|
+
* readonly[k in string]: Function
|
|
52
|
+
* }} FunctionMap
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @template T
|
|
57
|
+
* @typedef {readonly[string, T]} Entry
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/** @type {(a: Entry<Function>, b: Entry<Function>) => number} */
|
|
61
|
+
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {{
|
|
65
|
+
* [k in string]: MutableModule
|
|
66
|
+
* }} MutableModuleMap
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {{
|
|
71
|
+
* readonly[k in string]: Module
|
|
72
|
+
* }} ModuleMap
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/** @type {(v: readonly string[]) => (dif: number) => readonly string[]} */
|
|
76
|
+
const remove_tail = v => dif => v.slice(0, v.length - dif)
|
|
77
|
+
|
|
78
|
+
/** @type {any} */
|
|
79
|
+
const self = globalThis
|
|
80
|
+
|
|
81
|
+
export const loadModuleMap = async () => {
|
|
82
|
+
/** @type {FsPromises} */
|
|
83
|
+
const { readdir, readFile } = await import(self.Deno ? 'https://deno.land/std/node/fs/promises.ts' : 'node:fs/promises')
|
|
84
|
+
|
|
85
|
+
/** @type {() => Promise<FunctionMap>} */
|
|
86
|
+
const load = async () => {
|
|
87
|
+
/** @type {(readonly[string, Function])[]} */
|
|
88
|
+
const map = []
|
|
89
|
+
/** @type {(path: string) => Promise<void>} */
|
|
90
|
+
const f = async p => {
|
|
91
|
+
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
92
|
+
const { name } = i
|
|
93
|
+
if (!name.startsWith('.')) {
|
|
94
|
+
const file = `${p}/${name}`
|
|
95
|
+
if (i.isDirectory()) {
|
|
96
|
+
await f(file)
|
|
97
|
+
} else if (name.endsWith('.f.cjs')) {
|
|
98
|
+
const source = await readFile(file, 'utf8')
|
|
99
|
+
map.push([file, Function('module', 'require', `"use strict";${source}`)])
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
await f('.')
|
|
105
|
+
map.sort(cmp)
|
|
106
|
+
return Object.fromEntries(map)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const map = await load()
|
|
110
|
+
|
|
111
|
+
/** @type {() => ModuleMap} */
|
|
112
|
+
const build = () => {
|
|
113
|
+
/** @type {MutableModuleMap} */
|
|
114
|
+
const d = {}
|
|
115
|
+
/** @type {(base: readonly string[]) => (k: string) => readonly[string, MutableModule]} */
|
|
116
|
+
const getModule = base => k => {
|
|
117
|
+
const relativePath = k.split('/')
|
|
118
|
+
const dif = relativePath.filter(v => v === '..').length
|
|
119
|
+
const path = [remove_tail(base)(dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
120
|
+
.flat()
|
|
121
|
+
const pathStr = path.join('/')
|
|
122
|
+
{
|
|
123
|
+
const module = d[pathStr]
|
|
124
|
+
if (module !== undefined) {
|
|
125
|
+
return [pathStr, module]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
{
|
|
129
|
+
/** @type {MutableDependencyMap} */
|
|
130
|
+
const dependencyMap = {}
|
|
131
|
+
/** @type {MutableModule} */
|
|
132
|
+
const module = { dependencyMap }
|
|
133
|
+
const get = getModule(remove_tail(path)(1))
|
|
134
|
+
/** @type {(s: string) => unknown} */
|
|
135
|
+
const newReq = s => {
|
|
136
|
+
const [p, result] = get(s)
|
|
137
|
+
dependencyMap[p] = result
|
|
138
|
+
return result.exports
|
|
139
|
+
}
|
|
140
|
+
map[pathStr](module, newReq)
|
|
141
|
+
d[pathStr] = module
|
|
142
|
+
return [pathStr, module]
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
{
|
|
146
|
+
const get = getModule(['.'])
|
|
147
|
+
for (const k of Object.keys(map)) {
|
|
148
|
+
get(k)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return d
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return build()
|
|
155
|
+
}
|
package/dev/test/module.f.cjs
CHANGED
|
@@ -34,6 +34,17 @@ const { fold } = list
|
|
|
34
34
|
* }} Input
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* https://en.wikipedia.org/wiki/ANSI_escape_code#SGR
|
|
39
|
+
*
|
|
40
|
+
* @type {(c: number) => string}
|
|
41
|
+
*/
|
|
42
|
+
const sgr = c => `\x1b[${c.toString()}m`
|
|
43
|
+
|
|
44
|
+
const reset = sgr(0)
|
|
45
|
+
|
|
46
|
+
const fgGreen = sgr(32)
|
|
47
|
+
|
|
37
48
|
/** @type {(s: string) => boolean} */
|
|
38
49
|
const isTest = s => s.endsWith('test.f.cjs')
|
|
39
50
|
|
|
@@ -47,7 +58,7 @@ const main = ({moduleMap, log, state}) => {
|
|
|
47
58
|
case 'function': {
|
|
48
59
|
if (v.length === 0) {
|
|
49
60
|
const r = v()
|
|
50
|
-
state = log(`${i}()
|
|
61
|
+
state = log(`${i}() ${fgGreen}ok${reset}`)(state)
|
|
51
62
|
state = next(r)(state)
|
|
52
63
|
}
|
|
53
64
|
break
|
package/dev/test.mjs
CHANGED
|
@@ -1,162 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {{
|
|
3
|
-
* readonly withFileTypes: true
|
|
4
|
-
* }} Options
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {{
|
|
9
|
-
* readonly name: string
|
|
10
|
-
* readonly isDirectory: () => boolean
|
|
11
|
-
* }} Dirent
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {{
|
|
16
|
-
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
17
|
-
* readonly readFile: (path: string, options: 'utf8') => Promise<string>
|
|
18
|
-
* }} FsPromises
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {{
|
|
23
|
-
* [k in string]?: MutableModule
|
|
24
|
-
* }} MutableDependencyMap
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {{
|
|
29
|
-
* dependencyMap: MutableDependencyMap
|
|
30
|
-
* exports?: unknown
|
|
31
|
-
* }} MutableModule
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @typedef {{
|
|
36
|
-
* readonly dependencyMap: DependencyMap
|
|
37
|
-
* readonly exports?: unknown
|
|
38
|
-
* }} Module
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @typedef {{
|
|
43
|
-
* readonly[k in string]?: Module
|
|
44
|
-
* }} DependencyMap
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/** @typedef {(name: string) => unknown} Require */
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @typedef {{
|
|
51
|
-
* readonly[k in string]: Function
|
|
52
|
-
* }} FunctionMap
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @template T
|
|
57
|
-
* @typedef {readonly[string, T]} Entry
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/** @type {(a: Entry<Function>, b: Entry<Function>) => number} */
|
|
61
|
-
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @typedef {{
|
|
65
|
-
* [k in string]: MutableModule
|
|
66
|
-
* }} MutableModuleMap
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @typedef {{
|
|
71
|
-
* readonly[k in string]: Module
|
|
72
|
-
* }} ModuleMap
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/** @type {(v: readonly string[]) => (dif: number) => readonly string[]} */
|
|
76
|
-
const remove_tail = v => dif => v.slice(0, v.length - dif)
|
|
77
|
-
|
|
78
|
-
/** @type {any} */
|
|
79
|
-
const self = globalThis
|
|
80
|
-
|
|
81
|
-
const boot = async() => {
|
|
82
|
-
/** @type {FsPromises} */
|
|
83
|
-
const { readdir, readFile } = await import(self.Deno ? 'https://deno.land/std/node/fs/promises.ts' : 'node:fs/promises')
|
|
84
|
-
|
|
85
|
-
/** @type {() => Promise<FunctionMap>} */
|
|
86
|
-
const load = async () => {
|
|
87
|
-
/** @type {(readonly[string, Function])[]} */
|
|
88
|
-
const map = []
|
|
89
|
-
/** @type {(path: string) => Promise<void>} */
|
|
90
|
-
const f = async p => {
|
|
91
|
-
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
92
|
-
const { name } = i
|
|
93
|
-
if (!name.startsWith('.')) {
|
|
94
|
-
const file = `${p}/${name}`
|
|
95
|
-
if (i.isDirectory()) {
|
|
96
|
-
await f(file)
|
|
97
|
-
} else if (name.endsWith('.f.cjs')) {
|
|
98
|
-
const source = await readFile(file, 'utf8')
|
|
99
|
-
map.push([file, Function('module', 'require', `"use strict";${source}`)])
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
await f('.')
|
|
105
|
-
map.sort(cmp)
|
|
106
|
-
return Object.fromEntries(map)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const map = await load()
|
|
110
|
-
|
|
111
|
-
/** @type {() => ModuleMap} */
|
|
112
|
-
const build = () => {
|
|
113
|
-
/** @type {MutableModuleMap} */
|
|
114
|
-
const d = {}
|
|
115
|
-
/** @type {(base: readonly string[]) => (k: string) => readonly[string, MutableModule]} */
|
|
116
|
-
const getModule = base => k => {
|
|
117
|
-
const relativePath = k.split('/')
|
|
118
|
-
const dif = relativePath.filter(v => v === '..').length
|
|
119
|
-
const path = [remove_tail(base)(dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
120
|
-
.flat()
|
|
121
|
-
const pathStr = path.join('/')
|
|
122
|
-
{
|
|
123
|
-
const module = d[pathStr]
|
|
124
|
-
if (module !== undefined) {
|
|
125
|
-
return [pathStr, module]
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
{
|
|
129
|
-
/** @type {MutableDependencyMap} */
|
|
130
|
-
const dependencyMap = {}
|
|
131
|
-
/** @type {MutableModule} */
|
|
132
|
-
const module = { dependencyMap }
|
|
133
|
-
const get = getModule(remove_tail(path)(1))
|
|
134
|
-
/** @type {(s: string) => unknown} */
|
|
135
|
-
const newReq = s => {
|
|
136
|
-
const [p, result] = get(s)
|
|
137
|
-
dependencyMap[p] = result
|
|
138
|
-
return result.exports
|
|
139
|
-
}
|
|
140
|
-
map[pathStr](module, newReq)
|
|
141
|
-
d[pathStr] = module
|
|
142
|
-
return [pathStr, module]
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
{
|
|
146
|
-
const get = getModule(['.'])
|
|
147
|
-
for (const k of Object.keys(map)) {
|
|
148
|
-
get(k)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return d
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return build()
|
|
155
|
-
}
|
|
1
|
+
import { loadModuleMap } from './module.mjs'
|
|
156
2
|
|
|
157
3
|
// test runner.
|
|
158
4
|
const main = async() => {
|
|
159
|
-
const moduleMap = await
|
|
5
|
+
const moduleMap = await loadModuleMap()
|
|
160
6
|
|
|
161
7
|
/** @type {(s: string) => (_: undefined) => undefined} */
|
|
162
8
|
const log = s => state => {
|
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 =>
|
|
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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @template I,O
|
|
10
|
-
* @typedef {Binary<I, O, O>}
|
|
10
|
+
* @typedef {Binary<I, O, O>} Fold
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/** @type {(separator: string) => Reduce<string>} */
|
|
@@ -49,7 +49,7 @@ const stateScanToScan = op => prior => i => {
|
|
|
49
49
|
return [o, stateScanToScan(op)(s)]
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/** @type {<I, O>(fold:
|
|
52
|
+
/** @type {<I, O>(fold: Fold<I, O>) => (prior: O) => Scan<I, O>} */
|
|
53
53
|
const foldToScan = fold => prior => i => {
|
|
54
54
|
const result = fold(i)(prior)
|
|
55
55
|
return [result, foldToScan(fold)(result)]
|
|
@@ -57,7 +57,7 @@ const foldToScan = fold => prior => i => {
|
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* @template T
|
|
60
|
-
* @typedef {
|
|
60
|
+
* @typedef {Fold<T, T>} Reduce
|
|
61
61
|
*/
|
|
62
62
|
|
|
63
63
|
/** @type {<T>(fold: Reduce<T>) => Scan<T, T>} */
|
package/types/list/module.f.cjs
CHANGED
|
@@ -250,10 +250,10 @@ const scan = op => apply(scanStep(op))
|
|
|
250
250
|
/** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
|
|
251
251
|
const stateScan = op => init => scan(stateScanToScan(op)(init))
|
|
252
252
|
|
|
253
|
-
/** @type {<I,O>(op: operator.
|
|
253
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
|
|
254
254
|
const foldScan = op => init => scan(foldToScan(op)(init))
|
|
255
255
|
|
|
256
|
-
/** @type {<I,O>(op: operator.
|
|
256
|
+
/** @type {<I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O} */
|
|
257
257
|
const fold = op => init => input => last(init)(foldScan(op)(init)(input))
|
|
258
258
|
|
|
259
259
|
/** @type {<T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T} */
|
|
@@ -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
|
+
}
|