bare-buffer 2.2.0 → 2.3.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.
Files changed (2) hide show
  1. package/index.js +5 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -381,7 +381,11 @@ exports.allocUnsafeSlow = function allocUnsafeSlow (size) {
381
381
  }
382
382
 
383
383
  exports.byteLength = function byteLength (string, encoding) {
384
- return codecFor(encoding).byteLength(string)
384
+ if (typeof string === 'string') {
385
+ return codecFor(encoding).byteLength(string)
386
+ }
387
+
388
+ return string.byteLength
385
389
  }
386
390
 
387
391
  exports.compare = function compare (a, b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-buffer",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Native buffers for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",