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
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/array/base/getter/README.md
+27-16
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,9 @@ limitations under the License.
18
18
19
19
-->
20
20
21
-
# get
21
+
# getter
22
22
23
-
> Return an element from an indexed array-like object.
23
+
> Return an accessor function for retrieving an element from an indexed array-like object.
24
24
25
25
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26
26
@@ -37,20 +37,26 @@ limitations under the License.
37
37
## Usage
38
38
39
39
```javascript
40
-
varget=require( '@stdlib/array/base/get' );
40
+
vargetter=require( '@stdlib/array/base/getter' );
41
41
```
42
42
43
-
#### get( arr, idx )
43
+
#### getter( dtype )
44
44
45
-
Returns an element from an indexed array-like object.
45
+
Returns an accessor function for retrieving an element from an indexed array-like object.
46
46
47
47
```javascript
48
48
var arr = [ 1, 2, 3, 4 ];
49
49
50
+
var get =getter( 'generic' );
50
51
var v =get( arr, 2 );
51
52
// returns 3
52
53
```
53
54
55
+
The returned accessor function accepts the following arguments:
56
+
57
+
-**arr**: input array.
58
+
-**idx**: element index.
59
+
54
60
</section>
55
61
56
62
<!-- /.usage -->
@@ -61,7 +67,9 @@ var v = get( arr, 2 );
61
67
62
68
## Notes
63
69
64
-
- The function does **not** perform bounds checking.
70
+
- If provided an unrecognized [`dtype`][@stdlib/array/dtypes], the function returns a default accessor function for accessing elements from any indexed array-like object; otherwise, the function returns an accessor function which should **only** be provided an array instance corresponding to `dtype` (e.g., if `dtype` is `'float64'`, the returned accessor function should only be provided instances of `Float64Array`).
71
+
- Accessor functions do **not** verify that provided input arrays are array instances corresponding to `dtype`, as doing so would introduce performance overhead. If array instances corresponding to other data types are provided to an accessor function, JavaScript runtimes will consider the function polymorphic, potentially triggering de-optimization. In order to ensure maximum performance, **always** ensure that an accessor function is monomorphic.
72
+
- Accessor functions do **not** perform bounds checking.
65
73
- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices via bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`).
66
74
67
75
</section>
@@ -78,42 +86,43 @@ var v = get( arr, 2 );
78
86
79
87
```javascript
80
88
var filled =require( '@stdlib/array/filled' );
81
-
var get =require( '@stdlib/array/base/get' );
89
+
var dtype =require( '@stdlib/array/dtype' );
90
+
var getter =require( '@stdlib/array/base/getter' );
0 commit comments