Skip to main content

@terascope/utils / type-coercion

type-coercion

Variables

MAX_STRING_LENGTH_BEFORE_MD5

const MAX_STRING_LENGTH_BEFORE_MD5: 1024 = 1024

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

Source

packages/utils/src/type-coercion.ts:156

Functions

coerceToGeoBoundary()

coerceToGeoBoundary(input): GeoBoundary

Convert value to a GeoBoundary data type, a GeoBoundary is two GeoPoints, one representing the top left, the other representing the bottom right

Parameters

ParameterType
inputunknown

Returns

GeoBoundary

Source

packages/utils/src/type-coercion.ts:111


coerceToGeoPoint()

coerceToGeoPoint(input): GeoPoint

Convert value to a GeoPoint data type

Parameters

ParameterType
inputunknown

Returns

GeoPoint

Source

packages/utils/src/type-coercion.ts:102


coerceToNumberType()

coerceToNumberType(type): (input) => number | bigint

Parameters

ParameterType
typeFieldType

Returns

Function

Parameters
ParameterType
inputunknown
Returns

number | bigint

Source

packages/utils/src/type-coercion.ts:65


coerceToType()

coerceToType<T>(fieldConfig, childConfig?): CoerceFN<T>

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 parameterValue
Tunknown

Parameters

ParameterType
fieldConfigDataTypeFieldConfig
childConfig?DataTypeFields

Returns

CoerceFN<T>

Source

packages/utils/src/type-coercion.ts:28


getHashCodeFrom()

getHashCodeFrom(value): string

Generate a unique hash code from a value, this is not a guarantee but it is close enough for doing groupBys and caching

Parameters

ParameterType
valueunknown

Returns

string

Source

packages/utils/src/type-coercion.ts:163


md5()

md5(value): string

Parameters

ParameterType
valuestring | Buffer

Returns

string

Source

packages/utils/src/type-coercion.ts:169