Skip to content

Commit 8985944

Browse files
committed
arraybuffer docs, ref #1498 (comment)
1 parent 3355a5b commit 8985944

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/jswrap_arraybuffer.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
This is the built-in JavaScript class for array buffers.
2727
2828
If you want to access arrays of differing types of data
29-
you may also find [/Reference#DataView](DataView) useful.
29+
you may also find `DataView` useful.
3030
*/
3131

3232
/*JSON{
@@ -47,7 +47,7 @@ This is the built-in JavaScript class that is the prototype for:
4747
* [Float64Array](/Reference#Float64Array)
4848
4949
If you want to access arrays of differing types of data
50-
you may also find [DataView](/Reference#DataView) useful.
50+
you may also find `DataView` useful.
5151
*/
5252

5353
/*JSON{
@@ -226,7 +226,7 @@ JsVar *jswrap_arraybuffer_constructor(JsVarInt byteLength) {
226226
"generate_full" : "(JsVarInt)(parent->varData.arraybuffer.length)",
227227
"return" : ["int","The Length in bytes"]
228228
}
229-
The length, in bytes, of the ArrayBuffer
229+
The length, in bytes, of the `ArrayBuffer`
230230
*/
231231

232232

@@ -251,7 +251,7 @@ The length, in bytes, of the ArrayBuffer
251251
"return" : ["JsVar","A typed array"],
252252
"return_object" : "ArrayBufferView"
253253
}
254-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
254+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
255255
*/
256256
/*JSON{
257257
"type" : "constructor",
@@ -266,7 +266,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
266266
"return" : ["JsVar","A typed array"],
267267
"return_object" : "ArrayBufferView"
268268
}
269-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
269+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
270270
271271
Clamped arrays clamp their values to the allowed range, rather than 'wrapping'. e.g. after `a[0]=12345;`, `a[0]==255`.
272272
*/
@@ -283,7 +283,7 @@ Clamped arrays clamp their values to the allowed range, rather than 'wrapping'.
283283
"return" : ["JsVar","A typed array"],
284284
"return_object" : "ArrayBufferView"
285285
}
286-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
286+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
287287
*/
288288
/*JSON{
289289
"type" : "constructor",
@@ -298,7 +298,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
298298
"return" : ["JsVar","A typed array"],
299299
"return_object" : "ArrayBufferView"
300300
}
301-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
301+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
302302
*/
303303
/*JSON{
304304
"type" : "constructor",
@@ -313,7 +313,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
313313
"return" : ["JsVar","A typed array"],
314314
"return_object" : "ArrayBufferView"
315315
}
316-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
316+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
317317
*/
318318
/*JSON{
319319
"type" : "constructor",
@@ -328,7 +328,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
328328
"return" : ["JsVar","A typed array"],
329329
"return_object" : "ArrayBufferView"
330330
}
331-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
331+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
332332
*/
333333
/*JSON{
334334
"type" : "constructor",
@@ -344,7 +344,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
344344
"return" : ["JsVar","A typed array"],
345345
"return_object" : "ArrayBufferView"
346346
}
347-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
347+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
348348
*/
349349
/*JSON{
350350
"type" : "constructor",
@@ -359,7 +359,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
359359
"return" : ["JsVar","A typed array"],
360360
"return_object" : "ArrayBufferView"
361361
}
362-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
362+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
363363
*/
364364
/*JSON{
365365
"type" : "constructor",
@@ -374,7 +374,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
374374
"return" : ["JsVar","A typed array"],
375375
"return_object" : "ArrayBufferView"
376376
}
377-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
377+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
378378
*/
379379
/*JSON{
380380
"type" : "constructor",
@@ -389,7 +389,7 @@ Create a typed array based on the given input. Either an existing Array Buffer,
389389
"return" : ["JsVar","A typed array"],
390390
"return_object" : "ArrayBufferView"
391391
}
392-
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an ArrayBuffer view (eg. Uint8Array rather than ArrayBuffer) is given, it will be completely copied rather than referenced.
392+
Create a typed array based on the given input. Either an existing Array Buffer, an Integer as a Length, or a simple array. If an `ArrayBufferView` (eg. `Uint8Array` rather than `ArrayBuffer`) is given, it will be completely copied rather than referenced.
393393
*/
394394

395395
JsVar *jswrap_typedarray_constructor(JsVarDataArrayBufferViewType type, JsVar *arr, JsVarInt byteOffset, JsVarInt length) {
@@ -462,7 +462,7 @@ The buffer this view references
462462
"generate_full" : "(JsVarInt)(parent->varData.arraybuffer.length * JSV_ARRAYBUFFER_GET_SIZE(parent->varData.arraybuffer.type))",
463463
"return" : ["int","The Length"]
464464
}
465-
The length, in bytes, of the view
465+
The length, in bytes, of the `ArrayBufferView`
466466
*/
467467
/*JSON{
468468
"type" : "property",
@@ -471,7 +471,7 @@ The length, in bytes, of the view
471471
"generate_full" : "parent->varData.arraybuffer.byteOffset",
472472
"return" : ["int","The byte Offset"]
473473
}
474-
The offset, in bytes, to the first byte of the view within the ArrayBuffer
474+
The offset, in bytes, to the first byte of the view within the backing `ArrayBuffer`
475475
*/
476476

477477
/*JSON{
@@ -529,7 +529,7 @@ void jswrap_arraybufferview_set(JsVar *parent, JsVar *arr, int offset) {
529529
}
530530
Return an array which is made from the following: ```A.map(function) = [function(A[0]), function(A[1]), ...]```
531531
532-
**Note:** This returns an ArrayBuffer of the same type it was called on. To get an Array, use `Array.prototype.map`
532+
**Note:** This returns an `ArrayBuffer` of the same type it was called on. To get an `Array`, use `Array.map`, eg. `[].map.call(myArray, x=>x+1)`
533533
*/
534534
JsVar *jswrap_arraybufferview_map(JsVar *parent, JsVar *funcVar, JsVar *thisVar) {
535535
if (!jsvIsArrayBuffer(parent)) {
@@ -598,7 +598,7 @@ JsVar *jswrap_arraybufferview_map(JsVar *parent, JsVar *funcVar, JsVar *thisVar)
598598
],
599599
"return" : ["JsVar","the index of the value in the array, or -1"]
600600
}
601-
Return the index of the value in the array, or -1
601+
Return the index of the value in the array, or `-1`
602602
*/
603603
/*JSON{
604604
"type" : "method",
@@ -717,7 +717,7 @@ Return the array element's index where `function` returns `true`, or `-1` if it
717717
"return" : ["JsVar","This array"],
718718
"return_object" : "ArrayBufferView"
719719
}
720-
Reverse the contents of this arraybuffer in-place
720+
Reverse the contents of this `ArrayBufferView` in-place
721721
*/
722722
/*JSON{
723723
"type" : "method",
@@ -734,5 +734,5 @@ Reverse the contents of this arraybuffer in-place
734734
}
735735
Return a copy of a portion of this array (in a new array).
736736
737-
**Note:** This currently returns a normal Array, not an ArrayBuffer
737+
**Note:** This currently returns a normal `Array`, not an `ArrayBuffer`
738738
*/

0 commit comments

Comments
 (0)