@terascope/utils / type-coercion
type-coercion
Variables
MAX_STRING_LENGTH_BEFORE_MD5
constMAX_STRING_LENGTH_BEFORE_MD5:1024=1024
Defined in: packages/utils/src/type-coercion.ts:157
If we have a hash that is a long value we want to ensure that the value doesn't explode the memory since we may be using that value as a key. So when a string exceeds this specified length we can reduce its length to 35 characters by using md5
Functions
coerceToGeoBoundary()
coerceToGeoBoundary(
input):GeoBoundary
Defined in: packages/utils/src/type-coercion.ts:112
Convert value to a GeoBoundary data type, a GeoBoundary is two GeoPoints, one representing the top left, the other representing the bottom right
Parameters
| Parameter | Type |
|---|---|
input | unknown |
Returns
GeoBoundary
coerceToGeoPoint()
coerceToGeoPoint(
input):GeoPoint
Defined in: packages/utils/src/type-coercion.ts:103
Convert value to a GeoPoint data type
Parameters
| Parameter | Type |
|---|---|
input | unknown |
Returns
GeoPoint
coerceToNumberType()
coerceToNumberType(
type): (input) =>number|bigint
Defined in: packages/utils/src/type-coercion.ts:66
Parameters
| Parameter | Type |
|---|---|
type | FieldType |
Returns
(
input):number|bigint
Parameters
| Parameter | Type |
|---|---|
input | unknown |
Returns
number | bigint
coerceToType()
coerceToType<
T>(fieldConfig,childConfig?):CoerceFN<T>
Defined in: packages/utils/src/type-coercion.ts:28
Will return a function that will coerce the input values to the DataTypeFieldConfig provided. The parameter childConfig is only necessary with Tuple or Object field types
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
fieldConfig | DataTypeFieldConfig |
childConfig? | DataTypeFields |
Returns
CoerceFN<T>
getHashCodeFrom()
getHashCodeFrom(
value):string
Defined in: packages/utils/src/type-coercion.ts:164
Generate a unique hash code from a value, this is not a guarantee but it is close enough for doing groupBys and caching
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
string
md5()
md5(
value):string
Defined in: packages/utils/src/type-coercion.ts:170
Parameters
| Parameter | Type |
|---|---|
value | string | Buffer<ArrayBufferLike> |
Returns
string