@innofake/js-utilities
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Global Functions

Name Description Parameters Return Example

getValue

Retrieves the value from the object in a nested fashion. Specify a path as e.g. "food.fruit.apple". Click [here](https://hackernoon.com/accessing-nested-objects-in-javascript-f02f1bd6387f) for more info.

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

Assigns the value to the object in a nested fashion. Specify a path as e.g. "food.fruit.apple".

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

Check if the current value is non-null or non-undefined

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

Group by method for an array.

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

Determines if the given value is a [function](https://developer.mozilla.org/en-US/docs/Glossary/Function).

value {*} - Value to inspect.

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

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

isObject

Determines if a given value is an Object.

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

Determines if a given value is a Promise.

value {*} - Value to inspect.

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

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

formatBytes

Returns a formatted string with easier to read values for file sizes

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

Creates and returns a deep copy of an Object or Array.

inObject {*} - Object or Array to clone.

{*} - Copied object or Array.

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

isURL

Determines if a given string is a Url.

str {string} - Item to check

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

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i @innofake/js-utilities

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

67.9 kB

Total Files

24

Last publish

Collaborators

  • chromaticwaster
  • b0tlanner
  • stefan505