-
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use the deprecated Buffer() constructor
Fixes: #240 Refs: nodejs/citgm#605 Refs: https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor
- Loading branch information
Showing
3 changed files
with
17 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('<x>y</x>') | ||
var xml = Buffer.from('<x>y</x>') | ||
parser.write(xml).close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
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('<test><a>')) | ||
saxStream.write(Buffer.from('<test><a>')) | ||
saxStream.write(b.slice(0, 1)) | ||
saxStream.write(b.slice(1)) | ||
saxStream.write(new Buffer('</a><b>')) | ||
saxStream.write(Buffer.from('</a><b>')) | ||
saxStream.write(b.slice(0, 2)) | ||
saxStream.write(b.slice(2)) | ||
saxStream.write(new Buffer('</b><c>')) | ||
saxStream.write(Buffer.from('</b><c>')) | ||
saxStream.write(b) | ||
saxStream.write(new Buffer('</c>')) | ||
saxStream.write(Buffer.concat([new Buffer('<d>'), b.slice(0, 1)])) | ||
saxStream.end(Buffer.concat([b.slice(1), new Buffer('</d></test>')])) | ||
saxStream.write(Buffer.from('</c>')) | ||
saxStream.write(Buffer.concat([Buffer.from('<d>'), b.slice(0, 1)])) | ||
saxStream.end(Buffer.concat([b.slice(1), Buffer.from('</d></test>')])) | ||
|
||
var saxStream2 = require('../lib/sax').createStream() | ||
|
||
saxStream2.on('text', function (text) { | ||
tap.equal(text, '�') | ||
}) | ||
|
||
saxStream2.write(new Buffer('<root>')) | ||
saxStream2.write(new Buffer('<e>')) | ||
saxStream2.write(new Buffer([0xC0])) | ||
saxStream2.write(new Buffer('</e>')) | ||
saxStream2.write(Buffer.concat([new Buffer('<f>'), b.slice(0, 1)])) | ||
saxStream2.write(new Buffer('</root>')) | ||
saxStream2.write(Buffer.from('<root>')) | ||
saxStream2.write(Buffer.from('<e>')) | ||
saxStream2.write(Buffer.from([0xC0])) | ||
saxStream2.write(Buffer.from('</e>')) | ||
saxStream2.write(Buffer.concat([Buffer.from('<f>'), b.slice(0, 1)])) | ||
saxStream2.write(Buffer.from('</root>')) | ||
saxStream2.end() |