You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol.
54
+
*
55
+
* @param dtype - data type
56
+
* @returns accessor function
57
+
*
58
+
* @example
59
+
* var arr = [ 1, 2, 3, 4 ];
60
+
*
61
+
* function aget( idx ) {
62
+
* return arr[ idx ];
63
+
* }
64
+
*
65
+
* function aset( value, idx ) {
66
+
* arr[ idx ] = value;
67
+
* }
68
+
*
69
+
* arr.get = aget;
70
+
* arr.set = aset;
71
+
*
72
+
* var get = ns.accessorGetter( 'foo' );
73
+
* var v = get( arr, 2 );
74
+
* // returns 3
75
+
*/
76
+
accessorGetter: typeofaccessorGetter;
77
+
78
+
/**
79
+
* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol.
80
+
*
81
+
* @param dtype - data type
82
+
* @returns accessor function
83
+
*
84
+
* @example
85
+
* var arr = [ 1, 2, 3, 4 ];
86
+
*
87
+
* function aget( idx ) {
88
+
* return arr[ idx ];
89
+
* }
90
+
*
91
+
* function aset( value, idx ) {
92
+
* arr[ idx ] = value;
93
+
* }
94
+
*
95
+
* arr.get = aget;
96
+
* arr.set = aset;
97
+
*
98
+
* var set = ns.accessorSetter( 'foo' );
99
+
* set( arr, 2, 10 );
100
+
*
101
+
* var v = arr.get( 2 );
102
+
* // returns 3
103
+
*/
104
+
accessorSetter: typeofaccessorSetter;
105
+
106
+
/**
107
+
* Returns element accessors for a provided array-like object.
108
+
*
109
+
* ## Notes
110
+
*
111
+
* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects.
112
+
*
113
+
* @param x - input array
114
+
* @returns object containing accessor data
115
+
*
116
+
* @example
117
+
* var x = {
118
+
* '0': 1,
119
+
* '1': 2,
120
+
* '2': 3,
121
+
* '4': 4,
122
+
* 'length': 4
123
+
};
124
+
* var obj = ns.accessors( x );
125
+
* // returns {...}
126
+
*
127
+
* var bool = obj.accessorProtocol;
128
+
* // returns false
129
+
*
130
+
* var fcns = obj.ns.accessors;
131
+
* // returns [ <Function>, <Function> ]
132
+
*
133
+
* var v = fcns[ 0 ]( x, 2 );
134
+
* // returns 3
135
+
*/
136
+
accessors: typeofaccessors;
137
+
39
138
/**
40
139
* Converts a one-dimensional array-like object to an object likely to have the same "shape".
41
140
*
@@ -47,13 +146,90 @@ interface Namespace {
47
146
* @returns object containing array data
48
147
*
49
148
* @example
50
-
* var x = [ 1, 2, 3, 4, 5, 6 ];
51
-
*
149
+
* var x = {
150
+
* '0': 1,
151
+
* '1': 2,
152
+
* '2': 3,
153
+
* '4': 4,
154
+
* 'length': 4
155
+
};
52
156
* var obj = ns.arraylike2object( x );
53
157
* // returns {...}
158
+
*
159
+
* var bool = obj.accessorProtocol;
160
+
* // returns false
161
+
*
162
+
* var fcns = obj.accessors;
163
+
* // returns [ <Function>, <Function> ]
164
+
*
165
+
* var v = fcns[ 0 ]( x.data, 2 );
166
+
* // returns 3
54
167
*/
55
168
arraylike2object: typeofarraylike2object;
56
169
170
+
/**
171
+
* Base array assertion utilities.
172
+
*/
173
+
assert: typeofassert;
174
+
175
+
/**
176
+
* Returns the Cartesian power.
177
+
*
178
+
* ## Notes
179
+
*
180
+
* - If provided an empty array, the function returns an empty array.
181
+
* - If `n` is less than or equal to zero, the function returns an empty array.
* Returns an accessor function for setting an element in an indexed array-like object.
388
+
*
389
+
* @param dtype - data type
390
+
* @returns accessor function
391
+
*
392
+
* @example
393
+
* var dtype = require( `@stdlib/array/dtype` );
394
+
*
395
+
* var arr = [ 0, 0, 0, 0 ];
396
+
*
397
+
* var set = ns.setter( dtype( arr ) );
398
+
* set( arr, 2, 3 );
399
+
*
400
+
* var v = arr[ 2 ];
401
+
* // returns 3
402
+
*/
403
+
setter: typeofsetter;
404
+
405
+
/**
406
+
* Takes element from an array.
407
+
*
408
+
* ## Notes
409
+
*
410
+
* - The function does **not** perform bounds checking. If an index is less than zero or greater than the maximum index of `x`, the value of the corresponding element in the output array is undefined.
411
+
*
412
+
* @param x - input array
413
+
* @param indices - list of element indices
414
+
* @returns output array
415
+
*
416
+
* @example
417
+
* var x = [ 1, 2, 3, 4 ];
418
+
*
419
+
* var y = ns.take( x, [ 1, 3 ] );
420
+
* // returns [ 2, 4 ]
421
+
*/
422
+
take: typeoftake;
423
+
158
424
/**
159
425
* Generates a linearly spaced numeric array whose elements increment by 1.
160
426
*
@@ -168,6 +434,18 @@ interface Namespace {
168
434
*/
169
435
unitspace: typeofunitspace;
170
436
437
+
/**
438
+
* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero.
0 commit comments