* Returns the characters in a string beginning at the specified location * through the specified number of characters. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr * @param {number} start * @param {number} [length] * @return {Ch
(start, length = undefined)
| 192 | * @return {Chain} |
| 193 | */ |
| 194 | substr (start, length = undefined) { |
| 195 | if (length <= 0 || start >= this.getLength()) { |
| 196 | return Chain.empty() |
| 197 | } else if (start < 0) { |
| 198 | start = Math.max(this.getLength() + start, 0) |
| 199 | } |
| 200 | |
| 201 | const codePoints = this.getCodePoints() |
| 202 | .slice(start, length ? start + length : undefined) |
| 203 | return Chain.wrap(codePoints, this._encoding) |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Truncates chain to given length and adds ellipsis if truncated. |
no test coverage detected