easy-js-utils
Table of Contents
easy-js-utils
easy-js-utils is a package of helper functions.
Installation
It's recommended to install via npm:
npm install easy-js-utils --save
Usage
easy-js-utils has no external dependencies
//ES5var arrayUtils = arrayUtils; //ES6
API
Array Utilities
differenceBetweenTwoArrays Returns the different elements between two arrays
//returns ['1']
countofElements Returns the object of the count of elements in an array by key value pairings.
//returns { Lemon: 1, Orange: 2, Strawberry: 3, Banana: 2 }
getMaxElementInArray Returns the maximum number in an Array. If array includes different types only numbers are compared
//returns 123.456
getMinElementInArray Returns the minimum number in an Array. If array includes different types only numbers are compared
//returns 2
sumOfElementsInArray Returns the sum of elements in an array.
//returns 6
selectRandomFromArray Returns a random element from given array
//returns an element from array
String Utilities
revertString Returns the reverted string
//returns dcba
excerpt Reduces the text by word count limit. Works same in wordpress excerpt
//returns lorem ipsum dolor…
highlightText Highlight the text according to given parameters
//returns lorem <p class="highlight">ipsum</p> dolor <p class="highlight">sit</p> amet
unHighlightText Unhighlight the text according to given parameters
//returns lorem ipsum dolor sit amet
camelize Convert any string to camelcase
//returns loremIpsumDolorSitAmet
Date Utilities
isValidDate Returns false if the given date is not valid with the given format
//returns true //returns false
Number Utilities
addComas Returns string format of given number with separated given character
//returns 123.456.789
License
See LICENSE file.