@rimbu/deep 0.8.2 → 0.9.2

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/src/tuple.ts CHANGED
@@ -21,8 +21,10 @@ export namespace Tuple {
21
21
  * Convenience method to type Tuple types
22
22
  * @param values - the values of the tuple
23
23
  * @example
24
+ * ```ts
24
25
  * const t = Tuple.of(1, 'a', true)
25
26
  * // type of t => Tuple<[number, string, boolean]>
27
+ * ```
26
28
  */
27
29
  export function of<T extends Tuple.NonEmptySource>(...values: T): Tuple<T> {
28
30
  return values as any;
@@ -33,9 +35,11 @@ export namespace Tuple {
33
35
  * @param tuple - the tuple to get the item from
34
36
  * @param index - the index in of the tuple element
35
37
  * @example
38
+ * ```ts
36
39
  * const t = Tuple.of(1, 'a', true)
37
40
  * console.log(Tuple.getIndex(t, 1))
38
41
  * // => 'a'
42
+ * ```
39
43
  */
40
44
  export function getIndex<T extends Tuple.Source, K extends keyof T = keyof T>(
41
45
  tuple: T,
@@ -48,9 +52,11 @@ export namespace Tuple {
48
52
  * Returns the first element of a Tuple.
49
53
  * @param tuple - the source tuple
50
54
  * @example
55
+ * ```ts
51
56
  * const t = Tuple.of(1, 'a', true)
52
57
  * console.log(Tuple.first(t))
53
58
  * // => 1
59
+ * ```
54
60
  */
55
61
  export function first<T extends Tuple.Source>(tuple: T): T[0] {
56
62
  return tuple[0];
@@ -60,9 +66,11 @@ export namespace Tuple {
60
66
  * Returns the second element of a Tuple.
61
67
  * @param tuple - the source tuple
62
68
  * @example
69
+ * ```ts
63
70
  * const t = Tuple.of(1, 'a', true)
64
71
  * console.log(Tuple.second(t))
65
72
  * // => 'a'
73
+ * ```
66
74
  */
67
75
  export function second<T extends Tuple.Source>(tuple: T): T[1] {
68
76
  return tuple[1];
@@ -72,9 +80,11 @@ export namespace Tuple {
72
80
  * Returns the last element of a Tuple.
73
81
  * @param tuple - the source tuple
74
82
  * @example
83
+ * ```ts
75
84
  * const t = Tuple.of(1, 'a', true)
76
85
  * console.log(Tuple.last(t))
77
86
  * // => true
87
+ * ```
78
88
  */
79
89
  export function last<T extends readonly unknown[], R>(
80
90
  tuple: readonly [...T, R]
@@ -89,9 +99,11 @@ export namespace Tuple {
89
99
  * @param index - the index in the tuple
90
100
  * @param updater - the updater for the value
91
101
  * @example
102
+ * ```ts
92
103
  * const t = Tuple.of(1, 'a', true)
93
104
  * console.log(Tuple.updateAt(t, 1, 'b'))
94
105
  * // => [1, 'b', true]
106
+ * ```
95
107
  */
96
108
  export function updateAt<T extends Tuple.Source, K extends keyof T = keyof T>(
97
109
  tuple: T,
@@ -106,9 +118,11 @@ export namespace Tuple {
106
118
  * @param tuple - the source tuple
107
119
  * @param values - the values to append
108
120
  * @example
121
+ * ```ts
109
122
  * const t = Tuple.of(1, 'a')
110
123
  * console.log(Tuple.append(t, true, 5))
111
124
  * // => [1, 'a', true, 5]
125
+ * ```
112
126
  */
113
127
  export function append<
114
128
  T extends Tuple.Source,
@@ -123,10 +137,12 @@ export namespace Tuple {
123
137
  * @param tuple1 - the first Tuple
124
138
  * @param tuple2 - the second Tuple
125
139
  * @example
140
+ * ```ts
126
141
  * const t1 = Tuple.of(1, 'a')
127
142
  * const t2 = Tuple.of(true, 5)
128
143
  * console.log(Tuple.concat(t1, t2))
129
144
  * // => [1, 'a', true, 5]
145
+ * ```
130
146
  */
131
147
  export function concat<T1 extends Tuple.Source, T2 extends Tuple.Source>(
132
148
  tuple1: T1,
@@ -139,9 +155,11 @@ export namespace Tuple {
139
155
  * Returns a Tuple containing all but the last element of the given `tuple`.
140
156
  * @param tuple - the source tuple
141
157
  * @example
158
+ * ```ts
142
159
  * const t = Tuple.of(1, 'a', true)
143
160
  * console.log(Tuple.init(t))
144
161
  * // => [1, 'a']
162
+ * ```
145
163
  */
146
164
  export function init<T extends readonly unknown[]>(
147
165
  tuple: readonly [...T, unknown]
@@ -153,9 +171,11 @@ export namespace Tuple {
153
171
  * Returns a Tuple containing all but the first element of the given `tuple`.
154
172
  * @param tuple - the source tuple
155
173
  * @example
174
+ * ```ts
156
175
  * const t = Tuple.of(1, 'a', true)
157
176
  * console.log(Tuple.tail(t))
158
177
  * // => ['a', true]
178
+ * ```
159
179
  */
160
180
  export function tail<T extends readonly [...unknown[]]>(
161
181
  tuple: readonly [unknown, ...T]