Skip to content

Commit

Permalink
Merge pull request #85 from JMJBower/master
Browse files Browse the repository at this point in the history
Changed to Buffer.from to fix depreciation warning in node 8
  • Loading branch information
goto-bus-stop authored Jan 15, 2018
2 parents db00081 + 8923267 commit ea0c82d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
26 changes: 16 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var JSONStream = require('JSONStream');
var defined = require('defined');
var through = require('through2');
var umd = require('umd');
var Buffer = require('safe-buffer').Buffer;

var fs = require('fs');
var path = require('path');
Expand Down Expand Up @@ -44,13 +45,13 @@ module.exports = function (opts) {
function write (row, enc, next) {
if (first && opts.standalone) {
var pre = umd.prelude(opts.standalone).trim();
stream.push(new Buffer(pre + 'return '));
stream.push(Buffer.from(pre + 'return ', 'utf8'));
}
else if (first && stream.hasExports) {
var pre = opts.externalRequireName || 'require';
stream.push(new Buffer(pre + '='));
stream.push(Buffer.from(pre + '=', 'utf8'));
}
if (first) stream.push(new Buffer(prelude + '({'));
if (first) stream.push(Buffer.from(prelude + '({', 'utf8'));

if (row.sourceFile && !row.nomap) {
if (!sourcemap) {
Expand Down Expand Up @@ -81,7 +82,7 @@ module.exports = function (opts) {
']'
].join('');

stream.push(new Buffer(wrappedSource));
stream.push(Buffer.from(wrappedSource, 'utf8'));
lineno += newlinesIn(wrappedSource);

first = false;
Expand All @@ -93,15 +94,18 @@ module.exports = function (opts) {
}

function end () {
if (first) stream.push(new Buffer(prelude + '({'));
if (first) stream.push(Buffer.from(prelude + '({', 'utf8'));
entries = entries.filter(function (x) { return x !== undefined });

stream.push(new Buffer('},{},' + JSON.stringify(entries) + ')'));
stream.push(
Buffer.from('},{},' + JSON.stringify(entries) + ')', 'utf8')
);

if (opts.standalone && !first) {
stream.push(new Buffer(
stream.push(Buffer.from(
'(' + JSON.stringify(stream.standaloneModule) + ')'
+ umd.postlude(opts.standalone)
+ umd.postlude(opts.standalone),
'utf8'
));
}

Expand All @@ -112,9 +116,11 @@ module.exports = function (opts) {
/^\/\/#/, function () { return opts.sourceMapPrefix }
)
}
stream.push(new Buffer('\n' + comment + '\n'));
stream.push(Buffer.from('\n' + comment + '\n', 'utf8'));
}
if (!sourcemap && !opts.standalone) {
stream.push(Buffer.from(';\n', 'utf8'));
}
if (!sourcemap && !opts.standalone) stream.push(new Buffer(';\n'));

stream.push(null);
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"JSONStream": "^1.0.3",
"combine-source-map": "~0.8.0",
"defined": "^1.0.0",
"safe-buffer": "^5.1.1",
"through2": "^2.0.0",
"umd": "^3.0.0"
},
Expand Down

0 comments on commit ea0c82d

Please sign in to comment.