Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Remove buffer-from dependency (#15)
Browse files Browse the repository at this point in the history
`Buffer.from()` was added in Node.js v5.10.0, which is old
enough for the versions this module should support.

Closes #14.
  • Loading branch information
TooTallNate committed May 30, 2020
1 parent 5f10c58 commit 36bc033
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
},
"homepage": "https://github.com/TooTallNate/node-data-uri-to-buffer",
"devDependencies": {
"@types/buffer-from": "^1.1.0",
"@types/es6-promisify": "^5.0.0",
"@types/mocha": "^5.2.7",
"@types/node": "^10.5.3",
Expand All @@ -52,8 +51,5 @@
"eslint-plugin-react": "7.12.4",
"mocha": "^6.2.0",
"typescript": "^3.5.3"
},
"dependencies": {
"buffer-from": "^1.1.1"
}
}
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import bufferFrom from 'buffer-from';

/**
* Returns a `Buffer` instance from the given data URI `uri`.
*
Expand Down Expand Up @@ -50,7 +48,7 @@ function dataUriToBuffer(uri: string): dataUriToBuffer.MimeBuffer {
// get the encoded data portion and decode URI-encoded chars
const encoding = base64 ? 'base64' : 'ascii';
const data = unescape(uri.substring(firstComma + 1));
const buffer = bufferFrom(data, encoding) as dataUriToBuffer.MimeBuffer;
const buffer = Buffer.from(data, encoding) as dataUriToBuffer.MimeBuffer;

// set `.type` and `.typeFull` properties to MIME type
buffer.type = type;
Expand Down

0 comments on commit 36bc033

Please sign in to comment.