1.0.0 • Published 2 years ago

@innofake/js-utilities v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Global Functions

getValue

obj {Object} - Object to retrieve value from.

path {String} - Path to nested value, e.g. "food.fruit.apple".

separator {String} - Separator to the path split on.

{*} - Value of the resolved path.

    import { getValue } from '@innofake/js-utilities';
    

setValue

obj {Object} - Object to set value on.

path {String} - Path to nested value, e.g. "food.fruit.apple".

value {*} - Value to set for the path.

separator {String} - Separator to the path split on.

{void} -

    import { setValue } from '@innofake/js-utilities';
    

hasValue

value {Number|String|Object} - Value to check

{Boolean} - - Boolean for if the value is non-null or non-undefined

    import { hasValue } from '@innofake/js-utilities';
    

groupBy

arr {Array} - Array to group.

target {String|function} - Grouping target:

``` as property to group on, e.g. "userId"
 - 
```Function
``` as [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Syntax) callback function.

</td><td>

{`Object`} - Contains a property as key for each group.

</td><td>


```js

    import { groupBy } from '@innofake/js-utilities';
    

isFunction

value {*} - Value to inspect.

{Boolean} - True if the value is a valid function.

    import { isFunction } from '@innofake/js-utilities';
    

isObject

value {*} - Value to inspect.

{Boolean} - True if the value is an object.

    import { isObject } from '@innofake/js-utilities';
    

isEmptyObject

obj {*} - Value to inspect

{Boolean} - True if the value is an empty.

    import { isEmptyObject } from '@innofake/js-utilities';
    

isString

s {*} - Value to inspect

{Boolean} - True if the value is a string.

    import { isString } from '@innofake/js-utilities';
    

isPromise

value {*} - Value to inspect.

{Boolean} - True if the value is a Promise.

    import { isPromise } from '@innofake/js-utilities';
    

formatBytes

bytes {Number} - Size passed in.

decimals {Number} - Number of decimals to return. Default to 2

{String} - The value with size formatted

    import { formatBytes } from '@innofake/js-utilities';
    

deepCopy

inObject {*} - Object or Array to clone.

{*} - Copied object or Array.

    import { deepCopy } from '@innofake/js-utilities';
    

isURL

str {string} - Item to check

{Boolean} - True if the parameter is a Url.

    import { isURL } from '@innofake/js-utilities';
    

-----------------------------------------------------