Skip to content

Commit 6d2acc8

Browse files
committed
Auto-generated commit
1 parent 5acb289 commit 6d2acc8

2 files changed

Lines changed: 303 additions & 4 deletions

File tree

base/assert/docs/types/index.d.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,34 @@
2121
/* tslint:disable:max-line-length */
2222
/* tslint:disable:max-file-line-count */
2323

24+
import isAccessorArray = require( './../../../../base/assert/is-accessor-array' );
25+
2426
/**
2527
* Interface describing the `assert` namespace.
2628
*/
27-
interface Namespace {}
29+
interface Namespace {
30+
/**
31+
* Tests if an array-like object supports the accessor (get/set) protocol.
32+
*
33+
* @param value - value to test
34+
* @returns boolean indicating whether a value is an accessor array
35+
*
36+
* @example
37+
* var Complex128Array = require( `@stdlib/array/complex128` );
38+
*
39+
* var arr = new Complex128Array( 10 );
40+
* var bool = ns.isAccessorArray( arr );
41+
* // returns true
42+
*
43+
* @example
44+
* var bool = ns.isAccessorArray( [] );
45+
* // returns false
46+
*/
47+
isAccessorArray: typeof isAccessorArray;
48+
}
2849

2950
/**
30-
* Assert utilities.
51+
* Base array assertion utilities.
3152
*/
3253
declare var ns: Namespace;
3354

base/docs/types/index.d.ts

Lines changed: 280 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,120 @@
2121
/* tslint:disable:max-line-length */
2222
/* tslint:disable:max-file-line-count */
2323

24+
import accessorGetter = require( './../../../base/accessor-getter' );
25+
import accessorSetter = require( './../../../base/accessor-setter' );
26+
import accessors = require( './../../../base/accessors' );
2427
import arraylike2object = require( './../../../base/arraylike2object' );
28+
import assert = require( './../../../base/assert' );
29+
import cartesianPower = require( './../../../base/cartesian-power' );
30+
import cartesianProduct = require( './../../../base/cartesian-product' );
31+
import cartesianSquare = require( './../../../base/cartesian-square' );
2532
import copy = require( './../../../base/copy' );
33+
import copyIndexed = require( './../../../base/copy-indexed' );
2634
import filled = require( './../../../base/filled' );
2735
import filledBy = require( './../../../base/filled-by' );
36+
import getter = require( './../../../base/getter' );
2837
import incrspace = require( './../../../base/incrspace' );
2938
import linspace = require( './../../../base/linspace' );
3039
import logspace = require( './../../../base/logspace' );
40+
import nCartesianProduct = require( './../../../base/n-cartesian-product' );
3141
import ones = require( './../../../base/ones' );
42+
import setter = require( './../../../base/setter' );
43+
import take = require( './../../../base/take' );
3244
import unitspace = require( './../../../base/unitspace' );
45+
import zeroTo = require( './../../../base/zero-to' );
3346
import zeros = require( './../../../base/zeros' );
3447

3548
/**
3649
* Interface describing the `base` namespace.
3750
*/
3851
interface Namespace {
52+
/**
53+
* 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: typeof accessorGetter;
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: typeof accessorSetter;
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: typeof accessors;
137+
39138
/**
40139
* Converts a one-dimensional array-like object to an object likely to have the same "shape".
41140
*
@@ -47,13 +146,90 @@ interface Namespace {
47146
* @returns object containing array data
48147
*
49148
* @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+
};
52156
* var obj = ns.arraylike2object( x );
53157
* // 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
54167
*/
55168
arraylike2object: typeof arraylike2object;
56169

170+
/**
171+
* Base array assertion utilities.
172+
*/
173+
assert: typeof assert;
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.
182+
*
183+
* @param x - input array
184+
* @param n - power
185+
* @returns Cartesian product
186+
*
187+
* @example
188+
* var x = [ 1, 2 ];
189+
*
190+
* var out = ns.cartesianPower( x, 2 );
191+
* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]
192+
*/
193+
cartesianPower: typeof cartesianPower;
194+
195+
/**
196+
* Returns the Cartesian product.
197+
*
198+
* ## Notes
199+
*
200+
* - If provided one or more empty arrays, the function returns an empty array.
201+
*
202+
* @param x1 - first input array
203+
* @param x2 - second input array
204+
* @returns Cartesian product
205+
*
206+
* @example
207+
* var x1 = [ 1, 2, 3 ];
208+
* var x2 = [ 4, 5 ];
209+
*
210+
* var out = ns.cartesianProduct( x1, x2 );
211+
* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]
212+
*/
213+
cartesianProduct: typeof cartesianProduct;
214+
215+
/**
216+
* Returns the Cartesian square.
217+
*
218+
* ## Notes
219+
*
220+
* - If provided an empty array, the function returns an empty array.
221+
*
222+
* @param x - input array
223+
* @returns Cartesian product
224+
*
225+
* @example
226+
* var x = [ 1, 2 ];
227+
*
228+
* var out = ns.cartesianSquare( x );
229+
* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]
230+
*/
231+
cartesianSquare: typeof cartesianSquare;
232+
57233
/**
58234
* Copies the elements of an array-like object to a new "generic" array.
59235
*
@@ -68,6 +244,20 @@ interface Namespace {
68244
*/
69245
copy: typeof copy;
70246

