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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.276",
3
+ "version": "0.0.277",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,53 +3,48 @@ const seq = require('../list')
3
3
 
4
4
  /**
5
5
  * @template T
6
- * @typedef {readonly T[]} Array
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 [T, T]} Array2
13
+ * @typedef {readonly[T, T]} Array2
19
14
  */
20
15
 
21
16
  /**
22
17
  * @template T0
23
18
  * @template T1
24
- * @typedef {readonly [T0, T1]} Tuple2
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 [T, T, T]} Array3
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 [T0, T1, T2]} Tuple3
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 [T, T, T, T]} Array4
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 [T, T, T, T, T]} Array5
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>(_: Array<T>) => Array<T>} */
57
+ /** @type {<T>(_: readonly T[]) => readonly T[]} */
63
58
  const uncheckTail = a => a.slice(1)
64
59
 
65
- /** @type {<T>(_: Array<T>) => Array<T>} */
60
+ /** @type {<T>(_: readonly T[]) => readonly T[]} */
66
61
  const uncheckHead = a => a.slice(0, -1)
67
62
 
68
- /** @type {<T>(_: Array<T>) => T|undefined} */
63
+ /** @type {<T>(_: readonly T[]) => T|undefined} */
69
64
  const first = a => a[0]
70
65
 
71
- /** @type {<T>(_: Array<T>) => T|undefined} */
66
+ /** @type {<T>(_: readonly T[]) => T|undefined} */
72
67
  const last = a => a[a.length - 1]
73
68
 
74
- /** @type {<T>(_: Array<T>) => Array<T>|undefined} */
69
+ /** @type {<T>(_: readonly T[]) => readonly T[] | undefined} */
75
70
  const tail = a => a.length === 0 ? undefined : uncheckTail(a)
76
71
 
77
- /** @type {<T>(_: Array<T>) => readonly [T, Array<T>]|undefined} */
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 [T, Array<T>]} */
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>(_: Array<T>) => Array<T>|undefined} */
80
+ /** @type {<T>(_: readonly T[]) => readonly T[]|undefined} */
86
81
  const head = a => a.length === 0 ? undefined : uncheckHead(a)
87
82
 
88
- /** @type {<T>(_: Array<T>) => readonly [Array<T>, T]|undefined} */
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: Array<T>) => readonly[T]|undefined} */
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 = {
@@ -2,7 +2,7 @@ const _ = require('.')
2
2
  const json = require('../../json')
3
3
  const { sort } = require('../object')
4
4
 
5
- /** @type {(a: _.Array<json.Unknown>) => string} */
5
+ /** @type {(a: readonly json.Unknown[]) => string} */
6
6
  const stringify = a => json.stringify(sort)(a)
7
7
 
8
8
  {