@terascope/utils / objects
objects
Functions
fastAssign()
fastAssign<
T,U>(target,source):T&U
Defined in: packages/utils/src/objects.ts:58
Perform a shallow clone of an object to another, in the fastest way possible
Type Parameters
| Type Parameter | 
|---|
| Textendsobject | 
| Uextendsobject | 
Parameters
| Parameter | Type | 
|---|---|
| target | T | 
| source | U | 
Returns
T & U
fastCloneDeep()
fastCloneDeep<
T>(input):T
Defined in: packages/utils/src/objects.ts:53
A clone deep using JSON.parse(JSON.stringify(input))
Type Parameters
| Type Parameter | 
|---|
| T | 
Parameters
| Parameter | Type | 
|---|---|
| input | T | 
Returns
T
filterObject()
filterObject<
T,I,E>(data,by?):FilteredResult<T,I,E>
Defined in: packages/utils/src/objects.ts:135
Filters the keys of an object, by list of included key and excluded
Type Parameters
| Type Parameter | 
|---|
| Textendsobject | 
| Iextendsstring|number|symbol | 
| Eextendsstring|number|symbol | 
Parameters
| Parameter | Type | 
|---|---|
| data | T | 
| by? | { excludes?:E[];includes?:I[]; } | 
| by.excludes? | E[] | 
| by.includes? | I[] | 
Returns
FilteredResult<T, I, E>
getField()
Call Signature
getField<
V>(input,field,defaultVal?):V
Defined in: packages/utils/src/objects.ts:170
A type safe get function (will always return the correct type)
IMPORTANT This does not behave like lodash.get, it does not deal with dot notation (nested fields) and it will use the default when dealing with OR statements
Type Parameters
| Type Parameter | 
|---|
| V | 
Parameters
| Parameter | Type | 
|---|---|
| input | undefined | 
| field | string | 
| defaultVal? | V | 
Returns
V
Call Signature
getField<
T,P>(input,field):T[P]
Defined in: packages/utils/src/objects.ts:175
A type safe get function (will always return the correct type)
IMPORTANT This does not behave like lodash.get, it does not deal with dot notation (nested fields) and it will use the default when dealing with OR statements
Type Parameters
| Type Parameter | 
|---|
| T | 
| Pextendsstring|number|symbol | 
Parameters
| Parameter | Type | 
|---|---|
| input | T | 
| field | P | 
Returns
T[P]
Call Signature
getField<
T,P>(input,field):T[P]
Defined in: packages/utils/src/objects.ts:179
A type safe get function (will always return the correct type)
IMPORTANT This does not behave like lodash.get, it does not deal with dot notation (nested fields) and it will use the default when dealing with OR statements
Type Parameters
| Type Parameter | 
|---|
| T | 
| Pextendsstring|number|symbol | 
Parameters
| Parameter | Type | 
|---|---|
| input | undefined|T | 
| field | P | 
Returns
T[P]
Call Signature
getField<
T,P>(input,field,defaultVal):T[P]
Defined in: packages/utils/src/objects.ts:183
A type safe get function (will always return the correct type)
IMPORTANT This does not behave like lodash.get, it does not deal with dot notation (nested fields) and it will use the default when dealing with OR statements
Type Parameters
| Type Parameter | 
|---|
| T | 
| Pextendsstring|number|symbol | 
Parameters
| Parameter | Type | 
|---|---|
| input | undefined|T | 
| field | P | 
| defaultVal | never[] | 
Returns
T[P]
Call Signature
getField<
T,P,V>(input,field,defaultVal):V|T[P]
Defined in: packages/utils/src/objects.ts:188
A type safe get function (will always return the correct type)
IMPORTANT This does not behave like lodash.get, it does not deal with dot notation (nested fields) and it will use the default when dealing with OR statements
Type Parameters
| Type Parameter | 
|---|
| T | 
| Pextendsstring|number|symbol | 
| V | 
Parameters
| Parameter | Type | 
|---|---|
| input | undefined|T | 
| field | P | 
| defaultVal | V | 
Returns
V | T[P]
Call Signature
getField<
T,P,V>(input,field,defaultVal):T[P]
Defined in: packages/utils/src/objects.ts:193
A type safe get function (will always return the correct type)
IMPORTANT This does not behave like lodash.get, it does not deal with dot notation (nested fields) and it will use the default when dealing with OR statements
Type Parameters
| Type Parameter | 
|---|
| T | 
| Pextendsstring|number|symbol | 
| V | 
Parameters
| Parameter | Type | 
|---|---|
| input | undefined|T | 
| field | P | 
| defaultVal | V | 
Returns
T[P]
getFirstKey()
getFirstKey<
T>(input):undefined| keyofT
Defined in: packages/utils/src/objects.ts:32
Get the first key in an object
Type Parameters
| Type Parameter | 
|---|
| Textendsobject | 
Parameters
| Parameter | Type | 
|---|---|
| input | T | 
Returns
undefined | keyof T
getFirstValue()
getFirstValue<
T>(input):undefined|T
Defined in: packages/utils/src/objects.ts:25
Get the first value in an object
Type Parameters
| Type Parameter | 
|---|
| T | 
Parameters
| Parameter | Type | 
|---|---|
| input | {[ key:string]:T; } | 
Returns
undefined | T
hasOwn()
hasOwn(
obj,prop):boolean
Defined in: packages/utils/src/objects.ts:215
Check if a object has property (and not included in the prototype) Different from has since it doesn't deal with dot notation values.
Parameters
| Parameter | Type | 
|---|---|
| obj | any | 
| prop | string|number|symbol | 
Returns
boolean
isKey()
isKey<
T>(O,k):k is keyof T
Defined in: packages/utils/src/objects.ts:39
Verify that k is a key of object O
Type Parameters
| Type Parameter | 
|---|
| Textendsobject | 
Parameters
| Parameter | Type | 
|---|---|
| O | T | 
| k | PropertyKey | 
Returns
k is keyof T
isObjectEntity()
isObjectEntity(
input):boolean
Defined in: packages/utils/src/objects.ts:46
Verify if the input is a object like type
Parameters
| Parameter | Type | 
|---|---|
| input | unknown | 
Returns
boolean
isSimpleObject()
isSimpleObject(
input):input is Record<string, unknown>
Defined in: packages/utils/src/objects.ts:13
Similar to is-plain-object but works better when you cloneDeep a DataEntity
Parameters
| Parameter | Type | 
|---|---|
| input | unknown | 
Returns
input is Record<string, unknown>
lookup()
lookup(
input): (key) =>any
Defined in: packages/utils/src/objects.ts:219
Parameters
| Parameter | Type | 
|---|---|
| input | unknown | 
Returns
(
key):any
Parameters
| Parameter | Type | 
|---|---|
| key | unknown | 
Returns
any
mapKeys()
mapKeys<
T,R>(input,fn):R
Defined in: packages/utils/src/objects.ts:105
Map the keys of an object
Type Parameters
| Type Parameter | Default type | 
|---|---|
| Textendsobject | - | 
| R | T | 
Parameters
| Parameter | Type | 
|---|---|
| input | T | 
| fn | ( value,key) =>any | 
Returns
R
mapValues()
mapValues<
T,R>(input,fn):R
Defined in: packages/utils/src/objects.ts:91
Map the values of an object
Type Parameters
| Type Parameter | Default type | 
|---|---|
| Textendsobject | - | 
| R | T | 
Parameters
| Parameter | Type | 
|---|---|
| input | T | 
| fn | ( value,key) =>any | 
Returns
R
sortKeys()
sortKeys<
T>(input,options):T
Defined in: packages/utils/src/objects.ts:71
Sort keys on an object
Type Parameters
| Type Parameter | 
|---|
| TextendsRecord<string,unknown> | 
Parameters
| Parameter | Type | 
|---|---|
| input | T | 
| options | { deep?:boolean; } | 
| options.deep? | boolean | 
Returns
T
withoutNil()
withoutNil<
T>(input):WithoutNil<T>
Defined in: packages/utils/src/objects.ts:119
Build a new object without null or undefined values (shallow)
Type Parameters
| Type Parameter | 
|---|
| T | 
Parameters
| Parameter | Type | 
|---|---|
| input | T | 
Returns
WithoutNil<T>