@@ -66,8 +66,8 @@ differently based on what arguments are provided:
66
66
memory.
67
67
* Passing a string, array, or ` Buffer ` as the first argument copies the
68
68
passed object's data into the ` Buffer ` .
69
- * Passing an [ ` ArrayBuffer ` ] returns a ` Buffer ` that shares allocated memory with
70
- the given [ ` ArrayBuffer ` ] .
69
+ * Passing an [ ` ArrayBuffer ` ] or a [ ` SharedArrayBuffer ` ] returns a ` Buffer ` that
70
+ shares allocated memory with the given array buffer .
71
71
72
72
Because the behavior of ` new Buffer() ` changes significantly based on the type
73
73
of value passed as the first argument, applications that do not properly
@@ -361,16 +361,16 @@ changes:
361
361
> [ ` Buffer.from(arrayBuffer[, byteOffset [, length]]) ` ] [ `Buffer.from(arrayBuffer)` ]
362
362
> instead.
363
363
364
- * ` arrayBuffer ` {ArrayBuffer} An [ ` ArrayBuffer ` ] or the ` .buffer ` property of a
365
- [ ` TypedArray ` ] .
364
+ * ` arrayBuffer ` {ArrayBuffer|SharedArrayBuffer } An [ ` ArrayBuffer ` ] ,
365
+ [ ` SharedArrayBuffer ` ] or the ` .buffer ` property of a [ ` TypedArray ` ] .
366
366
* ` byteOffset ` {integer} Index of first byte to expose. ** Default:** ` 0 `
367
367
* ` length ` {integer} Number of bytes to expose.
368
368
** Default:** ` arrayBuffer.length - byteOffset `
369
369
370
- This creates a view of the [ ` ArrayBuffer ` ] without copying the underlying
371
- memory. For example, when passed a reference to the ` .buffer ` property of a
372
- [ ` TypedArray ` ] instance, the newly created ` Buffer ` will share the same
373
- allocated memory as the [ ` TypedArray ` ] .
370
+ This creates a view of the [ ` ArrayBuffer ` ] or [ ` SharedArrayBuffer ` ] without
371
+ copying the underlying memory. For example, when passed a reference to the
372
+ ` .buffer ` property of a [ ` TypedArray ` ] instance, the newly created ` Buffer ` will
373
+ share the same allocated memory as the [ ` TypedArray ` ] .
374
374
375
375
The optional ` byteOffset ` and ` length ` arguments specify a memory range within
376
376
the ` arrayBuffer ` that will be shared by the ` Buffer ` .
@@ -679,8 +679,8 @@ changes:
679
679
or `ArrayBuffer`.
680
680
-->
681
681
682
- * ` string ` {string|Buffer|TypedArray|DataView|ArrayBuffer} A value to
683
- calculate the length of.
682
+ * ` string ` {string|Buffer|TypedArray|DataView|ArrayBuffer|SharedArrayBuffer } A
683
+ value to calculate the length of.
684
684
* ` encoding ` {string} If ` string ` is a string, this is its encoding.
685
685
** Default:** ` 'utf8' `
686
686
* Returns: {integer} The number of bytes contained within ` string ` .
@@ -703,8 +703,8 @@ console.log(`${str}: ${str.length} characters, ` +
703
703
` ${ Buffer .byteLength (str, ' utf8' )} bytes` );
704
704
```
705
705
706
- When ` string ` is a ` Buffer ` /[ ` DataView ` ] /[ ` TypedArray ` ] /[ ` ArrayBuffer ` ] , the
707
- actual byte length is returned.
706
+ When ` string ` is a ` Buffer ` /[ ` DataView ` ] /[ ` TypedArray ` ] /[ ` ArrayBuffer ` ] /
707
+ [ ` SharedArrayBuffer ` ] , the actual byte length is returned.
708
708
709
709
### Class Method: Buffer.compare(buf1, buf2)
710
710
<!-- YAML
@@ -807,8 +807,8 @@ A `TypeError` will be thrown if `array` is not an `Array`.
807
807
added: v5.10.0
808
808
-->
809
809
810
- * ` arrayBuffer ` {ArrayBuffer} An [ ` ArrayBuffer ` ] or the ` .buffer ` property of a
811
- [ ` TypedArray ` ] .
810
+ * ` arrayBuffer ` {ArrayBuffer|SharedArrayBuffer } An [ ` ArrayBuffer ` ] ,
811
+ [ ` SharedArrayBuffer ` ] , or the ` .buffer ` property of a [ ` TypedArray ` ] .
812
812
* ` byteOffset ` {integer} Index of first byte to expose. ** Default:** ` 0 `
813
813
* ` length ` {integer} Number of bytes to expose.
814
814
** Default:** ` arrayBuffer.length - byteOffset `
@@ -852,7 +852,8 @@ const buf = Buffer.from(ab, 0, 2);
852
852
console .log (buf .length );
853
853
```
854
854
855
- A ` TypeError ` will be thrown if ` arrayBuffer ` is not an [ ` ArrayBuffer ` ] .
855
+ A ` TypeError ` will be thrown if ` arrayBuffer ` is not an [ ` ArrayBuffer ` ] or a
856
+ [ ` SharedArrayBuffer ` ] .
856
857
857
858
### Class Method: Buffer.from(buffer)
858
859
<!-- YAML
@@ -2712,6 +2713,7 @@ This value may depend on the JS engine that is being used.
2712
2713
[ `DataView` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
2713
2714
[ `JSON.stringify()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
2714
2715
[ `RangeError` ] : errors.html#errors_class_rangeerror
2716
+ [ `SharedArrayBuffer` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
2715
2717
[ `String#indexOf()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
2716
2718
[ `String#lastIndexOf()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf
2717
2719
[ `String.prototype.length` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
0 commit comments