[Pkg-javascript-commits] [node-browser-pack] 07/27: Changed to Buffer.from to fix depreciation warning in node 8

Bastien Roucariès rouca at moszumanska.debian.org
Sun Feb 18 22:35:15 UTC 2018


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browser-pack.

commit 5611b5c964b089bb655b50ed889a55f72ce05716
Author: JMJBower <jmjbower at gmail.com>
Date:   Tue Jan 9 18:03:52 2018 +0000

    Changed to Buffer.from to fix depreciation warning in node 8
---
 index.js | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/index.js b/index.js
index 3b96de8..284c780 100644
--- a/index.js
+++ b/index.js
@@ -44,13 +44,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) {
@@ -81,7 +81,7 @@ module.exports = function (opts) {
             ']'
         ].join('');
 
-        stream.push(new Buffer(wrappedSource));
+        stream.push(Buffer.from(wrappedSource, 'utf8'));
         lineno += newlinesIn(wrappedSource);
         
         first = false;
@@ -93,15 +93,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'
             ));
         }
         
@@ -112,9 +115,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);
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browser-pack.git



More information about the Pkg-javascript-commits mailing list