-
-
Notifications
You must be signed in to change notification settings - Fork 1
GenericHelper.js
GenericHelper module
Author: William Leemans
Copyright: William Leemans 2024
-
GenericHelper
-
.genericPropertyError ⇐
Error
-
.genericHelper
-
.capitalize(value) ⇒
string
-
.evalCheckMark(value, checked, unchecked) ⇒
string
- .isRequiredArg(argName, functionName)
-
.quantifyNumber(value) ⇒
string
-
.shortOrdinal(number) ⇒
string
-
.stripHTMLtag(html, tag, openTagReplace, closeTagReplace) ⇒
string
-
.stripNestedHTMLtag(html, tag, childTag, openTagReplace, closeTagReplace) ⇒
string
-
.unique(array) ⇒
array
-
.capitalize(value) ⇒
-
.genericPropertyError ⇐
Generic Property Error class
Kind: static class of GenericHelper
Extends: Error
Param | Type | Description |
---|---|---|
moduleName | string |
the name of the module the error has occurred in |
className | string |
the name of the class the error has occurred in |
methodName | string |
the name of the method the error has occurred in |
message | string |
the error message |
errorClassName | string |
the name of the error class |
This Generic Helper class provides universal static methods
Kind: static class of GenericHelper
-
.genericHelper
-
.capitalize(value) ⇒
string
-
.evalCheckMark(value, checked, unchecked) ⇒
string
- .isRequiredArg(argName, functionName)
-
.quantifyNumber(value) ⇒
string
-
.shortOrdinal(number) ⇒
string
-
.stripHTMLtag(html, tag, openTagReplace, closeTagReplace) ⇒
string
-
.stripNestedHTMLtag(html, tag, childTag, openTagReplace, closeTagReplace) ⇒
string
-
.unique(array) ⇒
array
-
.capitalize(value) ⇒
a helper function to capitalize a given string
Kind: static method of genericHelper
Returns: string
- Returns a capitalized string.
Param | Type | Description |
---|---|---|
value | string |
String to capitalize |
Return a checkmark based on the outcome of the provided logical value
Kind: static method of genericHelper
Param | Type | Default | Description |
---|---|---|---|
value | boolean |
the value to evaulate | |
checked | string |
"x" |
character to use when checked (default: x) |
unchecked | string |
character to use when unchecked (default: empty string) |
a fallback method for missing method arguments
Kind: static method of genericHelper
Throws:
Error
Param | Type | Description |
---|---|---|
argName | string |
the name of the argument |
functionName | string |
the name of the function |
convert the given number to a string and add a + sign if it is positive or 0.
Kind: static method of genericHelper
Returns: string
- Returns a string where the number is correctly prefixed with + or -
Param | Type | Description |
---|---|---|
value | number |
The number to quantify |
Return the short ordinal of the provided number
Kind: static method of genericHelper
Returns: string
- Returns a short ordinal of the given number
Param | Type | Description |
---|---|---|
number | number |
a number |
Strip html tags from text, possibly replacing opening and/or closing tags
Kind: static method of genericHelper
Returns: string
- the stripped html text
Param | Type | Description |
---|---|---|
html | string |
the HTML code to strip |
tag | string |
the name of the tag to strip |
openTagReplace | string |
the value to use to replace the opening tag with |
closeTagReplace | string |
the value to use to replace the closing tag with |
Strip html tags from html elements based on the parent element tag
Kind: static method of genericHelper
Returns: string
- the stripped html text
Param | Type | Description |
---|---|---|
html | string |
the HTML code to strip |
tag | string |
the name of the parent tag to strip child tags |
childTag | string |
the name of the child tag to strip |
openTagReplace | string |
the value to use to replace the opening tag with |
closeTagReplace | string |
the value to use to replace the closing tag with |
Return an array with unique elements
Kind: static method of genericHelper
Param | Type | Description |
---|---|---|
array | array |
the array to parse |