[Pkg-javascript-commits] [uglifyjs] 57/77: Export readNameCache / writeNameCache
Jonas Smedegaard
dr at jones.dk
Tue May 19 00:02:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag v2.4.18
in repository uglifyjs.
commit 80cfd063e20e6779fc03da20cd53e6d05df8a181
Author: Mihai Bazon <mihai.bazon at gmail.com>
Date: Tue Mar 17 10:05:49 2015 +0200
Export readNameCache / writeNameCache
---
bin/uglifyjs | 31 ++-----------------------------
tools/node.js | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 29 deletions(-)
diff --git a/bin/uglifyjs b/bin/uglifyjs
index f2f8f0d..e1deaf5 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -171,38 +171,11 @@ if (ARGS.reserved_file) (function(){
})();
function readNameCache(key) {
- var cache = null;
- if (ARGS.name_cache) {
- try {
- var cache = fs.readFileSync(ARGS.name_cache, "utf8");
- cache = JSON.parse(cache)[key];
- if (!cache) throw "init";
- cache.props = UglifyJS.Dictionary.fromObject(cache.props);
- } catch(ex) {
- cache = {
- cname: -1,
- props: new UglifyJS.Dictionary()
- };
- }
- }
- return cache;
+ return UglifyJS.readNameCache(ARGS.name_cache, key);
}
function writeNameCache(key, cache) {
- if (ARGS.name_cache) {
- var data;
- try {
- data = fs.readFileSync(ARGS.name_cache, "utf8");
- data = JSON.parse(data);
- } catch(ex) {
- data = {};
- }
- data[key] = {
- cname: cache.cname,
- props: cache.props.toObject()
- };
- fs.writeFileSync(ARGS.name_cache, JSON.stringify(data, null, 2), "utf8");
- }
+ return UglifyJS.writeNameCache(ARGS.name_cache, key, cache);
}
if (ARGS.quotes === true) {
diff --git a/tools/node.js b/tools/node.js
index af540e0..a8e734d 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -193,3 +193,38 @@ exports.describe_ast = function() {
doitem(UglifyJS.AST_Node);
return out + "";
};
+
+exports.readNameCache = function(filename, key) {
+ var cache = null;
+ if (filename) {
+ try {
+ var cache = fs.readFileSync(filename, "utf8");
+ cache = JSON.parse(cache)[key];
+ if (!cache) throw "init";
+ cache.props = UglifyJS.Dictionary.fromObject(cache.props);
+ } catch(ex) {
+ cache = {
+ cname: -1,
+ props: new UglifyJS.Dictionary()
+ };
+ }
+ }
+ return cache;
+};
+
+exports.writeNameCache = function(filename, key, cache) {
+ if (filename) {
+ var data;
+ try {
+ data = fs.readFileSync(filename, "utf8");
+ data = JSON.parse(data);
+ } catch(ex) {
+ data = {};
+ }
+ data[key] = {
+ cname: cache.cname,
+ props: cache.props.toObject()
+ };
+ fs.writeFileSync(filename, JSON.stringify(data, null, 2), "utf8");
+ }
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list