General
grupojaque-ngx-commons › Globals › "lib/helpers/general.helper"
General Helper
This module implements functions that we've used (and even implemented) repeatedly in the same project. Most of the functions in here are assumed to be requiered at least once in common front-end projects.
Index
Data Handling Functions
Other Functions
Data Handling Functions
getObjectPath
▸ getObjectPath(obj
: any, path
: string): any
Defined in lib/helpers/general.helper.ts:115
Return the value that an object holds in a given path
When the path doesn't exist in any of the anidated keys, it'll return undefined
.
Parameters:
Name | Type | Description |
---|---|---|
obj | any | An object |
path | string | Path to access, example "pagination.limit" |
Returns: any
objectHasPath
▸ objectHasPath(obj
: any, path
: string): boolean
Defined in lib/helpers/general.helper.ts:38
Check if a deep property path is defined in an object
The path is received as a string separated with dots, as you'd otherwise
try to access those properties: prop.prop2.prop3
.
If any property in the path is undefined, the function will return false.
Parameters:
Name | Type | Description |
---|---|---|
obj | any | Object to find the propety path |
path | string | Dot-separated string representing the property path to check |
Returns: boolean
Whether all the properties in the path are defined or not
objectHasPaths
▸ objectHasPaths(obj
: any, paths
: string[]): boolean
Defined in lib/helpers/general.helper.ts:85
Check if an object contains all of many deep property paths
Each path is received as a string separated with commas, as you'd otherwise
try to access those properties: prop.prop2.prop3
.
If any of the paths in the paths array is undefined, the function will return false.
Parameters:
Name | Type | Description |
---|---|---|
obj | any | Object to find the propety paths |
paths | string[] | Each string represents the path to check |
Returns: boolean
Whether each path in the list is defined or not
Other Functions
findValueInObjectArray
▸ findValueInObjectArray(array
: any[], path
: string, value
: string | boolean | number): any
Defined in lib/helpers/general.helper.ts:168
Returns the first element that matches a shallow comparison
For every object in the array, it'll try to fetch the property value for the received path and shallow-compare it to the value to match.
Parameters:
Name | Type | Description |
---|---|---|
array | any[] | Array of objects to look in |
path | string | Property path of the value to compare |
value | string | boolean | number | Value that matches the searched object |
Returns: any
getArrayOfAnEnum
▸ getArrayOfAnEnum<T>(obj
: T): Array‹object›
Defined in lib/helpers/general.helper.ts:131
Type parameters:
▪ T
Parameters:
Name | Type | Description |
---|---|---|
obj | T | is an enum |
Returns: Array‹object›
object array