@la40/js-helpers v1.0.2
Javascript Helper Functions
Install
Via npm
$ npm i -S @la40/js-helpersVia yarn
$ yarn add @la40/js-helpersUse
import { arrayMove, isEmpty } from @la40/js-helpers;Functions
arrayMove(arr, oldIndex, newIndex) ⇒ array
Move an array item from an index to another
Kind: global function
Returns: array - The new array
| Param | Type |
|---|---|
| arr | array |
| oldIndex | int |
| newIndex | int |
arrayToObjectByProperty(arr, property, compact) ⇒ object
Convert an array with objects to an object like {"property value x": object x, object y ..., "property value y": object z, object c ...}
Kind: global function
Returns: object - The new object
| Param | Type | Description |
|---|---|---|
| arr | array | array with objects to convert |
| property | string | property to use |
| compact | boolean | default to true will remove the property from objects x,y,z,c , if false will leave the objects as is |
arrayContainsSomeArray(arr1, arr2) ⇒ boolean
Determine if an array contains one or more items from another array.
Kind: global function
| Param | Type | Description |
|---|---|---|
| arr1 | array | the array to search |
| arr2 | array | the array providing items to check for in the arr1 |
arrayGetFirstFoundInArray(arr1, arr2) ⇒ null | any
Get first found item in arr1.
Kind: global function
Returns: null | any - null when not found or the found item from arr1
| Param | Type | Description |
|---|---|---|
| arr1 | array | the array to get the first found item from |
| arr2 | array | the array to search in |
stringToBoolean(string) ⇒ boolean
Convert boolean string like "false|no|0|''" to false everything else to true
Kind: global function
| Param | Type |
|---|---|
| string | string |
isEmpty(value) ⇒ boolean
Check if value not empty (null,'',undefined,{},{ k1: null, k2: "" },[],null,'')
Kind: global function
| Param | Type |
|---|---|
| value | any |
isEuDateTime(euDateTimeString) ⇒ boolean
Check if given string fulfill european data time format dd.mm.yyyy hh:mm:ss
Kind: global function
| Param | Type |
|---|---|
| euDateTimeString | string |
isDeepEqual(object1, object2) ⇒ boolean
Check if two objects are deep equal
Kind: global function
| Param | Type |
|---|---|
| object1 | object |
| object2 | object |
isObject(o) ⇒ boolean
Check if an object inherits Object, {}
Kind: global function
| Param | Type |
|---|---|
| o | object |
recursiveDeepCopy(o) ⇒ object
Will create a recursive deep copy of an object
Kind: global function
| Param | Type |
|---|---|
| o | object |
Testing
$ npm run testChange log
Please see CHANGELOG for more information on what has changed recently.
Security
If you discover any security related issues, please email lachezar@grigorov.website instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.