functionalscript 0.0.276 → 0.0.277
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/package.json +1 -1
- package/types/array/index.js +17 -22
- package/types/array/test.js +1 -1
package/package.json
CHANGED
package/types/array/index.js
CHANGED
|
@@ -3,53 +3,48 @@ const seq = require('../list')
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @template T
|
|
6
|
-
* @typedef {readonly
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @template T
|
|
11
|
-
* @typedef {readonly [T]} Array1
|
|
6
|
+
* @typedef {readonly[T]} Array1
|
|
12
7
|
*/
|
|
13
8
|
|
|
14
9
|
/** @typedef {0} Index1 */
|
|
15
10
|
|
|
16
11
|
/**
|
|
17
12
|
* @template T
|
|
18
|
-
* @typedef {readonly
|
|
13
|
+
* @typedef {readonly[T, T]} Array2
|
|
19
14
|
*/
|
|
20
15
|
|
|
21
16
|
/**
|
|
22
17
|
* @template T0
|
|
23
18
|
* @template T1
|
|
24
|
-
* @typedef {readonly
|
|
19
|
+
* @typedef {readonly[T0, T1]} Tuple2
|
|
25
20
|
*/
|
|
26
21
|
|
|
27
22
|
/** @typedef {0|1} Index2 */
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
25
|
* @template T
|
|
31
|
-
* @typedef {readonly
|
|
26
|
+
* @typedef {readonly[T, T, T]} Array3
|
|
32
27
|
*/
|
|
33
28
|
|
|
34
29
|
/**
|
|
35
30
|
* @template T0
|
|
36
31
|
* @template T1
|
|
37
32
|
* @template T2
|
|
38
|
-
* @typedef {readonly
|
|
33
|
+
* @typedef {readonly[T0, T1, T2]} Tuple3
|
|
39
34
|
*/
|
|
40
35
|
|
|
41
36
|
/** @typedef {0|1|2} Index3 */
|
|
42
37
|
|
|
43
38
|
/**
|
|
44
39
|
* @template T
|
|
45
|
-
* @typedef {readonly
|
|
40
|
+
* @typedef {readonly[T, T, T, T]} Array4
|
|
46
41
|
*/
|
|
47
42
|
|
|
48
43
|
/** @typedef {0|1|2|3} Index4 */
|
|
49
44
|
|
|
50
45
|
/**
|
|
51
46
|
* @template T
|
|
52
|
-
* @typedef {readonly
|
|
47
|
+
* @typedef {readonly[T, T, T, T, T]} Array5
|
|
53
48
|
*/
|
|
54
49
|
|
|
55
50
|
/**
|
|
@@ -59,40 +54,40 @@ const seq = require('../list')
|
|
|
59
54
|
|
|
60
55
|
/** @typedef {0|1|2|3|4} Index5 */
|
|
61
56
|
|
|
62
|
-
/** @type {<T>(_:
|
|
57
|
+
/** @type {<T>(_: readonly T[]) => readonly T[]} */
|
|
63
58
|
const uncheckTail = a => a.slice(1)
|
|
64
59
|
|
|
65
|
-
/** @type {<T>(_:
|
|
60
|
+
/** @type {<T>(_: readonly T[]) => readonly T[]} */
|
|
66
61
|
const uncheckHead = a => a.slice(0, -1)
|
|
67
62
|
|
|
68
|
-
/** @type {<T>(_:
|
|
63
|
+
/** @type {<T>(_: readonly T[]) => T|undefined} */
|
|
69
64
|
const first = a => a[0]
|
|
70
65
|
|
|
71
|
-
/** @type {<T>(_:
|
|
66
|
+
/** @type {<T>(_: readonly T[]) => T|undefined} */
|
|
72
67
|
const last = a => a[a.length - 1]
|
|
73
68
|
|
|
74
|
-
/** @type {<T>(_:
|
|
69
|
+
/** @type {<T>(_: readonly T[]) => readonly T[] | undefined} */
|
|
75
70
|
const tail = a => a.length === 0 ? undefined : uncheckTail(a)
|
|
76
71
|
|
|
77
|
-
/** @type {<T>(_:
|
|
72
|
+
/** @type {<T>(_: readonly T[]) => readonly[T, readonly T[]]|undefined} */
|
|
78
73
|
const splitFirst = a => {
|
|
79
74
|
/** @typedef {typeof a[0]} T*/
|
|
80
|
-
/** @type {(_: T) => readonly
|
|
75
|
+
/** @type {(_: T) => readonly[T, readonly T[]]} */
|
|
81
76
|
const split = first => [first, uncheckTail(a)]
|
|
82
77
|
return option.map(split)(a[0])
|
|
83
78
|
}
|
|
84
79
|
|
|
85
|
-
/** @type {<T>(_:
|
|
80
|
+
/** @type {<T>(_: readonly T[]) => readonly T[]|undefined} */
|
|
86
81
|
const head = a => a.length === 0 ? undefined : uncheckHead(a)
|
|
87
82
|
|
|
88
|
-
/** @type {<T>(_:
|
|
83
|
+
/** @type {<T>(_: readonly T[]) => readonly[readonly T[], T]|undefined} */
|
|
89
84
|
const splitLast = a => {
|
|
90
85
|
const lastA = last(a)
|
|
91
86
|
if (lastA === undefined) { return undefined }
|
|
92
87
|
return [uncheckHead(a), lastA]
|
|
93
88
|
}
|
|
94
89
|
|
|
95
|
-
/** @type {(index: number) => <T>(a:
|
|
90
|
+
/** @type {(index: number) => <T>(a: readonly T[]) => readonly[T]|undefined} */
|
|
96
91
|
const at = index => a => index < a.length ? [a[index]] : undefined
|
|
97
92
|
|
|
98
93
|
module.exports = {
|
package/types/array/test.js
CHANGED