+9
-0
@@ -8,2 +8,11 @@ # Changelog | ||
| ## [v1.2.2](https://github.com/browserify/to-buffer/compare/v1.2.1...v1.2.2) - 2025-09-24 | ||
| ### Commits | ||
| - [Fix] handle SlowBuffers in node 0.10 [`ca20eaa`](https://github.com/browserify/to-buffer/commit/ca20eaad8c9cbd6e3e6e99880b2b1c95abe62566) | ||
| - [Refactor] use `SafeBuffer.isBuffer` instead of `instanceof` [`81283c1`](https://github.com/browserify/to-buffer/commit/81283c14b585c0e921e04f327381e975cc8561bb) | ||
| - [Dev Deps] update `@ljharb/eslint-config` [`c7bc986`](https://github.com/browserify/to-buffer/commit/c7bc986d378ce4bdf2dac75612b45b0f618f26d6) | ||
| - [meta] since tests are npmignored, also npmignore test config files [`866639c`](https://github.com/browserify/to-buffer/commit/866639cf294799f8c0397153e5876ae1e6992a57) | ||
| ## [v1.2.1](https://github.com/browserify/to-buffer/compare/v1.2.0...v1.2.1) - 2025-06-19 | ||
@@ -10,0 +19,0 @@ |
+8
-8
@@ -22,7 +22,7 @@ 'use strict'; | ||
| module.exports = function toBuffer(data, encoding) { | ||
| /* | ||
| * No need to do anything for exact instance | ||
| * This is only valid when safe-buffer.Buffer === buffer.Buffer, i.e. when Buffer.from/Buffer.alloc existed | ||
| */ | ||
| if (data instanceof Buffer) { | ||
| if (Buffer.isBuffer(data)) { | ||
| if (data.constructor && !('isBuffer' in data)) { | ||
| // probably a SlowBuffer | ||
| return Buffer.from(data); | ||
| } | ||
| return data; | ||
@@ -101,5 +101,5 @@ } | ||
| Buffer.isBuffer(data) | ||
| && data.constructor | ||
| && typeof data.constructor.isBuffer === 'function' | ||
| && data.constructor.isBuffer(data) | ||
| && data.constructor | ||
| && typeof data.constructor.isBuffer === 'function' | ||
| && data.constructor.isBuffer(data) | ||
| ) | ||
@@ -106,0 +106,0 @@ ) { |
+4
-2
| { | ||
| "name": "to-buffer", | ||
| "version": "1.2.1", | ||
| "version": "1.2.2", | ||
| "description": "Pass in a string, array, Buffer, Data View, or Uint8Array, and get a Buffer back.", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
| "devDependencies": { | ||
| "@ljharb/eslint-config": "^21.1.1", | ||
| "@ljharb/eslint-config": "^21.2.0", | ||
| "auto-changelog": "^2.5.0", | ||
@@ -50,2 +50,4 @@ "available-typed-arrays": "^1.0.7", | ||
| ".github/workflows", | ||
| ".eslintrc", | ||
| ".nycrc", | ||
| "test" | ||
@@ -52,0 +54,0 @@ ] |
-16
| { | ||
| "root": true, | ||
| "extends": "@ljharb", | ||
| "globals": { | ||
| "Float64Array": "readonly", | ||
| "Uint8Array": "readonly", | ||
| "Uint16Array": "readonly", | ||
| }, | ||
| "rules": { | ||
| "complexity": "off", | ||
| "max-lines-per-function": "off", | ||
| }, | ||
| } |
Sorry, the diff of this file is not supported yet
14005
2.46%6
-25%