ReadonlyUint8Array

A read-only variant of Uint8Array.

This type prevents modifications to the array by omitting mutable methods such as copyWithin, fill, reverse, set, and sort, while still allowing indexed access to elements.

Example

const bytes: ReadonlyUint8Array = new Uint8Array([1, 2, 3]);
console.log(bytes[0]); // 1
bytes[0] = 42; // Type error: Cannot assign to '0' because it is a read-only property.

Extends

Indexable

[n: number]: number

Properties

PropertyModifierTypeDescriptionInherited from
[toStringTag]readonly"Uint8Array"-Omit.[toStringTag]
bufferreadonlyArrayBufferLikeThe ArrayBuffer instance referenced by the array.Omit.buffer
byteLengthreadonlynumberThe length in bytes of the array.Omit.byteLength
byteOffsetreadonlynumberThe offset in bytes of the array.Omit.byteOffset
BYTES_PER_ELEMENTreadonlynumberThe size in bytes of each element in the array.Omit.BYTES_PER_ELEMENT
lengthreadonlynumberThe length of the array.Omit.length

Methods

[iterator]()

iterator: ArrayIterator<number>;

Returns

ArrayIterator<number>

Inherited from

Omit.[iterator]

entries()

entries(): ArrayIterator<[number, number]>;

Returns an array of key, value pairs for every entry in the array

Returns

ArrayIterator<[number, number]>

Inherited from

Omit.entries

every()

every(predicate, thisArg?): boolean;

Determines whether all the members of an array satisfy the specified test.

Parameters

ParameterTypeDescription
predicate(value, index, array) => unknownA function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
thisArg?anyAn object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

Returns

boolean

Inherited from

Omit.every

filter()

filter(predicate, thisArg?): Uint8Array<ArrayBuffer>;

Returns the elements of an array that meet the condition specified in a callback function.

Parameters

ParameterTypeDescription
predicate(value, index, array) => anyA function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
thisArg?anyAn object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

Returns

Uint8Array<ArrayBuffer>

Inherited from

Omit.filter

find()

find(predicate, thisArg?): undefined | number;

Returns the value of the first element in the array where predicate is true, and undefined otherwise.

Parameters

ParameterTypeDescription
predicate(value, index, obj) => booleanfind calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.
thisArg?anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

Returns

undefined | number

Inherited from

Omit.find

findIndex()

findIndex(predicate, thisArg?): number;

Returns the index of the first element in the array where predicate is true, and -1 otherwise.

Parameters

ParameterTypeDescription
predicate(value, index, obj) => booleanfind calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.
thisArg?anyIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

Returns

number

Inherited from

Omit.findIndex

forEach()

forEach(callbackfn, thisArg?): void;

Performs the specified action for each element in an array.

Parameters

ParameterTypeDescription
callbackfn(value, index, array) => voidA function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
thisArg?anyAn object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

Returns

void

Inherited from

Omit.forEach

includes()

includes(searchElement, fromIndex?): boolean;

Determines whether an array includes a certain element, returning true or false as appropriate.

Parameters

ParameterTypeDescription
searchElementnumberThe element to search for.
fromIndex?numberThe position in this array at which to begin searching for searchElement.

Returns

boolean

Inherited from

Omit.includes

indexOf()

indexOf(searchElement, fromIndex?): number;

Returns the index of the first occurrence of a value in an array.

Parameters

ParameterTypeDescription
searchElementnumberThe value to locate in the array.
fromIndex?numberThe array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

Returns

number

Inherited from

Omit.indexOf

join()

join(separator?): string;

Adds all the elements of an array separated by the specified separator string.

Parameters

ParameterTypeDescription
separator?stringA string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.

Returns

string

Inherited from

Omit.join

keys()

keys(): ArrayIterator<number>;

Returns an list of keys in the array

Returns

ArrayIterator<number>

Inherited from

Omit.keys

lastIndexOf()

