* Performs encode on given content. * @protected * @param {Chain} content * @return {number[]|string|Uint8Array|Chain} Encoded content
(content)
| 55 | * @return {number[]|string|Uint8Array|Chain} Encoded content |
| 56 | */ |
| 57 | performEncode (content) { |
| 58 | switch (this.getSettingValue('case')) { |
| 59 | case 'lower': |
| 60 | return content.toLowerCase() |
| 61 | |
| 62 | case 'upper': |
| 63 | return content.toUpperCase() |
| 64 | |
| 65 | case 'capitalize': |
| 66 | return Chain.wrap( |
| 67 | content.getString() |
| 68 | .replace(/\w\S*/ug, word => |
| 69 | word.charAt(0).toUpperCase() + word.substr(1).toLowerCase()) |
| 70 | ) |
| 71 | |
| 72 | case 'alternating': |
| 73 | return Chain.wrap( |
| 74 | content.getChars() |
| 75 | .map((char, index) => |
| 76 | index % 2 === 0 |
| 77 | ? char.toLowerCase() |
| 78 | : char.toUpperCase()) |
| 79 | .join('') |
| 80 | ) |
| 81 | |
| 82 | case 'inverse': |
| 83 | return this._inverseCase(content) |
| 84 | |
| 85 | default: |
| 86 | return content |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Performs decode on given content. |
nothing calls this directly
no test coverage detected