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/float32/README.md
+111-1
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,8 @@ var arr = new Float32Array( buf, 0, 4 );
105
105
106
106
### Properties
107
107
108
+
<aname="static-prop-bytes-per-element"></a>
109
+
108
110
#### Float32Array.BYTES_PER_ELEMENT
109
111
110
112
Number of bytes per view element.
@@ -116,6 +118,8 @@ var nbytes = Float32Array.BYTES_PER_ELEMENT;
116
118
// returns 4
117
119
```
118
120
121
+
<aname="static-prop-name"></a>
122
+
119
123
#### Float32Array.name
120
124
121
125
[Typed array][mdn-typed-array] constructor name.
@@ -127,6 +131,8 @@ var str = Float32Array.name;
127
131
// returns 'Float32Array'
128
132
```
129
133
134
+
<aname="prop-buffer"></a>
135
+
130
136
#### Float32Array.prototype.buffer
131
137
132
138
**Read-only** property which returns the [`ArrayBuffer`][mdn-arraybuffer] referenced by the [typed array][mdn-typed-array].
@@ -139,6 +145,8 @@ var buf = arr.buffer;
139
145
// returns <ArrayBuffer>
140
146
```
141
147
148
+
<aname="prop-byte-length"></a>
149
+
142
150
#### Float32Array.prototype.byteLength
143
151
144
152
**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array].
@@ -151,6 +159,8 @@ var byteLength = arr.byteLength;
151
159
// returns 20
152
160
```
153
161
162
+
<aname="prop-byte-offset"></a>
163
+
154
164
#### Float32Array.prototype.byteOffset
155
165
156
166
**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][mdn-arraybuffer].
@@ -163,6 +173,8 @@ var byteOffset = arr.byteOffset;
163
173
// returns 0
164
174
```
165
175
176
+
<aname="prop-bytes-per-element"></a>
177
+
166
178
#### Float32Array.prototype.BYTES_PER_ELEMENT
167
179
168
180
Number of bytes per view element.
@@ -175,6 +187,8 @@ var nbytes = arr.BYTES_PER_ELEMENT;
175
187
// returns 4
176
188
```
177
189
190
+
<aname="prop-length"></a>
191
+
178
192
#### Float32Array.prototype.length
179
193
180
194
**Read-only** property which returns the number of view elements.
@@ -191,7 +205,103 @@ var len = arr.length;
191
205
192
206
### Methods
193
207
194
-
TODO: add methods
208
+
<aname="static-method-from"></a>
209
+
210
+
#### factory.from( src\[, map\[, thisArg]] )
211
+
212
+
Creates a new named typed tuple from an array-like `object` or an iterable.
213
+
214
+
```javascript
215
+
var factory =namedtypedtuple( [ 'x', 'y' ] );
216
+
217
+
var tuple =factory.from( [ 1.0, -1.0 ] );
218
+
219
+
var x =tuple.x;
220
+
// returns 1.0
221
+
222
+
x = tuple[ 0 ];
223
+
// returns 1.0
224
+
225
+
var y =tuple.y;
226
+
// returns -1.0
227
+
228
+
y = tuple[ 1 ];
229
+
// returns -1.0
230
+
```
231
+
232
+
To invoke a function for each `src` value, provide a callback function.
233
+
234
+
```javascript
235
+
var factory =namedtypedtuple( [ 'x', 'y' ] );
236
+
237
+
functionmapFcn( v ) {
238
+
return v *2.0;
239
+
}
240
+
241
+
var tuple =factory.from( [ 1.0, -1.0 ], mapFcn );
242
+
243
+
var x =tuple.x;
244
+
// returns 2.0
245
+
246
+
x = tuple[ 0 ];
247
+
// returns 2.0
248
+
249
+
var y =tuple.y;
250
+
// returns -2.0
251
+
252
+
y = tuple[ 1 ];
253
+
// returns -2.0
254
+
```
255
+
256
+
A callback function is provided three arguments:
257
+
258
+
-`value`: source value
259
+
-`index`: source index
260
+
-`field`: tuple field
261
+
262
+
To set the callback execution context, provide a `thisArg`.
263
+
264
+
```javascript
265
+
var factory =namedtypedtuple( [ 'x', 'y' ] );
266
+
267
+
functionmapFcn( v ) {
268
+
this.count+=1;
269
+
return v *2.0;
270
+
}
271
+
272
+
var ctx = {
273
+
'count':0
274
+
};
275
+
276
+
var tuple =factory.from( [ 1.0, -1.0 ], mapFcn, ctx );
0 commit comments