Constructor
new Converter(replacementsopt)
- Source:
Create a new Converter based on a set of replacement rules.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
replacements |
Array |
<optional> |
DEFAULT_REPLACEMENTS
|
the list with replacement rules. Each rule consists of two Strings: the original string with ASCII symbols and the unicode replacement symbol. |
Methods
rule(original, replacement)
- Source:
Add a new replacement rule.
Parameters:
Name | Type | Description |
---|---|---|
original |
String | a string of ASCII sybols |
replacement |
String | the unicode replacement symbol |
Throws:
-
-
The original string cannot be empty.
- Type
- Error
-
-
-
The replacement symbol should exactly be 1 character.
- Type
- Error
-
run(input) → {String}
- Source:
Run all replacement rules of this Converter on the input string.
Parameters:
Name | Type | Description |
---|---|---|
input |
String | the string to convert |
Returns:
the input string with all replacement rules applied
- Type
- String