fix tokenizer on ie8
changes $arrayTokens to use exec instead of split 1 it works on ie8 2 it is faster on chrome http://jsperf.com/capturing-split-vs-exec unfortunately exec is slow on firefox but ff regexes are a bit rusty atm (v21), and whole tokenizer is slow on it anyway.
This commit is contained in:
parent
118c80ce89
commit
77b5ae1062
6 changed files with 51 additions and 13 deletions
38
tool/lib.js
Normal file
38
tool/lib.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
var plist = require("plist");
|
||||
var util = require("util");
|
||||
exports.parsePlist = function(themeXml, callback) {
|
||||
var result = ""
|
||||
plist.parseString(themeXml, function(_, theme) {
|
||||
result = theme[0];
|
||||
callback && callback(theme[0]);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.formatJSON = function(object, initialIndent) {
|
||||
return util.inspect(object, false, 40).replace(/^/gm, initialIndent||"")
|
||||
|
||||
}
|
||||
|
||||
|
||||
exports.fillTemplate = function(template, replacements) {
|
||||
return template.replace(/%(.+?)%/g, function(str, m) {
|
||||
return replacements[m] || "";
|
||||
});
|
||||
}
|
||||
|
||||
exports.hyphenate = function(str) {
|
||||
return str.replace(/([A-Z])/g, "-$1").replace(/_/g, "-").toLowerCase();
|
||||
}
|
||||
|
||||
exports.quoteString = function(str) {
|
||||
return '"' + str.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"';
|
||||
}
|
||||
|
||||
|
||||
exports.restoreJSONComments = function(objStr) {
|
||||
return objStr.replace(/^(\s*)comment: '(.*)'/gm, function(_, i, c) {
|
||||
return i + "//" + c.replace(/\\n(\\t)*/g, "\n" + i + "//") + "\n" + i
|
||||
}).replace(/ \/\/ ERROR/g, '", // ERROR');
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue