Skip to content

Tihi321/tsl-utils

Repository files navigation

TSL Utils

Utils to suplement lodash.

yarn add tsl-utils

  • 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 value
    • renameKeys — Update object keys with callback.
    • objectMap — Mapping through object keys and return object with updated values
    • objectLoop — Looping through object, same as forEach though you get index as 3rd parameter in callback
    • objectFilter — Mapping through object keys and returns new filtered object
    • cleanObject — Mapping through object keys and removing undefined values
    • swapObjectData — Mapping through object keys and taking values form second object under same key
    • swapObjectCleanedData — Mapping through object keys and taking values form second object under same key, all undefined values are removed
    • setObjectLeaf — 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 dynamically
    • getSortedObject — 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 library
    • combineSelector — Function that allows usage of selector logic outside of reselect
  • Arrays

    • includesAll — Check if all keys from source array are in target array
    • rangeEach — Callback is executed a range number of times
    • rangeMap — Creates a range custom array
    • rangeReduce — Reduces a range array
    • orderedPromiseAll — Return array with all promises resolved in order, one after another
  • Events

    • dispatchEvent — Dispatches custom event
    • addOnHistoryChangeEvent — 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 browser
    • domReady — Runs function when content is rendered
    • addOnHistoryChangeCallback — Calls custom funtion on every history change

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published