Skip to content

Commit

Permalink
Deduplicate TypedArray ctor param description, add exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Aug 27, 2022
1 parent d44cca0 commit a971012
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,7 @@ new BigInt64Array(buffer, byteOffset, length)

> **Note:** `BigInt64Array()` can only be constructed with [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to call it without `new` throws a {{jsxref("TypeError")}}.
### Parameters

- `length`
- : When called with a `length` argument, an internal array buffer
is created in memory, of size `length` _multiplied by
`BYTES_PER_ELEMENT`_ bytes, containing zeros.
- `typedArray`
- : When called with a `typedArray` argument, which can be an
object of either of the {{glossary("bigint")}} typed-array types (such as {{JSxRef("BigUInt64Array")}}), the
`typedArray` gets copied into a new typed array. Each value in
`typedArray` is converted to the corresponding type of the
constructor before being copied into the new array. The length of the new typed array
will be same as the length of the `typedArray` argument.
- `object`
- : When called with an `object` argument, a new typed array is
created as if by the `TypedArray.from()` method.
- `buffer`, `byteOffset`,
`length`
- : When called with a `buffer`, and optionally a
`byteOffset` and a `length` argument, a
new typed array view is created that views the specified {{jsxref("ArrayBuffer")}}.
The `byteOffset` and `length` parameters
specify the memory range that will be exposed by the typed array view. If both are
omitted, all of `buffer` is viewed; if only
`length` is omitted, the remainder of
`buffer` is viewed.
For a detailed explanation of each constructor parameter, see the [`TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#constructor) page.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,7 @@ new BigUint64Array(buffer, byteOffset, length)

> **Note:** `BigUint64Array()` can only be constructed with [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to call it without `new` throws a {{jsxref("TypeError")}}.
### Parameters

- `length`
- : When called with a `length` argument, an internal array buffer
is created in memory, of size `length` _multiplied by
`BYTES_PER_ELEMENT`_ bytes, containing zeros.
- `typedArray`
- : When called with a `typedArray` argument, which can be an
object of either of the {{glossary("bigint")}} typed-array types (such as {{JSxRef("BigInt64Array")}}), the
`typedArray` gets copied into a new typed array. Each value in
`typedArray` is converted to the corresponding type of the
constructor before being copied into the new array. The length of the new typed array
will be same as the length of the `typedArray` argument.
- `object`
- : When called with an `object` argument, a new typed array is
created as if by the `TypedArray.from()` method.
- `buffer`, `byteOffset`,
`length`
- : When called with a `buffer`, and optionally a
`byteOffset` and a `length` argument, a
new typed array view is created that views the specified {{jsxref("ArrayBuffer")}}.
The `byteOffset` and `length` parameters
specify the memory range that will be exposed by the typed array view. If both are
omitted, all of `buffer` is viewed; if only
`length` is omitted, the remainder of
`buffer` is viewed.
For a detailed explanation of each constructor parameter, see the [`TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#constructor) page.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,7 @@ new Float32Array(buffer, byteOffset, length)

> **Note:** `Float32Array()` can only be constructed with [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to call it without `new` throws a {{jsxref("TypeError")}}.
### Parameters

- `length`
- : When called with a `length` argument, an internal array buffer
is created in memory, of size `length` _multiplied by
`BYTES_PER_ELEMENT`_ bytes, containing zeros.
- `typedArray`
- : When called with a `typedArray` argument, which can be an
object of any of the **non**-{{glossary("bigint")}} typed-array types (such as `Int32Array`), the
`typedArray` gets copied into a new typed array. Each value in
`typedArray` is converted to the corresponding type of the
constructor before being copied into the new array. The length of the new typed array
will be same as the length of the `typedArray` argument.
- `object`
- : When called with an `object` argument, a new typed array is
created as if by the `TypedArray.from()` method.
- `buffer`, `byteOffset`,
`length`
- : When called with a `buffer`, and optionally a
`byteOffset` and a `length` argument, a
new typed array view is created that views the specified {{jsxref("ArrayBuffer")}}.
The `byteOffset` and `length` parameters
specify the memory range that will be exposed by the typed array view. If both are
omitted, all of `buffer` is viewed; if only
`length` is omitted, the remainder of
`buffer` is viewed.
For a detailed explanation of each constructor parameter, see the [`TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#constructor) page.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,7 @@ new Float64Array(buffer, byteOffset, length)

> **Note:** `Float64Array()` can only be constructed with [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to call it without `new` throws a {{jsxref("TypeError")}}.
### Parameters

- `length`
- : When called with a `length` argument, an internal array buffer
is created in memory, of size `length` _multiplied by
`BYTES_PER_ELEMENT`_ bytes, containing zeros.
- `typedArray`
- : When called with a `typedArray` argument, which can be an
object of any of the **non**-{{glossary("bigint")}} typed-array types (such as `Int32Array`), the
`typedArray` gets copied into a new typed array. Each value in
`typedArray` is converted to the corresponding type of the
constructor before being copied into the new array. The length of the new typed array
will be same as the length of the `typedArray` argument.
- `object`
- : When called with an `object` argument, a new typed array is
created as if by the `TypedArray.from()` method.
- `buffer`, `byteOffset`,
`length`
- : When called with a `buffer`, and optionally a
`byteOffset` and a `length` argument, a
new typed array view is created that views the specified {{jsxref("ArrayBuffer")}}.
The `byteOffset` and `length` parameters
specify the memory range that will be exposed by the typed array view. If both are
omitted, all of `buffer` is viewed; if only
`length` is omitted, the remainder of
`buffer` is viewed.
For a detailed explanation of each constructor parameter, see the [`TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#constructor) page.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,7 @@ new Int16Array(buffer, byteOffset, length)

> **Note:** `Int16Array()` can only be constructed with [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to call it without `new` throws a {{jsxref("TypeError")}}.
### Parameters

- `length`
- : When called with a `length` argument, an internal array buffer
is created in memory, of size `length` _multiplied by
`BYTES_PER_ELEMENT`_ bytes, containing zeros.
- `typedArray`
- : When called with a `typedArray` argument, which can be an object of any
of the **non**-{{glossary("bigint")}} typed-array types (such as `Int32Array`), the
`typedArray` gets copied into a new typed array. Each value in
`typedArray` is converted to the corresponding type of the
constructor before being copied into the new array. The length of the new typed array
will be same as the length of the `typedArray` argument.
- `object`
- : When called with an `object` argument, a new typed array is
created as if by the `TypedArray.from()` method.
- `buffer`, `byteOffset`,
`length`
- : When called with a `buffer`, and optionally a
`byteOffset` and a `length` argument, a
new typed array view is created that views the specified {{jsxref("ArrayBuffer")}}.
The `byteOffset` and `length` parameters
specify the memory range that will be exposed by the typed array view. If both are
omitted, all of `buffer` is viewed; if only
`length` is omitted, the remainder of
`buffer` is viewed.
For a detailed explanation of each constructor parameter, see the [`TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#constructor) page.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,7 @@ new Int32Array(buffer, byteOffset, length)

> **Note:** `Int32Array()` can only be constructed with [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to call it without `new` throws a {{jsxref("TypeError")}}.
### Parameters

- `length`
- : When called with a `length` argument, an internal array buffer
is created in memory, of size `length` _multiplied by
`BYTES_PER_ELEMENT`_ bytes, containing zeros.
- `typedArray`
- : When called with a `typedArray` argument, which can be an object of any
of the **non**-{{glossary("bigint")}} typed-array types (such as `Int32Array`), the
`typedArray` gets copied into a new typed array. Each value in
`typedArray` is converted to the corresponding type of the
constructor before being copied into the new array. The length of the new typed array
will be same as the length of the `typedArray` argument.
- `object`
- : When called with an `object` argument, a new typed array is
created as if by the `TypedArray.from()` method.
- `buffer`, `byteOffset`,
`length`
- : When called with a `buffer`, and optionally a
`byteOffset` and a `length` argument, a
new typed array view is created that views the specified {{jsxref("ArrayBuffer")}}.
The `byteOffset` and `length` parameters
specify the memory range that will be exposed by the typed array view. If both are
omitted, all of `buffer` is viewed; if only
`length` is omitted, the remainder of
`buffer` is viewed.
For a detailed explanation of each constructor parameter, see the [`TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#constructor) page.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,7 @@ new Int8Array(buffer, byteOffset, length)

> **Note:** `Int8Array()` can only be constructed with [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new). Attempting to call it without `new` throws a {{jsxref("TypeError")}}.
### Parameters

- `length`
- : When called with a `length` argument, an internal array buffer
is created in memory, of size `length` _multiplied by
`BYTES_PER_ELEMENT`_ bytes, containing zeros.
- `typedArray`
- : When called with a `typedArray` argument, which can be an object of any
of the **non**-{{glossary("bigint")}} typed-array types (such as `Int32Array`), the
`typedArray` gets copied into a new typed array. Each value in
`typedArray` is converted to the corresponding type of the
constructor before being copied into the new array. The length of the new typed array
will be same as the length of the `typedArray` argument.
- `object`
- : When called with an `object` argument, a new typed array is
created as if by the `TypedArray.from()` method.
- `buffer`, `byteOffset`,
`length`
- : When called with a `buffer`, and optionally a
`byteOffset` and a `length` argument, a
new typed array view is created that views the specified {{jsxref("ArrayBuffer")}}.
The `byteOffset` and `length` parameters
specify the memory range that will be exposed by the typed array view. If both are
omitted, all of `buffer` is viewed; if only
`length` is omitted, the remainder of
`buffer` is viewed.
For a detailed explanation of each constructor parameter, see the [`TypedArray`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#constructor) page.

## Examples

Expand Down
Loading

0 comments on commit a971012

Please sign in to comment.