Skip to content

Commit

Permalink
Fix Buffer deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Jan 17, 2019
1 parent 61b931b commit 32fa2fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/MultipartDataGenerator.js
Expand Up @@ -8,12 +8,12 @@ var Buffer = require('safe-buffer').Buffer;
function multipartDataGenerator(method, data, headers) {
var segno = (Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16)).toString();
headers['Content-Type'] = ('multipart/form-data; boundary=' + segno);
var buffer = new Buffer(0);
var buffer = Buffer.alloc(0);

function push(l) {
var prevBuffer = buffer;
var newBuffer = (l instanceof Buffer) ? l : new Buffer(l);
buffer = new Buffer(prevBuffer.length + newBuffer.length + 2);
var newBuffer = (l instanceof Buffer) ? l : Buffer.from(l);
buffer = Buffer.alloc(prevBuffer.length + newBuffer.length + 2);
prevBuffer.copy(buffer);
newBuffer.copy(buffer, prevBuffer.length);
buffer.write('\r\n', buffer.length - 2);
Expand Down
2 changes: 1 addition & 1 deletion test/Webhook.spec.js
Expand Up @@ -132,7 +132,7 @@ describe('Webhooks', function() {
timestamp: (Date.now() / 1000),
});

expect(stripe.webhooks.signature.verifyHeader(new Buffer(EVENT_PAYLOAD_STRING), new Buffer(header), SECRET, 10)).to.equal(true);
expect(stripe.webhooks.signature.verifyHeader(Buffer.from(EVENT_PAYLOAD_STRING), Buffer.from(header), SECRET, 10)).to.equal(true);
});
});
});
Expand Down

0 comments on commit 32fa2fd

Please sign in to comment.