MCPcopy Index your code
hub / github.com/plotly/plotly.js / slowToString

Function slowToString

stackgl_modules/index.js:430–487  ·  view source on GitHub ↗
(encoding, start, end)

Source from the content-addressed store, hash-verified

428}
429Buffer.byteLength = byteLength;
430function slowToString(encoding, start, end) {
431 var loweredCase = false;
432
433 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
434 // property of a typed array.
435
436 // This behaves neither like String nor Uint8Array in that we set start/end
437 // to their upper/lower bounds if the value passed is out of range.
438 // undefined is handled specially as per ECMA-262 6th Edition,
439 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
440 if (start === undefined || start < 0) {
441 start = 0;
442 }
443 // Return early if start > this.length. Done here to prevent potential uint32
444 // coercion fail below.
445 if (start > this.length) {
446 return '';
447 }
448 if (end === undefined || end > this.length) {
449 end = this.length;
450 }
451 if (end <= 0) {
452 return '';
453 }
454
455 // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
456 end >>>= 0;
457 start >>>= 0;
458 if (end <= start) {
459 return '';
460 }
461 if (!encoding) encoding = 'utf8';
462 while (true) {
463 switch (encoding) {
464 case 'hex':
465 return hexSlice(this, start, end);
466 case 'utf8':
467 case 'utf-8':
468 return utf8Slice(this, start, end);
469 case 'ascii':
470 return asciiSlice(this, start, end);
471 case 'latin1':
472 case 'binary':
473 return latin1Slice(this, start, end);
474 case 'base64':
475 return base64Slice(this, start, end);
476 case 'ucs2':
477 case 'ucs-2':
478 case 'utf16le':
479 case 'utf-16le':
480 return utf16leSlice(this, start, end);
481 default:
482 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
483 encoding = (encoding + '').toLowerCase();
484 loweredCase = true;
485 }
486 }
487}

Callers

nothing calls this directly

Calls 6

hexSliceFunction · 0.85
utf8SliceFunction · 0.85
asciiSliceFunction · 0.85
latin1SliceFunction · 0.85
base64SliceFunction · 0.85
utf16leSliceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…