1.9.3 • Published 6 years ago
@ukon1990/js-utilities v1.9.3
Javascript utilities
This is a small package with some utilities.
To install: npm i @ukon1990/js-utilities --save
ObjectUtil
isObject(value)- Checks if a value is an object and not arrayisPopulatedObject(value)- Returns true if an object is populatedoverwrite(fromObject, toObject, doNotMutate = false)- Replaces all the values of one objects with another objectclone(object)- Returns a cloned version of an object. Removing all child object references.isEqual(object1, object2)- Checks if two objects are equal regardless of object reference.getDifference(object1, object2)- Returns an array of object differences asDifferenceobjects.merge(object1, object2- Merges/Combines two objects into one, keeping all the values from each that does not exist in the other.
ArrayUtil
isArray(value)- Checks if a value is an object and not arrayisPopulatedArray(value)- Returns true if an array is populatedclone(array)- Returns a cloned version of an array. Removing all child object references.isEqual(array1, array2)- Checks if two arrays are equal regardless of object reference.getDifference(array1, array2)- Returns an array of differences asDifferenceobjects.removeObject(value, fromArray, immutable = false)- Removes all entries that is identical to a value from an array, regardless of the object reference. If , immutable = true, it will return a copy instead of mutating the input array.removeObjects(values, fromArray)- Removes multiple objects/values from an array.removeIndexes(indexes, fromArray)- Removes the elements from an array at the supplied index locationsremoveDuplicates(fromArray, immutable = false)- Remove all duplicate entries in an array. If , immutable = true, it will return a copy instead of mutating the input array.randomOrder(fromArray)- Returns a new array with the items in the fromArray in random order.
TextUtil
isEmpty(string)- Checks if a string is null, undefined or has a length of 0.isEqualIgnoreCase(string, string- Checks if two strings are equal (case insensitive).getMatchingParts(string, stringToFind)- Returns a Match object. The Match object forgetMatchingParts('Chicken', 'ck')looks like this{start: 'Chi', match: 'ck', end: 'en'}.getIndexOf(sourceString, targetString)- Is basicallysourceString.toLowerCase().indexOf(targetString.toLowerCase)contains(sourceString, targetString)- Checks if a string exists within another. This is case-insensitive.isLowerCase(string)- Checks if a string is upper or lowercase.sentenceToCamelCase(sentence, upperCase?)- Converts a sentence into lower camel case.camelCaseToSentence(sentence)- Converts a sentence of camelCase words into a sentence with spaces.csvToObjects(input, delimiter?, options?: {headerNames?: string[], types?: string[]})- Generates an array of objects from a CSV string.objectsToCSV(list, delimiter?: string = ',', useKeys?: string[])- Converts a list of objects to a CSV string. If provided with the keys that is supposed to be used from the objects, it will increase performance.
EmptyUtil
isNullOrUndefined(value, value?)- Checks if all the input is null or undefined.isAPopulatedArrayOrObject(value)- Checks if a value is a populated array or object
DateUtil
getDifferenceInMS(fromDate, toDate)- Returns the difference between two dates in millisecondsgetDifferenceInSeconds(fromDate, toDate)- Returns the difference between two dates in secondsgetDifferenceInMinutes(fromDate, toDate)- Returns the difference between two dates in minutesgetDifferenceInHours(fromDate, toDate)- Returns the difference between two dates in hoursgetDifferenceInDays(fromDate, toDate)- Returns the difference between two dates in daysgetDifferenceInWeeks(fromDate, toDate)- Returns the difference between two dates in weekstimeSince(fromDate)- Returns the time since a provided date. The second parameter can be empty(defaults to ms) ors/seconds,m/minutes,h/hours,d/days,w/weeks.
1.9.3
6 years ago
1.9.2
6 years ago
1.9.1
6 years ago
1.9.0-beta-0
6 years ago
1.9.2-beta.0
6 years ago
1.9.0
6 years ago
1.8.3
6 years ago
1.8.3-beta.0
6 years ago
1.8.2
6 years ago
1.8.1
6 years ago
1.8.0
6 years ago
1.7.0
6 years ago
1.6.3
6 years ago
1.6.2
6 years ago
1.6.1
6 years ago
1.6.0
6 years ago
1.5.1
6 years ago
1.5.0
6 years ago
1.4.0
6 years ago
1.3.2
6 years ago
1.3.1
6 years ago
1.3.1-beta.0
6 years ago
1.3.0
6 years ago
1.2.0
6 years ago
1.1.0
6 years ago
1.0.0
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago