tsl-utils
v1.0.34
Published
Collection of Lodash like utilities
Downloads
10
Readme
Objects
pickFirstObjectItem
— Retrives first element from array value of object keys, used in combination with groupBy from lodash, groupBy returns grouped values from array with provided key in callback. If key is unique array will have one value. This can be used to take out that valuerenameKeys
— Update object keys with callback.objectMap
— Mapping through object keys and return object with updated valuesobjectLoop
— Looping through object, same as forEach though you get index as 3rd parameter in callbackobjectFilter
— Mapping through object keys and returns new filtered objectcleanObject
— Mapping through object keys and removing undefined valuesswapObjectData
— Mapping through object keys and taking values form second object under same keyswapObjectCleanedData
— Mapping through object keys and taking values form second object under same key, all undefined values are removedsetObjectLeaf
— similar to setWith from lodash, though this function returns new object. It takes array of keys and value, it updates object last key with value and if keys do not exist it creates them dynamicallygetSortedObject
— Get object where keys are sorted alphabetically
Functions
promisifyCallback
— Promisify functions that accept callback that will be called upon resolve, example wainting for message from api
Selectors
generateSelector
— Function that generates selector for reselect librarycombineSelector
— Function that allows usage of selector logic outside of reselect
Arrays
includesAll
— Check if all keys from source array are in target arrayrangeEach
— Callback is executed a range number of timesrangeMap
— Creates a range custom arrayrangeReduce
— Reduces a range arrayorderedPromiseAll
— Return array with all promises resolved in order, one after another
Events
dispatchEvent
— Dispatches custom eventaddOnHistoryChangeEvent
— Disptaches custom event on every history change
Api
fetchApi
— Fetch helper with options for generating query string and prefix, takes custom fetchCallback for usage if node-fetch should be used
Browser
isBrowser
— Detects if code is running in a browserdomReady
— Runs function when content is renderedaddOnHistoryChangeCallback
— Calls custom funtion on every history change