uglifier 1.3.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/split.js ADDED
@@ -0,0 +1,117 @@
1
+ /*!
2
+ * Cross-Browser Split 1.1.1
3
+ * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
4
+ * Available under the MIT License
5
+ * ECMAScript compliant, uniform cross-browser split method
6
+ */
7
+
8
+ /**
9
+ * Splits a string into an array of strings using a regex or string separator. Matches of the
10
+ * separator are not included in the result array. However, if `separator` is a regex that contains
11
+ * capturing groups, backreferences are spliced into the result each time `separator` is matched.
12
+ * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
13
+ * cross-browser.
14
+ * @param {String} str String to split.
15
+ * @param {RegExp|String} separator Regex or string to use for separating the string.
16
+ * @param {Number} [limit] Maximum number of items to include in the result array.
17
+ * @returns {Array} Array of substrings.
18
+ * @example
19
+ *
20
+ * // Basic use
21
+ * split('a b c d', ' ');
22
+ * // -> ['a', 'b', 'c', 'd']
23
+ *
24
+ * // With limit
25
+ * split('a b c d', ' ', 2);
26
+ * // -> ['a', 'b']
27
+ *
28
+ * // Backreferences in result array
29
+ * split('..word1 word2..', /([a-z]+)(\d+)/i);
30
+ * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
31
+ */
32
+ var split;
33
+
34
+ // Avoid running twice; that would break the `nativeSplit` reference
35
+ split = split || function (undef) {
36
+
37
+ var nativeSplit = String.prototype.split,
38
+ compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group
39
+ self;
40
+
41
+ self = function (str, separator, limit) {
42
+ // If `separator` is not a regex, use `nativeSplit`
43
+ if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
44
+ return nativeSplit.call(str, separator, limit);
45
+ }
46
+ var output = [],
47
+ flags = (separator.ignoreCase ? "i" : "") +
48
+ (separator.multiline ? "m" : "") +
49
+ (separator.extended ? "x" : "") + // Proposed for ES6
50
+ (separator.sticky ? "y" : ""), // Firefox 3+
51
+ lastLastIndex = 0,
52
+ // Make `global` and avoid `lastIndex` issues by working with a copy
53
+ separator = new RegExp(separator.source, flags + "g"),
54
+ separator2, match, lastIndex, lastLength;
55
+ str += ""; // Type-convert
56
+ if (!compliantExecNpcg) {
57
+ // Doesn't need flags gy, but they don't hurt
58
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
59
+ }
60
+ /* Values for `limit`, per the spec:
61
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
62
+ * If 0, Infinity, or NaN: 0
63
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
64
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
65
+ * If other: Type-convert, then use the above rules
66
+ */
67
+ limit = limit === undef ?
68
+ -1 >>> 0 : // Math.pow(2, 32) - 1
69
+ limit >>> 0; // ToUint32(limit)
70
+ while (match = separator.exec(str)) {
71
+ // `separator.lastIndex` is not reliable cross-browser
72
+ lastIndex = match.index + match[0].length;
73
+ if (lastIndex > lastLastIndex) {
74
+ output.push(str.slice(lastLastIndex, match.index));
75
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
76
+ // nonparticipating capturing groups
77
+ if (!compliantExecNpcg && match.length > 1) {
78
+ match[0].replace(separator2, function () {
79
+ for (var i = 1; i < arguments.length - 2; i++) {
80
+ if (arguments[i] === undef) {
81
+ match[i] = undef;
82
+ }
83
+ }
84
+ });
85
+ }
86
+ if (match.length > 1 && match.index < str.length) {
87
+ Array.prototype.push.apply(output, match.slice(1));
88
+ }
89
+ lastLength = match[0].length;
90
+ lastLastIndex = lastIndex;
91
+ if (output.length >= limit) {
92
+ break;
93
+ }
94
+ }
95
+ if (separator.lastIndex === match.index) {
96
+ separator.lastIndex++; // Avoid an infinite loop
97
+ }
98
+ }
99
+ if (lastLastIndex === str.length) {
100
+ if (lastLength || !separator.test("")) {
101
+ output.push("");
102
+ }
103
+ } else {
104
+ output.push(str.slice(lastLastIndex));
105
+ }
106
+ return output.length > limit ? output.slice(0, limit) : output;
107
+ };
108
+
109
+ if ("\n".split(/\n/).length == 0) {
110
+ String.prototype.split = function (separator, limit) {
111
+ return self(this, separator, limit);
112
+ };
113
+ }
114
+
115
+ return self;
116
+
117
+ }();
@@ -0,0 +1,4 @@
1
+ class Uglifier
2
+ # Current version of Uglifier.
3
+ VERSION = "4.2.0"
4
+ end
data/lib/uglifier.js ADDED
@@ -0,0 +1,49 @@
1
+ // Set source-map.js sourceMap to uglify.js MOZ_SourceMap
2
+ MOZ_SourceMap = sourceMap;
3
+
4
+ function comments(option) {
5
+ if (Object.prototype.toString.call(option) === '[object Array]') {
6
+ return new RegExp(option[0], option[1]);
7
+ } else if (option == "jsdoc") {
8
+ return function(node, comment) {
9
+ if (comment.type == "comment2") {
10
+ return /@preserve|@license|@cc_on/i.test(comment.value);
11
+ } else {
12
+ return false;
13
+ }
14
+ };
15
+ } else {
16
+ return option;
17
+ }
18
+ }
19
+
20
+ function regexOption(options) {
21
+ if (typeof options === 'object' && options.regex) {
22
+ return new RegExp(options.regex[0], options.regex[1]);
23
+ } else {
24
+ return null;
25
+ }
26
+ }
27
+
28
+ function uglifier(options) {
29
+ var source = options.source;
30
+ options.output.comments = comments(options.output.comments);
31
+
32
+ if (options.mangle) {
33
+ if (options.mangle.properties) {
34
+ options.mangle.properties.regex = regexOption(options.mangle.properties);
35
+ }
36
+ }
37
+ delete options.source;
38
+
39
+
40
+ var inputFilename = '0'
41
+ if (options.sourceMap) {
42
+ inputFilename = options.sourceMap.input;
43
+ delete options.sourceMap.input;
44
+ }
45
+
46
+ var inputs = {};
47
+ inputs[inputFilename] = source;
48
+ return UglifyJS.minify(inputs, options);
49
+ }