Data-Mate: `Vector Vector Vector`
vector/Vector.Vector
An immutable typed Array class with a constrained API.
Type parameters
Name | Type |
---|---|
T | unknown |
Hierarchy
Vector
↳
IPVector
Table of contents
Constructors
Properties
Accessors
Methods
- [iterator]
- append
- compare
- countUnique
- countValues
- findDataWithIndex
- fork
- get
- getComparableValue
- has
- hasNilValues
- isEmpty
- prepend
- slice
- toArray
- toJSON
- toJSONCompatibleValue
- toWritable
- unique
- uniqueValues
- values
- getSortedIndices
- make
Constructors
constructor
• new Vector<T
>(type
, data
, options
): Vector
<T
>
Type parameters
Name | Type |
---|---|
T | unknown |
Parameters
Name | Type | Description |
---|---|---|
type | VectorType | This will be set automatically by specific Vector classes |
data | DataBuckets <T > | - |
options | VectorOptions | - |
Returns
Vector
<T
>
Defined in
data-mate/src/vector/Vector.ts:114
Properties
childConfig
• Optional
Readonly
childConfig: ReadonlyDataTypeFields
When Vector is an object type, this will be the data type fields for the object
Defined in
data-mate/src/vector/Vector.ts:84
config
• Readonly
config: Readonly
<DataTypeFieldConfig
>
The field type configuration
Defined in
data-mate/src/vector/Vector.ts:78
data
• Readonly
data: readonly ReadableData
<T
>[]
A data type agnostic in-memory representation of the data for a Vector and potential indices/unique values. Currently there one ore more data buckets can be used.
Note
DO NOT MUTATE THESE IT WILL BREAK THE GUARANTEES OF IMMUTABILITY AND WILL CREATE SIDE EFFECTS BETWEEN DATA FRAMES
Defined in
data-mate/src/vector/Vector.ts:97
name
• Optional
Readonly
name: string
The name of field, if specified this will just be used for metadata
Defined in
data-mate/src/vector/Vector.ts:68
sortable
• sortable: boolean
= true
If set to false, the Vector is not sortable
Defined in
data-mate/src/vector/Vector.ts:102
type
• Readonly
type: VectorType
The type of Vector, this should only be set the specific Vector type classes.
Defined in
data-mate/src/vector/Vector.ts:73
Accessors
size
• get
size(): number
Returns the number items in the Vector
Returns
number
Defined in
data-mate/src/vector/Vector.ts:150
Methods
[iterator]
▸ [iterator](): IterableIterator
<Maybe
<T
>>
Returns
IterableIterator
<Maybe
<T
>>
Defined in
data-mate/src/vector/Vector.ts:184
append
▸ append(data
): Vector
<T
>
Add ReadableData to a end of the data buckets
Parameters
Name | Type | ||
---|---|---|---|
data | ReadableData <T > \ | readonly ReadableData <T >[] \ | ReadableData <T >[] |
Returns
Vector
<T
>
Defined in
data-mate/src/vector/Vector.ts:290
compare
▸ compare(a
, b
): 0
| 1
| -1
Compare two different values on the Vector type. This can be used for equality or sorted.
Parameters
Name | Type |
---|---|
a | Maybe <T > |
b | Maybe <T > |
Returns
0
| 1
| -1
Defined in
data-mate/src/vector/Vector.ts:498
countUnique
▸ countUnique(): number
Get the count of distinct values.
Returns
number
Note
this is O(1) for non-object types and O(n) + extra hashing logic for larger objects
Defined in
data-mate/src/vector/Vector.ts:231
countValues
▸ countValues(): number
Get the number of non-nil values in the Vector
Returns
number
Defined in
data-mate/src/vector/Vector.ts:200
findDataWithIndex
▸ findDataWithIndex(index
): undefined
| [data: ReadableData<T>, actualIndex: number]
Find the Data bucket that holds the value for that bucket
Parameters
Name | Type |
---|---|
index | number |
Returns
undefined
| [data: ReadableData<T>, actualIndex: number]
the data found and the index of the relative index of value
Defined in
data-mate/src/vector/Vector.ts:350
fork
▸ fork(_data
): Vector
<T
>
Create a new Vector with the same metadata but with different data
Parameters
Name | Type | |
---|---|---|
_data | readonly ReadableData <T >[] \ | ReadableData <T >[] |
Returns
Vector
<T
>
Defined in
data-mate/src/vector/Vector.ts:431
get
▸ get(index
, json?
, options?
): Maybe
<T
>
Get value by index
Parameters
Name | Type |
---|---|
index | number |
json? | boolean |
options? | SerializeOptions |
Returns
Maybe
<T
>
Defined in
data-mate/src/vector/Vector.ts:321
getComparableValue
▸ getComparableValue(value
): any
A function for converting an in-memory representation of a value to an JSON spec compatible format.
Parameters
Name | Type |
---|---|
value | T |
Returns
any
Defined in
data-mate/src/vector/Vector.ts:145
has
▸ has(index
): boolean
Returns true if the value for that index is not nil
Parameters
Name | Type |
---|---|
index | number |
Returns
boolean
Defined in
data-mate/src/vector/Vector.ts:339
hasNilValues
▸ hasNilValues(): boolean
Check to see there are any nil values stored in the Vector
Returns
boolean
Defined in
data-mate/src/vector/Vector.ts:193
isEmpty
▸ isEmpty(): boolean
Returns true if there are no non-nil values
Returns
boolean
Defined in
data-mate/src/vector/Vector.ts:207
prepend
▸ prepend(data
): Vector
<T
>
Add ReadableData to a beginning of the data buckets
Parameters
Name | Type | ||
---|---|---|---|
data | ReadableData <T > \ | readonly ReadableData <T >[] \ | ReadableData <T >[] |
Returns
Vector
<T
>
Defined in
data-mate/src/vector/Vector.ts:306
slice
▸ slice(start?
, end?
): Vector
<T
>
Create a new Vector with the range of values
Parameters
Name | Type | Default value |
---|---|---|
start | number | 0 |
end | number | undefined |
Returns
Vector
<T
>
Defined in
data-mate/src/vector/Vector.ts:448
toArray
▸ toArray(): Maybe
<T
>[]
Convert the Vector to array of values (the in-memory representation of the data)
Returns
Maybe
<T
>[]
Note
may not be JSON spec compatible
Defined in
data-mate/src/vector/Vector.ts:536
toJSON
▸ toJSON(options?
): Maybe
<T
>[]
Convert the Vector an array of values (the output is JSON compatible)
Parameters
Name | Type |
---|---|
options? | SerializeOptions |
Returns
Maybe
<T
>[]
Defined in
data-mate/src/vector/Vector.ts:524
toJSONCompatibleValue
▸ toJSONCompatibleValue(value
, options?
): any
A function for converting an in-memory representation of a value to an JSON spec compatible format.
Parameters
Name | Type |
---|---|
value | T |
options? | SerializeOptions |
Returns
any
Defined in
data-mate/src/vector/Vector.ts:139
toWritable
▸ toWritable(size?
): WritableData
<T
>
Fork the Data object with specific length.
Parameters
Name | Type | Description |
---|---|---|
size? | number | optionally change the size of the Data |
Returns
WritableData
<T
>
Defined in
data-mate/src/vector/Vector.ts:549
unique
▸ unique(): Iterable
<[index: number, value: T]>
Get the unique values with the index in a tuple form. This is useful for reconstructing an Vector with only the unique values
Returns
Iterable
<[index: number, value: T]>
Defined in
data-mate/src/vector/Vector.ts:245
uniqueValues
▸ uniqueValues(): Iterable
<T
>
Get the unique values, excluding nil values. Useful for getting a list of unique values.
Returns
Iterable
<T
>
Defined in
data-mate/src/vector/Vector.ts:270
values
▸ values(): IterableIterator
<[index: number, value: T]>
Iterate over the values and skip the nil ones, returns tuples a with index and value
Returns
IterableIterator
<[index: number, value: T]>
Defined in
data-mate/src/vector/Vector.ts:216
getSortedIndices
▸ getSortedIndices(sortBy
): number
[]
Sort the values in a Vector and return an array with the updated indices.
Parameters
Name | Type |
---|---|
sortBy | { direction : SortOrder ; vector : Vector <any > }[] |
Returns
number
[]
Defined in
data-mate/src/vector/Vector.ts:35
make
▸ make<R
>(data
, options
): Vector
<R
>
Make an instance of a Vector from a config
Type parameters
Name |
---|
R |
Parameters
Name | Type |
---|---|
data | DataBuckets <R > |
options | VectorOptions |
Returns
Vector
<R
>