Methods
(static) addLeadingZeroes(value, expectedLengthopt) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.addLeadingZeroes()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string to add leading zeroes to. |
||
expectedLength |
number |
<optional> |
NaN
|
The expected minimum length of the string after zeroes have been prepended to it. |
Returns:
TODO_RETURN_DESC
- Type
- string | null
(static) appendSlash(value, forwardSlashopt) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.appendSlash()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string to append a forward or back slash onto. |
||
forwardSlash |
boolean |
<optional> |
true
|
Determines if a forward or back slash should be appended. |
Returns:
The original string with a forward or back slash appended to it if there isn't already a forward or back slash at the end or null if the specified value is not a string.
- Type
- string | null
(static) clone(value) → {any}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.clone({ some: "value" })); // {"some":"value"}
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to clone. |
Returns:
A copy of the specified value.
- Type
- any
(static) compareCasePercentage(value) → {number}
- Source:
- Since:
- 1.0.0
TODO_FUNC_DESC
Example
console.log(utilities.compareCasePercentage()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The string value to compare the case percentage of. |
Returns:
TODO_RETURN_DESC
- Type
- number
(static) compareDates(a, b) → {number}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.compareDates()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
a |
any | The first date to compare. |
b |
any | The second date to compare. |
Returns:
TODO_RETURN_DESC
- Type
- number
(static) compareVersions(v1, v2, caseSensitiveopt) → {number}
- Source:
- Since:
- 1.0.3
- See:
TODO_FUNC_DESC
Example
console.log(utilities.compareVersions()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
v1 |
string | TODO_ARG_DESC. |
||
v2 |
string | TODO_ARG_DESC. |
||
caseSensitive |
boolean |
<optional> |
false
|
TODO_ARG_DESC. |
Throws:
Will throw an error if an invalid or empty version is passed in as an argument.
Returns:
TODO_RETURN_DESC
- Type
- number
(static) createError(message, statusopt) → {Error}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use new Error() instead. Will be removed in a future release.
- See:
Creates an Error object instance with the specified message and HTTP status code.
Example
console.log(utilities.createError("COOL HATS ONLY.", 401)); // new Error("COOL HATS ONLY.") (with status property set to 401)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
message |
string | The error message. |
||
status |
number |
<optional> |
500
|
The HTTP status code of the error. |
Returns:
The error with the specified message and status code property.
- Type
- Error
(static) createQueryString(value, includeQuestionMarkopt) → {string}
- Source:
- Since:
- 1.0.0
TODO_FUNC_DESC
Example
console.log(utilities.createQueryString()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
Object | An object to convert into a query string based on the key / value pairs. |
||
includeQuestionMark |
boolean |
<optional> |
false
|
Determines if a question mark should be included at the beginning of the query string. |
Returns:
A query string created from the specified object value with all keys and values safely URI encoded.
- Type
- string
(static) createRange(start, endopt) → {Array.<number>}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Determined to no longer be useful, will be removed in a future release.
TODO_FUNC_DESC
Example
console.log(utilities.createRange()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
start |
number | An integer number which decides what value to start the range at. If no end value is specified, this value is treated as the end of the range while the start is defaulted to 0. |
|
end |
number |
<optional> |
An integer which determines what value the range should end at. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<number>
(static) disabledElements(elements) → {Array.<Object>}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use Array.filter() instead. Will be removed in a future release.
- See:
TODO_FUNC_DESC
Example
console.log(utilities.disabledElements()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
elements |
Array.<Object> | TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<Object>
(static) elementsWithAttribute(elements, attribute, hasAttributeopt) → {Array.<Object>}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use Array.filter() instead. Will be removed in a future release.
- See:
TODO_FUNC_DESC
Example
console.log(utilities.elementsWithAttribute()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
elements |
Array.<Object> | TODO_ARG_DESC. |
||
attribute |
string | TODO_ARG_DESC. |
||
hasAttribute |
boolean |
<optional> |
true
|
TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<Object>
(static) elementsWithoutAttribute(elements, attribute) → {Array.<Object>}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use Array.filter() instead. Will be removed in a future release.
- See:
TODO_FUNC_DESC
Example
console.log(utilities.elementsWithoutAttribute()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
elements |
Array.<Object> | TODO_ARG_DESC. |
attribute |
string | TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<Object>
(static) enabledElements(elements) → {Array.<Object>}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use Array.filter() instead. Will be removed in a future release.
- See:
TODO_FUNC_DESC
Example
console.log(utilities.enabledElements()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
elements |
Array.<Object> | TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<Object>
(static) equalsIgnoreCase(stringA, stringB) → {boolean}
- Source:
- Since:
- 1.3.2
Case insensitively compares two strings to determine if they are equal.
Example
console.log(utilities.equalsIgnoreCase("Test", "TEsT")); // true
console.log(utilities.equalsIgnoreCase("lower", "lower")); // true
console.log(utilities.equalsIgnoreCase("yes", "ye$")); // false
console.log(utilities.equalsIgnoreCase(null, "unknown")); // false
Parameters:
Name | Type | Description |
---|---|---|
stringA |
string | The first string to compare. |
stringB |
string | The second string to compare against |
Returns:
.A value of true if the strings are case insensitively equal, otherwise false.
- Type
- boolean
(static) fileHasExtension(fileName, extension) → {boolean}
- Source:
- Since:
- 1.2.18
- See:
TODO_FUNC_DESC
Example
console.log(utilities.fileHasExtension("file.txt", "TXT")); // true
console.log(utilities.fileHasExtension("data/segment.ts", "ts")); // true
console.log(utilities.fileHasExtension("folder", "dir")); // false
console.log(utilities.fileHasExtension("lol.wut", "")); // false
console.log(utilities.fileHasExtension("", "ok")); // false
console.log(utilities.fileHasExtension(null, null)); // false
Parameters:
Name | Type | Description |
---|---|---|
fileName |
string | A file name or path string to extract the extension from. |
extension |
string | A string to case insensitively compare the actual file extension against. |
Returns:
Returns true if the extension of the file case insensitively matches the specified extension, otherwise false if they do not match or either the specified or actual extension is empty or not a string.
- Type
- boolean
(static) formatObject(object, format, removeExtraopt, throwErrorsopt) → {Object}
- Source:
- Since:
- 1.1.1
- Deprecated:
- Use formatValue instead. Will be removed in a future release.
- See:
TODO_FUNC_DESC
Example
console.log(utilities.formatObject()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
object |
Object | The object to format. |
||
format |
Object | The format specification. |
||
removeExtra |
boolean | Object |
<optional> |
false
|
Remove extra flag or formatting options object. |
throwErrors |
boolean |
<optional> |
false
|
Remove extra flag or formatting options object. |
Throws:
Will optionally throw an error if any invalid data is encountered when formatting the object.
Returns:
The formatted object.
- Type
- Object
(static) formatStringList(value, stringifyopt) → {string}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.formatStringList()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | Array.<string> | The string list to format. |
||
stringify |
boolean | null |
<optional> |
null
|
TODO_ARG_DESC |
Returns:
The formatted string list.
- Type
- string
(static) formatValue(value, format, optionsopt) → {any}
- Source:
- Since:
- 1.1.1
TODO_FUNC_DESC
Example
console.log(utilities.formatValue()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
any | The value to format. |
|
format |
Object | The format specification. |
|
options |
Object |
<optional> |
Formatting options. |
Throws:
Will optionally throw an error if invalid data is encountered when formatting the value.
Returns:
The formatted value.
- Type
- any
(static) futureMonths(date, prependZeroopt) → {Array.<string>|null}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Determined to no longer be useful, will be removed in a future release.
TODO_FUNC_DESC
Example
console.log(utilities.futureMonths("June 18, 1987", true)); // ["07", "08", "09", "10", "11", "12"]
console.log(utilities.futureMonths(1586022503089)); // ["5", "6", 7", "8", "9", "10", "11", "12"]
console.log(utilities.futureMonths("When?")); // null
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
date |
Date | The date to start at when determining which months to exclude from the list. |
||
prependZero |
boolean |
<optional> |
false
|
Determines if a zero should be prepended to each entry in the array. |
Returns:
An array of numbers as strings each optionally padded with a leading zero, representing all of the month numbers which come after the specified date.
- Type
- Array.<string> | null
(static) generateVersions(version, prefixopt, suffixopt) → {Array.<string>}
- Source:
- Since:
- 1.0.3
- See:
TODO_FUNC_DESC
Example
console.log(utilities.generateVersions()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
version |
string | TODO_ARG_DESC. |
||
prefix |
string | null |
<optional> |
null
|
TODO_ARG_DESC. |
suffix |
string | null |
<optional> |
null
|
TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<string>
(static) getFileExtension(fileName) → {string|null}
- Source:
- Since:
- 1.2.18
- See:
TODO_FUNC_DESC
Example
console.log(utilities.getFileExtension("settings.ini")); // "ini"
console.log(utilities.getFileExtension("./data/yes.no")); // "no"
console.log(utilities.getFileExtension("C:\\temp")); // ""
console.log(utilities.getFileExtension("/var/tmp/")); // ""
console.log(utilities.getFileExtension("")); // ""
console.log(utilities.getFileExtension(NaN)); // null
Parameters:
Name | Type | Description |
---|---|---|
fileName |
string | A file name or path string to extract the extension from. |
Returns:
Returns a string value containing the extension of the file or null if the file name or path was not a string.
- Type
- string | null
(static) getFileName(filePath) → {string|null}
- Source:
- Since:
- 1.2.18
- See:
TODO_FUNC_DESC
Example
console.log(utilities.getFileName("C:\settings.ini")); // "settings.ini"
console.log(utilities.getFileName("/var/tmp/test.txt")); // "test.txt"
console.log(utilities.getFileName("MyApp.wgt")); // "MyApp.wgt"
console.log(utilities.getFileName(NaN)); // null
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string | A file path string to extract the file name from. |
Returns:
Returns a string value containing the name of the file or null if the file path was not a string.
- Type
- string | null
(static) getFileNameNoExtension(fileName) → {string|null}
- Source:
- Since:
- 1.2.18
- See:
TODO_FUNC_DESC
Example
console.log(utilities.getFileNameNoExtension("data.bin")); // "data"
console.log(utilities.getFileNameNoExtension("something")); // "something"
console.log(utilities.getFileNameNoExtension("C:\\games\\z\\z.sh")); // "z"
console.log(utilities.getFileNameNoExtension("/data/db")); // "db"
console.log(utilities.getFileNameNoExtension("E:\\some_directory\\")); // ""
console.log(utilities.getFileNameNoExtension("")); // ""
console.log(utilities.getFileNameNoExtension({ })); // null
Parameters:
Name | Type | Description |
---|---|---|
fileName |
string | A file name or path string to extract the file name with no extension from. |
Returns:
Returns a string value containing the name of the file with no extension or null if the file name or path was not a string.
- Type
- string | null
(static) getFilePath(filePath) → {string|null}
- Source:
- Since:
- 1.2.18
- See:
TODO_FUNC_DESC
Example
console.log(utilities.getFilePath()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string | A file path string to extract the base path from. |
Returns:
Returns a string value containing the base path of the specified file path or null if the file path was not a string.
- Type
- string | null
(static) hiddenElements(elements) → {Array.<Object>}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use Array.filter() instead. Will be removed in a future release.
- See:
TODO_FUNC_DESC
Example
console.log(utilities.hiddenElements()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
elements |
Array.<Object> | TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<Object>
(static) indentText(value, amountopt, indentationopt, clearEmptyLinesopt) → {string|null}
- Source:
- Since:
- 1.0.0
TODO_FUNC_DESC
Example
console.log(utilities.indentText()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string to indent. |
||
amount |
number |
<optional> |
1
|
The amount of times to indent the string. |
indentation |
indentation |
<optional> |
"\t"
|
The indentation string to use. |
clearEmptyLines |
boolean |
<optional> |
true
|
Determines if empty lines should be trimmed or not. |
Returns:
TODO_RETURN_DESC
- Type
- string | null
(static) isBoolean(value, allowObjectsopt) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is a boolean.
Example
console.log(utilities.isBoolean(false)); // true
console.log(utilities.isBoolean(8675309)); // false
console.log(utilities.isBoolean(new Boolean(true))); // false
console.log(utilities.isBoolean(new Boolean(false), true)); // true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to check. |
||
allowObjects |
boolean |
<optional> |
false
|
Will allow Boolean objects to be treated as valid values. |
Returns:
A value of true if the specified value is a boolean, otherwise false.
- Type
- boolean
(static) isComment(value, commentopt) → {boolean}
- Source:
- Since:
- 1.0.0
Checks if a specified string value starts with the corresponding comment notation. Any whitespace characters at the start of the string will be ignored. Empty and non-string values will always result in a value of false being returned.
Example
console.log(utilities.isComment("// test comment, please ignore")); // true
console.log(utilities.isComment("# another comment")); // false
console.log(utilities.isComment("# valid comment", "#")); // true
console.log(utilities.isComment("some text")); // false
console.log(utilities.isComment("")); // false
console.log(utilities.isComment(null)); // false
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The value to check. |
||
comment |
string |
<optional> |
"//"
|
The comment notation string, can be one or more characters. |
Returns:
A value of true if the specified value is a string and begins with the corresponding comment notation.
- Type
- boolean
(static) isDate(value) → {boolean}
- Source:
- Since:
- 1.1.1
- See:
Checks if the specified value is an instance of the Date object.
Example
console.log(utilities.isDate(new Date())); // true
console.log(utilities.isDate("June 18")); // false
console.log(utilities.isDate(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is a Date object instance, otherwise false for any other value.
- Type
- boolean
(static) isDisabled(element) → {boolean}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Determined to no longer be useful, will be removed in a future release.
- See:
Checks if an object is disabled or not. A value which is not an object is considered to be disabled. A property named disabled with a boolean value of true or function returning true is considered to be disabled. If there is no property named disabled, but a property named disabled is present with a boolean value of false or function returning false, the object is considered to be disabled. If the value does not contain either a enabled or disabled property, it is not considered to be disabled.
Example
console.log(utilities.isDisabled({ disabled: true })); // true
console.log(utilities.isDisabled({ disabled: function() { return true; } })); // true
console.log(utilities.isDisabled({ enabled: false })); // true
console.log(utilities.isDisabled({ enabled: function() { return false; } })); // true
console.log(utilities.isDisabled({ })); // false
console.log(utilities.isDisabled(null)); // true
Parameters:
Name | Type | Description |
---|---|---|
element |
object | The element to check. |
Returns:
Returns a value of true if the object is determined to be disabled.
- Type
- boolean
(static) isEmptyArray(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is an array and contains no items. Values which are not arrays will always result in a value of false.
Example
console.log(utilities.isEmptyArray([])); // true
console.log(utilities.isEmptyArray(new Array())); // true
console.log(utilities.isEmptyArray([null])); // false
console.log(utilities.isEmptyArray({ })); // false
console.log(utilities.isEmptyArray(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value if true if the specified value is an array and does not contain any items, otherwise false for any other value.
- Type
- boolean
(static) isEmptyObject(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is an object and does not contain any enumerable properties. Values which are not strict objects regardless of how many enumerable properties they have will always result in a value of false.
Example
console.log(utilities.isEmptyObject({ })); // true
console.log(utilities.isEmptyObject(new Object())); // true
console.log(utilities.isEmptyObject({ example: "data" })); // false
console.log(utilities.isEmptyObject(new Map())); // false
console.log(utilities.isEmptyObject(new Error())); // false
console.log(utilities.isEmptyObject(function() { })); // false
console.log(utilities.isEmptyObject(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is a strict object with no enumerable properties, otherwise false for any other value.
- Type
- boolean
(static) isEmptyString(value, trimopt) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is an empty string. By default this will also trim strings and consider values which only contain whitespace, as well as non-string values to also be empty strings.
Example
console.log(utilities.isEmptyString("")); // true
console.log(utilities.isEmptyString("\t")); // true
console.log(utilities.isEmptyString("Door stuck!")); // false
console.log(utilities.isEmptyString(" ", false)); // false
console.log(utilities.isEmptyString(null)); // true
console.log(utilities.isEmptyString([])); // true
console.log(utilities.isEmptyString(NaN)); // true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to check. |
||
trim |
boolean |
<optional> |
true
|
Determines if the value should be trimmed before checking if it is empty. |
Returns:
A value of true if the specified value is not a string, or is a string and is empty or only contains whitespace characters if trim is set to true.
- Type
- boolean
(static) isEnabled(element) → {boolean}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Determined to no longer be useful, will be removed in a future release.
- See:
Checks if an object is enabled or not. A value which is not an object is not considered to be enabled. A property named enabled with a boolean value of true or function returning true is considered to be enabled. If there is no property named enabled, but a property named disabled is present with a boolean value of false or function returning false, the object is considered to be enabled. If the value does not contain either a enabled or disabled property, it is considered to be enabled.
Example
console.log(utilities.isEnabled({ enabled: true })); // true
console.log(utilities.isEnabled({ enabled: function() { return true; } })); // true
console.log(utilities.isEnabled({ disabled: false })); // true
console.log(utilities.isEnabled({ disabled: function() { return false; } })); // true
console.log(utilities.isEnabled({ })); // false
console.log(utilities.isEnabled(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
element |
object | The element to check. |
Returns:
Returns a value of true if the object is determined to be enabled.
- Type
- boolean
(static) isError(value) → {boolean}
- Source:
- Since:
- 1.2.2
Checks if the specified value is an instance of the Error object.
Example
console.log(utilities.isError(new Error("Oops."))); // true
console.log(utilities.isError(new SyntaxError("Unknown!"))); // true
console.log(utilities.isError(new DOMException("System failure.", "AbortError"))); // true
console.log(utilities.isError({ message: "fake" })); // false
console.log(utilities.isError(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is an Error object instance, otherwise false for any other value.
- Type
- boolean
(static) isFloat(value, allowObjectsopt) → {boolean}
- Source:
- Since:
- 1.3.7
- See:
Checks if the specified value is a floating point number either represented in a number type, string type or optionally a Number object. Integer values are also considered to be floating point numbers.
Example
console.log(utilities.isInteger(7)); // true
console.log(utilities.isInteger(133.7)); // true
console.log(utilities.isInteger("420")); // true
console.log(utilities.isInteger("6.9")); // true
console.log(utilities.isInteger(new Number(64))); // true
console.log(utilities.isInteger(new Number(3.2))); // true
console.log(utilities.isInteger(null)); // false
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to check. |
||
allowObjects |
boolean |
<optional> |
true
|
Will allow Number objects to be treated as valid values. |
Returns:
A value of true if the specified value is a floating point number, otherwise false.
- Type
- boolean
(static) isFunction(value) → {boolean}
- Source:
- Since:
- 1.0.0
Checks if the specified value is an instance of the Function object.
Example
console.log(utilities.isFunction(function() { })); // true
console.log(utilities.isFunction(console.log)); // true
console.log(utilities.isFunction({ })); // false
console.log(utilities.isFunction({ })); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is a Function object instance, otherwise false for any other value.
- Type
- boolean
(static) isHidden(element) → {boolean}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Determined to no longer be useful, will be removed in a future release.
- See:
Checks if an object is hidden or not. A value which is not an object is considered to be hidden. A property named hidden with a boolean value of true or function returning true is considered to be hidden. If there is no property named hidden, but a property named hidden is present with a boolean value of false or function returning false, the object is considered to be hidden. If the value does not contain either a visible or hidden property, it is not considered to be hidden.
Example
console.log(utilities.isHidden({ hidden: true })); // true
console.log(utilities.isHidden({ hidden: function() { return true; } })); // true
console.log(utilities.isHidden({ visible: false })); // true
console.log(utilities.isHidden({ visible: function() { return false; } })); // true
console.log(utilities.isHidden({ })); // false
console.log(utilities.isHidden(null)); // true
Parameters:
Name | Type | Description |
---|---|---|
element |
object | The element to check. |
Returns:
Returns a value of true if the object is determined to be hidden.
- Type
- boolean
(static) isInteger(value, allowObjectsopt) → {boolean}
- Source:
- Since:
- 1.3.7
- See:
Checks if the specified value is an integer either represented in a number type, string type or optionally a Number object.
Example
console.log(utilities.isInteger(7)); // true
console.log(utilities.isInteger(133.7)); // false
console.log(utilities.isInteger("420")); // true
console.log(utilities.isInteger("6.9")); // false
console.log(utilities.isInteger(new Number(64))); // true
console.log(utilities.isInteger(new Number(3.2))); // false
console.log(utilities.isInteger(null)); // false
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to check. |
||
allowObjects |
boolean |
<optional> |
true
|
Will allow Number objects to be treated as valid values. |
Returns:
A value of true if the specified value is an integer, otherwise false.
- Type
- boolean
(static) isInvalid(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is null or undefined.
Example
console.log(utilities.isInvalid(69)); // false
console.log(utilities.isInvalid(undefined)); // true
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is null or undefined, otherwise false.
- Type
- boolean
(static) isInvalidNumber(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is not a valid number. Values of NaN, +/- Infinity and Number objects are also not considered to be valid numbers.
Example
console.log(utilities.isInvalidNumber(7331)); // false
console.log(utilities.isInvalidNumber(-2.718281828459045)); // false
console.log(utilities.isInvalidNumber("7")); // true
console.log(utilities.isInvalidNumber(new Number(65534))); // true
console.log(utilities.isInvalidNumber(NaN)); // true
console.log(utilities.isInvalidNumber(Infinity)); // true
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is not a valid number, otherwise false.
- Type
- boolean
(static) isNonEmptyArray(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is an array and contains at least one item. Values which are not arrays will always result in a value of false.
Example
console.log(utilities.isEmptyArray([])); // false
console.log(utilities.isEmptyArray(new Array())); // false
console.log(utilities.isEmptyArray([null])); // true
console.log(utilities.isEmptyArray([4, 2, 0])); // true
console.log(utilities.isEmptyArray({ })); // false
console.log(utilities.isEmptyArray(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value if true if the specified value is an array and contains at least one item, otherwise false for any other value.
- Type
- boolean
(static) isNonEmptyObject(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is an object and contains at least one enumerable property. Values which are not strict objects regardless of how many properties they have will always result in a value of false.
Example
console.log(utilities.isEmptyObject({ })); // false
console.log(utilities.isEmptyObject(new Object())); // false
console.log(utilities.isEmptyObject({ example: "data" })); // true
console.log(utilities.isEmptyObject(new Map())); // false
console.log(utilities.isEmptyObject(new Error())); // false
console.log(utilities.isEmptyObject(function() { })); // false
console.log(utilities.isEmptyObject(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is a strict object with at least one enumerable property, otherwise false for any other value or strict object with no enumerable properties.
- Type
- boolean
(static) isNonEmptyString(value, trimopt) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is a non-empty string. By default this will also trim strings and consider values which only contain whitespace to be empty strings.
Example
console.log(utilities.isNonEmptyString("")); // false
console.log(utilities.isNonEmptyString("\t")); // false
console.log(utilities.isNonEmptyString("Door stuck!")); // true
console.log(utilities.isNonEmptyString(" ", false)); // true
console.log(utilities.isNonEmptyString(null)); // false
console.log(utilities.isNonEmptyString([])); // false
console.log(utilities.isNonEmptyString(NaN)); // false
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to check. |
||
trim |
boolean |
<optional> |
true
|
Determines if the value should be trimmed before checking if it is not empty. |
Returns:
A value of false if the specified value is not a string, or is a string and is empty or only contains whitespace characters if trim is set to true.
- Type
- boolean
(static) isObject(value, strictopt) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is an object. Functions and values of null are not considered to be real objects. Any object which inherits from object will yield a result of true unless strict is set to true.
Example
console.log(utilities.isObject({ please: "ignore" })); // true
console.log(utilities.isObject(new Object())); // true
console.log(utilities.isObject([1, 2, 3])); // true
console.log(utilities.isObject(new Date())); // true
console.log(utilities.isObject(new Date(), true)); // false
console.log(utilities.isObject(function() { })); // false
console.log(utilities.isObject(null)); // false
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to check. |
||
strict |
boolean |
<optional> |
false
|
Only consider values which have Object for a constructor as objects when checking the value. |
Returns:
A value of true if the specified value is an object, otherwise false if it inhertis from object and strict is set to true, or it is any other value type.
- Type
- boolean
(static) isObjectStrict(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is a strict object by checking that the value's constructor is Object. Functions and values of null are not considered to be strict objects. Any object which inherits from object will yield a result of false.
Example
console.log(utilities.isObjectStrict({ foo: "bar" })); // true
console.log(utilities.isObjectStrict(new Object())); // true
console.log(utilities.isObjectStrict(["a", "b", "c"])); // false
console.log(utilities.isObjectStrict(new Error("?"))); // false
console.log(utilities.isObjectStrict(function() { })); // false
console.log(utilities.isObjectStrict(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is an object and has Object for a constructor, otherwise false for any other value.
- Type
- boolean
(static) isRegularExpression(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks if the specified value is an instance of the RegExp object.
Example
console.log(utilities.isRegularExpression(/te|st/gmi)); // true
console.log(utilities.isRegularExpression(new RegExp("https?"))); // true
console.log(utilities.isRegularExpression("/hi/")); // false
console.log(utilities.isRegularExpression({ }})); // false
console.log(utilities.isRegularExpression(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is a RegExp object instance, otherwise false for any other value.
- Type
- boolean
(static) isValid(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks that the specified value is not null or undefined.
Example
console.log(utilities.isValid(42)); // true
console.log(utilities.isValid(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is not null or undefined, otherwise false.
- Type
- boolean
(static) isValidNumber(value) → {boolean}
- Source:
- Since:
- 1.0.0
- See:
Checks that that the specified value is a valid number. Values of NaN, +/- Infinity and Number objects are not considered to be valid numbers.
Example
console.log(utilities.isValidNumber(1337)); // true
console.log(utilities.isValidNumber(-3.141592654)); // true
console.log(utilities.isValidNumber("32767")); // false
console.log(utilities.isValidNumber(new Number(65534))); // false
console.log(utilities.isValidNumber(NaN)); // false
console.log(utilities.isValidNumber(-Infinity)); // false
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to check. |
Returns:
A value of true if the specified value is a valid number, otherwise false.
- Type
- boolean
(static) isVisible(element) → {boolean}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Determined to no longer be useful, will be removed in a future release.
- See:
Checks if an object is visible or not. A value which is not an object is not considered to be visible. A property named visible with a boolean value of true or function returning true is considered to be visible. If there is no property named visible, but a property named hidden is present with a boolean value of false or function returning false, the object is considered to be visible. If the value does not contain either a visible or hidden property, it is considered to be visible.
Example
console.log(utilities.isVisible({ visible: true })); // true
console.log(utilities.isVisible({ visible: function() { return true; } })); // true
console.log(utilities.isVisible({ hidden: false })); // true
console.log(utilities.isVisible({ hidden: function() { return false; } })); // true
console.log(utilities.isVisible({ })); // false
console.log(utilities.isVisible(null)); // false
Parameters:
Name | Type | Description |
---|---|---|
element |
object | The element to check. |
Returns:
Returns a value of true if the object is determined to be visible.
- Type
- boolean
(static) joinPaths(paths, optionsopt) → {string}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.joinPaths()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
paths |
string | Array.<string> | TODO_ARG_DESC. |
|
options |
Object |
<optional> |
TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- string
(static) leftShift(number, bits) → {number}
- Source:
- Since:
- 1.2.19
- See:
TODO_FUNC_DESC
Example
console.log(utilities.leftShift()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
number |
number | The number value to bit shift. |
bits |
number | The number of bits to shift the value left by. |
Returns:
The number value right shifted by the specified number of bits.
- Type
- number
(static) matchAttribute(element, attribute, value) → {boolean}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use Array.filter() instead. Will be removed in a future release.
TODO_FUNC_DESC
Example
console.log(utilities.matchAttribute()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
element |
Object | TODO_ARG_DESC. |
attribute |
string | TODO_ARG_DESC. |
value |
any | TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- boolean
(static) merge(a, b, copyopt, deepMergeopt) → {Object|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.merge({ a: 1 }, { b: 2 })); // { a: 1, b: 2 }
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
a |
Object | The object to merge into. |
||
b |
Object | The object whose properties are being merged. |
||
copy |
boolean |
<optional> |
true
|
Determines if a copy of the first object should be made before merging. |
deepMerge |
boolean |
<optional> |
true
|
Determines if properties should be recursively merged or just the base properties. |
Returns:
TODO_RETURN_DESC
- Type
- Object | null
(static) parseBoolean(value, defaultValueopt) → {boolean|null}
- Source:
- Since:
- 1.0.0
- See:
Parses a boolean from a given value. If no valid boolean value can be determined, defaultValue is returned instead which by default has a value of null. There are many possibilities for valid truthy boolean values including:
- true
- new Boolean(true)
- 1
- "1"
- "true"
- "yes"
- "on"
- "t"
- "y"
As well as a number of possibilities for valid falsey boolean values:
- false
- new Boolean(false)
- 0
- "0"
- "false"
- "no"
- "off"
- "f"
- "n"
Example
console.log(utilities.parseBoolean(true)); // true
console.log(utilities.parseBoolean("false")); // false
console.log(utilities.parseBoolean("yes")); // true
console.log(utilities.parseBoolean(1)); // true
console.log(utilities.parseBoolean(4)); // null
console.log(utilities.parseBoolean("wat")); // null
console.log(utilities.parseBoolean("wot", true)); // true
console.log(utilities.parseBoolean("huh", 420)); // null
console.log(utilities.parseBoolean(null)); // null
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to parse into a boolean. |
||
defaultValue |
boolean | null |
<optional> |
null
|
The value to return if no valid boolean value can be determined. Specifying a non-boolean value will result in null being used instead. |
Returns:
A value of true if a valid truthy value was determined from the specified value, false if a valid falsey value was determined, otherwise the default value is returned. A value of null will be returned if the default value is not specified.
- Type
- boolean | null
(static) parseDate(value, defaultValueopt) → {Date|null}
- Source:
- Since:
- 1.0.0
- See:
Parses a date object from a given value. Accepts date object, date string, timestamp number string and timestamp number values. If no valid date object can be determined from the specified value, the default value is returned instead.
Example
console.log(utilities.parseDate("June 18, 1987 3:30 PM")); // new Date("1987-06-18T19:30:00.000Z")
console.log(utilities.parseDate("2018-02-19T06:19:33Z")); // new Date("2018-02-19T06:19:33.000Z")
console.log(utilities.parseDate(new Date("2020-03-28T18:52:05.136Z"))); // new Date("2020-03-28T18:52:05.136Z")
console.log(utilities.parseDate(1585421525139)); // new Date("2020-03-28T18:52:05.136Z")
console.log(utilities.parseDate("1585421525139")); // new Date("2020-03-28T18:52:05.136Z")
console.log(utilities.parseDate(-1, new Date(0))); // new Date("1970-01-01T00:00:00.000Z")
console.log(utilities.parseDate(-420)); // null
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to parse into a date object. |
||
defaultValue |
Date | null |
<optional> |
null
|
The default value to return if the specified value is not a valid date or timestamp. |
Returns:
A Date object instance if a valid date was determined from the specified value, otherwise the default value is returned. A value of null will be returned if the default value is not specified.
- Type
- Date | null
(static) parseEmail(value) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
Parses an email address from a string by removing any text in the username after and including that which starts with '+' up to the '@' character and returns it. This is intended to determine the actual e-mail address since some providers allow you to place any text after a '+' character and have it be routed to the same email address.
Example
console.log(utilities.parseEmail("name+test@gmail.com")); // "name@gmail.com"
console.log(utilities.parseEmail("hello@email.com")); // "hello@email.com"
console.log(utilities.parseEmail("technovore")); // null
console.log(utilities.parseEmail(NaN)); // null
Parameters:
Name | Type | Description |
---|---|---|
value |
string | A string containing an email address. |
Returns:
Will return the e-mail address without any embedded text or null if the email address is not valid.
- Type
- string | null
(static) parseEmailDomain(value) → {string|null}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use value.split("@", 2)[1] instead. Will be removed in a future release.
- See:
Parses the domain portion from an e-mail address and returns it.
Example
console.log(utilities.parseEmailDomain("spam@mail.net")); // "mail.net"
console.log(utilities.parseEmailDomain("get+out@lavabit.com")); // "lavabit.com"
console.log(utilities.parseEmailDomain("my.website")); // null
console.log(utilities.parseEmailDomain(-1)); // null
Parameters:
Name | Type | Description |
---|---|---|
value |
string | A string containing an email address. |
Returns:
The e-mail address domain or null if the value is not a valid e-mail address.
- Type
- string | null
(static) parseFloat(value, defaultValueopt) → {number}
- Source:
- Since:
- 1.3.7
- See:
Parses a floating point number from a given value. Accepts number, string and number object values. If no valid floating point number can be determined from the specified value, the default value is returned instead.
Example
console.log(utilities.parseFloat(-999)); // -999
console.log(utilities.parseFloat(13.37)); // 13.37
console.log(utilities.parseFloat("51")); // 51
console.log(utilities.parseFloat("-867.5309")); // -867.5309
console.log(utilities.parseFloat(new Number(-4231))); // -4231
console.log(utilities.parseFloat(new Number(9.999))); // 9.999
console.log(utilities.parseFloat("wat", 10010101); // 10010101
console.log(utilities.parseFloat(null); // NaN
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to parse into a floating point number. |
||
defaultValue |
number |
<optional> |
NaN
|
The default value to return if the specified value is not a floating point number. |
Returns:
A floating point number value if a valid number value was determined from the specified value, otherwise the default value is returned. A value of NaN will be returned if the default value is not specified.
- Type
- number
(static) parseFloatingPointNumber(value, defaultValueopt) → {number}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use utilities.parseFloat instead. Will be removed in a future release.
- See:
Parses a floating point number from a given value. Accepts number, string and number object values. If no valid floating point number can be determined from the specified value, the default value is returned instead.
Example
console.log(utilities.parseFloatingPointNumber(-1)); // -1
console.log(utilities.parseFloatingPointNumber(2.2)); // 1.1
console.log(utilities.parseFloatingPointNumber("3")); // 3
console.log(utilities.parseFloatingPointNumber("4.4")); // 4.4
console.log(utilities.parseFloatingPointNumber(new Number(-5))); // -5
console.log(utilities.parseFloatingPointNumber(new Number(6.6))); // 6.6
console.log(utilities.parseFloatingPointNumber("nope.avi", 69); // 69
console.log(utilities.parseFloatingPointNumber(null); // NaN
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to parse into a floating point number. |
||
defaultValue |
number |
<optional> |
NaN
|
The default value to return if the specified value is not a floating point number. |
Returns:
A floating point number value if a valid number value was determined from the specified value, otherwise the default value is returned. A value of NaN will be returned if the default value is not specified.
- Type
- number
(static) parseInteger(value, defaultValueopt) → {number}
- Source:
- Since:
- 1.0.0
- See:
Parses an integer number from a given value. Accepts number, string and number object values. If no valid integer number can be determined from the specified value, the default value is returned instead.
Example
console.log(utilities.parseInteger(88)); // 88
console.log(utilities.parseInteger(-73.31)); // -73
console.log(utilities.parseInteger("-15")); // -15
console.log(utilities.parseInteger("3.141592654")); // 3
console.log(utilities.parseInteger(new Number(4096))); // 4096
console.log(utilities.parseInteger(new Number(3.333))); // 3
console.log(utilities.parseInteger("wat", 11100101); // 11100101
console.log(utilities.parseInteger(null); // NaN
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
any | The value to parse into a integer number. |
||
defaultValue |
number |
<optional> |
NaN
|
The default value to return if the specified value is not an integer or floating point number. |
Returns:
An integer number value if a valid number value was determined from the specified value, otherwise the default value is returned. A value of NaN will be returned if the default value is not specified.
- Type
- number
(static) parseRegularExpression(value, throwErrorsopt) → {RegExp|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.parseRegularExpression("/(regexp?)/gi")); // new RegExp("(regexp?)", "gi")
console.log(utilities.parseRegularExpression(new RegExp("ok"))); // new RegExp("ok")
console.log(utilities.parseRegularExpression({ })); // null
console.log(utilities.parseRegularExpression(/invalid/x, true)); // throws Error
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string value to parse a regular expression from. |
||
throwErrors |
boolean |
<optional> |
false
|
Determines if errors should be thrown or not when invalid regular expression values are encountered. |
Throws:
Will optionally throw an error if the regular expression is invalid and throwErrors is set to true.
Returns:
Returns a RegExp object instance if a valid regular expression was parsed from the specified value or null if the value was invalid and throwErrors is unspecified or set to false.
- Type
- RegExp | null
(static) parseStringList(value) → {Array.<string>|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.parseStringList("w, a, t")); // ["w", "a", "t"]
console.log(utilities.parseStringList("ok")); // ["ok"]
console.log(utilities.parseStringList([])); // null
Parameters:
Name | Type | Description |
---|---|---|
value |
string | A comma or semicolon separated list of string values. |
Returns:
An array of strings as parsed from the specified string list or null if the specified value is not a string.
- Type
- Array.<string> | null
(static) parseTime(value) → {Object}
- Source:
- Since:
- 1.1.2
- See:
Parses a string representation of 12 or 24 hour time into an object with all of the components of the time value represented in both 12 and 24 hour time. The structure of this time object is as follows:
{
regular: {
raw: <string>, // a string representing the time in 12 hour format
hour: <number>, // the hour component of the time value
minutes: <number>, // the minute component of the time value
period: <string>, // will be "AM" if the time is prior to 12:00 in the afternoon, otherwise "PM"
morning: <boolean> // will be true if the time is prior to 12:00 in the afternoon
},
military: {
raw: <string>, // a string representing the time in 24 hour format
hour: <nubmer>, // the hour component of the time value
minutes: <number> // the minute component of the time value
}
}
Example
console.log(utilities.parseTime("6:19 PM")); // {"regular":{"raw": "6:19 PM","hour":6, "minutes":19,"period":"PM","morning":false},"military":{"raw":"1819","hour":18,"minutes":19}}
console.log(utilities.parseTime("04:20")); // {"regular":{"raw": "4:20 AM","hour":4, "minutes":20,"period":"AM","morning":true}, "military":{"raw":"0420","hour":4, "minutes":20}}
console.log(utilities.parseTime("22:33")); // {"regular":{"raw":"10:33 PM","hour":10,"minutes":33,"period":"PM","morning":false},"military":{"raw":"2233","hour":22,"minutes":33}}
console.log(utilities.parseTime("12:34 AM")); // {"regular":{"raw":"12:34 AM","hour":12,"minutes":34,"period":"AM","morning":true}, "military":{"raw":"0034","hour":0, "minutes":34}}
utilities.parseTime("13:37 AM"); // throws an Error
utilities.parseTime("28:64"); // throws an Error
utilities.parseTime(-1); // throws an Error
Parameters:
Name | Type | Description |
---|---|---|
value |
string | A string to parse the time from. |
Throws:
Will throw an error for any invalid time string.
Returns:
An object representation of the different components of the time string in both 12 and 24 hour time formats.
- Type
- Object
(static) parseVersion(value, trimTrailingZeroesopt) → {Array.<string>|null}
- Source:
- Since:
- 1.0.3
- See:
TODO_FUNC_DESC
Example
console.log(utilities.parseVersion()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | number | TODO_ARG_DESC. |
||
trimTrailingZeroes |
boolean |
<optional> |
false
|
TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<string> | null
(static) parseYouTubeLink(value) → {string|null}
- Source:
- Since:
- 1.0.0
TODO_FUNC_DESC
Example
console.log(utilities.parseYouTubeLink("http://youtube.com/v/OEEEy1dMceI")); // OEEEy1dMceI
console.log(utilities.parseYouTubeLink("https://www.youtube.com/watch?v=NUnwFHplBg4")); // NUnwFHplBg4
console.log(utilities.parseYouTubeLink("www.youtu.be/watch?v=Dkm8Hteeh6M")); // Dkm8Hteeh6M
console.log(utilities.parseYouTubeLink("https://youtu.be/v/z874bjpO9d8")); // z874bjpO9d8
console.log(utilities.parseYouTubeLink("https://www.nitro404.com")); // null
console.log(utilities.parseYouTubeLink(NaN)); // null
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The string URL value to parse a YouTube video identifier from. |
Returns:
A string value containing the YouTube video ID or null if the video ID could be determined from the specified value.
- Type
- string | null
(static) prependSlash(value, forwardSlashopt) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.prependSlash()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string to prepend a forward or back slash onto. |
||
forwardSlash |
boolean |
<optional> |
true
|
Determines if a forward or back slash should be prepended. |
Returns:
The original string with a forward or back slash prepended to it if there isn't already a forward or back slash at the start or null if the specified value is not a string.
- Type
- string | null
(static) replaceNonBreakingSpaces(value) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.replaceNonBreakingSpaces()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The string to replace non breaking spaces in. |
Returns:
TODO_RETURN_DESC
- Type
- string | null
(static) reverseFileExtension(fileName) → {string|null}
- Source:
- Since:
- 1.2.18
- See:
TODO_FUNC_DESC
Example
console.log(utilities.reverseFileExtension("duke3d.grp")); // "duke3d.prg"
console.log(utilities.reverseFileExtension("F:\\data.json")); // "F:\\data.nosj"
console.log(utilities.reverseFileExtension("/home/downloads/")); // "/home/downloads/"
console.log(utilities.reverseFileExtension("X:\\secrets")); // "X:\\secrets"
console.log(utilities.reverseFileExtension("unknown")); // "unknown"
console.log(utilities.reverseFileExtension(Infinity)); // null
Parameters:
Name | Type | Description |
---|---|---|
fileName |
string | A file name or path string to reverse the file extension of. |
Returns:
Returns a string value containing the original file name or path with the extension reversed or null if the file name or path was not a string.
- Type
- string | null
(static) reverseString(value) → {string|null}
- Source:
- Since:
- 1.0.0
Reverses a string value with special handling for unicode characters.
Example
console.log(utilities.reverseString("backwards")); // "sdrawkcab"
console.log(utilities.reverseString(NaN)); // null
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The string value to reverse. |
Returns:
The reversed representation of the specified string value or a value of null if the specified value is not a string.
- Type
- string | null
(static) rightShift(number, bits) → {number}
- Source:
- Since:
- 1.2.19
- See:
TODO_FUNC_DESC
Example
console.log(utilities.rightShift()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
number |
number | The number value to bit shift. |
bits |
number | The number of bits to shift the value right by. |
Returns:
The number value right shifted by the specified number of bits.
- Type
- number
(static) toString(value) → {string}
- Source:
- Since:
- 1.0.0
TODO_FUNC_DESC
Example
console.log(utilities.toString(undefined)); // "undefined"
console.log(utilities.toString(null)); // "null"
console.log(utilities.toString(Infinity)); // "Infinity"
console.log(utilities.toString(-Infinity)); // "-Infinity"
console.log(utilities.toString(NaN)); // "NaN"
console.log(utilities.toString("test")); // "\"test\""
console.log(utilities.toString(new Date(0))); // "1970-01-01T00:00:00.000Z"
console.log(utilities.toString(function() { })); // "function() { }"
console.log(utilities.toString({ door: "stuck" })); // "{\"door":\"stuck\"}"
console.log(utilities.toString([4, 2, "0"])); // "[4,2,\"0\"]"
Parameters:
Name | Type | Description |
---|---|---|
value |
any | The value to convert into a string. |
Returns:
A string representation of the specified value.
- Type
- string
(static) trimLeadingZeroes(value) → {TODO_RETURN_TYPE}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.trimLeadingZeroes()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The string to remove leading zeroes from. |
Returns:
TODO_RETURN_DESC
- Type
- TODO_RETURN_TYPE
(static) trimNullTerminatedString(value, defaultValueopt) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.trimNullTerminatedString()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The null-terminated string to trim. |
||
defaultValue |
string | null |
<optional> |
null
|
The default value to return if the specified value is not a string. |
Returns:
TODO_RETURN_DESC
- Type
- string | null
(static) trimString(value, defaultValueopt) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.trimString()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string to trim. |
||
defaultValue |
string | null |
<optional> |
null
|
The default value to return if the specified value is not a string. |
Returns:
TODO_RETURN_DESC
- Type
- string | null
(static) trimTrailingNewlines(value, defaultValueopt) → {string|null}
- Source:
- Since:
- 1.1.5
- See:
TODO_FUNC_DESC
Example
console.log(utilities.trimTrailingNewlines()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string to trim trailing newline characters from. |
||
defaultValue |
string | null |
<optional> |
null
|
The default value to return if the specified value is not a string. |
Returns:
TODO_RETURN_DESC
- Type
- string | null
(static) trimWhitespace(value, trimNewlines, defaultValueopt) → {string|null}
- Source:
- Since:
- 1.0.0
- See:
TODO_FUNC_DESC
Example
console.log(utilities.trimWhitespace()); // TODO_RESULT
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
string | The string to trim whitespace characters from. |
||
trimNewlines |
boolean | TODO_ARG_DESC. |
||
defaultValue |
string | null |
<optional> |
null
|
The default value to return if the specified value is not a string. |
Returns:
TODO_RETURN_DESC
- Type
- string | null
(static) truncateFileName(fileName, maxLength) → {string|null}
- Source:
- Since:
- 1.2.18
- See:
TODO_FUNC_DESC
Example
console.log(utilities.truncateFileName()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
fileName |
string | A file name or path string to truncate. |
maxLength |
number | The maximum length of the file name. |
Returns:
The truncated file name or null if the file name is not a string.
- Type
- string | null
(static) visibleElements(elements) → {Array.<Object>}
- Source:
- Since:
- 1.0.0
- Deprecated:
- Use Array.filter() instead. Will be removed in a future release.
- See:
TODO_FUNC_DESC
Example
console.log(utilities.visibleElements()); // TODO_RESULT
Parameters:
Name | Type | Description |
---|---|---|
elements |
Array.<Object> | TODO_ARG_DESC. |
Returns:
TODO_RETURN_DESC
- Type
- Array.<Object>