1.0.2 • Published 1 year ago

@la40/js-helpers v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Javascript Helper Functions

Install

Via npm
$ npm i -S @la40/js-helpers
Via yarn
$ yarn add @la40/js-helpers

Use

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

ParamType
arrarray
oldIndexint
newIndexint

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

ParamTypeDescription
arrarrayarray with objects to convert
propertystringproperty to use
compactbooleandefault 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

ParamTypeDescription
arr1arraythe array to search
arr2arraythe 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

ParamTypeDescription
arr1arraythe array to get the first found item from
arr2arraythe array to search in

stringToBoolean(string) ⇒ boolean

Convert boolean string like "false|no|0|''" to false everything else to true

Kind: global function

ParamType
stringstring

isEmpty(value) ⇒ boolean

Check if value not empty (null,'',undefined,{},{ k1: null, k2: "" },[],null,'')

Kind: global function

ParamType
valueany

isEuDateTime(euDateTimeString) ⇒ boolean

Check if given string fulfill european data time format dd.mm.yyyy hh:mm:ss

Kind: global function

ParamType
euDateTimeStringstring

isDeepEqual(object1, object2) ⇒ boolean

Check if two objects are deep equal

Kind: global function

ParamType
object1object
object2object

isObject(o) ⇒ boolean

Check if an object inherits Object, {}

Kind: global function

ParamType
oobject

recursiveDeepCopy(o) ⇒ object

Will create a recursive deep copy of an object

Kind: global function

ParamType
oobject

Testing

$ npm run test

Change 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.

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago