functionalscript 0.0.484 → 0.0.486
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/com/types/module.f.cjs +1 -4
- package/commonjs/module.f.cjs +2 -2
- package/fsc/test.f.cjs +0 -1
- package/package.json +1 -1
- package/text/ascii/module.f.cjs +1 -1
- package/text/utf16/module.f.cjs +1 -1
- package/types/array/module.f.cjs +17 -14
- package/types/array/test.f.cjs +10 -14
- package/types/list/module.f.cjs +4 -4
package/com/types/module.f.cjs
CHANGED
|
@@ -62,10 +62,7 @@ const filterParam = filter(isParam)
|
|
|
62
62
|
const paramList = compose(entries)(filterParam)
|
|
63
63
|
|
|
64
64
|
/** @type {<T>(v: T) => (f: (type: Type) => T) => (fa: FieldArray) => T} */
|
|
65
|
-
const result = v => f => fa =>
|
|
66
|
-
const type = fa._
|
|
67
|
-
return type === undefined ? v : f(type)
|
|
68
|
-
}
|
|
65
|
+
const result = v => f => fa => '_' in fa ? f(fa._) : v
|
|
69
66
|
|
|
70
67
|
module.exports = {
|
|
71
68
|
/** @readonly */
|
package/commonjs/module.f.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** @typedef {(packageName: string) => PackageMap|Package|
|
|
1
|
+
/** @typedef {(packageName: string) => PackageMap|Package|null} PackageMap */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {readonly[
|
|
5
5
|
* string,
|
|
6
6
|
* PackageMap,
|
|
7
|
-
* (fileName: string) => string|
|
|
7
|
+
* (fileName: string) => string|null
|
|
8
8
|
* ]} Package
|
|
9
9
|
*/
|
|
10
10
|
|
package/fsc/test.f.cjs
CHANGED
package/package.json
CHANGED
package/text/ascii/module.f.cjs
CHANGED
package/text/utf16/module.f.cjs
CHANGED
|
@@ -82,7 +82,7 @@ const stringToList = s => {
|
|
|
82
82
|
/** @type {(i: number) => list.Result<number>} */
|
|
83
83
|
const at = i => {
|
|
84
84
|
const first = s.charCodeAt(i)
|
|
85
|
-
return isNaN(first) ?
|
|
85
|
+
return isNaN(first) ? empty : { first, tail: () => at(i + 1) }
|
|
86
86
|
}
|
|
87
87
|
return at(0)
|
|
88
88
|
}
|
package/types/array/module.f.cjs
CHANGED
|
@@ -84,35 +84,38 @@ const uncheckTail = a => a.slice(1)
|
|
|
84
84
|
/** @type {<T>(_: readonly T[]) => readonly T[]} */
|
|
85
85
|
const uncheckHead = a => a.slice(0, -1)
|
|
86
86
|
|
|
87
|
-
/** @type {<T>(
|
|
88
|
-
const
|
|
87
|
+
/** @type {<T>(a: T|undefined) => T|null} */
|
|
88
|
+
const undefinedToNull = a => a === void 0 ? null : a
|
|
89
89
|
|
|
90
|
-
/** @type {<T>(_: readonly T[]) => T|
|
|
91
|
-
const
|
|
90
|
+
/** @type {<T>(_: readonly T[]) => T|null} */
|
|
91
|
+
const first = a => undefinedToNull(a[0])
|
|
92
92
|
|
|
93
|
-
/** @type {<T>(_: readonly T[]) =>
|
|
94
|
-
const
|
|
93
|
+
/** @type {<T>(_: readonly T[]) => T|null} */
|
|
94
|
+
const last = a => undefinedToNull(a[a.length - 1])
|
|
95
95
|
|
|
96
|
-
/** @type {<T>(_: readonly T[]) => readonly
|
|
96
|
+
/** @type {<T>(_: readonly T[]) => readonly T[] | null} */
|
|
97
|
+
const tail = a => a.length === 0 ? null : uncheckTail(a)
|
|
98
|
+
|
|
99
|
+
/** @type {<T>(_: readonly T[]) => readonly[T, readonly T[]]|null} */
|
|
97
100
|
const splitFirst = a => {
|
|
98
101
|
/** @typedef {typeof a[0]} T*/
|
|
99
102
|
/** @type {(_: T) => readonly[T, readonly T[]]} */
|
|
100
103
|
const split = first => [first, uncheckTail(a)]
|
|
101
|
-
return map(split)(a[0])
|
|
104
|
+
return undefinedToNull(map(split)(a[0]))
|
|
102
105
|
}
|
|
103
106
|
|
|
104
|
-
/** @type {<T>(_: readonly T[]) => readonly T[]|
|
|
105
|
-
const head = a => a.length === 0 ?
|
|
107
|
+
/** @type {<T>(_: readonly T[]) => readonly T[]|null} */
|
|
108
|
+
const head = a => a.length === 0 ? null : uncheckHead(a)
|
|
106
109
|
|
|
107
|
-
/** @type {<T>(_: readonly T[]) => readonly[readonly T[], T]|
|
|
110
|
+
/** @type {<T>(_: readonly T[]) => readonly[readonly T[], T]|null} */
|
|
108
111
|
const splitLast = a => {
|
|
109
112
|
const lastA = last(a)
|
|
110
|
-
if (lastA ===
|
|
113
|
+
if (lastA === null) { return null }
|
|
111
114
|
return [uncheckHead(a), lastA]
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
/** @type {(index: number) => <T>(a: readonly T[]) => readonly[T]|
|
|
115
|
-
const at = index => a => index < a.length ? [a[index]] :
|
|
117
|
+
/** @type {(index: number) => <T>(a: readonly T[]) => readonly[T]|null} */
|
|
118
|
+
const at = index => a => index < a.length ? [a[index]] : null
|
|
116
119
|
|
|
117
120
|
module.exports = {
|
|
118
121
|
/** @readonly */
|
package/types/array/test.f.cjs
CHANGED
|
@@ -2,8 +2,7 @@ const _ = require('./module.f.cjs')
|
|
|
2
2
|
const json = require('../../json/module.f.cjs')
|
|
3
3
|
const { sort } = require('../object/module.f.cjs')
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const stringify = a => json.stringify(sort)(a)
|
|
5
|
+
const stringify = json.stringify(sort)
|
|
7
6
|
|
|
8
7
|
module.exports = {
|
|
9
8
|
stringify: () => {
|
|
@@ -13,13 +12,13 @@ module.exports = {
|
|
|
13
12
|
at: [
|
|
14
13
|
() => {
|
|
15
14
|
const result = _.at(2)([1, 20, 300])
|
|
16
|
-
if (result ===
|
|
15
|
+
if (result === null) { throw result }
|
|
17
16
|
if (result[0] !== 300) { throw result }
|
|
18
17
|
},
|
|
19
18
|
|
|
20
19
|
() => {
|
|
21
20
|
const result = _.at(3)([1, 20, 300])
|
|
22
|
-
if (result !==
|
|
21
|
+
if (result !== null) { throw result }
|
|
23
22
|
}
|
|
24
23
|
],
|
|
25
24
|
first: [
|
|
@@ -29,7 +28,7 @@ module.exports = {
|
|
|
29
28
|
},
|
|
30
29
|
() => {
|
|
31
30
|
const result = _.first([])
|
|
32
|
-
if (result !==
|
|
31
|
+
if (result !== null) { throw result }
|
|
33
32
|
}
|
|
34
33
|
],
|
|
35
34
|
last: [
|
|
@@ -39,54 +38,51 @@ module.exports = {
|
|
|
39
38
|
},
|
|
40
39
|
() => {
|
|
41
40
|
const result = _.last([])
|
|
42
|
-
if (result !==
|
|
41
|
+
if (result !== null) { throw result }
|
|
43
42
|
}
|
|
44
43
|
],
|
|
45
44
|
head: [
|
|
46
45
|
() => {
|
|
47
46
|
const result = _.head([1, 20, 300])
|
|
48
|
-
if (result ===
|
|
47
|
+
if (result === null) { throw result }
|
|
49
48
|
const str = stringify(result)
|
|
50
49
|
if (str !== '[1,20]') { throw str }
|
|
51
50
|
},
|
|
52
51
|
() => {
|
|
53
52
|
const result = _.head([])
|
|
54
|
-
if (result !==
|
|
53
|
+
if (result !== null) { throw result }
|
|
55
54
|
}
|
|
56
55
|
],
|
|
57
56
|
tail: [
|
|
58
57
|
() => {
|
|
59
58
|
const result = _.tail([1, 20, 300])
|
|
60
|
-
if (result === undefined) { throw result }
|
|
61
59
|
const str = stringify(result)
|
|
62
60
|
if (str !== '[20,300]') { throw str }
|
|
63
61
|
},
|
|
64
62
|
() => {
|
|
65
63
|
const result = _.tail([])
|
|
66
|
-
if (result !==
|
|
64
|
+
if (result !== null) { throw result }
|
|
67
65
|
}
|
|
68
66
|
],
|
|
69
67
|
|
|
70
68
|
splitFirst: [
|
|
71
69
|
() => {
|
|
72
70
|
const result = _.splitFirst([1, 20, 300])
|
|
73
|
-
if (result === undefined) { throw result }
|
|
74
71
|
const str = stringify(result)
|
|
75
72
|
if (str !== '[1,[20,300]]') { throw str }
|
|
76
73
|
},
|
|
77
74
|
() => {
|
|
78
75
|
const result = _.splitFirst([])
|
|
79
|
-
if (result !==
|
|
76
|
+
if (result !== null) { throw result }
|
|
80
77
|
},
|
|
81
78
|
() => {
|
|
82
79
|
const result = _.splitLast([1, 20, 300])
|
|
83
|
-
if (result === undefined) { throw result }
|
|
84
80
|
const str = stringify(result)
|
|
85
81
|
if (str !== '[[1,20],300]') { throw str }
|
|
86
82
|
},
|
|
87
83
|
() => {
|
|
88
84
|
const result = _.splitLast([])
|
|
89
|
-
if (result !==
|
|
85
|
+
if (result !== null) { throw result }
|
|
90
86
|
}
|
|
91
87
|
]
|
|
92
88
|
}
|
package/types/list/module.f.cjs
CHANGED
|
@@ -23,9 +23,11 @@ const {
|
|
|
23
23
|
* } NotLazy
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
/** @typedef {undefined} Empty */
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* @template T
|
|
28
|
-
* @typedef {
|
|
30
|
+
* @typedef {Empty | NonEmpty<T>} Result
|
|
29
31
|
*/
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -36,7 +38,6 @@ const {
|
|
|
36
38
|
/**
|
|
37
39
|
* @template T
|
|
38
40
|
* @typedef {{
|
|
39
|
-
* readonly isConcat?: undefined
|
|
40
41
|
* readonly first: T
|
|
41
42
|
* readonly tail: List<T>
|
|
42
43
|
* }} NonEmpty
|
|
@@ -45,7 +46,6 @@ const {
|
|
|
45
46
|
/**
|
|
46
47
|
* @template T
|
|
47
48
|
* @typedef {{
|
|
48
|
-
* readonly isConcat: true
|
|
49
49
|
* readonly a: List<T>
|
|
50
50
|
* readonly b: List<T>
|
|
51
51
|
* }} Concat
|
|
@@ -78,7 +78,7 @@ const next = list => {
|
|
|
78
78
|
|
|
79
79
|
if (a instanceof Array) {
|
|
80
80
|
a = fromArray(a)
|
|
81
|
-
} else if (a
|
|
81
|
+
} else if (a !== undefined && 'a' in a) {
|
|
82
82
|
[a, b] = [a.a, concat(a.b)(b)]
|
|
83
83
|
continue
|
|
84
84
|
}
|