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

Commit

Permalink
new Buffer deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Nov 25, 2018
1 parent a961e1a commit 4936d8f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions lib/pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Pass.prototype.pipe = function(output) {
}

// Create pass.json
var passJson = new Buffer(JSON.stringify(this.getPassJSON()), "utf-8");
var passJson = Buffer.from(JSON.stringify(this.getPassJSON()), "utf-8");
addFile("pass.json").end(passJson, "utf8");

var expecting = 0;
Expand Down Expand Up @@ -362,13 +362,13 @@ function signManifest(template, manifest, callback) {
"-passin", "pass:" + template.password
];
var sign = execFile("openssl", args, { stdio: "pipe" }, function(error, stdout, stderr) {
var trimmedStderr = stderr.trim();
var trimmedStderr = stderr.trim();
// Windows outputs some unhelpful error messages, but still produces a valid signature
if (error || (trimmedStderr && trimmedStderr.indexOf('- done') < 0)) {
callback(new Error(stderr));
} else {
var signature = stdout.split(/(\r\n|\n\n)/)[3];
callback(null, new Buffer(signature, "base64"));
callback(null, Buffer.from(signature, "base64"));
}
});
sign.stdin.write(manifest);
Expand Down
14 changes: 7 additions & 7 deletions lib/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ Zip.prototype._flush = function() {

// Write next central directory header. Returns header size;
Zip.prototype._writeCentralDirectoryHeader = function(file) {
var filename = new Buffer(file.filename, "utf-8");
var buffer = new Buffer(46 + filename.length);
var filename = Buffer.from(file.filename, "utf-8");
var buffer = Buffer.alloc(46 + filename.length);

// central file header signature
buffer.writeInt32LE(0x02014b50, 0);
Expand Down Expand Up @@ -165,7 +165,7 @@ Zip.prototype._writeCentralDirectoryHeader = function(file) {

// Write end of central directory record and close output stream.
Zip.prototype._writeEndOfCentralDirectory = function(offsetOfCentralDirectory, sizeOfCentralDirectory) {
var buffer = new Buffer(22);
var buffer = Buffer.alloc(22);
// end of central dir signature
buffer.writeInt32LE(0x06054b50, 0);
// number of this disk
Expand Down Expand Up @@ -277,7 +277,7 @@ File.prototype.write = function(buffer, encoding) {
if (!this.writable)
throw new Error("This file no longer open for writing");
if (typeof(buffer) == "string" || buffer instanceof String)
buffer = new Buffer(buffer, encoding || "utf8");
buffer = Buffer.from(buffer, encoding || "utf8");

// crc-32
for (var i = 0; i < buffer.length; i++) {
Expand Down Expand Up @@ -315,8 +315,8 @@ File.prototype.destroy = function() {
File.prototype._writeLocalFileHeader = function() {
debug("Started writing", this.filename);
this._offset = this.zip._offset;
var filename = new Buffer(this.filename, "utf-8");
var buffer = new Buffer(30 + filename.length);
var filename = Buffer.from(this.filename, "utf-8");
var buffer = Buffer.alloc(30 + filename.length);

// local file header signature
buffer.writeInt32LE(0x04034b50, 0);
Expand Down Expand Up @@ -391,7 +391,7 @@ File.prototype._doneWritingFile = function() {
File.prototype._writeDataDescriptor = function() {
// Write data descriptor at end of file: this is used for data we can only
// determine after processing file (CRC, length).
var buffer = new Buffer(16);
var buffer = Buffer.alloc(16);
buffer.writeInt32LE(0x08074b50, 0);
buffer.writeInt32LE(this._crc ^ -1, 4);
// compressed size
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ "name": "passbook",
{
"name": "passbook",
"description": "iOS Passbook for the Node hacker",
"homepage": "https://github.com/assaf/node-passbook",
"version": "2.1.2",
Expand All @@ -11,12 +12,12 @@
"node-passbook": "./bin/node-passbook"
},
"dependencies": {
"async": "^0.9.0",
"cli": "0.6.5",
"async": "^2.6.1",
"cli": "^1.0.1",
"follow-redirects": "^1.2.3"
},
"devDependencies": {
"mocha": "2.1.0"
"mocha": "^5.2.0"
},
"scripts": {
"test": "mocha"
Expand All @@ -35,7 +36,8 @@
"url": "http://github.com/assaf/node-passbook/issues"
},
"licenses": [
{ "type": "MIT",
{
"type": "MIT",
"url": "http://github.com/assaf/node-passbook/blob/master/MIT-LICENSE"
}
]
Expand Down
2 changes: 1 addition & 1 deletion test/pass_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function unzip(zipFile, filename, callback) {
if (error) {
callback(new Error(stdout));
} else {
callback(null, new Buffer(stdout, "binary"));
callback(null, Buffer.from(stdout, "binary"));
}
});
}
Expand Down

0 comments on commit 4936d8f

Please sign in to comment.