247+
/**
248+
* Copies the elements of an indexed array-like object to a new "generic" array.
249+
*
250+
* @param x - array length
251+
* @returns output array
252+
*
253+
* @example
254+
* var x = [ 1, 2, 3 ];
255+
*
256+
* var out = ns.copyIndexed( x );
257+
* // returns [ 1, 2, 3 ]
258+
*/
259+
copyIndexed: typeof copyIndexed;
260+
71261
/**
72262
* Returns a filled "generic" array.
73263
*
@@ -101,6 +291,23 @@ interface Namespace {
101291
*/
102292
filledBy: typeof filledBy;
103293

294+
/**
295+
* Returns an accessor function for retrieving an element from an indexed array-like object.
296+
*
297+
* @param dtype - data type
298+
* @returns accessor function
299+
*
300+
* @example
301+
* var dtype = require( `@stdlib/array/dtype` );
302+
*
303+
* var arr = [ 1, 2, 3, 4 ];
304+
*
305+
* var get = ns.getter( dtype( arr ) );
306+
* var v = get( arr, 2 );
307+
* // returns 3
308+
*/
309+
getter: typeof getter;
310+
104311
/**
105312
* Generates a linearly spaced numeric array according to a provided increment.
106313
*
@@ -143,6 +350,27 @@ interface Namespace {
143350
*/
144351
logspace: typeof logspace;
145352

353+
/**
354+
* Returns the n-fold Cartesian product.
355+
*
356+
* ## Notes
357+
*
358+
* - If provided one or more empty arrays, the function returns an empty array.
359+
*
360+
* @param x1 - first input array
361+
* @param x2 - second input array
362+
* @param xN - additional input arrays
363+
* @returns Cartesian product
364+
*
365+
* @example
366+
* var x1 = [ 1, 2, 3 ];
367+
* var x2 = [ 4, 5 ];
368+
*
369+
* var out = ns.nCartesianProduct( x1, x2 );
370+
* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]
371+
*/
372+
nCartesianProduct: typeof nCartesianProduct;
373+
146374
/**
147375
* Returns a "generic" array filled with ones.
148376
*
@@ -155,6 +383,44 @@ interface Namespace {
155383
*/
156384
ones: typeof ones;
157385

386+
/**
387+
* 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: typeof setter;
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: typeof take;
423+
158424
/**
159425
* Generates a linearly spaced numeric array whose elements increment by 1.
160426
*
@@ -168,6 +434,18 @@ interface Namespace {
168434
*/
169435
unitspace: typeof unitspace;
170436

437+
/**
438+
* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero.
439+
*
440+
* @param n - number of elements
441+
* @returns linearly spaced numeric array
442+
*
443+
* @example
444+
* var arr = ns.zeroTo( 6 );
445+
* // returns [ 0, 1, 2, 3, 4, 5 ]
446+
*/
447+
zeroTo: typeof zeroTo;
448+
171449
/**
172450
* Returns a zero-filled "generic" array.
173451
*

0 commit comments

Comments
 (0)