Skip to content

Commit

Permalink
chore: publish v0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJim committed May 6, 2022
1 parent 2e46b23 commit 68d66b1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
26 changes: 19 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class WXMLParser {
return this.inputs[this.pos];
}

getNextString(len) {
return this.inputs.substr(this.pos, len)
}

startWiths(str) {
return this.inputs.substr(this.pos, str.length) === str;
}
Expand All @@ -42,9 +46,18 @@ class WXMLParser {
return this.inputs[this.pos++];
}

consumeWhile(matchFunc) {
consumeCharIgnoreWhitespace() {
const text = this.consumeWhitespace()
// if (text) {
// handlerCompany.call(this, 'text', text);
// }
return this.inputs[this.pos++];
}

consumeWhile(matchFunc, len) {
let result = '';
while (!this.isEOF() && matchFunc(this.getNextChar())) {

while (!this.isEOF() && matchFunc(len ? this.getNextString(len) : this.getNextChar())) {
result += this.consumeChar();
}
return result;
Expand Down Expand Up @@ -129,17 +142,17 @@ class WXMLParser {
}

if (tagName === 'wxs') {
const wxs = this.consumeWhile(char => char !== '<');
const wxs = this.consumeWhile(str => str !== '</wxs', 5);
handlerCompany.call(this, 'wxs', wxs);
} else {
this.parseNodes();
}

assert.ok(this.consumeChar() === '<');
assert.ok(this.consumeChar() === '/');
assert.ok(this.consumeCharIgnoreWhitespace() === '<');
assert.ok(this.consumeCharIgnoreWhitespace() === '/');
let closeTagName = this.parseTagName();
handlerCompany.call(this, 'closetag', closeTagName, false);
assert.ok(this.consumeChar() === '>');
assert.ok(this.consumeCharIgnoreWhitespace() === '>');
}

parseTagName() {
Expand Down Expand Up @@ -216,7 +229,6 @@ let minifier = function(source, options) {
str += `</${tagname}>`;
},
onwxs(wxs) {
console.log(wxs);
str += wxs;
}
});
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wxml-minifier",
"version": "0.0.3",
"version": "0.0.4",
"description": "微信小程序WXML压缩工具",
"main": "dist/index.js",
"scripts": {
Expand All @@ -25,7 +25,7 @@
},
"homepage": "https://github.com/LeeJim/wxml-minifier#readme",
"dependencies": {
"@leejim/wxml-parser": "^0.1.2"
"@leejim/wxml-parser": "^0.1.5"
},
"devDependencies": {
"@vercel/ncc": "^0.33.1",
Expand Down

0 comments on commit 68d66b1

Please sign in to comment.