@terascope/data-mate / builder/ListBuilder / ListBuilder
Class: ListBuilder<T>
Defined in: data-mate/src/builder/ListBuilder.ts:7
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 | Default type |
---|---|
T | unknown |
Constructors
new ListBuilder()
new ListBuilder<
T
>(data
,options
):ListBuilder
<T
>
Defined in: data-mate/src/builder/ListBuilder.ts:10
Parameters
Parameter | Type |
---|---|
data | WritableData <readonly Maybe <T >[]> |
options | BuilderOptions |
Returns
ListBuilder
<T
>
Overrides
Properties
Property | Modifier | Type | Description | Overrides | Inherited from | Defined in |
---|---|---|---|---|---|---|
_valueFrom | public | CoerceFN <readonly Maybe <T >[]> | Convert a value to the internal in-memory storage format for the Vector | Builder ._valueFrom | - | data-mate/src/builder/ListBuilder.ts:8 |
childConfig? | readonly | DataTypeFields | When Vector is an object type, this will be the data type fields for the object | - | Builder .childConfig | data-mate/src/builder/Builder.ts:59 |
config | readonly | Readonly <DataTypeFieldConfig > | The field type configuration | - | Builder .config | data-mate/src/builder/Builder.ts:53 |
currentIndex | public | number | The current insertion index (used for append) | - | Builder .currentIndex | data-mate/src/builder/Builder.ts:74 |
data | readonly | WritableData <readonly Maybe <T >[]> | Internal | - | Builder .data | data-mate/src/builder/Builder.ts:64 |
name? | readonly | string | The name of field, if specified this will just be used for metadata | - | Builder .name | data-mate/src/builder/Builder.ts:69 |
type | readonly | VectorType | The type of Vector, this should only be set with the specific Vector type classes. | - | Builder .type | data-mate/src/builder/Builder.ts:48 |
Methods
append()
append(
value
):this
Defined in: data-mate/src/builder/Builder.ts:157
Append a value to the end
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
this
Inherited from
mset()
mset(
value
,indices
):this
Defined in: data-mate/src/builder/Builder.ts:146
Set a single unique value on multiple indices
Parameters
Parameter | Type |
---|---|
value | unknown |
indices | Iterable <number > |
Returns
this
Inherited from
resize()
resize(
size
):this
Defined in: data-mate/src/builder/Builder.ts:165
Resize the amount of records stored in in the writable data structure
Parameters
Parameter | Type |
---|---|
size | number |
Returns
this
Inherited from
set()
set(
index
,value
):this
Defined in: data-mate/src/builder/Builder.ts:138
Set value by index
Parameters
Parameter | Type |
---|---|
index | number |
value | unknown |
Returns
this
Inherited from
toVector()
toVector():
Vector
<readonlyMaybe
<T
>[]>
Defined in: data-mate/src/builder/Builder.ts:175
Flush and convert the result to a Vector
Returns
Vector
<readonly Maybe
<T
>[]>
Inherited from
valueFrom()
valueFrom(
value
,indices
?): readonlyMaybe
<T
>[]
Defined in: data-mate/src/builder/Builder.ts:102
Convert a value to the internal in-memory storage format for the Vector
Parameters
Parameter | Type |
---|---|
value | unknown |
indices ? | number | Iterable <number , any , any > |
Returns
readonly Maybe
<T
>[]
Inherited from
make()
static
make<R
>(data
,options
):Builder
<R
>
Defined in: data-mate/src/builder/Builder.ts:14
Make an instance of a Builder from a DataTypeFieldConfig
Type Parameters
Type Parameter | Default type |
---|---|
R | unknown |
Parameters
Parameter | Type |
---|---|
data | WritableData <R > |
options | BuilderOptions |
Returns
Builder
<R
>
Inherited from
makeFromVector()
static
makeFromVector<R
>(vector
,size
):Builder
<R
>
Defined in: data-mate/src/builder/Builder.ts:28
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
>