diff --git a/package.json b/package.json index d2039bf3..ce962cb9 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "README.md" ], "devDependencies": { + "safer-buffer": "^2.1.2", "standard": "^8.6.0", "tap": "^10.5.1" } diff --git a/test/not-string.js b/test/not-string.js index 86111e35..ca621459 100644 --- a/test/not-string.js +++ b/test/not-string.js @@ -1,8 +1,9 @@ +var Buffer = require('safer-buffer').Buffer var parser = require('../').parser(true) var t = require('tap') t.plan(1) parser.onopentag = function (node) { t.same(node, { name: 'x', attributes: {}, isSelfClosing: false }) } -var xml = new Buffer('y') +var xml = Buffer.from('y') parser.write(xml).close() diff --git a/test/utf8-split.js b/test/utf8-split.js index 80047e2f..130e22b7 100644 --- a/test/utf8-split.js +++ b/test/utf8-split.js @@ -1,23 +1,24 @@ +var Buffer = require('safer-buffer').Buffer var tap = require('tap') var saxStream = require('../lib/sax').createStream() -var b = new Buffer('误') +var b = Buffer.from('误') saxStream.on('text', function (text) { tap.equal(text, b.toString()) }) -saxStream.write(new Buffer('')) +saxStream.write(Buffer.from('')) saxStream.write(b.slice(0, 1)) saxStream.write(b.slice(1)) -saxStream.write(new Buffer('')) +saxStream.write(Buffer.from('')) saxStream.write(b.slice(0, 2)) saxStream.write(b.slice(2)) -saxStream.write(new Buffer('')) +saxStream.write(Buffer.from('')) saxStream.write(b) -saxStream.write(new Buffer('')) -saxStream.write(Buffer.concat([new Buffer(''), b.slice(0, 1)])) -saxStream.end(Buffer.concat([b.slice(1), new Buffer('')])) +saxStream.write(Buffer.from('')) +saxStream.write(Buffer.concat([Buffer.from(''), b.slice(0, 1)])) +saxStream.end(Buffer.concat([b.slice(1), Buffer.from('')])) var saxStream2 = require('../lib/sax').createStream() @@ -25,10 +26,10 @@ saxStream2.on('text', function (text) { tap.equal(text, '�') }) -saxStream2.write(new Buffer('')) -saxStream2.write(new Buffer('')) -saxStream2.write(new Buffer([0xC0])) -saxStream2.write(new Buffer('')) -saxStream2.write(Buffer.concat([new Buffer(''), b.slice(0, 1)])) -saxStream2.write(new Buffer('')) +saxStream2.write(Buffer.from('')) +saxStream2.write(Buffer.from('')) +saxStream2.write(Buffer.from([0xC0])) +saxStream2.write(Buffer.from('')) +saxStream2.write(Buffer.concat([Buffer.from(''), b.slice(0, 1)])) +saxStream2.write(Buffer.from('')) saxStream2.end()