Utilities for generating random or mock data.
Generates a random integer between min and max (inclusive).
number
:
A random integer between min and max.
Generates a random string of specified length using alphanumeric characters.
(number)
Length of the string.
string
:
A random alphanumeric string.
Generates a valid 9-digit Dutch BSN using elfproef. No retries or brute force.
string
:
Generates a random date between two dates.
Date
:
Random date between start and end.
Generates an array filled with random integers.
Array<number>
:
Array of random integers.
Creates a random string will have a random size between 5 and 10 characters. It uses getRandomString and getRndInt as auxiliary functions.
string
:
A string that simulates a word with 5 to 10 characters.
Creates a sentence with a given amount of words. It uses createWord as auxiliary functions. Each word is separated with a blank space.
(number)
The number of requested words.
string
:
A string that simulates a sentence with a given number of words.
Creates a random number of sentences with a given amount of words. It uses createSentence as auxiliary functions. Each word is separated with a blank space, while sentences are separated with a dot and blank space.
(number)
The number of requested words per sentence.
(number)
The number of requested sentences.
string
:
A string that simulates a word with 5 to 10 characters.
Creates a random document comprised of paragraphs. It uses createParagraph as auxiliary functions. Each paragraph is separated with a new line.
(number)
The number of requested sentences.
(number)
The number of requested words.
(number)
The number of requested paragraphs.
string
:
A string that simulates a word with 5 to 10 characters.
String utility functions including UTF-8 encoding/decoding.
Encodes a string into UTF-8.
(string)
The input string.
Uint8Array
:
The UTF-8 encoded byte array.
Decodes a UTF-8 encoded byte array back into a string.
(Uint8Array)
The UTF-8 byte array.
string
:
The decoded string.
Trims a string and returns an empty string if input is null or undefined.
string
:
A trimmed string or an empty string.
Capitalizes the first letter of a string.
(string)
The input string.
string
:
The capitalized string.
Date and time utility functions.
Converts a Unix timestamp (in seconds) to a JavaScript Date object.
(number)
The Unix timestamp in seconds.
Date
:
The corresponding JavaScript Date object.
Converts a JavaScript Date object to a Unix timestamp (in seconds).
(Date)
The JavaScript Date object.
number
:
The Unix timestamp in seconds.
Formats a date to a YYYY-MM-DD string.
string
:
The formatted date string.
Checks if dateA is before dateB.
boolean
:
True if dateA is before dateB.
Checks if dateA is after dateB.
boolean
:
True if dateA is after dateB.
Convert a native date to a object TWDate.
(date)
The number of requested words.
date
:
A TWDate with the same timestamp as the entry.
Adds a given amount of days into a given date.
(date)
The date where the days will be added.
(integer)
Amount of days to add to a date.
date
:
A date in where the amount of days were added.
Subtract a given amount of days from a given date.
(date)
The date where the days will be subtracted.
(integer)
Amount of days to add to a date.
date
:
A date in where the amount of days were subtracted.
Checks if the given date is smaller than the time it is when the function is executed plus the amount of days given as input. This makes sure that the date we have is smaller than 'days' in the future. This function is precise to milliseconds.
(date)
The date which will be compared to the future date.
(integer)
Amount of days in the future to where we will compare our date.
boolean
:
Returns true if the date given as input is sooner than the time this function ran plus the given amount of days as input.
Checks if the given date is smaller or equal than the time it is when the function is executed plus the amount of days given as input. This makes sure that the date we have is smaller or equal than 'days' in the future. This function is precise to milliseconds.
(date)
The date which will be compared to the future date.
(integer)
Amount of days in the future to where we will compare our date.
boolean
:
Returns true if the date given as input is sooner
or equal
than the time this function ran plus the given amount of days as input.
Checks if the given date is bigger than the time it is when the function is executed plus the amount of days given as input. This makes sure that the date we have is bigger than 'days' in the future. This function is precise to milliseconds.
(date)
The date which will be compared to the future date.
(integer)
Amount of days in the future to where we will compare our date.
boolean
:
Returns true if the date given as input is later than the time this function ran plus the given amount of days as input.
Checks if the given date is bigger or equal than the time it is when the function is executed plus the amount of days given as input. This makes sure that the date we have is bigger or equal than 'days' in the future. This function is precise to milliseconds.
(date)
The date which will be compared to the future date.
(integer)
Amount of days in the future to where we will compare our date.
boolean
:
Returns true if the date given as input is later or equal than the time this function ran plus the given amount of days as input.
Checks if the given date is equal than the time it is when the function is executed plus the amount of days given as input. This makes sure that the date we have is equal than 'days' in the future. This function is precise to milliseconds.
(date)
The date which will be compared to the future date.
(integer)
Amount of days in the future to where we will compare our date.
boolean
:
Returns true if the date given as input is equal than the time this function ran plus the given amount of days as input.
Checks if the amount of time between two dates is less that the limit we define. This function ignores time, making calculations only regarding days.
(date)
The date which is newest.
(date)
The date which is oldest.
(integer)
Number of days which the two dates can't be bigger.
boolean
:
Returns true if the amount of time between the two dates is less that our limit of days.
Calculates the difference of days between two dates. Ignores time.
(date)
The first date to compare, must be the bigger date or else the result will be negative.
(date)
The second date to compare, must be the smaller date or else the result will be negative.
integer
:
Returns the amount of days that separate the two dates.
Calculates the next business date after a given amount of days to wait.
(date)
The original date where we will base our calculations.
(integer)
Amount of days in the future we need.
(string)
The timeSchedule is the business hours our application uses.
(string)
The days of the calendar that are not business days.
(string)
The timezone where the application is working.
date
:
Returns what is the business day we need according to the business calendar and the amount of days in the future we want.
Adds mandatory prefixes to custom message. It prepends triple-angle-bracket marker ('>>>') then caller application acronym and then caller service (or process-level inline JS script) where this JS runs inside. Example. When application 'ABC' logs from 'Heavy Crunching' service a message 'some message', then following string is written to log file: '>>> [ABC][Heavy Crunching]: some message'
(String)
target message
any
:
message with mandatory prefixes.
Retrieves loghelper function caller name.
any
:
Process step or service name.
Retrieves runtime context details like process instance ID, task ID and user ID. Retrieved data is formatted using "UWVLog_contextTemplate" environment variable replacing specific placeholders: {pid}, {tid} or {uid}. If template string is empty returned context is empty.
any
:
Runtime context data formatted as string.
Formats message with extra parameters. Curly-braced placeholders in message are replaced with further arguments of function. Unmatched placeholders are filled with 'undefined'.
(String)
message template with placeholders in curly braces.
String
:
formatted message with replaced placeholders.
Navigates object to get nested attribute value, or subobject, using dot-notation. Other JS navigation syntax (square brackets etc) is not supported. Undefined value is returned for non-existent path or wrong syntax. Example:
This will log a message in info level if info is enabled on websphere.
This will log a message in debug level if debug is enabled on websphere.
This will log a message in error level.
This will log a message in warn level.
Validation utilities for strings, numbers, arrays, dates, and objects.
Checks if a value is a non-empty string.
(any)
The value to validate.
boolean
:
True if the value is a non-empty string.
Checks if a value is undefined, null, or the strings "undefined" / "null".
(any)
The value to validate.
boolean
:
True if the value is considered invalid.
Checks if a value is a valid non-empty string.
(any)
The value to validate.
boolean
:
True if the value is a valid non-empty string.
Checks if a value is a finite number.
(any)
The value to validate.
boolean
:
True if the value is a valid number.
Checks if a value is an array with at least one item.
(any)
The value to validate.
boolean
:
True if the value is a non-empty array.
Checks if a value is a valid Date object or parseable date string.
(any)
The value to validate.
boolean
:
True if the value is a valid date.
Checks if a given date is in the future.
boolean
:
True if the date is in the future.
Checks if a given date is in the past.
boolean
:
True if the date is in the past.
Validates that an object contains all specified required fields.
boolean
:
True if all required fields exist and are not null/undefined.
Recursively compares two objects and returns an object indicating key-wise equality.
Object
:
Object with boolean values for each key indicating equality.
Checks if a string is initialized and is different than a empty string.
(ANY)
The value to be checked if it's a string .
boolean
:
Returns true if the input is initialized and has as a value a string different than "".
Checks if the source is a BSN. The algorithm to check if a string is a valid BSN is (9xA)+(8xB)+(7xC)+(6xD)+(5xE)+(4xF)+(3xG)+(2xH)+(-1xI) and then divide everything by 11, if the integer division returns 0 it's valid.
(string)
The BSN to be validated.
boolean
:
Returns true if the source is a valid BSN.
Checks if a string is matched by a regex.
(RegEx)
The regular expression to test a string.
(string)
The string to be tested.
boolean
:
Returns true if the regex matches the whole string
Checks if the length of a string is between a given interval.
(string)
The string to be tested.
(integer)
The minimum amount of character the string can have.
(integer)
The maximum amount of character the string can have.
boolean
:
Returns true if the length of the source if between max and min characters.