From 595d199520ff2c7ddaa4e5b54a072ce44c94c180 Mon Sep 17 00:00:00 2001 From: Leandro Ostera Date: Fri, 8 Nov 2013 23:35:45 -0300 Subject: [PATCH] Unbreaks packages depending on uglify-js running node 0.11.8 --- lib/ast.js | 4 ++-- lib/compress.js | 2 +- lib/output.js | 2 +- lib/parse.js | 6 ++++-- lib/scope.js | 2 +- lib/sourcemap.js | 4 ++-- lib/transform.js | 4 ++-- lib/utils.js | 38 +++++++++++++++++++------------------- test/run-tests.js | 2 +- 9 files changed, 33 insertions(+), 31 deletions(-) diff --git a/lib/ast.js b/lib/ast.js index 0fa48e28..96255a67 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -43,7 +43,7 @@ "use strict"; -function DEFNODE(type, props, methods, base) { +var DEFNODE = function DEFNODE(type, props, methods, base) { if (arguments.length < 4) base = AST_Node; if (!props) props = []; else props = props.split(/\s+/); @@ -918,7 +918,7 @@ var AST_True = DEFNODE("True", null, { /* -----[ TreeWalker ]----- */ -function TreeWalker(callback) { +var TreeWalker = function TreeWalker(callback) { this.visit = callback; this.stack = []; }; diff --git a/lib/compress.js b/lib/compress.js index c60ee19e..b4f95160 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -43,7 +43,7 @@ "use strict"; -function Compressor(options, false_by_default) { +var Compressor = function Compressor(options, false_by_default) { if (!(this instanceof Compressor)) return new Compressor(options, false_by_default); TreeTransformer.call(this, this.before, this.after); diff --git a/lib/output.js b/lib/output.js index 37e30c0e..adb7a37c 100644 --- a/lib/output.js +++ b/lib/output.js @@ -43,7 +43,7 @@ "use strict"; -function OutputStream(options) { +var OutputStream = function OutputStream(options) { options = defaults(options, { indent_start : 0, diff --git a/lib/parse.js b/lib/parse.js index 4933649c..884b4201 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -608,7 +608,9 @@ var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "nam /* -----[ Parser ]----- */ -function parse($TEXT, options) { + + +var parse = function parse($TEXT, options) { options = defaults(options, { strict : false, @@ -1454,4 +1456,4 @@ function parse($TEXT, options) { return toplevel; })(); -}; +}; \ No newline at end of file diff --git a/lib/scope.js b/lib/scope.js index 49b04811..52bef9cd 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -43,7 +43,7 @@ "use strict"; -function SymbolDef(scope, index, orig) { +var SymbolDef = function SymbolDef(scope, index, orig) { this.name = orig.name; this.orig = [ orig ]; this.scope = scope; diff --git a/lib/sourcemap.js b/lib/sourcemap.js index 34299081..059985eb 100644 --- a/lib/sourcemap.js +++ b/lib/sourcemap.js @@ -44,7 +44,7 @@ "use strict"; // a small wrapper around fitzgen's source-map library -function SourceMap(options) { +var SourceMap = function SourceMap(options) { options = defaults(options, { file : null, root : null, @@ -78,4 +78,4 @@ function SourceMap(options) { get : function() { return generator }, toString : function() { return generator.toString() } }; -}; +}; \ No newline at end of file diff --git a/lib/transform.js b/lib/transform.js index c3c34f58..a9df65af 100644 --- a/lib/transform.js +++ b/lib/transform.js @@ -45,7 +45,7 @@ // Tree transformer helpers. -function TreeTransformer(before, after) { +var TreeTransformer = function TreeTransformer(before, after) { TreeWalker.call(this); this.before = before; this.after = after; @@ -215,4 +215,4 @@ TreeTransformer.prototype = new TreeWalker; self.value = self.value.transform(tw); }); -})(); +})(); \ No newline at end of file diff --git a/lib/utils.js b/lib/utils.js index 73964a09..94f7fd6b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -43,36 +43,36 @@ "use strict"; -function array_to_hash(a) { +var array_to_hash = function array_to_hash(a) { var ret = Object.create(null); for (var i = 0; i < a.length; ++i) ret[a[i]] = true; return ret; }; -function slice(a, start) { +var slice = function slice(a, start) { return Array.prototype.slice.call(a, start || 0); }; -function characters(str) { +var characters = function characters(str) { return str.split(""); }; -function member(name, array) { +var member = function member(name, array) { for (var i = array.length; --i >= 0;) if (array[i] == name) return true; return false; }; -function find_if(func, array) { +var find_if = function find_if(func, array) { for (var i = 0, n = array.length; i < n; ++i) { if (func(array[i])) return array[i]; } }; -function repeat_string(str, i) { +var repeat_string = function repeat_string(str, i) { if (i <= 0) return ""; if (i == 1) return str; var d = repeat_string(str, i >> 1); @@ -81,12 +81,12 @@ function repeat_string(str, i) { return d; }; -function DefaultsError(msg, defs) { +var DefaultsError = function DefaultsError(msg, defs) { this.msg = msg; this.defs = defs; }; -function defaults(args, defs, croak) { +var defaults = function defaults(args, defs, croak) { if (args === true) args = {}; var ret = args || {}; @@ -98,14 +98,14 @@ function defaults(args, defs, croak) { return ret; }; -function merge(obj, ext) { +var merge = function merge(obj, ext) { for (var i in ext) if (ext.hasOwnProperty(i)) { obj[i] = ext[i]; } return obj; }; -function noop() {}; +var noop = function noop() {}; var MAP = (function(){ function MAP(a, f, backwards) { @@ -155,24 +155,24 @@ var MAP = (function(){ return MAP; })(); -function push_uniq(array, el) { +var push_uniq = function push_uniq(array, el) { if (array.indexOf(el) < 0) array.push(el); }; -function string_template(text, props) { +var string_template = function string_template(text, props) { return text.replace(/\{(.+?)\}/g, function(str, p){ return props[p]; }); }; -function remove(array, el) { +var remove = function remove(array, el) { for (var i = array.length; --i >= 0;) { if (array[i] === el) array.splice(i, 1); } }; -function mergeSort(array, cmp) { +var mergeSort = function mergeSort(array, cmp) { if (array.length < 2) return array.slice(); function merge(a, b) { var r = [], ai = 0, bi = 0, i = 0; @@ -196,13 +196,13 @@ function mergeSort(array, cmp) { return _ms(array); }; -function set_difference(a, b) { +var set_difference = function set_difference(a, b) { return a.filter(function(el){ return b.indexOf(el) < 0; }); }; -function set_intersection(a, b) { +var set_intersection = function set_intersection(a, b) { return a.filter(function(el){ return b.indexOf(el) >= 0; }); @@ -210,7 +210,7 @@ function set_intersection(a, b) { // this function is taken from Acorn [1], written by Marijn Haverbeke // [1] https://github.com/marijnh/acorn -function makePredicate(words) { +var makePredicate = function makePredicate(words) { if (!(words instanceof Array)) words = words.split(" "); var f = "", cats = []; out: for (var i = 0; i < words.length; ++i) { @@ -245,14 +245,14 @@ function makePredicate(words) { return new Function("str", f); }; -function all(array, predicate) { +var all = function all(array, predicate) { for (var i = array.length; --i >= 0;) if (!predicate(array[i])) return false; return true; }; -function Dictionary() { +var Dictionary = function Dictionary() { this._values = Object.create(null); this._size = 0; }; diff --git a/test/run-tests.js b/test/run-tests.js index f8e88d48..0f358791 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -25,7 +25,7 @@ function tmpl() { function log() { var txt = tmpl.apply(this, arguments); - sys.puts(txt); + console.log(txt); } function log_directory(dir) {