Socket
Socket
Sign inDemoInstall

typedarray-to-buffer

Package Overview
Dependencies
0
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.5 to 4.0.0

19

index.js

@@ -0,1 +1,2 @@

/*! typedarray-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/**

@@ -10,17 +11,9 @@ * Convert a typed array to a Buffer without a copy

var isTypedArray = require('is-typedarray').strict
module.exports = function typedarrayToBuffer (arr) {
if (isTypedArray(arr)) {
// To avoid a copy, use the typed array's underlying ArrayBuffer to back new Buffer
var buf = Buffer.from(arr.buffer)
if (arr.byteLength !== arr.buffer.byteLength) {
// Respect the "view", i.e. byteOffset and byteLength, without doing a copy
buf = buf.slice(arr.byteOffset, arr.byteOffset + arr.byteLength)
}
return buf
} else {
return ArrayBuffer.isView(arr)
// To avoid a copy, use the typed array's underlying ArrayBuffer to back
// new Buffer, respecting the "view", i.e. byteOffset and byteLength
? Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength)
// Pass through all other types to `Buffer.from`
return Buffer.from(arr)
}
: Buffer.from(arr)
}
{
"name": "typedarray-to-buffer",
"description": "Convert a typed array to a Buffer without a copy",
"version": "3.1.5",
"version": "4.0.0",
"author": {
"name": "Feross Aboukhadijeh",
"email": "feross@feross.org",
"url": "http://feross.org/"
"url": "https://feross.org"
},

@@ -13,9 +13,7 @@ "bugs": {

},
"dependencies": {
"is-typedarray": "^1.0.0"
},
"dependencies": {},
"devDependencies": {
"airtap": "0.0.4",
"airtap": "^3.0.0",
"standard": "*",
"tape": "^4.0.0"
"tape": "^5.0.1"
},

@@ -50,3 +48,17 @@ "homepage": "http://feross.org",

"test-node": "tape test/*.js"
}
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
}
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