15013 lines
705 KiB
JavaScript
15013 lines
705 KiB
JavaScript
|
"no use strict";
|
||
|
!(function(window) {
|
||
|
if (typeof window.window != "undefined" && window.document)
|
||
|
return;
|
||
|
if (window.require && window.define)
|
||
|
return;
|
||
|
|
||
|
if (!window.console) {
|
||
|
window.console = function() {
|
||
|
var msgs = Array.prototype.slice.call(arguments, 0);
|
||
|
postMessage({type: "log", data: msgs});
|
||
|
};
|
||
|
window.console.error =
|
||
|
window.console.warn =
|
||
|
window.console.log =
|
||
|
window.console.trace = window.console;
|
||
|
}
|
||
|
window.window = window;
|
||
|
window.ace = window;
|
||
|
|
||
|
window.onerror = function(message, file, line, col, err) {
|
||
|
postMessage({type: "error", data: {
|
||
|
message: message,
|
||
|
data: err.data,
|
||
|
file: file,
|
||
|
line: line,
|
||
|
col: col,
|
||
|
stack: err.stack
|
||
|
}});
|
||
|
};
|
||
|
|
||
|
window.normalizeModule = function(parentId, moduleName) {
|
||
|
// normalize plugin requires
|
||
|
if (moduleName.indexOf("!") !== -1) {
|
||
|
var chunks = moduleName.split("!");
|
||
|
return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
|
||
|
}
|
||
|
// normalize relative requires
|
||
|
if (moduleName.charAt(0) == ".") {
|
||
|
var base = parentId.split("/").slice(0, -1).join("/");
|
||
|
moduleName = (base ? base + "/" : "") + moduleName;
|
||
|
|
||
|
while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
|
||
|
var previous = moduleName;
|
||
|
moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return moduleName;
|
||
|
};
|
||
|
|
||
|
window.require = function require(parentId, id) {
|
||
|
if (!id) {
|
||
|
id = parentId;
|
||
|
parentId = null;
|
||
|
}
|
||
|
if (!id.charAt)
|
||
|
throw new Error("worker.js require() accepts only (parentId, id) as arguments");
|
||
|
|
||
|
id = window.normalizeModule(parentId, id);
|
||
|
|
||
|
var module = window.require.modules[id];
|
||
|
if (module) {
|
||
|
if (!module.initialized) {
|
||
|
module.initialized = true;
|
||
|
module.exports = module.factory().exports;
|
||
|
}
|
||
|
return module.exports;
|
||
|
}
|
||
|
|
||
|
if (!window.require.tlns)
|
||
|
return console.log("unable to load " + id);
|
||
|
|
||
|
var path = resolveModuleId(id, window.require.tlns);
|
||
|
if (path.slice(-3) != ".js") path += ".js";
|
||
|
|
||
|
window.require.id = id;
|
||
|
window.require.modules[id] = {}; // prevent infinite loop on broken modules
|
||
|
importScripts(path);
|
||
|
return window.require(parentId, id);
|
||
|
};
|
||
|
function resolveModuleId(id, paths) {
|
||
|
var testPath = id, tail = "";
|
||
|
while (testPath) {
|
||
|
var alias = paths[testPath];
|
||
|
if (typeof alias == "string") {
|
||
|
return alias + tail;
|
||
|
} else if (alias) {
|
||
|
return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
|
||
|
} else if (alias === false) {
|
||
|
return "";
|
||
|
}
|
||
|
var i = testPath.lastIndexOf("/");
|
||
|
if (i === -1) break;
|
||
|
tail = testPath.substr(i) + tail;
|
||
|
testPath = testPath.slice(0, i);
|
||
|
}
|
||
|
return id;
|
||
|
}
|
||
|
window.require.modules = {};
|
||
|
window.require.tlns = {};
|
||
|
|
||
|
window.define = function(id, deps, factory) {
|
||
|
if (arguments.length == 2) {
|
||
|
factory = deps;
|
||
|
if (typeof id != "string") {
|
||
|
deps = id;
|
||
|
id = window.require.id;
|
||
|
}
|
||
|
} else if (arguments.length == 1) {
|
||
|
factory = id;
|
||
|
deps = [];
|
||
|
id = window.require.id;
|
||
|
}
|
||
|
|
||
|
if (typeof factory != "function") {
|
||
|
window.require.modules[id] = {
|
||
|
exports: factory,
|
||
|
initialized: true
|
||
|
};
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!deps.length)
|
||
|
// If there is no dependencies, we inject "require", "exports" and
|
||
|
// "module" as dependencies, to provide CommonJS compatibility.
|
||
|
deps = ["require", "exports", "module"];
|
||
|
|
||
|
var req = function(childId) {
|
||
|
return window.require(id, childId);
|
||
|
};
|
||
|
|
||
|
window.require.modules[id] = {
|
||
|
exports: {},
|
||
|
factory: function() {
|
||
|
var module = this;
|
||
|
var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
|
||
|
switch (dep) {
|
||
|
// Because "require", "exports" and "module" aren't actual
|
||
|
// dependencies, we must handle them seperately.
|
||
|
case "require": return req;
|
||
|
case "exports": return module.exports;
|
||
|
case "module": return module;
|
||
|
// But for all other dependencies, we can just go ahead and
|
||
|
// require them.
|
||
|
default: return req(dep);
|
||
|
}
|
||
|
}));
|
||
|
if (returnExports)
|
||
|
module.exports = returnExports;
|
||
|
return module;
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
window.define.amd = {};
|
||
|
require.tlns = {};
|
||
|
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
|
||
|
for (var i in topLevelNamespaces)
|
||
|
require.tlns[i] = topLevelNamespaces[i];
|
||
|
};
|
||
|
|
||
|
window.initSender = function initSender() {
|
||
|
|
||
|
var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
|
||
|
var oop = window.require("ace/lib/oop");
|
||
|
|
||
|
var Sender = function() {};
|
||
|
|
||
|
(function() {
|
||
|
|
||
|
oop.implement(this, EventEmitter);
|
||
|
|
||
|
this.callback = function(data, callbackId) {
|
||
|
postMessage({
|
||
|
type: "call",
|
||
|
id: callbackId,
|
||
|
data: data
|
||
|
});
|
||
|
};
|
||
|
|
||
|
this.emit = function(name, data) {
|
||
|
postMessage({
|
||
|
type: "event",
|
||
|
name: name,
|
||
|
data: data
|
||
|
});
|
||
|
};
|
||
|
|
||
|
}).call(Sender.prototype);
|
||
|
|
||
|
return new Sender();
|
||
|
};
|
||
|
|
||
|
var main = window.main = null;
|
||
|
var sender = window.sender = null;
|
||
|
|
||
|
window.onmessage = function(e) {
|
||
|
var msg = e.data;
|
||
|
if (msg.event && sender) {
|
||
|
sender._signal(msg.event, msg.data);
|
||
|
}
|
||
|
else if (msg.command) {
|
||
|
if (main[msg.command])
|
||
|
main[msg.command].apply(main, msg.args);
|
||
|
else if (window[msg.command])
|
||
|
window[msg.command].apply(window, msg.args);
|
||
|
else
|
||
|
throw new Error("Unknown command:" + msg.command);
|
||
|
}
|
||
|
else if (msg.init) {
|
||
|
window.initBaseUrls(msg.tlns);
|
||
|
sender = window.sender = window.initSender();
|
||
|
var clazz = require(msg.module)[msg.classname];
|
||
|
main = window.main = new clazz(sender);
|
||
|
}
|
||
|
};
|
||
|
})(this);
|
||
|
|
||
|
define("ace/lib/oop",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
exports.inherits = function(ctor, superCtor) {
|
||
|
ctor.super_ = superCtor;
|
||
|
ctor.prototype = Object.create(superCtor.prototype, {
|
||
|
constructor: {
|
||
|
value: ctor,
|
||
|
enumerable: false,
|
||
|
writable: true,
|
||
|
configurable: true
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
exports.mixin = function(obj, mixin) {
|
||
|
for (var key in mixin) {
|
||
|
obj[key] = mixin[key];
|
||
|
}
|
||
|
return obj;
|
||
|
};
|
||
|
|
||
|
exports.implement = function(proto, mixin) {
|
||
|
exports.mixin(proto, mixin);
|
||
|
};
|
||
|
|
||
|
});
|
||
|
|
||
|
define("ace/range",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
var comparePoints = function(p1, p2) {
|
||
|
return p1.row - p2.row || p1.column - p2.column;
|
||
|
};
|
||
|
var Range = function(startRow, startColumn, endRow, endColumn) {
|
||
|
this.start = {
|
||
|
row: startRow,
|
||
|
column: startColumn
|
||
|
};
|
||
|
|
||
|
this.end = {
|
||
|
row: endRow,
|
||
|
column: endColumn
|
||
|
};
|
||
|
};
|
||
|
|
||
|
(function() {
|
||
|
this.isEqual = function(range) {
|
||
|
return this.start.row === range.start.row &&
|
||
|
this.end.row === range.end.row &&
|
||
|
this.start.column === range.start.column &&
|
||
|
this.end.column === range.end.column;
|
||
|
};
|
||
|
this.toString = function() {
|
||
|
return ("Range: [" + this.start.row + "/" + this.start.column +
|
||
|
"] -> [" + this.end.row + "/" + this.end.column + "]");
|
||
|
};
|
||
|
|
||
|
this.contains = function(row, column) {
|
||
|
return this.compare(row, column) == 0;
|
||
|
};
|
||
|
this.compareRange = function(range) {
|
||
|
var cmp,
|
||
|
end = range.end,
|
||
|
start = range.start;
|
||
|
|
||
|
cmp = this.compare(end.row, end.column);
|
||
|
if (cmp == 1) {
|
||
|
cmp = this.compare(start.row, start.column);
|
||
|
if (cmp == 1) {
|
||
|
return 2;
|
||
|
} else if (cmp == 0) {
|
||
|
return 1;
|
||
|
} else {
|
||
|
return 0;
|
||
|
}
|
||
|
} else if (cmp == -1) {
|
||
|
return -2;
|
||
|
} else {
|
||
|
cmp = this.compare(start.row, start.column);
|
||
|
if (cmp == -1) {
|
||
|
return -1;
|
||
|
} else if (cmp == 1) {
|
||
|
return 42;
|
||
|
} else {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
this.comparePoint = function(p) {
|
||
|
return this.compare(p.row, p.column);
|
||
|
};
|
||
|
this.containsRange = function(range) {
|
||
|
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
|
||
|
};
|
||
|
this.intersects = function(range) {
|
||
|
var cmp = this.compareRange(range);
|
||
|
return (cmp == -1 || cmp == 0 || cmp == 1);
|
||
|
};
|
||
|
this.isEnd = function(row, column) {
|
||
|
return this.end.row == row && this.end.column == column;
|
||
|
};
|
||
|
this.isStart = function(row, column) {
|
||
|
return this.start.row == row && this.start.column == column;
|
||
|
};
|
||
|
this.setStart = function(row, column) {
|
||
|
if (typeof row == "object") {
|
||
|
this.start.column = row.column;
|
||
|
this.start.row = row.row;
|
||
|
} else {
|
||
|
this.start.row = row;
|
||
|
this.start.column = column;
|
||
|
}
|
||
|
};
|
||
|
this.setEnd = function(row, column) {
|
||
|
if (typeof row == "object") {
|
||
|
this.end.column = row.column;
|
||
|
this.end.row = row.row;
|
||
|
} else {
|
||
|
this.end.row = row;
|
||
|
this.end.column = column;
|
||
|
}
|
||
|
};
|
||
|
this.inside = function(row, column) {
|
||
|
if (this.compare(row, column) == 0) {
|
||
|
if (this.isEnd(row, column) || this.isStart(row, column)) {
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
};
|
||
|
this.insideStart = function(row, column) {
|
||
|
if (this.compare(row, column) == 0) {
|
||
|
if (this.isEnd(row, column)) {
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
};
|
||
|
this.insideEnd = function(row, column) {
|
||
|
if (this.compare(row, column) == 0) {
|
||
|
if (this.isStart(row, column)) {
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
};
|
||
|
this.compare = function(row, column) {
|
||
|
if (!this.isMultiLine()) {
|
||
|
if (row === this.start.row) {
|
||
|
return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (row < this.start.row)
|
||
|
return -1;
|
||
|
|
||
|
if (row > this.end.row)
|
||
|
return 1;
|
||
|
|
||
|
if (this.start.row === row)
|
||
|
return column >= this.start.column ? 0 : -1;
|
||
|
|
||
|
if (this.end.row === row)
|
||
|
return column <= this.end.column ? 0 : 1;
|
||
|
|
||
|
return 0;
|
||
|
};
|
||
|
this.compareStart = function(row, column) {
|
||
|
if (this.start.row == row && this.start.column == column) {
|
||
|
return -1;
|
||
|
} else {
|
||
|
return this.compare(row, column);
|
||
|
}
|
||
|
};
|
||
|
this.compareEnd = function(row, column) {
|
||
|
if (this.end.row == row && this.end.column == column) {
|
||
|
return 1;
|
||
|
} else {
|
||
|
return this.compare(row, column);
|
||
|
}
|
||
|
};
|
||
|
this.compareInside = function(row, column) {
|
||
|
if (this.end.row == row && this.end.column == column) {
|
||
|
return 1;
|
||
|
} else if (this.start.row == row && this.start.column == column) {
|
||
|
return -1;
|
||
|
} else {
|
||
|
return this.compare(row, column);
|
||
|
}
|
||
|
};
|
||
|
this.clipRows = function(firstRow, lastRow) {
|
||
|
if (this.end.row > lastRow)
|
||
|
var end = {row: lastRow + 1, column: 0};
|
||
|
else if (this.end.row < firstRow)
|
||
|
var end = {row: firstRow, column: 0};
|
||
|
|
||
|
if (this.start.row > lastRow)
|
||
|
var start = {row: lastRow + 1, column: 0};
|
||
|
else if (this.start.row < firstRow)
|
||
|
var start = {row: firstRow, column: 0};
|
||
|
|
||
|
return Range.fromPoints(start || this.start, end || this.end);
|
||
|
};
|
||
|
this.extend = function(row, column) {
|
||
|
var cmp = this.compare(row, column);
|
||
|
|
||
|
if (cmp == 0)
|
||
|
return this;
|
||
|
else if (cmp == -1)
|
||
|
var start = {row: row, column: column};
|
||
|
else
|
||
|
var end = {row: row, column: column};
|
||
|
|
||
|
return Range.fromPoints(start || this.start, end || this.end);
|
||
|
};
|
||
|
|
||
|
this.isEmpty = function() {
|
||
|
return (this.start.row === this.end.row && this.start.column === this.end.column);
|
||
|
};
|
||
|
this.isMultiLine = function() {
|
||
|
return (this.start.row !== this.end.row);
|
||
|
};
|
||
|
this.clone = function() {
|
||
|
return Range.fromPoints(this.start, this.end);
|
||
|
};
|
||
|
this.collapseRows = function() {
|
||
|
if (this.end.column == 0)
|
||
|
return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
|
||
|
else
|
||
|
return new Range(this.start.row, 0, this.end.row, 0);
|
||
|
};
|
||
|
this.toScreenRange = function(session) {
|
||
|
var screenPosStart = session.documentToScreenPosition(this.start);
|
||
|
var screenPosEnd = session.documentToScreenPosition(this.end);
|
||
|
|
||
|
return new Range(
|
||
|
screenPosStart.row, screenPosStart.column,
|
||
|
screenPosEnd.row, screenPosEnd.column
|
||
|
);
|
||
|
};
|
||
|
this.moveBy = function(row, column) {
|
||
|
this.start.row += row;
|
||
|
this.start.column += column;
|
||
|
this.end.row += row;
|
||
|
this.end.column += column;
|
||
|
};
|
||
|
|
||
|
}).call(Range.prototype);
|
||
|
Range.fromPoints = function(start, end) {
|
||
|
return new Range(start.row, start.column, end.row, end.column);
|
||
|
};
|
||
|
Range.comparePoints = comparePoints;
|
||
|
|
||
|
Range.comparePoints = function(p1, p2) {
|
||
|
return p1.row - p2.row || p1.column - p2.column;
|
||
|
};
|
||
|
|
||
|
|
||
|
exports.Range = Range;
|
||
|
});
|
||
|
|
||
|
define("ace/apply_delta",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
function throwDeltaError(delta, errorText){
|
||
|
console.log("Invalid Delta:", delta);
|
||
|
throw "Invalid Delta: " + errorText;
|
||
|
}
|
||
|
|
||
|
function positionInDocument(docLines, position) {
|
||
|
return position.row >= 0 && position.row < docLines.length &&
|
||
|
position.column >= 0 && position.column <= docLines[position.row].length;
|
||
|
}
|
||
|
|
||
|
function validateDelta(docLines, delta) {
|
||
|
if (delta.action != "insert" && delta.action != "remove")
|
||
|
throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
|
||
|
if (!(delta.lines instanceof Array))
|
||
|
throwDeltaError(delta, "delta.lines must be an Array");
|
||
|
if (!delta.start || !delta.end)
|
||
|
throwDeltaError(delta, "delta.start/end must be an present");
|
||
|
var start = delta.start;
|
||
|
if (!positionInDocument(docLines, delta.start))
|
||
|
throwDeltaError(delta, "delta.start must be contained in document");
|
||
|
var end = delta.end;
|
||
|
if (delta.action == "remove" && !positionInDocument(docLines, end))
|
||
|
throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
|
||
|
var numRangeRows = end.row - start.row;
|
||
|
var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
|
||
|
if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
|
||
|
throwDeltaError(delta, "delta.range must match delta lines");
|
||
|
}
|
||
|
|
||
|
exports.applyDelta = function(docLines, delta, doNotValidate) {
|
||
|
|
||
|
var row = delta.start.row;
|
||
|
var startColumn = delta.start.column;
|
||
|
var line = docLines[row] || "";
|
||
|
switch (delta.action) {
|
||
|
case "insert":
|
||
|
var lines = delta.lines;
|
||
|
if (lines.length === 1) {
|
||
|
docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
|
||
|
} else {
|
||
|
var args = [row, 1].concat(delta.lines);
|
||
|
docLines.splice.apply(docLines, args);
|
||
|
docLines[row] = line.substring(0, startColumn) + docLines[row];
|
||
|
docLines[row + delta.lines.length - 1] += line.substring(startColumn);
|
||
|
}
|
||
|
break;
|
||
|
case "remove":
|
||
|
var endColumn = delta.end.column;
|
||
|
var endRow = delta.end.row;
|
||
|
if (row === endRow) {
|
||
|
docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
|
||
|
} else {
|
||
|
docLines.splice(
|
||
|
row, endRow - row + 1,
|
||
|
line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
|
||
|
);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
};
|
||
|
});
|
||
|
|
||
|
define("ace/lib/event_emitter",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
var EventEmitter = {};
|
||
|
var stopPropagation = function() { this.propagationStopped = true; };
|
||
|
var preventDefault = function() { this.defaultPrevented = true; };
|
||
|
|
||
|
EventEmitter._emit =
|
||
|
EventEmitter._dispatchEvent = function(eventName, e) {
|
||
|
this._eventRegistry || (this._eventRegistry = {});
|
||
|
this._defaultHandlers || (this._defaultHandlers = {});
|
||
|
|
||
|
var listeners = this._eventRegistry[eventName] || [];
|
||
|
var defaultHandler = this._defaultHandlers[eventName];
|
||
|
if (!listeners.length && !defaultHandler)
|
||
|
return;
|
||
|
|
||
|
if (typeof e != "object" || !e)
|
||
|
e = {};
|
||
|
|
||
|
if (!e.type)
|
||
|
e.type = eventName;
|
||
|
if (!e.stopPropagation)
|
||
|
e.stopPropagation = stopPropagation;
|
||
|
if (!e.preventDefault)
|
||
|
e.preventDefault = preventDefault;
|
||
|
|
||
|
listeners = listeners.slice();
|
||
|
for (var i=0; i<listeners.length; i++) {
|
||
|
listeners[i](e, this);
|
||
|
if (e.propagationStopped)
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (defaultHandler && !e.defaultPrevented)
|
||
|
return defaultHandler(e, this);
|
||
|
};
|
||
|
|
||
|
|
||
|
EventEmitter._signal = function(eventName, e) {
|
||
|
var listeners = (this._eventRegistry || {})[eventName];
|
||
|
if (!listeners)
|
||
|
return;
|
||
|
listeners = listeners.slice();
|
||
|
for (var i=0; i<listeners.length; i++)
|
||
|
listeners[i](e, this);
|
||
|
};
|
||
|
|
||
|
EventEmitter.once = function(eventName, callback) {
|
||
|
var _self = this;
|
||
|
this.on(eventName, function newCallback() {
|
||
|
_self.off(eventName, newCallback);
|
||
|
callback.apply(null, arguments);
|
||
|
});
|
||
|
if (!callback) {
|
||
|
return new Promise(function(resolve) {
|
||
|
callback = resolve;
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
EventEmitter.setDefaultHandler = function(eventName, callback) {
|
||
|
var handlers = this._defaultHandlers;
|
||
|
if (!handlers)
|
||
|
handlers = this._defaultHandlers = {_disabled_: {}};
|
||
|
|
||
|
if (handlers[eventName]) {
|
||
|
var old = handlers[eventName];
|
||
|
var disabled = handlers._disabled_[eventName];
|
||
|
if (!disabled)
|
||
|
handlers._disabled_[eventName] = disabled = [];
|
||
|
disabled.push(old);
|
||
|
var i = disabled.indexOf(callback);
|
||
|
if (i != -1)
|
||
|
disabled.splice(i, 1);
|
||
|
}
|
||
|
handlers[eventName] = callback;
|
||
|
};
|
||
|
EventEmitter.removeDefaultHandler = function(eventName, callback) {
|
||
|
var handlers = this._defaultHandlers;
|
||
|
if (!handlers)
|
||
|
return;
|
||
|
var disabled = handlers._disabled_[eventName];
|
||
|
|
||
|
if (handlers[eventName] == callback) {
|
||
|
if (disabled)
|
||
|
this.setDefaultHandler(eventName, disabled.pop());
|
||
|
} else if (disabled) {
|
||
|
var i = disabled.indexOf(callback);
|
||
|
if (i != -1)
|
||
|
disabled.splice(i, 1);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
EventEmitter.on =
|
||
|
EventEmitter.addEventListener = function(eventName, callback, capturing) {
|
||
|
this._eventRegistry = this._eventRegistry || {};
|
||
|
|
||
|
var listeners = this._eventRegistry[eventName];
|
||
|
if (!listeners)
|
||
|
listeners = this._eventRegistry[eventName] = [];
|
||
|
|
||
|
if (listeners.indexOf(callback) == -1)
|
||
|
listeners[capturing ? "unshift" : "push"](callback);
|
||
|
return callback;
|
||
|
};
|
||
|
|
||
|
EventEmitter.off =
|
||
|
EventEmitter.removeListener =
|
||
|
EventEmitter.removeEventListener = function(eventName, callback) {
|
||
|
this._eventRegistry = this._eventRegistry || {};
|
||
|
|
||
|
var listeners = this._eventRegistry[eventName];
|
||
|
if (!listeners)
|
||
|
return;
|
||
|
|
||
|
var index = listeners.indexOf(callback);
|
||
|
if (index !== -1)
|
||
|
listeners.splice(index, 1);
|
||
|
};
|
||
|
|
||
|
EventEmitter.removeAllListeners = function(eventName) {
|
||
|
if (!eventName) this._eventRegistry = this._defaultHandlers = undefined;
|
||
|
if (this._eventRegistry) this._eventRegistry[eventName] = undefined;
|
||
|
if (this._defaultHandlers) this._defaultHandlers[eventName] = undefined;
|
||
|
};
|
||
|
|
||
|
exports.EventEmitter = EventEmitter;
|
||
|
|
||
|
});
|
||
|
|
||
|
define("ace/anchor",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
var oop = require("./lib/oop");
|
||
|
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||
|
|
||
|
var Anchor = exports.Anchor = function(doc, row, column) {
|
||
|
this.$onChange = this.onChange.bind(this);
|
||
|
this.attach(doc);
|
||
|
|
||
|
if (typeof column == "undefined")
|
||
|
this.setPosition(row.row, row.column);
|
||
|
else
|
||
|
this.setPosition(row, column);
|
||
|
};
|
||
|
|
||
|
(function() {
|
||
|
|
||
|
oop.implement(this, EventEmitter);
|
||
|
this.getPosition = function() {
|
||
|
return this.$clipPositionToDocument(this.row, this.column);
|
||
|
};
|
||
|
this.getDocument = function() {
|
||
|
return this.document;
|
||
|
};
|
||
|
this.$insertRight = false;
|
||
|
this.onChange = function(delta) {
|
||
|
if (delta.start.row == delta.end.row && delta.start.row != this.row)
|
||
|
return;
|
||
|
|
||
|
if (delta.start.row > this.row)
|
||
|
return;
|
||
|
|
||
|
var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
|
||
|
this.setPosition(point.row, point.column, true);
|
||
|
};
|
||
|
|
||
|
function $pointsInOrder(point1, point2, equalPointsInOrder) {
|
||
|
var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
|
||
|
return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
|
||
|
}
|
||
|
|
||
|
function $getTransformedPoint(delta, point, moveIfEqual) {
|
||
|
var deltaIsInsert = delta.action == "insert";
|
||
|
var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
|
||
|
var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
|
||
|
var deltaStart = delta.start;
|
||
|
var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
|
||
|
if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
|
||
|
return {
|
||
|
row: point.row,
|
||
|
column: point.column
|
||
|
};
|
||
|
}
|
||
|
if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
|
||
|
return {
|
||
|
row: point.row + deltaRowShift,
|
||
|
column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
row: deltaStart.row,
|
||
|
column: deltaStart.column
|
||
|
};
|
||
|
}
|
||
|
this.setPosition = function(row, column, noClip) {
|
||
|
var pos;
|
||
|
if (noClip) {
|
||
|
pos = {
|
||
|
row: row,
|
||
|
column: column
|
||
|
};
|
||
|
} else {
|
||
|
pos = this.$clipPositionToDocument(row, column);
|
||
|
}
|
||
|
|
||
|
if (this.row == pos.row && this.column == pos.column)
|
||
|
return;
|
||
|
|
||
|
var old = {
|
||
|
row: this.row,
|
||
|
column: this.column
|
||
|
};
|
||
|
|
||
|
this.row = pos.row;
|
||
|
this.column = pos.column;
|
||
|
this._signal("change", {
|
||
|
old: old,
|
||
|
value: pos
|
||
|
});
|
||
|
};
|
||
|
this.detach = function() {
|
||
|
this.document.off("change", this.$onChange);
|
||
|
};
|
||
|
this.attach = function(doc) {
|
||
|
this.document = doc || this.document;
|
||
|
this.document.on("change", this.$onChange);
|
||
|
};
|
||
|
this.$clipPositionToDocument = function(row, column) {
|
||
|
var pos = {};
|
||
|
|
||
|
if (row >= this.document.getLength()) {
|
||
|
pos.row = Math.max(0, this.document.getLength() - 1);
|
||
|
pos.column = this.document.getLine(pos.row).length;
|
||
|
}
|
||
|
else if (row < 0) {
|
||
|
pos.row = 0;
|
||
|
pos.column = 0;
|
||
|
}
|
||
|
else {
|
||
|
pos.row = row;
|
||
|
pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
|
||
|
}
|
||
|
|
||
|
if (column < 0)
|
||
|
pos.column = 0;
|
||
|
|
||
|
return pos;
|
||
|
};
|
||
|
|
||
|
}).call(Anchor.prototype);
|
||
|
|
||
|
});
|
||
|
|
||
|
define("ace/document",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
var oop = require("./lib/oop");
|
||
|
var applyDelta = require("./apply_delta").applyDelta;
|
||
|
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||
|
var Range = require("./range").Range;
|
||
|
var Anchor = require("./anchor").Anchor;
|
||
|
|
||
|
var Document = function(textOrLines) {
|
||
|
this.$lines = [""];
|
||
|
if (textOrLines.length === 0) {
|
||
|
this.$lines = [""];
|
||
|
} else if (Array.isArray(textOrLines)) {
|
||
|
this.insertMergedLines({row: 0, column: 0}, textOrLines);
|
||
|
} else {
|
||
|
this.insert({row: 0, column:0}, textOrLines);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
(function() {
|
||
|
|
||
|
oop.implement(this, EventEmitter);
|
||
|
this.setValue = function(text) {
|
||
|
var len = this.getLength() - 1;
|
||
|
this.remove(new Range(0, 0, len, this.getLine(len).length));
|
||
|
this.insert({row: 0, column: 0}, text);
|
||
|
};
|
||
|
this.getValue = function() {
|
||
|
return this.getAllLines().join(this.getNewLineCharacter());
|
||
|
};
|
||
|
this.createAnchor = function(row, column) {
|
||
|
return new Anchor(this, row, column);
|
||
|
};
|
||
|
if ("aaa".split(/a/).length === 0) {
|
||
|
this.$split = function(text) {
|
||
|
return text.replace(/\r\n|\r/g, "\n").split("\n");
|
||
|
};
|
||
|
} else {
|
||
|
this.$split = function(text) {
|
||
|
return text.split(/\r\n|\r|\n/);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
|
||
|
this.$detectNewLine = function(text) {
|
||
|
var match = text.match(/^.*?(\r\n|\r|\n)/m);
|
||
|
this.$autoNewLine = match ? match[1] : "\n";
|
||
|
this._signal("changeNewLineMode");
|
||
|
};
|
||
|
this.getNewLineCharacter = function() {
|
||
|
switch (this.$newLineMode) {
|
||
|
case "windows":
|
||
|
return "\r\n";
|
||
|
case "unix":
|
||
|
return "\n";
|
||
|
default:
|
||
|
return this.$autoNewLine || "\n";
|
||
|
}
|
||
|
};
|
||
|
|
||
|
this.$autoNewLine = "";
|
||
|
this.$newLineMode = "auto";
|
||
|
this.setNewLineMode = function(newLineMode) {
|
||
|
if (this.$newLineMode === newLineMode)
|
||
|
return;
|
||
|
|
||
|
this.$newLineMode = newLineMode;
|
||
|
this._signal("changeNewLineMode");
|
||
|
};
|
||
|
this.getNewLineMode = function() {
|
||
|
return this.$newLineMode;
|
||
|
};
|
||
|
this.isNewLine = function(text) {
|
||
|
return (text == "\r\n" || text == "\r" || text == "\n");
|
||
|
};
|
||
|
this.getLine = function(row) {
|
||
|
return this.$lines[row] || "";
|
||
|
};
|
||
|
this.getLines = function(firstRow, lastRow) {
|
||
|
return this.$lines.slice(firstRow, lastRow + 1);
|
||
|
};
|
||
|
this.getAllLines = function() {
|
||
|
return this.getLines(0, this.getLength());
|
||
|
};
|
||
|
this.getLength = function() {
|
||
|
return this.$lines.length;
|
||
|
};
|
||
|
this.getTextRange = function(range) {
|
||
|
return this.getLinesForRange(range).join(this.getNewLineCharacter());
|
||
|
};
|
||
|
this.getLinesForRange = function(range) {
|
||
|
var lines;
|
||
|
if (range.start.row === range.end.row) {
|
||
|
lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
|
||
|
} else {
|
||
|
lines = this.getLines(range.start.row, range.end.row);
|
||
|
lines[0] = (lines[0] || "").substring(range.start.column);
|
||
|
var l = lines.length - 1;
|
||
|
if (range.end.row - range.start.row == l)
|
||
|
lines[l] = lines[l].substring(0, range.end.column);
|
||
|
}
|
||
|
return lines;
|
||
|
};
|
||
|
this.insertLines = function(row, lines) {
|
||
|
console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
|
||
|
return this.insertFullLines(row, lines);
|
||
|
};
|
||
|
this.removeLines = function(firstRow, lastRow) {
|
||
|
console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
|
||
|
return this.removeFullLines(firstRow, lastRow);
|
||
|
};
|
||
|
this.insertNewLine = function(position) {
|
||
|
console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
|
||
|
return this.insertMergedLines(position, ["", ""]);
|
||
|
};
|
||
|
this.insert = function(position, text) {
|
||
|
if (this.getLength() <= 1)
|
||
|
this.$detectNewLine(text);
|
||
|
|
||
|
return this.insertMergedLines(position, this.$split(text));
|
||
|
};
|
||
|
this.insertInLine = function(position, text) {
|
||
|
var start = this.clippedPos(position.row, position.column);
|
||
|
var end = this.pos(position.row, position.column + text.length);
|
||
|
|
||
|
this.applyDelta({
|
||
|
start: start,
|
||
|
end: end,
|
||
|
action: "insert",
|
||
|
lines: [text]
|
||
|
}, true);
|
||
|
|
||
|
return this.clonePos(end);
|
||
|
};
|
||
|
|
||
|
this.clippedPos = function(row, column) {
|
||
|
var length = this.getLength();
|
||
|
if (row === undefined) {
|
||
|
row = length;
|
||
|
} else if (row < 0) {
|
||
|
row = 0;
|
||
|
} else if (row >= length) {
|
||
|
row = length - 1;
|
||
|
column = undefined;
|
||
|
}
|
||
|
var line = this.getLine(row);
|
||
|
if (column == undefined)
|
||
|
column = line.length;
|
||
|
column = Math.min(Math.max(column, 0), line.length);
|
||
|
return {row: row, column: column};
|
||
|
};
|
||
|
|
||
|
this.clonePos = function(pos) {
|
||
|
return {row: pos.row, column: pos.column};
|
||
|
};
|
||
|
|
||
|
this.pos = function(row, column) {
|
||
|
return {row: row, column: column};
|
||
|
};
|
||
|
|
||
|
this.$clipPosition = function(position) {
|
||
|
var length = this.getLength();
|
||
|
if (position.row >= length) {
|
||
|
position.row = Math.max(0, length - 1);
|
||
|
position.column = this.getLine(length - 1).length;
|
||
|
} else {
|
||
|
position.row = Math.max(0, position.row);
|
||
|
position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
|
||
|
}
|
||
|
return position;
|
||
|
};
|
||
|
this.insertFullLines = function(row, lines) {
|
||
|
row = Math.min(Math.max(row, 0), this.getLength());
|
||
|
var column = 0;
|
||
|
if (row < this.getLength()) {
|
||
|
lines = lines.concat([""]);
|
||
|
column = 0;
|
||
|
} else {
|
||
|
lines = [""].concat(lines);
|
||
|
row--;
|
||
|
column = this.$lines[row].length;
|
||
|
}
|
||
|
this.insertMergedLines({row: row, column: column}, lines);
|
||
|
};
|
||
|
this.insertMergedLines = function(position, lines) {
|
||
|
var start = this.clippedPos(position.row, position.column);
|
||
|
var end = {
|
||
|
row: start.row + lines.length - 1,
|
||
|
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
|
||
|
};
|
||
|
|
||
|
this.applyDelta({
|
||
|
start: start,
|
||
|
end: end,
|
||
|
action: "insert",
|
||
|
lines: lines
|
||
|
});
|
||
|
|
||
|
return this.clonePos(end);
|
||
|
};
|
||
|
this.remove = function(range) {
|
||
|
var start = this.clippedPos(range.start.row, range.start.column);
|
||
|
var end = this.clippedPos(range.end.row, range.end.column);
|
||
|
this.applyDelta({
|
||
|
start: start,
|
||
|
end: end,
|
||
|
action: "remove",
|
||
|
lines: this.getLinesForRange({start: start, end: end})
|
||
|
});
|
||
|
return this.clonePos(start);
|
||
|
};
|
||
|
this.removeInLine = function(row, startColumn, endColumn) {
|
||
|
var start = this.clippedPos(row, startColumn);
|
||
|
var end = this.clippedPos(row, endColumn);
|
||
|
|
||
|
this.applyDelta({
|
||
|
start: start,
|
||
|
end: end,
|
||
|
action: "remove",
|
||
|
lines: this.getLinesForRange({start: start, end: end})
|
||
|
}, true);
|
||
|
|
||
|
return this.clonePos(start);
|
||
|
};
|
||
|
this.removeFullLines = function(firstRow, lastRow) {
|
||
|
firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
|
||
|
lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
|
||
|
var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
|
||
|
var deleteLastNewLine = lastRow < this.getLength() - 1;
|
||
|
var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
|
||
|
var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
|
||
|
var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
|
||
|
var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
|
||
|
var range = new Range(startRow, startCol, endRow, endCol);
|
||
|
var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
|
||
|
|
||
|
this.applyDelta({
|
||
|
start: range.start,
|
||
|
end: range.end,
|
||
|
action: "remove",
|
||
|
lines: this.getLinesForRange(range)
|
||
|
});
|
||
|
return deletedLines;
|
||
|
};
|
||
|
this.removeNewLine = function(row) {
|
||
|
if (row < this.getLength() - 1 && row >= 0) {
|
||
|
this.applyDelta({
|
||
|
start: this.pos(row, this.getLine(row).length),
|
||
|
end: this.pos(row + 1, 0),
|
||
|
action: "remove",
|
||
|
lines: ["", ""]
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
this.replace = function(range, text) {
|
||
|
if (!(range instanceof Range))
|
||
|
range = Range.fromPoints(range.start, range.end);
|
||
|
if (text.length === 0 && range.isEmpty())
|
||
|
return range.start;
|
||
|
if (text == this.getTextRange(range))
|
||
|
return range.end;
|
||
|
|
||
|
this.remove(range);
|
||
|
var end;
|
||
|
if (text) {
|
||
|
end = this.insert(range.start, text);
|
||
|
}
|
||
|
else {
|
||
|
end = range.start;
|
||
|
}
|
||
|
|
||
|
return end;
|
||
|
};
|
||
|
this.applyDeltas = function(deltas) {
|
||
|
for (var i=0; i<deltas.length; i++) {
|
||
|
this.applyDelta(deltas[i]);
|
||
|
}
|
||
|
};
|
||
|
this.revertDeltas = function(deltas) {
|
||
|
for (var i=deltas.length-1; i>=0; i--) {
|
||
|
this.revertDelta(deltas[i]);
|
||
|
}
|
||
|
};
|
||
|
this.applyDelta = function(delta, doNotValidate) {
|
||
|
var isInsert = delta.action == "insert";
|
||
|
if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
|
||
|
: !Range.comparePoints(delta.start, delta.end)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (isInsert && delta.lines.length > 20000) {
|
||
|
this.$splitAndapplyLargeDelta(delta, 20000);
|
||
|
}
|
||
|
else {
|
||
|
applyDelta(this.$lines, delta, doNotValidate);
|
||
|
this._signal("change", delta);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
this.$safeApplyDelta = function(delta) {
|
||
|
var docLength = this.$lines.length;
|
||
|
if (
|
||
|
delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
|
||
|
|| delta.action == "insert" && delta.start.row <= docLength
|
||
|
) {
|
||
|
this.applyDelta(delta);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
this.$splitAndapplyLargeDelta = function(delta, MAX) {
|
||
|
var lines = delta.lines;
|
||
|
var l = lines.length - MAX + 1;
|
||
|
var row = delta.start.row;
|
||
|
var column = delta.start.column;
|
||
|
for (var from = 0, to = 0; from < l; from = to) {
|
||
|
to += MAX - 1;
|
||
|
var chunk = lines.slice(from, to);
|
||
|
chunk.push("");
|
||
|
this.applyDelta({
|
||
|
start: this.pos(row + from, column),
|
||
|
end: this.pos(row + to, column = 0),
|
||
|
action: delta.action,
|
||
|
lines: chunk
|
||
|
}, true);
|
||
|
}
|
||
|
delta.lines = lines.slice(from);
|
||
|
delta.start.row = row + from;
|
||
|
delta.start.column = column;
|
||
|
this.applyDelta(delta, true);
|
||
|
};
|
||
|
this.revertDelta = function(delta) {
|
||
|
this.$safeApplyDelta({
|
||
|
start: this.clonePos(delta.start),
|
||
|
end: this.clonePos(delta.end),
|
||
|
action: (delta.action == "insert" ? "remove" : "insert"),
|
||
|
lines: delta.lines.slice()
|
||
|
});
|
||
|
};
|
||
|
this.indexToPosition = function(index, startRow) {
|
||
|
var lines = this.$lines || this.getAllLines();
|
||
|
var newlineLength = this.getNewLineCharacter().length;
|
||
|
for (var i = startRow || 0, l = lines.length; i < l; i++) {
|
||
|
index -= lines[i].length + newlineLength;
|
||
|
if (index < 0)
|
||
|
return {row: i, column: index + lines[i].length + newlineLength};
|
||
|
}
|
||
|
return {row: l-1, column: index + lines[l-1].length + newlineLength};
|
||
|
};
|
||
|
this.positionToIndex = function(pos, startRow) {
|
||
|
var lines = this.$lines || this.getAllLines();
|
||
|
var newlineLength = this.getNewLineCharacter().length;
|
||
|
var index = 0;
|
||
|
var row = Math.min(pos.row, lines.length);
|
||
|
for (var i = startRow || 0; i < row; ++i)
|
||
|
index += lines[i].length + newlineLength;
|
||
|
|
||
|
return index + pos.column;
|
||
|
};
|
||
|
|
||
|
}).call(Document.prototype);
|
||
|
|
||
|
exports.Document = Document;
|
||
|
});
|
||
|
|
||
|
define("ace/lib/lang",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
exports.last = function(a) {
|
||
|
return a[a.length - 1];
|
||
|
};
|
||
|
|
||
|
exports.stringReverse = function(string) {
|
||
|
return string.split("").reverse().join("");
|
||
|
};
|
||
|
|
||
|
exports.stringRepeat = function (string, count) {
|
||
|
var result = '';
|
||
|
while (count > 0) {
|
||
|
if (count & 1)
|
||
|
result += string;
|
||
|
|
||
|
if (count >>= 1)
|
||
|
string += string;
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
var trimBeginRegexp = /^\s\s*/;
|
||
|
var trimEndRegexp = /\s\s*$/;
|
||
|
|
||
|
exports.stringTrimLeft = function (string) {
|
||
|
return string.replace(trimBeginRegexp, '');
|
||
|
};
|
||
|
|
||
|
exports.stringTrimRight = function (string) {
|
||
|
return string.replace(trimEndRegexp, '');
|
||
|
};
|
||
|
|
||
|
exports.copyObject = function(obj) {
|
||
|
var copy = {};
|
||
|
for (var key in obj) {
|
||
|
copy[key] = obj[key];
|
||
|
}
|
||
|
return copy;
|
||
|
};
|
||
|
|
||
|
exports.copyArray = function(array){
|
||
|
var copy = [];
|
||
|
for (var i=0, l=array.length; i<l; i++) {
|
||
|
if (array[i] && typeof array[i] == "object")
|
||
|
copy[i] = this.copyObject(array[i]);
|
||
|
else
|
||
|
copy[i] = array[i];
|
||
|
}
|
||
|
return copy;
|
||
|
};
|
||
|
|
||
|
exports.deepCopy = function deepCopy(obj) {
|
||
|
if (typeof obj !== "object" || !obj)
|
||
|
return obj;
|
||
|
var copy;
|
||
|
if (Array.isArray(obj)) {
|
||
|
copy = [];
|
||
|
for (var key = 0; key < obj.length; key++) {
|
||
|
copy[key] = deepCopy(obj[key]);
|
||
|
}
|
||
|
return copy;
|
||
|
}
|
||
|
if (Object.prototype.toString.call(obj) !== "[object Object]")
|
||
|
return obj;
|
||
|
|
||
|
copy = {};
|
||
|
for (var key in obj)
|
||
|
copy[key] = deepCopy(obj[key]);
|
||
|
return copy;
|
||
|
};
|
||
|
|
||
|
exports.arrayToMap = function(arr) {
|
||
|
var map = {};
|
||
|
for (var i=0; i<arr.length; i++) {
|
||
|
map[arr[i]] = 1;
|
||
|
}
|
||
|
return map;
|
||
|
|
||
|
};
|
||
|
|
||
|
exports.createMap = function(props) {
|
||
|
var map = Object.create(null);
|
||
|
for (var i in props) {
|
||
|
map[i] = props[i];
|
||
|
}
|
||
|
return map;
|
||
|
};
|
||
|
exports.arrayRemove = function(array, value) {
|
||
|
for (var i = 0; i <= array.length; i++) {
|
||
|
if (value === array[i]) {
|
||
|
array.splice(i, 1);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
exports.escapeRegExp = function(str) {
|
||
|
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
|
||
|
};
|
||
|
|
||
|
exports.escapeHTML = function(str) {
|
||
|
return ("" + str).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
|
||
|
};
|
||
|
|
||
|
exports.getMatchOffsets = function(string, regExp) {
|
||
|
var matches = [];
|
||
|
|
||
|
string.replace(regExp, function(str) {
|
||
|
matches.push({
|
||
|
offset: arguments[arguments.length-2],
|
||
|
length: str.length
|
||
|
});
|
||
|
});
|
||
|
|
||
|
return matches;
|
||
|
};
|
||
|
exports.deferredCall = function(fcn) {
|
||
|
var timer = null;
|
||
|
var callback = function() {
|
||
|
timer = null;
|
||
|
fcn();
|
||
|
};
|
||
|
|
||
|
var deferred = function(timeout) {
|
||
|
deferred.cancel();
|
||
|
timer = setTimeout(callback, timeout || 0);
|
||
|
return deferred;
|
||
|
};
|
||
|
|
||
|
deferred.schedule = deferred;
|
||
|
|
||
|
deferred.call = function() {
|
||
|
this.cancel();
|
||
|
fcn();
|
||
|
return deferred;
|
||
|
};
|
||
|
|
||
|
deferred.cancel = function() {
|
||
|
clearTimeout(timer);
|
||
|
timer = null;
|
||
|
return deferred;
|
||
|
};
|
||
|
|
||
|
deferred.isPending = function() {
|
||
|
return timer;
|
||
|
};
|
||
|
|
||
|
return deferred;
|
||
|
};
|
||
|
|
||
|
|
||
|
exports.delayedCall = function(fcn, defaultTimeout) {
|
||
|
var timer = null;
|
||
|
var callback = function() {
|
||
|
timer = null;
|
||
|
fcn();
|
||
|
};
|
||
|
|
||
|
var _self = function(timeout) {
|
||
|
if (timer == null)
|
||
|
timer = setTimeout(callback, timeout || defaultTimeout);
|
||
|
};
|
||
|
|
||
|
_self.delay = function(timeout) {
|
||
|
timer && clearTimeout(timer);
|
||
|
timer = setTimeout(callback, timeout || defaultTimeout);
|
||
|
};
|
||
|
_self.schedule = _self;
|
||
|
|
||
|
_self.call = function() {
|
||
|
this.cancel();
|
||
|
fcn();
|
||
|
};
|
||
|
|
||
|
_self.cancel = function() {
|
||
|
timer && clearTimeout(timer);
|
||
|
timer = null;
|
||
|
};
|
||
|
|
||
|
_self.isPending = function() {
|
||
|
return timer;
|
||
|
};
|
||
|
|
||
|
return _self;
|
||
|
};
|
||
|
});
|
||
|
|
||
|
define("ace/worker/mirror",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
var Range = require("../range").Range;
|
||
|
var Document = require("../document").Document;
|
||
|
var lang = require("../lib/lang");
|
||
|
|
||
|
var Mirror = exports.Mirror = function(sender) {
|
||
|
this.sender = sender;
|
||
|
var doc = this.doc = new Document("");
|
||
|
|
||
|
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
|
||
|
|
||
|
var _self = this;
|
||
|
sender.on("change", function(e) {
|
||
|
var data = e.data;
|
||
|
if (data[0].start) {
|
||
|
doc.applyDeltas(data);
|
||
|
} else {
|
||
|
for (var i = 0; i < data.length; i += 2) {
|
||
|
if (Array.isArray(data[i+1])) {
|
||
|
var d = {action: "insert", start: data[i], lines: data[i+1]};
|
||
|
} else {
|
||
|
var d = {action: "remove", start: data[i], end: data[i+1]};
|
||
|
}
|
||
|
doc.applyDelta(d, true);
|
||
|
}
|
||
|
}
|
||
|
if (_self.$timeout)
|
||
|
return deferredUpdate.schedule(_self.$timeout);
|
||
|
_self.onUpdate();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
(function() {
|
||
|
|
||
|
this.$timeout = 500;
|
||
|
|
||
|
this.setTimeout = function(timeout) {
|
||
|
this.$timeout = timeout;
|
||
|
};
|
||
|
|
||
|
this.setValue = function(value) {
|
||
|
this.doc.setValue(value);
|
||
|
this.deferredUpdate.schedule(this.$timeout);
|
||
|
};
|
||
|
|
||
|
this.getValue = function(callbackId) {
|
||
|
this.sender.callback(this.doc.getValue(), callbackId);
|
||
|
};
|
||
|
|
||
|
this.onUpdate = function() {
|
||
|
};
|
||
|
|
||
|
this.isPending = function() {
|
||
|
return this.deferredUpdate.isPending();
|
||
|
};
|
||
|
|
||
|
}).call(Mirror.prototype);
|
||
|
|
||
|
});
|
||
|
|
||
|
define("ace/mode/javascript/jshint",[], function(require, exports, module) {
|
||
|
module.exports = (function() {
|
||
|
function outer(modules, cache, entry) {
|
||
|
var previousRequire = typeof require == "function" && require;
|
||
|
function newRequire(name, jumped){
|
||
|
if(!cache[name]) {
|
||
|
if(!modules[name]) {
|
||
|
var currentRequire = typeof require == "function" && require;
|
||
|
if (!jumped && currentRequire) return currentRequire(name, true);
|
||
|
if (previousRequire) return previousRequire(name, true);
|
||
|
var err = new Error('Cannot find module \'' + name + '\'');
|
||
|
err.code = 'MODULE_NOT_FOUND';
|
||
|
throw err;
|
||
|
}
|
||
|
var m = cache[name] = {exports:{}};
|
||
|
modules[name][0].call(m.exports, function(x){
|
||
|
var id = modules[name][1][x];
|
||
|
return newRequire(id ? id : x);
|
||
|
},m,m.exports,outer,modules,cache,entry);
|
||
|
}
|
||
|
return cache[name].exports;
|
||
|
}
|
||
|
for(var i=0;i<entry.length;i++) newRequire(entry[i]);
|
||
|
return newRequire(entry[0]);
|
||
|
}
|
||
|
return outer;
|
||
|
})()
|
||
|
({"/../../jshint/data/ascii-identifier-data.js":[function(_dereq_,module,exports){
|
||
|
var identifierStartTable = [];
|
||
|
|
||
|
for (var i = 0; i < 128; i++) {
|
||
|
identifierStartTable[i] =
|
||
|
i === 36 || // $
|
||
|
i >= 65 && i <= 90 || // A-Z
|
||
|
i === 95 || // _
|
||
|
i >= 97 && i <= 122; // a-z
|
||
|
}
|
||
|
|
||
|
var identifierPartTable = [];
|
||
|
|
||
|
for (var i = 0; i < 128; i++) {
|
||
|
identifierPartTable[i] =
|
||
|
identifierStartTable[i] || // $, _, A-Z, a-z
|
||
|
i >= 48 && i <= 57; // 0-9
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
asciiIdentifierStartTable: identifierStartTable,
|
||
|
asciiIdentifierPartTable: identifierPartTable
|
||
|
};
|
||
|
|
||
|
},{}],"/../../jshint/data/es5-identifier-names.js":[function(_dereq_,module,exports){
|
||
|
module.exports = /^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0525\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0621-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971\u0972\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D3D\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC\u0EDD\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8B\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10D0-\u10FA\u10FC\u1100-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u2094\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2D00-\u2D25\u2D30-\u2D65\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31B7\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCB\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA65F\uA662-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B\uA78C\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA2D\uFA30-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC])(?:[\$0-9A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-
|
||
|
},{}],"/../../jshint/data/non-ascii-identifier-part-only.js":[function(_dereq_,module,exports){
|
||
|
var str = '183,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,903,1155,1156,1157,1158,1159,1425,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1471,1473,1474,1476,1477,1479,1552,1553,1554,1555,1556,1557,1558,1559,1560,1561,1562,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1625,1626,1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1648,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1763,1764,1767,1768,1770,1771,1772,1773,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,1809,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1861,1862,1863,1864,1865,1866,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,2027,2028,2029,2030,2031,2032,2033,2034,2035,2045,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2137,2138,2139,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2275,2276,2277,2278,2279,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,2290,2291,2292,2293,2294,2295,2296,2297,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2362,2363,2364,2366,2367,2368,2369,2370,2371,2372,2373,2374,2375,2376,2377,2378,2379,2380,2381,2382,2383,2385,2386,2387,2388,2389,2390,2391,2402,2403,2406,2407,2408,2409,2410,2411,2412,2413,2414,2415,2433,2434,2435,2492,2494,2495,2496,2497,2498,2499,2500,2503,2504,2507,2508,2509,2519,2530,2531,2534,2535,2536,2537,2538,2539,2540,2541,2542,2543,2558,2561,2562,2563,2620,2622,2623,2624,2625,2626,2631,2632,2635,2636,2637,2641,2662,2663,2664,2665,2666,2667,2668,2669,2670,2671,2672,2673,2677,2689,2690,2691,2748,2750,2751,2752,2753,2754,2755,2756,2757,2759,2760,2761,2763,2764,2765,2786,2787,2790,2791,2792,2793,2794,2795,2796,2797,2798,2799,2810,2811,2812,2813,2814,2815,2817,2818,2819,2876,2878,2879,2880,2881,2882,2883,2884,2887,2888,2891,2892,2893,2902,2903,2914,2915,2918,2919,2920,2921,2922,2923,2924,2925,2926,2927,2946,3006,3007,3008,3009,3010,3014,3015,3016,3018,3019,3020,3021,3031,3046,3047,3048,3049,3050,3051,3052,3053,3054,3055,3072,3073,3074,3075,3076,3134,3135,3136,3137,3138,3139,3140,3142,3143,3144,3146,3147,3148,3149,3157,3158,3170,3171,3174,3175,3176,3177,3178,3179,3180,3181,3182,3183,3201,3202,3203,3260,3262,3263,3264,3265,3266,3267,3268,3270,3271,3272,3274,3275,3276,3277,3285,3286,3298,3299,3302,3303,3304,3305,3306,3307,3308,3309,3310,3311,3328,3329,3330,3331,3387,3388,3390,3391,3392,3393,3394,3395,3396,3398,3399,3400,3402,3403,3404,3405,3415,3426,3427,3430,3431,3432,3433,3434,3435,3436,3437,3438,3439,3458,3459,3530,3535,3536,3537,3538,3539,3540,3542,3544,3545,3546,3547,3548,3549,3550,3551,3558,3559,3560,3561,3562,3563,3564,3565,3566,3567,3570,3571,3633,3636,3637,3638,3639,3640,3641,3642,3655,3656,3657,3658,3659,3660,3661,3662,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3761,3764,3765,3766,3767,3768,3769,3771,3772,3784,3785,3786,3787,3788,3789,3792,3793,3794,3795,3796,3797,3798,3799,3800,3801,3864,3865,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3893,3895,3897,3902,3903,3953,3954,3955,3956,3957,3958,3959,3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3972,3974,3975,3981,3982,3983,3984,3985,3986,3987,3988,3989,3990,3991,3993,3994,3995,3996,3997,3998,3999,4000,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027,4028,4038,4139,4140,4141,4142,4143,4144,4145,4146,4147,4148,4149,4150,415
|
||
|
var arr = str.split(',').map(function(code) {
|
||
|
return parseInt(code, 10);
|
||
|
});
|
||
|
module.exports = arr;
|
||
|
},{}],"/../../jshint/data/non-ascii-identifier-start.js":[function(_dereq_,module,exports){
|
||
|
var str = '170,181,186,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,710,711,712,713,714,715,716,717,718,719,720,721,736,737,738,739,740,748,750,880,881,882,883,884,886,887,890,891,892,893,895,902,904,905,906,908,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1150,1151,1152,1153,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313
|
||
|
var arr = str.split(',').map(function(code) {
|
||
|
return parseInt(code, 10);
|
||
|
});
|
||
|
module.exports = arr;
|
||
|
},{}],"/../../jshint/node_modules/console-browserify/index.js":[function(_dereq_,module,exports){
|
||
|
(function (global){
|
||
|
var util = _dereq_("util")
|
||
|
var assert = _dereq_("assert")
|
||
|
var now = _dereq_("date-now")
|
||
|
|
||
|
var slice = Array.prototype.slice
|
||
|
var console
|
||
|
var times = {}
|
||
|
|
||
|
if (typeof global !== "undefined" && global.console) {
|
||
|
console = global.console
|
||
|
} else if (typeof window !== "undefined" && window.console) {
|
||
|
console = window.console
|
||
|
} else {
|
||
|
console = {}
|
||
|
}
|
||
|
|
||
|
var functions = [
|
||
|
[log, "log"],
|
||
|
[info, "info"],
|
||
|
[warn, "warn"],
|
||
|
[error, "error"],
|
||
|
[time, "time"],
|
||
|
[timeEnd, "timeEnd"],
|
||
|
[trace, "trace"],
|
||
|
[dir, "dir"],
|
||
|
[consoleAssert, "assert"]
|
||
|
]
|
||
|
|
||
|
for (var i = 0; i < functions.length; i++) {
|
||
|
var tuple = functions[i]
|
||
|
var f = tuple[0]
|
||
|
var name = tuple[1]
|
||
|
|
||
|
if (!console[name]) {
|
||
|
console[name] = f
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = console
|
||
|
|
||
|
function log() {}
|
||
|
|
||
|
function info() {
|
||
|
console.log.apply(console, arguments)
|
||
|
}
|
||
|
|
||
|
function warn() {
|
||
|
console.log.apply(console, arguments)
|
||
|
}
|
||
|
|
||
|
function error() {
|
||
|
console.warn.apply(console, arguments)
|
||
|
}
|
||
|
|
||
|
function time(label) {
|
||
|
times[label] = now()
|
||
|
}
|
||
|
|
||
|
function timeEnd(label) {
|
||
|
var time = times[label]
|
||
|
if (!time) {
|
||
|
throw new Error("No such label: " + label)
|
||
|
}
|
||
|
|
||
|
var duration = now() - time
|
||
|
console.log(label + ": " + duration + "ms")
|
||
|
}
|
||
|
|
||
|
function trace() {
|
||
|
var err = new Error()
|
||
|
err.name = "Trace"
|
||
|
err.message = util.format.apply(null, arguments)
|
||
|
console.error(err.stack)
|
||
|
}
|
||
|
|
||
|
function dir(object) {
|
||
|
console.log(util.inspect(object) + "\n")
|
||
|
}
|
||
|
|
||
|
function consoleAssert(expression) {
|
||
|
if (!expression) {
|
||
|
var arr = slice.call(arguments, 1)
|
||
|
assert.ok(false, util.format.apply(null, arr))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
|
},{"assert":"/../node_modules/assert/assert.js","date-now":"/../../jshint/node_modules/date-now/index.js","util":"/../node_modules/util/util.js"}],"/../../jshint/node_modules/date-now/index.js":[function(_dereq_,module,exports){
|
||
|
module.exports = now
|
||
|
|
||
|
function now() {
|
||
|
return new Date().getTime()
|
||
|
}
|
||
|
|
||
|
},{}],"/../../jshint/node_modules/lodash.clone/index.js":[function(_dereq_,module,exports){
|
||
|
(function (global){
|
||
|
var LARGE_ARRAY_SIZE = 200;
|
||
|
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
||
|
var argsTag = '[object Arguments]',
|
||
|
arrayTag = '[object Array]',
|
||
|
boolTag = '[object Boolean]',
|
||
|
dateTag = '[object Date]',
|
||
|
errorTag = '[object Error]',
|
||
|
funcTag = '[object Function]',
|
||
|
genTag = '[object GeneratorFunction]',
|
||
|
mapTag = '[object Map]',
|
||
|
numberTag = '[object Number]',
|
||
|
objectTag = '[object Object]',
|
||
|
promiseTag = '[object Promise]',
|
||
|
regexpTag = '[object RegExp]',
|
||
|
setTag = '[object Set]',
|
||
|
stringTag = '[object String]',
|
||
|
symbolTag = '[object Symbol]',
|
||
|
weakMapTag = '[object WeakMap]';
|
||
|
|
||
|
var arrayBufferTag = '[object ArrayBuffer]',
|
||
|
dataViewTag = '[object DataView]',
|
||
|
float32Tag = '[object Float32Array]',
|
||
|
float64Tag = '[object Float64Array]',
|
||
|
int8Tag = '[object Int8Array]',
|
||
|
int16Tag = '[object Int16Array]',
|
||
|
int32Tag = '[object Int32Array]',
|
||
|
uint8Tag = '[object Uint8Array]',
|
||
|
uint8ClampedTag = '[object Uint8ClampedArray]',
|
||
|
uint16Tag = '[object Uint16Array]',
|
||
|
uint32Tag = '[object Uint32Array]';
|
||
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||
|
var reFlags = /\w*$/;
|
||
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||
|
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||
|
var cloneableTags = {};
|
||
|
cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
||
|
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
|
||
|
cloneableTags[boolTag] = cloneableTags[dateTag] =
|
||
|
cloneableTags[float32Tag] = cloneableTags[float64Tag] =
|
||
|
cloneableTags[int8Tag] = cloneableTags[int16Tag] =
|
||
|
cloneableTags[int32Tag] = cloneableTags[mapTag] =
|
||
|
cloneableTags[numberTag] = cloneableTags[objectTag] =
|
||
|
cloneableTags[regexpTag] = cloneableTags[setTag] =
|
||
|
cloneableTags[stringTag] = cloneableTags[symbolTag] =
|
||
|
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
|
||
|
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
||
|
cloneableTags[errorTag] = cloneableTags[funcTag] =
|
||
|
cloneableTags[weakMapTag] = false;
|
||
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
||
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||
|
var root = freeGlobal || freeSelf || Function('return this')();
|
||
|
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
||
|
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
||
|
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
function addMapEntry(map, pair) {
|
||
|
map.set(pair[0], pair[1]);
|
||
|
return map;
|
||
|
}
|
||
|
function addSetEntry(set, value) {
|
||
|
set.add(value);
|
||
|
return set;
|
||
|
}
|
||
|
function arrayEach(array, iteratee) {
|
||
|
var index = -1,
|
||
|
length = array ? array.length : 0;
|
||
|
|
||
|
while (++index < length) {
|
||
|
if (iteratee(array[index], index, array) === false) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return array;
|
||
|
}
|
||
|
function arrayPush(array, values) {
|
||
|
var index = -1,
|
||
|
length = values.length,
|
||
|
offset = array.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
array[offset + index] = values[index];
|
||
|
}
|
||
|
return array;
|
||
|
}
|
||
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
||
|
var index = -1,
|
||
|
length = array ? array.length : 0;
|
||
|
|
||
|
if (initAccum && length) {
|
||
|
accumulator = array[++index];
|
||
|
}
|
||
|
while (++index < length) {
|
||
|
accumulator = iteratee(accumulator, array[index], index, array);
|
||
|
}
|
||
|
return accumulator;
|
||
|
}
|
||
|
function baseTimes(n, iteratee) {
|
||
|
var index = -1,
|
||
|
result = Array(n);
|
||
|
|
||
|
while (++index < n) {
|
||
|
result[index] = iteratee(index);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function getValue(object, key) {
|
||
|
return object == null ? undefined : object[key];
|
||
|
}
|
||
|
function isHostObject(value) {
|
||
|
var result = false;
|
||
|
if (value != null && typeof value.toString != 'function') {
|
||
|
try {
|
||
|
result = !!(value + '');
|
||
|
} catch (e) {}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function mapToArray(map) {
|
||
|
var index = -1,
|
||
|
result = Array(map.size);
|
||
|
|
||
|
map.forEach(function(value, key) {
|
||
|
result[++index] = [key, value];
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
function overArg(func, transform) {
|
||
|
return function(arg) {
|
||
|
return func(transform(arg));
|
||
|
};
|
||
|
}
|
||
|
function setToArray(set) {
|
||
|
var index = -1,
|
||
|
result = Array(set.size);
|
||
|
|
||
|
set.forEach(function(value) {
|
||
|
result[++index] = value;
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
var arrayProto = Array.prototype,
|
||
|
funcProto = Function.prototype,
|
||
|
objectProto = Object.prototype;
|
||
|
var coreJsData = root['__core-js_shared__'];
|
||
|
var maskSrcKey = (function() {
|
||
|
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
||
|
return uid ? ('Symbol(src)_1.' + uid) : '';
|
||
|
}());
|
||
|
var funcToString = funcProto.toString;
|
||
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
var objectToString = objectProto.toString;
|
||
|
var reIsNative = RegExp('^' +
|
||
|
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
||
|
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
||
|
);
|
||
|
var Buffer = moduleExports ? root.Buffer : undefined,
|
||
|
Symbol = root.Symbol,
|
||
|
Uint8Array = root.Uint8Array,
|
||
|
getPrototype = overArg(Object.getPrototypeOf, Object),
|
||
|
objectCreate = Object.create,
|
||
|
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
||
|
splice = arrayProto.splice;
|
||
|
var nativeGetSymbols = Object.getOwnPropertySymbols,
|
||
|
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
||
|
nativeKeys = overArg(Object.keys, Object);
|
||
|
var DataView = getNative(root, 'DataView'),
|
||
|
Map = getNative(root, 'Map'),
|
||
|
Promise = getNative(root, 'Promise'),
|
||
|
Set = getNative(root, 'Set'),
|
||
|
WeakMap = getNative(root, 'WeakMap'),
|
||
|
nativeCreate = getNative(Object, 'create');
|
||
|
var dataViewCtorString = toSource(DataView),
|
||
|
mapCtorString = toSource(Map),
|
||
|
promiseCtorString = toSource(Promise),
|
||
|
setCtorString = toSource(Set),
|
||
|
weakMapCtorString = toSource(WeakMap);
|
||
|
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||
|
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||
|
function Hash(entries) {
|
||
|
var index = -1,
|
||
|
length = entries ? entries.length : 0;
|
||
|
|
||
|
this.clear();
|
||
|
while (++index < length) {
|
||
|
var entry = entries[index];
|
||
|
this.set(entry[0], entry[1]);
|
||
|
}
|
||
|
}
|
||
|
function hashClear() {
|
||
|
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||
|
}
|
||
|
function hashDelete(key) {
|
||
|
return this.has(key) && delete this.__data__[key];
|
||
|
}
|
||
|
function hashGet(key) {
|
||
|
var data = this.__data__;
|
||
|
if (nativeCreate) {
|
||
|
var result = data[key];
|
||
|
return result === HASH_UNDEFINED ? undefined : result;
|
||
|
}
|
||
|
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
||
|
}
|
||
|
function hashHas(key) {
|
||
|
var data = this.__data__;
|
||
|
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
||
|
}
|
||
|
function hashSet(key, value) {
|
||
|
var data = this.__data__;
|
||
|
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
||
|
return this;
|
||
|
}
|
||
|
Hash.prototype.clear = hashClear;
|
||
|
Hash.prototype['delete'] = hashDelete;
|
||
|
Hash.prototype.get = hashGet;
|
||
|
Hash.prototype.has = hashHas;
|
||
|
Hash.prototype.set = hashSet;
|
||
|
function ListCache(entries) {
|
||
|
var index = -1,
|
||
|
length = entries ? entries.length : 0;
|
||
|
|
||
|
this.clear();
|
||
|
while (++index < length) {
|
||
|
var entry = entries[index];
|
||
|
this.set(entry[0], entry[1]);
|
||
|
}
|
||
|
}
|
||
|
function listCacheClear() {
|
||
|
this.__data__ = [];
|
||
|
}
|
||
|
function listCacheDelete(key) {
|
||
|
var data = this.__data__,
|
||
|
index = assocIndexOf(data, key);
|
||
|
|
||
|
if (index < 0) {
|
||
|
return false;
|
||
|
}
|
||
|
var lastIndex = data.length - 1;
|
||
|
if (index == lastIndex) {
|
||
|
data.pop();
|
||
|
} else {
|
||
|
splice.call(data, index, 1);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
function listCacheGet(key) {
|
||
|
var data = this.__data__,
|
||
|
index = assocIndexOf(data, key);
|
||
|
|
||
|
return index < 0 ? undefined : data[index][1];
|
||
|
}
|
||
|
function listCacheHas(key) {
|
||
|
return assocIndexOf(this.__data__, key) > -1;
|
||
|
}
|
||
|
function listCacheSet(key, value) {
|
||
|
var data = this.__data__,
|
||
|
index = assocIndexOf(data, key);
|
||
|
|
||
|
if (index < 0) {
|
||
|
data.push([key, value]);
|
||
|
} else {
|
||
|
data[index][1] = value;
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
ListCache.prototype.clear = listCacheClear;
|
||
|
ListCache.prototype['delete'] = listCacheDelete;
|
||
|
ListCache.prototype.get = listCacheGet;
|
||
|
ListCache.prototype.has = listCacheHas;
|
||
|
ListCache.prototype.set = listCacheSet;
|
||
|
function MapCache(entries) {
|
||
|
var index = -1,
|
||
|
length = entries ? entries.length : 0;
|
||
|
|
||
|
this.clear();
|
||
|
while (++index < length) {
|
||
|
var entry = entries[index];
|
||
|
this.set(entry[0], entry[1]);
|
||
|
}
|
||
|
}
|
||
|
function mapCacheClear() {
|
||
|
this.__data__ = {
|
||
|
'hash': new Hash,
|
||
|
'map': new (Map || ListCache),
|
||
|
'string': new Hash
|
||
|
};
|
||
|
}
|
||
|
function mapCacheDelete(key) {
|
||
|
return getMapData(this, key)['delete'](key);
|
||
|
}
|
||
|
function mapCacheGet(key) {
|
||
|
return getMapData(this, key).get(key);
|
||
|
}
|
||
|
function mapCacheHas(key) {
|
||
|
return getMapData(this, key).has(key);
|
||
|
}
|
||
|
function mapCacheSet(key, value) {
|
||
|
getMapData(this, key).set(key, value);
|
||
|
return this;
|
||
|
}
|
||
|
MapCache.prototype.clear = mapCacheClear;
|
||
|
MapCache.prototype['delete'] = mapCacheDelete;
|
||
|
MapCache.prototype.get = mapCacheGet;
|
||
|
MapCache.prototype.has = mapCacheHas;
|
||
|
MapCache.prototype.set = mapCacheSet;
|
||
|
function Stack(entries) {
|
||
|
this.__data__ = new ListCache(entries);
|
||
|
}
|
||
|
function stackClear() {
|
||
|
this.__data__ = new ListCache;
|
||
|
}
|
||
|
function stackDelete(key) {
|
||
|
return this.__data__['delete'](key);
|
||
|
}
|
||
|
function stackGet(key) {
|
||
|
return this.__data__.get(key);
|
||
|
}
|
||
|
function stackHas(key) {
|
||
|
return this.__data__.has(key);
|
||
|
}
|
||
|
function stackSet(key, value) {
|
||
|
var cache = this.__data__;
|
||
|
if (cache instanceof ListCache) {
|
||
|
var pairs = cache.__data__;
|
||
|
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||
|
pairs.push([key, value]);
|
||
|
return this;
|
||
|
}
|
||
|
cache = this.__data__ = new MapCache(pairs);
|
||
|
}
|
||
|
cache.set(key, value);
|
||
|
return this;
|
||
|
}
|
||
|
Stack.prototype.clear = stackClear;
|
||
|
Stack.prototype['delete'] = stackDelete;
|
||
|
Stack.prototype.get = stackGet;
|
||
|
Stack.prototype.has = stackHas;
|
||
|
Stack.prototype.set = stackSet;
|
||
|
function arrayLikeKeys(value, inherited) {
|
||
|
var result = (isArray(value) || isArguments(value))
|
||
|
? baseTimes(value.length, String)
|
||
|
: [];
|
||
|
|
||
|
var length = result.length,
|
||
|
skipIndexes = !!length;
|
||
|
|
||
|
for (var key in value) {
|
||
|
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||
|
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
|
||
|
result.push(key);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function assignValue(object, key, value) {
|
||
|
var objValue = object[key];
|
||
|
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||
|
(value === undefined && !(key in object))) {
|
||
|
object[key] = value;
|
||
|
}
|
||
|
}
|
||
|
function assocIndexOf(array, key) {
|
||
|
var length = array.length;
|
||
|
while (length--) {
|
||
|
if (eq(array[length][0], key)) {
|
||
|
return length;
|
||
|
}
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
function baseAssign(object, source) {
|
||
|
return object && copyObject(source, keys(source), object);
|
||
|
}
|
||
|
function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
||
|
var result;
|
||
|
if (customizer) {
|
||
|
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||
|
}
|
||
|
if (result !== undefined) {
|
||
|
return result;
|
||
|
}
|
||
|
if (!isObject(value)) {
|
||
|
return value;
|
||
|
}
|
||
|
var isArr = isArray(value);
|
||
|
if (isArr) {
|
||
|
result = initCloneArray(value);
|
||
|
if (!isDeep) {
|
||
|
return copyArray(value, result);
|
||
|
}
|
||
|
} else {
|
||
|
var tag = getTag(value),
|
||
|
isFunc = tag == funcTag || tag == genTag;
|
||
|
|
||
|
if (isBuffer(value)) {
|
||
|
return cloneBuffer(value, isDeep);
|
||
|
}
|
||
|
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||
|
if (isHostObject(value)) {
|
||
|
return object ? value : {};
|
||
|
}
|
||
|
result = initCloneObject(isFunc ? {} : value);
|
||
|
if (!isDeep) {
|
||
|
return copySymbols(value, baseAssign(result, value));
|
||
|
}
|
||
|
} else {
|
||
|
if (!cloneableTags[tag]) {
|
||
|
return object ? value : {};
|
||
|
}
|
||
|
result = initCloneByTag(value, tag, baseClone, isDeep);
|
||
|
}
|
||
|
}
|
||
|
stack || (stack = new Stack);
|
||
|
var stacked = stack.get(value);
|
||
|
if (stacked) {
|
||
|
return stacked;
|
||
|
}
|
||
|
stack.set(value, result);
|
||
|
|
||
|
if (!isArr) {
|
||
|
var props = isFull ? getAllKeys(value) : keys(value);
|
||
|
}
|
||
|
arrayEach(props || value, function(subValue, key) {
|
||
|
if (props) {
|
||
|
key = subValue;
|
||
|
subValue = value[key];
|
||
|
}
|
||
|
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
function baseCreate(proto) {
|
||
|
return isObject(proto) ? objectCreate(proto) : {};
|
||
|
}
|
||
|
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
||
|
var result = keysFunc(object);
|
||
|
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
||
|
}
|
||
|
function baseGetTag(value) {
|
||
|
return objectToString.call(value);
|
||
|
}
|
||
|
function baseIsNative(value) {
|
||
|
if (!isObject(value) || isMasked(value)) {
|
||
|
return false;
|
||
|
}
|
||
|
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
||
|
return pattern.test(toSource(value));
|
||
|
}
|
||
|
function baseKeys(object) {
|
||
|
if (!isPrototype(object)) {
|
||
|
return nativeKeys(object);
|
||
|
}
|
||
|
var result = [];
|
||
|
for (var key in Object(object)) {
|
||
|
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
||
|
result.push(key);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function cloneBuffer(buffer, isDeep) {
|
||
|
if (isDeep) {
|
||
|
return buffer.slice();
|
||
|
}
|
||
|
var result = new buffer.constructor(buffer.length);
|
||
|
buffer.copy(result);
|
||
|
return result;
|
||
|
}
|
||
|
function cloneArrayBuffer(arrayBuffer) {
|
||
|
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
||
|
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
||
|
return result;
|
||
|
}
|
||
|
function cloneDataView(dataView, isDeep) {
|
||
|
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
|
||
|
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
||
|
}
|
||
|
function cloneMap(map, isDeep, cloneFunc) {
|
||
|
var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
|
||
|
return arrayReduce(array, addMapEntry, new map.constructor);
|
||
|
}
|
||
|
function cloneRegExp(regexp) {
|
||
|
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
||
|
result.lastIndex = regexp.lastIndex;
|
||
|
return result;
|
||
|
}
|
||
|
function cloneSet(set, isDeep, cloneFunc) {
|
||
|
var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
|
||
|
return arrayReduce(array, addSetEntry, new set.constructor);
|
||
|
}
|
||
|
function cloneSymbol(symbol) {
|
||
|
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
||
|
}
|
||
|
function cloneTypedArray(typedArray, isDeep) {
|
||
|
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
||
|
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
||
|
}
|
||
|
function copyArray(source, array) {
|
||
|
var index = -1,
|
||
|
length = source.length;
|
||
|
|
||
|
array || (array = Array(length));
|
||
|
while (++index < length) {
|
||
|
array[index] = source[index];
|
||
|
}
|
||
|
return array;
|
||
|
}
|
||
|
function copyObject(source, props, object, customizer) {
|
||
|
object || (object = {});
|
||
|
|
||
|
var index = -1,
|
||
|
length = props.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
var key = props[index];
|
||
|
|
||
|
var newValue = customizer
|
||
|
? customizer(object[key], source[key], key, object, source)
|
||
|
: undefined;
|
||
|
|
||
|
assignValue(object, key, newValue === undefined ? source[key] : newValue);
|
||
|
}
|
||
|
return object;
|
||
|
}
|
||
|
function copySymbols(source, object) {
|
||
|
return copyObject(source, getSymbols(source), object);
|
||
|
}
|
||
|
function getAllKeys(object) {
|
||
|
return baseGetAllKeys(object, keys, getSymbols);
|
||
|
}
|
||
|
function getMapData(map, key) {
|
||
|
var data = map.__data__;
|
||
|
return isKeyable(key)
|
||
|
? data[typeof key == 'string' ? 'string' : 'hash']
|
||
|
: data.map;
|
||
|
}
|
||
|
function getNative(object, key) {
|
||
|
var value = getValue(object, key);
|
||
|
return baseIsNative(value) ? value : undefined;
|
||
|
}
|
||
|
var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
|
||
|
var getTag = baseGetTag;
|
||
|
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
||
|
(Map && getTag(new Map) != mapTag) ||
|
||
|
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
||
|
(Set && getTag(new Set) != setTag) ||
|
||
|
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||
|
getTag = function(value) {
|
||
|
var result = objectToString.call(value),
|
||
|
Ctor = result == objectTag ? value.constructor : undefined,
|
||
|
ctorString = Ctor ? toSource(Ctor) : undefined;
|
||
|
|
||
|
if (ctorString) {
|
||
|
switch (ctorString) {
|
||
|
case dataViewCtorString: return dataViewTag;
|
||
|
case mapCtorString: return mapTag;
|
||
|
case promiseCtorString: return promiseTag;
|
||
|
case setCtorString: return setTag;
|
||
|
case weakMapCtorString: return weakMapTag;
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
}
|
||
|
function initCloneArray(array) {
|
||
|
var length = array.length,
|
||
|
result = array.constructor(length);
|
||
|
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
||
|
result.index = array.index;
|
||
|
result.input = array.input;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function initCloneObject(object) {
|
||
|
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||
|
? baseCreate(getPrototype(object))
|
||
|
: {};
|
||
|
}
|
||
|
function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
||
|
var Ctor = object.constructor;
|
||
|
switch (tag) {
|
||
|
case arrayBufferTag:
|
||
|
return cloneArrayBuffer(object);
|
||
|
|
||
|
case boolTag:
|
||
|
case dateTag:
|
||
|
return new Ctor(+object);
|
||
|
|
||
|
case dataViewTag:
|
||
|
return cloneDataView(object, isDeep);
|
||
|
|
||
|
case float32Tag: case float64Tag:
|
||
|
case int8Tag: case int16Tag: case int32Tag:
|
||
|
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
|
||
|
return cloneTypedArray(object, isDeep);
|
||
|
|
||
|
case mapTag:
|
||
|
return cloneMap(object, isDeep, cloneFunc);
|
||
|
|
||
|
case numberTag:
|
||
|
case stringTag:
|
||
|
return new Ctor(object);
|
||
|
|
||
|
case regexpTag:
|
||
|
return cloneRegExp(object);
|
||
|
|
||
|
case setTag:
|
||
|
return cloneSet(object, isDeep, cloneFunc);
|
||
|
|
||
|
case symbolTag:
|
||
|
return cloneSymbol(object);
|
||
|
}
|
||
|
}
|
||
|
function isIndex(value, length) {
|
||
|
length = length == null ? MAX_SAFE_INTEGER : length;
|
||
|
return !!length &&
|
||
|
(typeof value == 'number' || reIsUint.test(value)) &&
|
||
|
(value > -1 && value % 1 == 0 && value < length);
|
||
|
}
|
||
|
function isKeyable(value) {
|
||
|
var type = typeof value;
|
||
|
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
||
|
? (value !== '__proto__')
|
||
|
: (value === null);
|
||
|
}
|
||
|
function isMasked(func) {
|
||
|
return !!maskSrcKey && (maskSrcKey in func);
|
||
|
}
|
||
|
function isPrototype(value) {
|
||
|
var Ctor = value && value.constructor,
|
||
|
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
||
|
|
||
|
return value === proto;
|
||
|
}
|
||
|
function toSource(func) {
|
||
|
if (func != null) {
|
||
|
try {
|
||
|
return funcToString.call(func);
|
||
|
} catch (e) {}
|
||
|
try {
|
||
|
return (func + '');
|
||
|
} catch (e) {}
|
||
|
}
|
||
|
return '';
|
||
|
}
|
||
|
function clone(value) {
|
||
|
return baseClone(value, false, true);
|
||
|
}
|
||
|
function eq(value, other) {
|
||
|
return value === other || (value !== value && other !== other);
|
||
|
}
|
||
|
function isArguments(value) {
|
||
|
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
||
|
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
||
|
}
|
||
|
var isArray = Array.isArray;
|
||
|
function isArrayLike(value) {
|
||
|
return value != null && isLength(value.length) && !isFunction(value);
|
||
|
}
|
||
|
function isArrayLikeObject(value) {
|
||
|
return isObjectLike(value) && isArrayLike(value);
|
||
|
}
|
||
|
var isBuffer = nativeIsBuffer || stubFalse;
|
||
|
function isFunction(value) {
|
||
|
var tag = isObject(value) ? objectToString.call(value) : '';
|
||
|
return tag == funcTag || tag == genTag;
|
||
|
}
|
||
|
function isLength(value) {
|
||
|
return typeof value == 'number' &&
|
||
|
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||
|
}
|
||
|
function isObject(value) {
|
||
|
var type = typeof value;
|
||
|
return !!value && (type == 'object' || type == 'function');
|
||
|
}
|
||
|
function isObjectLike(value) {
|
||
|
return !!value && typeof value == 'object';
|
||
|
}
|
||
|
function keys(object) {
|
||
|
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
||
|
}
|
||
|
function stubArray() {
|
||
|
return [];
|
||
|
}
|
||
|
function stubFalse() {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
module.exports = clone;
|
||
|
|
||
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
|
},{}],"/../../jshint/node_modules/lodash.slice/index.js":[function(_dereq_,module,exports){
|
||
|
var INFINITY = 1 / 0,
|
||
|
MAX_SAFE_INTEGER = 9007199254740991,
|
||
|
MAX_INTEGER = 1.7976931348623157e+308,
|
||
|
NAN = 0 / 0;
|
||
|
var funcTag = '[object Function]',
|
||
|
genTag = '[object GeneratorFunction]',
|
||
|
symbolTag = '[object Symbol]';
|
||
|
var reTrim = /^\s+|\s+$/g;
|
||
|
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
||
|
var reIsBinary = /^0b[01]+$/i;
|
||
|
var reIsOctal = /^0o[0-7]+$/i;
|
||
|
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||
|
var freeParseInt = parseInt;
|
||
|
var objectProto = Object.prototype;
|
||
|
var objectToString = objectProto.toString;
|
||
|
function baseSlice(array, start, end) {
|
||
|
var index = -1,
|
||
|
length = array.length;
|
||
|
|
||
|
if (start < 0) {
|
||
|
start = -start > length ? 0 : (length + start);
|
||
|
}
|
||
|
end = end > length ? length : end;
|
||
|
if (end < 0) {
|
||
|
end += length;
|
||
|
}
|
||
|
length = start > end ? 0 : ((end - start) >>> 0);
|
||
|
start >>>= 0;
|
||
|
|
||
|
var result = Array(length);
|
||
|
while (++index < length) {
|
||
|
result[index] = array[index + start];
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function isIndex(value, length) {
|
||
|
length = length == null ? MAX_SAFE_INTEGER : length;
|
||
|
return !!length &&
|
||
|
(typeof value == 'number' || reIsUint.test(value)) &&
|
||
|
(value > -1 && value % 1 == 0 && value < length);
|
||
|
}
|
||
|
function isIterateeCall(value, index, object) {
|
||
|
if (!isObject(object)) {
|
||
|
return false;
|
||
|
}
|
||
|
var type = typeof index;
|
||
|
if (type == 'number'
|
||
|
? (isArrayLike(object) && isIndex(index, object.length))
|
||
|
: (type == 'string' && index in object)
|
||
|
) {
|
||
|
return eq(object[index], value);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
function slice(array, start, end) {
|
||
|
var length = array ? array.length : 0;
|
||
|
if (!length) {
|
||
|
return [];
|
||
|
}
|
||
|
if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
|
||
|
start = 0;
|
||
|
end = length;
|
||
|
}
|
||
|
else {
|
||
|
start = start == null ? 0 : toInteger(start);
|
||
|
end = end === undefined ? length : toInteger(end);
|
||
|
}
|
||
|
return baseSlice(array, start, end);
|
||
|
}
|
||
|
function eq(value, other) {
|
||
|
return value === other || (value !== value && other !== other);
|
||
|
}
|
||
|
function isArrayLike(value) {
|
||
|
return value != null && isLength(value.length) && !isFunction(value);
|
||
|
}
|
||
|
function isFunction(value) {
|
||
|
var tag = isObject(value) ? objectToString.call(value) : '';
|
||
|
return tag == funcTag || tag == genTag;
|
||
|
}
|
||
|
function isLength(value) {
|
||
|
return typeof value == 'number' &&
|
||
|
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||
|
}
|
||
|
function isObject(value) {
|
||
|
var type = typeof value;
|
||
|
return !!value && (type == 'object' || type == 'function');
|
||
|
}
|
||
|
function isObjectLike(value) {
|
||
|
return !!value && typeof value == 'object';
|
||
|
}
|
||
|
function isSymbol(value) {
|
||
|
return typeof value == 'symbol' ||
|
||
|
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
||
|
}
|
||
|
function toFinite(value) {
|
||
|
if (!value) {
|
||
|
return value === 0 ? value : 0;
|
||
|
}
|
||
|
value = toNumber(value);
|
||
|
if (value === INFINITY || value === -INFINITY) {
|
||
|
var sign = (value < 0 ? -1 : 1);
|
||
|
return sign * MAX_INTEGER;
|
||
|
}
|
||
|
return value === value ? value : 0;
|
||
|
}
|
||
|
function toInteger(value) {
|
||
|
var result = toFinite(value),
|
||
|
remainder = result % 1;
|
||
|
|
||
|
return result === result ? (remainder ? result - remainder : result) : 0;
|
||
|
}
|
||
|
function toNumber(value) {
|
||
|
if (typeof value == 'number') {
|
||
|
return value;
|
||
|
}
|
||
|
if (isSymbol(value)) {
|
||
|
return NAN;
|
||
|
}
|
||
|
if (isObject(value)) {
|
||
|
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
||
|
value = isObject(other) ? (other + '') : other;
|
||
|
}
|
||
|
if (typeof value != 'string') {
|
||
|
return value === 0 ? value : +value;
|
||
|
}
|
||
|
value = value.replace(reTrim, '');
|
||
|
var isBinary = reIsBinary.test(value);
|
||
|
return (isBinary || reIsOctal.test(value))
|
||
|
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
||
|
: (reIsBadHex.test(value) ? NAN : +value);
|
||
|
}
|
||
|
|
||
|
module.exports = slice;
|
||
|
|
||
|
},{}],"/../../jshint/node_modules/underscore/underscore.js":[function(_dereq_,module,exports){
|
||
|
(function (global){
|
||
|
(function (global, factory) {
|
||
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||
|
typeof define === 'function' && define.amd ? define('underscore', factory) :
|
||
|
(function() {
|
||
|
var current = global._;
|
||
|
var exports = factory();
|
||
|
global._ = exports;
|
||
|
exports.noConflict = function() { global._ = current; return exports; };
|
||
|
})();
|
||
|
}(this, (function () {
|
||
|
var root = typeof self == 'object' && self.self === self && self ||
|
||
|
typeof global == 'object' && global.global === global && global ||
|
||
|
Function('return this')() ||
|
||
|
{};
|
||
|
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
|
||
|
var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
|
||
|
var push = ArrayProto.push,
|
||
|
slice = ArrayProto.slice,
|
||
|
toString = ObjProto.toString,
|
||
|
hasOwnProperty = ObjProto.hasOwnProperty;
|
||
|
var nativeIsArray = Array.isArray,
|
||
|
nativeKeys = Object.keys,
|
||
|
nativeCreate = Object.create;
|
||
|
var _isNaN = root.isNaN,
|
||
|
_isFinite = root.isFinite;
|
||
|
var Ctor = function(){};
|
||
|
function _(obj) {
|
||
|
if (obj instanceof _) return obj;
|
||
|
if (!(this instanceof _)) return new _(obj);
|
||
|
this._wrapped = obj;
|
||
|
}
|
||
|
var VERSION = _.VERSION = '1.10.2';
|
||
|
function optimizeCb(func, context, argCount) {
|
||
|
if (context === void 0) return func;
|
||
|
switch (argCount == null ? 3 : argCount) {
|
||
|
case 1: return function(value) {
|
||
|
return func.call(context, value);
|
||
|
};
|
||
|
case 3: return function(value, index, collection) {
|
||
|
return func.call(context, value, index, collection);
|
||
|
};
|
||
|
case 4: return function(accumulator, value, index, collection) {
|
||
|
return func.call(context, accumulator, value, index, collection);
|
||
|
};
|
||
|
}
|
||
|
return function() {
|
||
|
return func.apply(context, arguments);
|
||
|
};
|
||
|
}
|
||
|
function baseIteratee(value, context, argCount) {
|
||
|
if (value == null) return identity;
|
||
|
if (isFunction(value)) return optimizeCb(value, context, argCount);
|
||
|
if (isObject(value) && !isArray(value)) return matcher(value);
|
||
|
return property(value);
|
||
|
}
|
||
|
_.iteratee = iteratee;
|
||
|
function iteratee(value, context) {
|
||
|
return baseIteratee(value, context, Infinity);
|
||
|
}
|
||
|
function cb(value, context, argCount) {
|
||
|
if (_.iteratee !== iteratee) return _.iteratee(value, context);
|
||
|
return baseIteratee(value, context, argCount);
|
||
|
}
|
||
|
function restArguments(func, startIndex) {
|
||
|
startIndex = startIndex == null ? func.length - 1 : +startIndex;
|
||
|
return function() {
|
||
|
var length = Math.max(arguments.length - startIndex, 0),
|
||
|
rest = Array(length),
|
||
|
index = 0;
|
||
|
for (; index < length; index++) {
|
||
|
rest[index] = arguments[index + startIndex];
|
||
|
}
|
||
|
switch (startIndex) {
|
||
|
case 0: return func.call(this, rest);
|
||
|
case 1: return func.call(this, arguments[0], rest);
|
||
|
case 2: return func.call(this, arguments[0], arguments[1], rest);
|
||
|
}
|
||
|
var args = Array(startIndex + 1);
|
||
|
for (index = 0; index < startIndex; index++) {
|
||
|
args[index] = arguments[index];
|
||
|
}
|
||
|
args[startIndex] = rest;
|
||
|
return func.apply(this, args);
|
||
|
};
|
||
|
}
|
||
|
function baseCreate(prototype) {
|
||
|
if (!isObject(prototype)) return {};
|
||
|
if (nativeCreate) return nativeCreate(prototype);
|
||
|
Ctor.prototype = prototype;
|
||
|
var result = new Ctor;
|
||
|
Ctor.prototype = null;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function shallowProperty(key) {
|
||
|
return function(obj) {
|
||
|
return obj == null ? void 0 : obj[key];
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function _has(obj, path) {
|
||
|
return obj != null && hasOwnProperty.call(obj, path);
|
||
|
}
|
||
|
|
||
|
function deepGet(obj, path) {
|
||
|
var length = path.length;
|
||
|
for (var i = 0; i < length; i++) {
|
||
|
if (obj == null) return void 0;
|
||
|
obj = obj[path[i]];
|
||
|
}
|
||
|
return length ? obj : void 0;
|
||
|
}
|
||
|
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
|
||
|
var getLength = shallowProperty('length');
|
||
|
function isArrayLike(collection) {
|
||
|
var length = getLength(collection);
|
||
|
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
|
||
|
}
|
||
|
function each(obj, iteratee, context) {
|
||
|
iteratee = optimizeCb(iteratee, context);
|
||
|
var i, length;
|
||
|
if (isArrayLike(obj)) {
|
||
|
for (i = 0, length = obj.length; i < length; i++) {
|
||
|
iteratee(obj[i], i, obj);
|
||
|
}
|
||
|
} else {
|
||
|
var _keys = keys(obj);
|
||
|
for (i = 0, length = _keys.length; i < length; i++) {
|
||
|
iteratee(obj[_keys[i]], _keys[i], obj);
|
||
|
}
|
||
|
}
|
||
|
return obj;
|
||
|
}
|
||
|
function map(obj, iteratee, context) {
|
||
|
iteratee = cb(iteratee, context);
|
||
|
var _keys = !isArrayLike(obj) && keys(obj),
|
||
|
length = (_keys || obj).length,
|
||
|
results = Array(length);
|
||
|
for (var index = 0; index < length; index++) {
|
||
|
var currentKey = _keys ? _keys[index] : index;
|
||
|
results[index] = iteratee(obj[currentKey], currentKey, obj);
|
||
|
}
|
||
|
return results;
|
||
|
}
|
||
|
function createReduce(dir) {
|
||
|
var reducer = function(obj, iteratee, memo, initial) {
|
||
|
var _keys = !isArrayLike(obj) && keys(obj),
|
||
|
length = (_keys || obj).length,
|
||
|
index = dir > 0 ? 0 : length - 1;
|
||
|
if (!initial) {
|
||
|
memo = obj[_keys ? _keys[index] : index];
|
||
|
index += dir;
|
||
|
}
|
||
|
for (; index >= 0 && index < length; index += dir) {
|
||
|
var currentKey = _keys ? _keys[index] : index;
|
||
|
memo = iteratee(memo, obj[currentKey], currentKey, obj);
|
||
|
}
|
||
|
return memo;
|
||
|
};
|
||
|
|
||
|
return function(obj, iteratee, memo, context) {
|
||
|
var initial = arguments.length >= 3;
|
||
|
return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
|
||
|
};
|
||
|
}
|
||
|
var reduce = createReduce(1);
|
||
|
var reduceRight = createReduce(-1);
|
||
|
function find(obj, predicate, context) {
|
||
|
var keyFinder = isArrayLike(obj) ? findIndex : findKey;
|
||
|
var key = keyFinder(obj, predicate, context);
|
||
|
if (key !== void 0 && key !== -1) return obj[key];
|
||
|
}
|
||
|
function filter(obj, predicate, context) {
|
||
|
var results = [];
|
||
|
predicate = cb(predicate, context);
|
||
|
each(obj, function(value, index, list) {
|
||
|
if (predicate(value, index, list)) results.push(value);
|
||
|
});
|
||
|
return results;
|
||
|
}
|
||
|
function reject(obj, predicate, context) {
|
||
|
return filter(obj, negate(cb(predicate)), context);
|
||
|
}
|
||
|
function every(obj, predicate, context) {
|
||
|
predicate = cb(predicate, context);
|
||
|
var _keys = !isArrayLike(obj) && keys(obj),
|
||
|
length = (_keys || obj).length;
|
||
|
for (var index = 0; index < length; index++) {
|
||
|
var currentKey = _keys ? _keys[index] : index;
|
||
|
if (!predicate(obj[currentKey], currentKey, obj)) return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
function some(obj, predicate, context) {
|
||
|
predicate = cb(predicate, context);
|
||
|
var _keys = !isArrayLike(obj) && keys(obj),
|
||
|
length = (_keys || obj).length;
|
||
|
for (var index = 0; index < length; index++) {
|
||
|
var currentKey = _keys ? _keys[index] : index;
|
||
|
if (predicate(obj[currentKey], currentKey, obj)) return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
function contains(obj, item, fromIndex, guard) {
|
||
|
if (!isArrayLike(obj)) obj = values(obj);
|
||
|
if (typeof fromIndex != 'number' || guard) fromIndex = 0;
|
||
|
return indexOf(obj, item, fromIndex) >= 0;
|
||
|
}
|
||
|
var invoke = restArguments(function(obj, path, args) {
|
||
|
var contextPath, func;
|
||
|
if (isFunction(path)) {
|
||
|
func = path;
|
||
|
} else if (isArray(path)) {
|
||
|
contextPath = path.slice(0, -1);
|
||
|
path = path[path.length - 1];
|
||
|
}
|
||
|
return map(obj, function(context) {
|
||
|
var method = func;
|
||
|
if (!method) {
|
||
|
if (contextPath && contextPath.length) {
|
||
|
context = deepGet(context, contextPath);
|
||
|
}
|
||
|
if (context == null) return void 0;
|
||
|
method = context[path];
|
||
|
}
|
||
|
return method == null ? method : method.apply(context, args);
|
||
|
});
|
||
|
});
|
||
|
function pluck(obj, key) {
|
||
|
return map(obj, property(key));
|
||
|
}
|
||
|
function where(obj, attrs) {
|
||
|
return filter(obj, matcher(attrs));
|
||
|
}
|
||
|
function findWhere(obj, attrs) {
|
||
|
return find(obj, matcher(attrs));
|
||
|
}
|
||
|
function max(obj, iteratee, context) {
|
||
|
var result = -Infinity, lastComputed = -Infinity,
|
||
|
value, computed;
|
||
|
if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
|
||
|
obj = isArrayLike(obj) ? obj : values(obj);
|
||
|
for (var i = 0, length = obj.length; i < length; i++) {
|
||
|
value = obj[i];
|
||
|
if (value != null && value > result) {
|
||
|
result = value;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
iteratee = cb(iteratee, context);
|
||
|
each(obj, function(v, index, list) {
|
||
|
computed = iteratee(v, index, list);
|
||
|
if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
|
||
|
result = v;
|
||
|
lastComputed = computed;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function min(obj, iteratee, context) {
|
||
|
var result = Infinity, lastComputed = Infinity,
|
||
|
value, computed;
|
||
|
if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
|
||
|
obj = isArrayLike(obj) ? obj : values(obj);
|
||
|
for (var i = 0, length = obj.length; i < length; i++) {
|
||
|
value = obj[i];
|
||
|
if (value != null && value < result) {
|
||
|
result = value;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
iteratee = cb(iteratee, context);
|
||
|
each(obj, function(v, index, list) {
|
||
|
computed = iteratee(v, index, list);
|
||
|
if (computed < lastComputed || computed === Infinity && result === Infinity) {
|
||
|
result = v;
|
||
|
lastComputed = computed;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function shuffle(obj) {
|
||
|
return sample(obj, Infinity);
|
||
|
}
|
||
|
function sample(obj, n, guard) {
|
||
|
if (n == null || guard) {
|
||
|
if (!isArrayLike(obj)) obj = values(obj);
|
||
|
return obj[random(obj.length - 1)];
|
||
|
}
|
||
|
var sample = isArrayLike(obj) ? clone(obj) : values(obj);
|
||
|
var length = getLength(sample);
|
||
|
n = Math.max(Math.min(n, length), 0);
|
||
|
var last = length - 1;
|
||
|
for (var index = 0; index < n; index++) {
|
||
|
var rand = random(index, last);
|
||
|
var temp = sample[index];
|
||
|
sample[index] = sample[rand];
|
||
|
sample[rand] = temp;
|
||
|
}
|
||
|
return sample.slice(0, n);
|
||
|
}
|
||
|
function sortBy(obj, iteratee, context) {
|
||
|
var index = 0;
|
||
|
iteratee = cb(iteratee, context);
|
||
|
return pluck(map(obj, function(value, key, list) {
|
||
|
return {
|
||
|
value: value,
|
||
|
index: index++,
|
||
|
criteria: iteratee(value, key, list)
|
||
|
};
|
||
|
}).sort(function(left, right) {
|
||
|
var a = left.criteria;
|
||
|
var b = right.criteria;
|
||
|
if (a !== b) {
|
||
|
if (a > b || a === void 0) return 1;
|
||
|
if (a < b || b === void 0) return -1;
|
||
|
}
|
||
|
return left.index - right.index;
|
||
|
}), 'value');
|
||
|
}
|
||
|
function group(behavior, partition) {
|
||
|
return function(obj, iteratee, context) {
|
||
|
var result = partition ? [[], []] : {};
|
||
|
iteratee = cb(iteratee, context);
|
||
|
each(obj, function(value, index) {
|
||
|
var key = iteratee(value, index, obj);
|
||
|
behavior(result, value, key);
|
||
|
});
|
||
|
return result;
|
||
|
};
|
||
|
}
|
||
|
var groupBy = group(function(result, value, key) {
|
||
|
if (_has(result, key)) result[key].push(value); else result[key] = [value];
|
||
|
});
|
||
|
var indexBy = group(function(result, value, key) {
|
||
|
result[key] = value;
|
||
|
});
|
||
|
var countBy = group(function(result, value, key) {
|
||
|
if (_has(result, key)) result[key]++; else result[key] = 1;
|
||
|
});
|
||
|
|
||
|
var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
|
||
|
function toArray(obj) {
|
||
|
if (!obj) return [];
|
||
|
if (isArray(obj)) return slice.call(obj);
|
||
|
if (isString(obj)) {
|
||
|
return obj.match(reStrSymbol);
|
||
|
}
|
||
|
if (isArrayLike(obj)) return map(obj, identity);
|
||
|
return values(obj);
|
||
|
}
|
||
|
function size(obj) {
|
||
|
if (obj == null) return 0;
|
||
|
return isArrayLike(obj) ? obj.length : keys(obj).length;
|
||
|
}
|
||
|
var partition = group(function(result, value, pass) {
|
||
|
result[pass ? 0 : 1].push(value);
|
||
|
}, true);
|
||
|
function first(array, n, guard) {
|
||
|
if (array == null || array.length < 1) return n == null ? void 0 : [];
|
||
|
if (n == null || guard) return array[0];
|
||
|
return initial(array, array.length - n);
|
||
|
}
|
||
|
function initial(array, n, guard) {
|
||
|
return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
|
||
|
}
|
||
|
function last(array, n, guard) {
|
||
|
if (array == null || array.length < 1) return n == null ? void 0 : [];
|
||
|
if (n == null || guard) return array[array.length - 1];
|
||
|
return rest(array, Math.max(0, array.length - n));
|
||
|
}
|
||
|
function rest(array, n, guard) {
|
||
|
return slice.call(array, n == null || guard ? 1 : n);
|
||
|
}
|
||
|
function compact(array) {
|
||
|
return filter(array, Boolean);
|
||
|
}
|
||
|
function _flatten(input, shallow, strict, output) {
|
||
|
output = output || [];
|
||
|
var idx = output.length;
|
||
|
for (var i = 0, length = getLength(input); i < length; i++) {
|
||
|
var value = input[i];
|
||
|
if (isArrayLike(value) && (isArray(value) || isArguments(value))) {
|
||
|
if (shallow) {
|
||
|
var j = 0, len = value.length;
|
||
|
while (j < len) output[idx++] = value[j++];
|
||
|
} else {
|
||
|
_flatten(value, shallow, strict, output);
|
||
|
idx = output.length;
|
||
|
}
|
||
|
} else if (!strict) {
|
||
|
output[idx++] = value;
|
||
|
}
|
||
|
}
|
||
|
return output;
|
||
|
}
|
||
|
function flatten(array, shallow) {
|
||
|
return _flatten(array, shallow, false);
|
||
|
}
|
||
|
var without = restArguments(function(array, otherArrays) {
|
||
|
return difference(array, otherArrays);
|
||
|
});
|
||
|
function uniq(array, isSorted, iteratee, context) {
|
||
|
if (!isBoolean(isSorted)) {
|
||
|
context = iteratee;
|
||
|
iteratee = isSorted;
|
||
|
isSorted = false;
|
||
|
}
|
||
|
if (iteratee != null) iteratee = cb(iteratee, context);
|
||
|
var result = [];
|
||
|
var seen = [];
|
||
|
for (var i = 0, length = getLength(array); i < length; i++) {
|
||
|
var value = array[i],
|
||
|
computed = iteratee ? iteratee(value, i, array) : value;
|
||
|
if (isSorted && !iteratee) {
|
||
|
if (!i || seen !== computed) result.push(value);
|
||
|
seen = computed;
|
||
|
} else if (iteratee) {
|
||
|
if (!contains(seen, computed)) {
|
||
|
seen.push(computed);
|
||
|
result.push(value);
|
||
|
}
|
||
|
} else if (!contains(result, value)) {
|
||
|
result.push(value);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
var union = restArguments(function(arrays) {
|
||
|
return uniq(_flatten(arrays, true, true));
|
||
|
});
|
||
|
function intersection(array) {
|
||
|
var result = [];
|
||
|
var argsLength = arguments.length;
|
||
|
for (var i = 0, length = getLength(array); i < length; i++) {
|
||
|
var item = array[i];
|
||
|
if (contains(result, item)) continue;
|
||
|
var j;
|
||
|
for (j = 1; j < argsLength; j++) {
|
||
|
if (!contains(arguments[j], item)) break;
|
||
|
}
|
||
|
if (j === argsLength) result.push(item);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
var difference = restArguments(function(array, rest) {
|
||
|
rest = _flatten(rest, true, true);
|
||
|
return filter(array, function(value){
|
||
|
return !contains(rest, value);
|
||
|
});
|
||
|
});
|
||
|
function unzip(array) {
|
||
|
var length = array && max(array, getLength).length || 0;
|
||
|
var result = Array(length);
|
||
|
|
||
|
for (var index = 0; index < length; index++) {
|
||
|
result[index] = pluck(array, index);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
var zip = restArguments(unzip);
|
||
|
function object(list, values) {
|
||
|
var result = {};
|
||
|
for (var i = 0, length = getLength(list); i < length; i++) {
|
||
|
if (values) {
|
||
|
result[list[i]] = values[i];
|
||
|
} else {
|
||
|
result[list[i][0]] = list[i][1];
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function createPredicateIndexFinder(dir) {
|
||
|
return function(array, predicate, context) {
|
||
|
predicate = cb(predicate, context);
|
||
|
var length = getLength(array);
|
||
|
var index = dir > 0 ? 0 : length - 1;
|
||
|
for (; index >= 0 && index < length; index += dir) {
|
||
|
if (predicate(array[index], index, array)) return index;
|
||
|
}
|
||
|
return -1;
|
||
|
};
|
||
|
}
|
||
|
var findIndex = createPredicateIndexFinder(1);
|
||
|
var findLastIndex = createPredicateIndexFinder(-1);
|
||
|
function sortedIndex(array, obj, iteratee, context) {
|
||
|
iteratee = cb(iteratee, context, 1);
|
||
|
var value = iteratee(obj);
|
||
|
var low = 0, high = getLength(array);
|
||
|
while (low < high) {
|
||
|
var mid = Math.floor((low + high) / 2);
|
||
|
if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
|
||
|
}
|
||
|
return low;
|
||
|
}
|
||
|
function createIndexFinder(dir, predicateFind, sortedIndex) {
|
||
|
return function(array, item, idx) {
|
||
|
var i = 0, length = getLength(array);
|
||
|
if (typeof idx == 'number') {
|
||
|
if (dir > 0) {
|
||
|
i = idx >= 0 ? idx : Math.max(idx + length, i);
|
||
|
} else {
|
||
|
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
|
||
|
}
|
||
|
} else if (sortedIndex && idx && length) {
|
||
|
idx = sortedIndex(array, item);
|
||
|
return array[idx] === item ? idx : -1;
|
||
|
}
|
||
|
if (item !== item) {
|
||
|
idx = predicateFind(slice.call(array, i, length), isNaN);
|
||
|
return idx >= 0 ? idx + i : -1;
|
||
|
}
|
||
|
for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
|
||
|
if (array[idx] === item) return idx;
|
||
|
}
|
||
|
return -1;
|
||
|
};
|
||
|
}
|
||
|
var indexOf = createIndexFinder(1, findIndex, sortedIndex);
|
||
|
var lastIndexOf = createIndexFinder(-1, findLastIndex);
|
||
|
function range(start, stop, step) {
|
||
|
if (stop == null) {
|
||
|
stop = start || 0;
|
||
|
start = 0;
|
||
|
}
|
||
|
if (!step) {
|
||
|
step = stop < start ? -1 : 1;
|
||
|
}
|
||
|
|
||
|
var length = Math.max(Math.ceil((stop - start) / step), 0);
|
||
|
var range = Array(length);
|
||
|
|
||
|
for (var idx = 0; idx < length; idx++, start += step) {
|
||
|
range[idx] = start;
|
||
|
}
|
||
|
|
||
|
return range;
|
||
|
}
|
||
|
function chunk(array, count) {
|
||
|
if (count == null || count < 1) return [];
|
||
|
var result = [];
|
||
|
var i = 0, length = array.length;
|
||
|
while (i < length) {
|
||
|
result.push(slice.call(array, i, i += count));
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
|
||
|
if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
|
||
|
var self = baseCreate(sourceFunc.prototype);
|
||
|
var result = sourceFunc.apply(self, args);
|
||
|
if (isObject(result)) return result;
|
||
|
return self;
|
||
|
}
|
||
|
var bind = restArguments(function(func, context, args) {
|
||
|
if (!isFunction(func)) throw new TypeError('Bind must be called on a function');
|
||
|
var bound = restArguments(function(callArgs) {
|
||
|
return executeBound(func, bound, context, this, args.concat(callArgs));
|
||
|
});
|
||
|
return bound;
|
||
|
});
|
||
|
var partial = restArguments(function(func, boundArgs) {
|
||
|
var placeholder = partial.placeholder;
|
||
|
var bound = function() {
|
||
|
var position = 0, length = boundArgs.length;
|
||
|
var args = Array(length);
|
||
|
for (var i = 0; i < length; i++) {
|
||
|
args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
|
||
|
}
|
||
|
while (position < arguments.length) args.push(arguments[position++]);
|
||
|
return executeBound(func, bound, this, this, args);
|
||
|
};
|
||
|
return bound;
|
||
|
});
|
||
|
|
||
|
partial.placeholder = _;
|
||
|
var bindAll = restArguments(function(obj, _keys) {
|
||
|
_keys = _flatten(_keys, false, false);
|
||
|
var index = _keys.length;
|
||
|
if (index < 1) throw new Error('bindAll must be passed function names');
|
||
|
while (index--) {
|
||
|
var key = _keys[index];
|
||
|
obj[key] = bind(obj[key], obj);
|
||
|
}
|
||
|
});
|
||
|
function memoize(func, hasher) {
|
||
|
var memoize = function(key) {
|
||
|
var cache = memoize.cache;
|
||
|
var address = '' + (hasher ? hasher.apply(this, arguments) : key);
|
||
|
if (!_has(cache, address)) cache[address] = func.apply(this, arguments);
|
||
|
return cache[address];
|
||
|
};
|
||
|
memoize.cache = {};
|
||
|
return memoize;
|
||
|
}
|
||
|
var delay = restArguments(function(func, wait, args) {
|
||
|
return setTimeout(function() {
|
||
|
return func.apply(null, args);
|
||
|
}, wait);
|
||
|
});
|
||
|
var defer = partial(delay, _, 1);
|
||
|
function throttle(func, wait, options) {
|
||
|
var timeout, context, args, result;
|
||
|
var previous = 0;
|
||
|
if (!options) options = {};
|
||
|
|
||
|
var later = function() {
|
||
|
previous = options.leading === false ? 0 : now();
|
||
|
timeout = null;
|
||
|
result = func.apply(context, args);
|
||
|
if (!timeout) context = args = null;
|
||
|
};
|
||
|
|
||
|
var throttled = function() {
|
||
|
var _now = now();
|
||
|
if (!previous && options.leading === false) previous = _now;
|
||
|
var remaining = wait - (_now - previous);
|
||
|
context = this;
|
||
|
args = arguments;
|
||
|
if (remaining <= 0 || remaining > wait) {
|
||
|
if (timeout) {
|
||
|
clearTimeout(timeout);
|
||
|
timeout = null;
|
||
|
}
|
||
|
previous = _now;
|
||
|
result = func.apply(context, args);
|
||
|
if (!timeout) context = args = null;
|
||
|
} else if (!timeout && options.trailing !== false) {
|
||
|
timeout = setTimeout(later, remaining);
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
throttled.cancel = function() {
|
||
|
clearTimeout(timeout);
|
||
|
previous = 0;
|
||
|
timeout = context = args = null;
|
||
|
};
|
||
|
|
||
|
return throttled;
|
||
|
}
|
||
|
function debounce(func, wait, immediate) {
|
||
|
var timeout, result;
|
||
|
|
||
|
var later = function(context, args) {
|
||
|
timeout = null;
|
||
|
if (args) result = func.apply(context, args);
|
||
|
};
|
||
|
|
||
|
var debounced = restArguments(function(args) {
|
||
|
if (timeout) clearTimeout(timeout);
|
||
|
if (immediate) {
|
||
|
var callNow = !timeout;
|
||
|
timeout = setTimeout(later, wait);
|
||
|
if (callNow) result = func.apply(this, args);
|
||
|
} else {
|
||
|
timeout = delay(later, wait, this, args);
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
});
|
||
|
|
||
|
debounced.cancel = function() {
|
||
|
clearTimeout(timeout);
|
||
|
timeout = null;
|
||
|
};
|
||
|
|
||
|
return debounced;
|
||
|
}
|
||
|
function wrap(func, wrapper) {
|
||
|
return partial(wrapper, func);
|
||
|
}
|
||
|
function negate(predicate) {
|
||
|
return function() {
|
||
|
return !predicate.apply(this, arguments);
|
||
|
};
|
||
|
}
|
||
|
function compose() {
|
||
|
var args = arguments;
|
||
|
var start = args.length - 1;
|
||
|
return function() {
|
||
|
var i = start;
|
||
|
var result = args[start].apply(this, arguments);
|
||
|
while (i--) result = args[i].call(this, result);
|
||
|
return result;
|
||
|
};
|
||
|
}
|
||
|
function after(times, func) {
|
||
|
return function() {
|
||
|
if (--times < 1) {
|
||
|
return func.apply(this, arguments);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
function before(times, func) {
|
||
|
var memo;
|
||
|
return function() {
|
||
|
if (--times > 0) {
|
||
|
memo = func.apply(this, arguments);
|
||
|
}
|
||
|
if (times <= 1) func = null;
|
||
|
return memo;
|
||
|
};
|
||
|
}
|
||
|
var once = partial(before, 2);
|
||
|
var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
|
||
|
var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
|
||
|
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
|
||
|
|
||
|
function collectNonEnumProps(obj, _keys) {
|
||
|
var nonEnumIdx = nonEnumerableProps.length;
|
||
|
var constructor = obj.constructor;
|
||
|
var proto = isFunction(constructor) && constructor.prototype || ObjProto;
|
||
|
var prop = 'constructor';
|
||
|
if (_has(obj, prop) && !contains(_keys, prop)) _keys.push(prop);
|
||
|
|
||
|
while (nonEnumIdx--) {
|
||
|
prop = nonEnumerableProps[nonEnumIdx];
|
||
|
if (prop in obj && obj[prop] !== proto[prop] && !contains(_keys, prop)) {
|
||
|
_keys.push(prop);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function keys(obj) {
|
||
|
if (!isObject(obj)) return [];
|
||
|
if (nativeKeys) return nativeKeys(obj);
|
||
|
var _keys = [];
|
||
|
for (var key in obj) if (_has(obj, key)) _keys.push(key);
|
||
|
if (hasEnumBug) collectNonEnumProps(obj, _keys);
|
||
|
return _keys;
|
||
|
}
|
||
|
function allKeys(obj) {
|
||
|
if (!isObject(obj)) return [];
|
||
|
var _keys = [];
|
||
|
for (var key in obj) _keys.push(key);
|
||
|
if (hasEnumBug) collectNonEnumProps(obj, _keys);
|
||
|
return _keys;
|
||
|
}
|
||
|
function values(obj) {
|
||
|
var _keys = keys(obj);
|
||
|
var length = _keys.length;
|
||
|
var values = Array(length);
|
||
|
for (var i = 0; i < length; i++) {
|
||
|
values[i] = obj[_keys[i]];
|
||
|
}
|
||
|
return values;
|
||
|
}
|
||
|
function mapObject(obj, iteratee, context) {
|
||
|
iteratee = cb(iteratee, context);
|
||
|
var _keys = keys(obj),
|
||
|
length = _keys.length,
|
||
|
results = {};
|
||
|
for (var index = 0; index < length; index++) {
|
||
|
var currentKey = _keys[index];
|
||
|
results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
|
||
|
}
|
||
|
return results;
|
||
|
}
|
||
|
function pairs(obj) {
|
||
|
var _keys = keys(obj);
|
||
|
var length = _keys.length;
|
||
|
var pairs = Array(length);
|
||
|
for (var i = 0; i < length; i++) {
|
||
|
pairs[i] = [_keys[i], obj[_keys[i]]];
|
||
|
}
|
||
|
return pairs;
|
||
|
}
|
||
|
function invert(obj) {
|
||
|
var result = {};
|
||
|
var _keys = keys(obj);
|
||
|
for (var i = 0, length = _keys.length; i < length; i++) {
|
||
|
result[obj[_keys[i]]] = _keys[i];
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
function functions(obj) {
|
||
|
var names = [];
|
||
|
for (var key in obj) {
|
||
|
if (isFunction(obj[key])) names.push(key);
|
||
|
}
|
||
|
return names.sort();
|
||
|
}
|
||
|
function createAssigner(keysFunc, defaults) {
|
||
|
return function(obj) {
|
||
|
var length = arguments.length;
|
||
|
if (defaults) obj = Object(obj);
|
||
|
if (length < 2 || obj == null) return obj;
|
||
|
for (var index = 1; index < length; index++) {
|
||
|
var source = arguments[index],
|
||
|
_keys = keysFunc(source),
|
||
|
l = _keys.length;
|
||
|
for (var i = 0; i < l; i++) {
|
||
|
var key = _keys[i];
|
||
|
if (!defaults || obj[key] === void 0) obj[key] = source[key];
|
||
|
}
|
||
|
}
|
||
|
return obj;
|
||
|
};
|
||
|
}
|
||
|
var extend = createAssigner(allKeys);
|
||
|
var extendOwn = createAssigner(keys);
|
||
|
function findKey(obj, predicate, context) {
|
||
|
predicate = cb(predicate, context);
|
||
|
var _keys = keys(obj), key;
|
||
|
for (var i = 0, length = _keys.length; i < length; i++) {
|
||
|
key = _keys[i];
|
||
|
if (predicate(obj[key], key, obj)) return key;
|
||
|
}
|
||
|
}
|
||
|
function keyInObj(value, key, obj) {
|
||
|
return key in obj;
|
||
|
}
|
||
|
var pick = restArguments(function(obj, _keys) {
|
||
|
var result = {}, iteratee = _keys[0];
|
||
|
if (obj == null) return result;
|
||
|
if (isFunction(iteratee)) {
|
||
|
if (_keys.length > 1) iteratee = optimizeCb(iteratee, _keys[1]);
|
||
|
_keys = allKeys(obj);
|
||
|
} else {
|
||
|
iteratee = keyInObj;
|
||
|
_keys = _flatten(_keys, false, false);
|
||
|
obj = Object(obj);
|
||
|
}
|
||
|
for (var i = 0, length = _keys.length; i < length; i++) {
|
||
|
var key = _keys[i];
|
||
|
var value = obj[key];
|
||
|
if (iteratee(value, key, obj)) result[key] = value;
|
||
|
}
|
||
|
return result;
|
||
|
});
|
||
|
var omit = restArguments(function(obj, _keys) {
|
||
|
var iteratee = _keys[0], context;
|
||
|
if (isFunction(iteratee)) {
|
||
|
iteratee = negate(iteratee);
|
||
|
if (_keys.length > 1) context = _keys[1];
|
||
|
} else {
|
||
|
_keys = map(_flatten(_keys, false, false), String);
|
||
|
iteratee = function(value, key) {
|
||
|
return !contains(_keys, key);
|
||
|
};
|
||
|
}
|
||
|
return pick(obj, iteratee, context);
|
||
|
});
|
||
|
var defaults = createAssigner(allKeys, true);
|
||
|
function create(prototype, props) {
|
||
|
var result = baseCreate(prototype);
|
||
|
if (props) extendOwn(result, props);
|
||
|
return result;
|
||
|
}
|
||
|
function clone(obj) {
|
||
|
if (!isObject(obj)) return obj;
|
||
|
return isArray(obj) ? obj.slice() : extend({}, obj);
|
||
|
}
|
||
|
function tap(obj, interceptor) {
|
||
|
interceptor(obj);
|
||
|
return obj;
|
||
|
}
|
||
|
function isMatch(object, attrs) {
|
||
|
var _keys = keys(attrs), length = _keys.length;
|
||
|
if (object == null) return !length;
|
||
|
var obj = Object(object);
|
||
|
for (var i = 0; i < length; i++) {
|
||
|
var key = _keys[i];
|
||
|
if (attrs[key] !== obj[key] || !(key in obj)) return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
function eq(a, b, aStack, bStack) {
|
||
|
if (a === b) return a !== 0 || 1 / a === 1 / b;
|
||
|
if (a == null || b == null) return false;
|
||
|
if (a !== a) return b !== b;
|
||
|
var type = typeof a;
|
||
|
if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
|
||
|
return deepEq(a, b, aStack, bStack);
|
||
|
}
|
||
|
function deepEq(a, b, aStack, bStack) {
|
||
|
if (a instanceof _) a = a._wrapped;
|
||
|
if (b instanceof _) b = b._wrapped;
|
||
|
var className = toString.call(a);
|
||
|
if (className !== toString.call(b)) return false;
|
||
|
switch (className) {
|
||
|
case '[object RegExp]':
|
||
|
case '[object String]':
|
||
|
return '' + a === '' + b;
|
||
|
case '[object Number]':
|
||
|
if (+a !== +a) return +b !== +b;
|
||
|
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
|
||
|
case '[object Date]':
|
||
|
case '[object Boolean]':
|
||
|
return +a === +b;
|
||
|
case '[object Symbol]':
|
||
|
return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
|
||
|
}
|
||
|
|
||
|
var areArrays = className === '[object Array]';
|
||
|
if (!areArrays) {
|
||
|
if (typeof a != 'object' || typeof b != 'object') return false;
|
||
|
var aCtor = a.constructor, bCtor = b.constructor;
|
||
|
if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor &&
|
||
|
isFunction(bCtor) && bCtor instanceof bCtor)
|
||
|
&& ('constructor' in a && 'constructor' in b)) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
aStack = aStack || [];
|
||
|
bStack = bStack || [];
|
||
|
var length = aStack.length;
|
||
|
while (length--) {
|
||
|
if (aStack[length] === a) return bStack[length] === b;
|
||
|
}
|
||
|
aStack.push(a);
|
||
|
bStack.push(b);
|
||
|
if (areArrays) {
|
||
|
length = a.length;
|
||
|
if (length !== b.length) return false;
|
||
|
while (length--) {
|
||
|
if (!eq(a[length], b[length], aStack, bStack)) return false;
|
||
|
}
|
||
|
} else {
|
||
|
var _keys = keys(a), key;
|
||
|
length = _keys.length;
|
||
|
if (keys(b).length !== length) return false;
|
||
|
while (length--) {
|
||
|
key = _keys[length];
|
||
|
if (!(_has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
|
||
|
}
|
||
|
}
|
||
|
aStack.pop();
|
||
|
bStack.pop();
|
||
|
return true;
|
||
|
}
|
||
|
function isEqual(a, b) {
|
||
|
return eq(a, b);
|
||
|
}
|
||
|
function isEmpty(obj) {
|
||
|
if (obj == null) return true;
|
||
|
if (isArrayLike(obj) && (isArray(obj) || isString(obj) || isArguments(obj))) return obj.length === 0;
|
||
|
return keys(obj).length === 0;
|
||
|
}
|
||
|
function isElement(obj) {
|
||
|
return !!(obj && obj.nodeType === 1);
|
||
|
}
|
||
|
function tagTester(name) {
|
||
|
return function(obj) {
|
||
|
return toString.call(obj) === '[object ' + name + ']';
|
||
|
};
|
||
|
}
|
||
|
var isArray = nativeIsArray || tagTester('Array');
|
||
|
function isObject(obj) {
|
||
|
var type = typeof obj;
|
||
|
return type === 'function' || type === 'object' && !!obj;
|
||
|
}
|
||
|
var isArguments = tagTester('Arguments');
|
||
|
var isFunction = tagTester('Function');
|
||
|
var isString = tagTester('String');
|
||
|
var isNumber = tagTester('Number');
|
||
|
var isDate = tagTester('Date');
|
||
|
var isRegExp = tagTester('RegExp');
|
||
|
var isError = tagTester('Error');
|
||
|
var isSymbol = tagTester('Symbol');
|
||
|
var isMap = tagTester('Map');
|
||
|
var isWeakMap = tagTester('WeakMap');
|
||
|
var isSet = tagTester('Set');
|
||
|
var isWeakSet = tagTester('WeakSet');
|
||
|
(function() {
|
||
|
if (!isArguments(arguments)) {
|
||
|
isArguments = function(obj) {
|
||
|
return _has(obj, 'callee');
|
||
|
};
|
||
|
}
|
||
|
}());
|
||
|
var nodelist = root.document && root.document.childNodes;
|
||
|
if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
|
||
|
isFunction = function(obj) {
|
||
|
return typeof obj == 'function' || false;
|
||
|
};
|
||
|
}
|
||
|
function isFinite(obj) {
|
||
|
return !isSymbol(obj) && _isFinite(obj) && !_isNaN(parseFloat(obj));
|
||
|
}
|
||
|
function isNaN(obj) {
|
||
|
return isNumber(obj) && _isNaN(obj);
|
||
|
}
|
||
|
function isBoolean(obj) {
|
||
|
return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
|
||
|
}
|
||
|
function isNull(obj) {
|
||
|
return obj === null;
|
||
|
}
|
||
|
function isUndefined(obj) {
|
||
|
return obj === void 0;
|
||
|
}
|
||
|
function has(obj, path) {
|
||
|
if (!isArray(path)) {
|
||
|
return _has(obj, path);
|
||
|
}
|
||
|
var length = path.length;
|
||
|
for (var i = 0; i < length; i++) {
|
||
|
var key = path[i];
|
||
|
if (obj == null || !hasOwnProperty.call(obj, key)) {
|
||
|
return false;
|
||
|
}
|
||
|
obj = obj[key];
|
||
|
}
|
||
|
return !!length;
|
||
|
}
|
||
|
function identity(value) {
|
||
|
return value;
|
||
|
}
|
||
|
function constant(value) {
|
||
|
return function() {
|
||
|
return value;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function noop(){}
|
||
|
function property(path) {
|
||
|
if (!isArray(path)) {
|
||
|
return shallowProperty(path);
|
||
|
}
|
||
|
return function(obj) {
|
||
|
return deepGet(obj, path);
|
||
|
};
|
||
|
}
|
||
|
function propertyOf(obj) {
|
||
|
if (obj == null) {
|
||
|
return function(){};
|
||
|
}
|
||
|
return function(path) {
|
||
|
return !isArray(path) ? obj[path] : deepGet(obj, path);
|
||
|
};
|
||
|
}
|
||
|
function matcher(attrs) {
|
||
|
attrs = extendOwn({}, attrs);
|
||
|
return function(obj) {
|
||
|
return isMatch(obj, attrs);
|
||
|
};
|
||
|
}
|
||
|
function times(n, iteratee, context) {
|
||
|
var accum = Array(Math.max(0, n));
|
||
|
iteratee = optimizeCb(iteratee, context, 1);
|
||
|
for (var i = 0; i < n; i++) accum[i] = iteratee(i);
|
||
|
return accum;
|
||
|
}
|
||
|
function random(min, max) {
|
||
|
if (max == null) {
|
||
|
max = min;
|
||
|
min = 0;
|
||
|
}
|
||
|
return min + Math.floor(Math.random() * (max - min + 1));
|
||
|
}
|
||
|
var now = Date.now || function() {
|
||
|
return new Date().getTime();
|
||
|
};
|
||
|
var escapeMap = {
|
||
|
'&': '&',
|
||
|
'<': '<',
|
||
|
'>': '>',
|
||
|
'"': '"',
|
||
|
"'": ''',
|
||
|
'`': '`'
|
||
|
};
|
||
|
var unescapeMap = invert(escapeMap);
|
||
|
function createEscaper(map) {
|
||
|
var escaper = function(match) {
|
||
|
return map[match];
|
||
|
};
|
||
|
var source = '(?:' + keys(map).join('|') + ')';
|
||
|
var testRegexp = RegExp(source);
|
||
|
var replaceRegexp = RegExp(source, 'g');
|
||
|
return function(string) {
|
||
|
string = string == null ? '' : '' + string;
|
||
|
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
|
||
|
};
|
||
|
}
|
||
|
var escape = createEscaper(escapeMap);
|
||
|
var unescape = createEscaper(unescapeMap);
|
||
|
function result(obj, path, fallback) {
|
||
|
if (!isArray(path)) path = [path];
|
||
|
var length = path.length;
|
||
|
if (!length) {
|
||
|
return isFunction(fallback) ? fallback.call(obj) : fallback;
|
||
|
}
|
||
|
for (var i = 0; i < length; i++) {
|
||
|
var prop = obj == null ? void 0 : obj[path[i]];
|
||
|
if (prop === void 0) {
|
||
|
prop = fallback;
|
||
|
i = length; // Ensure we don't continue iterating.
|
||
|
}
|
||
|
obj = isFunction(prop) ? prop.call(obj) : prop;
|
||
|
}
|
||
|
return obj;
|
||
|
}
|
||
|
var idCounter = 0;
|
||
|
function uniqueId(prefix) {
|
||
|
var id = ++idCounter + '';
|
||
|
return prefix ? prefix + id : id;
|
||
|
}
|
||
|
var templateSettings = _.templateSettings = {
|
||
|
evaluate: /<%([\s\S]+?)%>/g,
|
||
|
interpolate: /<%=([\s\S]+?)%>/g,
|
||
|
escape: /<%-([\s\S]+?)%>/g
|
||
|
};
|
||
|
var noMatch = /(.)^/;
|
||
|
var escapes = {
|
||
|
"'": "'",
|
||
|
'\\': '\\',
|
||
|
'\r': 'r',
|
||
|
'\n': 'n',
|
||
|
'\u2028': 'u2028',
|
||
|
'\u2029': 'u2029'
|
||
|
};
|
||
|
|
||
|
var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
|
||
|
|
||
|
var escapeChar = function(match) {
|
||
|
return '\\' + escapes[match];
|
||
|
};
|
||
|
function template(text, settings, oldSettings) {
|
||
|
if (!settings && oldSettings) settings = oldSettings;
|
||
|
settings = defaults({}, settings, _.templateSettings);
|
||
|
var matcher = RegExp([
|
||
|
(settings.escape || noMatch).source,
|
||
|
(settings.interpolate || noMatch).source,
|
||
|
(settings.evaluate || noMatch).source
|
||
|
].join('|') + '|$', 'g');
|
||
|
var index = 0;
|
||
|
var source = "__p+='";
|
||
|
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
|
||
|
source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
|
||
|
index = offset + match.length;
|
||
|
|
||
|
if (escape) {
|
||
|
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
|
||
|
} else if (interpolate) {
|
||
|
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
|
||
|
} else if (evaluate) {
|
||
|
source += "';\n" + evaluate + "\n__p+='";
|
||
|
}
|
||
|
return match;
|
||
|
});
|
||
|
source += "';\n";
|
||
|
if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
|
||
|
|
||
|
source = "var __t,__p='',__j=Array.prototype.join," +
|
||
|
"print=function(){__p+=__j.call(arguments,'');};\n" +
|
||
|
source + 'return __p;\n';
|
||
|
|
||
|
var render;
|
||
|
try {
|
||
|
render = new Function(settings.variable || 'obj', '_', source);
|
||
|
} catch (e) {
|
||
|
e.source = source;
|
||
|
throw e;
|
||
|
}
|
||
|
|
||
|
var template = function(data) {
|
||
|
return render.call(this, data, _);
|
||
|
};
|
||
|
var argument = settings.variable || 'obj';
|
||
|
template.source = 'function(' + argument + '){\n' + source + '}';
|
||
|
|
||
|
return template;
|
||
|
}
|
||
|
function chain(obj) {
|
||
|
var instance = _(obj);
|
||
|
instance._chain = true;
|
||
|
return instance;
|
||
|
}
|
||
|
function chainResult(instance, obj) {
|
||
|
return instance._chain ? _(obj).chain() : obj;
|
||
|
}
|
||
|
function mixin(obj) {
|
||
|
each(functions(obj), function(name) {
|
||
|
var func = _[name] = obj[name];
|
||
|
_.prototype[name] = function() {
|
||
|
var args = [this._wrapped];
|
||
|
push.apply(args, arguments);
|
||
|
return chainResult(this, func.apply(_, args));
|
||
|
};
|
||
|
});
|
||
|
return _;
|
||
|
}
|
||
|
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
|
||
|
var method = ArrayProto[name];
|
||
|
_.prototype[name] = function() {
|
||
|
var obj = this._wrapped;
|
||
|
method.apply(obj, arguments);
|
||
|
if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
|
||
|
return chainResult(this, obj);
|
||
|
};
|
||
|
});
|
||
|
each(['concat', 'join', 'slice'], function(name) {
|
||
|
var method = ArrayProto[name];
|
||
|
_.prototype[name] = function() {
|
||
|
return chainResult(this, method.apply(this._wrapped, arguments));
|
||
|
};
|
||
|
});
|
||
|
_.prototype.value = function() {
|
||
|
return this._wrapped;
|
||
|
};
|
||
|
_.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
|
||
|
|
||
|
_.prototype.toString = function() {
|
||
|
return String(this._wrapped);
|
||
|
};
|
||
|
|
||
|
var allExports = ({
|
||
|
'default': _,
|
||
|
VERSION: VERSION,
|
||
|
iteratee: iteratee,
|
||
|
restArguments: restArguments,
|
||
|
each: each,
|
||
|
forEach: each,
|
||
|
map: map,
|
||
|
collect: map,
|
||
|
reduce: reduce,
|
||
|
foldl: reduce,
|
||
|
inject: reduce,
|
||
|
reduceRight: reduceRight,
|
||
|
foldr: reduceRight,
|
||
|
find: find,
|
||
|
detect: find,
|
||
|
filter: filter,
|
||
|
select: filter,
|
||
|
reject: reject,
|
||
|
every: every,
|
||
|
all: every,
|
||
|
some: some,
|
||
|
any: some,
|
||
|
contains: contains,
|
||
|
includes: contains,
|
||
|
include: contains,
|
||
|
invoke: invoke,
|
||
|
pluck: pluck,
|
||
|
where: where,
|
||
|
findWhere: findWhere,
|
||
|
max: max,
|
||
|
min: min,
|
||
|
shuffle: shuffle,
|
||
|
sample: sample,
|
||
|
sortBy: sortBy,
|
||
|
groupBy: groupBy,
|
||
|
indexBy: indexBy,
|
||
|
countBy: countBy,
|
||
|
toArray: toArray,
|
||
|
size: size,
|
||
|
partition: partition,
|
||
|
first: first,
|
||
|
head: first,
|
||
|
take: first,
|
||
|
initial: initial,
|
||
|
last: last,
|
||
|
rest: rest,
|
||
|
tail: rest,
|
||
|
drop: rest,
|
||
|
compact: compact,
|
||
|
flatten: flatten,
|
||
|
without: without,
|
||
|
uniq: uniq,
|
||
|
unique: uniq,
|
||
|
union: union,
|
||
|
intersection: intersection,
|
||
|
difference: difference,
|
||
|
unzip: unzip,
|
||
|
zip: zip,
|
||
|
object: object,
|
||
|
findIndex: findIndex,
|
||
|
findLastIndex: findLastIndex,
|
||
|
sortedIndex: sortedIndex,
|
||
|
indexOf: indexOf,
|
||
|
lastIndexOf: lastIndexOf,
|
||
|
range: range,
|
||
|
chunk: chunk,
|
||
|
bind: bind,
|
||
|
partial: partial,
|
||
|
bindAll: bindAll,
|
||
|
memoize: memoize,
|
||
|
delay: delay,
|
||
|
defer: defer,
|
||
|
throttle: throttle,
|
||
|
debounce: debounce,
|
||
|
wrap: wrap,
|
||
|
negate: negate,
|
||
|
compose: compose,
|
||
|
after: after,
|
||
|
before: before,
|
||
|
once: once,
|
||
|
keys: keys,
|
||
|
allKeys: allKeys,
|
||
|
values: values,
|
||
|
mapObject: mapObject,
|
||
|
pairs: pairs,
|
||
|
invert: invert,
|
||
|
functions: functions,
|
||
|
methods: functions,
|
||
|
extend: extend,
|
||
|
extendOwn: extendOwn,
|
||
|
assign: extendOwn,
|
||
|
findKey: findKey,
|
||
|
pick: pick,
|
||
|
omit: omit,
|
||
|
defaults: defaults,
|
||
|
create: create,
|
||
|
clone: clone,
|
||
|
tap: tap,
|
||
|
isMatch: isMatch,
|
||
|
isEqual: isEqual,
|
||
|
isEmpty: isEmpty,
|
||
|
isElement: isElement,
|
||
|
isArray: isArray,
|
||
|
isObject: isObject,
|
||
|
isArguments: isArguments,
|
||
|
isFunction: isFunction,
|
||
|
isString: isString,
|
||
|
isNumber: isNumber,
|
||
|
isDate: isDate,
|
||
|
isRegExp: isRegExp,
|
||
|
isError: isError,
|
||
|
isSymbol: isSymbol,
|
||
|
isMap: isMap,
|
||
|
isWeakMap: isWeakMap,
|
||
|
isSet: isSet,
|
||
|
isWeakSet: isWeakSet,
|
||
|
isFinite: isFinite,
|
||
|
isNaN: isNaN,
|
||
|
isBoolean: isBoolean,
|
||
|
isNull: isNull,
|
||
|
isUndefined: isUndefined,
|
||
|
has: has,
|
||
|
identity: identity,
|
||
|
constant: constant,
|
||
|
noop: noop,
|
||
|
property: property,
|
||
|
propertyOf: propertyOf,
|
||
|
matcher: matcher,
|
||
|
matches: matcher,
|
||
|
times: times,
|
||
|
random: random,
|
||
|
now: now,
|
||
|
escape: escape,
|
||
|
unescape: unescape,
|
||
|
result: result,
|
||
|
uniqueId: uniqueId,
|
||
|
templateSettings: templateSettings,
|
||
|
template: template,
|
||
|
chain: chain,
|
||
|
mixin: mixin
|
||
|
});
|
||
|
var _$1 = mixin(allExports);
|
||
|
_$1._ = _$1;
|
||
|
|
||
|
return _$1;
|
||
|
|
||
|
})));
|
||
|
|
||
|
|
||
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
|
},{}],"/../../jshint/src/jshint.js":[function(_dereq_,module,exports){
|
||
|
|
||
|
var _ = _dereq_("underscore");
|
||
|
_.clone = _dereq_("lodash.clone");
|
||
|
var events = _dereq_("events");
|
||
|
var vars = _dereq_("./vars.js");
|
||
|
var messages = _dereq_("./messages.js");
|
||
|
var Lexer = _dereq_("./lex.js").Lexer;
|
||
|
var reg = _dereq_("./reg.js");
|
||
|
var state = _dereq_("./state.js").state;
|
||
|
var style = _dereq_("./style.js");
|
||
|
var options = _dereq_("./options.js");
|
||
|
var scopeManager = _dereq_("./scope-manager.js");
|
||
|
var prodParams = _dereq_("./prod-params.js");
|
||
|
var console = _dereq_("console-browserify");
|
||
|
|
||
|
var JSHINT = (function() {
|
||
|
"use strict";
|
||
|
|
||
|
var api, // Extension API
|
||
|
bang = {
|
||
|
"<" : true,
|
||
|
"<=" : true,
|
||
|
"==" : true,
|
||
|
"===": true,
|
||
|
"!==": true,
|
||
|
"!=" : true,
|
||
|
">" : true,
|
||
|
">=" : true,
|
||
|
"+" : true,
|
||
|
"-" : true,
|
||
|
"*" : true,
|
||
|
"/" : true,
|
||
|
"%" : true
|
||
|
},
|
||
|
|
||
|
declared, // Globals that were declared using /*global ... */ syntax.
|
||
|
|
||
|
functions, // All of the functions
|
||
|
|
||
|
inblock,
|
||
|
indent,
|
||
|
lookahead,
|
||
|
lex,
|
||
|
member,
|
||
|
membersOnly,
|
||
|
predefined, // Global variables defined by option
|
||
|
|
||
|
extraModules = [],
|
||
|
emitter = new events.EventEmitter();
|
||
|
|
||
|
function checkOption(name, isStable, t) {
|
||
|
var type, validNames;
|
||
|
|
||
|
if (isStable) {
|
||
|
type = "";
|
||
|
validNames = options.validNames;
|
||
|
} else {
|
||
|
type = "unstable ";
|
||
|
validNames = options.unstableNames;
|
||
|
}
|
||
|
|
||
|
name = name.trim();
|
||
|
|
||
|
if (/^[+-]W\d{3}$/g.test(name)) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (validNames.indexOf(name) === -1) {
|
||
|
if (t.type !== "jslint" && !_.has(options.removed, name)) {
|
||
|
error("E001", t, type, name);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
function isString(obj) {
|
||
|
return Object.prototype.toString.call(obj) === "[object String]";
|
||
|
}
|
||
|
|
||
|
function isIdentifier(tkn, value) {
|
||
|
if (!tkn)
|
||
|
return false;
|
||
|
|
||
|
if (!tkn.identifier || tkn.value !== value)
|
||
|
return false;
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
function isReserved(context, token) {
|
||
|
if (!token.reserved) {
|
||
|
return false;
|
||
|
}
|
||
|
var meta = token.meta;
|
||
|
|
||
|
if (meta && meta.isFutureReservedWord) {
|
||
|
if (state.inES5()) {
|
||
|
if (!meta.es5) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (token.isProperty) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
} else if (meta && meta.es5 && !state.inES5()) {
|
||
|
return false;
|
||
|
}
|
||
|
if (meta && meta.strictOnly && state.inES5()) {
|
||
|
if (!state.option.strict && !state.isStrict()) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (token.id === "await" && (!(context & prodParams.async) && !state.option.module)) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (token.id === "yield" && (!(context & prodParams.yield))) {
|
||
|
return state.isStrict();
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
function supplant(str, data) {
|
||
|
return str.replace(/\{([^{}]*)\}/g, function(a, b) {
|
||
|
var r = data[b];
|
||
|
return typeof r === "string" || typeof r === "number" ? r : a;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function combine(dest, src) {
|
||
|
Object.keys(src).forEach(function(name) {
|
||
|
if (_.has(JSHINT.blacklist, name)) return;
|
||
|
dest[name] = src[name];
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function processenforceall() {
|
||
|
if (state.option.enforceall) {
|
||
|
for (var enforceopt in options.bool.enforcing) {
|
||
|
if (state.option[enforceopt] === undefined &&
|
||
|
!options.noenforceall[enforceopt]) {
|
||
|
state.option[enforceopt] = true;
|
||
|
}
|
||
|
}
|
||
|
for (var relaxopt in options.bool.relaxing) {
|
||
|
if (state.option[relaxopt] === undefined) {
|
||
|
state.option[relaxopt] = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function applyOptions() {
|
||
|
var badESOpt = null;
|
||
|
processenforceall();
|
||
|
badESOpt = state.inferEsVersion();
|
||
|
if (badESOpt) {
|
||
|
quit("E059", state.tokens.next, "esversion", badESOpt);
|
||
|
}
|
||
|
|
||
|
if (state.inES5()) {
|
||
|
combine(predefined, vars.ecmaIdentifiers[5]);
|
||
|
}
|
||
|
|
||
|
if (state.inES6()) {
|
||
|
combine(predefined, vars.ecmaIdentifiers[6]);
|
||
|
}
|
||
|
|
||
|
if (state.inES8()) {
|
||
|
combine(predefined, vars.ecmaIdentifiers[8]);
|
||
|
}
|
||
|
if (state.option.strict === "global" && "globalstrict" in state.option) {
|
||
|
quit("E059", state.tokens.next, "strict", "globalstrict");
|
||
|
}
|
||
|
|
||
|
if (state.option.module) {
|
||
|
if (!state.inES6()) {
|
||
|
warning("W134", state.tokens.next, "module", 6);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.option.regexpu) {
|
||
|
if (!state.inES6()) {
|
||
|
warning("W134", state.tokens.next, "regexpu", 6);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.option.couch) {
|
||
|
combine(predefined, vars.couch);
|
||
|
}
|
||
|
|
||
|
if (state.option.qunit) {
|
||
|
combine(predefined, vars.qunit);
|
||
|
}
|
||
|
|
||
|
if (state.option.rhino) {
|
||
|
combine(predefined, vars.rhino);
|
||
|
}
|
||
|
|
||
|
if (state.option.shelljs) {
|
||
|
combine(predefined, vars.shelljs);
|
||
|
combine(predefined, vars.node);
|
||
|
}
|
||
|
if (state.option.typed) {
|
||
|
combine(predefined, vars.typed);
|
||
|
}
|
||
|
|
||
|
if (state.option.phantom) {
|
||
|
combine(predefined, vars.phantom);
|
||
|
}
|
||
|
|
||
|
if (state.option.prototypejs) {
|
||
|
combine(predefined, vars.prototypejs);
|
||
|
}
|
||
|
|
||
|
if (state.option.node) {
|
||
|
combine(predefined, vars.node);
|
||
|
combine(predefined, vars.typed);
|
||
|
}
|
||
|
|
||
|
if (state.option.devel) {
|
||
|
combine(predefined, vars.devel);
|
||
|
}
|
||
|
|
||
|
if (state.option.dojo) {
|
||
|
combine(predefined, vars.dojo);
|
||
|
}
|
||
|
|
||
|
if (state.option.browser) {
|
||
|
combine(predefined, vars.browser);
|
||
|
combine(predefined, vars.typed);
|
||
|
}
|
||
|
|
||
|
if (state.option.browserify) {
|
||
|
combine(predefined, vars.browser);
|
||
|
combine(predefined, vars.typed);
|
||
|
combine(predefined, vars.browserify);
|
||
|
}
|
||
|
|
||
|
if (state.option.nonstandard) {
|
||
|
combine(predefined, vars.nonstandard);
|
||
|
}
|
||
|
|
||
|
if (state.option.jasmine) {
|
||
|
combine(predefined, vars.jasmine);
|
||
|
}
|
||
|
|
||
|
if (state.option.jquery) {
|
||
|
combine(predefined, vars.jquery);
|
||
|
}
|
||
|
|
||
|
if (state.option.mootools) {
|
||
|
combine(predefined, vars.mootools);
|
||
|
}
|
||
|
|
||
|
if (state.option.worker) {
|
||
|
combine(predefined, vars.worker);
|
||
|
}
|
||
|
|
||
|
if (state.option.wsh) {
|
||
|
combine(predefined, vars.wsh);
|
||
|
}
|
||
|
|
||
|
if (state.option.yui) {
|
||
|
combine(predefined, vars.yui);
|
||
|
}
|
||
|
|
||
|
if (state.option.mocha) {
|
||
|
combine(predefined, vars.mocha);
|
||
|
}
|
||
|
}
|
||
|
function quit(code, token, a, b) {
|
||
|
var percentage = Math.floor((token.line / state.lines.length) * 100);
|
||
|
var message = messages.errors[code].desc;
|
||
|
|
||
|
var exception = {
|
||
|
name: "JSHintError",
|
||
|
line: token.line,
|
||
|
character: token.from,
|
||
|
message: message + " (" + percentage + "% scanned).",
|
||
|
raw: message,
|
||
|
code: code,
|
||
|
a: a,
|
||
|
b: b
|
||
|
};
|
||
|
|
||
|
exception.reason = supplant(message, exception) + " (" + percentage +
|
||
|
"% scanned).";
|
||
|
|
||
|
throw exception;
|
||
|
}
|
||
|
|
||
|
function removeIgnoredMessages() {
|
||
|
var ignored = state.ignoredLines;
|
||
|
|
||
|
if (_.isEmpty(ignored)) return;
|
||
|
JSHINT.errors = _.reject(JSHINT.errors, function(err) { return ignored[err.line] });
|
||
|
}
|
||
|
|
||
|
function warning(code, t, a, b, c, d) {
|
||
|
var ch, l, w, msg;
|
||
|
|
||
|
if (/^W\d{3}$/.test(code)) {
|
||
|
if (state.ignored[code])
|
||
|
return;
|
||
|
|
||
|
msg = messages.warnings[code];
|
||
|
} else if (/E\d{3}/.test(code)) {
|
||
|
msg = messages.errors[code];
|
||
|
} else if (/I\d{3}/.test(code)) {
|
||
|
msg = messages.info[code];
|
||
|
}
|
||
|
|
||
|
t = t || state.tokens.next || {};
|
||
|
if (t.id === "(end)") { // `~
|
||
|
t = state.tokens.curr;
|
||
|
}
|
||
|
|
||
|
l = t.line;
|
||
|
ch = t.from;
|
||
|
|
||
|
w = {
|
||
|
id: "(error)",
|
||
|
raw: msg.desc,
|
||
|
code: msg.code,
|
||
|
evidence: state.lines[l - 1] || "",
|
||
|
line: l,
|
||
|
character: ch,
|
||
|
scope: JSHINT.scope,
|
||
|
a: a,
|
||
|
b: b,
|
||
|
c: c,
|
||
|
d: d
|
||
|
};
|
||
|
|
||
|
w.reason = supplant(msg.desc, w);
|
||
|
JSHINT.errors.push(w);
|
||
|
|
||
|
removeIgnoredMessages();
|
||
|
|
||
|
if (JSHINT.errors.length >= state.option.maxerr)
|
||
|
quit("E043", t);
|
||
|
|
||
|
return w;
|
||
|
}
|
||
|
|
||
|
function warningAt(m, l, ch, a, b, c, d) {
|
||
|
return warning(m, {
|
||
|
line: l,
|
||
|
from: ch
|
||
|
}, a, b, c, d);
|
||
|
}
|
||
|
|
||
|
function error(m, t, a, b, c, d) {
|
||
|
warning(m, t, a, b, c, d);
|
||
|
}
|
||
|
|
||
|
function errorAt(m, l, ch, a, b, c, d) {
|
||
|
return error(m, {
|
||
|
line: l,
|
||
|
from: ch
|
||
|
}, a, b, c, d);
|
||
|
}
|
||
|
function addEvalCode(elem, token) {
|
||
|
JSHINT.internals.push({
|
||
|
id: "(internal)",
|
||
|
elem: elem,
|
||
|
token: token,
|
||
|
code: token.value.replace(/([^\\])(\\*)\2\\n/g, "$1\n")
|
||
|
});
|
||
|
}
|
||
|
function lintingDirective(directiveToken, previous) {
|
||
|
var body = directiveToken.body.split(",")
|
||
|
.map(function(s) { return s.trim(); });
|
||
|
var predef = {};
|
||
|
|
||
|
if (directiveToken.type === "falls through") {
|
||
|
previous.caseFallsThrough = true;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (directiveToken.type === "globals") {
|
||
|
body.forEach(function(item, idx) {
|
||
|
var parts = item.split(":");
|
||
|
var key = parts[0].trim();
|
||
|
|
||
|
if (key === "-" || !key.length) {
|
||
|
if (idx > 0 && idx === body.length - 1) {
|
||
|
return;
|
||
|
}
|
||
|
error("E002", directiveToken);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key.charAt(0) === "-") {
|
||
|
key = key.slice(1);
|
||
|
|
||
|
JSHINT.blacklist[key] = key;
|
||
|
delete predefined[key];
|
||
|
} else {
|
||
|
predef[key] = parts.length > 1 && parts[1].trim() === "true";
|
||
|
}
|
||
|
});
|
||
|
|
||
|
combine(predefined, predef);
|
||
|
|
||
|
for (var key in predef) {
|
||
|
if (_.has(predef, key)) {
|
||
|
declared[key] = directiveToken;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (directiveToken.type === "exported") {
|
||
|
body.forEach(function(e, idx) {
|
||
|
if (!e.length) {
|
||
|
if (idx > 0 && idx === body.length - 1) {
|
||
|
return;
|
||
|
}
|
||
|
error("E002", directiveToken);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
state.funct["(scope)"].addExported(e);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (directiveToken.type === "members") {
|
||
|
membersOnly = membersOnly || {};
|
||
|
|
||
|
body.forEach(function(m) {
|
||
|
var ch1 = m.charAt(0);
|
||
|
var ch2 = m.charAt(m.length - 1);
|
||
|
|
||
|
if (ch1 === ch2 && (ch1 === "\"" || ch1 === "'")) {
|
||
|
m = m
|
||
|
.substr(1, m.length - 2)
|
||
|
.replace("\\\"", "\"");
|
||
|
}
|
||
|
|
||
|
membersOnly[m] = false;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
var numvals = [
|
||
|
"maxstatements",
|
||
|
"maxparams",
|
||
|
"maxdepth",
|
||
|
"maxcomplexity",
|
||
|
"maxerr",
|
||
|
"maxlen",
|
||
|
"indent"
|
||
|
];
|
||
|
|
||
|
if (directiveToken.type === "jshint" || directiveToken.type === "jslint" ||
|
||
|
directiveToken.type === "jshint.unstable") {
|
||
|
body.forEach(function(item) {
|
||
|
var parts = item.split(":");
|
||
|
var key = parts[0].trim();
|
||
|
var val = parts.length > 1 ? parts[1].trim() : "";
|
||
|
var numberVal;
|
||
|
|
||
|
if (!checkOption(key, directiveToken.type !== "jshint.unstable", directiveToken)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (numvals.indexOf(key) >= 0) {
|
||
|
if (val !== "false") {
|
||
|
numberVal = +val;
|
||
|
|
||
|
if (typeof numberVal !== "number" || !isFinite(numberVal) ||
|
||
|
numberVal <= 0 || Math.floor(numberVal) !== numberVal) {
|
||
|
error("E032", directiveToken, val);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
state.option[key] = numberVal;
|
||
|
} else {
|
||
|
state.option[key] = key === "indent" ? 4 : false;
|
||
|
}
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "validthis") {
|
||
|
|
||
|
if (state.funct["(global)"])
|
||
|
return void error("E009");
|
||
|
|
||
|
if (val !== "true" && val !== "false")
|
||
|
return void error("E002", directiveToken);
|
||
|
|
||
|
state.option.validthis = (val === "true");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "quotmark") {
|
||
|
switch (val) {
|
||
|
case "true":
|
||
|
case "false":
|
||
|
state.option.quotmark = (val === "true");
|
||
|
break;
|
||
|
case "double":
|
||
|
case "single":
|
||
|
state.option.quotmark = val;
|
||
|
break;
|
||
|
default:
|
||
|
error("E002", directiveToken);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "shadow") {
|
||
|
switch (val) {
|
||
|
case "true":
|
||
|
state.option.shadow = true;
|
||
|
break;
|
||
|
case "outer":
|
||
|
state.option.shadow = "outer";
|
||
|
break;
|
||
|
case "false":
|
||
|
case "inner":
|
||
|
state.option.shadow = "inner";
|
||
|
break;
|
||
|
default:
|
||
|
error("E002", directiveToken);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "unused") {
|
||
|
switch (val) {
|
||
|
case "true":
|
||
|
state.option.unused = true;
|
||
|
break;
|
||
|
case "false":
|
||
|
state.option.unused = false;
|
||
|
break;
|
||
|
case "vars":
|
||
|
case "strict":
|
||
|
state.option.unused = val;
|
||
|
break;
|
||
|
default:
|
||
|
error("E002", directiveToken);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "latedef") {
|
||
|
switch (val) {
|
||
|
case "true":
|
||
|
state.option.latedef = true;
|
||
|
break;
|
||
|
case "false":
|
||
|
state.option.latedef = false;
|
||
|
break;
|
||
|
case "nofunc":
|
||
|
state.option.latedef = "nofunc";
|
||
|
break;
|
||
|
default:
|
||
|
error("E002", directiveToken);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "ignore") {
|
||
|
switch (val) {
|
||
|
case "line":
|
||
|
state.ignoredLines[directiveToken.line] = true;
|
||
|
removeIgnoredMessages();
|
||
|
break;
|
||
|
default:
|
||
|
error("E002", directiveToken);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "strict") {
|
||
|
switch (val) {
|
||
|
case "true":
|
||
|
state.option.strict = true;
|
||
|
break;
|
||
|
case "false":
|
||
|
state.option.strict = false;
|
||
|
break;
|
||
|
case "global":
|
||
|
case "implied":
|
||
|
state.option.strict = val;
|
||
|
break;
|
||
|
default:
|
||
|
error("E002", directiveToken);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (key === "module") {
|
||
|
if (!hasParsedCode(state.funct)) {
|
||
|
error("E055", directiveToken, "module");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (key === "esversion") {
|
||
|
switch (val) {
|
||
|
case "3":
|
||
|
case "5":
|
||
|
case "6":
|
||
|
case "7":
|
||
|
case "8":
|
||
|
case "9":
|
||
|
case "10":
|
||
|
state.option.moz = false;
|
||
|
state.option.esversion = +val;
|
||
|
break;
|
||
|
case "2015":
|
||
|
case "2016":
|
||
|
case "2017":
|
||
|
case "2018":
|
||
|
case "2019":
|
||
|
state.option.moz = false;
|
||
|
state.option.esversion = +val - 2009;
|
||
|
break;
|
||
|
default:
|
||
|
error("E002", directiveToken);
|
||
|
}
|
||
|
if (!hasParsedCode(state.funct)) {
|
||
|
error("E055", directiveToken, "esversion");
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var match = /^([+-])(W\d{3})$/g.exec(key);
|
||
|
if (match) {
|
||
|
state.ignored[match[2]] = (match[1] === "-");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var tn;
|
||
|
if (val === "true" || val === "false") {
|
||
|
if (directiveToken.type === "jslint") {
|
||
|
tn = options.renamed[key] || key;
|
||
|
state.option[tn] = (val === "true");
|
||
|
|
||
|
if (options.inverted[tn] !== undefined) {
|
||
|
state.option[tn] = !state.option[tn];
|
||
|
}
|
||
|
} else if (directiveToken.type === "jshint.unstable") {
|
||
|
state.option.unstable[key] = (val === "true");
|
||
|
} else {
|
||
|
state.option[key] = (val === "true");
|
||
|
}
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
error("E002", directiveToken);
|
||
|
});
|
||
|
|
||
|
applyOptions();
|
||
|
}
|
||
|
}
|
||
|
function peek(p) {
|
||
|
var i = p || 0, j = lookahead.length, t;
|
||
|
|
||
|
if (i < j) {
|
||
|
return lookahead[i];
|
||
|
}
|
||
|
|
||
|
while (j <= i) {
|
||
|
t = lex.token();
|
||
|
if (!t) {
|
||
|
if (!lookahead.length) {
|
||
|
return state.tokens.next;
|
||
|
}
|
||
|
|
||
|
return lookahead[j - 1];
|
||
|
}
|
||
|
|
||
|
lookahead[j] = t;
|
||
|
j += 1;
|
||
|
}
|
||
|
|
||
|
return t;
|
||
|
}
|
||
|
|
||
|
function peekIgnoreEOL() {
|
||
|
var i = 0;
|
||
|
var t;
|
||
|
do {
|
||
|
t = peek(i++);
|
||
|
} while (t.id === "(endline)");
|
||
|
return t;
|
||
|
}
|
||
|
function advance(expected, relatedToken) {
|
||
|
var nextToken = state.tokens.next;
|
||
|
|
||
|
if (expected && nextToken.id !== expected) {
|
||
|
if (relatedToken) {
|
||
|
if (nextToken.id === "(end)") {
|
||
|
error("E019", relatedToken, relatedToken.id);
|
||
|
} else {
|
||
|
error("E020", nextToken, expected, relatedToken.id,
|
||
|
relatedToken.line, nextToken.value);
|
||
|
}
|
||
|
} else if (nextToken.type !== "(identifier)" || nextToken.value !== expected) {
|
||
|
error("E021", nextToken, expected, nextToken.value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
state.tokens.prev = state.tokens.curr;
|
||
|
state.tokens.curr = state.tokens.next;
|
||
|
for (;;) {
|
||
|
state.tokens.next = lookahead.shift() || lex.token();
|
||
|
|
||
|
if (!state.tokens.next) { // No more tokens left, give up
|
||
|
quit("E041", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "(end)" || state.tokens.next.id === "(error)") {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.check) {
|
||
|
state.tokens.next.check();
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.isSpecial) {
|
||
|
lintingDirective(state.tokens.next, state.tokens.curr);
|
||
|
} else {
|
||
|
if (state.tokens.next.id !== "(endline)") {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function isOperator(token) {
|
||
|
return token.first || token.right || token.left || token.id === "yield" || token.id === "await";
|
||
|
}
|
||
|
|
||
|
function isEndOfExpr(context, curr, next) {
|
||
|
if (arguments.length <= 1) {
|
||
|
curr = state.tokens.curr;
|
||
|
next = state.tokens.next;
|
||
|
}
|
||
|
|
||
|
if (next.id === "in" && context & prodParams.noin) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (next.id === ";" || next.id === "}" || next.id === ":") {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (next.infix === curr.infix ||
|
||
|
(curr.id === "yield" && curr.rbp < next.rbp)) {
|
||
|
return !sameLine(curr, next);
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
function expression(context, rbp) {
|
||
|
var left, isArray = false, isObject = false;
|
||
|
var initial = context & prodParams.initial;
|
||
|
var curr;
|
||
|
|
||
|
context &= ~prodParams.initial;
|
||
|
|
||
|
state.nameStack.push();
|
||
|
|
||
|
if (state.tokens.next.id === "(end)")
|
||
|
error("E006", state.tokens.curr);
|
||
|
|
||
|
advance();
|
||
|
|
||
|
if (initial) {
|
||
|
state.funct["(verb)"] = state.tokens.curr.value;
|
||
|
state.tokens.curr.beginsStmt = true;
|
||
|
}
|
||
|
|
||
|
curr = state.tokens.curr;
|
||
|
|
||
|
if (initial && curr.fud && (!curr.useFud || curr.useFud(context))) {
|
||
|
left = state.tokens.curr.fud(context);
|
||
|
} else {
|
||
|
if (state.tokens.curr.nud) {
|
||
|
left = state.tokens.curr.nud(context, rbp);
|
||
|
} else {
|
||
|
error("E030", state.tokens.curr, state.tokens.curr.id);
|
||
|
}
|
||
|
|
||
|
while (rbp < state.tokens.next.lbp && !isEndOfExpr(context)) {
|
||
|
isArray = state.tokens.curr.value === "Array";
|
||
|
isObject = state.tokens.curr.value === "Object";
|
||
|
if (left && (left.value || (left.first && left.first.value))) {
|
||
|
if (left.value !== "new" ||
|
||
|
(left.first && left.first.value && left.first.value === ".")) {
|
||
|
isArray = false;
|
||
|
if (left.value !== state.tokens.curr.value) {
|
||
|
isObject = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
advance();
|
||
|
|
||
|
if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
|
||
|
warning("W009", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
|
||
|
warning("W010", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
if (left && state.tokens.curr.led) {
|
||
|
left = state.tokens.curr.led(context, left);
|
||
|
} else {
|
||
|
error("E033", state.tokens.curr, state.tokens.curr.id);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
state.nameStack.pop();
|
||
|
|
||
|
return left;
|
||
|
}
|
||
|
|
||
|
function sameLine(first, second) {
|
||
|
return first.line === (second.startLine || second.line);
|
||
|
}
|
||
|
|
||
|
function nobreaknonadjacent(left, right) {
|
||
|
if (!state.option.laxbreak && !sameLine(left, right)) {
|
||
|
warning("W014", right, right.value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function nolinebreak(t) {
|
||
|
t = t;
|
||
|
if (!sameLine(t, state.tokens.next)) {
|
||
|
warning("E022", t, t.value);
|
||
|
}
|
||
|
}
|
||
|
function checkComma(opts) {
|
||
|
var prev = state.tokens.prev;
|
||
|
var curr = state.tokens.curr;
|
||
|
opts = opts || {};
|
||
|
|
||
|
if (!sameLine(prev, curr)) {
|
||
|
if (!state.option.laxcomma) {
|
||
|
if (checkComma.first) {
|
||
|
warning("I001", curr);
|
||
|
checkComma.first = false;
|
||
|
}
|
||
|
warning("W014", prev, curr.value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.identifier && !(opts.property && state.inES5())) {
|
||
|
switch (state.tokens.next.value) {
|
||
|
case "break":
|
||
|
case "case":
|
||
|
case "catch":
|
||
|
case "continue":
|
||
|
case "default":
|
||
|
case "do":
|
||
|
case "else":
|
||
|
case "finally":
|
||
|
case "for":
|
||
|
case "if":
|
||
|
case "in":
|
||
|
case "instanceof":
|
||
|
case "return":
|
||
|
case "switch":
|
||
|
case "throw":
|
||
|
case "try":
|
||
|
case "var":
|
||
|
case "let":
|
||
|
case "while":
|
||
|
case "with":
|
||
|
error("E024", state.tokens.next, state.tokens.next.value);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.type === "(punctuator)") {
|
||
|
switch (state.tokens.next.value) {
|
||
|
case "}":
|
||
|
case "]":
|
||
|
case ",":
|
||
|
case ")":
|
||
|
if (opts.allowTrailing) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
error("E024", state.tokens.next, state.tokens.next.value);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
function symbol(s, p) {
|
||
|
var x = state.syntax[s];
|
||
|
if (!x || typeof x !== "object") {
|
||
|
state.syntax[s] = x = {
|
||
|
id: s,
|
||
|
lbp: p,
|
||
|
rbp: p,
|
||
|
value: s
|
||
|
};
|
||
|
}
|
||
|
return x;
|
||
|
}
|
||
|
function delim(s) {
|
||
|
var x = symbol(s, 0);
|
||
|
x.delim = true;
|
||
|
return x;
|
||
|
}
|
||
|
function stmt(s, f) {
|
||
|
var x = delim(s);
|
||
|
x.identifier = x.reserved = true;
|
||
|
x.fud = f;
|
||
|
return x;
|
||
|
}
|
||
|
function blockstmt(s, f) {
|
||
|
var x = stmt(s, f);
|
||
|
x.block = true;
|
||
|
return x;
|
||
|
}
|
||
|
function reserveName(x) {
|
||
|
var c = x.id.charAt(0);
|
||
|
if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) {
|
||
|
x.identifier = x.reserved = true;
|
||
|
}
|
||
|
return x;
|
||
|
}
|
||
|
function prefix(s, f) {
|
||
|
var x = symbol(s, 150);
|
||
|
reserveName(x);
|
||
|
|
||
|
x.nud = (typeof f === "function") ? f : function(context) {
|
||
|
this.arity = "unary";
|
||
|
this.right = expression(context, 150);
|
||
|
|
||
|
if (this.id === "++" || this.id === "--") {
|
||
|
if (state.option.plusplus) {
|
||
|
warning("W016", this, this.id);
|
||
|
}
|
||
|
|
||
|
if (this.right) {
|
||
|
checkLeftSideAssign(context, this.right, this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
return x;
|
||
|
}
|
||
|
function type(s, f) {
|
||
|
var x = symbol(s, 0);
|
||
|
x.type = s;
|
||
|
x.nud = f;
|
||
|
return x;
|
||
|
}
|
||
|
function reserve(name, func) {
|
||
|
var x = type(name, func);
|
||
|
x.identifier = true;
|
||
|
x.reserved = true;
|
||
|
return x;
|
||
|
}
|
||
|
function FutureReservedWord(name, meta) {
|
||
|
var x = type(name, state.syntax["(identifier)"].nud);
|
||
|
|
||
|
meta = meta || {};
|
||
|
meta.isFutureReservedWord = true;
|
||
|
|
||
|
x.value = name;
|
||
|
x.identifier = true;
|
||
|
x.reserved = true;
|
||
|
x.meta = meta;
|
||
|
|
||
|
return x;
|
||
|
}
|
||
|
function infix(s, f, p, w) {
|
||
|
var x = symbol(s, p);
|
||
|
reserveName(x);
|
||
|
x.infix = true;
|
||
|
x.led = function(context, left) {
|
||
|
if (!w) {
|
||
|
nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
|
||
|
}
|
||
|
if ((s === "in" || s === "instanceof") && left.id === "!") {
|
||
|
warning("W018", left, "!");
|
||
|
}
|
||
|
if (typeof f === "function") {
|
||
|
return f(context, left, this);
|
||
|
} else {
|
||
|
this.left = left;
|
||
|
this.right = expression(context, p);
|
||
|
return this;
|
||
|
}
|
||
|
};
|
||
|
return x;
|
||
|
}
|
||
|
function application(s) {
|
||
|
var x = symbol(s, 42);
|
||
|
|
||
|
x.infix = true;
|
||
|
x.led = function(context, left) {
|
||
|
nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
|
||
|
|
||
|
this.left = left;
|
||
|
this.right = doFunction(context, { type: "arrow", loneArg: left });
|
||
|
return this;
|
||
|
};
|
||
|
return x;
|
||
|
}
|
||
|
function relation(s, f) {
|
||
|
var x = symbol(s, 100);
|
||
|
|
||
|
x.infix = true;
|
||
|
x.led = function(context, left) {
|
||
|
nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
|
||
|
this.left = left;
|
||
|
var right = this.right = expression(context, 100);
|
||
|
|
||
|
if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) {
|
||
|
warning("W019", this);
|
||
|
} else if (f) {
|
||
|
f.apply(this, [context, left, right]);
|
||
|
}
|
||
|
|
||
|
if (!left || !right) {
|
||
|
quit("E041", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
if (left.id === "!") {
|
||
|
warning("W018", left, "!");
|
||
|
}
|
||
|
|
||
|
if (right.id === "!") {
|
||
|
warning("W018", right, "!");
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
};
|
||
|
return x;
|
||
|
}
|
||
|
function beginsUnaryExpression(token) {
|
||
|
return token.arity === "unary" && token.id !== "++" && token.id !== "--";
|
||
|
}
|
||
|
|
||
|
var typeofValues = {};
|
||
|
typeofValues.legacy = [
|
||
|
"xml",
|
||
|
"unknown"
|
||
|
];
|
||
|
typeofValues.es3 = [
|
||
|
"undefined", "boolean", "number", "string", "function", "object",
|
||
|
];
|
||
|
typeofValues.es3 = typeofValues.es3.concat(typeofValues.legacy);
|
||
|
typeofValues.es6 = typeofValues.es3.concat("symbol", "bigint");
|
||
|
function isTypoTypeof(left, right, state) {
|
||
|
var values;
|
||
|
|
||
|
if (state.option.notypeof)
|
||
|
return false;
|
||
|
|
||
|
if (!left || !right)
|
||
|
return false;
|
||
|
|
||
|
values = state.inES6() ? typeofValues.es6 : typeofValues.es3;
|
||
|
|
||
|
if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)") {
|
||
|
if (left.value === "bigint") {
|
||
|
if (!state.option.unstable.bigint) {
|
||
|
warning("W144", left, "BigInt", "bigint");
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return !_.includes(values, left.value);
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
function isGlobalEval(left, state) {
|
||
|
var isGlobal = false;
|
||
|
if (left.type === "this" && state.funct["(context)"] === null) {
|
||
|
isGlobal = true;
|
||
|
}
|
||
|
else if (left.type === "(identifier)") {
|
||
|
if (state.option.node && left.value === "global") {
|
||
|
isGlobal = true;
|
||
|
}
|
||
|
|
||
|
else if (state.option.browser && (left.value === "window" || left.value === "document")) {
|
||
|
isGlobal = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return isGlobal;
|
||
|
}
|
||
|
function findNativePrototype(left) {
|
||
|
var natives = [
|
||
|
"Array", "ArrayBuffer", "Boolean", "Collator", "DataView", "Date",
|
||
|
"DateTimeFormat", "Error", "EvalError", "Float32Array", "Float64Array",
|
||
|
"Function", "Infinity", "Intl", "Int16Array", "Int32Array", "Int8Array",
|
||
|
"Iterator", "Number", "NumberFormat", "Object", "RangeError",
|
||
|
"ReferenceError", "RegExp", "StopIteration", "String", "SyntaxError",
|
||
|
"TypeError", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray",
|
||
|
"URIError"
|
||
|
];
|
||
|
|
||
|
function walkPrototype(obj) {
|
||
|
if (typeof obj !== "object") return;
|
||
|
return obj.right === "prototype" ? obj : walkPrototype(obj.left);
|
||
|
}
|
||
|
|
||
|
function walkNative(obj) {
|
||
|
while (!obj.identifier && typeof obj.left === "object")
|
||
|
obj = obj.left;
|
||
|
|
||
|
if (obj.identifier && natives.indexOf(obj.value) >= 0 &&
|
||
|
state.funct["(scope)"].isPredefined(obj.value)) {
|
||
|
return obj.value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var prototype = walkPrototype(left);
|
||
|
if (prototype) return walkNative(prototype);
|
||
|
}
|
||
|
function checkLeftSideAssign(context, left, assignToken, options) {
|
||
|
|
||
|
var allowDestructuring = options && options.allowDestructuring;
|
||
|
|
||
|
assignToken = assignToken || left;
|
||
|
|
||
|
if (state.option.freeze) {
|
||
|
var nativeObject = findNativePrototype(left);
|
||
|
if (nativeObject)
|
||
|
warning("W121", left, nativeObject);
|
||
|
}
|
||
|
|
||
|
if (left.identifier && !left.isMetaProperty) {
|
||
|
state.funct["(scope)"].block.reassign(left.value, left);
|
||
|
}
|
||
|
|
||
|
if (left.id === ".") {
|
||
|
if (!left.left || left.left.value === "arguments" && !state.isStrict()) {
|
||
|
warning("W143", assignToken);
|
||
|
}
|
||
|
|
||
|
state.nameStack.set(state.tokens.prev);
|
||
|
return true;
|
||
|
} else if (left.id === "{" || left.id === "[") {
|
||
|
if (!allowDestructuring || !left.destructAssign) {
|
||
|
if (left.id === "{" || !left.left) {
|
||
|
warning("E031", assignToken);
|
||
|
} else if (left.left.value === "arguments" && !state.isStrict()) {
|
||
|
warning("W143", assignToken);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (left.id === "[") {
|
||
|
state.nameStack.set(left.right);
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
} else if (left.identifier && !isReserved(context, left) && !left.isMetaProperty) {
|
||
|
if (state.funct["(scope)"].bindingtype(left.value) === "exception") {
|
||
|
warning("W022", left);
|
||
|
}
|
||
|
|
||
|
if (left.value === "eval" && state.isStrict()) {
|
||
|
error("E031", assignToken);
|
||
|
return false;
|
||
|
} else if (left.value === "arguments") {
|
||
|
if (!state.isStrict()) {
|
||
|
warning("W143", assignToken);
|
||
|
} else {
|
||
|
error("E031", assignToken);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
state.nameStack.set(left);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
error("E031", assignToken);
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
function assignop(s, f) {
|
||
|
var x = infix(s, typeof f === "function" ? f : function(context, left, that) {
|
||
|
that.left = left;
|
||
|
|
||
|
checkLeftSideAssign(context, left, that, { allowDestructuring: true });
|
||
|
|
||
|
that.right = expression(context, 10);
|
||
|
|
||
|
return that;
|
||
|
}, 20);
|
||
|
|
||
|
x.exps = true;
|
||
|
x.assign = true;
|
||
|
|
||
|
return x;
|
||
|
}
|
||
|
function bitwise(s, f, p) {
|
||
|
var x = symbol(s, p);
|
||
|
reserveName(x);
|
||
|
x.infix = true;
|
||
|
x.led = (typeof f === "function") ? f : function(context, left) {
|
||
|
if (state.option.bitwise) {
|
||
|
warning("W016", this, this.id);
|
||
|
}
|
||
|
this.left = left;
|
||
|
this.right = expression(context, p);
|
||
|
return this;
|
||
|
};
|
||
|
return x;
|
||
|
}
|
||
|
function bitwiseassignop(s) {
|
||
|
symbol(s, 20).exps = true;
|
||
|
return infix(s, function(context, left, that) {
|
||
|
if (state.option.bitwise) {
|
||
|
warning("W016", that, that.id);
|
||
|
}
|
||
|
|
||
|
checkLeftSideAssign(context, left, that);
|
||
|
|
||
|
that.right = expression(context, 10);
|
||
|
|
||
|
return that;
|
||
|
}, 20);
|
||
|
}
|
||
|
function suffix(s) {
|
||
|
var x = symbol(s, 150);
|
||
|
|
||
|
x.led = function(context, left) {
|
||
|
if (state.option.plusplus) {
|
||
|
warning("W016", this, this.id);
|
||
|
}
|
||
|
|
||
|
checkLeftSideAssign(context, left, this);
|
||
|
|
||
|
this.left = left;
|
||
|
return this;
|
||
|
};
|
||
|
return x;
|
||
|
}
|
||
|
function optionalidentifier(context, prop, preserve) {
|
||
|
if (!state.tokens.next.identifier) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!preserve) {
|
||
|
advance();
|
||
|
}
|
||
|
|
||
|
var curr = state.tokens.curr;
|
||
|
var val = state.tokens.curr.value;
|
||
|
|
||
|
if (!isReserved(context, curr)) {
|
||
|
return val;
|
||
|
}
|
||
|
|
||
|
if (prop) {
|
||
|
if (state.inES5()) {
|
||
|
return val;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
warning("W024", state.tokens.curr, state.tokens.curr.id);
|
||
|
return val;
|
||
|
}
|
||
|
function spreadrest(operation) {
|
||
|
if (!checkPunctuator(state.tokens.next, "...")) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (!state.inES6(true)) {
|
||
|
warning("W119", state.tokens.next, operation + " operator", "6");
|
||
|
}
|
||
|
advance();
|
||
|
|
||
|
if (checkPunctuator(state.tokens.next, "...")) {
|
||
|
warning("E024", state.tokens.next, "...");
|
||
|
while (checkPunctuator(state.tokens.next, "...")) {
|
||
|
advance();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
function identifier(context, prop) {
|
||
|
var i = optionalidentifier(context, prop, false);
|
||
|
if (i) {
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
error("E030", state.tokens.next, state.tokens.next.value);
|
||
|
if (state.tokens.next.id !== ";") {
|
||
|
advance();
|
||
|
}
|
||
|
}
|
||
|
function reachable(controlToken) {
|
||
|
var i = 0, t;
|
||
|
if (state.tokens.next.id !== ";" || controlToken.inBracelessBlock) {
|
||
|
return;
|
||
|
}
|
||
|
for (;;) {
|
||
|
do {
|
||
|
t = peek(i);
|
||
|
i += 1;
|
||
|
} while (t.id !== "(end)" && t.id === "(comment)");
|
||
|
|
||
|
if (t.reach) {
|
||
|
return;
|
||
|
}
|
||
|
if (t.id !== "(endline)") {
|
||
|
if (t.id === "function") {
|
||
|
if (state.option.latedef === true) {
|
||
|
warning("W026", t);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
warning("W027", t, t.value, controlToken.value);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function parseFinalSemicolon(stmt) {
|
||
|
if (state.tokens.next.id !== ";") {
|
||
|
if (state.tokens.next.isUnclosed) return advance();
|
||
|
|
||
|
var isSameLine = sameLine(state.tokens.curr, state.tokens.next) &&
|
||
|
state.tokens.next.id !== "(end)";
|
||
|
var blockEnd = checkPunctuator(state.tokens.next, "}");
|
||
|
|
||
|
if (isSameLine && !blockEnd && !(stmt.id === "do" && state.inES6(true))) {
|
||
|
errorAt("E058", state.tokens.curr.line, state.tokens.curr.character);
|
||
|
} else if (!state.option.asi) {
|
||
|
if (!(blockEnd && isSameLine && state.option.lastsemic)) {
|
||
|
warningAt("W033", state.tokens.curr.line, state.tokens.curr.character);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
advance(";");
|
||
|
}
|
||
|
}
|
||
|
function statement(context) {
|
||
|
var i = indent, r, t = state.tokens.next, hasOwnScope = false;
|
||
|
|
||
|
context |= prodParams.initial;
|
||
|
|
||
|
if (t.id === ";") {
|
||
|
advance(";");
|
||
|
return;
|
||
|
}
|
||
|
var res = isReserved(context, t);
|
||
|
|
||
|
if (res && t.meta && t.meta.isFutureReservedWord && !t.fud) {
|
||
|
warning("W024", t, t.id);
|
||
|
res = false;
|
||
|
}
|
||
|
|
||
|
if (t.identifier && !res && peek().id === ":") {
|
||
|
advance();
|
||
|
advance(":");
|
||
|
|
||
|
hasOwnScope = true;
|
||
|
state.funct["(scope)"].stack();
|
||
|
state.funct["(scope)"].block.addLabel(t.value, { token: state.tokens.curr });
|
||
|
|
||
|
if (!state.tokens.next.labelled && state.tokens.next.value !== "{") {
|
||
|
warning("W028", state.tokens.next, t.value, state.tokens.next.value);
|
||
|
}
|
||
|
|
||
|
t = state.tokens.next;
|
||
|
}
|
||
|
|
||
|
if (t.id === "{") {
|
||
|
var iscase = (state.funct["(verb)"] === "case" && state.tokens.curr.value === ":");
|
||
|
block(context, true, true, false, false, iscase);
|
||
|
|
||
|
if (hasOwnScope) {
|
||
|
state.funct["(scope)"].unstack();
|
||
|
}
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
r = expression(context, 0);
|
||
|
|
||
|
if (r && !(r.identifier && r.value === "function") &&
|
||
|
!(r.type === "(punctuator)" && r.left &&
|
||
|
r.left.identifier && r.left.value === "function")) {
|
||
|
if (!state.isStrict() && state.stmtMissingStrict()) {
|
||
|
warning("E007");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!t.block) {
|
||
|
if (!state.option.expr && (!r || !r.exps)) {
|
||
|
warning("W030", state.tokens.curr);
|
||
|
} else if (state.option.nonew && r && r.left && r.id === "(" && r.left.id === "new") {
|
||
|
warning("W031", t);
|
||
|
}
|
||
|
|
||
|
parseFinalSemicolon(t);
|
||
|
}
|
||
|
|
||
|
indent = i;
|
||
|
if (hasOwnScope) {
|
||
|
state.funct["(scope)"].unstack();
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
function statements(context) {
|
||
|
var a = [], p;
|
||
|
|
||
|
while (!state.tokens.next.reach && state.tokens.next.id !== "(end)") {
|
||
|
if (state.tokens.next.id === ";") {
|
||
|
p = peek();
|
||
|
|
||
|
if (!p || (p.id !== "(" && p.id !== "[")) {
|
||
|
warning("W032");
|
||
|
}
|
||
|
|
||
|
advance(";");
|
||
|
} else {
|
||
|
a.push(statement(context));
|
||
|
}
|
||
|
}
|
||
|
return a;
|
||
|
}
|
||
|
function directives() {
|
||
|
var current = state.tokens.next;
|
||
|
while (state.tokens.next.id === "(string)") {
|
||
|
var next = peekIgnoreEOL();
|
||
|
if (!isEndOfExpr(0, current, next)) {
|
||
|
break;
|
||
|
}
|
||
|
current = next;
|
||
|
|
||
|
advance();
|
||
|
var directive = state.tokens.curr.value;
|
||
|
if (state.directive[directive] ||
|
||
|
(directive === "use strict" && state.option.strict === "implied")) {
|
||
|
warning("W034", state.tokens.curr, directive);
|
||
|
}
|
||
|
if (directive === "use strict" && state.inES7() &&
|
||
|
!state.funct["(global)"] && state.funct["(hasSimpleParams)"] === false) {
|
||
|
error("E065", state.tokens.curr);
|
||
|
}
|
||
|
state.directive[directive] = true;
|
||
|
|
||
|
parseFinalSemicolon(current);
|
||
|
}
|
||
|
|
||
|
if (state.isStrict()) {
|
||
|
state.option.undef = true;
|
||
|
}
|
||
|
}
|
||
|
function block(context, ordinary, stmt, isfunc, isfatarrow, iscase) {
|
||
|
var a,
|
||
|
b = inblock,
|
||
|
old_indent = indent,
|
||
|
m,
|
||
|
t,
|
||
|
d;
|
||
|
|
||
|
inblock = ordinary;
|
||
|
|
||
|
t = state.tokens.next;
|
||
|
|
||
|
var metrics = state.funct["(metrics)"];
|
||
|
metrics.nestedBlockDepth += 1;
|
||
|
metrics.verifyMaxNestedBlockDepthPerFunction();
|
||
|
|
||
|
if (state.tokens.next.id === "{") {
|
||
|
advance("{");
|
||
|
state.funct["(scope)"].stack();
|
||
|
|
||
|
if (state.tokens.next.id !== "}") {
|
||
|
indent += state.option.indent;
|
||
|
while (!ordinary && state.tokens.next.from > indent) {
|
||
|
indent += state.option.indent;
|
||
|
}
|
||
|
|
||
|
if (isfunc) {
|
||
|
m = {};
|
||
|
for (d in state.directive) {
|
||
|
m[d] = state.directive[d];
|
||
|
}
|
||
|
directives();
|
||
|
|
||
|
state.funct["(isStrict)"] = state.isStrict();
|
||
|
|
||
|
if (state.option.strict && state.funct["(context)"]["(global)"]) {
|
||
|
if (!m["use strict"] && !state.isStrict()) {
|
||
|
warning("E007");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
a = statements(context);
|
||
|
|
||
|
metrics.statementCount += a.length;
|
||
|
|
||
|
indent -= state.option.indent;
|
||
|
} else if (isfunc) {
|
||
|
state.funct["(isStrict)"] = state.isStrict();
|
||
|
}
|
||
|
|
||
|
advance("}", t);
|
||
|
|
||
|
if (isfunc) {
|
||
|
state.funct["(scope)"].validateParams(isfatarrow);
|
||
|
if (m) {
|
||
|
state.directive = m;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
state.funct["(scope)"].unstack();
|
||
|
|
||
|
indent = old_indent;
|
||
|
} else if (!ordinary) {
|
||
|
if (isfunc) {
|
||
|
state.funct["(scope)"].stack();
|
||
|
|
||
|
if (stmt && !isfatarrow && !state.inMoz()) {
|
||
|
error("W118", state.tokens.curr, "function closure expressions");
|
||
|
}
|
||
|
|
||
|
if (isfatarrow) {
|
||
|
state.funct["(scope)"].validateParams(true);
|
||
|
}
|
||
|
|
||
|
var expr = expression(context, 10);
|
||
|
|
||
|
if (state.option.noreturnawait && context & prodParams.async &&
|
||
|
expr.identifier && expr.value === "await") {
|
||
|
warning("W146", expr);
|
||
|
}
|
||
|
|
||
|
if (state.option.strict && state.funct["(context)"]["(global)"]) {
|
||
|
if (!state.isStrict()) {
|
||
|
warning("E007");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
state.funct["(scope)"].unstack();
|
||
|
} else {
|
||
|
error("E021", state.tokens.next, "{", state.tokens.next.value);
|
||
|
}
|
||
|
} else {
|
||
|
|
||
|
state.funct["(scope)"].stack();
|
||
|
|
||
|
if (!stmt || state.option.curly) {
|
||
|
warning("W116", state.tokens.next, "{", state.tokens.next.value);
|
||
|
}
|
||
|
var supportsFnDecl = state.funct["(verb)"] === "if" ||
|
||
|
state.tokens.curr.id === "else";
|
||
|
|
||
|
state.tokens.next.inBracelessBlock = true;
|
||
|
indent += state.option.indent;
|
||
|
a = [statement(context)];
|
||
|
indent -= state.option.indent;
|
||
|
|
||
|
if (a[0] && a[0].declaration &&
|
||
|
!(supportsFnDecl && a[0].id === "function")) {
|
||
|
error("E048", a[0], a[0].id[0].toUpperCase() + a[0].id.slice(1));
|
||
|
}
|
||
|
|
||
|
state.funct["(scope)"].unstack();
|
||
|
}
|
||
|
switch (state.funct["(verb)"]) {
|
||
|
case "break":
|
||
|
case "continue":
|
||
|
case "return":
|
||
|
case "throw":
|
||
|
if (iscase) {
|
||
|
break;
|
||
|
}
|
||
|
default:
|
||
|
state.funct["(verb)"] = null;
|
||
|
}
|
||
|
|
||
|
inblock = b;
|
||
|
if (ordinary && state.option.noempty && (!a || a.length === 0)) {
|
||
|
warning("W035", state.tokens.prev);
|
||
|
}
|
||
|
metrics.nestedBlockDepth -= 1;
|
||
|
return a;
|
||
|
}
|
||
|
function countMember(m) {
|
||
|
if (membersOnly && typeof membersOnly[m] !== "boolean") {
|
||
|
warning("W036", state.tokens.curr, m);
|
||
|
}
|
||
|
if (typeof member[m] === "number") {
|
||
|
member[m] += 1;
|
||
|
} else {
|
||
|
member[m] = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type("(number)", function() {
|
||
|
if (state.tokens.next.id === ".") {
|
||
|
warning("W005", this);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
type("(string)", function() {
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
state.syntax["(identifier)"] = {
|
||
|
type: "(identifier)",
|
||
|
lbp: 0,
|
||
|
identifier: true,
|
||
|
|
||
|
nud: function(context) {
|
||
|
var v = this.value;
|
||
|
var isLoneArrowParam = state.tokens.next.id === "=>";
|
||
|
|
||
|
if (isReserved(context, this)) {
|
||
|
warning("W024", this, v);
|
||
|
} else if (!isLoneArrowParam && !state.funct["(comparray)"].check(v)) {
|
||
|
state.funct["(scope)"].block.use(v, state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
},
|
||
|
|
||
|
led: function() {
|
||
|
error("E033", state.tokens.next, state.tokens.next.value);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var baseTemplateSyntax = {
|
||
|
identifier: false,
|
||
|
template: true,
|
||
|
};
|
||
|
state.syntax["(template)"] = _.extend({
|
||
|
lbp: 155,
|
||
|
type: "(template)",
|
||
|
nud: doTemplateLiteral,
|
||
|
led: doTemplateLiteral,
|
||
|
noSubst: false
|
||
|
}, baseTemplateSyntax);
|
||
|
|
||
|
state.syntax["(template middle)"] = _.extend({
|
||
|
lbp: 0,
|
||
|
type: "(template middle)",
|
||
|
noSubst: false
|
||
|
}, baseTemplateSyntax);
|
||
|
|
||
|
state.syntax["(template tail)"] = _.extend({
|
||
|
lbp: 0,
|
||
|
type: "(template tail)",
|
||
|
tail: true,
|
||
|
noSubst: false
|
||
|
}, baseTemplateSyntax);
|
||
|
|
||
|
state.syntax["(no subst template)"] = _.extend({
|
||
|
lbp: 155,
|
||
|
type: "(template)",
|
||
|
nud: doTemplateLiteral,
|
||
|
led: doTemplateLiteral,
|
||
|
noSubst: true,
|
||
|
tail: true // mark as tail, since it's always the last component
|
||
|
}, baseTemplateSyntax);
|
||
|
|
||
|
type("(regexp)", function() {
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
delim("(endline)");
|
||
|
(function(x) {
|
||
|
x.line = x.from = 0;
|
||
|
})(delim("(begin)"));
|
||
|
delim("(end)").reach = true;
|
||
|
delim("(error)").reach = true;
|
||
|
delim("}").reach = true;
|
||
|
delim(")");
|
||
|
delim("]");
|
||
|
delim("\"").reach = true;
|
||
|
delim("'").reach = true;
|
||
|
delim(";");
|
||
|
delim(":").reach = true;
|
||
|
delim("#");
|
||
|
|
||
|
reserve("else");
|
||
|
reserve("case").reach = true;
|
||
|
reserve("catch");
|
||
|
reserve("default").reach = true;
|
||
|
reserve("finally");
|
||
|
reserve("true", function() { return this; });
|
||
|
reserve("false", function() { return this; });
|
||
|
reserve("null", function() { return this; });
|
||
|
reserve("this", function() {
|
||
|
if (state.isStrict() && !isMethod() &&
|
||
|
!state.option.validthis && ((state.funct["(statement)"] &&
|
||
|
state.funct["(name)"].charAt(0) > "Z") || state.funct["(global)"])) {
|
||
|
warning("W040", this);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
reserve("super", function() {
|
||
|
superNud.call(state.tokens.curr, this);
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
assignop("=", "assign");
|
||
|
assignop("+=", "assignadd");
|
||
|
assignop("-=", "assignsub");
|
||
|
assignop("*=", "assignmult");
|
||
|
assignop("/=", "assigndiv").nud = function() {
|
||
|
error("E014");
|
||
|
};
|
||
|
assignop("%=", "assignmod");
|
||
|
assignop("**=", function(context, left, that) {
|
||
|
if (!state.inES7()) {
|
||
|
warning("W119", that, "Exponentiation operator", "7");
|
||
|
}
|
||
|
|
||
|
that.left = left;
|
||
|
|
||
|
checkLeftSideAssign(context, left, that);
|
||
|
|
||
|
that.right = expression(context, 10);
|
||
|
|
||
|
return that;
|
||
|
});
|
||
|
|
||
|
bitwiseassignop("&=");
|
||
|
bitwiseassignop("|=");
|
||
|
bitwiseassignop("^=");
|
||
|
bitwiseassignop("<<=");
|
||
|
bitwiseassignop(">>=");
|
||
|
bitwiseassignop(">>>=");
|
||
|
infix(",", function(context, left, that) {
|
||
|
if (state.option.nocomma) {
|
||
|
warning("W127", that);
|
||
|
}
|
||
|
|
||
|
that.left = left;
|
||
|
|
||
|
if (checkComma()) {
|
||
|
that.right = expression(context, 10);
|
||
|
} else {
|
||
|
that.right = null;
|
||
|
}
|
||
|
|
||
|
return that;
|
||
|
}, 10, true);
|
||
|
|
||
|
infix("?", function(context, left, that) {
|
||
|
increaseComplexityCount();
|
||
|
that.left = left;
|
||
|
that.right = expression(context & ~prodParams.noin, 10);
|
||
|
advance(":");
|
||
|
expression(context, 10);
|
||
|
return that;
|
||
|
}, 30);
|
||
|
|
||
|
var orPrecendence = 40;
|
||
|
infix("||", function(context, left, that) {
|
||
|
increaseComplexityCount();
|
||
|
that.left = left;
|
||
|
that.right = expression(context, orPrecendence);
|
||
|
return that;
|
||
|
}, orPrecendence);
|
||
|
infix("&&", "and", 50);
|
||
|
infix("**", function(context, left, that) {
|
||
|
if (!state.inES7()) {
|
||
|
warning("W119", that, "Exponentiation operator", "7");
|
||
|
}
|
||
|
if (!left.paren && beginsUnaryExpression(left)) {
|
||
|
error("E024", that, "**");
|
||
|
}
|
||
|
|
||
|
that.left = left;
|
||
|
that.right = expression(context, that.rbp);
|
||
|
return that;
|
||
|
}, 150);
|
||
|
state.syntax["**"].rbp = 140;
|
||
|
bitwise("|", "bitor", 70);
|
||
|
bitwise("^", "bitxor", 80);
|
||
|
bitwise("&", "bitand", 90);
|
||
|
relation("==", function(context, left, right) {
|
||
|
var eqnull = state.option.eqnull &&
|
||
|
((left && left.value) === "null" || (right && right.value) === "null");
|
||
|
|
||
|
switch (true) {
|
||
|
case !eqnull && state.option.eqeqeq:
|
||
|
this.from = this.character;
|
||
|
warning("W116", this, "===", "==");
|
||
|
break;
|
||
|
case isTypoTypeof(right, left, state):
|
||
|
warning("W122", this, right.value);
|
||
|
break;
|
||
|
case isTypoTypeof(left, right, state):
|
||
|
warning("W122", this, left.value);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
relation("===", function(context, left, right) {
|
||
|
if (isTypoTypeof(right, left, state)) {
|
||
|
warning("W122", this, right.value);
|
||
|
} else if (isTypoTypeof(left, right, state)) {
|
||
|
warning("W122", this, left.value);
|
||
|
}
|
||
|
return this;
|
||
|
});
|
||
|
relation("!=", function(context, left, right) {
|
||
|
var eqnull = state.option.eqnull &&
|
||
|
((left && left.value) === "null" || (right && right.value) === "null");
|
||
|
|
||
|
if (!eqnull && state.option.eqeqeq) {
|
||
|
this.from = this.character;
|
||
|
warning("W116", this, "!==", "!=");
|
||
|
} else if (isTypoTypeof(right, left, state)) {
|
||
|
warning("W122", this, right.value);
|
||
|
} else if (isTypoTypeof(left, right, state)) {
|
||
|
warning("W122", this, left.value);
|
||
|
}
|
||
|
return this;
|
||
|
});
|
||
|
relation("!==", function(context, left, right) {
|
||
|
if (isTypoTypeof(right, left, state)) {
|
||
|
warning("W122", this, right.value);
|
||
|
} else if (isTypoTypeof(left, right, state)) {
|
||
|
warning("W122", this, left.value);
|
||
|
}
|
||
|
return this;
|
||
|
});
|
||
|
relation("<");
|
||
|
relation(">");
|
||
|
relation("<=");
|
||
|
relation(">=");
|
||
|
bitwise("<<", "shiftleft", 120);
|
||
|
bitwise(">>", "shiftright", 120);
|
||
|
bitwise(">>>", "shiftrightunsigned", 120);
|
||
|
infix("in", "in", 120);
|
||
|
infix("instanceof", function(context, left, token) {
|
||
|
var right;
|
||
|
var scope = state.funct["(scope)"];
|
||
|
token.left = left;
|
||
|
token.right = right = expression(context, 120);
|
||
|
if (!right) {
|
||
|
return token;
|
||
|
}
|
||
|
|
||
|
if (right.id === "(number)" ||
|
||
|
right.id === "(string)" ||
|
||
|
right.value === "null" ||
|
||
|
(right.value === "undefined" && !scope.has("undefined")) ||
|
||
|
right.arity === "unary" ||
|
||
|
right.id === "{" ||
|
||
|
(right.id === "[" && !right.right) ||
|
||
|
right.id === "(regexp)" ||
|
||
|
(right.id === "(template)" && !right.tag)) {
|
||
|
error("E060");
|
||
|
}
|
||
|
|
||
|
if (right.id === "function") {
|
||
|
warning("W139");
|
||
|
}
|
||
|
|
||
|
return token;
|
||
|
}, 120);
|
||
|
infix("+", function(context, left, that) {
|
||
|
var next = state.tokens.next;
|
||
|
var right;
|
||
|
that.left = left;
|
||
|
that.right = right = expression(context, 130);
|
||
|
|
||
|
if (left && right && left.id === "(string)" && right.id === "(string)") {
|
||
|
left.value += right.value;
|
||
|
left.character = right.character;
|
||
|
if (!state.option.scripturl && reg.javascriptURL.test(left.value)) {
|
||
|
warning("W050", left);
|
||
|
}
|
||
|
return left;
|
||
|
}
|
||
|
|
||
|
if (next.id === "+" || next.id === "++") {
|
||
|
warning("W007", that.right);
|
||
|
}
|
||
|
|
||
|
return that;
|
||
|
}, 130);
|
||
|
prefix("+", function(context) {
|
||
|
var next = state.tokens.next;
|
||
|
this.arity = "unary";
|
||
|
this.right = expression(context, 150);
|
||
|
|
||
|
if (next.id === "+" || next.id === "++") {
|
||
|
warning("W007", this.right);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
infix("-", function(context, left, that) {
|
||
|
var next = state.tokens.next;
|
||
|
that.left = left;
|
||
|
that.right = expression(context, 130);
|
||
|
|
||
|
if (next.id === "-" || next.id === "--") {
|
||
|
warning("W006", that.right);
|
||
|
}
|
||
|
|
||
|
return that;
|
||
|
}, 130);
|
||
|
prefix("-", function(context) {
|
||
|
var next = state.tokens.next;
|
||
|
this.arity = "unary";
|
||
|
this.right = expression(context, 150);
|
||
|
|
||
|
if (next.id === "-" || next.id === "--") {
|
||
|
warning("W006", this.right);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
infix("*", "mult", 140);
|
||
|
infix("/", "div", 140);
|
||
|
infix("%", "mod", 140);
|
||
|
|
||
|
suffix("++");
|
||
|
prefix("++", "preinc");
|
||
|
state.syntax["++"].exps = true;
|
||
|
|
||
|
suffix("--");
|
||
|
prefix("--", "predec");
|
||
|
state.syntax["--"].exps = true;
|
||
|
|
||
|
prefix("delete", function(context) {
|
||
|
this.arity = "unary";
|
||
|
var p = expression(context, 150);
|
||
|
if (!p) {
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
if (p.id !== "." && p.id !== "[") {
|
||
|
warning("W051");
|
||
|
}
|
||
|
this.first = p;
|
||
|
if (p.identifier && !state.isStrict()) {
|
||
|
p.forgiveUndef = true;
|
||
|
}
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
|
||
|
prefix("~", function(context) {
|
||
|
if (state.option.bitwise) {
|
||
|
warning("W016", this, "~");
|
||
|
}
|
||
|
this.arity = "unary";
|
||
|
this.right = expression(context, 150);
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
infix("...");
|
||
|
|
||
|
prefix("!", function(context) {
|
||
|
this.arity = "unary";
|
||
|
this.right = expression(context, 150);
|
||
|
|
||
|
if (!this.right) { // '!' followed by nothing? Give up.
|
||
|
quit("E041", this);
|
||
|
}
|
||
|
|
||
|
if (bang[this.right.id] === true) {
|
||
|
warning("W018", this, "!");
|
||
|
}
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
prefix("typeof", function(context) {
|
||
|
this.arity = "unary";
|
||
|
var p = expression(context, 150);
|
||
|
this.first = this.right = p;
|
||
|
|
||
|
if (!p) { // 'typeof' followed by nothing? Give up.
|
||
|
quit("E041", this);
|
||
|
}
|
||
|
if (p.identifier) {
|
||
|
p.forgiveUndef = true;
|
||
|
}
|
||
|
return this;
|
||
|
});
|
||
|
prefix("new", function(context) {
|
||
|
var mp = metaProperty(context, "target", function() {
|
||
|
if (!state.inES6(true)) {
|
||
|
warning("W119", state.tokens.prev, "new.target", "6");
|
||
|
}
|
||
|
var inFunction, c = state.funct;
|
||
|
while (c) {
|
||
|
inFunction = !c["(global)"];
|
||
|
if (!c["(arrow)"]) { break; }
|
||
|
c = c["(context)"];
|
||
|
}
|
||
|
if (!inFunction) {
|
||
|
warning("W136", state.tokens.prev, "new.target");
|
||
|
}
|
||
|
});
|
||
|
if (mp) { return mp; }
|
||
|
|
||
|
var c = expression(context, 155), i;
|
||
|
if (c && c.id !== "function") {
|
||
|
if (c.identifier) {
|
||
|
switch (c.value) {
|
||
|
case "Number":
|
||
|
case "String":
|
||
|
case "Boolean":
|
||
|
case "Math":
|
||
|
case "JSON":
|
||
|
warning("W053", state.tokens.prev, c.value);
|
||
|
break;
|
||
|
case "Symbol":
|
||
|
if (state.inES6()) {
|
||
|
warning("W053", state.tokens.prev, c.value);
|
||
|
}
|
||
|
break;
|
||
|
case "Function":
|
||
|
if (!state.option.evil) {
|
||
|
warning("W054");
|
||
|
}
|
||
|
break;
|
||
|
case "Date":
|
||
|
case "RegExp":
|
||
|
case "this":
|
||
|
break;
|
||
|
default:
|
||
|
i = c.value.substr(0, 1);
|
||
|
if (state.option.newcap && (i < "A" || i > "Z") &&
|
||
|
!state.funct["(scope)"].isPredefined(c.value)) {
|
||
|
warning("W055", state.tokens.curr);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
if (c.id !== "." && c.id !== "[" && c.id !== "(") {
|
||
|
warning("W056", state.tokens.curr);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
if (!state.option.supernew)
|
||
|
warning("W057", this);
|
||
|
}
|
||
|
if (state.tokens.next.id !== "(" && !state.option.supernew) {
|
||
|
warning("W058", state.tokens.curr, state.tokens.curr.value);
|
||
|
}
|
||
|
this.first = this.right = c;
|
||
|
return this;
|
||
|
});
|
||
|
state.syntax["new"].exps = true;
|
||
|
blockstmt("class", function(context) {
|
||
|
var className, classNameToken;
|
||
|
var inexport = context & prodParams.export;
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.curr, "class", "6");
|
||
|
}
|
||
|
state.inClassBody = true;
|
||
|
if (state.tokens.next.identifier && state.tokens.next.value !== "extends") {
|
||
|
classNameToken = state.tokens.next;
|
||
|
className = classNameToken.value;
|
||
|
identifier(context);
|
||
|
state.funct["(scope)"].addbinding(className, {
|
||
|
type: "class",
|
||
|
initialized: false,
|
||
|
token: classNameToken
|
||
|
});
|
||
|
}
|
||
|
if (state.tokens.next.value === "extends") {
|
||
|
advance("extends");
|
||
|
expression(context, 0);
|
||
|
}
|
||
|
|
||
|
if (classNameToken) {
|
||
|
this.name = className;
|
||
|
state.funct["(scope)"].initialize(className);
|
||
|
if (inexport) {
|
||
|
state.funct["(scope)"].setExported(className, classNameToken);
|
||
|
}
|
||
|
}
|
||
|
state.funct["(scope)"].stack();
|
||
|
classBody(this, context);
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
prefix("class", function(context) {
|
||
|
var className, classNameToken;
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.curr, "class", "6");
|
||
|
}
|
||
|
state.inClassBody = true;
|
||
|
if (state.tokens.next.identifier && state.tokens.next.value !== "extends") {
|
||
|
classNameToken = state.tokens.next;
|
||
|
className = classNameToken.value;
|
||
|
identifier(context);
|
||
|
}
|
||
|
if (state.tokens.next.value === "extends") {
|
||
|
advance("extends");
|
||
|
expression(context, 0);
|
||
|
}
|
||
|
|
||
|
state.funct["(scope)"].stack();
|
||
|
if (classNameToken) {
|
||
|
this.name = className;
|
||
|
state.funct["(scope)"].addbinding(className, {
|
||
|
type: "class",
|
||
|
initialized: true,
|
||
|
token: classNameToken
|
||
|
});
|
||
|
state.funct["(scope)"].block.use(className, classNameToken);
|
||
|
}
|
||
|
|
||
|
classBody(this, context);
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
function classBody(classToken, context) {
|
||
|
var props = Object.create(null);
|
||
|
var name, accessorType, token, isStatic, inGenerator, hasConstructor;
|
||
|
if (state.tokens.next.value === "{") {
|
||
|
advance("{");
|
||
|
} else {
|
||
|
warning("W116", state.tokens.curr, "identifier", state.tokens.next.type); //?
|
||
|
advance();
|
||
|
}
|
||
|
|
||
|
while (state.tokens.next.value !== "}") {
|
||
|
isStatic = false;
|
||
|
inGenerator = false;
|
||
|
context &= ~prodParams.preAsync;
|
||
|
|
||
|
if (state.tokens.next.value === "static" &&
|
||
|
!checkPunctuator(peek(), "(")) {
|
||
|
isStatic = true;
|
||
|
advance();
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value === "async") {
|
||
|
if (!checkPunctuator(peek(), "(")) {
|
||
|
context |= prodParams.preAsync;
|
||
|
advance();
|
||
|
|
||
|
nolinebreak(state.tokens.curr);
|
||
|
|
||
|
if (checkPunctuator(state.tokens.next, "*")) {
|
||
|
inGenerator = true;
|
||
|
advance("*");
|
||
|
|
||
|
if (!state.inES9()) {
|
||
|
warning("W119", state.tokens.next, "async generators", "9");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!state.inES8()) {
|
||
|
warning("W119", state.tokens.curr, "async functions", "8");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value === "*") {
|
||
|
inGenerator = true;
|
||
|
advance();
|
||
|
}
|
||
|
|
||
|
token = state.tokens.next;
|
||
|
|
||
|
if ((token.value === "set" || token.value === "get") && !checkPunctuator(peek(), "(")) {
|
||
|
if (inGenerator) {
|
||
|
error("E024", token, token.value);
|
||
|
}
|
||
|
accessorType = token.value;
|
||
|
advance();
|
||
|
token = state.tokens.next;
|
||
|
|
||
|
if (!isStatic && token.value === "constructor") {
|
||
|
error("E049", token, "class " + accessorType + "ter method", token.value);
|
||
|
} else if (isStatic && token.value === "prototype") {
|
||
|
error("E049", token, "static class " + accessorType + "ter method", token.value);
|
||
|
}
|
||
|
} else {
|
||
|
accessorType = null;
|
||
|
}
|
||
|
|
||
|
switch (token.value) {
|
||
|
case ";":
|
||
|
warning("W032", token);
|
||
|
advance();
|
||
|
break;
|
||
|
case "constructor":
|
||
|
if (isStatic) {
|
||
|
name = propertyName(context);
|
||
|
saveProperty(props, name, token, true, isStatic);
|
||
|
doMethod(classToken, context, name, inGenerator);
|
||
|
} else {
|
||
|
if (inGenerator || context & prodParams.preAsync) {
|
||
|
error("E024", token, token.value);
|
||
|
} else if (hasConstructor) {
|
||
|
error("E024", token, token.value);
|
||
|
} else {
|
||
|
hasConstructor = !accessorType && !isStatic;
|
||
|
}
|
||
|
advance();
|
||
|
doMethod(classToken, context, state.nameStack.infer());
|
||
|
}
|
||
|
break;
|
||
|
case "[":
|
||
|
name = computedPropertyName(context);
|
||
|
doMethod(classToken, context, name, inGenerator);
|
||
|
break;
|
||
|
default:
|
||
|
name = propertyName(context);
|
||
|
if (name === undefined) {
|
||
|
error("E024", token, token.value);
|
||
|
advance();
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (accessorType) {
|
||
|
saveAccessor(accessorType, props, name, token, true, isStatic);
|
||
|
name = state.nameStack.infer();
|
||
|
} else {
|
||
|
if (isStatic && name === "prototype") {
|
||
|
error("E049", token, "static class method", name);
|
||
|
}
|
||
|
|
||
|
saveProperty(props, name, token, true, isStatic);
|
||
|
}
|
||
|
|
||
|
doMethod(classToken, context, name, inGenerator);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
advance("}");
|
||
|
checkProperties(props);
|
||
|
|
||
|
state.inClassBody = false;
|
||
|
state.funct["(scope)"].unstack();
|
||
|
}
|
||
|
|
||
|
function doMethod(classToken, context, name, generator) {
|
||
|
if (generator) {
|
||
|
if (!state.inES6()) {
|
||
|
warning("W119", state.tokens.curr, "function*", "6");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value !== "(") {
|
||
|
error("E054", state.tokens.next, state.tokens.next.value);
|
||
|
advance();
|
||
|
if (state.tokens.next.value === "{") {
|
||
|
advance();
|
||
|
if (state.tokens.next.value === "}") {
|
||
|
warning("W116", state.tokens.next, "(", state.tokens.next.value);
|
||
|
advance();
|
||
|
identifier(context);
|
||
|
advance();
|
||
|
}
|
||
|
return;
|
||
|
} else {
|
||
|
while (state.tokens.next.value !== "(") {
|
||
|
advance();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
doFunction(context, { name: name,
|
||
|
type: generator ? "generator" : null,
|
||
|
isMethod: true,
|
||
|
statement: classToken });
|
||
|
}
|
||
|
|
||
|
prefix("void").exps = true;
|
||
|
|
||
|
infix(".", function(context, left, that) {
|
||
|
var m = identifier(context, true);
|
||
|
|
||
|
if (typeof m === "string") {
|
||
|
countMember(m);
|
||
|
}
|
||
|
|
||
|
that.left = left;
|
||
|
that.right = m;
|
||
|
|
||
|
if (m && m === "hasOwnProperty" && state.tokens.next.value === "=") {
|
||
|
warning("W001");
|
||
|
}
|
||
|
|
||
|
if (left && left.value === "arguments" && (m === "callee" || m === "caller")) {
|
||
|
if (state.option.noarg)
|
||
|
warning("W059", left, m);
|
||
|
else if (state.isStrict())
|
||
|
error("E008");
|
||
|
} else if (!state.option.evil && left && left.value === "document" &&
|
||
|
(m === "write" || m === "writeln")) {
|
||
|
warning("W060", left);
|
||
|
}
|
||
|
|
||
|
if (!state.option.evil && (m === "eval" || m === "execScript")) {
|
||
|
if (isGlobalEval(left, state)) {
|
||
|
warning("W061");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return that;
|
||
|
}, 160, true);
|
||
|
|
||
|
infix("(", function(context, left, that) {
|
||
|
if (state.option.immed && left && !left.immed && left.id === "function") {
|
||
|
warning("W062");
|
||
|
}
|
||
|
|
||
|
if (state.option.asi && checkPunctuators(state.tokens.prev, [")", "]"]) &&
|
||
|
!sameLine(state.tokens.prev, state.tokens.curr)) {
|
||
|
warning("W014", state.tokens.curr, state.tokens.curr.id);
|
||
|
}
|
||
|
|
||
|
var n = 0;
|
||
|
var p = [];
|
||
|
|
||
|
if (left) {
|
||
|
if (left.type === "(identifier)") {
|
||
|
if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
|
||
|
if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) {
|
||
|
if (left.value === "Math") {
|
||
|
warning("W063", left);
|
||
|
} else if (state.option.newcap) {
|
||
|
warning("W064", left);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id !== ")") {
|
||
|
for (;;) {
|
||
|
spreadrest("spread");
|
||
|
|
||
|
p[p.length] = expression(context, 10);
|
||
|
n += 1;
|
||
|
if (state.tokens.next.id !== ",") {
|
||
|
break;
|
||
|
}
|
||
|
advance(",");
|
||
|
checkComma({ allowTrailing: true });
|
||
|
|
||
|
if (state.tokens.next.id === ")") {
|
||
|
if (!state.inES8()) {
|
||
|
warning("W119", state.tokens.curr, "Trailing comma in arguments lists", "8");
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
advance(")");
|
||
|
|
||
|
if (typeof left === "object") {
|
||
|
if (!state.inES5() && left.value === "parseInt" && n === 1) {
|
||
|
warning("W065", state.tokens.curr);
|
||
|
}
|
||
|
if (!state.option.evil) {
|
||
|
if (left.value === "eval" || left.value === "Function" ||
|
||
|
left.value === "execScript") {
|
||
|
warning("W061", left);
|
||
|
} else if (p[0] && p[0].id === "(string)" &&
|
||
|
(left.value === "setTimeout" ||
|
||
|
left.value === "setInterval")) {
|
||
|
warning("W066", left);
|
||
|
addEvalCode(left, p[0]);
|
||
|
} else if (p[0] && p[0].id === "(string)" &&
|
||
|
left.value === "." &&
|
||
|
left.left.value === "window" &&
|
||
|
(left.right === "setTimeout" ||
|
||
|
left.right === "setInterval")) {
|
||
|
warning("W066", left);
|
||
|
addEvalCode(left, p[0]);
|
||
|
}
|
||
|
}
|
||
|
if (!left.identifier && left.id !== "." && left.id !== "[" && left.id !== "=>" &&
|
||
|
left.id !== "(" && left.id !== "&&" && left.id !== "||" && left.id !== "?" &&
|
||
|
left.id !== "async" && !(state.inES6() && left["(name)"])) {
|
||
|
warning("W067", that);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
that.left = left;
|
||
|
return that;
|
||
|
}, 155, true).exps = true;
|
||
|
|
||
|
function peekThroughParens(parens) {
|
||
|
var pn = state.tokens.next;
|
||
|
var i = -1;
|
||
|
var pn1;
|
||
|
|
||
|
do {
|
||
|
if (pn.value === "(") {
|
||
|
parens += 1;
|
||
|
} else if (pn.value === ")") {
|
||
|
parens -= 1;
|
||
|
}
|
||
|
|
||
|
i += 1;
|
||
|
pn1 = pn;
|
||
|
pn = peek(i);
|
||
|
} while (!(parens === 0 && pn1.value === ")") && pn.type !== "(end)");
|
||
|
|
||
|
return pn;
|
||
|
}
|
||
|
|
||
|
prefix("(", function(context, rbp) {
|
||
|
var ret, triggerFnExpr, first, last;
|
||
|
var opening = state.tokens.curr;
|
||
|
var preceeding = state.tokens.prev;
|
||
|
var isNecessary = !state.option.singleGroups;
|
||
|
var pn = peekThroughParens(1);
|
||
|
|
||
|
if (state.tokens.next.id === "function") {
|
||
|
triggerFnExpr = state.tokens.next.immed = true;
|
||
|
}
|
||
|
if (pn.value === "=>") {
|
||
|
pn.funct = doFunction(context, { type: "arrow", parsedOpening: true });
|
||
|
return pn;
|
||
|
}
|
||
|
if (state.tokens.next.id === ")") {
|
||
|
advance(")");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
ret = expression(context, 0);
|
||
|
|
||
|
advance(")", this);
|
||
|
|
||
|
if (!ret) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
ret.paren = true;
|
||
|
|
||
|
if (state.option.immed && ret && ret.id === "function") {
|
||
|
if (state.tokens.next.id !== "(" &&
|
||
|
state.tokens.next.id !== "." && state.tokens.next.id !== "[") {
|
||
|
warning("W068", this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (ret.id === ",") {
|
||
|
first = ret.left;
|
||
|
while (first.id === ",") {
|
||
|
first = first.left;
|
||
|
}
|
||
|
|
||
|
last = ret.right;
|
||
|
} else {
|
||
|
first = last = ret;
|
||
|
|
||
|
if (!isNecessary) {
|
||
|
if (!triggerFnExpr) {
|
||
|
triggerFnExpr = ret.id === "async";
|
||
|
}
|
||
|
|
||
|
isNecessary =
|
||
|
(opening.beginsStmt && (ret.id === "{" || triggerFnExpr)) ||
|
||
|
(triggerFnExpr &&
|
||
|
(!isEndOfExpr() || state.tokens.prev.id !== "}")) ||
|
||
|
(ret.id === "=>" && !isEndOfExpr()) ||
|
||
|
(ret.id === "{" && preceeding.id === "=>") ||
|
||
|
(beginsUnaryExpression(ret) && state.tokens.next.id === "**") ||
|
||
|
(ret.type === "(number)" &&
|
||
|
checkPunctuator(pn, ".") && /^\d+$/.test(ret.value)) ||
|
||
|
(opening.beginsStmt && ret.id === "=" && ret.left.id === "{");
|
||
|
}
|
||
|
}
|
||
|
if (!isNecessary && (isOperator(first) || first !== last)) {
|
||
|
isNecessary =
|
||
|
(rbp > first.lbp) ||
|
||
|
(rbp > 0 && rbp === first.lbp) ||
|
||
|
(!isEndOfExpr() && last.rbp < state.tokens.next.lbp);
|
||
|
}
|
||
|
|
||
|
if (!isNecessary) {
|
||
|
warning("W126", opening);
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
});
|
||
|
|
||
|
application("=>");
|
||
|
|
||
|
infix("[", function(context, left, that) {
|
||
|
var e, s, canUseDot;
|
||
|
|
||
|
if (state.option.asi && checkPunctuators(state.tokens.prev, [")", "]"]) &&
|
||
|
!sameLine(state.tokens.prev, state.tokens.curr)) {
|
||
|
warning("W014", state.tokens.curr, state.tokens.curr.id);
|
||
|
}
|
||
|
|
||
|
e = expression(context & ~prodParams.noin, 10);
|
||
|
|
||
|
if (e && e.type === "(string)") {
|
||
|
if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) {
|
||
|
if (isGlobalEval(left, state)) {
|
||
|
warning("W061");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
countMember(e.value);
|
||
|
if (!state.option.sub && reg.identifier.test(e.value)) {
|
||
|
s = state.syntax[e.value];
|
||
|
|
||
|
if (s) {
|
||
|
canUseDot = !isReserved(context, s);
|
||
|
} else {
|
||
|
canUseDot = e.value !== "eval" && e.value !== "arguments";
|
||
|
}
|
||
|
|
||
|
if (canUseDot) {
|
||
|
warning("W069", state.tokens.prev, e.value);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
advance("]", that);
|
||
|
|
||
|
if (e && e.value === "hasOwnProperty" && state.tokens.next.value === "=") {
|
||
|
warning("W001");
|
||
|
}
|
||
|
|
||
|
that.left = left;
|
||
|
that.right = e;
|
||
|
return that;
|
||
|
}, 160, true);
|
||
|
|
||
|
function comprehensiveArrayExpression(context) {
|
||
|
var res = {};
|
||
|
res.exps = true;
|
||
|
state.funct["(comparray)"].stack();
|
||
|
var reversed = false;
|
||
|
if (state.tokens.next.value !== "for") {
|
||
|
reversed = true;
|
||
|
if (!state.inMoz()) {
|
||
|
warning("W116", state.tokens.next, "for", state.tokens.next.value);
|
||
|
}
|
||
|
state.funct["(comparray)"].setState("use");
|
||
|
res.right = expression(context, 10);
|
||
|
}
|
||
|
|
||
|
advance("for");
|
||
|
if (state.tokens.next.value === "each") {
|
||
|
advance("each");
|
||
|
if (!state.inMoz()) {
|
||
|
warning("W118", state.tokens.curr, "for each");
|
||
|
}
|
||
|
}
|
||
|
advance("(");
|
||
|
state.funct["(comparray)"].setState("define");
|
||
|
res.left = expression(context, 130);
|
||
|
if (_.includes(["in", "of"], state.tokens.next.value)) {
|
||
|
advance();
|
||
|
} else {
|
||
|
error("E045", state.tokens.curr);
|
||
|
}
|
||
|
state.funct["(comparray)"].setState("generate");
|
||
|
expression(context, 10);
|
||
|
|
||
|
advance(")");
|
||
|
if (state.tokens.next.value === "if") {
|
||
|
advance("if");
|
||
|
advance("(");
|
||
|
state.funct["(comparray)"].setState("filter");
|
||
|
expression(context, 10);
|
||
|
advance(")");
|
||
|
}
|
||
|
|
||
|
if (!reversed) {
|
||
|
state.funct["(comparray)"].setState("use");
|
||
|
res.right = expression(context, 10);
|
||
|
}
|
||
|
|
||
|
advance("]");
|
||
|
state.funct["(comparray)"].unstack();
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
prefix("[", function(context) {
|
||
|
var blocktype = lookupBlockType();
|
||
|
if (blocktype.isCompArray) {
|
||
|
if (!state.option.esnext && !state.inMoz()) {
|
||
|
warning("W118", state.tokens.curr, "array comprehension");
|
||
|
}
|
||
|
return comprehensiveArrayExpression(context);
|
||
|
} else if (blocktype.isDestAssign) {
|
||
|
this.destructAssign = destructuringPattern(context, {
|
||
|
openingParsed: true,
|
||
|
assignment: true
|
||
|
});
|
||
|
return this;
|
||
|
}
|
||
|
var b = !sameLine(state.tokens.curr, state.tokens.next);
|
||
|
this.first = [];
|
||
|
if (b) {
|
||
|
indent += state.option.indent;
|
||
|
if (state.tokens.next.from === indent + state.option.indent) {
|
||
|
indent += state.option.indent;
|
||
|
}
|
||
|
}
|
||
|
while (state.tokens.next.id !== "(end)") {
|
||
|
while (state.tokens.next.id === ",") {
|
||
|
if (!state.option.elision) {
|
||
|
if (!state.inES5()) {
|
||
|
warning("W070");
|
||
|
} else {
|
||
|
warning("W128");
|
||
|
do {
|
||
|
advance(",");
|
||
|
} while (state.tokens.next.id === ",");
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
advance(",");
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "]") {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
spreadrest("spread");
|
||
|
|
||
|
this.first.push(expression(context, 10));
|
||
|
if (state.tokens.next.id === ",") {
|
||
|
advance(",");
|
||
|
checkComma({ allowTrailing: true });
|
||
|
if (state.tokens.next.id === "]" && !state.inES5()) {
|
||
|
warning("W070", state.tokens.curr);
|
||
|
break;
|
||
|
}
|
||
|
} else {
|
||
|
if (state.option.trailingcomma && state.inES5()) {
|
||
|
warningAt("W140", state.tokens.curr.line, state.tokens.curr.character);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (b) {
|
||
|
indent -= state.option.indent;
|
||
|
}
|
||
|
advance("]", this);
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
|
||
|
function isMethod() {
|
||
|
return !!state.funct["(method)"];
|
||
|
}
|
||
|
|
||
|
function propertyName(context, preserveOrToken) {
|
||
|
var id;
|
||
|
var preserve = true;
|
||
|
if (typeof preserveOrToken === "object") {
|
||
|
id = preserveOrToken;
|
||
|
} else {
|
||
|
preserve = preserveOrToken;
|
||
|
id = optionalidentifier(context, true, preserve);
|
||
|
}
|
||
|
|
||
|
if (!id) {
|
||
|
if (state.tokens.next.id === "(string)") {
|
||
|
id = state.tokens.next.value;
|
||
|
if (!preserve) {
|
||
|
advance();
|
||
|
}
|
||
|
} else if (state.tokens.next.id === "(number)") {
|
||
|
id = state.tokens.next.value.toString();
|
||
|
if (!preserve) {
|
||
|
advance();
|
||
|
}
|
||
|
}
|
||
|
} else if (typeof id === "object") {
|
||
|
if (id.id === "(string)" || id.id === "(identifier)") id = id.value;
|
||
|
else if (id.id === "(number)") id = id.value.toString();
|
||
|
}
|
||
|
|
||
|
if (id === "hasOwnProperty") {
|
||
|
warning("W001");
|
||
|
}
|
||
|
|
||
|
return id;
|
||
|
}
|
||
|
function functionparams(context, options) {
|
||
|
var next;
|
||
|
var paramsIds = [];
|
||
|
var ident;
|
||
|
var tokens = [];
|
||
|
var t;
|
||
|
var pastDefault = false;
|
||
|
var pastRest = false;
|
||
|
var arity = 0;
|
||
|
var loneArg = options && options.loneArg;
|
||
|
var hasDestructuring = false;
|
||
|
|
||
|
if (loneArg && loneArg.identifier === true) {
|
||
|
state.funct["(scope)"].addParam(loneArg.value, loneArg);
|
||
|
return { arity: 1, params: [ loneArg.value ], isSimple: true };
|
||
|
}
|
||
|
|
||
|
next = state.tokens.next;
|
||
|
|
||
|
if (!options || !options.parsedOpening) {
|
||
|
advance("(");
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === ")") {
|
||
|
advance(")");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
function addParam(addParamArgs) {
|
||
|
state.funct["(scope)"].addParam.apply(state.funct["(scope)"], addParamArgs);
|
||
|
}
|
||
|
|
||
|
for (;;) {
|
||
|
arity++;
|
||
|
var currentParams = [];
|
||
|
|
||
|
if (_.includes(["{", "["], state.tokens.next.id)) {
|
||
|
hasDestructuring = true;
|
||
|
tokens = destructuringPattern(context);
|
||
|
for (t in tokens) {
|
||
|
t = tokens[t];
|
||
|
if (t.id) {
|
||
|
paramsIds.push(t.id);
|
||
|
currentParams.push([t.id, t.token]);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
pastRest = spreadrest("rest");
|
||
|
ident = identifier(context);
|
||
|
|
||
|
if (ident) {
|
||
|
paramsIds.push(ident);
|
||
|
currentParams.push([ident, state.tokens.curr]);
|
||
|
} else {
|
||
|
while (!checkPunctuators(state.tokens.next, [",", ")"])) advance();
|
||
|
}
|
||
|
}
|
||
|
if (pastDefault) {
|
||
|
if (state.tokens.next.id !== "=") {
|
||
|
error("W138", state.tokens.curr);
|
||
|
}
|
||
|
}
|
||
|
if (state.tokens.next.id === "=") {
|
||
|
if (!state.inES6()) {
|
||
|
warning("W119", state.tokens.next, "default parameters", "6");
|
||
|
}
|
||
|
|
||
|
if (pastRest) {
|
||
|
error("E062", state.tokens.next);
|
||
|
}
|
||
|
|
||
|
advance("=");
|
||
|
pastDefault = true;
|
||
|
expression(context, 10);
|
||
|
}
|
||
|
currentParams.forEach(addParam);
|
||
|
if (state.tokens.next.id === ",") {
|
||
|
if (pastRest) {
|
||
|
warning("W131", state.tokens.next);
|
||
|
}
|
||
|
advance(",");
|
||
|
checkComma({ allowTrailing: true });
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === ")") {
|
||
|
if (state.tokens.curr.id === "," && !state.inES8()) {
|
||
|
warning("W119", state.tokens.curr, "Trailing comma in function parameters", "8");
|
||
|
}
|
||
|
|
||
|
advance(")", next);
|
||
|
return {
|
||
|
arity: arity,
|
||
|
params: paramsIds,
|
||
|
isSimple: !hasDestructuring && !pastRest && !pastDefault
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function functor(name, token, overwrites) {
|
||
|
var funct = {
|
||
|
"(name)" : name,
|
||
|
"(breakage)" : 0,
|
||
|
"(loopage)" : 0,
|
||
|
"(isStrict)" : "unknown",
|
||
|
|
||
|
"(global)" : false,
|
||
|
|
||
|
"(line)" : null,
|
||
|
"(character)" : null,
|
||
|
"(metrics)" : null,
|
||
|
"(statement)" : null,
|
||
|
"(context)" : null,
|
||
|
"(scope)" : null,
|
||
|
"(comparray)" : null,
|
||
|
"(yielded)" : null,
|
||
|
"(arrow)" : null,
|
||
|
"(async)" : null,
|
||
|
"(params)" : null
|
||
|
};
|
||
|
|
||
|
if (token) {
|
||
|
_.extend(funct, {
|
||
|
"(line)" : token.line,
|
||
|
"(character)": token.character,
|
||
|
"(metrics)" : createMetrics(token)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
_.extend(funct, overwrites);
|
||
|
|
||
|
if (funct["(context)"]) {
|
||
|
funct["(scope)"] = funct["(context)"]["(scope)"];
|
||
|
funct["(comparray)"] = funct["(context)"]["(comparray)"];
|
||
|
}
|
||
|
|
||
|
return funct;
|
||
|
}
|
||
|
function hasParsedCode(funct) {
|
||
|
return funct["(global)"] && !funct["(verb)"];
|
||
|
}
|
||
|
function doTemplateLiteral(context, leftOrRbp) {
|
||
|
var ctx = this.context;
|
||
|
var noSubst = this.noSubst;
|
||
|
var depth = this.depth;
|
||
|
var left = typeof leftOrRbp === "number" ? null : leftOrRbp;
|
||
|
|
||
|
if (!noSubst) {
|
||
|
while (!end()) {
|
||
|
if (!state.tokens.next.template || state.tokens.next.depth > depth) {
|
||
|
expression(context, 0); // should probably have different rbp?
|
||
|
} else {
|
||
|
advance();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
id: "(template)",
|
||
|
type: "(template)",
|
||
|
tag: left
|
||
|
};
|
||
|
|
||
|
function end() {
|
||
|
if (state.tokens.curr.template && state.tokens.curr.tail &&
|
||
|
state.tokens.curr.context === ctx) {
|
||
|
return true;
|
||
|
}
|
||
|
var complete = (state.tokens.next.template && state.tokens.next.tail &&
|
||
|
state.tokens.next.context === ctx);
|
||
|
if (complete) advance();
|
||
|
return complete || state.tokens.next.isUnclosed;
|
||
|
}
|
||
|
}
|
||
|
function doFunction(context, options) {
|
||
|
var f, token, name, statement, classExprBinding, isGenerator, isArrow,
|
||
|
isMethod, ignoreLoopFunc;
|
||
|
var oldOption = state.option;
|
||
|
var oldIgnored = state.ignored;
|
||
|
var isAsync = context & prodParams.preAsync;
|
||
|
|
||
|
if (options) {
|
||
|
name = options.name;
|
||
|
statement = options.statement;
|
||
|
classExprBinding = options.classExprBinding;
|
||
|
isGenerator = options.type === "generator";
|
||
|
isArrow = options.type === "arrow";
|
||
|
isMethod = options.isMethod;
|
||
|
ignoreLoopFunc = options.ignoreLoopFunc;
|
||
|
}
|
||
|
|
||
|
context &= ~prodParams.noin;
|
||
|
context &= ~prodParams.tryClause;
|
||
|
|
||
|
if (isAsync) {
|
||
|
context |= prodParams.async;
|
||
|
} else {
|
||
|
context &= ~prodParams.async;
|
||
|
}
|
||
|
|
||
|
if (isGenerator) {
|
||
|
context |= prodParams.yield;
|
||
|
} else if (!isArrow) {
|
||
|
context &= ~prodParams.yield;
|
||
|
}
|
||
|
context &= ~prodParams.preAsync;
|
||
|
|
||
|
state.option = Object.create(state.option);
|
||
|
state.ignored = Object.create(state.ignored);
|
||
|
|
||
|
state.funct = functor(name || state.nameStack.infer(), state.tokens.next, {
|
||
|
"(statement)": statement,
|
||
|
"(context)": state.funct,
|
||
|
"(arrow)": isArrow,
|
||
|
"(method)": isMethod,
|
||
|
"(async)": isAsync
|
||
|
});
|
||
|
|
||
|
f = state.funct;
|
||
|
token = state.tokens.curr;
|
||
|
|
||
|
functions.push(state.funct);
|
||
|
state.funct["(scope)"].stack("functionouter");
|
||
|
var internallyAccessibleName = !isMethod && (name || classExprBinding);
|
||
|
if (internallyAccessibleName) {
|
||
|
state.funct["(scope)"].block.add(internallyAccessibleName,
|
||
|
classExprBinding ? "class" : "function", state.tokens.curr, false);
|
||
|
}
|
||
|
|
||
|
if (!isArrow) {
|
||
|
state.funct["(scope)"].funct.add("arguments", "var", token, false);
|
||
|
}
|
||
|
state.funct["(scope)"].stack("functionparams");
|
||
|
|
||
|
var paramsInfo = functionparams(context, options);
|
||
|
|
||
|
if (paramsInfo) {
|
||
|
state.funct["(params)"] = paramsInfo.params;
|
||
|
state.funct["(hasSimpleParams)"] = paramsInfo.isSimple;
|
||
|
state.funct["(metrics)"].arity = paramsInfo.arity;
|
||
|
state.funct["(metrics)"].verifyMaxParametersPerFunction();
|
||
|
} else {
|
||
|
state.funct["(params)"] = [];
|
||
|
state.funct["(metrics)"].arity = 0;
|
||
|
state.funct["(hasSimpleParams)"] = true;
|
||
|
}
|
||
|
|
||
|
if (isArrow) {
|
||
|
context &= ~prodParams.yield;
|
||
|
|
||
|
if (!state.inES6(true)) {
|
||
|
warning("W119", state.tokens.curr, "arrow function syntax (=>)", "6");
|
||
|
}
|
||
|
|
||
|
if (!options.loneArg) {
|
||
|
advance("=>");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
block(context, false, true, true, isArrow);
|
||
|
|
||
|
if (!state.option.noyield && isGenerator && !state.funct["(yielded)"]) {
|
||
|
warning("W124", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
state.funct["(metrics)"].verifyMaxStatementsPerFunction();
|
||
|
state.funct["(metrics)"].verifyMaxComplexityPerFunction();
|
||
|
state.funct["(unusedOption)"] = state.option.unused;
|
||
|
state.option = oldOption;
|
||
|
state.ignored = oldIgnored;
|
||
|
state.funct["(last)"] = state.tokens.curr.line;
|
||
|
state.funct["(lastcharacter)"] = state.tokens.curr.character;
|
||
|
state.funct["(scope)"].unstack(); // also does usage and label checks
|
||
|
state.funct["(scope)"].unstack();
|
||
|
|
||
|
state.funct = state.funct["(context)"];
|
||
|
|
||
|
if (!ignoreLoopFunc && !state.option.loopfunc && state.funct["(loopage)"]) {
|
||
|
if (f["(outerMutables)"]) {
|
||
|
warning("W083", token, f["(outerMutables)"].join(", "));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return f;
|
||
|
}
|
||
|
|
||
|
function createMetrics(functionStartToken) {
|
||
|
return {
|
||
|
statementCount: 0,
|
||
|
nestedBlockDepth: -1,
|
||
|
ComplexityCount: 1,
|
||
|
arity: 0,
|
||
|
|
||
|
verifyMaxStatementsPerFunction: function() {
|
||
|
if (state.option.maxstatements &&
|
||
|
this.statementCount > state.option.maxstatements) {
|
||
|
warning("W071", functionStartToken, this.statementCount);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
verifyMaxParametersPerFunction: function() {
|
||
|
if (_.isNumber(state.option.maxparams) &&
|
||
|
this.arity > state.option.maxparams) {
|
||
|
warning("W072", functionStartToken, this.arity);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
verifyMaxNestedBlockDepthPerFunction: function() {
|
||
|
if (state.option.maxdepth &&
|
||
|
this.nestedBlockDepth > 0 &&
|
||
|
this.nestedBlockDepth === state.option.maxdepth + 1) {
|
||
|
warning("W073", null, this.nestedBlockDepth);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
verifyMaxComplexityPerFunction: function() {
|
||
|
var max = state.option.maxcomplexity;
|
||
|
var cc = this.ComplexityCount;
|
||
|
if (max && cc > max) {
|
||
|
warning("W074", functionStartToken, cc);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function increaseComplexityCount() {
|
||
|
state.funct["(metrics)"].ComplexityCount += 1;
|
||
|
}
|
||
|
|
||
|
function checkCondAssignment(token) {
|
||
|
if (!token || token.paren) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (token.id === ",") {
|
||
|
checkCondAssignment(token.right);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
switch (token.id) {
|
||
|
case "=":
|
||
|
case "+=":
|
||
|
case "-=":
|
||
|
case "*=":
|
||
|
case "%=":
|
||
|
case "&=":
|
||
|
case "|=":
|
||
|
case "^=":
|
||
|
case "/=":
|
||
|
if (!state.option.boss) {
|
||
|
warning("W084", token);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function checkProperties(props) {
|
||
|
if (state.inES5()) {
|
||
|
for (var name in props) {
|
||
|
if (props[name] && props[name].setterToken && !props[name].getterToken &&
|
||
|
!props[name].static) {
|
||
|
warning("W078", props[name].setterToken);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function metaProperty(context, name, c) {
|
||
|
if (checkPunctuator(state.tokens.next, ".")) {
|
||
|
var left = state.tokens.curr.id;
|
||
|
advance(".");
|
||
|
var id = identifier(context);
|
||
|
state.tokens.curr.isMetaProperty = true;
|
||
|
if (name !== id) {
|
||
|
error("E057", state.tokens.prev, left, id);
|
||
|
} else {
|
||
|
c();
|
||
|
}
|
||
|
return state.tokens.curr;
|
||
|
}
|
||
|
}
|
||
|
(function(x) {
|
||
|
x.nud = function(context) {
|
||
|
var b, f, i, params, t, isGeneratorMethod = false, nextVal;
|
||
|
var props = Object.create(null); // All properties, including accessors
|
||
|
var isAsyncMethod = false;
|
||
|
|
||
|
b = !sameLine(state.tokens.curr, state.tokens.next);
|
||
|
if (b) {
|
||
|
indent += state.option.indent;
|
||
|
if (state.tokens.next.from === indent + state.option.indent) {
|
||
|
indent += state.option.indent;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var blocktype = lookupBlockType();
|
||
|
if (blocktype.isDestAssign) {
|
||
|
this.destructAssign = destructuringPattern(context, {
|
||
|
openingParsed: true,
|
||
|
assignment: true
|
||
|
});
|
||
|
return this;
|
||
|
}
|
||
|
state.inObjectBody = true;
|
||
|
for (;;) {
|
||
|
if (state.tokens.next.id === "}") {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
nextVal = state.tokens.next.value;
|
||
|
if (state.tokens.next.identifier &&
|
||
|
(peekIgnoreEOL().id === "," || peekIgnoreEOL().id === "}")) {
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.next, "object short notation", "6");
|
||
|
}
|
||
|
i = propertyName(context, true);
|
||
|
saveProperty(props, i, state.tokens.next);
|
||
|
|
||
|
expression(context, 10);
|
||
|
|
||
|
} else if (peek().id !== ":" && (nextVal === "get" || nextVal === "set")) {
|
||
|
advance(nextVal);
|
||
|
|
||
|
if (!state.inES5()) {
|
||
|
error("E034");
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "[") {
|
||
|
i = computedPropertyName(context);
|
||
|
} else {
|
||
|
i = propertyName(context);
|
||
|
if (!i && !state.inES6()) {
|
||
|
error("E035");
|
||
|
}
|
||
|
}
|
||
|
if (i) {
|
||
|
saveAccessor(nextVal, props, i, state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
t = state.tokens.next;
|
||
|
f = doFunction(context, { isMethod: true });
|
||
|
params = f["(params)"];
|
||
|
if (nextVal === "get" && i && params.length) {
|
||
|
warning("W076", t, params[0], i);
|
||
|
} else if (nextVal === "set" && i && f["(metrics)"].arity !== 1) {
|
||
|
warning("W077", t, i);
|
||
|
}
|
||
|
|
||
|
} else if (spreadrest("spread")) {
|
||
|
if (!state.inES9()) {
|
||
|
warning("W119", state.tokens.next, "object spread property", "9");
|
||
|
}
|
||
|
|
||
|
expression(context, 10);
|
||
|
} else {
|
||
|
if (state.tokens.next.id === "async" && !checkPunctuators(peek(), ["(", ":"])) {
|
||
|
if (!state.inES8()) {
|
||
|
warning("W119", state.tokens.next, "async functions", "8");
|
||
|
}
|
||
|
|
||
|
isAsyncMethod = true;
|
||
|
advance();
|
||
|
|
||
|
nolinebreak(state.tokens.curr);
|
||
|
} else {
|
||
|
isAsyncMethod = false;
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value === "*" && state.tokens.next.type === "(punctuator)") {
|
||
|
if (isAsyncMethod && !state.inES9()) {
|
||
|
warning("W119", state.tokens.next, "async generators", "9");
|
||
|
} else if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.next, "generator functions", "6");
|
||
|
}
|
||
|
|
||
|
advance("*");
|
||
|
isGeneratorMethod = true;
|
||
|
} else {
|
||
|
isGeneratorMethod = false;
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "[") {
|
||
|
i = computedPropertyName(context);
|
||
|
state.nameStack.set(i);
|
||
|
} else {
|
||
|
state.nameStack.set(state.tokens.next);
|
||
|
i = propertyName(context);
|
||
|
saveProperty(props, i, state.tokens.next);
|
||
|
|
||
|
if (typeof i !== "string") {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value === "(") {
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.curr, "concise methods", "6");
|
||
|
}
|
||
|
|
||
|
doFunction(isAsyncMethod ? context | prodParams.preAsync : context, {
|
||
|
isMethod: true,
|
||
|
type: isGeneratorMethod ? "generator" : null
|
||
|
});
|
||
|
} else {
|
||
|
advance(":");
|
||
|
expression(context, 10);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
countMember(i);
|
||
|
|
||
|
if (state.tokens.next.id === ",") {
|
||
|
advance(",");
|
||
|
checkComma({ allowTrailing: true, property: true });
|
||
|
if (state.tokens.next.id === ",") {
|
||
|
warning("W070", state.tokens.curr);
|
||
|
} else if (state.tokens.next.id === "}" && !state.inES5()) {
|
||
|
warning("W070", state.tokens.curr);
|
||
|
}
|
||
|
} else {
|
||
|
if (state.option.trailingcomma && state.inES5()) {
|
||
|
warningAt("W140", state.tokens.curr.line, state.tokens.curr.character);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (b) {
|
||
|
indent -= state.option.indent;
|
||
|
}
|
||
|
advance("}", this);
|
||
|
|
||
|
checkProperties(props);
|
||
|
state.inObjectBody = false;
|
||
|
|
||
|
return this;
|
||
|
};
|
||
|
x.fud = function() {
|
||
|
error("E036", state.tokens.curr);
|
||
|
};
|
||
|
}(delim("{")));
|
||
|
|
||
|
function destructuringPattern(context, options) {
|
||
|
var isAssignment = options && options.assignment;
|
||
|
|
||
|
context &= ~prodParams.noin;
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.curr,
|
||
|
isAssignment ? "destructuring assignment" : "destructuring binding", "6");
|
||
|
}
|
||
|
|
||
|
return destructuringPatternRecursive(context, options);
|
||
|
}
|
||
|
|
||
|
function destructuringPatternRecursive(context, options) {
|
||
|
var ids, idx;
|
||
|
var identifiers = [];
|
||
|
var openingParsed = options && options.openingParsed;
|
||
|
var isAssignment = options && options.assignment;
|
||
|
var recursiveOptions = isAssignment ? { assignment: isAssignment } : null;
|
||
|
var firstToken = openingParsed ? state.tokens.curr : state.tokens.next;
|
||
|
|
||
|
var nextInnerDE = function() {
|
||
|
var ident;
|
||
|
if (checkPunctuators(state.tokens.next, ["[", "{"])) {
|
||
|
ids = destructuringPatternRecursive(context, recursiveOptions);
|
||
|
for (idx = 0; idx < ids.length; idx++) {
|
||
|
identifiers.push({ id: ids[idx].id, token: ids[idx].token });
|
||
|
}
|
||
|
} else if (checkPunctuator(state.tokens.next, ",")) {
|
||
|
identifiers.push({ id: null, token: state.tokens.curr });
|
||
|
} else if (checkPunctuator(state.tokens.next, "(")) {
|
||
|
advance("(");
|
||
|
nextInnerDE();
|
||
|
advance(")");
|
||
|
} else {
|
||
|
if (isAssignment) {
|
||
|
var assignTarget = expression(context, 20);
|
||
|
if (assignTarget) {
|
||
|
checkLeftSideAssign(context, assignTarget);
|
||
|
if (assignTarget.identifier) {
|
||
|
ident = assignTarget.value;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
ident = identifier(context);
|
||
|
}
|
||
|
if (ident) {
|
||
|
identifiers.push({ id: ident, token: state.tokens.curr });
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var assignmentProperty = function(context) {
|
||
|
var id, expr;
|
||
|
|
||
|
if (checkPunctuator(state.tokens.next, "[")) {
|
||
|
advance("[");
|
||
|
expression(context, 10);
|
||
|
advance("]");
|
||
|
advance(":");
|
||
|
nextInnerDE();
|
||
|
} else if (state.tokens.next.id === "(string)" ||
|
||
|
state.tokens.next.id === "(number)") {
|
||
|
advance();
|
||
|
advance(":");
|
||
|
nextInnerDE();
|
||
|
} else {
|
||
|
var isRest = spreadrest("rest");
|
||
|
|
||
|
if (isRest) {
|
||
|
if (!state.inES9()) {
|
||
|
warning("W119", state.tokens.next, "object rest property", "9");
|
||
|
}
|
||
|
if (state.tokens.next.type === "(identifier)") {
|
||
|
id = identifier(context);
|
||
|
} else {
|
||
|
expr = expression(context, 10);
|
||
|
error("E030", expr, expr.value);
|
||
|
}
|
||
|
} else {
|
||
|
id = identifier(context);
|
||
|
}
|
||
|
|
||
|
if (!isRest && checkPunctuator(state.tokens.next, ":")) {
|
||
|
advance(":");
|
||
|
nextInnerDE();
|
||
|
} else if (id) {
|
||
|
if (isAssignment) {
|
||
|
checkLeftSideAssign(context, state.tokens.curr);
|
||
|
}
|
||
|
identifiers.push({ id: id, token: state.tokens.curr });
|
||
|
}
|
||
|
|
||
|
if (isRest && checkPunctuator(state.tokens.next, ",")) {
|
||
|
warning("W130", state.tokens.next);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var id, value;
|
||
|
if (checkPunctuator(firstToken, "[")) {
|
||
|
if (!openingParsed) {
|
||
|
advance("[");
|
||
|
}
|
||
|
if (checkPunctuator(state.tokens.next, "]")) {
|
||
|
warning("W137", state.tokens.curr);
|
||
|
}
|
||
|
var element_after_rest = false;
|
||
|
while (!checkPunctuator(state.tokens.next, "]")) {
|
||
|
var isRest = spreadrest("rest");
|
||
|
|
||
|
nextInnerDE();
|
||
|
|
||
|
if (isRest && !element_after_rest &&
|
||
|
checkPunctuator(state.tokens.next, ",")) {
|
||
|
warning("W130", state.tokens.next);
|
||
|
element_after_rest = true;
|
||
|
}
|
||
|
if (!isRest && checkPunctuator(state.tokens.next, "=")) {
|
||
|
if (checkPunctuator(state.tokens.prev, "...")) {
|
||
|
advance("]");
|
||
|
} else {
|
||
|
advance("=");
|
||
|
}
|
||
|
id = state.tokens.prev;
|
||
|
value = expression(context, 10);
|
||
|
if (value && value.identifier && value.value === "undefined") {
|
||
|
warning("W080", id, id.value);
|
||
|
}
|
||
|
}
|
||
|
if (!checkPunctuator(state.tokens.next, "]")) {
|
||
|
advance(",");
|
||
|
}
|
||
|
}
|
||
|
advance("]");
|
||
|
} else if (checkPunctuator(firstToken, "{")) {
|
||
|
|
||
|
if (!openingParsed) {
|
||
|
advance("{");
|
||
|
}
|
||
|
if (checkPunctuator(state.tokens.next, "}")) {
|
||
|
warning("W137", state.tokens.curr);
|
||
|
}
|
||
|
while (!checkPunctuator(state.tokens.next, "}")) {
|
||
|
assignmentProperty(context);
|
||
|
if (checkPunctuator(state.tokens.next, "=")) {
|
||
|
advance("=");
|
||
|
id = state.tokens.prev;
|
||
|
value = expression(context, 10);
|
||
|
if (value && value.identifier && value.value === "undefined") {
|
||
|
warning("W080", id, id.value);
|
||
|
}
|
||
|
}
|
||
|
if (!checkPunctuator(state.tokens.next, "}")) {
|
||
|
advance(",");
|
||
|
if (checkPunctuator(state.tokens.next, "}")) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
advance("}");
|
||
|
}
|
||
|
return identifiers;
|
||
|
}
|
||
|
|
||
|
function destructuringPatternMatch(tokens, value) {
|
||
|
var first = value.first;
|
||
|
|
||
|
if (!first)
|
||
|
return;
|
||
|
|
||
|
_.zip(tokens, Array.isArray(first) ? first : [ first ]).forEach(function(val) {
|
||
|
var token = val[0];
|
||
|
var value = val[1];
|
||
|
|
||
|
if (token && value)
|
||
|
token.first = value;
|
||
|
else if (token && token.first && !value)
|
||
|
warning("W080", token.first, token.first.value);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function blockVariableStatement(type, statement, context) {
|
||
|
|
||
|
var noin = context & prodParams.noin;
|
||
|
var inexport = context & prodParams.export;
|
||
|
var isLet = type === "let";
|
||
|
var isConst = type === "const";
|
||
|
var tokens, lone, value, letblock;
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.curr, type, "6");
|
||
|
}
|
||
|
|
||
|
if (isLet && isMozillaLet()) {
|
||
|
advance("(");
|
||
|
state.funct["(scope)"].stack();
|
||
|
letblock = true;
|
||
|
statement.declaration = false;
|
||
|
}
|
||
|
|
||
|
statement.first = [];
|
||
|
for (;;) {
|
||
|
var names = [];
|
||
|
if (_.includes(["{", "["], state.tokens.next.value)) {
|
||
|
tokens = destructuringPattern(context);
|
||
|
lone = false;
|
||
|
} else {
|
||
|
tokens = [ { id: identifier(context), token: state.tokens.curr } ];
|
||
|
lone = true;
|
||
|
}
|
||
|
if (!noin && isConst && state.tokens.next.id !== "=") {
|
||
|
warning("E012", state.tokens.curr, state.tokens.curr.value);
|
||
|
}
|
||
|
|
||
|
for (var t in tokens) {
|
||
|
if (tokens.hasOwnProperty(t)) {
|
||
|
t = tokens[t];
|
||
|
if (t.id === "let") {
|
||
|
warning("W024", t.token, t.id);
|
||
|
}
|
||
|
|
||
|
if (state.funct["(scope)"].block.isGlobal()) {
|
||
|
if (predefined[t.id] === false) {
|
||
|
warning("W079", t.token, t.id);
|
||
|
}
|
||
|
}
|
||
|
if (t.id) {
|
||
|
state.funct["(scope)"].addbinding(t.id, {
|
||
|
type: type,
|
||
|
token: t.token });
|
||
|
names.push(t.token);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "=") {
|
||
|
statement.hasInitializer = true;
|
||
|
|
||
|
advance("=");
|
||
|
if (!noin && peek(0).id === "=" && state.tokens.next.identifier) {
|
||
|
warning("W120", state.tokens.next, state.tokens.next.value);
|
||
|
}
|
||
|
var id = state.tokens.prev;
|
||
|
value = expression(context, 10);
|
||
|
if (value) {
|
||
|
if (value.identifier && value.value === "undefined") {
|
||
|
warning("W080", id, id.value);
|
||
|
}
|
||
|
if (!lone) {
|
||
|
destructuringPatternMatch(names, value);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (state.tokens.next.value !== "in" && state.tokens.next.value !== "of") {
|
||
|
for (t in tokens) {
|
||
|
if (tokens.hasOwnProperty(t)) {
|
||
|
t = tokens[t];
|
||
|
state.funct["(scope)"].initialize(t.id);
|
||
|
|
||
|
if (lone && inexport) {
|
||
|
state.funct["(scope)"].setExported(t.token.value, t.token);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
statement.first = statement.first.concat(names);
|
||
|
|
||
|
if (state.tokens.next.id !== ",") {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
statement.hasComma = true;
|
||
|
advance(",");
|
||
|
checkComma();
|
||
|
}
|
||
|
if (letblock) {
|
||
|
advance(")");
|
||
|
block(context, true, true);
|
||
|
statement.block = true;
|
||
|
state.funct["(scope)"].unstack();
|
||
|
}
|
||
|
|
||
|
return statement;
|
||
|
}
|
||
|
|
||
|
var conststatement = stmt("const", function(context) {
|
||
|
return blockVariableStatement("const", this, context);
|
||
|
});
|
||
|
conststatement.exps = true;
|
||
|
conststatement.declaration = true;
|
||
|
function isMozillaLet() {
|
||
|
return state.tokens.next.id === "(" && state.inMoz();
|
||
|
}
|
||
|
var letstatement = stmt("let", function(context) {
|
||
|
return blockVariableStatement("let", this, context);
|
||
|
});
|
||
|
letstatement.nud = function(context, rbp) {
|
||
|
if (isMozillaLet()) {
|
||
|
state.funct["(scope)"].stack();
|
||
|
advance("(");
|
||
|
state.tokens.prev.fud(context);
|
||
|
advance(")");
|
||
|
expression(context, rbp);
|
||
|
state.funct["(scope)"].unstack();
|
||
|
} else {
|
||
|
this.exps = false;
|
||
|
return state.syntax["(identifier)"].nud.apply(this, arguments);
|
||
|
}
|
||
|
};
|
||
|
letstatement.meta = { es5: true, isFutureReservedWord: false, strictOnly: true };
|
||
|
letstatement.exps = true;
|
||
|
letstatement.declaration = true;
|
||
|
letstatement.useFud = function(context) {
|
||
|
var next = state.tokens.next;
|
||
|
var nextIsBindingName;
|
||
|
|
||
|
if (this.line !== next.line && !state.inES6()) {
|
||
|
return false;
|
||
|
}
|
||
|
nextIsBindingName = next.identifier && (!isReserved(context, next) ||
|
||
|
next.id === "let");
|
||
|
|
||
|
return nextIsBindingName || checkPunctuators(next, ["{", "["]) ||
|
||
|
isMozillaLet();
|
||
|
};
|
||
|
|
||
|
var varstatement = stmt("var", function(context) {
|
||
|
var noin = context & prodParams.noin;
|
||
|
var inexport = context & prodParams.export;
|
||
|
var tokens, lone, value, id;
|
||
|
|
||
|
this.first = [];
|
||
|
for (;;) {
|
||
|
var names = [];
|
||
|
if (_.includes(["{", "["], state.tokens.next.value)) {
|
||
|
tokens = destructuringPattern(context);
|
||
|
lone = false;
|
||
|
} else {
|
||
|
tokens = [];
|
||
|
id = identifier(context);
|
||
|
|
||
|
if (id) {
|
||
|
tokens.push({ id: id, token: state.tokens.curr });
|
||
|
}
|
||
|
|
||
|
lone = true;
|
||
|
}
|
||
|
|
||
|
if (state.option.varstmt) {
|
||
|
warning("W132", this);
|
||
|
}
|
||
|
|
||
|
|
||
|
for (var t in tokens) {
|
||
|
if (tokens.hasOwnProperty(t)) {
|
||
|
t = tokens[t];
|
||
|
if (state.funct["(global)"] && !state.impliedClosure()) {
|
||
|
if (predefined[t.id] === false) {
|
||
|
warning("W079", t.token, t.id);
|
||
|
} else if (state.option.futurehostile === false) {
|
||
|
if ((!state.inES5() && vars.ecmaIdentifiers[5][t.id] === false) ||
|
||
|
(!state.inES6() && vars.ecmaIdentifiers[6][t.id] === false)) {
|
||
|
warning("W129", t.token, t.id);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (t.id) {
|
||
|
state.funct["(scope)"].addbinding(t.id, {
|
||
|
type: "var",
|
||
|
token: t.token });
|
||
|
|
||
|
if (lone && inexport) {
|
||
|
state.funct["(scope)"].setExported(t.id, t.token);
|
||
|
}
|
||
|
names.push(t.token);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "=") {
|
||
|
this.hasInitializer = true;
|
||
|
|
||
|
state.nameStack.set(state.tokens.curr);
|
||
|
|
||
|
advance("=");
|
||
|
if (peek(0).id === "=" && state.tokens.next.identifier) {
|
||
|
if (!noin &&
|
||
|
!state.funct["(params)"] ||
|
||
|
state.funct["(params)"].indexOf(state.tokens.next.value) === -1) {
|
||
|
warning("W120", state.tokens.next, state.tokens.next.value);
|
||
|
}
|
||
|
}
|
||
|
id = state.tokens.prev;
|
||
|
value = expression(context, 10);
|
||
|
if (value) {
|
||
|
if (!state.funct["(loopage)"] && value.identifier &&
|
||
|
value.value === "undefined") {
|
||
|
warning("W080", id, id.value);
|
||
|
}
|
||
|
if (!lone) {
|
||
|
destructuringPatternMatch(names, value);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.first = this.first.concat(names);
|
||
|
|
||
|
if (state.tokens.next.id !== ",") {
|
||
|
break;
|
||
|
}
|
||
|
this.hasComma = true;
|
||
|
advance(",");
|
||
|
checkComma();
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
varstatement.exps = true;
|
||
|
|
||
|
blockstmt("function", function(context) {
|
||
|
var inexport = context & prodParams.export;
|
||
|
var generator = false;
|
||
|
var isAsync = context & prodParams.preAsync;
|
||
|
var labelType = "";
|
||
|
|
||
|
if (isAsync) {
|
||
|
labelType = "async ";
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value === "*") {
|
||
|
if (isAsync && !state.inES9()) {
|
||
|
warning("W119", state.tokens.prev, "async generators", "9");
|
||
|
} else if (!isAsync && !state.inES6(true)) {
|
||
|
warning("W119", state.tokens.next, "function*", "6");
|
||
|
}
|
||
|
|
||
|
advance("*");
|
||
|
labelType += "generator ";
|
||
|
generator = true;
|
||
|
}
|
||
|
|
||
|
labelType += "function";
|
||
|
|
||
|
if (inblock) {
|
||
|
warning("W082", state.tokens.curr);
|
||
|
}
|
||
|
var nameToken = optionalidentifier(context) ? state.tokens.curr : null;
|
||
|
|
||
|
if (!nameToken) {
|
||
|
if (!inexport) {
|
||
|
warning("W025");
|
||
|
}
|
||
|
} else {
|
||
|
state.funct["(scope)"].addbinding(nameToken.value, {
|
||
|
type: labelType,
|
||
|
token: state.tokens.curr,
|
||
|
initialized: true });
|
||
|
|
||
|
if (inexport) {
|
||
|
state.funct["(scope)"].setExported(nameToken.value, state.tokens.prev);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var f = doFunction(context, {
|
||
|
name: nameToken && nameToken.value,
|
||
|
statement: this,
|
||
|
type: generator ? "generator" : null,
|
||
|
ignoreLoopFunc: inblock // a declaration may already have warned
|
||
|
});
|
||
|
var enablesStrictMode = f["(isStrict)"] && !state.isStrict();
|
||
|
if (nameToken && (f["(name)"] === "arguments" || f["(name)"] === "eval") &&
|
||
|
enablesStrictMode) {
|
||
|
error("E008", nameToken);
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) {
|
||
|
error("E039");
|
||
|
}
|
||
|
return this;
|
||
|
}).declaration = true;
|
||
|
|
||
|
prefix("function", function(context) {
|
||
|
var generator = false;
|
||
|
var isAsync = context & prodParams.preAsync;
|
||
|
|
||
|
if (state.tokens.next.value === "*") {
|
||
|
if (isAsync && !state.inES9()) {
|
||
|
warning("W119", state.tokens.prev, "async generators", "9");
|
||
|
} else if (!isAsync && !state.inES6(true)) {
|
||
|
warning("W119", state.tokens.curr, "function*", "6");
|
||
|
}
|
||
|
|
||
|
advance("*");
|
||
|
generator = true;
|
||
|
}
|
||
|
var nameToken = optionalidentifier(isAsync ? context | prodParams.async : context) ?
|
||
|
state.tokens.curr : null;
|
||
|
|
||
|
var f = doFunction(context, {
|
||
|
name: nameToken && nameToken.value,
|
||
|
type: generator ? "generator" : null
|
||
|
});
|
||
|
|
||
|
if (generator && nameToken && nameToken.value === "yield") {
|
||
|
error("E024", nameToken, "yield");
|
||
|
}
|
||
|
|
||
|
if (nameToken && (f["(name)"] === "arguments" || f["(name)"] === "eval") &&
|
||
|
f["(isStrict)"]) {
|
||
|
error("E008", nameToken);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
blockstmt("if", function(context) {
|
||
|
var t = state.tokens.next;
|
||
|
increaseComplexityCount();
|
||
|
advance("(");
|
||
|
var expr = expression(context, 0);
|
||
|
|
||
|
if (!expr) {
|
||
|
quit("E041", this);
|
||
|
}
|
||
|
|
||
|
checkCondAssignment(expr);
|
||
|
var forinifcheck = null;
|
||
|
if (state.option.forin && state.forinifcheckneeded) {
|
||
|
state.forinifcheckneeded = false; // We only need to analyze the first if inside the loop
|
||
|
forinifcheck = state.forinifchecks[state.forinifchecks.length - 1];
|
||
|
if (expr.type === "(punctuator)" && expr.value === "!") {
|
||
|
forinifcheck.type = "(negative)";
|
||
|
} else {
|
||
|
forinifcheck.type = "(positive)";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
advance(")", t);
|
||
|
var s = block(context, true, true);
|
||
|
if (forinifcheck && forinifcheck.type === "(negative)") {
|
||
|
if (s && s[0] && s[0].type === "(identifier)" && s[0].value === "continue") {
|
||
|
forinifcheck.type = "(negative-with-continue)";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "else") {
|
||
|
advance("else");
|
||
|
if (state.tokens.next.id === "if" || state.tokens.next.id === "switch") {
|
||
|
statement(context);
|
||
|
} else {
|
||
|
block(context, true, true);
|
||
|
}
|
||
|
}
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
blockstmt("try", function(context) {
|
||
|
var b;
|
||
|
var hasParameter = false;
|
||
|
|
||
|
function catchParameter() {
|
||
|
advance("(");
|
||
|
|
||
|
if (checkPunctuators(state.tokens.next, ["[", "{"])) {
|
||
|
var tokens = destructuringPattern(context);
|
||
|
_.each(tokens, function(token) {
|
||
|
if (token.id) {
|
||
|
state.funct["(scope)"].addParam(token.id, token, "exception");
|
||
|
}
|
||
|
});
|
||
|
} else if (state.tokens.next.type !== "(identifier)") {
|
||
|
warning("E030", state.tokens.next, state.tokens.next.value);
|
||
|
} else {
|
||
|
state.funct["(scope)"].addParam(identifier(context), state.tokens.curr, "exception");
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value === "if") {
|
||
|
if (!state.inMoz()) {
|
||
|
warning("W118", state.tokens.curr, "catch filter");
|
||
|
}
|
||
|
advance("if");
|
||
|
expression(context, 0);
|
||
|
}
|
||
|
|
||
|
advance(")");
|
||
|
}
|
||
|
|
||
|
block(context | prodParams.tryClause, true);
|
||
|
|
||
|
while (state.tokens.next.id === "catch") {
|
||
|
increaseComplexityCount();
|
||
|
if (b && (!state.inMoz())) {
|
||
|
warning("W118", state.tokens.next, "multiple catch blocks");
|
||
|
}
|
||
|
advance("catch");
|
||
|
if (state.tokens.next.id !== "{") {
|
||
|
state.funct["(scope)"].stack("catchparams");
|
||
|
hasParameter = true;
|
||
|
catchParameter();
|
||
|
} else if (!state.inES10()) {
|
||
|
warning("W119", state.tokens.curr, "optional catch binding", "10");
|
||
|
}
|
||
|
block(context, false);
|
||
|
|
||
|
if (hasParameter) {
|
||
|
state.funct["(scope)"].unstack();
|
||
|
hasParameter = false;
|
||
|
}
|
||
|
b = true;
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "finally") {
|
||
|
advance("finally");
|
||
|
block(context, true);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!b) {
|
||
|
error("E021", state.tokens.next, "catch", state.tokens.next.value);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
blockstmt("while", function(context) {
|
||
|
var t = state.tokens.next;
|
||
|
state.funct["(breakage)"] += 1;
|
||
|
state.funct["(loopage)"] += 1;
|
||
|
increaseComplexityCount();
|
||
|
advance("(");
|
||
|
checkCondAssignment(expression(context, 0));
|
||
|
advance(")", t);
|
||
|
block(context, true, true);
|
||
|
state.funct["(breakage)"] -= 1;
|
||
|
state.funct["(loopage)"] -= 1;
|
||
|
return this;
|
||
|
}).labelled = true;
|
||
|
|
||
|
blockstmt("with", function(context) {
|
||
|
var t = state.tokens.next;
|
||
|
if (state.isStrict()) {
|
||
|
error("E010", state.tokens.curr);
|
||
|
} else if (!state.option.withstmt) {
|
||
|
warning("W085", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
advance("(");
|
||
|
expression(context, 0);
|
||
|
advance(")", t);
|
||
|
block(context, true, true);
|
||
|
|
||
|
return this;
|
||
|
});
|
||
|
|
||
|
blockstmt("switch", function(context) {
|
||
|
var t = state.tokens.next;
|
||
|
var g = false;
|
||
|
var noindent = false;
|
||
|
var seenCase = false;
|
||
|
|
||
|
state.funct["(breakage)"] += 1;
|
||
|
advance("(");
|
||
|
checkCondAssignment(expression(context, 0));
|
||
|
advance(")", t);
|
||
|
t = state.tokens.next;
|
||
|
advance("{");
|
||
|
state.funct["(scope)"].stack();
|
||
|
|
||
|
if (state.tokens.next.from === indent)
|
||
|
noindent = true;
|
||
|
|
||
|
if (!noindent)
|
||
|
indent += state.option.indent;
|
||
|
|
||
|
for (;;) {
|
||
|
switch (state.tokens.next.id) {
|
||
|
case "case":
|
||
|
switch (state.funct["(verb)"]) {
|
||
|
case "yield":
|
||
|
case "break":
|
||
|
case "case":
|
||
|
case "continue":
|
||
|
case "return":
|
||
|
case "switch":
|
||
|
case "throw":
|
||
|
break;
|
||
|
case "default":
|
||
|
if (state.option.leanswitch) {
|
||
|
warning("W145", state.tokens.next);
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
default:
|
||
|
if (!state.tokens.curr.caseFallsThrough) {
|
||
|
warning("W086", state.tokens.curr, "case");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
advance("case");
|
||
|
expression(context, 0);
|
||
|
seenCase = true;
|
||
|
increaseComplexityCount();
|
||
|
g = true;
|
||
|
advance(":");
|
||
|
state.funct["(verb)"] = "case";
|
||
|
break;
|
||
|
case "default":
|
||
|
switch (state.funct["(verb)"]) {
|
||
|
case "yield":
|
||
|
case "break":
|
||
|
case "continue":
|
||
|
case "return":
|
||
|
case "throw":
|
||
|
break;
|
||
|
case "case":
|
||
|
if (state.option.leanswitch) {
|
||
|
warning("W145", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
default:
|
||
|
if (seenCase && !state.tokens.curr.caseFallsThrough) {
|
||
|
warning("W086", state.tokens.curr, "default");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
advance("default");
|
||
|
g = true;
|
||
|
advance(":");
|
||
|
state.funct["(verb)"] = "default";
|
||
|
break;
|
||
|
case "}":
|
||
|
if (!noindent)
|
||
|
indent -= state.option.indent;
|
||
|
|
||
|
advance("}", t);
|
||
|
state.funct["(scope)"].unstack();
|
||
|
state.funct["(breakage)"] -= 1;
|
||
|
state.funct["(verb)"] = undefined;
|
||
|
return;
|
||
|
case "(end)":
|
||
|
error("E023", state.tokens.next, "}");
|
||
|
return;
|
||
|
default:
|
||
|
indent += state.option.indent;
|
||
|
if (g) {
|
||
|
switch (state.tokens.curr.id) {
|
||
|
case ",":
|
||
|
error("E040");
|
||
|
return;
|
||
|
case ":":
|
||
|
g = false;
|
||
|
statements(context);
|
||
|
break;
|
||
|
default:
|
||
|
error("E025", state.tokens.curr);
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
if (state.tokens.curr.id === ":") {
|
||
|
advance(":");
|
||
|
error("E024", state.tokens.curr, ":");
|
||
|
statements(context);
|
||
|
} else {
|
||
|
error("E021", state.tokens.next, "case", state.tokens.next.value);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
indent -= state.option.indent;
|
||
|
}
|
||
|
}
|
||
|
}).labelled = true;
|
||
|
|
||
|
stmt("debugger", function() {
|
||
|
if (!state.option.debug) {
|
||
|
warning("W087", this);
|
||
|
}
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
|
||
|
(function() {
|
||
|
var x = stmt("do", function(context) {
|
||
|
state.funct["(breakage)"] += 1;
|
||
|
state.funct["(loopage)"] += 1;
|
||
|
increaseComplexityCount();
|
||
|
|
||
|
this.first = block(context, true, true);
|
||
|
advance("while");
|
||
|
var t = state.tokens.next;
|
||
|
advance("(");
|
||
|
checkCondAssignment(expression(context, 0));
|
||
|
advance(")", t);
|
||
|
state.funct["(breakage)"] -= 1;
|
||
|
state.funct["(loopage)"] -= 1;
|
||
|
return this;
|
||
|
});
|
||
|
x.labelled = true;
|
||
|
x.exps = true;
|
||
|
}());
|
||
|
|
||
|
blockstmt("for", function(context) {
|
||
|
var s, t = state.tokens.next;
|
||
|
var letscope = false;
|
||
|
var isAsync = false;
|
||
|
var foreachtok = null;
|
||
|
|
||
|
if (t.value === "each") {
|
||
|
foreachtok = t;
|
||
|
advance("each");
|
||
|
if (!state.inMoz()) {
|
||
|
warning("W118", state.tokens.curr, "for each");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.identifier && state.tokens.next.value === "await") {
|
||
|
advance("await");
|
||
|
isAsync = true;
|
||
|
|
||
|
if (!(context & prodParams.async)) {
|
||
|
error("E024", state.tokens.curr, "await");
|
||
|
} else if (!state.inES9()) {
|
||
|
warning("W119", state.tokens.curr, "asynchronous iteration", "9");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
increaseComplexityCount();
|
||
|
advance("(");
|
||
|
var nextop; // contains the token of the "in" or "of" operator
|
||
|
var comma; // First comma punctuator at level 0
|
||
|
var initializer; // First initializer at level 0
|
||
|
var bindingPower;
|
||
|
var targets;
|
||
|
var target;
|
||
|
var decl;
|
||
|
var afterNext = peek();
|
||
|
|
||
|
var headContext = context | prodParams.noin;
|
||
|
|
||
|
if (state.tokens.next.id === "var") {
|
||
|
advance("var");
|
||
|
decl = state.tokens.curr.fud(headContext);
|
||
|
comma = decl.hasComma ? decl : null;
|
||
|
initializer = decl.hasInitializer ? decl : null;
|
||
|
} else if (state.tokens.next.id === "const" ||
|
||
|
(state.tokens.next.id === "let" &&
|
||
|
((afterNext.identifier && afterNext.id !== "in") ||
|
||
|
checkPunctuators(afterNext, ["{", "["])))) {
|
||
|
advance(state.tokens.next.id);
|
||
|
letscope = true;
|
||
|
state.funct["(scope)"].stack();
|
||
|
decl = state.tokens.curr.fud(headContext);
|
||
|
comma = decl.hasComma ? decl : null;
|
||
|
initializer = decl.hasInitializer ? decl : null;
|
||
|
} else if (!checkPunctuator(state.tokens.next, ";")) {
|
||
|
targets = [];
|
||
|
|
||
|
while (state.tokens.next.value !== "in" &&
|
||
|
state.tokens.next.value !== "of" &&
|
||
|
!checkPunctuator(state.tokens.next, ";")) {
|
||
|
|
||
|
if (checkPunctuators(state.tokens.next, ["{", "["])) {
|
||
|
destructuringPattern(headContext, { assignment: true })
|
||
|
.forEach(function(elem) {
|
||
|
this.push(elem.token);
|
||
|
}, targets);
|
||
|
if (checkPunctuator(state.tokens.next, "=")) {
|
||
|
advance("=");
|
||
|
initializer = state.tokens.curr;
|
||
|
expression(headContext, 10);
|
||
|
}
|
||
|
} else {
|
||
|
target = expression(headContext, 10);
|
||
|
|
||
|
if (target) {
|
||
|
if (target.type === "(identifier)") {
|
||
|
targets.push(target);
|
||
|
} else if (checkPunctuator(target, "=")) {
|
||
|
initializer = target;
|
||
|
targets.push(target);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (checkPunctuator(state.tokens.next, ",")) {
|
||
|
advance(",");
|
||
|
|
||
|
if (!comma) {
|
||
|
comma = state.tokens.curr;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (!initializer && !comma) {
|
||
|
targets.forEach(function(token) {
|
||
|
if (!state.funct["(scope)"].has(token.value)) {
|
||
|
warning("W088", token, token.value);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
nextop = state.tokens.next;
|
||
|
|
||
|
if (isAsync && nextop.value !== "of") {
|
||
|
error("E066", nextop);
|
||
|
}
|
||
|
if (_.includes(["in", "of"], nextop.value)) {
|
||
|
if (nextop.value === "of") {
|
||
|
bindingPower = 20;
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", nextop, "for of", "6");
|
||
|
}
|
||
|
} else {
|
||
|
bindingPower = 0;
|
||
|
}
|
||
|
if (comma) {
|
||
|
error("W133", comma, nextop.value, "more than one ForBinding");
|
||
|
}
|
||
|
if (initializer) {
|
||
|
error("W133", initializer, nextop.value, "initializer is forbidden");
|
||
|
}
|
||
|
if (target && !comma && !initializer) {
|
||
|
checkLeftSideAssign(context, target, nextop);
|
||
|
}
|
||
|
|
||
|
advance(nextop.value);
|
||
|
expression(context, bindingPower);
|
||
|
advance(")", t);
|
||
|
|
||
|
if (nextop.value === "in" && state.option.forin) {
|
||
|
state.forinifcheckneeded = true;
|
||
|
|
||
|
if (state.forinifchecks === undefined) {
|
||
|
state.forinifchecks = [];
|
||
|
}
|
||
|
state.forinifchecks.push({
|
||
|
type: "(none)"
|
||
|
});
|
||
|
}
|
||
|
|
||
|
state.funct["(breakage)"] += 1;
|
||
|
state.funct["(loopage)"] += 1;
|
||
|
|
||
|
s = block(context, true, true);
|
||
|
|
||
|
if (nextop.value === "in" && state.option.forin) {
|
||
|
if (state.forinifchecks && state.forinifchecks.length > 0) {
|
||
|
var check = state.forinifchecks.pop();
|
||
|
|
||
|
if (// No if statement or not the first statement in loop body
|
||
|
s && s.length > 0 && (typeof s[0] !== "object" || s[0].value !== "if") ||
|
||
|
check.type === "(positive)" && s.length > 1 ||
|
||
|
check.type === "(negative)") {
|
||
|
warning("W089", this);
|
||
|
}
|
||
|
}
|
||
|
state.forinifcheckneeded = false;
|
||
|
}
|
||
|
|
||
|
state.funct["(breakage)"] -= 1;
|
||
|
state.funct["(loopage)"] -= 1;
|
||
|
|
||
|
} else {
|
||
|
if (foreachtok) {
|
||
|
error("E045", foreachtok);
|
||
|
}
|
||
|
nolinebreak(state.tokens.curr);
|
||
|
advance(";");
|
||
|
if (decl) {
|
||
|
if (decl.value === "const" && !decl.hasInitializer) {
|
||
|
warning("E012", decl, decl.first[0].value);
|
||
|
}
|
||
|
|
||
|
decl.first.forEach(function(token) {
|
||
|
state.funct["(scope)"].initialize(token.value);
|
||
|
});
|
||
|
}
|
||
|
state.funct["(loopage)"] += 1;
|
||
|
if (state.tokens.next.id !== ";") {
|
||
|
checkCondAssignment(expression(context, 0));
|
||
|
}
|
||
|
nolinebreak(state.tokens.curr);
|
||
|
advance(";");
|
||
|
if (state.tokens.next.id === ";") {
|
||
|
error("E021", state.tokens.next, ")", ";");
|
||
|
}
|
||
|
if (state.tokens.next.id !== ")") {
|
||
|
for (;;) {
|
||
|
expression(context, 0);
|
||
|
if (state.tokens.next.id !== ",") {
|
||
|
break;
|
||
|
}
|
||
|
advance(",");
|
||
|
checkComma();
|
||
|
}
|
||
|
}
|
||
|
advance(")", t);
|
||
|
state.funct["(breakage)"] += 1;
|
||
|
block(context, true, true);
|
||
|
state.funct["(breakage)"] -= 1;
|
||
|
state.funct["(loopage)"] -= 1;
|
||
|
}
|
||
|
if (letscope) {
|
||
|
state.funct["(scope)"].unstack();
|
||
|
}
|
||
|
return this;
|
||
|
}).labelled = true;
|
||
|
|
||
|
|
||
|
stmt("break", function() {
|
||
|
var v = state.tokens.next.value;
|
||
|
|
||
|
if (!state.option.asi)
|
||
|
nolinebreak(this);
|
||
|
|
||
|
if (state.tokens.next.identifier &&
|
||
|
sameLine(state.tokens.curr, state.tokens.next)) {
|
||
|
if (!state.funct["(scope)"].funct.hasLabel(v)) {
|
||
|
warning("W090", state.tokens.next, v);
|
||
|
}
|
||
|
this.first = state.tokens.next;
|
||
|
advance();
|
||
|
} else {
|
||
|
if (state.funct["(breakage)"] === 0)
|
||
|
warning("W052", state.tokens.next, this.value);
|
||
|
}
|
||
|
|
||
|
reachable(this);
|
||
|
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
|
||
|
|
||
|
stmt("continue", function() {
|
||
|
var v = state.tokens.next.value;
|
||
|
|
||
|
if (state.funct["(breakage)"] === 0 || !state.funct["(loopage)"]) {
|
||
|
warning("W052", state.tokens.next, this.value);
|
||
|
}
|
||
|
|
||
|
if (!state.option.asi)
|
||
|
nolinebreak(this);
|
||
|
|
||
|
if (state.tokens.next.identifier) {
|
||
|
if (sameLine(state.tokens.curr, state.tokens.next)) {
|
||
|
if (!state.funct["(scope)"].funct.hasLabel(v)) {
|
||
|
warning("W090", state.tokens.next, v);
|
||
|
}
|
||
|
this.first = state.tokens.next;
|
||
|
advance();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
reachable(this);
|
||
|
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
|
||
|
|
||
|
stmt("return", function(context) {
|
||
|
if (sameLine(this, state.tokens.next)) {
|
||
|
if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
|
||
|
this.first = expression(context, 0);
|
||
|
|
||
|
if (this.first &&
|
||
|
this.first.type === "(punctuator)" && this.first.value === "=" &&
|
||
|
!this.first.paren && !state.option.boss) {
|
||
|
warning("W093", this.first);
|
||
|
}
|
||
|
|
||
|
if (state.option.noreturnawait && context & prodParams.async &&
|
||
|
!(context & prodParams.tryClause) &&
|
||
|
this.first.identifier && this.first.value === "await") {
|
||
|
warning("W146", this.first);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
if (state.tokens.next.type === "(punctuator)" &&
|
||
|
["[", "{", "+", "-"].indexOf(state.tokens.next.value) > -1) {
|
||
|
nolinebreak(this); // always warn (Line breaking error)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
reachable(this);
|
||
|
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
|
||
|
prefix("await", function(context) {
|
||
|
if (context & prodParams.async) {
|
||
|
if (!state.funct["(params)"]) {
|
||
|
error("E024", this, "await");
|
||
|
}
|
||
|
|
||
|
expression(context, 10);
|
||
|
return this;
|
||
|
} else {
|
||
|
this.exps = false;
|
||
|
return state.syntax["(identifier)"].nud.apply(this, arguments);
|
||
|
}
|
||
|
}).exps = true;
|
||
|
|
||
|
(function(asyncSymbol) {
|
||
|
asyncSymbol.meta = { es5: true, isFutureReservedWord: true, strictOnly: true };
|
||
|
asyncSymbol.isFunc = function() {
|
||
|
var next = state.tokens.next;
|
||
|
var afterParens;
|
||
|
|
||
|
if (this.line !== next.line) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (next.id === "function") {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (next.id === "(") {
|
||
|
afterParens = peekThroughParens(0);
|
||
|
|
||
|
return afterParens.id === "=>";
|
||
|
}
|
||
|
|
||
|
if (next.identifier) {
|
||
|
return peek().id === "=>";
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
};
|
||
|
asyncSymbol.useFud = asyncSymbol.isFunc;
|
||
|
asyncSymbol.fud = function(context) {
|
||
|
if (!state.inES8()) {
|
||
|
warning("W119", this, "async functions", "8");
|
||
|
}
|
||
|
context |= prodParams.preAsync;
|
||
|
context |= prodParams.initial;
|
||
|
this.func = expression(context, 0);
|
||
|
this.block = this.func.block;
|
||
|
this.exps = this.func.exps;
|
||
|
return this;
|
||
|
};
|
||
|
asyncSymbol.exps = true;
|
||
|
delete asyncSymbol.reserved;
|
||
|
}(prefix("async", function(context, rbp) {
|
||
|
if (this.isFunc(context)) {
|
||
|
if (!state.inES8()) {
|
||
|
warning("W119", this, "async functions", "8");
|
||
|
}
|
||
|
|
||
|
context |= prodParams.preAsync;
|
||
|
this.func = expression(context, rbp);
|
||
|
this.identifier = false;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
this.exps = false;
|
||
|
return state.syntax["(identifier)"].nud.apply(this, arguments);
|
||
|
})));
|
||
|
|
||
|
(function(yieldSymbol) {
|
||
|
yieldSymbol.rbp = yieldSymbol.lbp = 25;
|
||
|
yieldSymbol.exps = true;
|
||
|
})(prefix("yield", function(context) {
|
||
|
if (state.inMoz()) {
|
||
|
return mozYield.call(this, context);
|
||
|
}
|
||
|
|
||
|
if (!(context & prodParams.yield)) {
|
||
|
this.exps = false;
|
||
|
return state.syntax["(identifier)"].nud.apply(this, arguments);
|
||
|
}
|
||
|
|
||
|
var prev = state.tokens.prev;
|
||
|
if (!state.funct["(params)"]) {
|
||
|
error("E024", this, "yield");
|
||
|
}
|
||
|
|
||
|
if (!this.beginsStmt && prev.lbp > 30 && !checkPunctuators(prev, ["("])) {
|
||
|
error("E061", this);
|
||
|
}
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W104", state.tokens.curr, "yield", "6");
|
||
|
}
|
||
|
state.funct["(yielded)"] = true;
|
||
|
|
||
|
if (state.tokens.next.value === "*") {
|
||
|
advance("*");
|
||
|
}
|
||
|
if (state.tokens.curr.value === "*" || sameLine(state.tokens.curr, state.tokens.next)) {
|
||
|
if (state.tokens.next.nud) {
|
||
|
|
||
|
nobreaknonadjacent(state.tokens.curr, state.tokens.next);
|
||
|
this.first = expression(context, 10);
|
||
|
|
||
|
if (this.first.type === "(punctuator)" && this.first.value === "=" &&
|
||
|
!this.first.paren && !state.option.boss) {
|
||
|
warning("W093", this.first);
|
||
|
}
|
||
|
} else if (state.tokens.next.led) {
|
||
|
if (state.tokens.next.id !== ",") {
|
||
|
error("W017", state.tokens.next);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
}));
|
||
|
var mozYield = function(context) {
|
||
|
var prev = state.tokens.prev;
|
||
|
if (state.inES6(true) && !(context & prodParams.yield)) {
|
||
|
error("E046", state.tokens.curr, "yield");
|
||
|
}
|
||
|
state.funct["(yielded)"] = true;
|
||
|
var delegatingYield = false;
|
||
|
|
||
|
if (state.tokens.next.value === "*") {
|
||
|
delegatingYield = true;
|
||
|
advance("*");
|
||
|
}
|
||
|
|
||
|
if (sameLine(this, state.tokens.next)) {
|
||
|
if (delegatingYield ||
|
||
|
(state.tokens.next.id !== ";" && !state.option.asi &&
|
||
|
!state.tokens.next.reach && state.tokens.next.nud)) {
|
||
|
|
||
|
nobreaknonadjacent(state.tokens.curr, state.tokens.next);
|
||
|
this.first = expression(context, 10);
|
||
|
|
||
|
if (this.first.type === "(punctuator)" && this.first.value === "=" &&
|
||
|
!this.first.paren && !state.option.boss) {
|
||
|
warning("W093", this.first);
|
||
|
}
|
||
|
}
|
||
|
if (state.tokens.next.id !== ")" &&
|
||
|
(prev.lbp > 30 || (!prev.assign && !isEndOfExpr()))) {
|
||
|
error("E050", this);
|
||
|
}
|
||
|
} else if (!state.option.asi) {
|
||
|
nolinebreak(this); // always warn (Line breaking error)
|
||
|
}
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
stmt("throw", function(context) {
|
||
|
nolinebreak(this);
|
||
|
this.first = expression(context, 20);
|
||
|
|
||
|
reachable(this);
|
||
|
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
|
||
|
stmt("import", function(context) {
|
||
|
if (!state.funct["(scope)"].block.isGlobal()) {
|
||
|
error("E053", state.tokens.curr, "Import");
|
||
|
}
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W119", state.tokens.curr, "import", "6");
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.type === "(string)") {
|
||
|
advance("(string)");
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.identifier) {
|
||
|
this.name = identifier(context);
|
||
|
state.funct["(scope)"].addbinding(this.name, {
|
||
|
type: "import",
|
||
|
initialized: true,
|
||
|
token: state.tokens.curr });
|
||
|
|
||
|
if (state.tokens.next.value === ",") {
|
||
|
advance(",");
|
||
|
} else {
|
||
|
advance("from");
|
||
|
advance("(string)");
|
||
|
return this;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id === "*") {
|
||
|
advance("*");
|
||
|
advance("as");
|
||
|
if (state.tokens.next.identifier) {
|
||
|
this.name = identifier(context);
|
||
|
state.funct["(scope)"].addbinding(this.name, {
|
||
|
type: "import",
|
||
|
initialized: true,
|
||
|
token: state.tokens.curr });
|
||
|
}
|
||
|
} else {
|
||
|
advance("{");
|
||
|
for (;;) {
|
||
|
if (state.tokens.next.value === "}") {
|
||
|
advance("}");
|
||
|
break;
|
||
|
}
|
||
|
var importName;
|
||
|
if (state.tokens.next.type === "default") {
|
||
|
importName = "default";
|
||
|
advance("default");
|
||
|
} else {
|
||
|
importName = identifier(context);
|
||
|
}
|
||
|
if (state.tokens.next.value === "as") {
|
||
|
advance("as");
|
||
|
importName = identifier(context);
|
||
|
}
|
||
|
state.funct["(scope)"].addbinding(importName, {
|
||
|
type: "import",
|
||
|
initialized: true,
|
||
|
token: state.tokens.curr });
|
||
|
|
||
|
if (state.tokens.next.value === ",") {
|
||
|
advance(",");
|
||
|
} else if (state.tokens.next.value === "}") {
|
||
|
advance("}");
|
||
|
break;
|
||
|
} else {
|
||
|
error("E024", state.tokens.next, state.tokens.next.value);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
advance("from");
|
||
|
advance("(string)");
|
||
|
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
|
||
|
stmt("export", function(context) {
|
||
|
var ok = true;
|
||
|
var token;
|
||
|
var identifier;
|
||
|
var moduleSpecifier;
|
||
|
context = context | prodParams.export;
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W119", state.tokens.curr, "export", "6");
|
||
|
ok = false;
|
||
|
}
|
||
|
|
||
|
if (!state.funct["(scope)"].block.isGlobal()) {
|
||
|
error("E053", state.tokens.curr, "Export");
|
||
|
ok = false;
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.value === "*") {
|
||
|
advance("*");
|
||
|
advance("from");
|
||
|
advance("(string)");
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.type === "default") {
|
||
|
state.nameStack.set(state.tokens.next);
|
||
|
|
||
|
advance("default");
|
||
|
var exportType = state.tokens.next.id;
|
||
|
if (exportType === "function") {
|
||
|
this.block = true;
|
||
|
advance("function");
|
||
|
state.syntax["function"].fud(context);
|
||
|
} else if (exportType === "async" && peek().id === "function") {
|
||
|
this.block = true;
|
||
|
advance("async");
|
||
|
advance("function");
|
||
|
state.syntax["function"].fud(context | prodParams.preAsync);
|
||
|
} else if (exportType === "class") {
|
||
|
this.block = true;
|
||
|
advance("class");
|
||
|
state.syntax["class"].fud(context);
|
||
|
} else {
|
||
|
token = expression(context, 10);
|
||
|
if (token.identifier) {
|
||
|
identifier = token.value;
|
||
|
state.funct["(scope)"].setExported(identifier, token);
|
||
|
}
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
if (state.tokens.next.value === "{") {
|
||
|
advance("{");
|
||
|
var exportedTokens = [];
|
||
|
while (!checkPunctuator(state.tokens.next, "}")) {
|
||
|
if (!state.tokens.next.identifier) {
|
||
|
error("E030", state.tokens.next, state.tokens.next.value);
|
||
|
}
|
||
|
advance();
|
||
|
|
||
|
exportedTokens.push(state.tokens.curr);
|
||
|
|
||
|
if (state.tokens.next.value === "as") {
|
||
|
advance("as");
|
||
|
if (!state.tokens.next.identifier) {
|
||
|
error("E030", state.tokens.next, state.tokens.next.value);
|
||
|
}
|
||
|
advance();
|
||
|
}
|
||
|
|
||
|
if (!checkPunctuator(state.tokens.next, "}")) {
|
||
|
advance(",");
|
||
|
}
|
||
|
}
|
||
|
advance("}");
|
||
|
if (state.tokens.next.value === "from") {
|
||
|
advance("from");
|
||
|
moduleSpecifier = state.tokens.next;
|
||
|
advance("(string)");
|
||
|
} else if (ok) {
|
||
|
exportedTokens.forEach(function(token) {
|
||
|
state.funct["(scope)"].setExported(token.value, token);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (exportedTokens.length === 0) {
|
||
|
if (moduleSpecifier) {
|
||
|
warning("W142", this, "export", moduleSpecifier.value);
|
||
|
} else {
|
||
|
warning("W141", this, "export");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
} else if (state.tokens.next.id === "var") {
|
||
|
advance("var");
|
||
|
state.tokens.curr.fud(context);
|
||
|
} else if (state.tokens.next.id === "let") {
|
||
|
advance("let");
|
||
|
state.tokens.curr.fud(context);
|
||
|
} else if (state.tokens.next.id === "const") {
|
||
|
advance("const");
|
||
|
state.tokens.curr.fud(context);
|
||
|
} else if (state.tokens.next.id === "function") {
|
||
|
this.block = true;
|
||
|
advance("function");
|
||
|
state.syntax["function"].fud(context);
|
||
|
} else if (state.tokens.next.id === "async" && peek().id === "function") {
|
||
|
this.block = true;
|
||
|
advance("async");
|
||
|
advance("function");
|
||
|
state.syntax["function"].fud(context | prodParams.preAsync);
|
||
|
} else if (state.tokens.next.id === "class") {
|
||
|
this.block = true;
|
||
|
advance("class");
|
||
|
state.syntax["class"].fud(context);
|
||
|
} else {
|
||
|
error("E024", state.tokens.next, state.tokens.next.value);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
}).exps = true;
|
||
|
function supportsSuper(type, funct) {
|
||
|
if (type === "call" && funct["(async)"]) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (type === "property" && funct["(method)"]) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (type === "call" && funct["(statement)"] &&
|
||
|
funct["(statement)"].id === "class") {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (funct["(arrow)"]) {
|
||
|
return supportsSuper(type, funct["(context)"]);
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var superNud = function() {
|
||
|
var next = state.tokens.next;
|
||
|
|
||
|
if (checkPunctuators(next, ["[", "."])) {
|
||
|
if (!supportsSuper("property", state.funct)) {
|
||
|
error("E063", this);
|
||
|
}
|
||
|
} else if (checkPunctuator(next, "(")) {
|
||
|
if (!supportsSuper("call", state.funct)) {
|
||
|
error("E064", this);
|
||
|
}
|
||
|
} else {
|
||
|
error("E024", next, next.value || next.id);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
FutureReservedWord("abstract");
|
||
|
FutureReservedWord("boolean");
|
||
|
FutureReservedWord("byte");
|
||
|
FutureReservedWord("char");
|
||
|
FutureReservedWord("double");
|
||
|
FutureReservedWord("enum", { es5: true });
|
||
|
FutureReservedWord("export", { es5: true });
|
||
|
FutureReservedWord("extends", { es5: true });
|
||
|
FutureReservedWord("final");
|
||
|
FutureReservedWord("float");
|
||
|
FutureReservedWord("goto");
|
||
|
FutureReservedWord("implements", { es5: true, strictOnly: true });
|
||
|
FutureReservedWord("import", { es5: true });
|
||
|
FutureReservedWord("int");
|
||
|
FutureReservedWord("interface", { es5: true, strictOnly: true });
|
||
|
FutureReservedWord("long");
|
||
|
FutureReservedWord("native");
|
||
|
FutureReservedWord("package", { es5: true, strictOnly: true });
|
||
|
FutureReservedWord("private", { es5: true, strictOnly: true });
|
||
|
FutureReservedWord("protected", { es5: true, strictOnly: true });
|
||
|
FutureReservedWord("public", { es5: true, strictOnly: true });
|
||
|
FutureReservedWord("short");
|
||
|
FutureReservedWord("static", { es5: true, strictOnly: true });
|
||
|
FutureReservedWord("synchronized");
|
||
|
FutureReservedWord("transient");
|
||
|
FutureReservedWord("volatile");
|
||
|
|
||
|
var lookupBlockType = function() {
|
||
|
var pn, pn1, prev;
|
||
|
var i = -1;
|
||
|
var bracketStack = 0;
|
||
|
var ret = {};
|
||
|
if (checkPunctuators(state.tokens.curr, ["[", "{"])) {
|
||
|
bracketStack += 1;
|
||
|
}
|
||
|
do {
|
||
|
prev = i === -1 ? state.tokens.curr : pn;
|
||
|
pn = i === -1 ? state.tokens.next : peek(i);
|
||
|
pn1 = peek(i + 1);
|
||
|
i = i + 1;
|
||
|
if (checkPunctuators(pn, ["[", "{"])) {
|
||
|
bracketStack += 1;
|
||
|
} else if (checkPunctuators(pn, ["]", "}"])) {
|
||
|
bracketStack -= 1;
|
||
|
}
|
||
|
if (bracketStack === 1 && pn.identifier && pn.value === "for" &&
|
||
|
!checkPunctuator(prev, ".")) {
|
||
|
ret.isCompArray = true;
|
||
|
ret.notJson = true;
|
||
|
break;
|
||
|
}
|
||
|
if (bracketStack === 0 && checkPunctuators(pn, ["}", "]"])) {
|
||
|
if (pn1.value === "=") {
|
||
|
ret.isDestAssign = true;
|
||
|
ret.notJson = true;
|
||
|
break;
|
||
|
} else if (pn1.value === ".") {
|
||
|
ret.notJson = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (checkPunctuator(pn, ";")) {
|
||
|
ret.notJson = true;
|
||
|
}
|
||
|
} while (bracketStack > 0 && pn.id !== "(end)");
|
||
|
return ret;
|
||
|
};
|
||
|
function saveProperty(props, name, tkn, isClass, isStatic, isComputed) {
|
||
|
if (tkn.identifier) {
|
||
|
name = tkn.value;
|
||
|
}
|
||
|
var key = name;
|
||
|
if (isClass && isStatic) {
|
||
|
key = "static " + name;
|
||
|
}
|
||
|
|
||
|
if (props[key] && name !== "__proto__" && !isComputed) {
|
||
|
var msg = ["key", "class method", "static class method"];
|
||
|
msg = msg[(isClass || false) + (isStatic || false)];
|
||
|
warning("W075", state.tokens.next, msg, name);
|
||
|
} else {
|
||
|
props[key] = Object.create(null);
|
||
|
}
|
||
|
|
||
|
props[key].basic = true;
|
||
|
props[key].basictkn = tkn;
|
||
|
}
|
||
|
function saveAccessor(accessorType, props, name, tkn, isClass, isStatic) {
|
||
|
var flagName = accessorType === "get" ? "getterToken" : "setterToken";
|
||
|
var key = name;
|
||
|
state.tokens.curr.accessorType = accessorType;
|
||
|
state.nameStack.set(tkn);
|
||
|
if (isClass && isStatic) {
|
||
|
key = "static " + name;
|
||
|
}
|
||
|
|
||
|
if (props[key]) {
|
||
|
if ((props[key].basic || props[key][flagName]) && name !== "__proto__") {
|
||
|
var msg = "";
|
||
|
if (isClass) {
|
||
|
if (isStatic) {
|
||
|
msg += "static ";
|
||
|
}
|
||
|
msg += accessorType + "ter method";
|
||
|
} else {
|
||
|
msg = "key";
|
||
|
}
|
||
|
warning("W075", state.tokens.next, msg, name);
|
||
|
}
|
||
|
} else {
|
||
|
props[key] = Object.create(null);
|
||
|
}
|
||
|
|
||
|
props[key][flagName] = tkn;
|
||
|
if (isStatic) {
|
||
|
props[key].static = true;
|
||
|
}
|
||
|
}
|
||
|
function computedPropertyName(context) {
|
||
|
advance("[");
|
||
|
state.tokens.curr.delim = true;
|
||
|
state.tokens.curr.lbp = 0;
|
||
|
|
||
|
if (!state.inES6()) {
|
||
|
warning("W119", state.tokens.curr, "computed property names", "6");
|
||
|
}
|
||
|
var value = expression(context & ~prodParams.noin, 10);
|
||
|
advance("]");
|
||
|
return value;
|
||
|
}
|
||
|
function checkPunctuators(token, values) {
|
||
|
if (token.type === "(punctuator)") {
|
||
|
return _.includes(values, token.value);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
function checkPunctuator(token, value) {
|
||
|
return token.type === "(punctuator)" && token.value === value;
|
||
|
}
|
||
|
function destructuringAssignOrJsonValue(context) {
|
||
|
|
||
|
var block = lookupBlockType();
|
||
|
if (block.notJson) {
|
||
|
if (!state.inES6() && block.isDestAssign) {
|
||
|
warning("W104", state.tokens.curr, "destructuring assignment", "6");
|
||
|
}
|
||
|
statements(context);
|
||
|
} else {
|
||
|
state.option.laxbreak = true;
|
||
|
state.jsonMode = true;
|
||
|
jsonValue();
|
||
|
}
|
||
|
}
|
||
|
var arrayComprehension = function() {
|
||
|
var CompArray = function() {
|
||
|
this.mode = "use";
|
||
|
this.variables = [];
|
||
|
};
|
||
|
var _carrays = [];
|
||
|
var _current;
|
||
|
function declare(v) {
|
||
|
var l = _current.variables.filter(function(elt) {
|
||
|
if (elt.value === v) {
|
||
|
elt.undef = false;
|
||
|
return v;
|
||
|
}
|
||
|
}).length;
|
||
|
return l !== 0;
|
||
|
}
|
||
|
function use(v) {
|
||
|
var l = _current.variables.filter(function(elt) {
|
||
|
if (elt.value === v && !elt.undef) {
|
||
|
if (elt.unused === true) {
|
||
|
elt.unused = false;
|
||
|
}
|
||
|
return v;
|
||
|
}
|
||
|
}).length;
|
||
|
return (l === 0);
|
||
|
}
|
||
|
return { stack: function() {
|
||
|
_current = new CompArray();
|
||
|
_carrays.push(_current);
|
||
|
},
|
||
|
unstack: function() {
|
||
|
_current.variables.filter(function(v) {
|
||
|
if (v.unused)
|
||
|
warning("W098", v.token, v.token.raw_text || v.value);
|
||
|
if (v.undef)
|
||
|
state.funct["(scope)"].block.use(v.value, v.token);
|
||
|
});
|
||
|
_carrays.splice(-1, 1);
|
||
|
_current = _carrays[_carrays.length - 1];
|
||
|
},
|
||
|
setState: function(s) {
|
||
|
if (_.includes(["use", "define", "generate", "filter"], s))
|
||
|
_current.mode = s;
|
||
|
},
|
||
|
check: function(v) {
|
||
|
if (!_current) {
|
||
|
return;
|
||
|
}
|
||
|
if (_current && _current.mode === "use") {
|
||
|
if (use(v)) {
|
||
|
_current.variables.push({
|
||
|
token: state.tokens.curr,
|
||
|
value: v,
|
||
|
undef: true,
|
||
|
unused: false
|
||
|
});
|
||
|
}
|
||
|
return true;
|
||
|
} else if (_current && _current.mode === "define") {
|
||
|
if (!declare(v)) {
|
||
|
_current.variables.push({
|
||
|
token: state.tokens.curr,
|
||
|
value: v,
|
||
|
undef: false,
|
||
|
unused: true
|
||
|
});
|
||
|
}
|
||
|
return true;
|
||
|
} else if (_current && _current.mode === "generate") {
|
||
|
state.funct["(scope)"].block.use(v, state.tokens.curr);
|
||
|
return true;
|
||
|
} else if (_current && _current.mode === "filter") {
|
||
|
if (use(v)) {
|
||
|
state.funct["(scope)"].block.use(v, state.tokens.curr);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
function jsonValue() {
|
||
|
function jsonObject() {
|
||
|
var o = {}, t = state.tokens.next;
|
||
|
advance("{");
|
||
|
if (state.tokens.next.id !== "}") {
|
||
|
for (;;) {
|
||
|
if (state.tokens.next.id === "(end)") {
|
||
|
error("E026", state.tokens.next, t.line);
|
||
|
} else if (state.tokens.next.id === "}") {
|
||
|
warning("W094", state.tokens.curr);
|
||
|
break;
|
||
|
} else if (state.tokens.next.id === ",") {
|
||
|
error("E028", state.tokens.next);
|
||
|
} else if (state.tokens.next.id !== "(string)") {
|
||
|
warning("W095", state.tokens.next, state.tokens.next.value);
|
||
|
}
|
||
|
if (o[state.tokens.next.value] === true) {
|
||
|
warning("W075", state.tokens.next, "key", state.tokens.next.value);
|
||
|
} else if ((state.tokens.next.value === "__proto__" &&
|
||
|
!state.option.proto) || (state.tokens.next.value === "__iterator__" &&
|
||
|
!state.option.iterator)) {
|
||
|
warning("W096", state.tokens.next, state.tokens.next.value);
|
||
|
} else {
|
||
|
o[state.tokens.next.value] = true;
|
||
|
}
|
||
|
advance();
|
||
|
advance(":");
|
||
|
jsonValue();
|
||
|
if (state.tokens.next.id !== ",") {
|
||
|
break;
|
||
|
}
|
||
|
advance(",");
|
||
|
}
|
||
|
}
|
||
|
advance("}");
|
||
|
}
|
||
|
|
||
|
function jsonArray() {
|
||
|
var t = state.tokens.next;
|
||
|
advance("[");
|
||
|
if (state.tokens.next.id !== "]") {
|
||
|
for (;;) {
|
||
|
if (state.tokens.next.id === "(end)") {
|
||
|
error("E027", state.tokens.next, t.line);
|
||
|
} else if (state.tokens.next.id === "]") {
|
||
|
warning("W094", state.tokens.curr);
|
||
|
break;
|
||
|
} else if (state.tokens.next.id === ",") {
|
||
|
error("E028", state.tokens.next);
|
||
|
}
|
||
|
jsonValue();
|
||
|
if (state.tokens.next.id !== ",") {
|
||
|
break;
|
||
|
}
|
||
|
advance(",");
|
||
|
}
|
||
|
}
|
||
|
advance("]");
|
||
|
}
|
||
|
|
||
|
switch (state.tokens.next.id) {
|
||
|
case "{":
|
||
|
jsonObject();
|
||
|
break;
|
||
|
case "[":
|
||
|
jsonArray();
|
||
|
break;
|
||
|
case "true":
|
||
|
case "false":
|
||
|
case "null":
|
||
|
case "(number)":
|
||
|
case "(string)":
|
||
|
advance();
|
||
|
break;
|
||
|
case "-":
|
||
|
advance("-");
|
||
|
advance("(number)");
|
||
|
break;
|
||
|
default:
|
||
|
error("E003", state.tokens.next);
|
||
|
}
|
||
|
}
|
||
|
function lintEvalCode(internals, options, globals) {
|
||
|
var priorErrorCount, idx, jdx, internal;
|
||
|
|
||
|
for (idx = 0; idx < internals.length; idx += 1) {
|
||
|
internal = internals[idx];
|
||
|
options.scope = internal.elem;
|
||
|
priorErrorCount = JSHINT.errors.length;
|
||
|
|
||
|
itself(internal.code, options, globals);
|
||
|
|
||
|
for (jdx = priorErrorCount; jdx < JSHINT.errors.length; jdx += 1) {
|
||
|
JSHINT.errors[jdx].line += internal.token.line - 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var escapeRegex = function(str) {
|
||
|
return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
||
|
};
|
||
|
var itself = function(s, o, g) {
|
||
|
var x, reIgnoreStr, reIgnore;
|
||
|
var optionKeys, newOptionObj, newIgnoredObj;
|
||
|
|
||
|
o = _.clone(o);
|
||
|
state.reset();
|
||
|
newOptionObj = state.option;
|
||
|
newIgnoredObj = state.ignored;
|
||
|
|
||
|
if (o && o.scope) {
|
||
|
JSHINT.scope = o.scope;
|
||
|
} else {
|
||
|
JSHINT.errors = [];
|
||
|
JSHINT.internals = [];
|
||
|
JSHINT.blacklist = {};
|
||
|
JSHINT.scope = "(main)";
|
||
|
}
|
||
|
|
||
|
predefined = Object.create(null);
|
||
|
combine(predefined, vars.ecmaIdentifiers[3]);
|
||
|
combine(predefined, vars.reservedVars);
|
||
|
|
||
|
declared = Object.create(null);
|
||
|
var exported = Object.create(null); // Variables that live outside the current file
|
||
|
|
||
|
function each(obj, cb) {
|
||
|
if (!obj)
|
||
|
return;
|
||
|
|
||
|
if (!Array.isArray(obj) && typeof obj === "object")
|
||
|
obj = Object.keys(obj);
|
||
|
|
||
|
obj.forEach(cb);
|
||
|
}
|
||
|
|
||
|
if (o) {
|
||
|
|
||
|
each([o.predef, o.globals], function(dict) {
|
||
|
each(dict, function(item) {
|
||
|
var slice, prop;
|
||
|
|
||
|
if (item[0] === "-") {
|
||
|
slice = item.slice(1);
|
||
|
JSHINT.blacklist[slice] = slice;
|
||
|
delete predefined[slice];
|
||
|
} else {
|
||
|
prop = Object.getOwnPropertyDescriptor(dict, item);
|
||
|
predefined[item] = prop ? prop.value : false;
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
each(o.exported || null, function(item) {
|
||
|
exported[item] = true;
|
||
|
});
|
||
|
|
||
|
delete o.predef;
|
||
|
delete o.exported;
|
||
|
|
||
|
optionKeys = Object.keys(o);
|
||
|
for (x = 0; x < optionKeys.length; x++) {
|
||
|
if (/^-W\d{3}$/g.test(optionKeys[x])) {
|
||
|
newIgnoredObj[optionKeys[x].slice(1)] = true;
|
||
|
} else {
|
||
|
var optionKey = optionKeys[x];
|
||
|
newOptionObj[optionKey] = o[optionKey];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
state.option = newOptionObj;
|
||
|
state.ignored = newIgnoredObj;
|
||
|
|
||
|
state.option.indent = state.option.indent || 4;
|
||
|
state.option.maxerr = state.option.maxerr || 50;
|
||
|
|
||
|
indent = 1;
|
||
|
|
||
|
var scopeManagerInst = scopeManager(state, predefined, exported, declared);
|
||
|
scopeManagerInst.on("warning", function(ev) {
|
||
|
warning.apply(null, [ ev.code, ev.token].concat(ev.data));
|
||
|
});
|
||
|
|
||
|
scopeManagerInst.on("error", function(ev) {
|
||
|
error.apply(null, [ ev.code, ev.token ].concat(ev.data));
|
||
|
});
|
||
|
|
||
|
state.funct = functor("(global)", null, {
|
||
|
"(global)" : true,
|
||
|
"(scope)" : scopeManagerInst,
|
||
|
"(comparray)" : arrayComprehension(),
|
||
|
"(metrics)" : createMetrics(state.tokens.next)
|
||
|
});
|
||
|
|
||
|
functions = [state.funct];
|
||
|
member = {};
|
||
|
membersOnly = null;
|
||
|
inblock = false;
|
||
|
lookahead = [];
|
||
|
|
||
|
if (!isString(s) && !Array.isArray(s)) {
|
||
|
errorAt("E004", 0);
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
api = {
|
||
|
get isJSON() {
|
||
|
return state.jsonMode;
|
||
|
},
|
||
|
|
||
|
getOption: function(name) {
|
||
|
return state.option[name] || null;
|
||
|
},
|
||
|
|
||
|
getCache: function(name) {
|
||
|
return state.cache[name];
|
||
|
},
|
||
|
|
||
|
setCache: function(name, value) {
|
||
|
state.cache[name] = value;
|
||
|
},
|
||
|
|
||
|
warn: function(code, data) {
|
||
|
warningAt.apply(null, [ code, data.line, data.char ].concat(data.data));
|
||
|
},
|
||
|
|
||
|
on: function(names, listener) {
|
||
|
names.split(" ").forEach(function(name) {
|
||
|
emitter.on(name, listener);
|
||
|
}.bind(this));
|
||
|
}
|
||
|
};
|
||
|
|
||
|
emitter.removeAllListeners();
|
||
|
(extraModules || []).forEach(function(func) {
|
||
|
func(api);
|
||
|
});
|
||
|
|
||
|
state.tokens.prev = state.tokens.curr = state.tokens.next = state.syntax["(begin)"];
|
||
|
if (o && o.ignoreDelimiters) {
|
||
|
|
||
|
if (!Array.isArray(o.ignoreDelimiters)) {
|
||
|
o.ignoreDelimiters = [o.ignoreDelimiters];
|
||
|
}
|
||
|
|
||
|
o.ignoreDelimiters.forEach(function(delimiterPair) {
|
||
|
if (!delimiterPair.start || !delimiterPair.end)
|
||
|
return;
|
||
|
|
||
|
reIgnoreStr = escapeRegex(delimiterPair.start) +
|
||
|
"[\\s\\S]*?" +
|
||
|
escapeRegex(delimiterPair.end);
|
||
|
|
||
|
reIgnore = new RegExp(reIgnoreStr, "ig");
|
||
|
|
||
|
s = s.replace(reIgnore, function(match) {
|
||
|
return match.replace(/./g, " ");
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
lex = new Lexer(s);
|
||
|
|
||
|
lex.on("warning", function(ev) {
|
||
|
warningAt.apply(null, [ ev.code, ev.line, ev.character].concat(ev.data));
|
||
|
});
|
||
|
|
||
|
lex.on("error", function(ev) {
|
||
|
errorAt.apply(null, [ ev.code, ev.line, ev.character ].concat(ev.data));
|
||
|
});
|
||
|
|
||
|
lex.on("fatal", function(ev) {
|
||
|
quit("E041", ev);
|
||
|
});
|
||
|
|
||
|
lex.on("Identifier", function(ev) {
|
||
|
emitter.emit("Identifier", ev);
|
||
|
});
|
||
|
|
||
|
lex.on("String", function(ev) {
|
||
|
emitter.emit("String", ev);
|
||
|
});
|
||
|
|
||
|
lex.on("Number", function(ev) {
|
||
|
emitter.emit("Number", ev);
|
||
|
});
|
||
|
var name;
|
||
|
for (name in o) {
|
||
|
if (_.has(o, name)) {
|
||
|
checkOption(name, true, state.tokens.curr);
|
||
|
}
|
||
|
}
|
||
|
if (o) {
|
||
|
for (name in o.unstable) {
|
||
|
if (_.has(o.unstable, name)) {
|
||
|
checkOption(name, false, state.tokens.curr);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
applyOptions();
|
||
|
combine(predefined, g || {});
|
||
|
checkComma.first = true;
|
||
|
|
||
|
advance();
|
||
|
switch (state.tokens.next.id) {
|
||
|
case "{":
|
||
|
case "[":
|
||
|
destructuringAssignOrJsonValue(0);
|
||
|
break;
|
||
|
default:
|
||
|
directives();
|
||
|
|
||
|
if (state.directive["use strict"]) {
|
||
|
if (!state.allowsGlobalUsd()) {
|
||
|
warning("W097", state.tokens.prev);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
statements(0);
|
||
|
}
|
||
|
|
||
|
if (state.tokens.next.id !== "(end)") {
|
||
|
quit("E041", state.tokens.curr);
|
||
|
}
|
||
|
|
||
|
state.funct["(scope)"].unstack();
|
||
|
|
||
|
} catch (err) {
|
||
|
if (err && err.name === "JSHintError") {
|
||
|
var nt = state.tokens.next || {};
|
||
|
JSHINT.errors.push({
|
||
|
scope : "(main)",
|
||
|
raw : err.raw,
|
||
|
code : err.code,
|
||
|
reason : err.reason,
|
||
|
line : err.line || nt.line,
|
||
|
character : err.character || nt.from
|
||
|
});
|
||
|
} else {
|
||
|
throw err;
|
||
|
}
|
||
|
}
|
||
|
if (JSHINT.scope === "(main)") {
|
||
|
lintEvalCode(JSHINT.internals, o || {}, g);
|
||
|
}
|
||
|
|
||
|
return JSHINT.errors.length === 0;
|
||
|
};
|
||
|
itself.addModule = function(func) {
|
||
|
extraModules.push(func);
|
||
|
};
|
||
|
|
||
|
itself.addModule(style.register);
|
||
|
itself.data = function() {
|
||
|
var data = {
|
||
|
functions: [],
|
||
|
options: state.option
|
||
|
};
|
||
|
|
||
|
var fu, f, i, n, globals;
|
||
|
|
||
|
if (itself.errors.length) {
|
||
|
data.errors = itself.errors;
|
||
|
}
|
||
|
|
||
|
if (state.jsonMode) {
|
||
|
data.json = true;
|
||
|
}
|
||
|
|
||
|
var impliedGlobals = state.funct["(scope)"].getImpliedGlobals();
|
||
|
if (impliedGlobals.length > 0) {
|
||
|
data.implieds = impliedGlobals;
|
||
|
}
|
||
|
|
||
|
globals = state.funct["(scope)"].getUsedOrDefinedGlobals();
|
||
|
if (globals.length > 0) {
|
||
|
data.globals = globals;
|
||
|
}
|
||
|
|
||
|
for (i = 1; i < functions.length; i += 1) {
|
||
|
f = functions[i];
|
||
|
fu = {};
|
||
|
|
||
|
fu.name = f["(name)"];
|
||
|
fu.param = f["(params)"];
|
||
|
fu.line = f["(line)"];
|
||
|
fu.character = f["(character)"];
|
||
|
fu.last = f["(last)"];
|
||
|
fu.lastcharacter = f["(lastcharacter)"];
|
||
|
|
||
|
fu.metrics = {
|
||
|
complexity: f["(metrics)"].ComplexityCount,
|
||
|
parameters: f["(metrics)"].arity,
|
||
|
statements: f["(metrics)"].statementCount
|
||
|
};
|
||
|
|
||
|
data.functions.push(fu);
|
||
|
}
|
||
|
|
||
|
var unuseds = state.funct["(scope)"].getUnuseds();
|
||
|
if (unuseds.length > 0) {
|
||
|
data.unused = unuseds;
|
||
|
}
|
||
|
|
||
|
for (n in member) {
|
||
|
if (typeof member[n] === "number") {
|
||
|
data.member = member;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return data;
|
||
|
};
|
||
|
|
||
|
itself.jshint = itself;
|
||
|
|
||
|
return itself;
|
||
|
}());
|
||
|
if (typeof exports === "object" && exports) {
|
||
|
exports.JSHINT = JSHINT;
|
||
|
}
|
||
|
|
||
|
},{"./lex.js":"/../../jshint/src/lex.js","./messages.js":"/../../jshint/src/messages.js","./options.js":"/../../jshint/src/options.js","./prod-params.js":"/../../jshint/src/prod-params.js","./reg.js":"/../../jshint/src/reg.js","./scope-manager.js":"/../../jshint/src/scope-manager.js","./state.js":"/../../jshint/src/state.js","./style.js":"/../../jshint/src/style.js","./vars.js":"/../../jshint/src/vars.js","console-browserify":"/../../jshint/node_modules/console-browserify/index.js","events":"/../node_modules/events/events.js","lodash.clone":"/../../jshint/node_modules/lodash.clone/index.js","underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/lex.js":[function(_dereq_,module,exports){
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
var _ = _dereq_("underscore");
|
||
|
var events = _dereq_("events");
|
||
|
var reg = _dereq_("./reg.js");
|
||
|
var state = _dereq_("./state.js").state;
|
||
|
|
||
|
var unicodeData = _dereq_("../data/ascii-identifier-data.js");
|
||
|
var asciiIdentifierStartTable = unicodeData.asciiIdentifierStartTable;
|
||
|
var asciiIdentifierPartTable = unicodeData.asciiIdentifierPartTable;
|
||
|
var nonAsciiIdentifierStartTable = _dereq_("../data/non-ascii-identifier-start.js");
|
||
|
var nonAsciiIdentifierPartTable = _dereq_("../data/non-ascii-identifier-part-only.js");
|
||
|
var es5IdentifierNames;
|
||
|
|
||
|
var Token = {
|
||
|
Identifier: 1,
|
||
|
Punctuator: 2,
|
||
|
NumericLiteral: 3,
|
||
|
StringLiteral: 4,
|
||
|
Comment: 5,
|
||
|
Keyword: 6,
|
||
|
RegExp: 9,
|
||
|
TemplateHead: 10,
|
||
|
TemplateMiddle: 11,
|
||
|
TemplateTail: 12,
|
||
|
NoSubstTemplate: 13
|
||
|
};
|
||
|
|
||
|
var Context = {
|
||
|
Block: 1,
|
||
|
Template: 2
|
||
|
};
|
||
|
|
||
|
function isHex(str) {
|
||
|
return /^[0-9a-fA-F]+$/.test(str);
|
||
|
}
|
||
|
|
||
|
function isHexDigit(str) {
|
||
|
return str.length === 1 && isHex(str);
|
||
|
}
|
||
|
|
||
|
function asyncTrigger() {
|
||
|
var _checks = [];
|
||
|
|
||
|
return {
|
||
|
push: function(fn) {
|
||
|
_checks.push(fn);
|
||
|
},
|
||
|
|
||
|
check: function() {
|
||
|
for (var check = 0; check < _checks.length; ++check) {
|
||
|
_checks[check]();
|
||
|
}
|
||
|
|
||
|
_checks.splice(0, _checks.length);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
function Lexer(source) {
|
||
|
var lines = source;
|
||
|
|
||
|
if (typeof lines === "string") {
|
||
|
lines = lines
|
||
|
.replace(/\r\n/g, "\n")
|
||
|
.replace(/\r/g, "\n")
|
||
|
.split("\n");
|
||
|
}
|
||
|
|
||
|
if (lines[0] && lines[0].substr(0, 2) === "#!") {
|
||
|
if (lines[0].indexOf("node") !== -1) {
|
||
|
state.option.node = true;
|
||
|
}
|
||
|
lines[0] = "";
|
||
|
}
|
||
|
|
||
|
this.emitter = new events.EventEmitter();
|
||
|
this.source = source;
|
||
|
this.setLines(lines);
|
||
|
this.prereg = true;
|
||
|
|
||
|
this.line = 0;
|
||
|
this.char = 1;
|
||
|
this.from = 1;
|
||
|
this.input = "";
|
||
|
this.inComment = false;
|
||
|
this.context = [];
|
||
|
this.templateStarts = [];
|
||
|
|
||
|
for (var i = 0; i < state.option.indent; i += 1) {
|
||
|
state.tab += " ";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Lexer.prototype = {
|
||
|
_lines: [],
|
||
|
|
||
|
inContext: function(ctxType) {
|
||
|
return this.context.length > 0 && this.context[this.context.length - 1].type === ctxType;
|
||
|
},
|
||
|
|
||
|
pushContext: function(ctxType) {
|
||
|
this.context.push({ type: ctxType });
|
||
|
},
|
||
|
|
||
|
popContext: function() {
|
||
|
return this.context.pop();
|
||
|
},
|
||
|
|
||
|
currentContext: function() {
|
||
|
return this.context.length > 0 && this.context[this.context.length - 1];
|
||
|
},
|
||
|
|
||
|
getLines: function() {
|
||
|
this._lines = state.lines;
|
||
|
return this._lines;
|
||
|
},
|
||
|
|
||
|
setLines: function(val) {
|
||
|
this._lines = val;
|
||
|
state.lines = this._lines;
|
||
|
},
|
||
|
peek: function(i) {
|
||
|
return this.input.charAt(i || 0);
|
||
|
},
|
||
|
skip: function(i) {
|
||
|
i = i || 1;
|
||
|
this.char += i;
|
||
|
this.input = this.input.slice(i);
|
||
|
},
|
||
|
on: function(names, listener) {
|
||
|
names.split(" ").forEach(function(name) {
|
||
|
this.emitter.on(name, listener);
|
||
|
}.bind(this));
|
||
|
},
|
||
|
trigger: function() {
|
||
|
this.emitter.emit.apply(this.emitter, Array.prototype.slice.call(arguments));
|
||
|
},
|
||
|
triggerAsync: function(type, args, checks, fn) {
|
||
|
checks.push(function() {
|
||
|
if (fn()) {
|
||
|
this.trigger(type, args);
|
||
|
}
|
||
|
}.bind(this));
|
||
|
},
|
||
|
scanPunctuator: function() {
|
||
|
var ch1 = this.peek();
|
||
|
var ch2, ch3, ch4;
|
||
|
|
||
|
switch (ch1) {
|
||
|
case ".":
|
||
|
if ((/^[0-9]$/).test(this.peek(1))) {
|
||
|
return null;
|
||
|
}
|
||
|
if (this.peek(1) === "." && this.peek(2) === ".") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: "..."
|
||
|
};
|
||
|
}
|
||
|
case "(":
|
||
|
case ")":
|
||
|
case ";":
|
||
|
case ",":
|
||
|
case "[":
|
||
|
case "]":
|
||
|
case ":":
|
||
|
case "~":
|
||
|
case "?":
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1
|
||
|
};
|
||
|
case "{":
|
||
|
this.pushContext(Context.Block);
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1
|
||
|
};
|
||
|
case "}":
|
||
|
if (this.inContext(Context.Block)) {
|
||
|
this.popContext();
|
||
|
}
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1
|
||
|
};
|
||
|
case "#":
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1
|
||
|
};
|
||
|
case "":
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
ch2 = this.peek(1);
|
||
|
ch3 = this.peek(2);
|
||
|
ch4 = this.peek(3);
|
||
|
|
||
|
if (ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ">>>="
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (ch1 === "=" && ch2 === "=" && ch3 === "=") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: "==="
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (ch1 === "!" && ch2 === "=" && ch3 === "=") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: "!=="
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (ch1 === ">" && ch2 === ">" && ch3 === ">") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ">>>"
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (ch1 === "<" && ch2 === "<" && ch3 === "=") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: "<<="
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (ch1 === ">" && ch2 === ">" && ch3 === "=") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ">>="
|
||
|
};
|
||
|
}
|
||
|
if (ch1 === "=" && ch2 === ">") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1 + ch2
|
||
|
};
|
||
|
}
|
||
|
if (ch1 === ch2 && ("+-<>&|*".indexOf(ch1) >= 0)) {
|
||
|
if (ch1 === "*" && ch3 === "=") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1 + ch2 + ch3
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1 + ch2
|
||
|
};
|
||
|
}
|
||
|
if ("<>=!+-*%&|^/".indexOf(ch1) >= 0) {
|
||
|
if (ch2 === "=") {
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1 + ch2
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type: Token.Punctuator,
|
||
|
value: ch1
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
},
|
||
|
scanComments: function(checks) {
|
||
|
var ch1 = this.peek();
|
||
|
var ch2 = this.peek(1);
|
||
|
var rest = this.input.substr(2);
|
||
|
var startLine = this.line;
|
||
|
var startChar = this.char;
|
||
|
var self = this;
|
||
|
|
||
|
function commentToken(label, body, opt) {
|
||
|
var special = [
|
||
|
"jshint", "jshint.unstable", "jslint", "members", "member", "globals",
|
||
|
"global", "exported"
|
||
|
];
|
||
|
var isSpecial = false;
|
||
|
var value = label + body;
|
||
|
var commentType = "plain";
|
||
|
opt = opt || {};
|
||
|
|
||
|
if (opt.isMultiline) {
|
||
|
value += "*/";
|
||
|
}
|
||
|
|
||
|
body = body.replace(/\n/g, " ");
|
||
|
|
||
|
if (label === "/*" && reg.fallsThrough.test(body)) {
|
||
|
isSpecial = true;
|
||
|
commentType = "falls through";
|
||
|
}
|
||
|
|
||
|
special.forEach(function(str) {
|
||
|
if (isSpecial) {
|
||
|
return;
|
||
|
}
|
||
|
if (label === "//" && str !== "jshint" && str !== "jshint.unstable") {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (body.charAt(str.length) === " " && body.substr(0, str.length) === str) {
|
||
|
isSpecial = true;
|
||
|
label = label + str;
|
||
|
body = body.substr(str.length);
|
||
|
}
|
||
|
|
||
|
if (!isSpecial && body.charAt(0) === " " && body.charAt(str.length + 1) === " " &&
|
||
|
body.substr(1, str.length) === str) {
|
||
|
isSpecial = true;
|
||
|
label = label + " " + str;
|
||
|
body = body.substr(str.length + 1);
|
||
|
}
|
||
|
var strIndex = body.indexOf(str);
|
||
|
if (!isSpecial && strIndex >= 0 && body.charAt(strIndex + str.length) === " ") {
|
||
|
var isAllWhitespace = body.substr(0, strIndex).trim().length === 0;
|
||
|
if (isAllWhitespace) {
|
||
|
isSpecial = true;
|
||
|
body = body.substr(str.length + strIndex);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!isSpecial) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
switch (str) {
|
||
|
case "member":
|
||
|
commentType = "members";
|
||
|
break;
|
||
|
case "global":
|
||
|
commentType = "globals";
|
||
|
break;
|
||
|
default:
|
||
|
var options = body.split(":").map(function(v) {
|
||
|
return v.replace(/^\s+/, "").replace(/\s+$/, "");
|
||
|
});
|
||
|
|
||
|
if (options.length === 2) {
|
||
|
switch (options[0]) {
|
||
|
case "ignore":
|
||
|
switch (options[1]) {
|
||
|
case "start":
|
||
|
self.ignoringLinterErrors = true;
|
||
|
isSpecial = false;
|
||
|
break;
|
||
|
case "end":
|
||
|
self.ignoringLinterErrors = false;
|
||
|
isSpecial = false;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
commentType = str;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return {
|
||
|
type: Token.Comment,
|
||
|
commentType: commentType,
|
||
|
value: value,
|
||
|
body: body,
|
||
|
isSpecial: isSpecial,
|
||
|
isMalformed: opt.isMalformed || false
|
||
|
};
|
||
|
}
|
||
|
if (ch1 === "*" && ch2 === "/") {
|
||
|
this.trigger("error", {
|
||
|
code: "E018",
|
||
|
line: startLine,
|
||
|
character: startChar
|
||
|
});
|
||
|
|
||
|
this.skip(2);
|
||
|
return null;
|
||
|
}
|
||
|
if (ch1 !== "/" || (ch2 !== "*" && ch2 !== "/")) {
|
||
|
return null;
|
||
|
}
|
||
|
if (ch2 === "/") {
|
||
|
this.skip(this.input.length); // Skip to the EOL.
|
||
|
return commentToken("//", rest);
|
||
|
}
|
||
|
|
||
|
var body = "";
|
||
|
if (ch2 === "*") {
|
||
|
this.inComment = true;
|
||
|
this.skip(2);
|
||
|
|
||
|
while (this.peek() !== "*" || this.peek(1) !== "/") {
|
||
|
if (this.peek() === "") { // End of Line
|
||
|
body += "\n";
|
||
|
if (!this.nextLine(checks)) {
|
||
|
this.trigger("error", {
|
||
|
code: "E017",
|
||
|
line: startLine,
|
||
|
character: startChar
|
||
|
});
|
||
|
|
||
|
this.inComment = false;
|
||
|
return commentToken("/*", body, {
|
||
|
isMultiline: true,
|
||
|
isMalformed: true
|
||
|
});
|
||
|
}
|
||
|
} else {
|
||
|
body += this.peek();
|
||
|
this.skip();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.skip(2);
|
||
|
this.inComment = false;
|
||
|
return commentToken("/*", body, { isMultiline: true });
|
||
|
}
|
||
|
},
|
||
|
scanKeyword: function() {
|
||
|
var result = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input);
|
||
|
var keywords = [
|
||
|
"if", "in", "do", "var", "for", "new",
|
||
|
"try", "let", "this", "else", "case",
|
||
|
"void", "with", "enum", "while", "break",
|
||
|
"catch", "throw", "const", "yield", "class",
|
||
|
"super", "return", "typeof", "delete",
|
||
|
"switch", "export", "import", "default",
|
||
|
"finally", "extends", "function", "continue",
|
||
|
"debugger", "instanceof", "true", "false", "null", "async", "await"
|
||
|
];
|
||
|
|
||
|
if (result && keywords.indexOf(result[0]) >= 0) {
|
||
|
return {
|
||
|
type: Token.Keyword,
|
||
|
value: result[0]
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
},
|
||
|
scanIdentifier: function(checks) {
|
||
|
var id = "";
|
||
|
var index = 0;
|
||
|
var char, value;
|
||
|
|
||
|
function isNonAsciiIdentifierStart(code) {
|
||
|
return nonAsciiIdentifierStartTable.indexOf(code) > -1;
|
||
|
}
|
||
|
|
||
|
function isNonAsciiIdentifierPart(code) {
|
||
|
return isNonAsciiIdentifierStart(code) || nonAsciiIdentifierPartTable.indexOf(code) > -1;
|
||
|
}
|
||
|
|
||
|
var readUnicodeEscapeSequence = function() {
|
||
|
index += 1;
|
||
|
|
||
|
if (this.peek(index) !== "u") {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
var sequence = this.peek(index + 1) + this.peek(index + 2) +
|
||
|
this.peek(index + 3) + this.peek(index + 4);
|
||
|
var code;
|
||
|
|
||
|
if (isHex(sequence)) {
|
||
|
code = parseInt(sequence, 16);
|
||
|
|
||
|
if (asciiIdentifierPartTable[code] || isNonAsciiIdentifierPart(code)) {
|
||
|
index += 5;
|
||
|
return "\\u" + sequence;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}.bind(this);
|
||
|
|
||
|
var getIdentifierStart = function() {
|
||
|
var chr = this.peek(index);
|
||
|
var code = chr.charCodeAt(0);
|
||
|
|
||
|
if (code === 92) {
|
||
|
return readUnicodeEscapeSequence();
|
||
|
}
|
||
|
|
||
|
if (code < 128) {
|
||
|
if (asciiIdentifierStartTable[code]) {
|
||
|
index += 1;
|
||
|
return chr;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
if (isNonAsciiIdentifierStart(code)) {
|
||
|
index += 1;
|
||
|
return chr;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}.bind(this);
|
||
|
|
||
|
var getIdentifierPart = function() {
|
||
|
var chr = this.peek(index);
|
||
|
var code = chr.charCodeAt(0);
|
||
|
|
||
|
if (code === 92) {
|
||
|
return readUnicodeEscapeSequence();
|
||
|
}
|
||
|
|
||
|
if (code < 128) {
|
||
|
if (asciiIdentifierPartTable[code]) {
|
||
|
index += 1;
|
||
|
return chr;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
if (isNonAsciiIdentifierPart(code)) {
|
||
|
index += 1;
|
||
|
return chr;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}.bind(this);
|
||
|
|
||
|
function removeEscapeSequences(id) {
|
||
|
return id.replace(/\\u([0-9a-fA-F]{4})/g, function(m0, codepoint) {
|
||
|
return String.fromCharCode(parseInt(codepoint, 16));
|
||
|
});
|
||
|
}
|
||
|
|
||
|
char = getIdentifierStart();
|
||
|
if (char === null) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
id = char;
|
||
|
for (;;) {
|
||
|
char = getIdentifierPart();
|
||
|
|
||
|
if (char === null) {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
id += char;
|
||
|
}
|
||
|
|
||
|
value = removeEscapeSequences(id);
|
||
|
|
||
|
if (!state.inES6(true)) {
|
||
|
es5IdentifierNames = _dereq_("../data/es5-identifier-names.js");
|
||
|
|
||
|
if (!es5IdentifierNames.test(value)) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W119",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: ["unicode 8", "6"]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type: Token.Identifier,
|
||
|
value: value,
|
||
|
text: id,
|
||
|
tokenLength: id.length
|
||
|
};
|
||
|
},
|
||
|
scanNumericLiteral: function(checks) {
|
||
|
var index = 0;
|
||
|
var value = "";
|
||
|
var length = this.input.length;
|
||
|
var char = this.peek(index);
|
||
|
var isAllowedDigit = isDecimalDigit;
|
||
|
var base = 10;
|
||
|
var isLegacy = false;
|
||
|
|
||
|
function isDecimalDigit(str) {
|
||
|
return (/^[0-9]$/).test(str);
|
||
|
}
|
||
|
|
||
|
function isOctalDigit(str) {
|
||
|
return (/^[0-7]$/).test(str);
|
||
|
}
|
||
|
|
||
|
function isBinaryDigit(str) {
|
||
|
return (/^[01]$/).test(str);
|
||
|
}
|
||
|
|
||
|
function isIdentifierStart(ch) {
|
||
|
return (ch === "$") || (ch === "_") || (ch === "\\") ||
|
||
|
(ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z");
|
||
|
}
|
||
|
|
||
|
if (char !== "." && !isDecimalDigit(char)) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
if (char !== ".") {
|
||
|
value = this.peek(index);
|
||
|
index += 1;
|
||
|
char = this.peek(index);
|
||
|
|
||
|
if (value === "0") {
|
||
|
if (char === "x" || char === "X") {
|
||
|
isAllowedDigit = isHexDigit;
|
||
|
base = 16;
|
||
|
|
||
|
index += 1;
|
||
|
value += char;
|
||
|
}
|
||
|
if (char === "o" || char === "O") {
|
||
|
isAllowedDigit = isOctalDigit;
|
||
|
base = 8;
|
||
|
|
||
|
if (!state.inES6(true)) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W119",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Octal integer literal", "6" ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
|
||
|
index += 1;
|
||
|
value += char;
|
||
|
}
|
||
|
if (char === "b" || char === "B") {
|
||
|
isAllowedDigit = isBinaryDigit;
|
||
|
base = 2;
|
||
|
|
||
|
if (!state.inES6(true)) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W119",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Binary integer literal", "6" ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
|
||
|
index += 1;
|
||
|
value += char;
|
||
|
}
|
||
|
if (isOctalDigit(char)) {
|
||
|
isAllowedDigit = isOctalDigit;
|
||
|
base = 8;
|
||
|
isLegacy = true;
|
||
|
|
||
|
index += 1;
|
||
|
value += char;
|
||
|
}
|
||
|
|
||
|
if (!isOctalDigit(char) && isDecimalDigit(char)) {
|
||
|
index += 1;
|
||
|
value += char;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
while (index < length) {
|
||
|
char = this.peek(index);
|
||
|
if (!(isLegacy && isDecimalDigit(char)) && !isAllowedDigit(char)) {
|
||
|
break;
|
||
|
}
|
||
|
value += char;
|
||
|
index += 1;
|
||
|
}
|
||
|
|
||
|
var isBigInt = this.peek(index) === 'n';
|
||
|
|
||
|
if (isAllowedDigit !== isDecimalDigit || isBigInt) {
|
||
|
if (isBigInt) {
|
||
|
if (!state.option.unstable.bigint) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W144",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "BigInt", "bigint" ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
|
||
|
value += char;
|
||
|
index += 1;
|
||
|
} else if (!isLegacy && value.length <= 2) { // 0x
|
||
|
return {
|
||
|
type: Token.NumericLiteral,
|
||
|
value: value,
|
||
|
isMalformed: true
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (index < length) {
|
||
|
char = this.peek(index);
|
||
|
if (isIdentifierStart(char)) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type: Token.NumericLiteral,
|
||
|
value: value,
|
||
|
base: base,
|
||
|
isLegacy: isLegacy,
|
||
|
isMalformed: false
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (char === ".") {
|
||
|
value += char;
|
||
|
index += 1;
|
||
|
|
||
|
while (index < length) {
|
||
|
char = this.peek(index);
|
||
|
if (!isDecimalDigit(char)) {
|
||
|
break;
|
||
|
}
|
||
|
value += char;
|
||
|
index += 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (char === "e" || char === "E") {
|
||
|
value += char;
|
||
|
index += 1;
|
||
|
char = this.peek(index);
|
||
|
|
||
|
if (char === "+" || char === "-") {
|
||
|
value += this.peek(index);
|
||
|
index += 1;
|
||
|
}
|
||
|
|
||
|
char = this.peek(index);
|
||
|
if (isDecimalDigit(char)) {
|
||
|
value += char;
|
||
|
index += 1;
|
||
|
|
||
|
while (index < length) {
|
||
|
char = this.peek(index);
|
||
|
if (!isDecimalDigit(char)) {
|
||
|
break;
|
||
|
}
|
||
|
value += char;
|
||
|
index += 1;
|
||
|
}
|
||
|
} else {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (index < length) {
|
||
|
char = this.peek(index);
|
||
|
if (isIdentifierStart(char)) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type: Token.NumericLiteral,
|
||
|
value: value,
|
||
|
base: base,
|
||
|
isMalformed: !isFinite(value)
|
||
|
};
|
||
|
},
|
||
|
scanEscapeSequence: function(checks) {
|
||
|
var allowNewLine = false;
|
||
|
var jump = 1;
|
||
|
this.skip();
|
||
|
var char = this.peek();
|
||
|
|
||
|
switch (char) {
|
||
|
case "'":
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W114",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "\\'" ]
|
||
|
}, checks, function() {return state.jsonMode; });
|
||
|
break;
|
||
|
case "b":
|
||
|
char = "\\b";
|
||
|
break;
|
||
|
case "f":
|
||
|
char = "\\f";
|
||
|
break;
|
||
|
case "n":
|
||
|
char = "\\n";
|
||
|
break;
|
||
|
case "r":
|
||
|
char = "\\r";
|
||
|
break;
|
||
|
case "t":
|
||
|
char = "\\t";
|
||
|
break;
|
||
|
case "0":
|
||
|
char = "\\0";
|
||
|
var n = parseInt(this.peek(1), 10);
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W115",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
}, checks,
|
||
|
function() { return n >= 0 && n <= 7 && state.isStrict(); });
|
||
|
break;
|
||
|
case "1":
|
||
|
case "2":
|
||
|
case "3":
|
||
|
case "4":
|
||
|
case "5":
|
||
|
case "6":
|
||
|
case "7":
|
||
|
char = "\\" + char;
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W115",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
}, checks,
|
||
|
function() { return state.isStrict(); });
|
||
|
break;
|
||
|
case "u":
|
||
|
var sequence = this.input.substr(1, 4);
|
||
|
var code = parseInt(sequence, 16);
|
||
|
if (!isHex(sequence)) {
|
||
|
this.trigger("warning", {
|
||
|
code: "W052",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "u" + sequence ]
|
||
|
});
|
||
|
}
|
||
|
char = String.fromCharCode(code);
|
||
|
jump = 5;
|
||
|
break;
|
||
|
case "v":
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W114",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "\\v" ]
|
||
|
}, checks, function() { return state.jsonMode; });
|
||
|
|
||
|
char = "\v";
|
||
|
break;
|
||
|
case "x":
|
||
|
var x = parseInt(this.input.substr(1, 2), 16);
|
||
|
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W114",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "\\x-" ]
|
||
|
}, checks, function() { return state.jsonMode; });
|
||
|
|
||
|
char = String.fromCharCode(x);
|
||
|
jump = 3;
|
||
|
break;
|
||
|
case "\\":
|
||
|
char = "\\\\";
|
||
|
break;
|
||
|
case "\"":
|
||
|
char = "\\\"";
|
||
|
break;
|
||
|
case "/":
|
||
|
break;
|
||
|
case "":
|
||
|
allowNewLine = true;
|
||
|
char = "";
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return { char: char, jump: jump, allowNewLine: allowNewLine };
|
||
|
},
|
||
|
scanTemplateLiteral: function(checks) {
|
||
|
var tokenType;
|
||
|
var value = "";
|
||
|
var ch;
|
||
|
var startLine = this.line;
|
||
|
var startChar = this.char;
|
||
|
var depth = this.templateStarts.length;
|
||
|
|
||
|
if (this.peek() === "`") {
|
||
|
if (!state.inES6(true)) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W119",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: ["template literal syntax", "6"]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
tokenType = Token.TemplateHead;
|
||
|
this.templateStarts.push({ line: this.line, char: this.char });
|
||
|
depth = this.templateStarts.length;
|
||
|
this.skip(1);
|
||
|
this.pushContext(Context.Template);
|
||
|
} else if (this.inContext(Context.Template) && this.peek() === "}") {
|
||
|
tokenType = Token.TemplateMiddle;
|
||
|
} else {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
while (this.peek() !== "`") {
|
||
|
while ((ch = this.peek()) === "") {
|
||
|
value += "\n";
|
||
|
if (!this.nextLine(checks)) {
|
||
|
var startPos = this.templateStarts.pop();
|
||
|
this.trigger("error", {
|
||
|
code: "E052",
|
||
|
line: startPos.line,
|
||
|
character: startPos.char
|
||
|
});
|
||
|
return {
|
||
|
type: tokenType,
|
||
|
value: value,
|
||
|
startLine: startLine,
|
||
|
startChar: startChar,
|
||
|
isUnclosed: true,
|
||
|
depth: depth,
|
||
|
context: this.popContext()
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (ch === '$' && this.peek(1) === '{') {
|
||
|
value += '${';
|
||
|
this.skip(2);
|
||
|
return {
|
||
|
type: tokenType,
|
||
|
value: value,
|
||
|
startLine: startLine,
|
||
|
startChar: startChar,
|
||
|
isUnclosed: false,
|
||
|
depth: depth,
|
||
|
context: this.currentContext()
|
||
|
};
|
||
|
} else if (ch === '\\') {
|
||
|
var escape = this.scanEscapeSequence(checks);
|
||
|
value += escape.char;
|
||
|
this.skip(escape.jump);
|
||
|
} else if (ch !== '`') {
|
||
|
value += ch;
|
||
|
this.skip(1);
|
||
|
}
|
||
|
}
|
||
|
tokenType = tokenType === Token.TemplateHead ? Token.NoSubstTemplate : Token.TemplateTail;
|
||
|
this.skip(1);
|
||
|
this.templateStarts.pop();
|
||
|
|
||
|
return {
|
||
|
type: tokenType,
|
||
|
value: value,
|
||
|
startLine: startLine,
|
||
|
startChar: startChar,
|
||
|
isUnclosed: false,
|
||
|
depth: depth,
|
||
|
context: this.popContext()
|
||
|
};
|
||
|
},
|
||
|
scanStringLiteral: function(checks) {
|
||
|
var quote = this.peek();
|
||
|
if (quote !== "\"" && quote !== "'") {
|
||
|
return null;
|
||
|
}
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W108",
|
||
|
line: this.line,
|
||
|
character: this.char // +1?
|
||
|
}, checks, function() { return state.jsonMode && quote !== "\""; });
|
||
|
|
||
|
var value = "";
|
||
|
var startLine = this.line;
|
||
|
var startChar = this.char;
|
||
|
var allowNewLine = false;
|
||
|
|
||
|
this.skip();
|
||
|
|
||
|
while (this.peek() !== quote) {
|
||
|
if (this.peek() === "") { // End Of Line
|
||
|
|
||
|
if (!allowNewLine) {
|
||
|
this.trigger("warning", {
|
||
|
code: "W112",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
});
|
||
|
} else {
|
||
|
allowNewLine = false;
|
||
|
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W043",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
}, checks, function() { return !state.option.multistr; });
|
||
|
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W042",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
}, checks, function() { return state.jsonMode && state.option.multistr; });
|
||
|
}
|
||
|
|
||
|
if (!this.nextLine(checks)) {
|
||
|
return {
|
||
|
type: Token.StringLiteral,
|
||
|
value: value,
|
||
|
startLine: startLine,
|
||
|
startChar: startChar,
|
||
|
isUnclosed: true,
|
||
|
quote: quote
|
||
|
};
|
||
|
}
|
||
|
|
||
|
} else { // Any character other than End Of Line
|
||
|
|
||
|
allowNewLine = false;
|
||
|
var char = this.peek();
|
||
|
var jump = 1; // A length of a jump, after we're done
|
||
|
|
||
|
if (char < " ") {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W113",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "<non-printable>" ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
if (char === "\\") {
|
||
|
var parsed = this.scanEscapeSequence(checks);
|
||
|
char = parsed.char;
|
||
|
jump = parsed.jump;
|
||
|
allowNewLine = parsed.allowNewLine;
|
||
|
}
|
||
|
if (char !== "") {
|
||
|
value += char;
|
||
|
this.skip(jump);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.skip();
|
||
|
return {
|
||
|
type: Token.StringLiteral,
|
||
|
value: value,
|
||
|
startLine: startLine,
|
||
|
startChar: startChar,
|
||
|
isUnclosed: false,
|
||
|
quote: quote
|
||
|
};
|
||
|
},
|
||
|
scanRegExp: function(checks) {
|
||
|
var index = 0;
|
||
|
var length = this.input.length;
|
||
|
var char = this.peek();
|
||
|
var value = char;
|
||
|
var body = "";
|
||
|
var groupReferences = [];
|
||
|
var allFlags = "";
|
||
|
var es5Flags = "";
|
||
|
var malformed = false;
|
||
|
var isCharSet = false;
|
||
|
var isCharSetRange = false;
|
||
|
var isGroup = false;
|
||
|
var isQuantifiable = false;
|
||
|
var hasInvalidQuantifier = false;
|
||
|
var escapedChars = "";
|
||
|
var hasUFlag = function() { return allFlags.indexOf("u") > -1; };
|
||
|
var escapeSequence;
|
||
|
var groupCount = 0;
|
||
|
var terminated, malformedDesc;
|
||
|
|
||
|
var scanRegexpEscapeSequence = function() {
|
||
|
var next, sequence;
|
||
|
index += 1;
|
||
|
char = this.peek(index);
|
||
|
|
||
|
if (reg.nonzeroDigit.test(char)) {
|
||
|
sequence = char;
|
||
|
next = this.peek(index + 1);
|
||
|
while (reg.nonzeroDigit.test(next) || next === "0") {
|
||
|
index += 1;
|
||
|
char = next;
|
||
|
sequence += char;
|
||
|
body += char;
|
||
|
value += char;
|
||
|
next = this.peek(index + 1);
|
||
|
}
|
||
|
groupReferences.push(Number(sequence));
|
||
|
return sequence;
|
||
|
}
|
||
|
|
||
|
escapedChars += char;
|
||
|
|
||
|
if (char === "u" && this.peek(index + 1) === "{") {
|
||
|
var x = index + 2;
|
||
|
sequence = "u{";
|
||
|
next = this.peek(x);
|
||
|
while (isHex(next)) {
|
||
|
sequence += next;
|
||
|
x += 1;
|
||
|
next = this.peek(x);
|
||
|
}
|
||
|
|
||
|
if (next !== "}") {
|
||
|
this.triggerAsync(
|
||
|
"error",
|
||
|
{
|
||
|
code: "E016",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Invalid Unicode escape sequence" ]
|
||
|
},
|
||
|
checks,
|
||
|
hasUFlag
|
||
|
);
|
||
|
} else if (sequence.length > 2) {
|
||
|
sequence += "}";
|
||
|
body += sequence;
|
||
|
value += sequence;
|
||
|
index = x + 1;
|
||
|
return sequence;
|
||
|
}
|
||
|
}
|
||
|
if (char < " ") {
|
||
|
malformed = true;
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W048",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
if (char === "<") {
|
||
|
malformed = true;
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W049",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ char ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
} else if (char === "0" && reg.decimalDigit.test(this.peek(index + 1))) {
|
||
|
this.triggerAsync(
|
||
|
"error",
|
||
|
{
|
||
|
code: "E016",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Invalid decimal escape sequence" ]
|
||
|
},
|
||
|
checks,
|
||
|
hasUFlag
|
||
|
);
|
||
|
}
|
||
|
|
||
|
index += 1;
|
||
|
body += char;
|
||
|
value += char;
|
||
|
|
||
|
return char;
|
||
|
}.bind(this);
|
||
|
|
||
|
var checkQuantifier = function() {
|
||
|
var lookahead = index;
|
||
|
var lowerBound = "";
|
||
|
var upperBound = "";
|
||
|
var next;
|
||
|
|
||
|
next = this.peek(lookahead + 1);
|
||
|
|
||
|
while (reg.decimalDigit.test(next)) {
|
||
|
lookahead += 1;
|
||
|
lowerBound += next;
|
||
|
next = this.peek(lookahead + 1);
|
||
|
}
|
||
|
|
||
|
if (!lowerBound) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (next === "}") {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (next !== ",") {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
lookahead += 1;
|
||
|
next = this.peek(lookahead + 1);
|
||
|
|
||
|
while (reg.decimalDigit.test(next)) {
|
||
|
lookahead += 1;
|
||
|
upperBound += next;
|
||
|
next = this.peek(lookahead + 1);
|
||
|
}
|
||
|
|
||
|
if (next !== "}") {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (upperBound) {
|
||
|
return Number(lowerBound) <= Number(upperBound);
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}.bind(this);
|
||
|
|
||
|
var translateUFlag = function(body) {
|
||
|
var astralSubstitute = "\uFFFF";
|
||
|
|
||
|
return body
|
||
|
.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function($0, $1, $2) {
|
||
|
var codePoint = parseInt($1 || $2, 16);
|
||
|
var literal;
|
||
|
|
||
|
if (codePoint > 0x10FFFF) {
|
||
|
malformed = true;
|
||
|
this.trigger("error", {
|
||
|
code: "E016",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ char ]
|
||
|
});
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
literal = String.fromCharCode(codePoint);
|
||
|
|
||
|
if (reg.regexpSyntaxChars.test(literal)) {
|
||
|
return $0;
|
||
|
}
|
||
|
|
||
|
if (codePoint <= 0xFFFF) {
|
||
|
return String.fromCharCode(codePoint);
|
||
|
}
|
||
|
return astralSubstitute;
|
||
|
}.bind(this))
|
||
|
.replace(
|
||
|
/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
|
||
|
astralSubstitute
|
||
|
);
|
||
|
}.bind(this);
|
||
|
if (!this.prereg || char !== "/") {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
index += 1;
|
||
|
terminated = false;
|
||
|
|
||
|
while (index < length) {
|
||
|
isCharSetRange &= char === "-";
|
||
|
char = this.peek(index);
|
||
|
value += char;
|
||
|
body += char;
|
||
|
|
||
|
if (isCharSet) {
|
||
|
if (char === "]") {
|
||
|
if (this.peek(index - 1) !== "\\" || this.peek(index - 2) === "\\") {
|
||
|
isCharSet = false;
|
||
|
}
|
||
|
} else if (char === "-") {
|
||
|
isCharSetRange = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (char === "\\") {
|
||
|
escapeSequence = scanRegexpEscapeSequence();
|
||
|
|
||
|
if (isCharSet && (this.peek(index) === "-" || isCharSetRange) &&
|
||
|
reg.regexpCharClasses.test(escapeSequence)) {
|
||
|
this.triggerAsync(
|
||
|
"error",
|
||
|
{
|
||
|
code: "E016",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Character class used in range" ]
|
||
|
},
|
||
|
checks,
|
||
|
hasUFlag
|
||
|
);
|
||
|
}
|
||
|
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (isCharSet) {
|
||
|
index += 1;
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (char === "{" && !hasInvalidQuantifier) {
|
||
|
hasInvalidQuantifier = !checkQuantifier();
|
||
|
}
|
||
|
|
||
|
if (char === "[") {
|
||
|
isCharSet = true;
|
||
|
index += 1;
|
||
|
continue;
|
||
|
} else if (char === "(") {
|
||
|
isGroup = true;
|
||
|
|
||
|
if (this.peek(index + 1) === "?" &&
|
||
|
(this.peek(index + 2) === "=" || this.peek(index + 2) === "!")) {
|
||
|
isQuantifiable = true;
|
||
|
}
|
||
|
} else if (char === ")") {
|
||
|
if (isQuantifiable) {
|
||
|
isQuantifiable = false;
|
||
|
|
||
|
if (reg.regexpQuantifiers.test(this.peek(index + 1))) {
|
||
|
this.triggerAsync(
|
||
|
"error",
|
||
|
{
|
||
|
code: "E016",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Quantified quantifiable" ]
|
||
|
},
|
||
|
checks,
|
||
|
hasUFlag
|
||
|
);
|
||
|
}
|
||
|
} else {
|
||
|
groupCount += 1;
|
||
|
}
|
||
|
|
||
|
isGroup = false;
|
||
|
} else if (char === "/") {
|
||
|
body = body.substr(0, body.length - 1);
|
||
|
terminated = true;
|
||
|
index += 1;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
index += 1;
|
||
|
}
|
||
|
|
||
|
if (!terminated) {
|
||
|
this.trigger("error", {
|
||
|
code: "E015",
|
||
|
line: this.line,
|
||
|
character: this.from
|
||
|
});
|
||
|
|
||
|
return void this.trigger("fatal", {
|
||
|
line: this.line,
|
||
|
from: this.from
|
||
|
});
|
||
|
}
|
||
|
|
||
|
while (index < length) {
|
||
|
char = this.peek(index);
|
||
|
if (!/[gimyus]/.test(char)) {
|
||
|
break;
|
||
|
}
|
||
|
if (char === "y") {
|
||
|
if (!state.inES6(true)) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W119",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Sticky RegExp flag", "6" ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
} else if (char === "u") {
|
||
|
if (!state.inES6(true)) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W119",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "Unicode RegExp flag", "6" ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
|
||
|
var hasInvalidEscape = (function(groupReferences, groupCount, escapedChars, reg) {
|
||
|
var hasInvalidGroup = groupReferences.some(function(groupReference) {
|
||
|
if (groupReference > groupCount) {
|
||
|
return true;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (hasInvalidGroup) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return !escapedChars.split("").every(function(escapedChar) {
|
||
|
return escapedChar === "u" ||
|
||
|
escapedChar === "/" ||
|
||
|
escapedChar === "0" ||
|
||
|
reg.regexpControlEscapes.test(escapedChar) ||
|
||
|
reg.regexpCharClasses.test(escapedChar) ||
|
||
|
reg.regexpSyntaxChars.test(escapedChar);
|
||
|
});
|
||
|
}(groupReferences, groupCount, escapedChars, reg));
|
||
|
|
||
|
if (hasInvalidEscape) {
|
||
|
malformedDesc = "Invalid escape";
|
||
|
} else if (hasInvalidQuantifier) {
|
||
|
malformedDesc = "Invalid quantifier";
|
||
|
}
|
||
|
|
||
|
body = translateUFlag(body);
|
||
|
} else if (char === "s") {
|
||
|
if (!state.inES9()) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{
|
||
|
code: "W119",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "DotAll RegExp flag", "9" ]
|
||
|
},
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
if (value.indexOf("s") > -1) {
|
||
|
malformedDesc = "Duplicate RegExp flag";
|
||
|
}
|
||
|
} else {
|
||
|
es5Flags += char;
|
||
|
}
|
||
|
|
||
|
if (allFlags.indexOf(char) > -1) {
|
||
|
malformedDesc = "Duplicate RegExp flag";
|
||
|
}
|
||
|
allFlags += char;
|
||
|
|
||
|
value += char;
|
||
|
allFlags += char;
|
||
|
index += 1;
|
||
|
}
|
||
|
|
||
|
if (allFlags.indexOf("u") === -1) {
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W147",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
}, checks, function() { return state.option.regexpu; });
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
new RegExp(body, es5Flags);
|
||
|
} catch (err) {
|
||
|
malformedDesc = err.message;
|
||
|
}
|
||
|
|
||
|
if (malformedDesc) {
|
||
|
malformed = true;
|
||
|
this.trigger("error", {
|
||
|
code: "E016",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ malformedDesc ]
|
||
|
});
|
||
|
} else if (allFlags.indexOf("s") > -1 && !reg.regexpDot.test(body)) {
|
||
|
this.trigger("warning", {
|
||
|
code: "W148",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type: Token.RegExp,
|
||
|
value: value,
|
||
|
isMalformed: malformed
|
||
|
};
|
||
|
},
|
||
|
scanNonBreakingSpaces: function() {
|
||
|
return state.option.nonbsp ?
|
||
|
this.input.search(/(\u00A0)/) : -1;
|
||
|
},
|
||
|
next: function(checks) {
|
||
|
this.from = this.char;
|
||
|
while (reg.whitespace.test(this.peek())) {
|
||
|
this.from += 1;
|
||
|
this.skip();
|
||
|
}
|
||
|
|
||
|
var match = this.scanComments(checks) ||
|
||
|
this.scanStringLiteral(checks) ||
|
||
|
this.scanTemplateLiteral(checks);
|
||
|
|
||
|
if (match) {
|
||
|
return match;
|
||
|
}
|
||
|
|
||
|
match =
|
||
|
this.scanRegExp(checks) ||
|
||
|
this.scanPunctuator() ||
|
||
|
this.scanKeyword() ||
|
||
|
this.scanIdentifier(checks) ||
|
||
|
this.scanNumericLiteral(checks);
|
||
|
|
||
|
if (match) {
|
||
|
this.skip(match.tokenLength || match.value.length);
|
||
|
return match;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
},
|
||
|
nextLine: function(checks) {
|
||
|
var char;
|
||
|
|
||
|
if (this.line >= this.getLines().length) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
this.input = this.getLines()[this.line];
|
||
|
this.line += 1;
|
||
|
this.char = 1;
|
||
|
this.from = 1;
|
||
|
|
||
|
var inputTrimmed = this.input.trim();
|
||
|
|
||
|
var startsWith = function() {
|
||
|
return _.some(arguments, function(prefix) {
|
||
|
return inputTrimmed.indexOf(prefix) === 0;
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var endsWith = function() {
|
||
|
return _.some(arguments, function(suffix) {
|
||
|
return inputTrimmed.indexOf(suffix, inputTrimmed.length - suffix.length) !== -1;
|
||
|
});
|
||
|
};
|
||
|
if (this.ignoringLinterErrors === true) {
|
||
|
if (!startsWith("/*", "//") && !(this.inComment && endsWith("*/"))) {
|
||
|
this.input = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
char = this.scanNonBreakingSpaces();
|
||
|
if (char >= 0) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{ code: "W125", line: this.line, character: char + 1 },
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
|
||
|
this.input = this.input.replace(/\t/g, state.tab);
|
||
|
|
||
|
if (!this.ignoringLinterErrors && state.option.maxlen &&
|
||
|
state.option.maxlen < this.input.length) {
|
||
|
var inComment = this.inComment ||
|
||
|
startsWith.call(inputTrimmed, "//") ||
|
||
|
startsWith.call(inputTrimmed, "/*");
|
||
|
|
||
|
var shouldTriggerError = !inComment || !reg.maxlenException.test(inputTrimmed);
|
||
|
|
||
|
if (shouldTriggerError) {
|
||
|
this.triggerAsync(
|
||
|
"warning",
|
||
|
{ code: "W101", line: this.line, character: this.input.length },
|
||
|
checks,
|
||
|
function() { return true; }
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
},
|
||
|
token: function() {
|
||
|
var checks = asyncTrigger();
|
||
|
var token;
|
||
|
var create = function(type, value, isProperty, token) {
|
||
|
var obj;
|
||
|
|
||
|
if (type !== "(endline)" && type !== "(end)") {
|
||
|
this.prereg = false;
|
||
|
}
|
||
|
|
||
|
if (type === "(punctuator)") {
|
||
|
switch (value) {
|
||
|
case ".":
|
||
|
case ")":
|
||
|
case "~":
|
||
|
case "#":
|
||
|
case "]":
|
||
|
case "}":
|
||
|
case "++":
|
||
|
case "--":
|
||
|
this.prereg = false;
|
||
|
break;
|
||
|
default:
|
||
|
this.prereg = true;
|
||
|
}
|
||
|
|
||
|
obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
|
||
|
}
|
||
|
|
||
|
if (type === "(identifier)") {
|
||
|
if (value === "return" || value === "case" || value === "yield" ||
|
||
|
value === "typeof" || value === "instanceof" || value === "void" ||
|
||
|
value === "await") {
|
||
|
this.prereg = true;
|
||
|
}
|
||
|
|
||
|
if (_.has(state.syntax, value)) {
|
||
|
obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (type === "(template)" || type === "(template middle)") {
|
||
|
this.prereg = true;
|
||
|
}
|
||
|
|
||
|
if (!obj) {
|
||
|
obj = Object.create(state.syntax[type]);
|
||
|
}
|
||
|
|
||
|
obj.identifier = (type === "(identifier)");
|
||
|
obj.type = obj.type || type;
|
||
|
obj.value = value;
|
||
|
obj.line = this.line;
|
||
|
obj.character = this.char;
|
||
|
obj.from = this.from;
|
||
|
if (obj.identifier && token) obj.raw_text = token.text || token.value;
|
||
|
if (token && token.startLine && token.startLine !== this.line) {
|
||
|
obj.startLine = token.startLine;
|
||
|
}
|
||
|
if (token && token.context) {
|
||
|
obj.context = token.context;
|
||
|
}
|
||
|
if (token && token.depth) {
|
||
|
obj.depth = token.depth;
|
||
|
}
|
||
|
if (token && token.isUnclosed) {
|
||
|
obj.isUnclosed = token.isUnclosed;
|
||
|
}
|
||
|
|
||
|
if (isProperty && obj.identifier) {
|
||
|
obj.isProperty = isProperty;
|
||
|
}
|
||
|
|
||
|
obj.check = checks.check;
|
||
|
|
||
|
return obj;
|
||
|
}.bind(this);
|
||
|
|
||
|
for (;;) {
|
||
|
if (!this.input.length) {
|
||
|
if (this.nextLine(checks)) {
|
||
|
return create("(endline)", "");
|
||
|
}
|
||
|
|
||
|
if (this.exhausted) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
this.exhausted = true;
|
||
|
return create("(end)", "");
|
||
|
}
|
||
|
|
||
|
token = this.next(checks);
|
||
|
|
||
|
if (!token) {
|
||
|
if (this.input.length) {
|
||
|
this.trigger("error", {
|
||
|
code: "E024",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ this.peek() ]
|
||
|
});
|
||
|
|
||
|
this.input = "";
|
||
|
}
|
||
|
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
switch (token.type) {
|
||
|
case Token.StringLiteral:
|
||
|
this.triggerAsync("String", {
|
||
|
line: this.line,
|
||
|
char: this.char,
|
||
|
from: this.from,
|
||
|
startLine: token.startLine,
|
||
|
startChar: token.startChar,
|
||
|
value: token.value,
|
||
|
quote: token.quote
|
||
|
}, checks, function() { return true; });
|
||
|
|
||
|
return create("(string)", token.value, null, token);
|
||
|
|
||
|
case Token.TemplateHead:
|
||
|
this.trigger("TemplateHead", {
|
||
|
line: this.line,
|
||
|
char: this.char,
|
||
|
from: this.from,
|
||
|
startLine: token.startLine,
|
||
|
startChar: token.startChar,
|
||
|
value: token.value
|
||
|
});
|
||
|
return create("(template)", token.value, null, token);
|
||
|
|
||
|
case Token.TemplateMiddle:
|
||
|
this.trigger("TemplateMiddle", {
|
||
|
line: this.line,
|
||
|
char: this.char,
|
||
|
from: this.from,
|
||
|
startLine: token.startLine,
|
||
|
startChar: token.startChar,
|
||
|
value: token.value
|
||
|
});
|
||
|
return create("(template middle)", token.value, null, token);
|
||
|
|
||
|
case Token.TemplateTail:
|
||
|
this.trigger("TemplateTail", {
|
||
|
line: this.line,
|
||
|
char: this.char,
|
||
|
from: this.from,
|
||
|
startLine: token.startLine,
|
||
|
startChar: token.startChar,
|
||
|
value: token.value
|
||
|
});
|
||
|
return create("(template tail)", token.value, null, token);
|
||
|
|
||
|
case Token.NoSubstTemplate:
|
||
|
this.trigger("NoSubstTemplate", {
|
||
|
line: this.line,
|
||
|
char: this.char,
|
||
|
from: this.from,
|
||
|
startLine: token.startLine,
|
||
|
startChar: token.startChar,
|
||
|
value: token.value
|
||
|
});
|
||
|
return create("(no subst template)", token.value, null, token);
|
||
|
|
||
|
case Token.Identifier:
|
||
|
this.triggerAsync("Identifier", {
|
||
|
line: this.line,
|
||
|
char: this.char,
|
||
|
from: this.from,
|
||
|
name: token.value,
|
||
|
raw_name: token.text,
|
||
|
isProperty: state.tokens.curr.id === "."
|
||
|
}, checks, function() { return true; });
|
||
|
case Token.Keyword:
|
||
|
return create("(identifier)", token.value, state.tokens.curr.id === ".", token);
|
||
|
|
||
|
case Token.NumericLiteral:
|
||
|
if (token.isMalformed) {
|
||
|
this.trigger("warning", {
|
||
|
code: "W045",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ token.value ]
|
||
|
});
|
||
|
}
|
||
|
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W114",
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
data: [ "0x-" ]
|
||
|
}, checks, function() { return token.base === 16 && state.jsonMode; });
|
||
|
|
||
|
this.triggerAsync("warning", {
|
||
|
code: "W115",
|
||
|
line: this.line,
|
||
|
character: this.char
|
||
|
}, checks, function() {
|
||
|
return state.isStrict() && token.base === 8 && token.isLegacy;
|
||
|
});
|
||
|
|
||
|
this.trigger("Number", {
|
||
|
line: this.line,
|
||
|
char: this.char,
|
||
|
from: this.from,
|
||
|
value: token.value,
|
||
|
base: token.base,
|
||
|
isMalformed: token.isMalformed
|
||
|
});
|
||
|
|
||
|
return create("(number)", token.value);
|
||
|
|
||
|
case Token.RegExp:
|
||
|
return create("(regexp)", token.value);
|
||
|
|
||
|
case Token.Comment:
|
||
|
if (token.isSpecial) {
|
||
|
return {
|
||
|
id: '(comment)',
|
||
|
value: token.value,
|
||
|
body: token.body,
|
||
|
type: token.commentType,
|
||
|
isSpecial: token.isSpecial,
|
||
|
line: this.line,
|
||
|
character: this.char,
|
||
|
from: this.from
|
||
|
};
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
return create("(punctuator)", token.value);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
exports.Lexer = Lexer;
|
||
|
exports.Context = Context;
|
||
|
|
||
|
},{"../data/ascii-identifier-data.js":"/../../jshint/data/ascii-identifier-data.js","../data/es5-identifier-names.js":"/../../jshint/data/es5-identifier-names.js","../data/non-ascii-identifier-part-only.js":"/../../jshint/data/non-ascii-identifier-part-only.js","../data/non-ascii-identifier-start.js":"/../../jshint/data/non-ascii-identifier-start.js","./reg.js":"/../../jshint/src/reg.js","./state.js":"/../../jshint/src/state.js","events":"/../node_modules/events/events.js","underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/messages.js":[function(_dereq_,module,exports){
|
||
|
"use strict";
|
||
|
|
||
|
var _ = _dereq_("underscore");
|
||
|
|
||
|
var errors = {
|
||
|
E001: "Bad {a}option: '{b}'.",
|
||
|
E002: "Bad option value.",
|
||
|
E003: "Expected a JSON value.",
|
||
|
E004: "Input is neither a string nor an array of strings.",
|
||
|
E005: "Input is empty.",
|
||
|
E006: "Unexpected early end of program.",
|
||
|
E007: "Missing \"use strict\" statement.",
|
||
|
E008: "Strict violation.",
|
||
|
E009: "Option 'validthis' can't be used in a global scope.",
|
||
|
E010: "'with' is not allowed in strict mode.",
|
||
|
E011: "'{a}' has already been declared.",
|
||
|
E012: "const '{a}' is initialized to 'undefined'.",
|
||
|
E013: "Attempting to override '{a}' which is a constant.",
|
||
|
E014: "A regular expression literal can be confused with '/='.",
|
||
|
E015: "Unclosed regular expression.",
|
||
|
E016: "Invalid regular expression.",
|
||
|
E017: "Unclosed comment.",
|
||
|
E018: "Unbegun comment.",
|
||
|
E019: "Unmatched '{a}'.",
|
||
|
E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
|
||
|
E021: "Expected '{a}' and instead saw '{b}'.",
|
||
|
E022: "Line breaking error '{a}'.",
|
||
|
E023: "Missing '{a}'.",
|
||
|
E024: "Unexpected '{a}'.",
|
||
|
E025: "Missing ':' on a case clause.",
|
||
|
E026: "Missing '}' to match '{' from line {a}.",
|
||
|
E027: "Missing ']' to match '[' from line {a}.",
|
||
|
E028: "Illegal comma.",
|
||
|
E029: "Unclosed string.",
|
||
|
E030: "Expected an identifier and instead saw '{a}'.",
|
||
|
E031: "Bad assignment.", // FIXME: Rephrase
|
||
|
E032: "Expected a small integer or 'false' and instead saw '{a}'.",
|
||
|
E033: "Expected an operator and instead saw '{a}'.",
|
||
|
E034: "get/set are ES5 features.",
|
||
|
E035: "Missing property name.",
|
||
|
E036: "Expected to see a statement and instead saw a block.",
|
||
|
E037: null,
|
||
|
E038: null,
|
||
|
E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.",
|
||
|
E040: "Each value should have its own case label.",
|
||
|
E041: "Unrecoverable syntax error.",
|
||
|
E042: "Stopping.",
|
||
|
E043: "Too many errors.",
|
||
|
E044: null,
|
||
|
E045: "Invalid for each loop.",
|
||
|
E046: "Yield expressions may only occur within generator functions.",
|
||
|
E047: null,
|
||
|
E048: "{a} declaration not directly within block.",
|
||
|
E049: "A {a} cannot be named '{b}'.",
|
||
|
E050: "Mozilla requires the yield expression to be parenthesized here.",
|
||
|
E051: null,
|
||
|
E052: "Unclosed template literal.",
|
||
|
E053: "{a} declarations are only allowed at the top level of module scope.",
|
||
|
E054: "Class properties must be methods. Expected '(' but instead saw '{a}'.",
|
||
|
E055: "The '{a}' option cannot be set after any executable code.",
|
||
|
E056: "'{a}' was used before it was declared, which is illegal for '{b}' variables.",
|
||
|
E057: "Invalid meta property: '{a}.{b}'.",
|
||
|
E058: "Missing semicolon.",
|
||
|
E059: "Incompatible values for the '{a}' and '{b}' linting options.",
|
||
|
E060: "Non-callable values cannot be used as the second operand to instanceof.",
|
||
|
E061: "Invalid position for 'yield' expression (consider wrapping in parenthesis).",
|
||
|
E062: "Rest parameter does not a support default value.",
|
||
|
E063: "Super property may only be used within method bodies.",
|
||
|
E064: "Super call may only be used within class method bodies.",
|
||
|
E065: "Functions defined outside of strict mode with non-simple parameter lists may not " +
|
||
|
"enable strict mode.",
|
||
|
E066: "Asynchronous iteration is only available with for-of loops."
|
||
|
};
|
||
|
|
||
|
var warnings = {
|
||
|
W001: "'hasOwnProperty' is a really bad name.",
|
||
|
W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
|
||
|
W003: "'{a}' was used before it was defined.",
|
||
|
W004: "'{a}' is already defined.",
|
||
|
W005: "A dot following a number can be confused with a decimal point.",
|
||
|
W006: "Confusing minuses.",
|
||
|
W007: "Confusing plusses.",
|
||
|
W008: "A leading decimal point can be confused with a dot: '{a}'.",
|
||
|
W009: "The array literal notation [] is preferable.",
|
||
|
W010: "The object literal notation {} is preferable.",
|
||
|
W011: null,
|
||
|
W012: null,
|
||
|
W013: null,
|
||
|
W014: "Misleading line break before '{a}'; readers may interpret this as an expression boundary.",
|
||
|
W015: null,
|
||
|
W016: "Unexpected use of '{a}'.",
|
||
|
W017: "Bad operand.",
|
||
|
W018: "Confusing use of '{a}'.",
|
||
|
W019: "Use the isNaN function to compare with NaN.",
|
||
|
W020: "Read only.",
|
||
|
W021: "Reassignment of '{a}', which is a {b}. " +
|
||
|
"Use 'var' or 'let' to declare bindings that may change.",
|
||
|
W022: "Do not assign to the exception parameter.",
|
||
|
W023: null,
|
||
|
W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
|
||
|
W025: "Missing name in function declaration.",
|
||
|
W026: "Inner functions should be listed at the top of the outer function.",
|
||
|
W027: "Unreachable '{a}' after '{b}'.",
|
||
|
W028: "Label '{a}' on {b} statement.",
|
||
|
W030: "Expected an assignment or function call and instead saw an expression.",
|
||
|
W031: "Do not use 'new' for side effects.",
|
||
|
W032: "Unnecessary semicolon.",
|
||
|
W033: "Missing semicolon.",
|
||
|
W034: "Unnecessary directive \"{a}\".",
|
||
|
W035: "Empty block.",
|
||
|
W036: "Unexpected /*member '{a}'.",
|
||
|
W037: "'{a}' is a statement label.",
|
||
|
W038: "'{a}' used out of scope.",
|
||
|
W039: null,
|
||
|
W040: "If a strict mode function is executed using function invocation, " +
|
||
|
"its 'this' value will be undefined.",
|
||
|
W041: null,
|
||
|
W042: "Avoid EOL escaping.",
|
||
|
W043: "Bad escaping of EOL. Use option multistr if needed.",
|
||
|
W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */
|
||
|
W045: "Bad number '{a}'.",
|
||
|
W046: "Don't use extra leading zeros '{a}'.",
|
||
|
W047: "A trailing decimal point can be confused with a dot: '{a}'.",
|
||
|
W048: "Unexpected control character in regular expression.",
|
||
|
W049: "Unexpected escaped character '{a}' in regular expression.",
|
||
|
W050: "JavaScript URL.",
|
||
|
W051: "Variables should not be deleted.",
|
||
|
W052: "Unexpected '{a}'.",
|
||
|
W053: "Do not use {a} as a constructor.",
|
||
|
W054: "The Function constructor is a form of eval.",
|
||
|
W055: "A constructor name should start with an uppercase letter.",
|
||
|
W056: "Bad constructor.",
|
||
|
W057: "Weird construction. Is 'new' necessary?",
|
||
|
W058: "Missing '()' invoking a constructor.",
|
||
|
W059: "Avoid arguments.{a}.",
|
||
|
W060: "document.write can be a form of eval.",
|
||
|
W061: "eval can be harmful.",
|
||
|
W062: "Wrap an immediate function invocation in parens " +
|
||
|
"to assist the reader in understanding that the expression " +
|
||
|
"is the result of a function, and not the function itself.",
|
||
|
W063: "Math is not a function.",
|
||
|
W064: "Missing 'new' prefix when invoking a constructor.",
|
||
|
W065: "Missing radix parameter.",
|
||
|
W066: "Implied eval. Consider passing a function instead of a string.",
|
||
|
W067: "Bad invocation.",
|
||
|
W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
|
||
|
W069: "['{a}'] is better written in dot notation.",
|
||
|
W070: "Extra comma. (it breaks older versions of IE)",
|
||
|
W071: "This function has too many statements. ({a})",
|
||
|
W072: "This function has too many parameters. ({a})",
|
||
|
W073: "Blocks are nested too deeply. ({a})",
|
||
|
W074: "This function's cyclomatic complexity is too high. ({a})",
|
||
|
W075: "Duplicate {a} '{b}'.",
|
||
|
W076: "Unexpected parameter '{a}' in get {b} function.",
|
||
|
W077: "Expected a single parameter in set {a} function.",
|
||
|
W078: "Setter is defined without getter.",
|
||
|
W079: "Redefinition of '{a}'.",
|
||
|
W080: "It's not necessary to initialize '{a}' to 'undefined'.",
|
||
|
W081: null,
|
||
|
W082: "Function declarations should not be placed in blocks. " +
|
||
|
"Use a function expression or move the statement to the top of " +
|
||
|
"the outer function.",
|
||
|
W083: "Functions declared within loops referencing an outer scoped " +
|
||
|
"variable may lead to confusing semantics. ({a})",
|
||
|
W084: "Assignment in conditional expression",
|
||
|
W085: "Don't use 'with'.",
|
||
|
W086: "Expected a 'break' statement before '{a}'.",
|
||
|
W087: "Forgotten 'debugger' statement?",
|
||
|
W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.",
|
||
|
W089: "The body of a for in should be wrapped in an if statement to filter " +
|
||
|
"unwanted properties from the prototype.",
|
||
|
W090: "'{a}' is not a statement label.",
|
||
|
W091: null,
|
||
|
W093: "Did you mean to return a conditional instead of an assignment?",
|
||
|
W094: "Unexpected comma.",
|
||
|
W095: "Expected a string and instead saw {a}.",
|
||
|
W096: "The '{a}' key may produce unexpected results.",
|
||
|
W097: "Use the function form of \"use strict\".",
|
||
|
W098: "'{a}' is defined but never used.",
|
||
|
W099: null,
|
||
|
W100: null,
|
||
|
W101: "Line is too long.",
|
||
|
W102: null,
|
||
|
W103: "The '{a}' property is deprecated.",
|
||
|
W104: "'{a}' is available in ES{b} (use 'esversion: {b}') or Mozilla JS extensions (use moz).",
|
||
|
W105: null,
|
||
|
W106: "Identifier '{a}' is not in camel case.",
|
||
|
W107: "Script URL.",
|
||
|
W108: "Strings must use doublequote.",
|
||
|
W109: "Strings must use singlequote.",
|
||
|
W110: "Mixed double and single quotes.",
|
||
|
W112: "Unclosed string.",
|
||
|
W113: "Control character in string: {a}.",
|
||
|
W114: "Avoid {a}.",
|
||
|
W115: "Octal literals are not allowed in strict mode.",
|
||
|
W116: "Expected '{a}' and instead saw '{b}'.",
|
||
|
W117: "'{a}' is not defined.",
|
||
|
W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).",
|
||
|
W119: "'{a}' is only available in ES{b} (use 'esversion: {b}').",
|
||
|
W120: "You might be leaking a variable ({a}) here.",
|
||
|
W121: "Extending prototype of native object: '{a}'.",
|
||
|
W122: "Invalid typeof value '{a}'",
|
||
|
W123: "'{a}' is already defined in outer scope.",
|
||
|
W124: "A generator function should contain at least one yield expression.",
|
||
|
W125: "This line contains non-breaking spaces: http://jshint.com/docs/options/#nonbsp",
|
||
|
W126: "Unnecessary grouping operator.",
|
||
|
W127: "Unexpected use of a comma operator.",
|
||
|
W128: "Empty array elements require elision=true.",
|
||
|
W129: "'{a}' is defined in a future version of JavaScript. Use a " +
|
||
|
"different variable name to avoid migration issues.",
|
||
|
W130: "Invalid element after rest element.",
|
||
|
W131: "Invalid parameter after rest parameter.",
|
||
|
W132: "`var` declarations are forbidden. Use `let` or `const` instead.",
|
||
|
W133: "Invalid for-{a} loop left-hand-side: {b}.",
|
||
|
W134: "The '{a}' option is only available when linting ECMAScript {b} code.",
|
||
|
W135: "{a} may not be supported by non-browser environments.",
|
||
|
W136: "'{a}' must be in function scope.",
|
||
|
W137: "Empty destructuring: this is unnecessary and can be removed.",
|
||
|
W138: "Regular parameters should not come after default parameters.",
|
||
|
W139: "Function expressions should not be used as the second operand to instanceof.",
|
||
|
W140: "Missing comma.",
|
||
|
W141: "Empty {a}: this is unnecessary and can be removed.",
|
||
|
W142: "Empty {a}: consider replacing with `import '{b}';`.",
|
||
|
W143: "Assignment to properties of a mapped arguments object may cause " +
|
||
|
"unexpected changes to formal parameters.",
|
||
|
W144: "'{a}' is a non-standard language feature. Enable it using the '{b}' unstable option.",
|
||
|
W145: "Superfluous 'case' clause.",
|
||
|
W146: "Unnecessary `await` expression.",
|
||
|
W147: "Regular expressions should include the 'u' flag.",
|
||
|
W148: "Unnecessary RegExp 's' flag."
|
||
|
};
|
||
|
|
||
|
var info = {
|
||
|
I001: "Comma warnings can be turned off with 'laxcomma'.",
|
||
|
I002: null,
|
||
|
I003: "ES5 option is now set per default"
|
||
|
};
|
||
|
|
||
|
exports.errors = {};
|
||
|
exports.warnings = {};
|
||
|
exports.info = {};
|
||
|
|
||
|
_.each(errors, function(desc, code) {
|
||
|
exports.errors[code] = { code: code, desc: desc };
|
||
|
});
|
||
|
|
||
|
_.each(warnings, function(desc, code) {
|
||
|
exports.warnings[code] = { code: code, desc: desc };
|
||
|
});
|
||
|
|
||
|
_.each(info, function(desc, code) {
|
||
|
exports.info[code] = { code: code, desc: desc };
|
||
|
});
|
||
|
|
||
|
},{"underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/name-stack.js":[function(_dereq_,module,exports){
|
||
|
"use strict";
|
||
|
|
||
|
function NameStack() {
|
||
|
this._stack = [];
|
||
|
}
|
||
|
|
||
|
Object.defineProperty(NameStack.prototype, "length", {
|
||
|
get: function() {
|
||
|
return this._stack.length;
|
||
|
}
|
||
|
});
|
||
|
NameStack.prototype.push = function() {
|
||
|
this._stack.push(null);
|
||
|
};
|
||
|
NameStack.prototype.pop = function() {
|
||
|
this._stack.pop();
|
||
|
};
|
||
|
NameStack.prototype.set = function(token) {
|
||
|
this._stack[this.length - 1] = token;
|
||
|
};
|
||
|
NameStack.prototype.infer = function() {
|
||
|
var nameToken = this._stack[this.length - 1];
|
||
|
var prefix = "";
|
||
|
var type;
|
||
|
if (!nameToken || nameToken.type === "class") {
|
||
|
nameToken = this._stack[this.length - 2];
|
||
|
}
|
||
|
|
||
|
if (!nameToken) {
|
||
|
return "(empty)";
|
||
|
}
|
||
|
|
||
|
type = nameToken.type;
|
||
|
|
||
|
if (type !== "(string)" && type !== "(number)" && type !== "(identifier)" && type !== "default") {
|
||
|
return "(expression)";
|
||
|
}
|
||
|
|
||
|
if (nameToken.accessorType) {
|
||
|
prefix = nameToken.accessorType + " ";
|
||
|
}
|
||
|
|
||
|
return prefix + nameToken.value;
|
||
|
};
|
||
|
|
||
|
module.exports = NameStack;
|
||
|
|
||
|
},{}],"/../../jshint/src/options.js":[function(_dereq_,module,exports){
|
||
|
"use strict";
|
||
|
exports.bool = {
|
||
|
enforcing: {
|
||
|
bitwise : true,
|
||
|
freeze : true,
|
||
|
camelcase : true,
|
||
|
curly : true,
|
||
|
eqeqeq : true,
|
||
|
futurehostile: true,
|
||
|
es3 : true,
|
||
|
es5 : true,
|
||
|
forin : true,
|
||
|
immed : true,
|
||
|
leanswitch : true,
|
||
|
newcap : true,
|
||
|
noarg : true,
|
||
|
nocomma : true,
|
||
|
noempty : true,
|
||
|
nonbsp : true,
|
||
|
nonew : true,
|
||
|
noreturnawait: true,
|
||
|
regexpu : true,
|
||
|
undef : true,
|
||
|
singleGroups: false,
|
||
|
varstmt: false,
|
||
|
enforceall : false,
|
||
|
trailingcomma: false
|
||
|
},
|
||
|
relaxing: {
|
||
|
asi : true,
|
||
|
multistr : true,
|
||
|
debug : true,
|
||
|
boss : true,
|
||
|
evil : true,
|
||
|
funcscope : true,
|
||
|
globalstrict: true,
|
||
|
iterator : true,
|
||
|
notypeof : true,
|
||
|
plusplus : true,
|
||
|
proto : true,
|
||
|
scripturl : true,
|
||
|
sub : true,
|
||
|
supernew : true,
|
||
|
laxbreak : true,
|
||
|
laxcomma : true,
|
||
|
validthis : true,
|
||
|
withstmt : true,
|
||
|
moz : true,
|
||
|
noyield : true,
|
||
|
eqnull : true,
|
||
|
lastsemic : true,
|
||
|
loopfunc : true,
|
||
|
expr : true,
|
||
|
esnext : true,
|
||
|
elision : true,
|
||
|
},
|
||
|
environments: {
|
||
|
mootools : true,
|
||
|
couch : true,
|
||
|
jasmine : true,
|
||
|
jquery : true,
|
||
|
node : true,
|
||
|
qunit : true,
|
||
|
rhino : true,
|
||
|
shelljs : true,
|
||
|
prototypejs : true,
|
||
|
yui : true,
|
||
|
mocha : true,
|
||
|
module : true,
|
||
|
wsh : true,
|
||
|
worker : true,
|
||
|
nonstandard : true,
|
||
|
browser : true,
|
||
|
browserify : true,
|
||
|
devel : true,
|
||
|
dojo : true,
|
||
|
typed : true,
|
||
|
phantom : true
|
||
|
},
|
||
|
obsolete: {
|
||
|
onecase : true, // if one case switch statements should be allowed
|
||
|
regexp : true, // if the . should not be allowed in regexp literals
|
||
|
regexdash : true // if unescaped first/last dash (-) inside brackets
|
||
|
}
|
||
|
};
|
||
|
exports.val = {
|
||
|
maxlen : false,
|
||
|
indent : false,
|
||
|
maxerr : false,
|
||
|
predef : false,
|
||
|
globals : false,
|
||
|
quotmark : false,
|
||
|
|
||
|
scope : false,
|
||
|
maxstatements: false,
|
||
|
maxdepth : false,
|
||
|
maxparams : false,
|
||
|
maxcomplexity: false,
|
||
|
shadow : false,
|
||
|
strict : true,
|
||
|
unused : true,
|
||
|
latedef : false,
|
||
|
|
||
|
ignore : false, // start/end ignoring lines of code, bypassing the lexer
|
||
|
|
||
|
ignoreDelimiters: false, // array of start/end delimiters used to ignore
|
||
|
esversion: 5
|
||
|
};
|
||
|
exports.unstable = {
|
||
|
bigint: true
|
||
|
};
|
||
|
exports.inverted = {
|
||
|
bitwise : true,
|
||
|
forin : true,
|
||
|
newcap : true,
|
||
|
plusplus: true,
|
||
|
regexp : true,
|
||
|
undef : true,
|
||
|
eqeqeq : true,
|
||
|
strict : true
|
||
|
};
|
||
|
|
||
|
exports.validNames = Object.keys(exports.val)
|
||
|
.concat(Object.keys(exports.bool.relaxing))
|
||
|
.concat(Object.keys(exports.bool.enforcing))
|
||
|
.concat(Object.keys(exports.bool.obsolete))
|
||
|
.concat(Object.keys(exports.bool.environments))
|
||
|
.concat(["unstable"]);
|
||
|
|
||
|
exports.unstableNames = Object.keys(exports.unstable);
|
||
|
exports.renamed = {
|
||
|
eqeq : "eqeqeq",
|
||
|
windows: "wsh",
|
||
|
sloppy : "strict"
|
||
|
};
|
||
|
|
||
|
exports.removed = {
|
||
|
nomen: true,
|
||
|
onevar: true,
|
||
|
passfail: true,
|
||
|
white: true,
|
||
|
gcl: true,
|
||
|
smarttabs: true,
|
||
|
trailing: true
|
||
|
};
|
||
|
exports.noenforceall = {
|
||
|
varstmt: true,
|
||
|
strict: true,
|
||
|
regexpu: true
|
||
|
};
|
||
|
|
||
|
},{}],"/../../jshint/src/prod-params.js":[function(_dereq_,module,exports){
|
||
|
module.exports = {
|
||
|
export: 1,
|
||
|
noin: 2,
|
||
|
initial: 4,
|
||
|
|
||
|
preAsync: 8,
|
||
|
|
||
|
async: 16,
|
||
|
tryClause: 32,
|
||
|
yield: 64
|
||
|
};
|
||
|
|
||
|
},{}],"/../../jshint/src/reg.js":[function(_dereq_,module,exports){
|
||
|
|
||
|
"use strict";
|
||
|
exports.unsafeString =
|
||
|
/@cc|<\/?|script|\]\s*\]|<\s*!|</i;
|
||
|
exports.needEsc =
|
||
|
/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
|
||
|
|
||
|
exports.needEscGlobal =
|
||
|
/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||
|
exports.starSlash = /\*\//;
|
||
|
exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
|
||
|
exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
|
||
|
exports.fallsThrough = /^\s*falls?\sthrough\s*$/;
|
||
|
exports.maxlenException = /^(?:(?:\/\/|\/\*|\*) ?)?[^ ]+$/;
|
||
|
exports.whitespace = /[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/;
|
||
|
|
||
|
exports.nonzeroDigit = /^[1-9]$/;
|
||
|
|
||
|
exports.decimalDigit = /^[0-9]$/;
|
||
|
|
||
|
exports.regexpSyntaxChars = /[\^$\\.*+?()[\]{}|]/;
|
||
|
|
||
|
exports.regexpQuantifiers = /[*+?{]/;
|
||
|
|
||
|
exports.regexpControlEscapes = /[fnrtv]/;
|
||
|
|
||
|
exports.regexpCharClasses = /[dDsSwW]/;
|
||
|
exports.regexpDot = /(^|[^\\])(\\\\)*\./;
|
||
|
|
||
|
},{}],"/../../jshint/src/scope-manager.js":[function(_dereq_,module,exports){
|
||
|
"use strict";
|
||
|
|
||
|
var _ = _dereq_("underscore");
|
||
|
_.slice = _dereq_("lodash.slice");
|
||
|
var events = _dereq_("events");
|
||
|
var marker = {};
|
||
|
var scopeManager = function(state, predefined, exported, declared) {
|
||
|
|
||
|
var _current;
|
||
|
var _scopeStack = [];
|
||
|
|
||
|
function _newScope(type) {
|
||
|
_current = {
|
||
|
"(bindings)": Object.create(null),
|
||
|
"(usages)": Object.create(null),
|
||
|
"(labels)": Object.create(null),
|
||
|
"(parent)": _current,
|
||
|
"(type)": type,
|
||
|
"(params)": (type === "functionparams" || type === "catchparams") ? [] : null
|
||
|
};
|
||
|
_scopeStack.push(_current);
|
||
|
}
|
||
|
|
||
|
_newScope("global");
|
||
|
_current["(predefined)"] = predefined;
|
||
|
|
||
|
var _currentFunctBody = _current; // this is the block after the params = function
|
||
|
|
||
|
var usedPredefinedAndGlobals = Object.create(null);
|
||
|
var impliedGlobals = Object.create(null);
|
||
|
var unuseds = [];
|
||
|
var emitter = new events.EventEmitter();
|
||
|
|
||
|
function warning(code, token) {
|
||
|
emitter.emit("warning", {
|
||
|
code: code,
|
||
|
token: token,
|
||
|
data: _.slice(arguments, 2)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function error(code, token) {
|
||
|
emitter.emit("warning", {
|
||
|
code: code,
|
||
|
token: token,
|
||
|
data: _.slice(arguments, 2)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function _setupUsages(bindingName) {
|
||
|
if (!_current["(usages)"][bindingName]) {
|
||
|
_current["(usages)"][bindingName] = {
|
||
|
"(modified)": [],
|
||
|
"(reassigned)": [],
|
||
|
"(tokens)": []
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var _getUnusedOption = function(unused_opt) {
|
||
|
if (unused_opt === undefined) {
|
||
|
unused_opt = state.option.unused;
|
||
|
}
|
||
|
|
||
|
if (unused_opt === true) {
|
||
|
unused_opt = "last-param";
|
||
|
}
|
||
|
|
||
|
return unused_opt;
|
||
|
};
|
||
|
|
||
|
var _warnUnused = function(name, tkn, type, unused_opt) {
|
||
|
var line = tkn.line;
|
||
|
var chr = tkn.from;
|
||
|
var raw_name = tkn.raw_text || name;
|
||
|
|
||
|
unused_opt = _getUnusedOption(unused_opt);
|
||
|
|
||
|
var warnable_types = {
|
||
|
"vars": ["var"],
|
||
|
"last-param": ["var", "param"],
|
||
|
"strict": ["var", "param", "last-param"]
|
||
|
};
|
||
|
|
||
|
if (unused_opt) {
|
||
|
if (warnable_types[unused_opt] && warnable_types[unused_opt].indexOf(type) !== -1) {
|
||
|
warning("W098", { line: line, from: chr }, raw_name);
|
||
|
}
|
||
|
}
|
||
|
if (unused_opt || type === "var") {
|
||
|
unuseds.push({
|
||
|
name: name,
|
||
|
line: line,
|
||
|
character: chr
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
function _checkForUnused() {
|
||
|
if (_current["(type)"] === "functionparams") {
|
||
|
_checkParams();
|
||
|
return;
|
||
|
}
|
||
|
var currentBindings = _current["(bindings)"];
|
||
|
for (var bindingName in currentBindings) {
|
||
|
if (currentBindings[bindingName]["(type)"] !== "exception" &&
|
||
|
currentBindings[bindingName]["(unused)"]) {
|
||
|
_warnUnused(bindingName, currentBindings[bindingName]["(token)"], "var");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function _checkParams() {
|
||
|
var params = _current["(params)"];
|
||
|
|
||
|
if (!params) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var param = params.pop();
|
||
|
var unused_opt;
|
||
|
|
||
|
while (param) {
|
||
|
var binding = _current["(bindings)"][param];
|
||
|
|
||
|
unused_opt = _getUnusedOption(state.funct["(unusedOption)"]);
|
||
|
if (param === "undefined")
|
||
|
return;
|
||
|
|
||
|
if (binding["(unused)"]) {
|
||
|
_warnUnused(param, binding["(token)"], "param", state.funct["(unusedOption)"]);
|
||
|
} else if (unused_opt === "last-param") {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
param = params.pop();
|
||
|
}
|
||
|
}
|
||
|
function _getBinding(bindingName) {
|
||
|
for (var i = _scopeStack.length - 1 ; i >= 0; --i) {
|
||
|
var scopeBindings = _scopeStack[i]["(bindings)"];
|
||
|
if (scopeBindings[bindingName]) {
|
||
|
return scopeBindings;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function usedSoFarInCurrentFunction(bindingName) {
|
||
|
for (var i = _scopeStack.length - 1; i >= 0; i--) {
|
||
|
var current = _scopeStack[i];
|
||
|
if (current["(usages)"][bindingName]) {
|
||
|
return current["(usages)"][bindingName];
|
||
|
}
|
||
|
if (current === _currentFunctBody) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
function _checkOuterShadow(bindingName, token) {
|
||
|
if (state.option.shadow !== "outer") {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var isGlobal = _currentFunctBody["(type)"] === "global",
|
||
|
isNewFunction = _current["(type)"] === "functionparams";
|
||
|
|
||
|
var outsideCurrentFunction = !isGlobal;
|
||
|
for (var i = 0; i < _scopeStack.length; i++) {
|
||
|
var stackItem = _scopeStack[i];
|
||
|
|
||
|
if (!isNewFunction && _scopeStack[i + 1] === _currentFunctBody) {
|
||
|
outsideCurrentFunction = false;
|
||
|
}
|
||
|
if (outsideCurrentFunction && stackItem["(bindings)"][bindingName]) {
|
||
|
warning("W123", token, bindingName);
|
||
|
}
|
||
|
if (stackItem["(labels)"][bindingName]) {
|
||
|
warning("W123", token, bindingName);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function _latedefWarning(type, bindingName, token) {
|
||
|
var isFunction;
|
||
|
|
||
|
if (state.option.latedef) {
|
||
|
isFunction = type === "function" || type === "generator function" ||
|
||
|
type === "async function";
|
||
|
if ((state.option.latedef === true && isFunction) || !isFunction) {
|
||
|
warning("W003", token, bindingName);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var scopeManagerInst = {
|
||
|
|
||
|
on: function(names, listener) {
|
||
|
names.split(" ").forEach(function(name) {
|
||
|
emitter.on(name, listener);
|
||
|
});
|
||
|
},
|
||
|
|
||
|
isPredefined: function(bindingName) {
|
||
|
return !this.has(bindingName) && _.has(_scopeStack[0]["(predefined)"], bindingName);
|
||
|
},
|
||
|
stack: function(type) {
|
||
|
var previousScope = _current;
|
||
|
_newScope(type);
|
||
|
|
||
|
if (!type && previousScope["(type)"] === "functionparams") {
|
||
|
|
||
|
_current["(isFuncBody)"] = true;
|
||
|
_currentFunctBody = _current;
|
||
|
}
|
||
|
},
|
||
|
unstack: function() {
|
||
|
var subScope = _scopeStack.length > 1 ? _scopeStack[_scopeStack.length - 2] : null;
|
||
|
var isUnstackingFunctionBody = _current === _currentFunctBody,
|
||
|
isUnstackingFunctionParams = _current["(type)"] === "functionparams",
|
||
|
isUnstackingFunctionOuter = _current["(type)"] === "functionouter";
|
||
|
|
||
|
var i, j, isImmutable, isFunction;
|
||
|
var currentUsages = _current["(usages)"];
|
||
|
var currentBindings = _current["(bindings)"];
|
||
|
var usedBindingNameList = Object.keys(currentUsages);
|
||
|
if (currentUsages.__proto__ && usedBindingNameList.indexOf("__proto__") === -1) {
|
||
|
usedBindingNameList.push("__proto__");
|
||
|
}
|
||
|
|
||
|
for (i = 0; i < usedBindingNameList.length; i++) {
|
||
|
var usedBindingName = usedBindingNameList[i];
|
||
|
|
||
|
var usage = currentUsages[usedBindingName];
|
||
|
var usedBinding = currentBindings[usedBindingName];
|
||
|
if (usedBinding) {
|
||
|
var usedBindingType = usedBinding["(type)"];
|
||
|
isImmutable = usedBindingType === "const" || usedBindingType === "import";
|
||
|
|
||
|
if (usedBinding["(useOutsideOfScope)"] && !state.option.funcscope) {
|
||
|
var usedTokens = usage["(tokens)"];
|
||
|
for (j = 0; j < usedTokens.length; j++) {
|
||
|
if (usedBinding["(function)"] === usedTokens[j]["(function)"]) {
|
||
|
error("W038", usedTokens[j], usedBindingName);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
_current["(bindings)"][usedBindingName]["(unused)"] = false;
|
||
|
if (isImmutable && usage["(modified)"]) {
|
||
|
for (j = 0; j < usage["(modified)"].length; j++) {
|
||
|
error("E013", usage["(modified)"][j], usedBindingName);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
isFunction = usedBindingType === "function" ||
|
||
|
usedBindingType === "generator function" ||
|
||
|
usedBindingType === "async function";
|
||
|
if ((isFunction || usedBindingType === "class") && usage["(reassigned)"]) {
|
||
|
for (j = 0; j < usage["(reassigned)"].length; j++) {
|
||
|
if (!usage["(reassigned)"][j].ignoreW021) {
|
||
|
warning("W021", usage["(reassigned)"][j], usedBindingName, usedBindingType);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (subScope) {
|
||
|
var bindingType = this.bindingtype(usedBindingName);
|
||
|
isImmutable = bindingType === "const" ||
|
||
|
(bindingType === null && _scopeStack[0]["(predefined)"][usedBindingName] === false);
|
||
|
if (isUnstackingFunctionOuter && !isImmutable) {
|
||
|
if (!state.funct["(outerMutables)"]) {
|
||
|
state.funct["(outerMutables)"] = [];
|
||
|
}
|
||
|
state.funct["(outerMutables)"].push(usedBindingName);
|
||
|
}
|
||
|
if (!subScope["(usages)"][usedBindingName]) {
|
||
|
subScope["(usages)"][usedBindingName] = usage;
|
||
|
if (isUnstackingFunctionBody) {
|
||
|
subScope["(usages)"][usedBindingName]["(onlyUsedSubFunction)"] = true;
|
||
|
}
|
||
|
} else {
|
||
|
var subScopeUsage = subScope["(usages)"][usedBindingName];
|
||
|
subScopeUsage["(modified)"] = subScopeUsage["(modified)"].concat(usage["(modified)"]);
|
||
|
subScopeUsage["(tokens)"] = subScopeUsage["(tokens)"].concat(usage["(tokens)"]);
|
||
|
subScopeUsage["(reassigned)"] =
|
||
|
subScopeUsage["(reassigned)"].concat(usage["(reassigned)"]);
|
||
|
}
|
||
|
} else {
|
||
|
if (typeof _current["(predefined)"][usedBindingName] === "boolean") {
|
||
|
delete declared[usedBindingName];
|
||
|
usedPredefinedAndGlobals[usedBindingName] = marker;
|
||
|
if (_current["(predefined)"][usedBindingName] === false && usage["(reassigned)"]) {
|
||
|
for (j = 0; j < usage["(reassigned)"].length; j++) {
|
||
|
if (!usage["(reassigned)"][j].ignoreW020) {
|
||
|
warning("W020", usage["(reassigned)"][j]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
for (j = 0; j < usage["(tokens)"].length; j++) {
|
||
|
var undefinedToken = usage["(tokens)"][j];
|
||
|
if (!undefinedToken.forgiveUndef) {
|
||
|
if (state.option.undef && !undefinedToken.ignoreUndef) {
|
||
|
warning("W117", undefinedToken, usedBindingName);
|
||
|
}
|
||
|
if (impliedGlobals[usedBindingName]) {
|
||
|
impliedGlobals[usedBindingName].line.push(undefinedToken.line);
|
||
|
} else {
|
||
|
impliedGlobals[usedBindingName] = {
|
||
|
name: usedBindingName,
|
||
|
line: [undefinedToken.line]
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (!subScope) {
|
||
|
Object.keys(declared)
|
||
|
.forEach(function(bindingNotUsed) {
|
||
|
_warnUnused(bindingNotUsed, declared[bindingNotUsed], "var");
|
||
|
});
|
||
|
}
|
||
|
if (subScope && !isUnstackingFunctionBody &&
|
||
|
!isUnstackingFunctionParams && !isUnstackingFunctionOuter) {
|
||
|
var bindingNames = Object.keys(currentBindings);
|
||
|
for (i = 0; i < bindingNames.length; i++) {
|
||
|
|
||
|
var defBindingName = bindingNames[i];
|
||
|
var defBinding = currentBindings[defBindingName];
|
||
|
|
||
|
if (!defBinding["(blockscoped)"] && defBinding["(type)"] !== "exception") {
|
||
|
var shadowed = subScope["(bindings)"][defBindingName];
|
||
|
if (shadowed) {
|
||
|
shadowed["(unused)"] &= defBinding["(unused)"];
|
||
|
} else {
|
||
|
defBinding["(useOutsideOfScope)"] =
|
||
|
_currentFunctBody["(type)"] !== "global" &&
|
||
|
!this.funct.has(defBindingName, { excludeCurrent: true });
|
||
|
|
||
|
subScope["(bindings)"][defBindingName] = defBinding;
|
||
|
}
|
||
|
|
||
|
delete currentBindings[defBindingName];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
_checkForUnused();
|
||
|
|
||
|
_scopeStack.pop();
|
||
|
if (isUnstackingFunctionBody) {
|
||
|
_currentFunctBody = _scopeStack[_.findLastIndex(_scopeStack, function(scope) {
|
||
|
return scope["(isFuncBody)"] || scope["(type)"] === "global";
|
||
|
})];
|
||
|
}
|
||
|
|
||
|
_current = subScope;
|
||
|
},
|
||
|
addParam: function(bindingName, token, type) {
|
||
|
type = type || "param";
|
||
|
|
||
|
if (type === "exception") {
|
||
|
var previouslyDefinedBindingType = this.funct.bindingtype(bindingName);
|
||
|
if (previouslyDefinedBindingType && previouslyDefinedBindingType !== "exception") {
|
||
|
if (!state.option.node) {
|
||
|
warning("W002", state.tokens.next, bindingName);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (state.isStrict() && (bindingName === "arguments" || bindingName === "eval")) {
|
||
|
warning("E008", token);
|
||
|
}
|
||
|
}
|
||
|
if (_.has(_current["(bindings)"], bindingName)) {
|
||
|
_current["(bindings)"][bindingName].duplicated = true;
|
||
|
} else {
|
||
|
_checkOuterShadow(bindingName, token);
|
||
|
|
||
|
_current["(bindings)"][bindingName] = {
|
||
|
"(type)" : type,
|
||
|
"(token)": token,
|
||
|
"(unused)": true };
|
||
|
|
||
|
_current["(params)"].push(bindingName);
|
||
|
}
|
||
|
|
||
|
if (_.has(_current["(usages)"], bindingName)) {
|
||
|
var usage = _current["(usages)"][bindingName];
|
||
|
if (usage["(onlyUsedSubFunction)"]) {
|
||
|
_latedefWarning(type, bindingName, token);
|
||
|
} else {
|
||
|
warning("E056", token, bindingName, type);
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
validateParams: function(isArrow) {
|
||
|
var isStrict = state.isStrict();
|
||
|
var currentFunctParamScope = _currentFunctBody["(parent)"];
|
||
|
var isSimple = state.funct['(hasSimpleParams)'];
|
||
|
var isMethod = state.funct["(method)"];
|
||
|
|
||
|
if (!currentFunctParamScope["(params)"]) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
currentFunctParamScope["(params)"].forEach(function(bindingName) {
|
||
|
var binding = currentFunctParamScope["(bindings)"][bindingName];
|
||
|
|
||
|
if (binding.duplicated) {
|
||
|
if (isStrict || isArrow || isMethod || !isSimple) {
|
||
|
warning("E011", binding["(token)"], bindingName);
|
||
|
} else if (state.option.shadow !== true) {
|
||
|
warning("W004", binding["(token)"], bindingName);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (isStrict && (bindingName === "arguments" || bindingName === "eval")) {
|
||
|
warning("E008", binding["(token)"]);
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
|
||
|
getUsedOrDefinedGlobals: function() {
|
||
|
var list = Object.keys(usedPredefinedAndGlobals);
|
||
|
if (usedPredefinedAndGlobals.__proto__ === marker &&
|
||
|
list.indexOf("__proto__") === -1) {
|
||
|
list.push("__proto__");
|
||
|
}
|
||
|
|
||
|
return list;
|
||
|
},
|
||
|
getImpliedGlobals: function() {
|
||
|
var values = _.values(impliedGlobals);
|
||
|
var hasProto = false;
|
||
|
if (impliedGlobals.__proto__) {
|
||
|
hasProto = values.some(function(value) {
|
||
|
return value.name === "__proto__";
|
||
|
});
|
||
|
if (!hasProto) {
|
||
|
values.push(impliedGlobals.__proto__);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return values;
|
||
|
},
|
||
|
getUnuseds: function() {
|
||
|
return unuseds;
|
||
|
},
|
||
|
has: function(bindingName) {
|
||
|
return Boolean(_getBinding(bindingName));
|
||
|
},
|
||
|
bindingtype: function(bindingName) {
|
||
|
var scopeBindings = _getBinding(bindingName);
|
||
|
if (scopeBindings) {
|
||
|
return scopeBindings[bindingName]["(type)"];
|
||
|
}
|
||
|
return null;
|
||
|
},
|
||
|
addExported: function(bindingName) {
|
||
|
var globalBindings = _scopeStack[0]["(bindings)"];
|
||
|
if (_.has(declared, bindingName)) {
|
||
|
delete declared[bindingName];
|
||
|
} else if (_.has(globalBindings, bindingName)) {
|
||
|
globalBindings[bindingName]["(unused)"] = false;
|
||
|
} else {
|
||
|
for (var i = 1; i < _scopeStack.length; i++) {
|
||
|
var scope = _scopeStack[i];
|
||
|
if (!scope["(type)"]) {
|
||
|
if (_.has(scope["(bindings)"], bindingName) &&
|
||
|
!scope["(bindings)"][bindingName]["(blockscoped)"]) {
|
||
|
scope["(bindings)"][bindingName]["(unused)"] = false;
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
exported[bindingName] = true;
|
||
|
}
|
||
|
},
|
||
|
setExported: function(bindingName, token) {
|
||
|
this.block.use(bindingName, token);
|
||
|
},
|
||
|
initialize: function(bindingName) {
|
||
|
if (_current["(bindings)"][bindingName]) {
|
||
|
_current["(bindings)"][bindingName]["(initialized)"] = true;
|
||
|
}
|
||
|
},
|
||
|
addbinding: function(bindingName, opts) {
|
||
|
|
||
|
var type = opts.type;
|
||
|
var token = opts.token;
|
||
|
var isblockscoped = type === "let" || type === "const" ||
|
||
|
type === "class" || type === "import" || type === "generator function" ||
|
||
|
type === "async function" || type === "async generator function";
|
||
|
var ishoisted = type === "function" || type === "generator function" ||
|
||
|
type === "async function" || type === "import";
|
||
|
var isexported = (isblockscoped ? _current : _currentFunctBody)["(type)"] === "global" &&
|
||
|
_.has(exported, bindingName);
|
||
|
_checkOuterShadow(bindingName, token);
|
||
|
|
||
|
if (state.isStrict() && (bindingName === "arguments" || bindingName === "eval")) {
|
||
|
warning("E008", token);
|
||
|
}
|
||
|
|
||
|
if (isblockscoped) {
|
||
|
|
||
|
var declaredInCurrentScope = _current["(bindings)"][bindingName];
|
||
|
if (!declaredInCurrentScope && _current === _currentFunctBody &&
|
||
|
_current["(type)"] !== "global") {
|
||
|
declaredInCurrentScope = !!_currentFunctBody["(parent)"]["(bindings)"][bindingName];
|
||
|
}
|
||
|
if (!declaredInCurrentScope && _current["(usages)"][bindingName]) {
|
||
|
var usage = _current["(usages)"][bindingName];
|
||
|
if (usage["(onlyUsedSubFunction)"] || ishoisted) {
|
||
|
_latedefWarning(type, bindingName, token);
|
||
|
} else if (!ishoisted) {
|
||
|
warning("E056", token, bindingName, type);
|
||
|
}
|
||
|
}
|
||
|
if (declaredInCurrentScope &&
|
||
|
(!ishoisted || (_current["(type)"] !== "global" || type === "import"))) {
|
||
|
warning("E011", token, bindingName);
|
||
|
}
|
||
|
else if (state.option.shadow === "outer") {
|
||
|
if (scopeManagerInst.funct.has(bindingName)) {
|
||
|
warning("W004", token, bindingName);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
scopeManagerInst.block.add(
|
||
|
bindingName, type, token, !isexported, opts.initialized
|
||
|
);
|
||
|
|
||
|
} else {
|
||
|
|
||
|
var declaredInCurrentFunctionScope = scopeManagerInst.funct.has(bindingName);
|
||
|
if (!declaredInCurrentFunctionScope && usedSoFarInCurrentFunction(bindingName)) {
|
||
|
_latedefWarning(type, bindingName, token);
|
||
|
}
|
||
|
if (scopeManagerInst.funct.has(bindingName, { onlyBlockscoped: true })) {
|
||
|
warning("E011", token, bindingName);
|
||
|
} else if (state.option.shadow !== true) {
|
||
|
if (declaredInCurrentFunctionScope && bindingName !== "__proto__") {
|
||
|
if (_currentFunctBody["(type)"] !== "global") {
|
||
|
warning("W004", token, bindingName);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
scopeManagerInst.funct.add(bindingName, type, token, !isexported);
|
||
|
|
||
|
if (_currentFunctBody["(type)"] === "global" && !state.impliedClosure()) {
|
||
|
usedPredefinedAndGlobals[bindingName] = marker;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
funct: {
|
||
|
bindingtype: function(bindingName, options) {
|
||
|
var onlyBlockscoped = options && options.onlyBlockscoped;
|
||
|
var excludeParams = options && options.excludeParams;
|
||
|
var currentScopeIndex = _scopeStack.length - (options && options.excludeCurrent ? 2 : 1);
|
||
|
for (var i = currentScopeIndex; i >= 0; i--) {
|
||
|
var current = _scopeStack[i];
|
||
|
if (current["(bindings)"][bindingName] &&
|
||
|
(!onlyBlockscoped || current["(bindings)"][bindingName]["(blockscoped)"])) {
|
||
|
return current["(bindings)"][bindingName]["(type)"];
|
||
|
}
|
||
|
var scopeCheck = excludeParams ? _scopeStack[ i - 1 ] : current;
|
||
|
if (scopeCheck && scopeCheck["(type)"] === "functionparams") {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
},
|
||
|
hasLabel: function(labelName) {
|
||
|
for (var i = _scopeStack.length - 1; i >= 0; i--) {
|
||
|
var current = _scopeStack[i];
|
||
|
|
||
|
if (current["(labels)"][labelName]) {
|
||
|
return true;
|
||
|
}
|
||
|
if (current["(type)"] === "functionparams") {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
},
|
||
|
has: function(bindingName, options) {
|
||
|
return Boolean(this.bindingtype(bindingName, options));
|
||
|
},
|
||
|
add: function(bindingName, type, tok, unused) {
|
||
|
_current["(bindings)"][bindingName] = {
|
||
|
"(type)" : type,
|
||
|
"(token)": tok,
|
||
|
"(blockscoped)": false,
|
||
|
"(function)": _currentFunctBody,
|
||
|
"(unused)": unused };
|
||
|
}
|
||
|
},
|
||
|
|
||
|
block: {
|
||
|
isGlobal: function() {
|
||
|
return _current["(type)"] === "global";
|
||
|
},
|
||
|
use: function(bindingName, token) {
|
||
|
var paramScope = _currentFunctBody["(parent)"];
|
||
|
if (paramScope && paramScope["(bindings)"][bindingName] &&
|
||
|
paramScope["(bindings)"][bindingName]["(type)"] === "param") {
|
||
|
if (!scopeManagerInst.funct.has(bindingName,
|
||
|
{ excludeParams: true, onlyBlockscoped: true })) {
|
||
|
paramScope["(bindings)"][bindingName]["(unused)"] = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (token && (state.ignored.W117 || state.option.undef === false)) {
|
||
|
token.ignoreUndef = true;
|
||
|
}
|
||
|
|
||
|
_setupUsages(bindingName);
|
||
|
|
||
|
_current["(usages)"][bindingName]["(onlyUsedSubFunction)"] = false;
|
||
|
|
||
|
if (token) {
|
||
|
token["(function)"] = _currentFunctBody;
|
||
|
_current["(usages)"][bindingName]["(tokens)"].push(token);
|
||
|
}
|
||
|
var binding = _current["(bindings)"][bindingName];
|
||
|
if (binding && binding["(blockscoped)"] && !binding["(initialized)"]) {
|
||
|
error("E056", token, bindingName, binding["(type)"]);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
reassign: function(bindingName, token) {
|
||
|
token.ignoreW020 = state.ignored.W020;
|
||
|
token.ignoreW021 = state.ignored.W021;
|
||
|
|
||
|
this.modify(bindingName, token);
|
||
|
|
||
|
_current["(usages)"][bindingName]["(reassigned)"].push(token);
|
||
|
},
|
||
|
|
||
|
modify: function(bindingName, token) {
|
||
|
|
||
|
_setupUsages(bindingName);
|
||
|
|
||
|
_current["(usages)"][bindingName]["(onlyUsedSubFunction)"] = false;
|
||
|
_current["(usages)"][bindingName]["(modified)"].push(token);
|
||
|
},
|
||
|
add: function(bindingName, type, tok, unused, initialized) {
|
||
|
_current["(bindings)"][bindingName] = {
|
||
|
"(type)" : type,
|
||
|
"(token)": tok,
|
||
|
"(initialized)": !!initialized,
|
||
|
"(blockscoped)": true,
|
||
|
"(unused)": unused };
|
||
|
},
|
||
|
|
||
|
addLabel: function(labelName, opts) {
|
||
|
var token = opts.token;
|
||
|
if (scopeManagerInst.funct.hasLabel(labelName)) {
|
||
|
warning("E011", token, labelName);
|
||
|
}
|
||
|
else if (state.option.shadow === "outer") {
|
||
|
if (scopeManagerInst.funct.has(labelName)) {
|
||
|
warning("W004", token, labelName);
|
||
|
} else {
|
||
|
_checkOuterShadow(labelName, token);
|
||
|
}
|
||
|
}
|
||
|
_current["(labels)"][labelName] = token;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
return scopeManagerInst;
|
||
|
};
|
||
|
|
||
|
module.exports = scopeManager;
|
||
|
|
||
|
},{"events":"/../node_modules/events/events.js","lodash.slice":"/../../jshint/node_modules/lodash.slice/index.js","underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/state.js":[function(_dereq_,module,exports){
|
||
|
"use strict";
|
||
|
var NameStack = _dereq_("./name-stack.js");
|
||
|
|
||
|
var state = {
|
||
|
syntax: {},
|
||
|
isStrict: function() {
|
||
|
return this.directive["use strict"] || this.inClassBody ||
|
||
|
this.option.module || this.option.strict === "implied";
|
||
|
},
|
||
|
stmtMissingStrict: function() {
|
||
|
if (this.option.strict === "global") {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (this.option.strict === false) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (this.option.globalstrict) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
},
|
||
|
|
||
|
allowsGlobalUsd: function() {
|
||
|
return this.option.strict === "global" || this.option.globalstrict ||
|
||
|
this.option.module || this.impliedClosure();
|
||
|
},
|
||
|
impliedClosure: function() {
|
||
|
return this.option.node || this.option.phantom || this.option.browserify;
|
||
|
},
|
||
|
|
||
|
inMoz: function() {
|
||
|
return this.option.moz;
|
||
|
},
|
||
|
inES10: function() {
|
||
|
return this.esVersion >= 10;
|
||
|
},
|
||
|
inES9: function() {
|
||
|
return this.esVersion >= 9;
|
||
|
},
|
||
|
inES8: function() {
|
||
|
return this.esVersion >= 8;
|
||
|
},
|
||
|
inES7: function() {
|
||
|
return this.esVersion >= 7;
|
||
|
},
|
||
|
inES6: function(strict) {
|
||
|
if (!strict && this.option.moz) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return this.esVersion >= 6;
|
||
|
},
|
||
|
inES5: function() {
|
||
|
return !this.esVersion || this.esVersion >= 5 || this.option.moz;
|
||
|
},
|
||
|
inferEsVersion: function() {
|
||
|
var badOpt = null;
|
||
|
|
||
|
if (this.option.esversion) {
|
||
|
if (this.option.es3) {
|
||
|
badOpt = "es3";
|
||
|
} else if (this.option.es5) {
|
||
|
badOpt = "es5";
|
||
|
} else if (this.option.esnext) {
|
||
|
badOpt = "esnext";
|
||
|
}
|
||
|
|
||
|
if (badOpt) {
|
||
|
return badOpt;
|
||
|
}
|
||
|
|
||
|
if (this.option.esversion === 2015) {
|
||
|
this.esVersion = 6;
|
||
|
} else {
|
||
|
this.esVersion = this.option.esversion;
|
||
|
}
|
||
|
} else if (this.option.es3) {
|
||
|
this.esVersion = 3;
|
||
|
} else if (this.option.esnext) {
|
||
|
this.esVersion = 6;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
},
|
||
|
|
||
|
reset: function() {
|
||
|
this.tokens = {
|
||
|
prev: null,
|
||
|
next: null,
|
||
|
curr: null
|
||
|
};
|
||
|
|
||
|
this.option = { unstable: {} };
|
||
|
this.esVersion = 5;
|
||
|
this.funct = null;
|
||
|
this.ignored = {};
|
||
|
this.directive = Object.create(null);
|
||
|
this.jsonMode = false;
|
||
|
this.lines = [];
|
||
|
this.tab = "";
|
||
|
this.cache = {}; // Node.JS doesn't have Map. Sniff.
|
||
|
this.ignoredLines = {};
|
||
|
this.forinifcheckneeded = false;
|
||
|
this.nameStack = new NameStack();
|
||
|
this.inClassBody = false;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
exports.state = state;
|
||
|
|
||
|
},{"./name-stack.js":"/../../jshint/src/name-stack.js"}],"/../../jshint/src/style.js":[function(_dereq_,module,exports){
|
||
|
"use strict";
|
||
|
|
||
|
exports.register = function(linter) {
|
||
|
|
||
|
linter.on("Identifier", function style_scanProto(data) {
|
||
|
if (linter.getOption("proto")) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (data.name === "__proto__") {
|
||
|
linter.warn("W103", {
|
||
|
line: data.line,
|
||
|
char: data.char,
|
||
|
data: [ data.name, "6" ]
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
linter.on("Identifier", function style_scanIterator(data) {
|
||
|
if (linter.getOption("iterator")) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (data.name === "__iterator__") {
|
||
|
linter.warn("W103", {
|
||
|
line: data.line,
|
||
|
char: data.char,
|
||
|
data: [ data.name ]
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
linter.on("Identifier", function style_scanCamelCase(data) {
|
||
|
if (!linter.getOption("camelcase")) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (data.name.replace(/^_+|_+$/g, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) {
|
||
|
linter.warn("W106", {
|
||
|
line: data.line,
|
||
|
char: data.char,
|
||
|
data: [ data.name ]
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
linter.on("String", function style_scanQuotes(data) {
|
||
|
var quotmark = linter.getOption("quotmark");
|
||
|
var code;
|
||
|
|
||
|
if (!quotmark) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (quotmark === "single" && data.quote !== "'") {
|
||
|
code = "W109";
|
||
|
}
|
||
|
|
||
|
if (quotmark === "double" && data.quote !== "\"") {
|
||
|
code = "W108";
|
||
|
}
|
||
|
|
||
|
if (quotmark === true) {
|
||
|
if (!linter.getCache("quotmark")) {
|
||
|
linter.setCache("quotmark", data.quote);
|
||
|
}
|
||
|
|
||
|
if (linter.getCache("quotmark") !== data.quote) {
|
||
|
code = "W110";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (code) {
|
||
|
linter.warn(code, {
|
||
|
line: data.line,
|
||
|
char: data.char,
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
linter.on("Number", function style_scanNumbers(data) {
|
||
|
if (data.value.charAt(0) === ".") {
|
||
|
linter.warn("W008", {
|
||
|
line: data.line,
|
||
|
char: data.char,
|
||
|
data: [ data.value ]
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (data.value.substr(data.value.length - 1) === ".") {
|
||
|
linter.warn("W047", {
|
||
|
line: data.line,
|
||
|
char: data.char,
|
||
|
data: [ data.value ]
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (/^00+/.test(data.value)) {
|
||
|
linter.warn("W046", {
|
||
|
line: data.line,
|
||
|
char: data.char,
|
||
|
data: [ data.value ]
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
linter.on("String", function style_scanJavaScriptURLs(data) {
|
||
|
var re = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
|
||
|
|
||
|
if (linter.getOption("scripturl")) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (re.test(data.value)) {
|
||
|
linter.warn("W107", {
|
||
|
line: data.line,
|
||
|
char: data.char
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
},{}],"/../../jshint/src/vars.js":[function(_dereq_,module,exports){
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
exports.reservedVars = {
|
||
|
NaN : false,
|
||
|
undefined : false
|
||
|
};
|
||
|
|
||
|
exports.ecmaIdentifiers = {
|
||
|
3: {
|
||
|
Array : false,
|
||
|
Boolean : false,
|
||
|
Date : false,
|
||
|
decodeURI : false,
|
||
|
decodeURIComponent : false,
|
||
|
encodeURI : false,
|
||
|
encodeURIComponent : false,
|
||
|
Error : false,
|
||
|
"eval" : false,
|
||
|
EvalError : false,
|
||
|
Function : false,
|
||
|
hasOwnProperty : false,
|
||
|
Infinity : false,
|
||
|
isFinite : false,
|
||
|
isNaN : false,
|
||
|
Math : false,
|
||
|
Number : false,
|
||
|
Object : false,
|
||
|
parseInt : false,
|
||
|
parseFloat : false,
|
||
|
RangeError : false,
|
||
|
ReferenceError : false,
|
||
|
RegExp : false,
|
||
|
String : false,
|
||
|
SyntaxError : false,
|
||
|
TypeError : false,
|
||
|
URIError : false
|
||
|
},
|
||
|
5: {
|
||
|
JSON : false
|
||
|
},
|
||
|
6: {
|
||
|
ArrayBuffer : false,
|
||
|
DataView : false,
|
||
|
Float32Array : false,
|
||
|
Float64Array : false,
|
||
|
Int8Array : false,
|
||
|
Int16Array : false,
|
||
|
Int32Array : false,
|
||
|
Map : false,
|
||
|
Promise : false,
|
||
|
Proxy : false,
|
||
|
Reflect : false,
|
||
|
Set : false,
|
||
|
Symbol : false,
|
||
|
Uint8Array : false,
|
||
|
Uint16Array : false,
|
||
|
Uint32Array : false,
|
||
|
Uint8ClampedArray : false,
|
||
|
WeakMap : false,
|
||
|
WeakSet : false
|
||
|
},
|
||
|
8: {
|
||
|
Atomics : false,
|
||
|
SharedArrayBuffer : false
|
||
|
}
|
||
|
};
|
||
|
|
||
|
exports.browser = {
|
||
|
Audio : false,
|
||
|
Blob : false,
|
||
|
addEventListener : false, // EventTarget
|
||
|
applicationCache : false,
|
||
|
atob : false, // WindowOrWorkerGlobalScope
|
||
|
blur : false,
|
||
|
btoa : false, // WindowOrWorkerGlobalScope
|
||
|
cancelAnimationFrame : false,
|
||
|
CanvasGradient : false,
|
||
|
CanvasPattern : false,
|
||
|
CanvasRenderingContext2D: false,
|
||
|
CSS : false,
|
||
|
CSSImportRule : false,
|
||
|
CSSGroupingRule : false,
|
||
|
CSSMarginRule : false,
|
||
|
CSSMediaRule : false,
|
||
|
CSSNamespaceRule : false,
|
||
|
CSSPageRule : false,
|
||
|
CSSRule : false,
|
||
|
CSSRuleList : false,
|
||
|
CSSStyleDeclaration : false,
|
||
|
CSSStyleRule : false,
|
||
|
CSSStyleSheet : false,
|
||
|
clearInterval : false, // WindowOrWorkerGlobalScope
|
||
|
clearTimeout : false, // WindowOrWorkerGlobalScope
|
||
|
close : false,
|
||
|
closed : false,
|
||
|
Comment : false,
|
||
|
CompositionEvent : false,
|
||
|
createImageBitmap : false, // WindowOrWorkerGlobalScope
|
||
|
CustomEvent : false,
|
||
|
DOMParser : false,
|
||
|
defaultStatus : false,
|
||
|
dispatchEvent : false, // EventTarget
|
||
|
Document : false,
|
||
|
document : false,
|
||
|
DocumentFragment : false,
|
||
|
Element : false,
|
||
|
ElementTimeControl : false,
|
||
|
Event : false,
|
||
|
event : false,
|
||
|
fetch : false,
|
||
|
File : false,
|
||
|
FileList : false,
|
||
|
FileReader : false,
|
||
|
FormData : false,
|
||
|
focus : false,
|
||
|
frames : false,
|
||
|
getComputedStyle : false,
|
||
|
Headers : false,
|
||
|
HTMLAnchorElement : false,
|
||
|
HTMLAreaElement : false,
|
||
|
HTMLAudioElement : false,
|
||
|
HTMLBaseElement : false,
|
||
|
HTMLBlockquoteElement: false,
|
||
|
HTMLBodyElement : false,
|
||
|
HTMLBRElement : false,
|
||
|
HTMLButtonElement : false,
|
||
|
HTMLCanvasElement : false,
|
||
|
HTMLCollection : false,
|
||
|
HTMLDataElement : false,
|
||
|
HTMLDataListElement : false,
|
||
|
HTMLDetailsElement : false,
|
||
|
HTMLDialogElement : false,
|
||
|
HTMLDirectoryElement : false,
|
||
|
HTMLDivElement : false,
|
||
|
HTMLDListElement : false,
|
||
|
HTMLElement : false,
|
||
|
HTMLEmbedElement : false,
|
||
|
HTMLFieldSetElement : false,
|
||
|
HTMLFontElement : false,
|
||
|
HTMLFormElement : false,
|
||
|
HTMLFrameElement : false,
|
||
|
HTMLFrameSetElement : false,
|
||
|
HTMLHeadElement : false,
|
||
|
HTMLHeadingElement : false,
|
||
|
HTMLHRElement : false,
|
||
|
HTMLHtmlElement : false,
|
||
|
HTMLIFrameElement : false,
|
||
|
HTMLImageElement : false,
|
||
|
HTMLInputElement : false,
|
||
|
HTMLIsIndexElement : false,
|
||
|
HTMLLabelElement : false,
|
||
|
HTMLLayerElement : false,
|
||
|
HTMLLegendElement : false,
|
||
|
HTMLLIElement : false,
|
||
|
HTMLLinkElement : false,
|
||
|
HTMLMapElement : false,
|
||
|
HTMLMarqueeElement : false,
|
||
|
HTMLMediaElement : false,
|
||
|
HTMLMenuElement : false,
|
||
|
HTMLMetaElement : false,
|
||
|
HTMLMeterElement : false,
|
||
|
HTMLModElement : false,
|
||
|
HTMLObjectElement : false,
|
||
|
HTMLOListElement : false,
|
||
|
HTMLOptGroupElement : false,
|
||
|
HTMLOptionElement : false,
|
||
|
HTMLParagraphElement : false,
|
||
|
HTMLParamElement : false,
|
||
|
HTMLPictureElement : false,
|
||
|
HTMLPreElement : false,
|
||
|
HTMLProgressElement : false,
|
||
|
HTMLQuoteElement : false,
|
||
|
HTMLScriptElement : false,
|
||
|
HTMLSelectElement : false,
|
||
|
HTMLSlotElement : false,
|
||
|
HTMLSourceElement : false,
|
||
|
HTMLStyleElement : false,
|
||
|
HTMLTableCaptionElement: false,
|
||
|
HTMLTableCellElement : false,
|
||
|
HTMLTableColElement : false,
|
||
|
HTMLTableElement : false,
|
||
|
HTMLTableRowElement : false,
|
||
|
HTMLTableSectionElement: false,
|
||
|
HTMLTemplateElement : false,
|
||
|
HTMLTextAreaElement : false,
|
||
|
HTMLTimeElement : false,
|
||
|
HTMLTitleElement : false,
|
||
|
HTMLTrackElement : false,
|
||
|
HTMLUListElement : false,
|
||
|
HTMLVideoElement : false,
|
||
|
history : false,
|
||
|
Image : false,
|
||
|
IntersectionObserver : false,
|
||
|
Intl : false,
|
||
|
length : false,
|
||
|
localStorage : false,
|
||
|
location : false,
|
||
|
matchMedia : false,
|
||
|
MediaList : false,
|
||
|
MediaRecorder : false,
|
||
|
MessageChannel : false,
|
||
|
MessageEvent : false,
|
||
|
MessagePort : false,
|
||
|
MouseEvent : false,
|
||
|
moveBy : false,
|
||
|
moveTo : false,
|
||
|
MutationObserver : false,
|
||
|
name : false,
|
||
|
Node : false,
|
||
|
NodeFilter : false,
|
||
|
NodeList : false,
|
||
|
Notification : false,
|
||
|
navigator : false,
|
||
|
onbeforeunload : true,
|
||
|
onblur : true,
|
||
|
onerror : true,
|
||
|
onfocus : true,
|
||
|
onload : true,
|
||
|
onresize : true,
|
||
|
onunload : true,
|
||
|
open : false,
|
||
|
openDatabase : false,
|
||
|
opener : false,
|
||
|
Option : false,
|
||
|
origin : false, // WindowOrWorkerGlobalScope
|
||
|
parent : false,
|
||
|
performance : false,
|
||
|
print : false,
|
||
|
queueMicrotask : false, // WindowOrWorkerGlobalScope
|
||
|
Range : false,
|
||
|
requestAnimationFrame : false,
|
||
|
removeEventListener : false, // EventTarget
|
||
|
Request : false,
|
||
|
resizeBy : false,
|
||
|
resizeTo : false,
|
||
|
Response : false,
|
||
|
screen : false,
|
||
|
scroll : false,
|
||
|
scrollBy : false,
|
||
|
scrollTo : false,
|
||
|
sessionStorage : false,
|
||
|
setInterval : false, // WindowOrWorkerGlobalScope
|
||
|
setTimeout : false, // WindowOrWorkerGlobalScope
|
||
|
SharedWorker : false,
|
||
|
status : false,
|
||
|
Storage : false,
|
||
|
StyleSheet : false,
|
||
|
SVGAElement : false,
|
||
|
SVGAltGlyphDefElement: false,
|
||
|
SVGAltGlyphElement : false,
|
||
|
SVGAltGlyphItemElement: false,
|
||
|
SVGAngle : false,
|
||
|
SVGAnimateColorElement: false,
|
||
|
SVGAnimateElement : false,
|
||
|
SVGAnimateMotionElement: false,
|
||
|
SVGAnimateTransformElement: false,
|
||
|
SVGAnimatedAngle : false,
|
||
|
SVGAnimatedBoolean : false,
|
||
|
SVGAnimatedEnumeration: false,
|
||
|
SVGAnimatedInteger : false,
|
||
|
SVGAnimatedLength : false,
|
||
|
SVGAnimatedLengthList: false,
|
||
|
SVGAnimatedNumber : false,
|
||
|
SVGAnimatedNumberList: false,
|
||
|
SVGAnimatedPathData : false,
|
||
|
SVGAnimatedPoints : false,
|
||
|
SVGAnimatedPreserveAspectRatio: false,
|
||
|
SVGAnimatedRect : false,
|
||
|
SVGAnimatedString : false,
|
||
|
SVGAnimatedTransformList: false,
|
||
|
SVGAnimationElement : false,
|
||
|
SVGCSSRule : false,
|
||
|
SVGCircleElement : false,
|
||
|
SVGClipPathElement : false,
|
||
|
SVGColor : false,
|
||
|
SVGColorProfileElement: false,
|
||
|
SVGColorProfileRule : false,
|
||
|
SVGComponentTransferFunctionElement: false,
|
||
|
SVGCursorElement : false,
|
||
|
SVGDefsElement : false,
|
||
|
SVGDescElement : false,
|
||
|
SVGDocument : false,
|
||
|
SVGElement : false,
|
||
|
SVGElementInstance : false,
|
||
|
SVGElementInstanceList: false,
|
||
|
SVGEllipseElement : false,
|
||
|
SVGExternalResourcesRequired: false,
|
||
|
SVGFEBlendElement : false,
|
||
|
SVGFEColorMatrixElement: false,
|
||
|
SVGFEComponentTransferElement: false,
|
||
|
SVGFECompositeElement: false,
|
||
|
SVGFEConvolveMatrixElement: false,
|
||
|
SVGFEDiffuseLightingElement: false,
|
||
|
SVGFEDisplacementMapElement: false,
|
||
|
SVGFEDistantLightElement: false,
|
||
|
SVGFEFloodElement : false,
|
||
|
SVGFEFuncAElement : false,
|
||
|
SVGFEFuncBElement : false,
|
||
|
SVGFEFuncGElement : false,
|
||
|
SVGFEFuncRElement : false,
|
||
|
SVGFEGaussianBlurElement: false,
|
||
|
SVGFEImageElement : false,
|
||
|
SVGFEMergeElement : false,
|
||
|
SVGFEMergeNodeElement: false,
|
||
|
SVGFEMorphologyElement: false,
|
||
|
SVGFEOffsetElement : false,
|
||
|
SVGFEPointLightElement: false,
|
||
|
SVGFESpecularLightingElement: false,
|
||
|
SVGFESpotLightElement: false,
|
||
|
SVGFETileElement : false,
|
||
|
SVGFETurbulenceElement: false,
|
||
|
SVGFilterElement : false,
|
||
|
SVGFilterPrimitiveStandardAttributes: false,
|
||
|
SVGFitToViewBox : false,
|
||
|
SVGFontElement : false,
|
||
|
SVGFontFaceElement : false,
|
||
|
SVGFontFaceFormatElement: false,
|
||
|
SVGFontFaceNameElement: false,
|
||
|
SVGFontFaceSrcElement: false,
|
||
|
SVGFontFaceUriElement: false,
|
||
|
SVGForeignObjectElement: false,
|
||
|
SVGGElement : false,
|
||
|
SVGGlyphElement : false,
|
||
|
SVGGlyphRefElement : false,
|
||
|
SVGGradientElement : false,
|
||
|
SVGHKernElement : false,
|
||
|
SVGICCColor : false,
|
||
|
SVGImageElement : false,
|
||
|
SVGLangSpace : false,
|
||
|
SVGLength : false,
|
||
|
SVGLengthList : false,
|
||
|
SVGLineElement : false,
|
||
|
SVGLinearGradientElement: false,
|
||
|
SVGLocatable : false,
|
||
|
SVGMPathElement : false,
|
||
|
SVGMarkerElement : false,
|
||
|
SVGMaskElement : false,
|
||
|
SVGMatrix : false,
|
||
|
SVGMetadataElement : false,
|
||
|
SVGMissingGlyphElement: false,
|
||
|
SVGNumber : false,
|
||
|
SVGNumberList : false,
|
||
|
SVGPaint : false,
|
||
|
SVGPathElement : false,
|
||
|
SVGPathSeg : false,
|
||
|
SVGPathSegArcAbs : false,
|
||
|
SVGPathSegArcRel : false,
|
||
|
SVGPathSegClosePath : false,
|
||
|
SVGPathSegCurvetoCubicAbs: false,
|
||
|
SVGPathSegCurvetoCubicRel: false,
|
||
|
SVGPathSegCurvetoCubicSmoothAbs: false,
|
||
|
SVGPathSegCurvetoCubicSmoothRel: false,
|
||
|
SVGPathSegCurvetoQuadraticAbs: false,
|
||
|
SVGPathSegCurvetoQuadraticRel: false,
|
||
|
SVGPathSegCurvetoQuadraticSmoothAbs: false,
|
||
|
SVGPathSegCurvetoQuadraticSmoothRel: false,
|
||
|
SVGPathSegLinetoAbs : false,
|
||
|
SVGPathSegLinetoHorizontalAbs: false,
|
||
|
SVGPathSegLinetoHorizontalRel: false,
|
||
|
SVGPathSegLinetoRel : false,
|
||
|
SVGPathSegLinetoVerticalAbs: false,
|
||
|
SVGPathSegLinetoVerticalRel: false,
|
||
|
SVGPathSegList : false,
|
||
|
SVGPathSegMovetoAbs : false,
|
||
|
SVGPathSegMovetoRel : false,
|
||
|
SVGPatternElement : false,
|
||
|
SVGPoint : false,
|
||
|
SVGPointList : false,
|
||
|
SVGPolygonElement : false,
|
||
|
SVGPolylineElement : false,
|
||
|
SVGPreserveAspectRatio: false,
|
||
|
SVGRadialGradientElement: false,
|
||
|
SVGRect : false,
|
||
|
SVGRectElement : false,
|
||
|
SVGRenderingIntent : false,
|
||
|
SVGSVGElement : false,
|
||
|
SVGScriptElement : false,
|
||
|
SVGSetElement : false,
|
||
|
SVGStopElement : false,
|
||
|
SVGStringList : false,
|
||
|
SVGStylable : false,
|
||
|
SVGStyleElement : false,
|
||
|
SVGSwitchElement : false,
|
||
|
SVGSymbolElement : false,
|
||
|
SVGTRefElement : false,
|
||
|
SVGTSpanElement : false,
|
||
|
SVGTests : false,
|
||
|
SVGTextContentElement: false,
|
||
|
SVGTextElement : false,
|
||
|
SVGTextPathElement : false,
|
||
|
SVGTextPositioningElement: false,
|
||
|
SVGTitleElement : false,
|
||
|
SVGTransform : false,
|
||
|
SVGTransformList : false,
|
||
|
SVGTransformable : false,
|
||
|
SVGURIReference : false,
|
||
|
SVGUnitTypes : false,
|
||
|
SVGUseElement : false,
|
||
|
SVGVKernElement : false,
|
||
|
SVGViewElement : false,
|
||
|
SVGViewSpec : false,
|
||
|
SVGZoomAndPan : false,
|
||
|
Text : false,
|
||
|
TextDecoder : false,
|
||
|
TextEncoder : false,
|
||
|
TimeEvent : false,
|
||
|
top : false,
|
||
|
URL : false,
|
||
|
WebGLActiveInfo : false,
|
||
|
WebGLBuffer : false,
|
||
|
WebGLContextEvent : false,
|
||
|
WebGLFramebuffer : false,
|
||
|
WebGLProgram : false,
|
||
|
WebGLRenderbuffer : false,
|
||
|
WebGLRenderingContext: false,
|
||
|
WebGLShader : false,
|
||
|
WebGLShaderPrecisionFormat: false,
|
||
|
WebGLTexture : false,
|
||
|
WebGLUniformLocation : false,
|
||
|
WebSocket : false,
|
||
|
window : false,
|
||
|
Window : false,
|
||
|
Worker : false,
|
||
|
XDomainRequest : false,
|
||
|
XMLDocument : false,
|
||
|
XMLHttpRequest : false,
|
||
|
XMLSerializer : false,
|
||
|
XPathEvaluator : false,
|
||
|
XPathException : false,
|
||
|
XPathExpression : false,
|
||
|
XPathNamespace : false,
|
||
|
XPathNSResolver : false,
|
||
|
XPathResult : false
|
||
|
};
|
||
|
|
||
|
exports.devel = {
|
||
|
alert : false,
|
||
|
confirm: false,
|
||
|
console: false,
|
||
|
Debug : false,
|
||
|
opera : false,
|
||
|
prompt : false
|
||
|
};
|
||
|
|
||
|
exports.worker = {
|
||
|
addEventListener : true, // EventTarget
|
||
|
atob : true, // WindowOrWorkerGlobalScope
|
||
|
btoa : true, // WindowOrWorkerGlobalScope
|
||
|
clearInterval : true, // WindowOrWorkerGlobalScope
|
||
|
clearTimeout : true, // WindowOrWorkerGlobalScope
|
||
|
createImageBitmap : true, // WindowOrWorkerGlobalScope
|
||
|
dispatchEvent : true, // EventTarget
|
||
|
importScripts : true,
|
||
|
onmessage : true,
|
||
|
origin : true, // WindowOrWorkerGlobalScope
|
||
|
postMessage : true,
|
||
|
queueMicrotask : true, // WindowOrWorkerGlobalScope
|
||
|
removeEventListener : true, // EventTarget
|
||
|
self : true,
|
||
|
setInterval : true, // WindowOrWorkerGlobalScope
|
||
|
setTimeout : true, // WindowOrWorkerGlobalScope
|
||
|
FileReaderSync : true
|
||
|
};
|
||
|
exports.nonstandard = {
|
||
|
escape : false,
|
||
|
unescape: false
|
||
|
};
|
||
|
|
||
|
exports.couch = {
|
||
|
"require" : false,
|
||
|
respond : false,
|
||
|
getRow : false,
|
||
|
emit : false,
|
||
|
send : false,
|
||
|
start : false,
|
||
|
sum : false,
|
||
|
log : false,
|
||
|
exports : false,
|
||
|
module : false,
|
||
|
provides : false
|
||
|
};
|
||
|
|
||
|
exports.node = {
|
||
|
__filename : false,
|
||
|
__dirname : false,
|
||
|
arguments : false,
|
||
|
GLOBAL : false,
|
||
|
global : false,
|
||
|
module : false,
|
||
|
require : false,
|
||
|
|
||
|
Buffer : true,
|
||
|
console : true,
|
||
|
exports : true,
|
||
|
process : true,
|
||
|
setTimeout : true,
|
||
|
clearTimeout : true,
|
||
|
setInterval : true,
|
||
|
clearInterval : true,
|
||
|
setImmediate : true, // v0.9.1+
|
||
|
clearImmediate: true // v0.9.1+
|
||
|
};
|
||
|
|
||
|
exports.browserify = {
|
||
|
__filename : false,
|
||
|
__dirname : false,
|
||
|
global : false,
|
||
|
module : false,
|
||
|
require : false,
|
||
|
Buffer : true,
|
||
|
exports : true,
|
||
|
process : true
|
||
|
};
|
||
|
|
||
|
exports.phantom = {
|
||
|
phantom : true,
|
||
|
require : true,
|
||
|
WebPage : true,
|
||
|
console : true, // in examples, but undocumented
|
||
|
exports : true // v1.7+
|
||
|
};
|
||
|
|
||
|
exports.qunit = {
|
||
|
asyncTest : false,
|
||
|
deepEqual : false,
|
||
|
equal : false,
|
||
|
expect : false,
|
||
|
module : false,
|
||
|
notDeepEqual : false,
|
||
|
notEqual : false,
|
||
|
notOk : false,
|
||
|
notPropEqual : false,
|
||
|
notStrictEqual : false,
|
||
|
ok : false,
|
||
|
propEqual : false,
|
||
|
QUnit : false,
|
||
|
raises : false,
|
||
|
start : false,
|
||
|
stop : false,
|
||
|
strictEqual : false,
|
||
|
test : false,
|
||
|
"throws" : false
|
||
|
};
|
||
|
|
||
|
exports.rhino = {
|
||
|
arguments : false,
|
||
|
defineClass : false,
|
||
|
deserialize : false,
|
||
|
gc : false,
|
||
|
help : false,
|
||
|
importClass : false,
|
||
|
importPackage: false,
|
||
|
"java" : false,
|
||
|
load : false,
|
||
|
loadClass : false,
|
||
|
Packages : false,
|
||
|
print : false,
|
||
|
quit : false,
|
||
|
readFile : false,
|
||
|
readUrl : false,
|
||
|
runCommand : false,
|
||
|
seal : false,
|
||
|
serialize : false,
|
||
|
spawn : false,
|
||
|
sync : false,
|
||
|
toint32 : false,
|
||
|
version : false
|
||
|
};
|
||
|
|
||
|
exports.shelljs = {
|
||
|
target : false,
|
||
|
echo : false,
|
||
|
exit : false,
|
||
|
cd : false,
|
||
|
pwd : false,
|
||
|
ls : false,
|
||
|
find : false,
|
||
|
cp : false,
|
||
|
rm : false,
|
||
|
mv : false,
|
||
|
mkdir : false,
|
||
|
test : false,
|
||
|
cat : false,
|
||
|
sed : false,
|
||
|
grep : false,
|
||
|
which : false,
|
||
|
dirs : false,
|
||
|
pushd : false,
|
||
|
popd : false,
|
||
|
env : false,
|
||
|
exec : false,
|
||
|
chmod : false,
|
||
|
config : false,
|
||
|
error : false,
|
||
|
tempdir : false
|
||
|
};
|
||
|
|
||
|
exports.typed = {
|
||
|
ArrayBuffer : false,
|
||
|
ArrayBufferView : false,
|
||
|
DataView : false,
|
||
|
Float32Array : false,
|
||
|
Float64Array : false,
|
||
|
Int16Array : false,
|
||
|
Int32Array : false,
|
||
|
Int8Array : false,
|
||
|
Uint16Array : false,
|
||
|
Uint32Array : false,
|
||
|
Uint8Array : false,
|
||
|
Uint8ClampedArray : false
|
||
|
};
|
||
|
|
||
|
exports.wsh = {
|
||
|
ActiveXObject : true,
|
||
|
Enumerator : true,
|
||
|
GetObject : true,
|
||
|
ScriptEngine : true,
|
||
|
ScriptEngineBuildVersion : true,
|
||
|
ScriptEngineMajorVersion : true,
|
||
|
ScriptEngineMinorVersion : true,
|
||
|
VBArray : true,
|
||
|
WSH : true,
|
||
|
WScript : true,
|
||
|
XDomainRequest : true
|
||
|
};
|
||
|
|
||
|
exports.dojo = {
|
||
|
dojo : false,
|
||
|
dijit : false,
|
||
|
dojox : false,
|
||
|
define : false,
|
||
|
"require": false
|
||
|
};
|
||
|
|
||
|
exports.jquery = {
|
||
|
"$" : false,
|
||
|
jQuery : false
|
||
|
};
|
||
|
|
||
|
exports.mootools = {
|
||
|
"$" : false,
|
||
|
"$$" : false,
|
||
|
Asset : false,
|
||
|
Browser : false,
|
||
|
Chain : false,
|
||
|
Class : false,
|
||
|
Color : false,
|
||
|
Cookie : false,
|
||
|
Core : false,
|
||
|
Document : false,
|
||
|
DomReady : false,
|
||
|
DOMEvent : false,
|
||
|
DOMReady : false,
|
||
|
Drag : false,
|
||
|
Element : false,
|
||
|
Elements : false,
|
||
|
Event : false,
|
||
|
Events : false,
|
||
|
Fx : false,
|
||
|
Group : false,
|
||
|
Hash : false,
|
||
|
HtmlTable : false,
|
||
|
IFrame : false,
|
||
|
IframeShim : false,
|
||
|
InputValidator: false,
|
||
|
instanceOf : false,
|
||
|
Keyboard : false,
|
||
|
Locale : false,
|
||
|
Mask : false,
|
||
|
MooTools : false,
|
||
|
Native : false,
|
||
|
Options : false,
|
||
|
OverText : false,
|
||
|
Request : false,
|
||
|
Scroller : false,
|
||
|
Slick : false,
|
||
|
Slider : false,
|
||
|
Sortables : false,
|
||
|
Spinner : false,
|
||
|
Swiff : false,
|
||
|
Tips : false,
|
||
|
Type : false,
|
||
|
typeOf : false,
|
||
|
URI : false,
|
||
|
Window : false
|
||
|
};
|
||
|
|
||
|
exports.prototypejs = {
|
||
|
"$" : false,
|
||
|
"$$" : false,
|
||
|
"$A" : false,
|
||
|
"$F" : false,
|
||
|
"$H" : false,
|
||
|
"$R" : false,
|
||
|
"$break" : false,
|
||
|
"$continue" : false,
|
||
|
"$w" : false,
|
||
|
Abstract : false,
|
||
|
Ajax : false,
|
||
|
Class : false,
|
||
|
Enumerable : false,
|
||
|
Element : false,
|
||
|
Event : false,
|
||
|
Field : false,
|
||
|
Form : false,
|
||
|
Hash : false,
|
||
|
Insertion : false,
|
||
|
ObjectRange : false,
|
||
|
PeriodicalExecuter: false,
|
||
|
Position : false,
|
||
|
Prototype : false,
|
||
|
Selector : false,
|
||
|
Template : false,
|
||
|
Toggle : false,
|
||
|
Try : false,
|
||
|
Autocompleter : false,
|
||
|
Builder : false,
|
||
|
Control : false,
|
||
|
Draggable : false,
|
||
|
Draggables : false,
|
||
|
Droppables : false,
|
||
|
Effect : false,
|
||
|
Sortable : false,
|
||
|
SortableObserver : false,
|
||
|
Sound : false,
|
||
|
Scriptaculous : false
|
||
|
};
|
||
|
|
||
|
exports.yui = {
|
||
|
YUI : false,
|
||
|
Y : false,
|
||
|
YUI_config: false
|
||
|
};
|
||
|
|
||
|
exports.mocha = {
|
||
|
mocha : false,
|
||
|
describe : false,
|
||
|
xdescribe : false,
|
||
|
it : false,
|
||
|
xit : false,
|
||
|
context : false,
|
||
|
xcontext : false,
|
||
|
before : false,
|
||
|
after : false,
|
||
|
beforeEach : false,
|
||
|
afterEach : false,
|
||
|
suite : false,
|
||
|
test : false,
|
||
|
setup : false,
|
||
|
teardown : false,
|
||
|
suiteSetup : false,
|
||
|
suiteTeardown : false
|
||
|
};
|
||
|
|
||
|
exports.jasmine = {
|
||
|
jasmine : false,
|
||
|
describe : false,
|
||
|
xdescribe : false,
|
||
|
it : false,
|
||
|
xit : false,
|
||
|
beforeEach : false,
|
||
|
afterEach : false,
|
||
|
setFixtures : false,
|
||
|
loadFixtures: false,
|
||
|
spyOn : false,
|
||
|
expect : false,
|
||
|
runs : false,
|
||
|
waitsFor : false,
|
||
|
waits : false,
|
||
|
beforeAll : false,
|
||
|
afterAll : false,
|
||
|
fail : false,
|
||
|
fdescribe : false,
|
||
|
fit : false,
|
||
|
pending : false,
|
||
|
spyOnProperty: false
|
||
|
};
|
||
|
|
||
|
},{}],"/../node_modules/assert/assert.js":[function(_dereq_,module,exports){
|
||
|
(function (global){
|
||
|
'use strict';
|
||
|
|
||
|
var objectAssign = _dereq_('object-assign');
|
||
|
function compare(a, b) {
|
||
|
if (a === b) {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
var x = a.length;
|
||
|
var y = b.length;
|
||
|
|
||
|
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
||
|
if (a[i] !== b[i]) {
|
||
|
x = a[i];
|
||
|
y = b[i];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (x < y) {
|
||
|
return -1;
|
||
|
}
|
||
|
if (y < x) {
|
||
|
return 1;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
function isBuffer(b) {
|
||
|
if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
|
||
|
return global.Buffer.isBuffer(b);
|
||
|
}
|
||
|
return !!(b != null && b._isBuffer);
|
||
|
}
|
||
|
|
||
|
var util = _dereq_('util/');
|
||
|
var hasOwn = Object.prototype.hasOwnProperty;
|
||
|
var pSlice = Array.prototype.slice;
|
||
|
var functionsHaveNames = (function () {
|
||
|
return function foo() {}.name === 'foo';
|
||
|
}());
|
||
|
function pToString (obj) {
|
||
|
return Object.prototype.toString.call(obj);
|
||
|
}
|
||
|
function isView(arrbuf) {
|
||
|
if (isBuffer(arrbuf)) {
|
||
|
return false;
|
||
|
}
|
||
|
if (typeof global.ArrayBuffer !== 'function') {
|
||
|
return false;
|
||
|
}
|
||
|
if (typeof ArrayBuffer.isView === 'function') {
|
||
|
return ArrayBuffer.isView(arrbuf);
|
||
|
}
|
||
|
if (!arrbuf) {
|
||
|
return false;
|
||
|
}
|
||
|
if (arrbuf instanceof DataView) {
|
||
|
return true;
|
||
|
}
|
||
|
if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var assert = module.exports = ok;
|
||
|
|
||
|
var regex = /\s*function\s+([^\(\s]*)\s*/;
|
||
|
function getName(func) {
|
||
|
if (!util.isFunction(func)) {
|
||
|
return;
|
||
|
}
|
||
|
if (functionsHaveNames) {
|
||
|
return func.name;
|
||
|
}
|
||
|
var str = func.toString();
|
||
|
var match = str.match(regex);
|
||
|
return match && match[1];
|
||
|
}
|
||
|
assert.AssertionError = function AssertionError(options) {
|
||
|
this.name = 'AssertionError';
|
||
|
this.actual = options.actual;
|
||
|
this.expected = options.expected;
|
||
|
this.operator = options.operator;
|
||
|
if (options.message) {
|
||
|
this.message = options.message;
|
||
|
this.generatedMessage = false;
|
||
|
} else {
|
||
|
this.message = getMessage(this);
|
||
|
this.generatedMessage = true;
|
||
|
}
|
||
|
var stackStartFunction = options.stackStartFunction || fail;
|
||
|
if (Error.captureStackTrace) {
|
||
|
Error.captureStackTrace(this, stackStartFunction);
|
||
|
} else {
|
||
|
var err = new Error();
|
||
|
if (err.stack) {
|
||
|
var out = err.stack;
|
||
|
var fn_name = getName(stackStartFunction);
|
||
|
var idx = out.indexOf('\n' + fn_name);
|
||
|
if (idx >= 0) {
|
||
|
var next_line = out.indexOf('\n', idx + 1);
|
||
|
out = out.substring(next_line + 1);
|
||
|
}
|
||
|
|
||
|
this.stack = out;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
util.inherits(assert.AssertionError, Error);
|
||
|
|
||
|
function truncate(s, n) {
|
||
|
if (typeof s === 'string') {
|
||
|
return s.length < n ? s : s.slice(0, n);
|
||
|
} else {
|
||
|
return s;
|
||
|
}
|
||
|
}
|
||
|
function inspect(something) {
|
||
|
if (functionsHaveNames || !util.isFunction(something)) {
|
||
|
return util.inspect(something);
|
||
|
}
|
||
|
var rawname = getName(something);
|
||
|
var name = rawname ? ': ' + rawname : '';
|
||
|
return '[Function' + name + ']';
|
||
|
}
|
||
|
function getMessage(self) {
|
||
|
return truncate(inspect(self.actual), 128) + ' ' +
|
||
|
self.operator + ' ' +
|
||
|
truncate(inspect(self.expected), 128);
|
||
|
}
|
||
|
|
||
|
function fail(actual, expected, message, operator, stackStartFunction) {
|
||
|
throw new assert.AssertionError({
|
||
|
message: message,
|
||
|
actual: actual,
|
||
|
expected: expected,
|
||
|
operator: operator,
|
||
|
stackStartFunction: stackStartFunction
|
||
|
});
|
||
|
}
|
||
|
assert.fail = fail;
|
||
|
|
||
|
function ok(value, message) {
|
||
|
if (!value) fail(value, true, message, '==', assert.ok);
|
||
|
}
|
||
|
assert.ok = ok;
|
||
|
|
||
|
assert.equal = function equal(actual, expected, message) {
|
||
|
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
|
||
|
};
|
||
|
|
||
|
assert.notEqual = function notEqual(actual, expected, message) {
|
||
|
if (actual == expected) {
|
||
|
fail(actual, expected, message, '!=', assert.notEqual);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
assert.deepEqual = function deepEqual(actual, expected, message) {
|
||
|
if (!_deepEqual(actual, expected, false)) {
|
||
|
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
|
||
|
if (!_deepEqual(actual, expected, true)) {
|
||
|
fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
function _deepEqual(actual, expected, strict, memos) {
|
||
|
if (actual === expected) {
|
||
|
return true;
|
||
|
} else if (isBuffer(actual) && isBuffer(expected)) {
|
||
|
return compare(actual, expected) === 0;
|
||
|
} else if (util.isDate(actual) && util.isDate(expected)) {
|
||
|
return actual.getTime() === expected.getTime();
|
||
|
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
|
||
|
return actual.source === expected.source &&
|
||
|
actual.global === expected.global &&
|
||
|
actual.multiline === expected.multiline &&
|
||
|
actual.lastIndex === expected.lastIndex &&
|
||
|
actual.ignoreCase === expected.ignoreCase;
|
||
|
} else if ((actual === null || typeof actual !== 'object') &&
|
||
|
(expected === null || typeof expected !== 'object')) {
|
||
|
return strict ? actual === expected : actual == expected;
|
||
|
} else if (isView(actual) && isView(expected) &&
|
||
|
pToString(actual) === pToString(expected) &&
|
||
|
!(actual instanceof Float32Array ||
|
||
|
actual instanceof Float64Array)) {
|
||
|
return compare(new Uint8Array(actual.buffer),
|
||
|
new Uint8Array(expected.buffer)) === 0;
|
||
|
} else if (isBuffer(actual) !== isBuffer(expected)) {
|
||
|
return false;
|
||
|
} else {
|
||
|
memos = memos || {actual: [], expected: []};
|
||
|
|
||
|
var actualIndex = memos.actual.indexOf(actual);
|
||
|
if (actualIndex !== -1) {
|
||
|
if (actualIndex === memos.expected.indexOf(expected)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
memos.actual.push(actual);
|
||
|
memos.expected.push(expected);
|
||
|
|
||
|
return objEquiv(actual, expected, strict, memos);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function isArguments(object) {
|
||
|
return Object.prototype.toString.call(object) == '[object Arguments]';
|
||
|
}
|
||
|
|
||
|
function objEquiv(a, b, strict, actualVisitedObjects) {
|
||
|
if (a === null || a === undefined || b === null || b === undefined)
|
||
|
return false;
|
||
|
if (util.isPrimitive(a) || util.isPrimitive(b))
|
||
|
return a === b;
|
||
|
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
|
||
|
return false;
|
||
|
var aIsArgs = isArguments(a);
|
||
|
var bIsArgs = isArguments(b);
|
||
|
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
|
||
|
return false;
|
||
|
if (aIsArgs) {
|
||
|
a = pSlice.call(a);
|
||
|
b = pSlice.call(b);
|
||
|
return _deepEqual(a, b, strict);
|
||
|
}
|
||
|
var ka = objectKeys(a);
|
||
|
var kb = objectKeys(b);
|
||
|
var key, i;
|
||
|
if (ka.length !== kb.length)
|
||
|
return false;
|
||
|
ka.sort();
|
||
|
kb.sort();
|
||
|
for (i = ka.length - 1; i >= 0; i--) {
|
||
|
if (ka[i] !== kb[i])
|
||
|
return false;
|
||
|
}
|
||
|
for (i = ka.length - 1; i >= 0; i--) {
|
||
|
key = ka[i];
|
||
|
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
||
|
if (_deepEqual(actual, expected, false)) {
|
||
|
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
assert.notDeepStrictEqual = notDeepStrictEqual;
|
||
|
function notDeepStrictEqual(actual, expected, message) {
|
||
|
if (_deepEqual(actual, expected, true)) {
|
||
|
fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
assert.strictEqual = function strictEqual(actual, expected, message) {
|
||
|
if (actual !== expected) {
|
||
|
fail(actual, expected, message, '===', assert.strictEqual);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
||
|
if (actual === expected) {
|
||
|
fail(actual, expected, message, '!==', assert.notStrictEqual);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
function expectedException(actual, expected) {
|
||
|
if (!actual || !expected) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
|
||
|
return expected.test(actual);
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
if (actual instanceof expected) {
|
||
|
return true;
|
||
|
}
|
||
|
} catch (e) {
|
||
|
}
|
||
|
|
||
|
if (Error.isPrototypeOf(expected)) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return expected.call({}, actual) === true;
|
||
|
}
|
||
|
|
||
|
function _tryBlock(block) {
|
||
|
var error;
|
||
|
try {
|
||
|
block();
|
||
|
} catch (e) {
|
||
|
error = e;
|
||
|
}
|
||
|
return error;
|
||
|
}
|
||
|
|
||
|
function _throws(shouldThrow, block, expected, message) {
|
||
|
var actual;
|
||
|
|
||
|
if (typeof block !== 'function') {
|
||
|
throw new TypeError('"block" argument must be a function');
|
||
|
}
|
||
|
|
||
|
if (typeof expected === 'string') {
|
||
|
message = expected;
|
||
|
expected = null;
|
||
|
}
|
||
|
|
||
|
actual = _tryBlock(block);
|
||
|
|
||
|
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
|
||
|
(message ? ' ' + message : '.');
|
||
|
|
||
|
if (shouldThrow && !actual) {
|
||
|
fail(actual, expected, 'Missing expected exception' + message);
|
||
|
}
|
||
|
|
||
|
var userProvidedMessage = typeof message === 'string';
|
||
|
var isUnwantedException = !shouldThrow && util.isError(actual);
|
||
|
var isUnexpectedException = !shouldThrow && actual && !expected;
|
||
|
|
||
|
if ((isUnwantedException &&
|
||
|
userProvidedMessage &&
|
||
|
expectedException(actual, expected)) ||
|
||
|
isUnexpectedException) {
|
||
|
fail(actual, expected, 'Got unwanted exception' + message);
|
||
|
}
|
||
|
|
||
|
if ((shouldThrow && actual && expected &&
|
||
|
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
|
||
|
throw actual;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
assert.throws = function(block, /*optional*/error, /*optional*/message) {
|
||
|
_throws(true, block, error, message);
|
||
|
};
|
||
|
assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
|
||
|
_throws(false, block, error, message);
|
||
|
};
|
||
|
|
||
|
assert.ifError = function(err) { if (err) throw err; };
|
||
|
function strict(value, message) {
|
||
|
if (!value) fail(value, true, message, '==', strict);
|
||
|
}
|
||
|
assert.strict = objectAssign(strict, assert, {
|
||
|
equal: assert.strictEqual,
|
||
|
deepEqual: assert.deepStrictEqual,
|
||
|
notEqual: assert.notStrictEqual,
|
||
|
notDeepEqual: assert.notDeepStrictEqual
|
||
|
});
|
||
|
assert.strict.strict = assert.strict;
|
||
|
|
||
|
var objectKeys = Object.keys || function (obj) {
|
||
|
var keys = [];
|
||
|
for (var key in obj) {
|
||
|
if (hasOwn.call(obj, key)) keys.push(key);
|
||
|
}
|
||
|
return keys;
|
||
|
};
|
||
|
|
||
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
|
},{"object-assign":"/../node_modules/object-assign/index.js","util/":"/../node_modules/assert/node_modules/util/util.js"}],"/../node_modules/assert/node_modules/inherits/inherits_browser.js":[function(_dereq_,module,exports){
|
||
|
if (typeof Object.create === 'function') {
|
||
|
module.exports = function inherits(ctor, superCtor) {
|
||
|
ctor.super_ = superCtor
|
||
|
ctor.prototype = Object.create(superCtor.prototype, {
|
||
|
constructor: {
|
||
|
value: ctor,
|
||
|
enumerable: false,
|
||
|
writable: true,
|
||
|
configurable: true
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
} else {
|
||
|
module.exports = function inherits(ctor, superCtor) {
|
||
|
ctor.super_ = superCtor
|
||
|
var TempCtor = function () {}
|
||
|
TempCtor.prototype = superCtor.prototype
|
||
|
ctor.prototype = new TempCtor()
|
||
|
ctor.prototype.constructor = ctor
|
||
|
}
|
||
|
}
|
||
|
|
||
|
},{}],"/../node_modules/assert/node_modules/util/support/isBufferBrowser.js":[function(_dereq_,module,exports){
|
||
|
module.exports = function isBuffer(arg) {
|
||
|
return arg && typeof arg === 'object'
|
||
|
&& typeof arg.copy === 'function'
|
||
|
&& typeof arg.fill === 'function'
|
||
|
&& typeof arg.readUInt8 === 'function';
|
||
|
}
|
||
|
},{}],"/../node_modules/assert/node_modules/util/util.js":[function(_dereq_,module,exports){
|
||
|
(function (process,global){
|
||
|
|
||
|
var formatRegExp = /%[sdj%]/g;
|
||
|
exports.format = function(f) {
|
||
|
if (!isString(f)) {
|
||
|
var objects = [];
|
||
|
for (var i = 0; i < arguments.length; i++) {
|
||
|
objects.push(inspect(arguments[i]));
|
||
|
}
|
||
|
return objects.join(' ');
|
||
|
}
|
||
|
|
||
|
var i = 1;
|
||
|
var args = arguments;
|
||
|
var len = args.length;
|
||
|
var str = String(f).replace(formatRegExp, function(x) {
|
||
|
if (x === '%%') return '%';
|
||
|
if (i >= len) return x;
|
||
|
switch (x) {
|
||
|
case '%s': return String(args[i++]);
|
||
|
case '%d': return Number(args[i++]);
|
||
|
case '%j':
|
||
|
try {
|
||
|
return JSON.stringify(args[i++]);
|
||
|
} catch (_) {
|
||
|
return '[Circular]';
|
||
|
}
|
||
|
default:
|
||
|
return x;
|
||
|
}
|
||
|
});
|
||
|
for (var x = args[i]; i < len; x = args[++i]) {
|
||
|
if (isNull(x) || !isObject(x)) {
|
||
|
str += ' ' + x;
|
||
|
} else {
|
||
|
str += ' ' + inspect(x);
|
||
|
}
|
||
|
}
|
||
|
return str;
|
||
|
};
|
||
|
exports.deprecate = function(fn, msg) {
|
||
|
if (isUndefined(global.process)) {
|
||
|
return function() {
|
||
|
return exports.deprecate(fn, msg).apply(this, arguments);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (process.noDeprecation === true) {
|
||
|
return fn;
|
||
|
}
|
||
|
|
||
|
var warned = false;
|
||
|
function deprecated() {
|
||
|
if (!warned) {
|
||
|
if (process.throwDeprecation) {
|
||
|
throw new Error(msg);
|
||
|
} else if (process.traceDeprecation) {
|
||
|
console.trace(msg);
|
||
|
} else {
|
||
|
console.error(msg);
|
||
|
}
|
||
|
warned = true;
|
||
|
}
|
||
|
return fn.apply(this, arguments);
|
||
|
}
|
||
|
|
||
|
return deprecated;
|
||
|
};
|
||
|
|
||
|
|
||
|
var debugs = {};
|
||
|
var debugEnviron;
|
||
|
exports.debuglog = function(set) {
|
||
|
if (isUndefined(debugEnviron))
|
||
|
debugEnviron = process.env.NODE_DEBUG || '';
|
||
|
set = set.toUpperCase();
|
||
|
if (!debugs[set]) {
|
||
|
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
||
|
var pid = process.pid;
|
||
|
debugs[set] = function() {
|
||
|
var msg = exports.format.apply(exports, arguments);
|
||
|
console.error('%s %d: %s', set, pid, msg);
|
||
|
};
|
||
|
} else {
|
||
|
debugs[set] = function() {};
|
||
|
}
|
||
|
}
|
||
|
return debugs[set];
|
||
|
};
|
||
|
function inspect(obj, opts) {
|
||
|
var ctx = {
|
||
|
seen: [],
|
||
|
stylize: stylizeNoColor
|
||
|
};
|
||
|
if (arguments.length >= 3) ctx.depth = arguments[2];
|
||
|
if (arguments.length >= 4) ctx.colors = arguments[3];
|
||
|
if (isBoolean(opts)) {
|
||
|
ctx.showHidden = opts;
|
||
|
} else if (opts) {
|
||
|
exports._extend(ctx, opts);
|
||
|
}
|
||
|
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
||
|
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
||
|
if (isUndefined(ctx.colors)) ctx.colors = false;
|
||
|
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
||
|
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
||
|
return formatValue(ctx, obj, ctx.depth);
|
||
|
}
|
||
|
exports.inspect = inspect;
|
||
|
inspect.colors = {
|
||
|
'bold' : [1, 22],
|
||
|
'italic' : [3, 23],
|
||
|
'underline' : [4, 24],
|
||
|
'inverse' : [7, 27],
|
||
|
'white' : [37, 39],
|
||
|
'grey' : [90, 39],
|
||
|
'black' : [30, 39],
|
||
|
'blue' : [34, 39],
|
||
|
'cyan' : [36, 39],
|
||
|
'green' : [32, 39],
|
||
|
'magenta' : [35, 39],
|
||
|
'red' : [31, 39],
|
||
|
'yellow' : [33, 39]
|
||
|
};
|
||
|
inspect.styles = {
|
||
|
'special': 'cyan',
|
||
|
'number': 'yellow',
|
||
|
'boolean': 'yellow',
|
||
|
'undefined': 'grey',
|
||
|
'null': 'bold',
|
||
|
'string': 'green',
|
||
|
'date': 'magenta',
|
||
|
'regexp': 'red'
|
||
|
};
|
||
|
|
||
|
|
||
|
function stylizeWithColor(str, styleType) {
|
||
|
var style = inspect.styles[styleType];
|
||
|
|
||
|
if (style) {
|
||
|
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
||
|
'\u001b[' + inspect.colors[style][1] + 'm';
|
||
|
} else {
|
||
|
return str;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function stylizeNoColor(str, styleType) {
|
||
|
return str;
|
||
|
}
|
||
|
|
||
|
|
||
|
function arrayToHash(array) {
|
||
|
var hash = {};
|
||
|
|
||
|
array.forEach(function(val, idx) {
|
||
|
hash[val] = true;
|
||
|
});
|
||
|
|
||
|
return hash;
|
||
|
}
|
||
|
|
||
|
|
||
|
function formatValue(ctx, value, recurseTimes) {
|
||
|
if (ctx.customInspect &&
|
||
|
value &&
|
||
|
isFunction(value.inspect) &&
|
||
|
value.inspect !== exports.inspect &&
|
||
|
!(value.constructor && value.constructor.prototype === value)) {
|
||
|
var ret = value.inspect(recurseTimes, ctx);
|
||
|
if (!isString(ret)) {
|
||
|
ret = formatValue(ctx, ret, recurseTimes);
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
var primitive = formatPrimitive(ctx, value);
|
||
|
if (primitive) {
|
||
|
return primitive;
|
||
|
}
|
||
|
var keys = Object.keys(value);
|
||
|
var visibleKeys = arrayToHash(keys);
|
||
|
|
||
|
if (ctx.showHidden) {
|
||
|
keys = Object.getOwnPropertyNames(value);
|
||
|
}
|
||
|
if (isError(value)
|
||
|
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
||
|
return formatError(value);
|
||
|
}
|
||
|
if (keys.length === 0) {
|
||
|
if (isFunction(value)) {
|
||
|
var name = value.name ? ': ' + value.name : '';
|
||
|
return ctx.stylize('[Function' + name + ']', 'special');
|
||
|
}
|
||
|
if (isRegExp(value)) {
|
||
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||
|
}
|
||
|
if (isDate(value)) {
|
||
|
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
||
|
}
|
||
|
if (isError(value)) {
|
||
|
return formatError(value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var base = '', array = false, braces = ['{', '}'];
|
||
|
if (isArray(value)) {
|
||
|
array = true;
|
||
|
braces = ['[', ']'];
|
||
|
}
|
||
|
if (isFunction(value)) {
|
||
|
var n = value.name ? ': ' + value.name : '';
|
||
|
base = ' [Function' + n + ']';
|
||
|
}
|
||
|
if (isRegExp(value)) {
|
||
|
base = ' ' + RegExp.prototype.toString.call(value);
|
||
|
}
|
||
|
if (isDate(value)) {
|
||
|
base = ' ' + Date.prototype.toUTCString.call(value);
|
||
|
}
|
||
|
if (isError(value)) {
|
||
|
base = ' ' + formatError(value);
|
||
|
}
|
||
|
|
||
|
if (keys.length === 0 && (!array || value.length == 0)) {
|
||
|
return braces[0] + base + braces[1];
|
||
|
}
|
||
|
|
||
|
if (recurseTimes < 0) {
|
||
|
if (isRegExp(value)) {
|
||
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||
|
} else {
|
||
|
return ctx.stylize('[Object]', 'special');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ctx.seen.push(value);
|
||
|
|
||
|
var output;
|
||
|
if (array) {
|
||
|
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
||
|
} else {
|
||
|
output = keys.map(function(key) {
|
||
|
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
ctx.seen.pop();
|
||
|
|
||
|
return reduceToSingleString(output, base, braces);
|
||
|
}
|
||
|
|
||
|
|
||
|
function formatPrimitive(ctx, value) {
|
||
|
if (isUndefined(value))
|
||
|
return ctx.stylize('undefined', 'undefined');
|
||
|
if (isString(value)) {
|
||
|
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
||
|
.replace(/'/g, "\\'")
|
||
|
.replace(/\\"/g, '"') + '\'';
|
||
|
return ctx.stylize(simple, 'string');
|
||
|
}
|
||
|
if (isNumber(value))
|
||
|
return ctx.stylize('' + value, 'number');
|
||
|
if (isBoolean(value))
|
||
|
return ctx.stylize('' + value, 'boolean');
|
||
|
if (isNull(value))
|
||
|
return ctx.stylize('null', 'null');
|
||
|
}
|
||
|
|
||
|
|
||
|
function formatError(value) {
|
||
|
return '[' + Error.prototype.toString.call(value) + ']';
|
||
|
}
|
||
|
|
||
|
|
||
|
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
||
|
var output = [];
|
||
|
for (var i = 0, l = value.length; i < l; ++i) {
|
||
|
if (hasOwnProperty(value, String(i))) {
|
||
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||
|
String(i), true));
|
||
|
} else {
|
||
|
output.push('');
|
||
|
}
|
||
|
}
|
||
|
keys.forEach(function(key) {
|
||
|
if (!key.match(/^\d+$/)) {
|
||
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||
|
key, true));
|
||
|
}
|
||
|
});
|
||
|
return output;
|
||
|
}
|
||
|
|
||
|
|
||
|
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
||
|
var name, str, desc;
|
||
|
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
||
|
if (desc.get) {
|
||
|
if (desc.set) {
|
||
|
str = ctx.stylize('[Getter/Setter]', 'special');
|
||
|
} else {
|
||
|
str = ctx.stylize('[Getter]', 'special');
|
||
|
}
|
||
|
} else {
|
||
|
if (desc.set) {
|
||
|
str = ctx.stylize('[Setter]', 'special');
|
||
|
}
|
||
|
}
|
||
|
if (!hasOwnProperty(visibleKeys, key)) {
|
||
|
name = '[' + key + ']';
|
||
|
}
|
||
|
if (!str) {
|
||
|
if (ctx.seen.indexOf(desc.value) < 0) {
|
||
|
if (isNull(recurseTimes)) {
|
||
|
str = formatValue(ctx, desc.value, null);
|
||
|
} else {
|
||
|
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
||
|
}
|
||
|
if (str.indexOf('\n') > -1) {
|
||
|
if (array) {
|
||
|
str = str.split('\n').map(function(line) {
|
||
|
return ' ' + line;
|
||
|
}).join('\n').substr(2);
|
||
|
} else {
|
||
|
str = '\n' + str.split('\n').map(function(line) {
|
||
|
return ' ' + line;
|
||
|
}).join('\n');
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
str = ctx.stylize('[Circular]', 'special');
|
||
|
}
|
||
|
}
|
||
|
if (isUndefined(name)) {
|
||
|
if (array && key.match(/^\d+$/)) {
|
||
|
return str;
|
||
|
}
|
||
|
name = JSON.stringify('' + key);
|
||
|
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
||
|
name = name.substr(1, name.length - 2);
|
||
|
name = ctx.stylize(name, 'name');
|
||
|
} else {
|
||
|
name = name.replace(/'/g, "\\'")
|
||
|
.replace(/\\"/g, '"')
|
||
|
.replace(/(^"|"$)/g, "'");
|
||
|
name = ctx.stylize(name, 'string');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return name + ': ' + str;
|
||
|
}
|
||
|
|
||
|
|
||
|
function reduceToSingleString(output, base, braces) {
|
||
|
var numLinesEst = 0;
|
||
|
var length = output.reduce(function(prev, cur) {
|
||
|
numLinesEst++;
|
||
|
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
||
|
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
||
|
}, 0);
|
||
|
|
||
|
if (length > 60) {
|
||
|
return braces[0] +
|
||
|
(base === '' ? '' : base + '\n ') +
|
||
|
' ' +
|
||
|
output.join(',\n ') +
|
||
|
' ' +
|
||
|
braces[1];
|
||
|
}
|
||
|
|
||
|
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
||
|
}
|
||
|
function isArray(ar) {
|
||
|
return Array.isArray(ar);
|
||
|
}
|
||
|
exports.isArray = isArray;
|
||
|
|
||
|
function isBoolean(arg) {
|
||
|
return typeof arg === 'boolean';
|
||
|
}
|
||
|
exports.isBoolean = isBoolean;
|
||
|
|
||
|
function isNull(arg) {
|
||
|
return arg === null;
|
||
|
}
|
||
|
exports.isNull = isNull;
|
||
|
|
||
|
function isNullOrUndefined(arg) {
|
||
|
return arg == null;
|
||
|
}
|
||
|
exports.isNullOrUndefined = isNullOrUndefined;
|
||
|
|
||
|
function isNumber(arg) {
|
||
|
return typeof arg === 'number';
|
||
|
}
|
||
|
exports.isNumber = isNumber;
|
||
|
|
||
|
function isString(arg) {
|
||
|
return typeof arg === 'string';
|
||
|
}
|
||
|
exports.isString = isString;
|
||
|
|
||
|
function isSymbol(arg) {
|
||
|
return typeof arg === 'symbol';
|
||
|
}
|
||
|
exports.isSymbol = isSymbol;
|
||
|
|
||
|
function isUndefined(arg) {
|
||
|
return arg === void 0;
|
||
|
}
|
||
|
exports.isUndefined = isUndefined;
|
||
|
|
||
|
function isRegExp(re) {
|
||
|
return isObject(re) && objectToString(re) === '[object RegExp]';
|
||
|
}
|
||
|
exports.isRegExp = isRegExp;
|
||
|
|
||
|
function isObject(arg) {
|
||
|
return typeof arg === 'object' && arg !== null;
|
||
|
}
|
||
|
exports.isObject = isObject;
|
||
|
|
||
|
function isDate(d) {
|
||
|
return isObject(d) && objectToString(d) === '[object Date]';
|
||
|
}
|
||
|
exports.isDate = isDate;
|
||
|
|
||
|
function isError(e) {
|
||
|
return isObject(e) &&
|
||
|
(objectToString(e) === '[object Error]' || e instanceof Error);
|
||
|
}
|
||
|
exports.isError = isError;
|
||
|
|
||
|
function isFunction(arg) {
|
||
|
return typeof arg === 'function';
|
||
|
}
|
||
|
exports.isFunction = isFunction;
|
||
|
|
||
|
function isPrimitive(arg) {
|
||
|
return arg === null ||
|
||
|
typeof arg === 'boolean' ||
|
||
|
typeof arg === 'number' ||
|
||
|
typeof arg === 'string' ||
|
||
|
typeof arg === 'symbol' || // ES6 symbol
|
||
|
typeof arg === 'undefined';
|
||
|
}
|
||
|
exports.isPrimitive = isPrimitive;
|
||
|
|
||
|
exports.isBuffer = _dereq_('./support/isBuffer');
|
||
|
|
||
|
function objectToString(o) {
|
||
|
return Object.prototype.toString.call(o);
|
||
|
}
|
||
|
|
||
|
|
||
|
function pad(n) {
|
||
|
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
||
|
}
|
||
|
|
||
|
|
||
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
||
|
'Oct', 'Nov', 'Dec'];
|
||
|
function timestamp() {
|
||
|
var d = new Date();
|
||
|
var time = [pad(d.getHours()),
|
||
|
pad(d.getMinutes()),
|
||
|
pad(d.getSeconds())].join(':');
|
||
|
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
||
|
}
|
||
|
exports.log = function() {
|
||
|
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
||
|
};
|
||
|
exports.inherits = _dereq_('inherits');
|
||
|
|
||
|
exports._extend = function(origin, add) {
|
||
|
if (!add || !isObject(add)) return origin;
|
||
|
|
||
|
var keys = Object.keys(add);
|
||
|
var i = keys.length;
|
||
|
while (i--) {
|
||
|
origin[keys[i]] = add[keys[i]];
|
||
|
}
|
||
|
return origin;
|
||
|
};
|
||
|
|
||
|
function hasOwnProperty(obj, prop) {
|
||
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||
|
}
|
||
|
|
||
|
}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
|
},{"./support/isBuffer":"/../node_modules/assert/node_modules/util/support/isBufferBrowser.js","_process":"/../node_modules/process/browser.js","inherits":"/../node_modules/assert/node_modules/inherits/inherits_browser.js"}],"/../node_modules/events/events.js":[function(_dereq_,module,exports){
|
||
|
|
||
|
var objectCreate = Object.create || objectCreatePolyfill
|
||
|
var objectKeys = Object.keys || objectKeysPolyfill
|
||
|
var bind = Function.prototype.bind || functionBindPolyfill
|
||
|
|
||
|
function EventEmitter() {
|
||
|
if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
|
||
|
this._events = objectCreate(null);
|
||
|
this._eventsCount = 0;
|
||
|
}
|
||
|
|
||
|
this._maxListeners = this._maxListeners || undefined;
|
||
|
}
|
||
|
module.exports = EventEmitter;
|
||
|
EventEmitter.EventEmitter = EventEmitter;
|
||
|
|
||
|
EventEmitter.prototype._events = undefined;
|
||
|
EventEmitter.prototype._maxListeners = undefined;
|
||
|
var defaultMaxListeners = 200;
|
||
|
|
||
|
var hasDefineProperty;
|
||
|
try {
|
||
|
var o = {};
|
||
|
if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
|
||
|
hasDefineProperty = o.x === 0;
|
||
|
} catch (err) { hasDefineProperty = false }
|
||
|
if (hasDefineProperty) {
|
||
|
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
||
|
enumerable: true,
|
||
|
get: function() {
|
||
|
return defaultMaxListeners;
|
||
|
},
|
||
|
set: function(arg) {
|
||
|
if (typeof arg !== 'number' || arg < 0 || arg !== arg)
|
||
|
throw new TypeError('"defaultMaxListeners" must be a positive number');
|
||
|
defaultMaxListeners = arg;
|
||
|
}
|
||
|
});
|
||
|
} else {
|
||
|
EventEmitter.defaultMaxListeners = defaultMaxListeners;
|
||
|
}
|
||
|
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
||
|
if (typeof n !== 'number' || n < 0 || isNaN(n))
|
||
|
throw new TypeError('"n" argument must be a positive number');
|
||
|
this._maxListeners = n;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
function $getMaxListeners(that) {
|
||
|
if (that._maxListeners === undefined)
|
||
|
return EventEmitter.defaultMaxListeners;
|
||
|
return that._maxListeners;
|
||
|
}
|
||
|
|
||
|
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
||
|
return $getMaxListeners(this);
|
||
|
};
|
||
|
function emitNone(handler, isFn, self) {
|
||
|
if (isFn)
|
||
|
handler.call(self);
|
||
|
else {
|
||
|
var len = handler.length;
|
||
|
var listeners = arrayClone(handler, len);
|
||
|
for (var i = 0; i < len; ++i)
|
||
|
listeners[i].call(self);
|
||
|
}
|
||
|
}
|
||
|
function emitOne(handler, isFn, self, arg1) {
|
||
|
if (isFn)
|
||
|
handler.call(self, arg1);
|
||
|
else {
|
||
|
var len = handler.length;
|
||
|
var listeners = arrayClone(handler, len);
|
||
|
for (var i = 0; i < len; ++i)
|
||
|
listeners[i].call(self, arg1);
|
||
|
}
|
||
|
}
|
||
|
function emitTwo(handler, isFn, self, arg1, arg2) {
|
||
|
if (isFn)
|
||
|
handler.call(self, arg1, arg2);
|
||
|
else {
|
||
|
var len = handler.length;
|
||
|
var listeners = arrayClone(handler, len);
|
||
|
for (var i = 0; i < len; ++i)
|
||
|
listeners[i].call(self, arg1, arg2);
|
||
|
}
|
||
|
}
|
||
|
function emitThree(handler, isFn, self, arg1, arg2, arg3) {
|
||
|
if (isFn)
|
||
|
handler.call(self, arg1, arg2, arg3);
|
||
|
else {
|
||
|
var len = handler.length;
|
||
|
var listeners = arrayClone(handler, len);
|
||
|
for (var i = 0; i < len; ++i)
|
||
|
listeners[i].call(self, arg1, arg2, arg3);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function emitMany(handler, isFn, self, args) {
|
||
|
if (isFn)
|
||
|
handler.apply(self, args);
|
||
|
else {
|
||
|
var len = handler.length;
|
||
|
var listeners = arrayClone(handler, len);
|
||
|
for (var i = 0; i < len; ++i)
|
||
|
listeners[i].apply(self, args);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
EventEmitter.prototype.emit = function emit(type) {
|
||
|
var er, handler, len, args, i, events;
|
||
|
var doError = (type === 'error');
|
||
|
|
||
|
events = this._events;
|
||
|
if (events)
|
||
|
doError = (doError && events.error == null);
|
||
|
else if (!doError)
|
||
|
return false;
|
||
|
if (doError) {
|
||
|
if (arguments.length > 1)
|
||
|
er = arguments[1];
|
||
|
if (er instanceof Error) {
|
||
|
throw er; // Unhandled 'error' event
|
||
|
} else {
|
||
|
var err = new Error('Unhandled "error" event. (' + er + ')');
|
||
|
err.context = er;
|
||
|
throw err;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
handler = events[type];
|
||
|
|
||
|
if (!handler)
|
||
|
return false;
|
||
|
|
||
|
var isFn = typeof handler === 'function';
|
||
|
len = arguments.length;
|
||
|
switch (len) {
|
||
|
case 1:
|
||
|
emitNone(handler, isFn, this);
|
||
|
break;
|
||
|
case 2:
|
||
|
emitOne(handler, isFn, this, arguments[1]);
|
||
|
break;
|
||
|
case 3:
|
||
|
emitTwo(handler, isFn, this, arguments[1], arguments[2]);
|
||
|
break;
|
||
|
case 4:
|
||
|
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
|
||
|
break;
|
||
|
default:
|
||
|
args = new Array(len - 1);
|
||
|
for (i = 1; i < len; i++)
|
||
|
args[i - 1] = arguments[i];
|
||
|
emitMany(handler, isFn, this, args);
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
};
|
||
|
|
||
|
function _addListener(target, type, listener, prepend) {
|
||
|
var m;
|
||
|
var events;
|
||
|
var existing;
|
||
|
|
||
|
if (typeof listener !== 'function')
|
||
|
throw new TypeError('"listener" argument must be a function');
|
||
|
|
||
|
events = target._events;
|
||
|
if (!events) {
|
||
|
events = target._events = objectCreate(null);
|
||
|
target._eventsCount = 0;
|
||
|
} else {
|
||
|
if (events.newListener) {
|
||
|
target.emit('newListener', type,
|
||
|
listener.listener ? listener.listener : listener);
|
||
|
events = target._events;
|
||
|
}
|
||
|
existing = events[type];
|
||
|
}
|
||
|
|
||
|
if (!existing) {
|
||
|
existing = events[type] = listener;
|
||
|
++target._eventsCount;
|
||
|
} else {
|
||
|
if (typeof existing === 'function') {
|
||
|
existing = events[type] =
|
||
|
prepend ? [listener, existing] : [existing, listener];
|
||
|
} else {
|
||
|
if (prepend) {
|
||
|
existing.unshift(listener);
|
||
|
} else {
|
||
|
existing.push(listener);
|
||
|
}
|
||
|
}
|
||
|
if (!existing.warned) {
|
||
|
m = $getMaxListeners(target);
|
||
|
if (m && m > 0 && existing.length > m) {
|
||
|
existing.warned = true;
|
||
|
var w = new Error('Possible EventEmitter memory leak detected. ' +
|
||
|
existing.length + ' "' + String(type) + '" listeners ' +
|
||
|
'added. Use emitter.setMaxListeners() to ' +
|
||
|
'increase limit.');
|
||
|
w.name = 'MaxListenersExceededWarning';
|
||
|
w.emitter = target;
|
||
|
w.type = type;
|
||
|
w.count = existing.length;
|
||
|
if (typeof console === 'object' && console.warn) {
|
||
|
console.warn('%s: %s', w.name, w.message);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return target;
|
||
|
}
|
||
|
|
||
|
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
||
|
return _addListener(this, type, listener, false);
|
||
|
};
|
||
|
|
||
|
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
||
|
|
||
|
EventEmitter.prototype.prependListener =
|
||
|
function prependListener(type, listener) {
|
||
|
return _addListener(this, type, listener, true);
|
||
|
};
|
||
|
|
||
|
function onceWrapper() {
|
||
|
if (!this.fired) {
|
||
|
this.target.removeListener(this.type, this.wrapFn);
|
||
|
this.fired = true;
|
||
|
switch (arguments.length) {
|
||
|
case 0:
|
||
|
return this.listener.call(this.target);
|
||
|
case 1:
|
||
|
return this.listener.call(this.target, arguments[0]);
|
||
|
case 2:
|
||
|
return this.listener.call(this.target, arguments[0], arguments[1]);
|
||
|
case 3:
|
||
|
return this.listener.call(this.target, arguments[0], arguments[1],
|
||
|
arguments[2]);
|
||
|
default:
|
||
|
var args = new Array(arguments.length);
|
||
|
for (var i = 0; i < args.length; ++i)
|
||
|
args[i] = arguments[i];
|
||
|
this.listener.apply(this.target, args);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function _onceWrap(target, type, listener) {
|
||
|
var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
|
||
|
var wrapped = bind.call(onceWrapper, state);
|
||
|
wrapped.listener = listener;
|
||
|
state.wrapFn = wrapped;
|
||
|
return wrapped;
|
||
|
}
|
||
|
|
||
|
EventEmitter.prototype.once = function once(type, listener) {
|
||
|
if (typeof listener !== 'function')
|
||
|
throw new TypeError('"listener" argument must be a function');
|
||
|
this.on(type, _onceWrap(this, type, listener));
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
EventEmitter.prototype.prependOnceListener =
|
||
|
function prependOnceListener(type, listener) {
|
||
|
if (typeof listener !== 'function')
|
||
|
throw new TypeError('"listener" argument must be a function');
|
||
|
this.prependListener(type, _onceWrap(this, type, listener));
|
||
|
return this;
|
||
|
};
|
||
|
EventEmitter.prototype.removeListener =
|
||
|
function removeListener(type, listener) {
|
||
|
var list, events, position, i, originalListener;
|
||
|
|
||
|
if (typeof listener !== 'function')
|
||
|
throw new TypeError('"listener" argument must be a function');
|
||
|
|
||
|
events = this._events;
|
||
|
if (!events)
|
||
|
return this;
|
||
|
|
||
|
list = events[type];
|
||
|
if (!list)
|
||
|
return this;
|
||
|
|
||
|
if (list === listener || list.listener === listener) {
|
||
|
if (--this._eventsCount === 0)
|
||
|
this._events = objectCreate(null);
|
||
|
else {
|
||
|
delete events[type];
|
||
|
if (events.removeListener)
|
||
|
this.emit('removeListener', type, list.listener || listener);
|
||
|
}
|
||
|
} else if (typeof list !== 'function') {
|
||
|
position = -1;
|
||
|
|
||
|
for (i = list.length - 1; i >= 0; i--) {
|
||
|
if (list[i] === listener || list[i].listener === listener) {
|
||
|
originalListener = list[i].listener;
|
||
|
position = i;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (position < 0)
|
||
|
return this;
|
||
|
|
||
|
if (position === 0)
|
||
|
list.shift();
|
||
|
else
|
||
|
spliceOne(list, position);
|
||
|
|
||
|
if (list.length === 1)
|
||
|
events[type] = list[0];
|
||
|
|
||
|
if (events.removeListener)
|
||
|
this.emit('removeListener', type, originalListener || listener);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
EventEmitter.prototype.removeAllListeners =
|
||
|
function removeAllListeners(type) {
|
||
|
var listeners, events, i;
|
||
|
|
||
|
events = this._events;
|
||
|
if (!events)
|
||
|
return this;
|
||
|
if (!events.removeListener) {
|
||
|
if (arguments.length === 0) {
|
||
|
this._events = objectCreate(null);
|
||
|
this._eventsCount = 0;
|
||
|
} else if (events[type]) {
|
||
|
if (--this._eventsCount === 0)
|
||
|
this._events = objectCreate(null);
|
||
|
else
|
||
|
delete events[type];
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
if (arguments.length === 0) {
|
||
|
var keys = objectKeys(events);
|
||
|
var key;
|
||
|
for (i = 0; i < keys.length; ++i) {
|
||
|
key = keys[i];
|
||
|
if (key === 'removeListener') continue;
|
||
|
this.removeAllListeners(key);
|
||
|
}
|
||
|
this.removeAllListeners('removeListener');
|
||
|
this._events = objectCreate(null);
|
||
|
this._eventsCount = 0;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
listeners = events[type];
|
||
|
|
||
|
if (typeof listeners === 'function') {
|
||
|
this.removeListener(type, listeners);
|
||
|
} else if (listeners) {
|
||
|
for (i = listeners.length - 1; i >= 0; i--) {
|
||
|
this.removeListener(type, listeners[i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
function _listeners(target, type, unwrap) {
|
||
|
var events = target._events;
|
||
|
|
||
|
if (!events)
|
||
|
return [];
|
||
|
|
||
|
var evlistener = events[type];
|
||
|
if (!evlistener)
|
||
|
return [];
|
||
|
|
||
|
if (typeof evlistener === 'function')
|
||
|
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
|
||
|
|
||
|
return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
||
|
}
|
||
|
|
||
|
EventEmitter.prototype.listeners = function listeners(type) {
|
||
|
return _listeners(this, type, true);
|
||
|
};
|
||
|
|
||
|
EventEmitter.prototype.rawListeners = function rawListeners(type) {
|
||
|
return _listeners(this, type, false);
|
||
|
};
|
||
|
|
||
|
EventEmitter.listenerCount = function(emitter, type) {
|
||
|
if (typeof emitter.listenerCount === 'function') {
|
||
|
return emitter.listenerCount(type);
|
||
|
} else {
|
||
|
return listenerCount.call(emitter, type);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
EventEmitter.prototype.listenerCount = listenerCount;
|
||
|
function listenerCount(type) {
|
||
|
var events = this._events;
|
||
|
|
||
|
if (events) {
|
||
|
var evlistener = events[type];
|
||
|
|
||
|
if (typeof evlistener === 'function') {
|
||
|
return 1;
|
||
|
} else if (evlistener) {
|
||
|
return evlistener.length;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
EventEmitter.prototype.eventNames = function eventNames() {
|
||
|
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
||
|
};
|
||
|
function spliceOne(list, index) {
|
||
|
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
|
||
|
list[i] = list[k];
|
||
|
list.pop();
|
||
|
}
|
||
|
|
||
|
function arrayClone(arr, n) {
|
||
|
var copy = new Array(n);
|
||
|
for (var i = 0; i < n; ++i)
|
||
|
copy[i] = arr[i];
|
||
|
return copy;
|
||
|
}
|
||
|
|
||
|
function unwrapListeners(arr) {
|
||
|
var ret = new Array(arr.length);
|
||
|
for (var i = 0; i < ret.length; ++i) {
|
||
|
ret[i] = arr[i].listener || arr[i];
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
function objectCreatePolyfill(proto) {
|
||
|
var F = function() {};
|
||
|
F.prototype = proto;
|
||
|
return new F;
|
||
|
}
|
||
|
function objectKeysPolyfill(obj) {
|
||
|
var keys = [];
|
||
|
for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
||
|
keys.push(k);
|
||
|
}
|
||
|
return k;
|
||
|
}
|
||
|
function functionBindPolyfill(context) {
|
||
|
var fn = this;
|
||
|
return function () {
|
||
|
return fn.apply(context, arguments);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
},{}],"/../node_modules/object-assign/index.js":[function(_dereq_,module,exports){
|
||
|
|
||
|
'use strict';
|
||
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||
|
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
||
|
|
||
|
function toObject(val) {
|
||
|
if (val === null || val === undefined) {
|
||
|
throw new TypeError('Object.assign cannot be called with null or undefined');
|
||
|
}
|
||
|
|
||
|
return Object(val);
|
||
|
}
|
||
|
|
||
|
function shouldUseNative() {
|
||
|
try {
|
||
|
if (!Object.assign) {
|
||
|
return false;
|
||
|
}
|
||
|
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
||
|
test1[5] = 'de';
|
||
|
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
||
|
return false;
|
||
|
}
|
||
|
var test2 = {};
|
||
|
for (var i = 0; i < 10; i++) {
|
||
|
test2['_' + String.fromCharCode(i)] = i;
|
||
|
}
|
||
|
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
||
|
return test2[n];
|
||
|
});
|
||
|
if (order2.join('') !== '0123456789') {
|
||
|
return false;
|
||
|
}
|
||
|
var test3 = {};
|
||
|
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
||
|
test3[letter] = letter;
|
||
|
});
|
||
|
if (Object.keys(Object.assign({}, test3)).join('') !==
|
||
|
'abcdefghijklmnopqrst') {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
} catch (err) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
||
|
var from;
|
||
|
var to = toObject(target);
|
||
|
var symbols;
|
||
|
|
||
|
for (var s = 1; s < arguments.length; s++) {
|
||
|
from = Object(arguments[s]);
|
||
|
|
||
|
for (var key in from) {
|
||
|
if (hasOwnProperty.call(from, key)) {
|
||
|
to[key] = from[key];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (getOwnPropertySymbols) {
|
||
|
symbols = getOwnPropertySymbols(from);
|
||
|
for (var i = 0; i < symbols.length; i++) {
|
||
|
if (propIsEnumerable.call(from, symbols[i])) {
|
||
|
to[symbols[i]] = from[symbols[i]];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return to;
|
||
|
};
|
||
|
|
||
|
},{}],"/../node_modules/process/browser.js":[function(_dereq_,module,exports){
|
||
|
var process = module.exports = {};
|
||
|
|
||
|
var cachedSetTimeout;
|
||
|
var cachedClearTimeout;
|
||
|
|
||
|
function defaultSetTimout() {
|
||
|
throw new Error('setTimeout has not been defined');
|
||
|
}
|
||
|
function defaultClearTimeout () {
|
||
|
throw new Error('clearTimeout has not been defined');
|
||
|
}
|
||
|
(function () {
|
||
|
try {
|
||
|
if (typeof setTimeout === 'function') {
|
||
|
cachedSetTimeout = setTimeout;
|
||
|
} else {
|
||
|
cachedSetTimeout = defaultSetTimout;
|
||
|
}
|
||
|
} catch (e) {
|
||
|
cachedSetTimeout = defaultSetTimout;
|
||
|
}
|
||
|
try {
|
||
|
if (typeof clearTimeout === 'function') {
|
||
|
cachedClearTimeout = clearTimeout;
|
||
|
} else {
|
||
|
cachedClearTimeout = defaultClearTimeout;
|
||
|
}
|
||
|
} catch (e) {
|
||
|
cachedClearTimeout = defaultClearTimeout;
|
||
|
}
|
||
|
} ())
|
||
|
function runTimeout(fun) {
|
||
|
if (cachedSetTimeout === setTimeout) {
|
||
|
return setTimeout(fun, 0);
|
||
|
}
|
||
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
||
|
cachedSetTimeout = setTimeout;
|
||
|
return setTimeout(fun, 0);
|
||
|
}
|
||
|
try {
|
||
|
return cachedSetTimeout(fun, 0);
|
||
|
} catch(e){
|
||
|
try {
|
||
|
return cachedSetTimeout.call(null, fun, 0);
|
||
|
} catch(e){
|
||
|
return cachedSetTimeout.call(this, fun, 0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
function runClearTimeout(marker) {
|
||
|
if (cachedClearTimeout === clearTimeout) {
|
||
|
return clearTimeout(marker);
|
||
|
}
|
||
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
||
|
cachedClearTimeout = clearTimeout;
|
||
|
return clearTimeout(marker);
|
||
|
}
|
||
|
try {
|
||
|
return cachedClearTimeout(marker);
|
||
|
} catch (e){
|
||
|
try {
|
||
|
return cachedClearTimeout.call(null, marker);
|
||
|
} catch (e){
|
||
|
return cachedClearTimeout.call(this, marker);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
var queue = [];
|
||
|
var draining = false;
|
||
|
var currentQueue;
|
||
|
var queueIndex = -1;
|
||
|
|
||
|
function cleanUpNextTick() {
|
||
|
if (!draining || !currentQueue) {
|
||
|
return;
|
||
|
}
|
||
|
draining = false;
|
||
|
if (currentQueue.length) {
|
||
|
queue = currentQueue.concat(queue);
|
||
|
} else {
|
||
|
queueIndex = -1;
|
||
|
}
|
||
|
if (queue.length) {
|
||
|
drainQueue();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function drainQueue() {
|
||
|
if (draining) {
|
||
|
return;
|
||
|
}
|
||
|
var timeout = runTimeout(cleanUpNextTick);
|
||
|
draining = true;
|
||
|
|
||
|
var len = queue.length;
|
||
|
while(len) {
|
||
|
currentQueue = queue;
|
||
|
queue = [];
|
||
|
while (++queueIndex < len) {
|
||
|
if (currentQueue) {
|
||
|
currentQueue[queueIndex].run();
|
||
|
}
|
||
|
}
|
||
|
queueIndex = -1;
|
||
|
len = queue.length;
|
||
|
}
|
||
|
currentQueue = null;
|
||
|
draining = false;
|
||
|
runClearTimeout(timeout);
|
||
|
}
|
||
|
|
||
|
process.nextTick = function (fun) {
|
||
|
var args = new Array(arguments.length - 1);
|
||
|
if (arguments.length > 1) {
|
||
|
for (var i = 1; i < arguments.length; i++) {
|
||
|
args[i - 1] = arguments[i];
|
||
|
}
|
||
|
}
|
||
|
queue.push(new Item(fun, args));
|
||
|
if (queue.length === 1 && !draining) {
|
||
|
runTimeout(drainQueue);
|
||
|
}
|
||
|
};
|
||
|
function Item(fun, array) {
|
||
|
this.fun = fun;
|
||
|
this.array = array;
|
||
|
}
|
||
|
Item.prototype.run = function () {
|
||
|
this.fun.apply(null, this.array);
|
||
|
};
|
||
|
process.title = 'browser';
|
||
|
process.browser = true;
|
||
|
process.env = {};
|
||
|
process.argv = [];
|
||
|
process.version = ''; // empty string to avoid regexp issues
|
||
|
process.versions = {};
|
||
|
|
||
|
function noop() {}
|
||
|
|
||
|
process.on = noop;
|
||
|
process.addListener = noop;
|
||
|
process.once = noop;
|
||
|
process.off = noop;
|
||
|
process.removeListener = noop;
|
||
|
process.removeAllListeners = noop;
|
||
|
process.emit = noop;
|
||
|
process.prependListener = noop;
|
||
|
process.prependOnceListener = noop;
|
||
|
|
||
|
process.listeners = function (name) { return [] }
|
||
|
|
||
|
process.binding = function (name) {
|
||
|
throw new Error('process.binding is not supported');
|
||
|
};
|
||
|
|
||
|
process.cwd = function () { return '/' };
|
||
|
process.chdir = function (dir) {
|
||
|
throw new Error('process.chdir is not supported');
|
||
|
};
|
||
|
process.umask = function() { return 0; };
|
||
|
|
||
|
},{}],"/../node_modules/util/node_modules/inherits/inherits_browser.js":[function(_dereq_,module,exports){
|
||
|
arguments[4]["/../node_modules/assert/node_modules/inherits/inherits_browser.js"][0].apply(exports,arguments)
|
||
|
},{}],"/../node_modules/util/support/isBufferBrowser.js":[function(_dereq_,module,exports){
|
||
|
arguments[4]["/../node_modules/assert/node_modules/util/support/isBufferBrowser.js"][0].apply(exports,arguments)
|
||
|
},{}],"/../node_modules/util/util.js":[function(_dereq_,module,exports){
|
||
|
arguments[4]["/../node_modules/assert/node_modules/util/util.js"][0].apply(exports,arguments)
|
||
|
},{"./support/isBuffer":"/../node_modules/util/support/isBufferBrowser.js","_process":"/../node_modules/process/browser.js","inherits":"/../node_modules/util/node_modules/inherits/inherits_browser.js"}]},{},["/../../jshint/src/jshint.js"]);
|
||
|
|
||
|
});
|
||
|
|
||
|
define("ace/mode/javascript_worker",[], function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
var oop = require("../lib/oop");
|
||
|
var Mirror = require("../worker/mirror").Mirror;
|
||
|
var lint = require("./javascript/jshint").JSHINT;
|
||
|
|
||
|
function startRegex(arr) {
|
||
|
return RegExp("^(" + arr.join("|") + ")");
|
||
|
}
|
||
|
|
||
|
var disabledWarningsRe = startRegex([
|
||
|
"Bad for in variable '(.+)'.",
|
||
|
'Missing "use strict"'
|
||
|
]);
|
||
|
var errorsRe = startRegex([
|
||
|
"Unexpected",
|
||
|
"Expected ",
|
||
|
"Confusing (plus|minus)",
|
||
|
"\\{a\\} unterminated regular expression",
|
||
|
"Unclosed ",
|
||
|
"Unmatched ",
|
||
|
"Unbegun comment",
|
||
|
"Bad invocation",
|
||
|
"Missing space after",
|
||
|
"Missing operator at"
|
||
|
]);
|
||
|
var infoRe = startRegex([
|
||
|
"Expected an assignment",
|
||
|
"Bad escapement of EOL",
|
||
|
"Unexpected comma",
|
||
|
"Unexpected space",
|
||
|
"Missing radix parameter.",
|
||
|
"A leading decimal point can",
|
||
|
"\\['{a}'\\] is better written in dot notation.",
|
||
|
"'{a}' used out of scope"
|
||
|
]);
|
||
|
|
||
|
var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
|
||
|
Mirror.call(this, sender);
|
||
|
this.setTimeout(500);
|
||
|
this.setOptions();
|
||
|
};
|
||
|
|
||
|
oop.inherits(JavaScriptWorker, Mirror);
|
||
|
|
||
|
(function() {
|
||
|
this.setOptions = function(options) {
|
||
|
this.options = options || {
|
||
|
esnext: true,
|
||
|
moz: true,
|
||
|
devel: true,
|
||
|
browser: true,
|
||
|
node: true,
|
||
|
laxcomma: true,
|
||
|
laxbreak: true,
|
||
|
lastsemic: true,
|
||
|
onevar: false,
|
||
|
passfail: false,
|
||
|
maxerr: 100,
|
||
|
expr: true,
|
||
|
multistr: true,
|
||
|
globalstrict: true
|
||
|
};
|
||
|
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||
|
};
|
||
|
|
||
|
this.changeOptions = function(newOptions) {
|
||
|
oop.mixin(this.options, newOptions);
|
||
|
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||
|
};
|
||
|
|
||
|
this.isValidJS = function(str) {
|
||
|
try {
|
||
|
eval("throw 0;" + str);
|
||
|
} catch(e) {
|
||
|
if (e === 0)
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
};
|
||
|
|
||
|
this.onUpdate = function() {
|
||
|
var value = this.doc.getValue();
|
||
|
value = value.replace(/^#!.*\n/, "\n");
|
||
|
if (!value)
|
||
|
return this.sender.emit("annotate", []);
|
||
|
|
||
|
var errors = [];
|
||
|
var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
|
||
|
lint(value, this.options, this.options.globals);
|
||
|
var results = lint.errors;
|
||
|
|
||
|
var errorAdded = false;
|
||
|
for (var i = 0; i < results.length; i++) {
|
||
|
var error = results[i];
|
||
|
if (!error)
|
||
|
continue;
|
||
|
var raw = error.raw;
|
||
|
var type = "warning";
|
||
|
|
||
|
if (raw == "Missing semicolon.") {
|
||
|
var str = error.evidence.substr(error.character);
|
||
|
str = str.charAt(str.search(/\S/));
|
||
|
if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
|
||
|
error.reason = 'Missing ";" before statement';
|
||
|
type = "error";
|
||
|
} else {
|
||
|
type = "info";
|
||
|
}
|
||
|
}
|
||
|
else if (disabledWarningsRe.test(raw)) {
|
||
|
continue;
|
||
|
}
|
||
|
else if (infoRe.test(raw)) {
|
||
|
type = "info";
|
||
|
}
|
||
|
else if (errorsRe.test(raw)) {
|
||
|
errorAdded = true;
|
||
|
type = maxErrorLevel;
|
||
|
}
|
||
|
else if (raw == "'{a}' is not defined.") {
|
||
|
type = "warning";
|
||
|
}
|
||
|
else if (raw == "'{a}' is defined but never used.") {
|
||
|
type = "info";
|
||
|
}
|
||
|
|
||
|
errors.push({
|
||
|
row: error.line-1,
|
||
|
column: error.character-1,
|
||
|
text: error.reason,
|
||
|
type: type,
|
||
|
raw: raw
|
||
|
});
|
||
|
|
||
|
if (errorAdded) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.sender.emit("annotate", errors);
|
||
|
};
|
||
|
|
||
|
}).call(JavaScriptWorker.prototype);
|
||
|
|
||
|
});
|