@@ -63,8 +63,8 @@ differently based on what arguments are provided:
6363 a fast-but-uninitialized ` Buffer ` versus creating a slower-but-safer ` Buffer ` .
6464* Passing a string, array, or ` Buffer ` as the first argument copies the
6565 passed object's data into the ` Buffer ` .
66- * Passing an [ ` ArrayBuffer ` ] returns a ` Buffer ` that shares allocated memory with
67- the given [ ` ArrayBuffer ` ] .
66+ * Passing an [ ` ArrayBuffer ` ] or a [ ` SharedArrayBuffer ` ] returns a ` Buffer ` that
67+ shares allocated memory with the given array buffer .
6868
6969Because the behavior of ` new Buffer() ` changes significantly based on the type
7070of value passed as the first argument, applications that do not properly
@@ -350,16 +350,16 @@ deprecated: v6.0.0
350350> [ ` Buffer.from(arrayBuffer[, byteOffset [, length]]) ` ] [ `Buffer.from(arrayBuffer)` ]
351351> instead.
352352
353- * ` arrayBuffer ` {ArrayBuffer} An [ ` ArrayBuffer ` ] or the ` .buffer ` property of a
354- [ ` TypedArray ` ] .
353+ * ` arrayBuffer ` {ArrayBuffer|SharedArrayBuffer } An [ ` ArrayBuffer ` ] ,
354+ [ ` SharedArrayBuffer ` ] or the ` .buffer ` property of a [ ` TypedArray ` ] .
355355* ` byteOffset ` {integer} Index of first byte to expose. ** Default:** ` 0 `
356356* ` length ` {integer} Number of bytes to expose.
357357 ** Default:** ` arrayBuffer.length - byteOffset `
358358
359- This creates a view of the [ ` ArrayBuffer ` ] without copying the underlying
360- memory. For example, when passed a reference to the ` .buffer ` property of a
361- [ ` TypedArray ` ] instance, the newly created ` Buffer ` will share the same
362- allocated memory as the [ ` TypedArray ` ] .
359+ This creates a view of the [ ` ArrayBuffer ` ] or [ ` SharedArrayBuffer ` ] without
360+ copying the underlying memory. For example, when passed a reference to the
361+ ` .buffer ` property of a [ ` TypedArray ` ] instance, the newly created ` Buffer ` will
362+ share the same allocated memory as the [ ` TypedArray ` ] .
363363
364364The optional ` byteOffset ` and ` length ` arguments specify a memory range within
365365the ` arrayBuffer ` that will be shared by the ` Buffer ` .
@@ -611,8 +611,8 @@ A `TypeError` will be thrown if `size` is not a number.
611611added: v0.1.90
612612-->
613613
614- * ` string ` {string|Buffer|TypedArray|DataView|ArrayBuffer} A value to
615- calculate the length of.
614+ * ` string ` {string|Buffer|TypedArray|DataView|ArrayBuffer|SharedArrayBuffer } A
615+ value to calculate the length of.
616616* ` encoding ` {string} If ` string ` is a string, this is its encoding.
617617 ** Default:** ` 'utf8' `
618618* Returns: {integer} The number of bytes contained within ` string ` .
@@ -635,8 +635,8 @@ console.log(`${str}: ${str.length} characters, ` +
635635 ` ${ Buffer .byteLength (str, ' utf8' )} bytes` );
636636```
637637
638- When ` string ` is a ` Buffer ` /[ ` DataView ` ] /[ ` TypedArray ` ] /[ ` ArrayBuffer ` ] , the
639- actual byte length is returned.
638+ When ` string ` is a ` Buffer ` /[ ` DataView ` ] /[ ` TypedArray ` ] /[ ` ArrayBuffer ` ] /
639+ [ ` SharedArrayBuffer ` ] , the actual byte length is returned.
640640
641641Otherwise, converts to ` String ` and returns the byte length of string.
642642
@@ -733,8 +733,8 @@ A `TypeError` will be thrown if `array` is not an `Array`.
733733added: v5.10.0
734734-->
735735
736- * ` arrayBuffer ` {ArrayBuffer} An [ ` ArrayBuffer ` ] or the ` .buffer ` property of a
737- [ ` TypedArray ` ] .
736+ * ` arrayBuffer ` {ArrayBuffer|SharedArrayBuffer } An [ ` ArrayBuffer ` ] ,
737+ [ ` SharedArrayBuffer ` ] , or the ` .buffer ` property of a [ ` TypedArray ` ] .
738738* ` byteOffset ` {integer} Index of first byte to expose. ** Default:** ` 0 `
739739* ` length ` {integer} Number of bytes to expose.
740740 ** Default:** ` arrayBuffer.length - byteOffset `
@@ -778,7 +778,8 @@ const buf = Buffer.from(ab, 0, 2);
778778console .log (buf .length );
779779```
780780
781- A ` TypeError ` will be thrown if ` arrayBuffer ` is not an [ ` ArrayBuffer ` ] .
781+ A ` TypeError ` will be thrown if ` arrayBuffer ` is not an [ ` ArrayBuffer ` ] or a
782+ [ ` SharedArrayBuffer ` ] .
782783
783784### Class Method: Buffer.from(buffer)
784785<!-- YAML
@@ -2544,6 +2545,7 @@ console.log(buf);
25442545[ RFC1345 ] : https://tools.ietf.org/html/rfc1345
25452546[ RFC4648, Section 5 ] : https://tools.ietf.org/html/rfc4648#section-5
25462547[ `String.prototype.length` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
2548+ [ `SharedArrayBuffer` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
25472549[ `String#indexOf()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
25482550[ `String#lastIndexOf()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf
25492551[ `TypedArray` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
0 commit comments