MCPcopy Create free account
hub / github.com/SocketCluster/socketcluster / slowToString

Function slowToString

app/public/socketcluster-client.js:3079–3147  ·  view source on GitHub ↗
(encoding, start, end)

Source from the content-addressed store, hash-verified

3077Buffer.byteLength = byteLength
3078
3079function slowToString (encoding, start, end) {
3080 var loweredCase = false
3081
3082 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
3083 // property of a typed array.
3084
3085 // This behaves neither like String nor Uint8Array in that we set start/end
3086 // to their upper/lower bounds if the value passed is out of range.
3087 // undefined is handled specially as per ECMA-262 6th Edition,
3088 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
3089 if (start === undefined || start < 0) {
3090 start = 0
3091 }
3092 // Return early if start > this.length. Done here to prevent potential uint32
3093 // coercion fail below.
3094 if (start > this.length) {
3095 return ''
3096 }
3097
3098 if (end === undefined || end > this.length) {
3099 end = this.length
3100 }
3101
3102 if (end <= 0) {
3103 return ''
3104 }
3105
3106 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
3107 end >>>= 0
3108 start >>>= 0
3109
3110 if (end <= start) {
3111 return ''
3112 }
3113
3114 if (!encoding) encoding = 'utf8'
3115
3116 while (true) {
3117 switch (encoding) {
3118 case 'hex':
3119 return hexSlice(this, start, end)
3120
3121 case 'utf8':
3122 case 'utf-8':
3123 return utf8Slice(this, start, end)
3124
3125 case 'ascii':
3126 return asciiSlice(this, start, end)
3127
3128 case 'latin1':
3129 case 'binary':
3130 return latin1Slice(this, start, end)
3131
3132 case 'base64':
3133 return base64Slice(this, start, end)
3134
3135 case 'ucs2':
3136 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…