UnorderedSet

collections/unordered-setDocs


near-sdk-js v2.0.0 / collections/unordered-set / UnorderedSet

Class: UnorderedSet<DataType>

An unordered set that stores data in NEAR storage.

Type Parameters

DataType

Constructors

new UnorderedSet()

new UnorderedSet<DataType>(prefix): UnorderedSet<DataType>

Parameters

prefix: string

The byte prefix to use when storing elements inside this collection.

Returns

UnorderedSet<DataType>

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:35

Properties

_elements

readonly _elements: Vector<DataType>

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:30


elementIndexPrefix

readonly elementIndexPrefix: string

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:29


prefix

readonly prefix: string

The byte prefix to use when storing elements inside this collection.

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:35

Accessors

length

get length(): number

The number of elements stored in the collection.

Returns

number

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:43

Methods

[iterator]()

[iterator](): VectorIterator<DataType>

Returns

VectorIterator<DataType>

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:157


clear()

clear(options?): void

Remove all of the elements stored within the collection.

Parameters

options?: Pick<GetOptions<DataType>, "serializer">

Returns

void

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:147


contains()

contains(element, options?): boolean

Checks whether the collection contains the value.

Parameters

element: DataType

The value for which to check the presence.

options?: Pick<GetOptions<DataType>, "serializer">

Options for storing data.

Returns

boolean

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:60


elements()

elements(__namedParameters): DataType[]

Parameters

__namedParameters

__namedParameters.limit?: number

__namedParameters.options?: GetOptions<DataType>

__namedParameters.start?: number

Returns

DataType[]

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:230


extend()

extend(elements): void

Extends the current collection with the passed in array of elements.

Parameters

elements: DataType[]

The elements to extend the collection with.

Returns

void

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:196


isEmpty()

isEmpty(): boolean

Checks whether the collection is empty.

Returns

boolean

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:50


remove()

remove(element, options?): boolean

Returns true if the element was present in the set.

Parameters

element: DataType

The entry to remove.

options?: GetOptions<DataType>

Options for retrieving and storing data.

Returns

boolean

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:101


serialize()

serialize(options?): Uint8Array

Serialize the collection.

Parameters

options?: Pick<GetOptions<DataType>, "serializer">

Options for storing the data.

Returns

Uint8Array

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:207


set()

set(element, options?): boolean

If the set did not have this value present, true is returned. If the set did have this value present, false is returned.

Parameters

element: DataType

The value to store in the collection.

options?: Pick<GetOptions<DataType>, "serializer">

Options for storing the data.

Returns

boolean

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:76


toArray()

toArray(options?): DataType[]

Return a JavaScript array of the data stored within the collection.

Parameters

options?: GetOptions<DataType>

Options for retrieving and storing the data.

Returns

DataType[]

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:179


reconstruct()

static reconstruct<DataType>(data): UnorderedSet<DataType>

Converts the deserialized data from storage to a JavaScript instance of the collection.

Type Parameters

DataType

Parameters

data: UnorderedSet<DataType>

The deserialized data to create an instance from.

Returns

UnorderedSet<DataType>

Defined in

packages/near-sdk-js/src/collections/unordered-set.ts:216

Last updated