0
# Destructuring Helpers
1
2
Support for destructuring assignments, rest/spread operators, and array/object manipulation patterns.
3
4
## Capabilities
5
6
### Array Destructuring
7
8
#### _sliced_to_array
9
10
Converts arrays to fixed-length arrays for destructuring.
11
12
```javascript { .api }
13
/**
14
* Converts arrays to fixed-length arrays for destructuring
15
* @param {Array} arr - Source array
16
* @param {number} i - Maximum number of elements
17
* @returns {Array} Fixed-length array
18
*/
19
function _sliced_to_array(arr, i): Array;
20
```
21
22
**Usage Example:**
23
24
```javascript
25
// For: const [a, b] = someArray;
26
const [a, b] = _sliced_to_array(someArray, 2);
27
```
28
29
#### _sliced_to_array_loose
30
31
Loose mode array slicing for destructuring.
32
33
```javascript { .api }
34
/**
35
* Loose mode array slicing for destructuring
36
* @param {Array} arr - Source array
37
* @param {number} i - Maximum number of elements
38
* @returns {Array} Sliced array
39
*/
40
function _sliced_to_array_loose(arr, i): Array;
41
```
42
43
#### _to_array
44
45
Converts iterables to arrays for destructuring.
46
47
```javascript { .api }
48
/**
49
* Converts iterables to arrays for destructuring
50
* @param {Iterable} arr - Iterable to convert
51
* @returns {Array} Converted array
52
*/
53
function _to_array(arr): Array;
54
```
55
56
#### _array_with_holes
57
58
Handles arrays with holes in destructuring.
59
60
```javascript { .api }
61
/**
62
* Handles arrays with holes in destructuring
63
* @param {Array} arr - Array with potential holes
64
* @returns {Array} Array with holes preserved
65
*/
66
function _array_with_holes(arr): Array;
67
```
68
69
#### _array_without_holes
70
71
Converts arrays to dense arrays (removes holes).
72
73
```javascript { .api }
74
/**
75
* Converts arrays to dense arrays (removes holes)
76
* @param {Array} arr - Array with potential holes
77
* @returns {Array} Dense array
78
*/
79
function _array_without_holes(arr): Array;
80
```
81
82
#### _array_like_to_array
83
84
Converts array-like objects to arrays.
85
86
```javascript { .api }
87
/**
88
* Converts array-like objects to arrays
89
* @param {ArrayLike} o - Array-like object
90
* @param {number} minLen - Minimum length
91
* @returns {Array} Converted array
92
*/
93
function _array_like_to_array(o, minLen): Array;
94
```
95
96
### Iterable Helpers
97
98
#### _iterable_to_array
99
100
Converts iterables to arrays.
101
102
```javascript { .api }
103
/**
104
* Converts iterables to arrays
105
* @param {Iterable} iter - Iterable to convert
106
* @returns {Array} Converted array
107
*/
108
function _iterable_to_array(iter): Array;
109
```
110
111
#### _iterable_to_array_limit
112
113
Converts iterables to arrays with length limit.
114
115
```javascript { .api }
116
/**
117
* Converts iterables to arrays with length limit
118
* @param {Iterable} arr - Iterable to convert
119
* @param {number} i - Maximum length
120
* @returns {Array} Limited array
121
*/
122
function _iterable_to_array_limit(arr, i): Array;
123
```
124
125
#### _iterable_to_array_limit_loose
126
127
Loose mode iterable to array conversion with limit.
128
129
```javascript { .api }
130
/**
131
* Loose mode iterable to array conversion with limit
132
* @param {Iterable} arr - Iterable to convert
133
* @param {number} i - Maximum length
134
* @returns {Array} Limited array
135
*/
136
function _iterable_to_array_limit_loose(arr, i): Array;
137
```
138
139
#### _unsupported_iterable_to_array
140
141
Handles unsupported iterables with fallbacks.
142
143
```javascript { .api }
144
/**
145
* Handles unsupported iterables with fallbacks
146
* @param {any} o - Object to convert
147
* @param {number} minLen - Minimum length
148
* @returns {Array} Converted array
149
* @throws {TypeError} If conversion not possible
150
*/
151
function _unsupported_iterable_to_array(o, minLen): Array;
152
```
153
154
### Spread Operators
155
156
#### _to_consumable_array
157
158
Converts iterables to consumable arrays for spread operations.
159
160
```javascript { .api }
161
/**
162
* Converts iterables to consumable arrays for spread operations
163
* @param {Iterable} arr - Iterable to convert
164
* @returns {Array} Consumable array
165
*/
166
function _to_consumable_array(arr): Array;
167
```
168
169
#### _non_iterable_spread
170
171
Handles non-iterable values in spread operations.
172
173
```javascript { .api }
174
/**
175
* Handles non-iterable values in spread operations
176
* @throws {TypeError} Non-iterable spread error
177
*/
178
function _non_iterable_spread(): never;
179
```
180
181
#### _non_iterable_rest
182
183
Handles non-iterable values in rest patterns.
184
185
```javascript { .api }
186
/**
187
* Handles non-iterable values in rest patterns
188
* @throws {TypeError} Non-iterable rest error
189
*/
190
function _non_iterable_rest(): never;
191
```
192
193
### Object Destructuring
194
195
#### _object_without_properties
196
197
Removes specified properties from objects.
198
199
```javascript { .api }
200
/**
201
* Removes specified properties from objects
202
* @param {Object} source - Source object
203
* @param {Array} excluded - Properties to exclude
204
* @returns {Object} Object without excluded properties
205
*/
206
function _object_without_properties(source, excluded): Object;
207
```
208
209
**Usage Example:**
210
211
```javascript
212
// For: const {a, ...rest} = obj;
213
const rest = _object_without_properties(obj, ["a"]);
214
```
215
216
#### _object_without_properties_loose
217
218
Loose mode object property exclusion.
219
220
```javascript { .api }
221
/**
222
* Loose mode object property exclusion
223
* @param {Object} source - Source object
224
* @param {Array} excluded - Properties to exclude
225
* @returns {Object} Object without excluded properties
226
*/
227
function _object_without_properties_loose(source, excluded): Object;
228
```
229
230
#### _object_destructuring_empty
231
232
Handles empty object destructuring patterns.
233
234
```javascript { .api }
235
/**
236
* Handles empty object destructuring patterns
237
* @param {any} obj - Object to check
238
* @throws {TypeError} If obj is null or undefined
239
*/
240
function _object_destructuring_empty(obj): void;
241
```
242
243
### Object Spread
244
245
#### _object_spread
246
247
Handles object spread operations.
248
249
```javascript { .api }
250
/**
251
* Handles object spread operations
252
* @param {...Object} sources - Source objects to spread
253
* @returns {Object} Merged object
254
*/
255
function _object_spread(...sources): Object;
256
```
257
258
#### _object_spread_props
259
260
Handles object spread with specific properties.
261
262
```javascript { .api }
263
/**
264
* Handles object spread with specific properties
265
* @param {Object} target - Target object
266
* @param {Array} sources - Source objects and properties
267
* @returns {Object} Object with spread properties
268
*/
269
function _object_spread_props(target, sources): Object;
270
```
271
272
### General Object Utilities
273
274
#### _extends
275
276
Extends objects (similar to Object.assign).
277
278
```javascript { .api }
279
/**
280
* Extends objects (similar to Object.assign)
281
* @param {Object} target - Target object
282
* @param {...Object} sources - Source objects
283
* @returns {Object} Extended object
284
*/
285
function _extends(target, ...sources): Object;
286
```
287
288
#### _defaults
289
290
Sets default property values on objects.
291
292
```javascript { .api }
293
/**
294
* Sets default property values on objects
295
* @param {Object} obj - Target object
296
* @param {...Object} defaults - Default value objects
297
* @returns {Object} Object with defaults applied
298
*/
299
function _defaults(obj, ...defaults): Object;
300
```