MCPcopy Index your code
hub / github.com/dataease/SQLBot / byteLength

Function byteLength

frontend/public/swagger-ui-bundle.js:21636–21670  ·  view source on GitHub ↗
(s, o)

Source from the content-addressed store, hash-verified

21634 return 0 | s
21635 }
21636 function byteLength(s, o) {
21637 if (Buffer.isBuffer(s)) return s.length
21638 if (ArrayBuffer.isView(s) || isInstance(s, ArrayBuffer)) return s.byteLength
21639 if ('string' != typeof s)
21640 throw new TypeError(
21641 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' +
21642 typeof s
21643 )
21644 const i = s.length,
21645 a = arguments.length > 2 && !0 === arguments[2]
21646 if (!a && 0 === i) return 0
21647 let u = !1
21648 for (;;)
21649 switch (o) {
21650 case 'ascii':
21651 case 'latin1':
21652 case 'binary':
21653 return i
21654 case 'utf8':
21655 case 'utf-8':
21656 return utf8ToBytes(s).length
21657 case 'ucs2':
21658 case 'ucs-2':
21659 case 'utf16le':
21660 case 'utf-16le':
21661 return 2 * i
21662 case 'hex':
21663 return i >>> 1
21664 case 'base64':
21665 return base64ToBytes(s).length
21666 default:
21667 if (u) return a ? -1 : utf8ToBytes(s).length
21668 ;((o = ('' + o).toLowerCase()), (u = !0))
21669 }
21670 }
21671 function slowToString(s, o, i) {
21672 let a = !1
21673 if (((void 0 === o || o < 0) && (o = 0), o > this.length)) return ''

Callers 1

fromFunction · 0.85

Calls 3

isInstanceFunction · 0.85
utf8ToBytesFunction · 0.85
base64ToBytesFunction · 0.85

Tested by

no test coverage detected