Socket
Socket
Sign inDemoInstall

typedarray-to-buffer

Package Overview
Dependencies
1
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.2 to 3.1.3

.airtap.yml

6

index.js

@@ -15,3 +15,3 @@ /**

// To avoid a copy, use the typed array's underlying ArrayBuffer to back new Buffer
var buf = new Buffer(arr.buffer)
var buf = Buffer.from(arr.buffer)
if (arr.byteLength !== arr.buffer.byteLength) {

@@ -23,5 +23,5 @@ // Respect the "view", i.e. byteOffset and byteLength, without doing a copy

} else {
// Pass through all other types to the `Buffer` constructor
return new Buffer(arr)
// Pass through all other types to `Buffer.from`
return Buffer.from(arr)
}
}
{
"name": "typedarray-to-buffer",
"description": "Convert a typed array to a Buffer without a copy",
"version": "3.1.2",
"version": "3.1.3",
"author": {

@@ -17,5 +17,5 @@ "name": "Feross Aboukhadijeh",

"devDependencies": {
"standard": "^6.0.4",
"tape": "^4.0.0",
"zuul": "^3.0.0"
"airtap": "0.0.4",
"standard": "*",
"tape": "^4.0.0"
},

@@ -47,6 +47,6 @@ "homepage": "http://feross.org",

"test": "standard && npm run test-node && npm run test-browser",
"test-browser": "zuul -- test/*.js",
"test-browser-local": "zuul --local -- test/*.js",
"test-browser": "airtap -- test/*.js",
"test-browser-local": "airtap --local -- test/*.js",
"test-node": "tape test/*.js"
}
}

@@ -1,7 +0,3 @@

# typedarray-to-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][npm-url]
# typedarray-to-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
#### Convert a typed array to a [Buffer](https://github.com/feross/buffer) without a copy.
[![saucelabs][saucelabs-image]][saucelabs-url]
[travis-image]: https://img.shields.io/travis/feross/typedarray-to-buffer/master.svg

@@ -12,2 +8,10 @@ [travis-url]: https://travis-ci.org/feross/typedarray-to-buffer

[downloads-image]: https://img.shields.io/npm/dm/typedarray-to-buffer.svg
[downloads-url]: https://npmjs.org/package/typedarray-to-buffer
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com
#### Convert a typed array to a [Buffer](https://github.com/feross/buffer) without a copy.
[![saucelabs][saucelabs-image]][saucelabs-url]
[saucelabs-image]: https://saucelabs.com/browser-matrix/typedarray-to-buffer.svg

@@ -22,5 +26,5 @@ [saucelabs-url]: https://saucelabs.com/u/typedarray-to-buffer

Of course: `new Buffer(uint8array)`
Of course: `Buffer.from(uint8array)`
But, alas, every time you do `new Buffer(uint8array)` **the entire array gets copied**.
But, alas, every time you do `Buffer.from(uint8array)` **the entire array gets copied**.
The `Buffer` constructor does a copy; this is

@@ -36,4 +40,4 @@ defined by the [node docs](http://nodejs.org/api/buffer.html) and the 'buffer' module

If you have an `ArrayBuffer`, you don't need this module, because
`new Buffer(arrayBuffer)`
[is already efficient](https://nodejs.org/api/buffer.html#buffer_new_buffer_arraybuffer).
`Buffer.from(arrayBuffer)`
[is already efficient](https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length).

@@ -79,3 +83,3 @@ ## install

If this module is used in node, then it will just call `new Buffer`. This is just for
If this module is used in node, then it will just call `Buffer.from`. This is just for
the convenience of modules that work in both node and the browser.

@@ -82,0 +86,0 @@

@@ -9,3 +9,3 @@ var test = require('tape')

t.deepEqual(arr, new Buffer([1, 2, 3]), 'contents equal')
t.deepEqual(arr, Buffer.from([1, 2, 3]), 'contents equal')
t.ok(Buffer.isBuffer(arr), 'is buffer')

@@ -26,3 +26,3 @@ t.equal(arr.readUInt8(0), 1)

t.deepEqual(arr, new Buffer([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]), 'contents equal')
t.deepEqual(arr, Buffer.from([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]), 'contents equal')
t.ok(Buffer.isBuffer(arr), 'is buffer')

@@ -44,3 +44,3 @@ t.equal(arr.readUInt32LE(0), 1)

t.deepEqual(arr, new Buffer([2, 0, 0, 0]), 'contents equal')
t.deepEqual(arr, Buffer.from([2, 0, 0, 0]), 'contents equal')
t.ok(Buffer.isBuffer(arr), 'is buffer')

@@ -47,0 +47,0 @@ t.equal(arr.readUInt32LE(0), 2)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc