Skip to content

GenericHelper.js

William edited this page Apr 27, 2024 · 4 revisions

GenericHelper

GenericHelper module

Author: William Leemans
Copyright: William Leemans 2024

GenericHelper.genericPropertyError ⇐ Error

Generic Property Error class

Kind: static class of GenericHelper
Extends: Error

new exports.genericPropertyError(moduleName, className, methodName, message, errorClassName)

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

GenericHelper.genericHelper

This Generic Helper class provides universal static methods

Kind: static class of GenericHelper

genericHelper.capitalize(value) ⇒ string

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

genericHelper.evalCheckMark(value, checked, unchecked) ⇒ string

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)

genericHelper.isRequiredArg(argName, functionName)

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

genericHelper.quantifyNumber(value) ⇒ string

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

genericHelper.shortOrdinal(number) ⇒ string

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

genericHelper.stripHTMLtag(html, tag, openTagReplace, closeTagReplace) ⇒ string

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

genericHelper.stripNestedHTMLtag(html, tag, childTag, openTagReplace, closeTagReplace) ⇒ string

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

genericHelper.unique(array) ⇒ array

Return an array with unique elements

Kind: static method of genericHelper

Param Type Description
array array the array to parse