lastIndexOf(searchElement, fromIndex?): number;

Returns the index of the last occurrence of a value in an array.

Parameters

ParameterTypeDescription
searchElementnumberThe value to locate in the array.
fromIndex?numberThe array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

Returns

number

Inherited from

Omit.lastIndexOf

map()

map(callbackfn, thisArg?): Uint8Array<ArrayBuffer>;

Calls a defined callback function on each element of an array, and returns an array that contains the results.

Parameters

ParameterTypeDescription
callbackfn(value, index, array) => numberA function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
thisArg?anyAn object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

Returns

Uint8Array<ArrayBuffer>

Inherited from

Omit.map

reduce()

Call Signature

reduce(callbackfn): number;

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Parameters
ParameterTypeDescription
callbackfn(previousValue, currentValue, currentIndex, array) => numberA function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
Returns

number

Inherited from
Omit.reduce

Call Signature

reduce(callbackfn, initialValue): number;
Parameters
ParameterType
callbackfn(previousValue, currentValue, currentIndex, array) => number
initialValuenumber
Returns

number

Inherited from
Omit.reduce

Call Signature

reduce<U>(callbackfn, initialValue): U;

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Type Parameters
Type Parameter
U
Parameters
ParameterTypeDescription
callbackfn(previousValue, currentValue, currentIndex, array) => UA function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
initialValueUIf initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
Returns

U

Inherited from
Omit.reduce

reduceRight()

Call Signature

reduceRight(callbackfn): number;

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Parameters
ParameterTypeDescription
callbackfn(previousValue, currentValue, currentIndex, array) => numberA function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
Returns

number

Inherited from
Omit.reduceRight

Call Signature

reduceRight(callbackfn, initialValue): number;
Parameters
ParameterType
callbackfn(previousValue, currentValue, currentIndex, array) => number
initialValuenumber
Returns

number

Inherited from
Omit.reduceRight

Call Signature

reduceRight<U>(callbackfn, initialValue): U;

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Type Parameters
Type Parameter
U
Parameters
ParameterTypeDescription
callbackfn(previousValue, currentValue, currentIndex, array) => UA function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
initialValueUIf initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
Returns

U

Inherited from
Omit.reduceRight

slice()

slice(start?, end?): Uint8Array<ArrayBuffer>;

Returns a section of an array.

Parameters

ParameterTypeDescription
start?numberThe beginning of the specified portion of the array.
end?numberThe end of the specified portion of the array. This is exclusive of the element at the index 'end'.

Returns

Uint8Array<ArrayBuffer>

Inherited from

Omit.slice

some()

some(predicate, thisArg?): boolean;

Determines whether the specified callback function returns true for any element of an array.

Parameters

ParameterTypeDescription
predicate(value, index, array) => unknownA function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array.
thisArg?anyAn object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

Returns

boolean

Inherited from

Omit.some

subarray()

subarray(begin?, end?): Uint8Array<ArrayBufferLike>;

Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive.

Parameters

ParameterTypeDescription
begin?numberThe index of the beginning of the array.
end?numberThe index of the end of the array.

Returns

Uint8Array<ArrayBufferLike>

Inherited from

Omit.subarray

toLocaleString()

Call Signature

toLocaleString(): string;

Converts a number to a string by using the current locale.

Returns

string

Inherited from
Omit.toLocaleString

Call Signature

toLocaleString(locales, options?): string;
Parameters
ParameterType
localesstring | string[]
options?NumberFormatOptions
Returns

string

Inherited from
Omit.toLocaleString

toString()

toString(): string;

Returns a string representation of an array.

Returns

string

Inherited from

Omit.toString

valueOf()

valueOf(): this;

Returns the primitive value of the specified object.

Returns

this

Inherited from

Omit.valueOf

values()

values(): ArrayIterator<number>;

Returns an list of values in the array

Returns

ArrayIterator<number>

Inherited from

Omit.values