prefix()

Always ensures that a string starts with a specific substring.

This function is valid in v2.0.0 to v2.24.3. This function has been downloaded 60 times.

Parameters

{string|undefined|null} str
This will be the string to which the prefix will be prepended unless the test proves that it doesn't need to be prepended. Specifying undefined or null will cause a partial function to be returned.
{string} strPrefix
This will be the prefix to add to str if it needs to be added.
{RegExp=} opt_rgxTester Optional
Regular expression to test against the string to be prefixed. If the string tests negative against this regular expression strPrefix will be prepended to the beginning of it.

Returns

{string|function(string)}
If str is not given a partial function will be returned which will await the string value of str. If opt_rgxTester isn't given, the str will be returned and it will be prefixed with strPrefix if it isn't already at the beginning of it. If opt_rgxTester is given and str tests negative against it str prefixed with strPrefix will be returned. Otherwise str will be returned.