Comparing version 1.1.0 to 1.1.1
@@ -11,3 +11,3 @@ "use strict"; | ||
ElementStatue[ElementStatue["Complete"] = 3] = "Complete"; | ||
})(ElementStatue = exports.ElementStatue || (exports.ElementStatue = {})); | ||
})(ElementStatue || (exports.ElementStatue = ElementStatue = {})); | ||
class Element { | ||
@@ -42,3 +42,3 @@ constructor(parent) { | ||
if ((_a = this.attrList) === null || _a === void 0 ? void 0 : _a.length) { | ||
this.attribute = utils_1.formatAttr(this.attrList); | ||
this.attribute = (0, utils_1.formatAttr)(this.attrList); | ||
} | ||
@@ -45,0 +45,0 @@ const parent = this.parent; |
@@ -16,7 +16,7 @@ "use strict"; | ||
if (!currentElementNameLength) { | ||
utils_1.error('Element need name'); | ||
(0, utils_1.error)('Element need name'); | ||
} | ||
const nextCharList = xmlChars.splice(0, currentElementNameLength).join(''); | ||
if (nextCharList !== pointer.name) { | ||
utils_1.error('Element need close'); | ||
(0, utils_1.error)('Element need close'); | ||
} | ||
@@ -28,3 +28,3 @@ let next = xmlChars.shift(); | ||
if (next !== '>') { | ||
utils_1.error(`Element end need </${pointer.name}>, ${next}`); | ||
(0, utils_1.error)(`Element end need </${pointer.name}>, ${next}`); | ||
} | ||
@@ -39,3 +39,3 @@ pointer = pointer.end(); | ||
if (valueIndex === -1) { | ||
utils_1.error('CDATA need close'); | ||
(0, utils_1.error)('CDATA need close'); | ||
} | ||
@@ -58,2 +58,5 @@ const cdata = xmlChars.splice(0, valueIndex).join(''); | ||
} | ||
else { | ||
pointer.value(current); | ||
} | ||
} | ||
@@ -60,0 +63,0 @@ else if (current === '>') { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatAttr = exports.error = void 0; | ||
exports.error = (errorMessage) => { | ||
const error = (errorMessage) => { | ||
throw new Error(errorMessage); | ||
}; | ||
exports.formatAttr = (attr) => { | ||
exports.error = error; | ||
const formatAttr = (attr) => { | ||
const attrObj = {}; | ||
@@ -23,3 +24,3 @@ if (!attr || !attr.length) { | ||
if (!key) { | ||
exports.error('xml property name cannot is empty'); | ||
(0, exports.error)('xml property name cannot is empty'); | ||
} | ||
@@ -31,6 +32,6 @@ attrObj[key] = true; | ||
if (!key && !/[a-z_]/i.test(char)) { | ||
exports.error('xml property name must be start with a-z or _, but current is ' + char); | ||
(0, exports.error)('xml property name must be start with a-z or _, but current is ' + char); | ||
} | ||
if (!/[\w-:]/i.test(char)) { | ||
exports.error('xml property name must be use a-z/0-9/-/_'); | ||
(0, exports.error)('xml property name must be use a-z/0-9/-/_'); | ||
} | ||
@@ -47,3 +48,3 @@ key += char; | ||
else if (char !== ' ') { | ||
exports.error('xml property value must be start with \' or "'); | ||
(0, exports.error)('xml property value must be start with \' or "'); | ||
} | ||
@@ -69,1 +70,2 @@ } | ||
}; | ||
exports.formatAttr = formatAttr; |
{ | ||
"name": "dolmx", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "mini xml parser", | ||
@@ -26,3 +26,3 @@ "repository": { | ||
"dev": "tsc --watch", | ||
"build": "tslint -c tslint.json 'src/**/*.ts' & tsc --build", | ||
"build": "tslint -c tslint.json 'src/**/*.ts' && tsc --build", | ||
"test": "jest", | ||
@@ -39,3 +39,3 @@ "coverage": "jest --coverage", | ||
"tslint": "^5.20.1", | ||
"typescript": "^3.5.3", | ||
"typescript": "^5.6.2", | ||
"uglify-js": "^3.6.0" | ||
@@ -42,0 +42,0 @@ }, |
@@ -76,3 +76,3 @@ Dolmx is a **1kb** [XML] parser. | ||
"link": { | ||
"_value": "https:www.zhihu.combillboard" | ||
"_value": "https://www.zhihu.com/billboard" | ||
}, | ||
@@ -108,6 +108,6 @@ "description": { | ||
"guid": { | ||
"_value": "https:www.zhihu.comquestion294345168" | ||
"_value": "https://www.zhihu.com/question/294345168" | ||
}, | ||
"link": { | ||
"_value": "https:www.zhihu.comquestion294345168" | ||
"_value": "https://www.zhihu.com/question/294345168" | ||
} | ||
@@ -114,0 +114,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12820
9
264
0