Skip to main content

@terascope/data-mate / builder/ListBuilder / ListBuilder

Class: ListBuilder<T>

Since Vectors are immutable, a Builder can be used to construct a Vector. When values are inserted they are coerced and validated.

Extends

Type parameters

Type parameterValue
Tunknown

Constructors

new ListBuilder()

new ListBuilder<T>(data, options): ListBuilder<T>

Parameters

ParameterType
dataWritableData<readonly Maybe<T>[]>
optionsBuilderOptions

Returns

ListBuilder<T>

Overrides

Builder.constructor

Source

data-mate/src/builder/ListBuilder.ts:10

Properties

_valueFrom

_valueFrom: CoerceFN<readonly Maybe<T>[]>

Overrides

Builder._valueFrom

Source

data-mate/src/builder/ListBuilder.ts:8


childConfig?

optional readonly childConfig: DataTypeFields

When Vector is an object type, this will be the data type fields for the object

Inherited from

Builder.childConfig

Source

data-mate/src/builder/Builder.ts:59


config

readonly config: Readonly<DataTypeFieldConfig>

The field type configuration

Inherited from

Builder.config

Source

data-mate/src/builder/Builder.ts:53


currentIndex

currentIndex: number

The current insertion index (used for append)

Inherited from

Builder.currentIndex

Source

data-mate/src/builder/Builder.ts:74


data

Internal

readonly data: WritableData<readonly Maybe<T>[]>

Inherited from

Builder.data

Source

data-mate/src/builder/Builder.ts:64


name?

optional readonly name: string

The name of field, if specified this will just be used for metadata

Inherited from

Builder.name

Source

data-mate/src/builder/Builder.ts:69


type

readonly type: VectorType

The type of Vector, this should only be set with the specific Vector type classes.

Inherited from

Builder.type

Source

data-mate/src/builder/Builder.ts:48

Methods

append()

append(value): this

Append a value to the end

Parameters

ParameterType
valueunknown

Returns

this

Inherited from

Builder.append

Source

data-mate/src/builder/Builder.ts:157


mset()

mset(value, indices): this

Set a single unique value on multiple indices

Parameters

ParameterType
valueunknown
indicesIterable<number>

Returns

this

Inherited from

Builder.mset

Source

data-mate/src/builder/Builder.ts:146


resize()

resize(size): this

Resize the amount of records stored in in the writable data structure

Parameters

ParameterType
sizenumber

Returns

this

Inherited from

Builder.resize

Source

data-mate/src/builder/Builder.ts:165


set()

set(index, value): this

Set value by index

Parameters

ParameterType
indexnumber
valueunknown

Returns

this

Inherited from

Builder.set

Source

data-mate/src/builder/Builder.ts:138


toVector()

toVector(): Vector<readonly Maybe<T>[]>

Flush and convert the result to a Vector

Returns

Vector<readonly Maybe<T>[]>

Inherited from

Builder.toVector

Source

data-mate/src/builder/Builder.ts:175


valueFrom()

valueFrom(value, indices?): readonly Maybe<T>[]

Convert a value to the internal in-memory storage format for the Vector

Parameters

ParameterType
valueunknown
indices?number | Iterable<number>

Returns

readonly Maybe<T>[]

Inherited from

Builder.valueFrom

Source

data-mate/src/builder/Builder.ts:102


make()

static make<R>(data, options): Builder<R>

Make an instance of a Builder from a DataTypeFieldConfig

Type parameters

Type parameterValue
Runknown

Parameters

ParameterType
dataWritableData<R>
optionsBuilderOptions

Returns

Builder<R>

Inherited from

Builder.make

Source

data-mate/src/builder/Builder.ts:14


makeFromVector()

static makeFromVector<R>(vector, size): Builder<R>

Convert a Vector to a Builder with current values populated depending on the length populated

Type parameters

Type parameter
R

Parameters

ParameterType
vectorVector<R>
sizenumber

Returns

Builder<R>

Inherited from

Builder.makeFromVector

Source

data-mate/src/builder/Builder.ts:28