* Creates a mixed alphabet by extending this chain by the given one. * @param {number[]|string|Uint8Array|Chain} alphabet Alphabet the target * should be extended by. * @return {Chain} Mixed alphabet
(alphabet)
| 221 | * @return {Chain} Mixed alphabet |
| 222 | */ |
| 223 | extend (alphabet) { |
| 224 | const key = this.getCodePoints() |
| 225 | const codePoints = Chain.wrap(alphabet).getCodePoints() |
| 226 | const mixedAlphabet = key.slice() |
| 227 | let element |
| 228 | let i = 0 |
| 229 | while (mixedAlphabet.length < codePoints.length && i < codePoints.length) { |
| 230 | element = codePoints[i++] |
| 231 | if (key.indexOf(element) === -1) { |
| 232 | mixedAlphabet.push(element) |
| 233 | } |
| 234 | } |
| 235 | return Chain.wrap(mixedAlphabet) |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Retrieves the matches when matching a string against a regular expression. |
no test coverage detected