├── .npmrc ├── .nycrc ├── .github ├── workflows │ ├── node-pretest.yml │ ├── rebase.yml │ ├── require-allow-edits.yml │ ├── node-aught.yml │ ├── node-twenties.yml │ └── node-tens.yml └── FUNDING.yml ├── .gitignore ├── .eslintrc ├── LICENSE ├── test ├── fixtures.json └── index.js ├── README.md ├── package.json ├── index.js └── CHANGELOG.md /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | allow-same-version=true 3 | message=v%s 4 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "all": true, 3 | "check-coverage": false, 4 | "reporter": ["text-summary", "text", "html", "json"], 5 | "exclude": [ 6 | "coverage", 7 | "test" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/node-pretest.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: pretest/posttest' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | tests: 7 | uses: ljharb/actions/.github/workflows/pretest.yml@main 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | coverage/ 4 | .nyc_output/ 5 | 6 | # Only apps should have lockfiles 7 | npm-shrinkwrap.json 8 | package-lock.json 9 | yarn.lock 10 | 11 | .npmignore 12 | -------------------------------------------------------------------------------- /.github/workflows/rebase.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Rebase 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | uses: ljharb/actions/.github/workflows/rebase.yml@main 8 | secrets: 9 | token: ${{ secrets.GITHUB_TOKEN }} 10 | -------------------------------------------------------------------------------- /.github/workflows/require-allow-edits.yml: -------------------------------------------------------------------------------- 1 | name: Require “Allow Edits” 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | name: "Require “Allow Edits”" 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: ljharb/require-allow-edits@main 13 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | 4 | "extends": "@ljharb", 5 | 6 | "globals": { 7 | "Float64Array": "readonly", 8 | "Uint8Array": "readonly", 9 | "Uint16Array": "readonly", 10 | }, 11 | 12 | "rules": { 13 | "complexity": "off", 14 | "max-lines-per-function": "off", 15 | }, 16 | } 17 | -------------------------------------------------------------------------------- /.github/workflows/node-aught.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js < 10' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | tests: 7 | uses: ljharb/actions/.github/workflows/node.yml@main 8 | with: 9 | range: '< 10' 10 | type: minors 11 | command: npm run tests-only 12 | 13 | node: 14 | name: 'node < 10' 15 | needs: [tests] 16 | runs-on: ubuntu-latest 17 | steps: 18 | - run: true 19 | -------------------------------------------------------------------------------- /.github/workflows/node-twenties.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js >= 20' 2 | 3 | on: [pull_request, push] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | tests: 10 | uses: ljharb/actions/.github/workflows/node.yml@main 11 | with: 12 | range: '>= 20' 13 | type: minors 14 | command: npm run tests-only 15 | 16 | node: 17 | name: 'node >= 20' 18 | needs: [tests] 19 | runs-on: ubuntu-latest 20 | steps: 21 | - run: true 22 | -------------------------------------------------------------------------------- /.github/workflows/node-tens.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js 10 - 20' 2 | 3 | on: [pull_request, push] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | tests: 10 | uses: ljharb/actions/.github/workflows/node.yml@main 11 | with: 12 | range: '>= 10 < 20' 13 | type: minors 14 | command: npm run tests-only 15 | 16 | node: 17 | name: 'node 10 - 20' 18 | needs: [tests] 19 | runs-on: ubuntu-latest 20 | steps: 21 | - run: true 22 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [ljharb, mafintosh] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: npm/to-buffer 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Mathias Buus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/fixtures.json: -------------------------------------------------------------------------------- 1 | { 2 | "Float16Array": { 3 | "input": [1234.56, 45.67], 4 | "output": [211, 100, 181, 81] 5 | }, 6 | "Float32Array": { 7 | "input": [1234.56, 45.67], 8 | "output": [236, 81, 154, 68, 20, 174, 54, 66] 9 | }, 10 | "Float64Array": { 11 | "input": [1234.56, 45.67], 12 | "output": [10, 215, 163, 112, 61, 74, 147, 64, 246, 40, 92, 143, 194, 213, 70, 64] 13 | }, 14 | "Int8Array": { 15 | "input": [1234, 45], 16 | "output": [210, 45] 17 | }, 18 | "Int16Array": { 19 | "input": [1234, 512], 20 | "output": [210, 4, 0, 2] 21 | }, 22 | "Int32Array": { 23 | "input": [1234, 512], 24 | "output": [210, 4, 0, 0, 0, 2, 0, 0] 25 | }, 26 | "Uint8Array": { 27 | "input": [1234, 45], 28 | "output": [210, 45] 29 | }, 30 | "Uint8ClampedArray": { 31 | "input": [1234, 45], 32 | "output": [255, 45] 33 | }, 34 | "Uint16Array": { 35 | "input": [1234, 512], 36 | "output": [210, 4, 0, 2] 37 | }, 38 | "Uint32Array": { 39 | "input": [1234, 512], 40 | "output": [210, 4, 0, 0, 0, 2, 0, 0] 41 | }, 42 | "BigInt64Array": { 43 | "input": ["123456789012345678", "987654321098765432"], 44 | "output": [78, 243, 48, 166, 75, 155, 182, 1, 120, 180, 248, 73, 95, 218, 180, 13] 45 | }, 46 | "BigUint64Array": { 47 | "input": ["123456789012345678", "987654321098765432"], 48 | "output": [78, 243, 48, 166, 75, 155, 182, 1, 120, 180, 248, 73, 95, 218, 180, 13] 49 | } 50 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # to-buffer [![Version Badge][2]][1] 2 | 3 | Pass in a string, array, Buffer, Data View, or Uint8Array, and get a Buffer back. 4 | 5 | [![github actions][actions-image]][actions-url] 6 | [![coverage][codecov-image]][codecov-url] 7 | [![dependency status][5]][6] 8 | [![dev dependency status][7]][8] 9 | [![License][license-image]][license-url] 10 | [![Downloads][downloads-image]][downloads-url] 11 | 12 | [![npm badge][11]][1] 13 | 14 | 15 | ``` 16 | npm install to-buffer 17 | ``` 18 | 19 | ## Usage 20 | 21 | ``` js 22 | var toBuffer = require('to-buffer'); 23 | 24 | console.log(toBuffer('hi')); // 25 | console.log(toBuffer(Buffer('hi'))); // 26 | console.log(toBuffer('6869', 'hex')); // 27 | console.log(toBuffer(43)); // throws 28 | ``` 29 | 30 | [1]: https://npmjs.org/package/to-buffer 31 | [2]: https://versionbadg.es/browserify/to-buffer.svg 32 | [5]: https://david-dm.org/browserify/to-buffer.svg 33 | [6]: https://david-dm.org/browserify/to-buffer 34 | [7]: https://david-dm.org/browserify/to-buffer/dev-status.svg 35 | [8]: https://david-dm.org/browserify/to-buffer#info=devDependencies 36 | [11]: https://nodei.co/npm/to-buffer.png?downloads=true&stars=true 37 | [license-image]: https://img.shields.io/npm/l/to-buffer.svg 38 | [license-url]: LICENSE 39 | [downloads-image]: https://img.shields.io/npm/dm/to-buffer.svg 40 | [downloads-url]: https://npm-stat.com/charts.html?package=to-buffer 41 | [codecov-image]: https://codecov.io/gh/browserify/to-buffer/branch/main/graphs/badge.svg 42 | [codecov-url]: https://app.codecov.io/gh/browserify/to-buffer/ 43 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/browserify/to-buffer 44 | [actions-url]: https://github.com/browserify/to-buffer/actions 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "to-buffer", 3 | "version": "1.2.2", 4 | "description": "Pass in a string, array, Buffer, Data View, or Uint8Array, and get a Buffer back.", 5 | "main": "index.js", 6 | "sideEffects": false, 7 | "scripts": { 8 | "prepack": "npmignore --auto --commentLines=autogenerated", 9 | "lint": "eslint --ext=js,mjs .", 10 | "pretest": "npm run lint", 11 | "tests-only": "nyc tape 'test/**/*'", 12 | "test": "npm run tests-only", 13 | "posttest": "npx npm@\">= 10.2\" audit --production", 14 | "version": "auto-changelog && git add CHANGELOG.md", 15 | "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/browserify/to-buffer.git" 20 | }, 21 | "author": "Mathias Buus (@mafintosh)", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/browserify/to-buffer/issues" 25 | }, 26 | "homepage": "https://github.com/browserify/to-buffer", 27 | "dependencies": { 28 | "isarray": "^2.0.5", 29 | "safe-buffer": "^5.2.1", 30 | "typed-array-buffer": "^1.0.3" 31 | }, 32 | "devDependencies": { 33 | "@ljharb/eslint-config": "^21.2.0", 34 | "auto-changelog": "^2.5.0", 35 | "available-typed-arrays": "^1.0.7", 36 | "encoding": "^0.1.13", 37 | "eslint": "=8.8.0", 38 | "for-each": "^0.3.5", 39 | "npmignore": "^0.3.1", 40 | "nyc": "^10.3.2", 41 | "tape": "^5.9.0" 42 | }, 43 | "engines": { 44 | "node": ">= 0.4" 45 | }, 46 | "publishConfig": { 47 | "ignore": [ 48 | ".github/workflows", 49 | ".eslintrc", 50 | ".nycrc", 51 | "test" 52 | ] 53 | }, 54 | "auto-changelog": { 55 | "output": "CHANGELOG.md", 56 | "template": "keepachangelog", 57 | "unreleased": false, 58 | "commitLimit": false, 59 | "backfillLimit": false, 60 | "hideCredit": true 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Buffer = require('safe-buffer').Buffer; 4 | var isArray = require('isarray'); 5 | var typedArrayBuffer = require('typed-array-buffer'); 6 | 7 | var isView = ArrayBuffer.isView || function isView(obj) { 8 | try { 9 | typedArrayBuffer(obj); 10 | return true; 11 | } catch (e) { 12 | return false; 13 | } 14 | }; 15 | 16 | var useUint8Array = typeof Uint8Array !== 'undefined'; 17 | var useArrayBuffer = typeof ArrayBuffer !== 'undefined' 18 | && typeof Uint8Array !== 'undefined'; 19 | var useFromArrayBuffer = useArrayBuffer && (Buffer.prototype instanceof Uint8Array || Buffer.TYPED_ARRAY_SUPPORT); 20 | 21 | module.exports = function toBuffer(data, encoding) { 22 | if (Buffer.isBuffer(data)) { 23 | if (data.constructor && !('isBuffer' in data)) { 24 | // probably a SlowBuffer 25 | return Buffer.from(data); 26 | } 27 | return data; 28 | } 29 | 30 | if (typeof data === 'string') { 31 | return Buffer.from(data, encoding); 32 | } 33 | 34 | /* 35 | * Wrap any TypedArray instances and DataViews 36 | * Makes sense only on engines with full TypedArray support -- let Buffer detect that 37 | */ 38 | if (useArrayBuffer && isView(data)) { 39 | // Bug in Node.js <6.3.1, which treats this as out-of-bounds 40 | if (data.byteLength === 0) { 41 | return Buffer.alloc(0); 42 | } 43 | 44 | // When Buffer is based on Uint8Array, we can just construct it from ArrayBuffer 45 | if (useFromArrayBuffer) { 46 | var res = Buffer.from(data.buffer, data.byteOffset, data.byteLength); 47 | /* 48 | * Recheck result size, as offset/length doesn't work on Node.js <5.10 49 | * We just go to Uint8Array case if this fails 50 | */ 51 | if (res.byteLength === data.byteLength) { 52 | return res; 53 | } 54 | } 55 | 56 | // Convert to Uint8Array bytes and then to Buffer 57 | var uint8 = data instanceof Uint8Array ? data : new Uint8Array(data.buffer, data.byteOffset, data.byteLength); 58 | var result = Buffer.from(uint8); 59 | 60 | /* 61 | * Let's recheck that conversion succeeded 62 | * We have .length but not .byteLength when useFromArrayBuffer is false 63 | */ 64 | if (result.length === data.byteLength) { 65 | return result; 66 | } 67 | } 68 | 69 | /* 70 | * Uint8Array in engines where Buffer.from might not work with ArrayBuffer, just copy over 71 | * Doesn't make sense with other TypedArray instances 72 | */ 73 | if (useUint8Array && data instanceof Uint8Array) { 74 | return Buffer.from(data); 75 | } 76 | 77 | var isArr = isArray(data); 78 | if (isArr) { 79 | for (var i = 0; i < data.length; i += 1) { 80 | var x = data[i]; 81 | if ( 82 | typeof x !== 'number' 83 | || x < 0 84 | || x > 255 85 | || ~~x !== x // NaN and integer check 86 | ) { 87 | throw new RangeError('Array items must be numbers in the range 0-255.'); 88 | } 89 | } 90 | } 91 | 92 | /* 93 | * Old Buffer polyfill on an engine that doesn't have TypedArray support 94 | * Also, this is from a different Buffer polyfill implementation then we have, as instanceof check failed 95 | * Convert to our current Buffer implementation 96 | */ 97 | if ( 98 | isArr || ( 99 | Buffer.isBuffer(data) 100 | && data.constructor 101 | && typeof data.constructor.isBuffer === 'function' 102 | && data.constructor.isBuffer(data) 103 | ) 104 | ) { 105 | return Buffer.from(data); 106 | } 107 | 108 | throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.'); 109 | }; 110 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var test = require('tape'); 4 | var availableTypedArrays = require('available-typed-arrays')(); 5 | var forEach = require('for-each'); 6 | var typedArrayBuffer = require('typed-array-buffer'); 7 | var SafeBuffer = require('safe-buffer').Buffer; 8 | var SlowBuffer = require('buffer').SlowBuffer; 9 | 10 | var toBuffer = require('../'); 11 | var fixtures = require('./fixtures.json'); 12 | 13 | test('buffer returns buffer', function (t) { 14 | var result = toBuffer(new Buffer('hi')); 15 | 16 | t.deepEqual(result, new Buffer('hi')); 17 | t.ok(result instanceof Buffer, 'is a Buffer'); 18 | t.notOk(result instanceof SlowBuffer, 'not a SlowBuffer'); 19 | 20 | t.end(); 21 | }); 22 | 23 | test('SlowBuffer returns Buffer', { skip: SlowBuffer.name === 'deprecated' }, function (t) { 24 | var slow = new SlowBuffer(2); 25 | slow[0] = 7; 26 | slow[1] = 8; 27 | var result = toBuffer(slow); 28 | 29 | t.deepEqual(result, new Buffer([7, 8])); 30 | t.ok(result instanceof Buffer, 'is a Buffer'); 31 | t.notOk(result instanceof SlowBuffer, 'not a SlowBuffer'); 32 | 33 | t.end(); 34 | }); 35 | 36 | test('string returns buffer', function (t) { 37 | t.deepEqual(toBuffer('hi'), new Buffer('hi')); 38 | t.end(); 39 | }); 40 | 41 | test('string + enc returns buffer', function (t) { 42 | t.deepEqual(toBuffer('6869', 'hex'), new Buffer('hi')); 43 | t.end(); 44 | }); 45 | 46 | test('array returns buffer', function (t) { 47 | t.deepEqual(toBuffer([104, 105]), new Buffer('hi')); 48 | 49 | forEach([-1, 256, NaN, 4.2, Infinity], function (nonByte) { 50 | t['throws']( 51 | function () { toBuffer([0, 42, nonByte]); }, 52 | RangeError, 53 | nonByte + ': arrays with out-of-bounds byte values throw' 54 | ); 55 | }); 56 | 57 | t.end(); 58 | }); 59 | 60 | test('other input throws', function (t) { 61 | try { 62 | toBuffer(42); 63 | } catch (err) { 64 | t.deepEqual(err.message, 'The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.'); 65 | t.end(); 66 | } 67 | }); 68 | 69 | test('handle all TA types', function (t) { 70 | forEach(availableTypedArrays, function (type) { 71 | var TA = global[type]; 72 | if (!(type in fixtures)) { 73 | t.fail('No fixtures for ' + type); 74 | return; 75 | } 76 | 77 | var input = fixtures[type].input; 78 | if (typeof input[0] === 'string') { 79 | for (var i = 0; i < input.length; i++) { 80 | input[i] = BigInt(input[i]); 81 | } 82 | } 83 | 84 | t.deepEqual( 85 | toBuffer(new TA(input)), 86 | new Buffer(fixtures[type].output), 87 | type + ' should be converted to Buffer correctly' 88 | ); 89 | }); 90 | 91 | t.test('TA subset view on another one', { skip: typeof Float64Array === 'undefined' || typeof Uint8Array === 'undefined' }, function (st) { 92 | var arr = new Uint8Array(100); 93 | for (var i = 0; i < arr.length; i += 1) { 94 | arr[i] = i; 95 | } 96 | 97 | var buffer = typedArrayBuffer(arr); 98 | var expectedHex = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60616263'; 99 | 100 | forEach(availableTypedArrays, function (type) { 101 | var TA = global[type]; 102 | var offset = 8; 103 | var len = 4; 104 | var arr2 = new TA(buffer, offset, len); 105 | st.ok(arr2.BYTES_PER_ELEMENT >= 1, 'BYTES_PER_ELEMENT: sanity check'); 106 | 107 | var expectedSlice = expectedHex.slice(offset * 2, (offset + (len * arr2.BYTES_PER_ELEMENT)) * 2); 108 | var expected = SafeBuffer.from(expectedSlice, 'hex'); 109 | st.equal(expected.length, len * arr2.BYTES_PER_ELEMENT, 'expected length: sanity check'); 110 | 111 | var result = toBuffer(arr2); 112 | st.deepEqual( 113 | result, 114 | expected, 115 | 'Uint8Array subset view on ' + type + ' should be converted to Buffer correctly' 116 | ); 117 | st.equal( 118 | result.toString('hex'), 119 | expectedSlice, 120 | 'Uint8Array subset view on ' + type + ' should be converted to Buffer that toStrings correctly' 121 | ); 122 | }); 123 | 124 | st.end(); 125 | }); 126 | 127 | t.end(); 128 | }); 129 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [v1.2.2](https://github.com/browserify/to-buffer/compare/v1.2.1...v1.2.2) - 2025-09-24 9 | 10 | ### Commits 11 | 12 | - [Fix] handle SlowBuffers in node 0.10 [`ca20eaa`](https://github.com/browserify/to-buffer/commit/ca20eaad8c9cbd6e3e6e99880b2b1c95abe62566) 13 | - [Refactor] use `SafeBuffer.isBuffer` instead of `instanceof` [`81283c1`](https://github.com/browserify/to-buffer/commit/81283c14b585c0e921e04f327381e975cc8561bb) 14 | - [Dev Deps] update `@ljharb/eslint-config` [`c7bc986`](https://github.com/browserify/to-buffer/commit/c7bc986d378ce4bdf2dac75612b45b0f618f26d6) 15 | - [meta] since tests are npmignored, also npmignore test config files [`866639c`](https://github.com/browserify/to-buffer/commit/866639cf294799f8c0397153e5876ae1e6992a57) 16 | 17 | ## [v1.2.1](https://github.com/browserify/to-buffer/compare/v1.2.0...v1.2.1) - 2025-06-19 18 | 19 | ### Commits 20 | 21 | - [Fix] handle non-Uint8Arrays in node < 3 [`7f8a881`](https://github.com/browserify/to-buffer/commit/7f8a881929133935f8e15ffd60d6dbbc513b2c5f) 22 | - [Tests] add coverage [`286c96a`](https://github.com/browserify/to-buffer/commit/286c96a52cfeee14a2ba974d78071bdd667e9360) 23 | - [Fix] provide a fallback for engines without `ArrayBuffer.isView` [`e336166`](https://github.com/browserify/to-buffer/commit/e336166b8f4bf13860bafa191ee1ec53fca2e331) 24 | - [Fix] correct error message [`b45247e`](https://github.com/browserify/to-buffer/commit/b45247ed337fb44b2c8d74a14e8f86d985119fb9) 25 | 26 | ## [v1.2.0](https://github.com/browserify/to-buffer/compare/v1.1.1...v1.2.0) - 2025-06-17 27 | 28 | ### Commits 29 | 30 | - [New] replace with implementation from cipher-base [`970adb5`](https://github.com/browserify/to-buffer/commit/970adb5523efdaa13f5ecb82967fc9f617865549) 31 | - [Tests] migrate from travis to GHA [`8084393`](https://github.com/browserify/to-buffer/commit/808439337ca9ac3dbb8399079aaa2a4cb738627c) 32 | - [eslint] fix whitespace [`a62e651`](https://github.com/browserify/to-buffer/commit/a62e651b661adf98c17e9e486b55bb8ff0ffb8c9) 33 | - [eslint] fix semicolon usage [`4d85c63`](https://github.com/browserify/to-buffer/commit/4d85c6318c72feae8d19037937154f9b99ba266f) 34 | - [meta] add `auto-changelog` [`aa0279c`](https://github.com/browserify/to-buffer/commit/aa0279c5199ca7fe39acfb950a4c824e97f06232) 35 | - [readme] update URLs, add badges [`ff77d90`](https://github.com/browserify/to-buffer/commit/ff77d90b89de7b02538ecb2d6a89da086093bed8) 36 | - [lint] switch to eslint [`e45f467`](https://github.com/browserify/to-buffer/commit/e45f467c7229e632cd3c10fc02895ba4d3204bbe) 37 | - [Fix] validate that arrays contain valid byte values [`c2fb75e`](https://github.com/browserify/to-buffer/commit/c2fb75edf2fb113d58599e990f86574b4dfa62d8) 38 | - [Fix] restore previous implementation Array behavior [`cb93b75`](https://github.com/browserify/to-buffer/commit/cb93b75a79caa9897f6c29ecde91f4ae35f704fe) 39 | - [Tests] add nyc for coverage [`ab7026e`](https://github.com/browserify/to-buffer/commit/ab7026e36e3716c8101229f426e7f4571e55794b) 40 | - [Refactor] use `safe-buffer`.from instead of `buffer-from` [`8e01307`](https://github.com/browserify/to-buffer/commit/8e01307191245044469e47695c5c2675b85e84e9) 41 | - [Fix] Replace Buffer.from with `buffer-from` [`d652e54`](https://github.com/browserify/to-buffer/commit/d652e54e2396a47358a553c447e0f338b4c2dc67) 42 | - [Tests] use `deepEqual` over `same` alias [`66a5548`](https://github.com/browserify/to-buffer/commit/66a55480258011bb5d81c5aad1360468f418d0b4) 43 | - [meta] add `npmignore` [`90ce602`](https://github.com/browserify/to-buffer/commit/90ce6023737d50521aff44d87063db1e3f7e352a) 44 | - [Tests] move into a test dir, update tape [`08aea81`](https://github.com/browserify/to-buffer/commit/08aea81b61b90d1fcb7e9275b5b0ba718531d9a8) 45 | - Only apps should have lockfiles [`16ccceb`](https://github.com/browserify/to-buffer/commit/16ccceb23f350be16e80111188c90a3492916f5d) 46 | - [Tests] add coverage [`d2cba2e`](https://github.com/browserify/to-buffer/commit/d2cba2ec76ed43c83e2a7a91f58fa7640aeb61e9) 47 | - [meta] update description [`2cf2a20`](https://github.com/browserify/to-buffer/commit/2cf2a200a31f9543d2e8a24b5ea0e8bd843166c3) 48 | - [Fix] add `safe-buffer`, missing from 970adb5 [`d9a0dea`](https://github.com/browserify/to-buffer/commit/d9a0dead7c638d188f8b48cdf2b5fd6cfa886071) 49 | - [meta] temporarily limit support to node v0.10 [`8dca458`](https://github.com/browserify/to-buffer/commit/8dca458bd9a2c6b84d6e3a1996e41b242fe1c49a) 50 | - [meta] add missing `engines.node` [`35bdfcb`](https://github.com/browserify/to-buffer/commit/35bdfcb3a71dfbd5b35d35250c9dac19c99f4197) 51 | - [Dev Deps] add missing peer dep [`220143f`](https://github.com/browserify/to-buffer/commit/220143f1f6e47154380c27a2d88ce300104007fa) 52 | - [meta] add `sideEffects` flag [`cd37473`](https://github.com/browserify/to-buffer/commit/cd374738d24b22b029862b3c27b9e247d4e62daf) 53 | 54 | ## [v1.1.1](https://github.com/browserify/to-buffer/compare/v1.1.0...v1.1.1) - 2018-04-26 55 | 56 | ### Commits 57 | 58 | - use Buffer.from when avail [`eebe20e`](https://github.com/browserify/to-buffer/commit/eebe20e0603e2c6a542b00316f1661741fdf1124) 59 | 60 | ## [v1.1.0](https://github.com/browserify/to-buffer/compare/v1.0.1...v1.1.0) - 2017-04-12 61 | 62 | ### Merged 63 | 64 | - Fix typo [`#2`](https://github.com/browserify/to-buffer/pull/2) 65 | 66 | ### Commits 67 | 68 | - support arrays as well [`ef98c82`](https://github.com/browserify/to-buffer/commit/ef98c82791d71601077577e84c4614ec2d05f086) 69 | 70 | ## [v1.0.1](https://github.com/browserify/to-buffer/compare/v1.0.0...v1.0.1) - 2016-02-15 71 | 72 | ### Commits 73 | 74 | - fix desc [`7d50a7c`](https://github.com/browserify/to-buffer/commit/7d50a7c69c3eef77448893744ada16601c44af6a) 75 | 76 | ## v1.0.0 - 2016-02-15 77 | 78 | ### Commits 79 | 80 | - first commit [`8361941`](https://github.com/browserify/to-buffer/commit/8361941d7acb3b82c732ecd10bdb047da5af2028) 81 | - add travis [`de911b5`](https://github.com/browserify/to-buffer/commit/de911b5364558561d84b4ec9e43c6a0fe1c8e904) 82 | --------------------------------------------------------------------------------