Methods
(static) copyRegExp(expression, injectFlagsopt) → {RegExp}
Copies a regular expression and, if specified, inject extra flags.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
expression |
RegExp | The expression to copy. |
||
injectFlags |
string |
<optional> |
''
|
Extra flags to add to the new expression. For example 'ig'. |
Returns:
- Type
- RegExp
(static) ensureArray(target) → {Array.<T>}
Ensures a given value is wrapped on an array
.
Parameters:
Name | Type | Description |
---|---|---|
target |
T | Array.<T> | The target to validate and, if necessary, wrap. |
Returns:
- Type
- Array.<T>
(static) escapeForRegExp(text) → {string}
Escapes a string to be used on new RegExp(...)
.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The text to escape. |
Returns:
- Type
- string
(static) execRegExp(expression, text) → (nullable) {Array}
This is a simple wrapper for RegExp.exec
. The reason for this wrapper is that it
allows me to mock it on the tests and add support for named groups, something that is
not yet available on the target version this project is for.
Parameters:
Name | Type | Description |
---|---|---|
expression |
RegExp | The regular expression to execute. |
text |
string | The target text where the expression will be executed. |
Returns:
- Type
- Array
(static) getRandomString(length) → {string}
Generates a unique random string.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | The required length of the string. |
Returns:
- Type
- string
(static) isObject(target) → {boolean}
Checks whether a target is a literal object
or not.
Parameters:
Name | Type | Description |
---|---|---|
target |
* | The target to validate. |
Returns:
- Type
- boolean