NPM Dependencies UPDATE
This commit is contained in:
1 parent
20c29bb4d6
commit
a9bfe7a413
599 files changed
+12369
-51423
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "sax",
|
||||
"description": "An evented streaming XML parser in JavaScript",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"version": "0.5.2",
|
||||
"main": "lib/sax.js",
|
||||
"license": "BSD",
|
||||
"scripts": [
|
||||
"lib/sax.js"
|
||||
],
|
||||
"repository": "git://github.com/isaacs/sax-js.git"
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
#!/usr/local/bin/node-bench
|
||||
|
||||
var Promise = require("events").Promise;
|
||||
|
||||
var xml = require("posix").cat("test.xml").wait(),
|
||||
path = require("path"),
|
||||
sax = require("../lib/sax"),
|
||||
saxT = require("../lib/sax-trampoline"),
|
||||
|
||||
parser = sax.parser(false, {trim:true}),
|
||||
parserT = saxT.parser(false, {trim:true}),
|
||||
|
||||
sys = require("sys");
|
||||
|
||||
|
||||
var count = exports.stepsPerLap = 500,
|
||||
l = xml.length,
|
||||
runs = 0;
|
||||
exports.countPerLap = 1000;
|
||||
exports.compare = {
|
||||
"switch" : function () {
|
||||
// sys.debug("switch runs: "+runs++);
|
||||
// for (var x = 0; x < l; x += 1000) {
|
||||
// parser.write(xml.substr(x, 1000))
|
||||
// }
|
||||
// for (var i = 0; i < count; i ++) {
|
||||
parser.write(xml);
|
||||
parser.close();
|
||||
// }
|
||||
// done();
|
||||
},
|
||||
trampoline : function () {
|
||||
// sys.debug("trampoline runs: "+runs++);
|
||||
// for (var x = 0; x < l; x += 1000) {
|
||||
// parserT.write(xml.substr(x, 1000))
|
||||
// }
|
||||
// for (var i = 0; i < count; i ++) {
|
||||
parserT.write(xml);
|
||||
parserT.close();
|
||||
// }
|
||||
// done();
|
||||
},
|
||||
};
|
||||
|
||||
sys.debug("rock and roll...");
|
||||
+50
-10
@@ -133,11 +133,24 @@ function clearBuffers (parser) {
|
||||
}
|
||||
}
|
||||
|
||||
function flushBuffers (parser) {
|
||||
closeText(parser)
|
||||
if (parser.cdata !== "") {
|
||||
emitNode(parser, "oncdata", parser.cdata)
|
||||
parser.cdata = ""
|
||||
}
|
||||
if (parser.script !== "") {
|
||||
emitNode(parser, "onscript", parser.script)
|
||||
parser.script = ""
|
||||
}
|
||||
}
|
||||
|
||||
SAXParser.prototype =
|
||||
{ end: function () { end(this) }
|
||||
, write: write
|
||||
, resume: function () { this.error = null; return this }
|
||||
, close: function () { return this.write(null) }
|
||||
, flush: function () { flushBuffers(this) }
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -179,6 +192,8 @@ function SAXStream (strict, opt) {
|
||||
me._parser.error = null
|
||||
}
|
||||
|
||||
this._decoder = null;
|
||||
|
||||
streamWraps.forEach(function (ev) {
|
||||
Object.defineProperty(me, "on" + ev, {
|
||||
get: function () { return me._parser["on" + ev] },
|
||||
@@ -199,13 +214,23 @@ SAXStream.prototype = Object.create(Stream.prototype,
|
||||
{ constructor: { value: SAXStream } })
|
||||
|
||||
SAXStream.prototype.write = function (data) {
|
||||
if (typeof Buffer === 'function' &&
|
||||
typeof Buffer.isBuffer === 'function' &&
|
||||
Buffer.isBuffer(data)) {
|
||||
if (!this._decoder) {
|
||||
var SD = require('string_decoder').StringDecoder
|
||||
this._decoder = new SD('utf8')
|
||||
}
|
||||
data = this._decoder.write(data);
|
||||
}
|
||||
|
||||
this._parser.write(data.toString())
|
||||
this.emit("data", data)
|
||||
return true
|
||||
}
|
||||
|
||||
SAXStream.prototype.end = function (chunk) {
|
||||
if (chunk && chunk.length) this._parser.write(chunk.toString())
|
||||
if (chunk && chunk.length) this.write(chunk)
|
||||
this._parser.end()
|
||||
return true
|
||||
}
|
||||
@@ -309,6 +334,7 @@ sax.STATE =
|
||||
, ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
|
||||
, ATTRIB_VALUE : S++ // <a foo=
|
||||
, ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
|
||||
, ATTRIB_VALUE_CLOSED : S++ // <a foo="bar"
|
||||
, ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
|
||||
, ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="""
|
||||
, ATTRIB_VALUE_ENTITY_U : S++ // <foo bar="
|
||||
@@ -621,7 +647,7 @@ function error (parser, er) {
|
||||
|
||||
function end (parser) {
|
||||
if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
|
||||
if (parser.state !== S.TEXT) error(parser, "Unexpected end")
|
||||
if ((parser.state !== S.BEGIN) && (parser.state !== S.TEXT)) error(parser, "Unexpected end")
|
||||
closeText(parser)
|
||||
parser.c = ""
|
||||
parser.closed = true
|
||||
@@ -646,14 +672,14 @@ function newTag (parser) {
|
||||
parser.attribList.length = 0
|
||||
}
|
||||
|
||||
function qname (name) {
|
||||
function qname (name, attribute) {
|
||||
var i = name.indexOf(":")
|
||||
, qualName = i < 0 ? [ "", name ] : name.split(":")
|
||||
, prefix = qualName[0]
|
||||
, local = qualName[1]
|
||||
|
||||
// <x "xmlns"="http://foo">
|
||||
if (name === "xmlns") {
|
||||
if (attribute && name === "xmlns") {
|
||||
prefix = "xmlns"
|
||||
local = ""
|
||||
}
|
||||
@@ -664,13 +690,13 @@ function qname (name) {
|
||||
function attrib (parser) {
|
||||
if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
|
||||
|
||||
if (parser.attribList.hasOwnProperty(parser.attribName) ||
|
||||
if (parser.attribList.indexOf(parser.attribName) !== -1 ||
|
||||
parser.tag.attributes.hasOwnProperty(parser.attribName)) {
|
||||
return parser.attribName = parser.attribValue = ""
|
||||
return parser.attribName = parser.attribValue = ""
|
||||
}
|
||||
|
||||
if (parser.opt.xmlns) {
|
||||
var qn = qname(parser.attribName)
|
||||
var qn = qname(parser.attribName, true)
|
||||
, prefix = qn.prefix
|
||||
, local = qn.local
|
||||
|
||||
@@ -719,11 +745,12 @@ function openTag (parser, selfClosing) {
|
||||
var qn = qname(parser.tagName)
|
||||
tag.prefix = qn.prefix
|
||||
tag.local = qn.local
|
||||
tag.uri = tag.ns[qn.prefix] || qn.prefix
|
||||
tag.uri = tag.ns[qn.prefix] || ""
|
||||
|
||||
if (tag.prefix && !tag.uri) {
|
||||
strictFail(parser, "Unbound namespace prefix: "
|
||||
+ JSON.stringify(parser.tagName))
|
||||
tag.uri = qn.prefix
|
||||
}
|
||||
|
||||
var parent = parser.tags[parser.tags.length - 1] || parser
|
||||
@@ -742,7 +769,7 @@ function openTag (parser, selfClosing) {
|
||||
var nv = parser.attribList[i]
|
||||
var name = nv[0]
|
||||
, value = nv[1]
|
||||
, qualName = qname(name)
|
||||
, qualName = qname(name, true)
|
||||
, prefix = qualName.prefix
|
||||
, local = qualName.local
|
||||
, uri = prefix == "" ? "" : (tag.ns[prefix] || "")
|
||||
@@ -1224,7 +1251,20 @@ function write (chunk) {
|
||||
}
|
||||
attrib(parser)
|
||||
parser.q = ""
|
||||
parser.state = S.ATTRIB
|
||||
parser.state = S.ATTRIB_VALUE_CLOSED
|
||||
continue
|
||||
|
||||
case S.ATTRIB_VALUE_CLOSED:
|
||||
if (is(whitespace, c)) {
|
||||
parser.state = S.ATTRIB
|
||||
} else if (c === ">") openTag(parser)
|
||||
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
||||
else if (is(nameStart, c)) {
|
||||
strictFail(parser, "No whitespace between attributes")
|
||||
parser.attribName = c
|
||||
parser.attribValue = ""
|
||||
parser.state = S.ATTRIB_NAME
|
||||
} else strictFail(parser, "Invalid attribute name")
|
||||
continue
|
||||
|
||||
case S.ATTRIB_VALUE_UNQUOTED:
|
||||
|
||||
+14
-17
@@ -1,32 +1,27 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"sax@0.5.2",
|
||||
"C:\\Users\\Luis\\source\\repos\\AACloud"
|
||||
]
|
||||
],
|
||||
"_from": "sax@0.5.2",
|
||||
"_id": "sax@0.5.2",
|
||||
"_from": "sax@0.5.x",
|
||||
"_id": "sax@0.5.8",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-c1/6o5oc/4/7lZjwIjq9sDqfsuo=",
|
||||
"_integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=",
|
||||
"_location": "/sax",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "sax@0.5.2",
|
||||
"raw": "sax@0.5.x",
|
||||
"name": "sax",
|
||||
"escapedName": "sax",
|
||||
"rawSpec": "0.5.2",
|
||||
"rawSpec": "0.5.x",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.5.2"
|
||||
"fetchSpec": "0.5.x"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/xml2js"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/sax/-/sax-0.5.2.tgz",
|
||||
"_spec": "0.5.2",
|
||||
"_where": "C:\\Users\\Luis\\source\\repos\\AACloud",
|
||||
"_resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz",
|
||||
"_shasum": "d472db228eb331c2506b0e8c15524adb939d12c1",
|
||||
"_spec": "sax@0.5.x",
|
||||
"_where": "C:\\Users\\Luis\\source\\repos\\AACloud\\node_modules\\xml2js",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
@@ -35,6 +30,7 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/sax-js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Isaac Z. Schlueter",
|
||||
@@ -73,6 +69,7 @@
|
||||
"email": "mike@emotive.com"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"description": "An evented streaming XML parser in JavaScript",
|
||||
"homepage": "https://github.com/isaacs/sax-js#readme",
|
||||
"license": "BSD",
|
||||
@@ -85,5 +82,5 @@
|
||||
"scripts": {
|
||||
"test": "node test/index.js"
|
||||
},
|
||||
"version": "0.5.2"
|
||||
"version": "0.5.8"
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
require(__dirname).test(
|
||||
{ xml: "<root length='12345'></root>"
|
||||
, expect: [
|
||||
["attribute", {
|
||||
name: "length"
|
||||
, value: "12345"
|
||||
, prefix: ""
|
||||
, local: "length"
|
||||
, uri: ""
|
||||
}]
|
||||
, ["opentag", {
|
||||
name: "root"
|
||||
, prefix: ""
|
||||
, local: "root"
|
||||
, uri: ""
|
||||
, attributes: {
|
||||
length: {
|
||||
name: "length"
|
||||
, value: "12345"
|
||||
, prefix: ""
|
||||
, local: "length"
|
||||
, uri: ""
|
||||
}
|
||||
}
|
||||
, ns: {}
|
||||
, isSelfClosing: false
|
||||
}]
|
||||
, ["closetag", "root"]
|
||||
]
|
||||
, strict: true
|
||||
, opt: { xmlns: true }
|
||||
}
|
||||
)
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// non-strict: no error
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first"attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : { lowercase: true }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: should give an error, but still parse
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first"attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "error", "No whitespace between attributes\nLine: 0\nColumn: 20\nChar: a" ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: other cases should still pass
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first" attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: other cases should still pass
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first"\nattr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: other cases should still pass
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first" attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var saxStream = require('../lib/sax').createStream();
|
||||
assert.doesNotThrow(function() {
|
||||
saxStream.end();
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
var parser = require(__dirname).test({
|
||||
expect: [
|
||||
['opentag', {'name':'T', attributes:{}, isSelfClosing: false}],
|
||||
['text', 'flush'],
|
||||
['text', 'rest'],
|
||||
['closetag', 'T'],
|
||||
]
|
||||
});
|
||||
|
||||
parser.write('<T>flush');
|
||||
parser.flush();
|
||||
parser.write('rest</T>');
|
||||
parser.close();
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
var assert = require('assert')
|
||||
var saxStream = require('../lib/sax').createStream()
|
||||
|
||||
var b = new Buffer('误')
|
||||
|
||||
saxStream.on('text', function(text) {
|
||||
assert.equal(text, b.toString())
|
||||
})
|
||||
|
||||
saxStream.write(new Buffer('<test><a>'))
|
||||
saxStream.write(b.slice(0, 1))
|
||||
saxStream.write(b.slice(1))
|
||||
saxStream.write(new Buffer('</a><b>'))
|
||||
saxStream.write(b.slice(0, 2))
|
||||
saxStream.write(b.slice(2))
|
||||
saxStream.write(new Buffer('</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>')]))
|
||||
|
||||
var saxStream2 = require('../lib/sax').createStream()
|
||||
|
||||
saxStream2.on('text', function(text) {
|
||||
assert.equal(text, '�')
|
||||
});
|
||||
|
||||
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.end();
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<xmlns/>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xmlns", uri: "", prefix: "", local: "xmlns",
|
||||
attributes: {}, ns: {},
|
||||
isSelfClosing: true}
|
||||
],
|
||||
["closetag", "xmlns"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
);
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
require(__dirname).test(
|
||||
{ strict : true
|
||||
, opt : { xmlns: true }
|
||||
, expect :
|
||||
[ [ "error", "Unbound namespace prefix: \"unbound:root\"\nLine: 0\nColumn: 15\nChar: >"]
|
||||
, [ "opentag", { name: "unbound:root", uri: "unbound", prefix: "unbound", local: "root"
|
||||
, attributes: {}, ns: {}, isSelfClosing: true } ]
|
||||
, [ "closetag", "unbound:root" ]
|
||||
]
|
||||
}
|
||||
).write("<unbound:root/>");
|
||||
|
||||
require(__dirname).test(
|
||||
{ strict : true
|
||||
, opt : { xmlns: true }
|
||||
, expect :
|
||||
[ [ "opennamespace", { prefix: "unbound", uri: "someuri" } ]
|
||||
, [ "attribute", { name: 'xmlns:unbound', value: 'someuri'
|
||||
, prefix: 'xmlns', local: 'unbound'
|
||||
, uri: 'http://www.w3.org/2000/xmlns/' } ]
|
||||
, [ "opentag", { name: "unbound:root", uri: "someuri", prefix: "unbound", local: "root"
|
||||
, attributes: { 'xmlns:unbound': {
|
||||
name: 'xmlns:unbound'
|
||||
, value: 'someuri'
|
||||
, prefix: 'xmlns'
|
||||
, local: 'unbound'
|
||||
, uri: 'http://www.w3.org/2000/xmlns/' } }
|
||||
, ns: { "unbound": "someuri" }, isSelfClosing: true } ]
|
||||
, [ "closetag", "unbound:root" ]
|
||||
, [ "closenamespace", { prefix: 'unbound', uri: 'someuri' }]
|
||||
]
|
||||
}
|
||||
).write("<unbound:root xmlns:unbound=\"someuri\"/>");
|
||||
Reference in new issue
Block a user