MCPcopy Index your code
hub / github.com/OneNoteDev/WebClipper / slowToString

Function slowToString

lib/sanitize-html.js:1046–1114  ·  view source on GitHub ↗
(encoding, start, end)

Source from the content-addressed store, hash-verified

1044Buffer.byteLength = byteLength
1045
1046function slowToString (encoding, start, end) {
1047 var loweredCase = false
1048
1049 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1050 // property of a typed array.
1051
1052 // This behaves neither like String nor Uint8Array in that we set start/end
1053 // to their upper/lower bounds if the value passed is out of range.
1054 // undefined is handled specially as per ECMA-262 6th Edition,
1055 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1056 if (start === undefined || start < 0) {
1057 start = 0
1058 }
1059 // Return early if start > this.length. Done here to prevent potential uint32
1060 // coercion fail below.
1061 if (start > this.length) {
1062 return ''
1063 }
1064
1065 if (end === undefined || end > this.length) {
1066 end = this.length
1067 }
1068
1069 if (end <= 0) {
1070 return ''
1071 }
1072
1073 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
1074 end >>>= 0
1075 start >>>= 0
1076
1077 if (end <= start) {
1078 return ''
1079 }
1080
1081 if (!encoding) encoding = 'utf8'
1082
1083 while (true) {
1084 switch (encoding) {
1085 case 'hex':
1086 return hexSlice(this, start, end)
1087
1088 case 'utf8':
1089 case 'utf-8':
1090 return utf8Slice(this, start, end)
1091
1092 case 'ascii':
1093 return asciiSlice(this, start, end)
1094
1095 case 'latin1':
1096 case 'binary':
1097 return latin1Slice(this, start, end)
1098
1099 case 'base64':
1100 return base64Slice(this, start, end)
1101
1102 case 'ucs2':
1103 case 'ucs-2':

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