MCPcopy Create free account
hub / github.com/cryptii/cryptii / substr

Method substr

src/Chain.js:194–204  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 13

truncateMethod · 0.95
Chain.jsFile · 0.80
indexOfMethod · 0.80
base64StringFromBytesMethod · 0.80
bytesFromBase64StringMethod · 0.80
performDecodeMethod · 0.80
performDecodeMethod · 0.80
performTranslateMethod · 0.80
translateMarksMethod · 0.80
performDecodeMethod · 0.80
performEncodeMethod · 0.80

Calls 4

getLengthMethod · 0.95
getCodePointsMethod · 0.95
emptyMethod · 0.80
wrapMethod · 0.80

Tested by

no test coverage detected