@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
Builder
<readonlyMaybe
<T
>[]>
Type parameters
Type parameter | Value |
---|---|
T | unknown |
Constructors
new ListBuilder()
new ListBuilder<
T
>(data
,options
):ListBuilder
<T
>
Parameters
Parameter | Type |
---|---|
data | WritableData <readonly Maybe <T >[]> |
options | BuilderOptions |
Returns
ListBuilder
<T
>
Overrides
Source
data-mate/src/builder/ListBuilder.ts:10
Properties
_valueFrom
_valueFrom:
CoerceFN
<readonlyMaybe
<T
>[]>
Overrides
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
Source
data-mate/src/builder/Builder.ts:59
config
readonly
config:Readonly
<DataTypeFieldConfig
>
The field type configuration
Inherited from
Source
data-mate/src/builder/Builder.ts:53
currentIndex
currentIndex:
number
The current insertion index (used for append)
Inherited from
Source
data-mate/src/builder/Builder.ts:74
data
Internal
readonly
data:WritableData
<readonlyMaybe
<T
>[]>
Inherited from
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
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
Source
data-mate/src/builder/Builder.ts:48
Methods
append()
append(
value
):this
Append a value to the end
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
this
Inherited from
Source
data-mate/src/builder/Builder.ts:157
mset()
mset(
value
,indices
):this
Set a single unique value on multiple indices
Parameters
Parameter | Type |
---|---|
value | unknown |
indices | Iterable <number > |
Returns
this
Inherited from
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
Parameter | Type |
---|---|
size | number |
Returns
this
Inherited from
Source
data-mate/src/builder/Builder.ts:165
set()
set(
index
,value
):this
Set value by index
Parameters
Parameter | Type |
---|---|
index | number |
value | unknown |
Returns
this
Inherited from
Source
data-mate/src/builder/Builder.ts:138
toVector()
toVector():
Vector
<readonlyMaybe
<T
>[]>
Flush and convert the result to a Vector
Returns
Vector
<readonly Maybe
<T
>[]>
Inherited from
Source
data-mate/src/builder/Builder.ts:175
valueFrom()
valueFrom(
value
,indices
?): readonlyMaybe
<T
>[]
Convert a value to the internal in-memory storage format for the Vector
Parameters
Parameter | Type |
---|---|
value | unknown |
indices ? | number | Iterable <number > |
Returns
readonly Maybe
<T
>[]
Inherited from
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 parameter | Value |
---|---|
R | unknown |
Parameters
Parameter | Type |
---|---|
data | WritableData <R > |
options | BuilderOptions |
Returns
Builder
<R
>
Inherited from
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
Parameter | Type |
---|---|
vector | Vector <R > |
size | number |
Returns
Builder
<R
>