Skip to content

Use is-buffer module to reduce bundle size. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Buffer = require('buffer').Buffer
var isBuffer = require('is-buffer')

module.exports = function (buf) {
// If the buffer is backed by a Uint8Array, a faster version will work
Expand All @@ -12,7 +12,7 @@ module.exports = function (buf) {
}
}

if (Buffer.isBuffer(buf)) {
if (isBuffer(buf)) {
// This is the slow version that will work with any Buffer
// implementation (even in old browsers)
var arrayCopy = new Uint8Array(buf.length)
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
"devDependencies": {
"tape": "^4.4.0",
"zuul": "^3.9.0"
},
"dependencies": {
"is-buffer": "^1.1.1"
}
}