How to use the byteLength function from buffer

Find comprehensive JavaScript buffer.byteLength code examples handpicked from public code repositorys.

2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
jsPDFAPI.arrayBufferToBinaryString = function(buffer) {
	if(this.isArrayBuffer(buffer))
		buffer = new Uint8Array(buffer);

    var binary_string = '';
    var len = buffer.byteLength;
    for (var i = 0; i < len; i++) {
        binary_string += String.fromCharCode(buffer[i]);
    }
    return binary_string;
fork icon4
star icon14
watch icon0

63
64
65
66
67
68
69
70
71
72
  }

  return lkey !== 'connection' && lkey !== 'keep-alive' &&
         lkey !== 'proxy-connection' && lkey !== 'transfer-encoding'
}, this).map(function (key) {
  var klen = Buffer.byteLength(key)
  var value = stringify(loweredHeaders[key])
  var vlen = Buffer.byteLength(value)

  len += size * 2 + klen + vlen
fork icon0
star icon0
watch icon1

+ 3 other calls in file

94
95
96
97
98
99
100
101
102
103
original.BufferIsEncoding = Buffer.isEncoding;
Buffer.isEncoding = function(encoding) {
    return Buffer.isNativeEncoding(encoding) || iconv.encodingExists(encoding);
}

original.BufferByteLength = Buffer.byteLength;
Buffer.byteLength = SlowBuffer.byteLength = function(str, encoding) {
    encoding = String(encoding || 'utf8').toLowerCase();

    // Use native conversion when possible
fork icon0
star icon0
watch icon2

1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
// Find the length
var length
if (type === 'number')
  length = coerce(subject)
else if (type === 'string')
  length = Buffer.byteLength(subject, encoding)
else if (type === 'object')
  length = coerce(subject.length) // assume that object is array-like
else
  throw new Error('First argument needs to be a number, array or string.')
fork icon0
star icon0
watch icon1