| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8fd316f commit df5436c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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`. | |
@@ -684,8 +684,8 @@ changes: | |||
| 684 | 684 | or `ArrayBuffer`. | |
| 685 | 685 | --> | |
| 686 | 686 | ||
| 687 | - * `string` {string|Buffer|TypedArray|DataView|ArrayBuffer} A value to | ||
| 688 | - calculate the length of. | ||
| 687 | + * `string` {string|Buffer|TypedArray|DataView|ArrayBuffer|SharedArrayBuffer} A | ||
| 688 | + value to calculate the length of. | ||
| 689 | 689 | * `encoding` {string} If `string` is a string, this is its encoding. | |
| 690 | 690 | **Default:** `'utf8'` | |
| 691 | 691 | * Returns: {integer} The number of bytes contained within `string`. | |
@@ -708,8 +708,8 @@ console.log(`${str}: ${str.length} characters, ` + | |||
| 708 | 708 | `${Buffer.byteLength(str, 'utf8')} bytes`); | |
| 709 | 709 | ``` | |
| 710 | 710 | ||
| 711 | - When `string` is a `Buffer`/[`DataView`]/[`TypedArray`]/[`ArrayBuffer`], the | ||
| 712 | - actual byte length is returned. | ||
| 711 | + When `string` is a `Buffer`/[`DataView`]/[`TypedArray`]/[`ArrayBuffer`]/ | ||
| 712 | + [`SharedArrayBuffer`], the actual byte length is returned. | ||
| 713 | 713 | ||
| 714 | 714 | ### Class Method: Buffer.compare(buf1, buf2) | |
| 715 | 715 | <!-- YAML | |
@@ -812,8 +812,8 @@ A `TypeError` will be thrown if `array` is not an `Array`. | |||
| 812 | 812 | added: v5.10.0 | |
| 813 | 813 | --> | |
| 814 | 814 | ||
| 815 | - * `arrayBuffer` {ArrayBuffer} An [`ArrayBuffer`] or the `.buffer` property of a | ||
| 816 | - [`TypedArray`]. | ||
| 815 | + * `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`], | ||
| 816 | + [`SharedArrayBuffer`], or the `.buffer` property of a [`TypedArray`]. | ||
| 817 | 817 | * `byteOffset` {integer} Index of first byte to expose. **Default:** `0` | |
| 818 | 818 | * `length` {integer} Number of bytes to expose. | |
| 819 | 819 | **Default:** `arrayBuffer.length - byteOffset` | |
@@ -857,7 +857,8 @@ const buf = Buffer.from(ab, 0, 2); | |||
| 857 | 857 | console.log(buf.length); | |
| 858 | 858 | ``` | |
| 859 | 859 | ||
| 860 | - A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`]. | ||
| 860 | + A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`] or a | ||
| 861 | + [`SharedArrayBuffer`]. | ||
| 861 | 862 | ||
| 862 | 863 | ### Class Method: Buffer.from(buffer) | |
| 863 | 864 | <!-- YAML | |
@@ -2730,6 +2731,7 @@ This value may depend on the JS engine that is being used. | |||
| 2730 | 2731 | [`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView | |
| 2731 | 2732 | [`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify | |
| 2732 | 2733 | [`RangeError`]: errors.html#errors_class_rangeerror | |
| 2734 | + [`SharedArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer | ||
| 2733 | 2735 | [`String#indexOf()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf | |
| 2734 | 2736 | [`String#lastIndexOf()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf | |
| 2735 | 2737 | [`String.prototype.length`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length | |
| Back | FazBrowse Home | New Git URL |
0 commit comments