bare-buffer 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +25 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -235,6 +235,13 @@ const Buffer = module.exports = exports = class Buffer extends Uint8Array {
|
|
|
235
235
|
return offset + 4
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
writeUInt16LE (value, offset = 0) {
|
|
239
|
+
const view = new DataView(this.buffer, this.byteOffset, this.byteLength)
|
|
240
|
+
view.setUint16(offset, value, true)
|
|
241
|
+
|
|
242
|
+
return offset + 2
|
|
243
|
+
}
|
|
244
|
+
|
|
238
245
|
writeUInt32LE (value, offset = 0) {
|
|
239
246
|
const view = new DataView(this.buffer, this.byteOffset, this.byteLength)
|
|
240
247
|
view.setUint32(offset, value, true)
|
|
@@ -287,6 +294,13 @@ const Buffer = module.exports = exports = class Buffer extends Uint8Array {
|
|
|
287
294
|
return offset + 4
|
|
288
295
|
}
|
|
289
296
|
|
|
297
|
+
writeUInt16BE (value, offset = 0) {
|
|
298
|
+
const view = new DataView(this.buffer, this.byteOffset, this.byteLength)
|
|
299
|
+
view.setUint16(offset, value, false)
|
|
300
|
+
|
|
301
|
+
return offset + 2
|
|
302
|
+
}
|
|
303
|
+
|
|
290
304
|
writeUInt32BE (value, offset = 0) {
|
|
291
305
|
const view = new DataView(this.buffer, this.byteOffset, this.byteLength)
|
|
292
306
|
view.setUint32(offset, value, false)
|
|
@@ -313,6 +327,12 @@ const Buffer = module.exports = exports = class Buffer extends Uint8Array {
|
|
|
313
327
|
return view.getFloat32(offset, false)
|
|
314
328
|
}
|
|
315
329
|
|
|
330
|
+
readUInt16BE (offset = 0) {
|
|
331
|
+
const view = new DataView(this.buffer, this.byteOffset, this.byteLength)
|
|
332
|
+
|
|
333
|
+
return view.getUint16(offset, false)
|
|
334
|
+
}
|
|
335
|
+
|
|
316
336
|
readUInt32BE (offset = 0) {
|
|
317
337
|
const view = new DataView(this.buffer, this.byteOffset, this.byteLength)
|
|
318
338
|
|
|
@@ -381,7 +401,11 @@ exports.allocUnsafeSlow = function allocUnsafeSlow (size) {
|
|
|
381
401
|
}
|
|
382
402
|
|
|
383
403
|
exports.byteLength = function byteLength (string, encoding) {
|
|
384
|
-
|
|
404
|
+
if (typeof string === 'string') {
|
|
405
|
+
return codecFor(encoding).byteLength(string)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return string.byteLength
|
|
385
409
|
}
|
|
386
410
|
|
|
387
411
|
exports.compare = function compare (a, b) {
|