JavaScript Snippets as an NPM package
Accepts arguments: url - string and tagName - string
tagName will usually be 'head' or 'body'.
To add an external JavaScript file to the head or body if it isn't already present.
Also uses isScriptPresentByURL
Accepts: contents - stringified JavaScript, scriptId - string (gives the script an id), tagName - string.
tagName will usually be 'head' or 'body'.
To add JavaScript contents to the head or body if it isn't already present.
Also uses isScriptPresentByID
Accepts: url - string
To check if an external JavaScript file has been loaded by using it's URL to match.
Accepts: id - string
To check if an external JavaScript file has been loaded by using it's ID to match.
Accepts: startDate, stopDate - Dates
Returns array of dates between start and stop date.
Accepts: startDate, stopDate
Returns array of dates between start and stop date not including weekends.
Accepts: dataURI
Converts dataURI to a Blob, returns {error} if fails.
Accepts: date1, date2 - Dates
Check if two dates are the same day. Returns a boolean.
Array, Field.
Returns a boolean if field exists and is identical in array.
e.g Array= ['test', {name:'value'}] returns true for: field = 'test' and field = {name:'value'}
String - string
UpperCase the first character of a string only
Date - Date
Format a time slot hh:mm AM or hh:mm PM in local time.
Date - Date
dd/mm/yyyy hh:mm
Date - Date
Convert date to UNIX seconds, JavaScript uses milliseconds when using new Date().getTime()
Date - Date
Takes a date and removes the hours, minutes and seconds.
Date - Date, minutes - number of minutes to remove
Returns a date with specific number of minutes removed
Element Identifier - Query Selector, event - callback function
To add a click outside event listener to an element.
String - string
Remove whitespace, tabs and line breaks.
String - String
Return a title cased string
String - String
Uses a regex pattern to check if email is a valid email.