3 if (typeof window.window != "undefined" && window.document)
5 if (window.require && window.define)
9 window.console = function() {
10 var msgs = Array.prototype.slice.call(arguments, 0);
11 postMessage({type: "log", data: msgs});
13 window.console.error =
16 window.console.trace = window.console;
18 window.window = window;
21 window.onerror = function(message, file, line, col, err) {
22 postMessage({type: "error", data: {
32 window.normalizeModule = function(parentId, moduleName) {
33 // normalize plugin requires
34 if (moduleName.indexOf("!") !== -1) {
35 var chunks = moduleName.split("!");
36 return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
38 // normalize relative requires
39 if (moduleName.charAt(0) == ".") {
40 var base = parentId.split("/").slice(0, -1).join("/");
41 moduleName = (base ? base + "/" : "") + moduleName;
43 while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
44 var previous = moduleName;
45 moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
52 window.require = function require(parentId, id) {
58 throw new Error("worker.js require() accepts only (parentId, id) as arguments");
60 id = window.normalizeModule(parentId, id);
62 var module = window.require.modules[id];
64 if (!module.initialized) {
65 module.initialized = true;
66 module.exports = module.factory().exports;
68 return module.exports;
71 if (!window.require.tlns)
72 return console.log("unable to load " + id);
74 var path = resolveModuleId(id, window.require.tlns);
75 if (path.slice(-3) != ".js") path += ".js";
77 window.require.id = id;
78 window.require.modules[id] = {}; // prevent infinite loop on broken modules
80 return window.require(parentId, id);
82 function resolveModuleId(id, paths) {
83 var testPath = id, tail = "";
85 var alias = paths[testPath];
86 if (typeof alias == "string") {
89 return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
90 } else if (alias === false) {
93 var i = testPath.lastIndexOf("/");
95 tail = testPath.substr(i) + tail;
96 testPath = testPath.slice(0, i);
100 window.require.modules = {};
101 window.require.tlns = {};
103 window.define = function(id, deps, factory) {
104 if (arguments.length == 2) {
106 if (typeof id != "string") {
108 id = window.require.id;
110 } else if (arguments.length == 1) {
113 id = window.require.id;
116 if (typeof factory != "function") {
117 window.require.modules[id] = {
125 // If there is no dependencies, we inject "require", "exports" and
126 // "module" as dependencies, to provide CommonJS compatibility.
127 deps = ["require", "exports", "module"];
129 var req = function(childId) {
130 return window.require(id, childId);
133 window.require.modules[id] = {
135 factory: function() {
137 var returnExports = factory.apply(this, deps.map(function(dep) {
139 // Because "require", "exports" and "module" aren't actual
140 // dependencies, we must handle them seperately.
141 case "require": return req;
142 case "exports": return module.exports;
143 case "module": return module;
144 // But for all other dependencies, we can just go ahead and
146 default: return req(dep);
150 module.exports = returnExports;
155 window.define.amd = {};
157 window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
158 for (var i in topLevelNamespaces)
159 require.tlns[i] = topLevelNamespaces[i];
162 window.initSender = function initSender() {
164 var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
165 var oop = window.require("ace/lib/oop");
167 var Sender = function() {};
171 oop.implement(this, EventEmitter);
173 this.callback = function(data, callbackId) {
181 this.emit = function(name, data) {
189 }).call(Sender.prototype);
194 var main = window.main = null;
195 var sender = window.sender = null;
197 window.onmessage = function(e) {
199 if (msg.event && sender) {
200 sender._signal(msg.event, msg.data);
202 else if (msg.command) {
203 if (main[msg.command])
204 main[msg.command].apply(main, msg.args);
205 else if (window[msg.command])
206 window[msg.command].apply(window, msg.args);
208 throw new Error("Unknown command:" + msg.command);
211 window.initBaseUrls(msg.tlns);
212 require("ace/lib/es5-shim");
213 sender = window.sender = window.initSender();
214 var clazz = require(msg.module)[msg.classname];
215 main = window.main = new clazz(sender);
220 define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
223 exports.inherits = function(ctor, superCtor) {
224 ctor.super_ = superCtor;
225 ctor.prototype = Object.create(superCtor.prototype, {
235 exports.mixin = function(obj, mixin) {
236 for (var key in mixin) {
237 obj[key] = mixin[key];
242 exports.implement = function(proto, mixin) {
243 exports.mixin(proto, mixin);
248 define("ace/range",["require","exports","module"], function(require, exports, module) {
250 var comparePoints = function(p1, p2) {
251 return p1.row - p2.row || p1.column - p2.column;
253 var Range = function(startRow, startColumn, endRow, endColumn) {
266 this.isEqual = function(range) {
267 return this.start.row === range.start.row &&
268 this.end.row === range.end.row &&
269 this.start.column === range.start.column &&
270 this.end.column === range.end.column;
272 this.toString = function() {
273 return ("Range: [" + this.start.row + "/" + this.start.column +
274 "] -> [" + this.end.row + "/" + this.end.column + "]");
277 this.contains = function(row, column) {
278 return this.compare(row, column) == 0;
280 this.compareRange = function(range) {
285 cmp = this.compare(end.row, end.column);
287 cmp = this.compare(start.row, start.column);
290 } else if (cmp == 0) {
295 } else if (cmp == -1) {
298 cmp = this.compare(start.row, start.column);
301 } else if (cmp == 1) {
308 this.comparePoint = function(p) {
309 return this.compare(p.row, p.column);
311 this.containsRange = function(range) {
312 return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
314 this.intersects = function(range) {
315 var cmp = this.compareRange(range);
316 return (cmp == -1 || cmp == 0 || cmp == 1);
318 this.isEnd = function(row, column) {
319 return this.end.row == row && this.end.column == column;
321 this.isStart = function(row, column) {
322 return this.start.row == row && this.start.column == column;
324 this.setStart = function(row, column) {
325 if (typeof row == "object") {
326 this.start.column = row.column;
327 this.start.row = row.row;
329 this.start.row = row;
330 this.start.column = column;
333 this.setEnd = function(row, column) {
334 if (typeof row == "object") {
335 this.end.column = row.column;
336 this.end.row = row.row;
339 this.end.column = column;
342 this.inside = function(row, column) {
343 if (this.compare(row, column) == 0) {
344 if (this.isEnd(row, column) || this.isStart(row, column)) {
352 this.insideStart = function(row, column) {
353 if (this.compare(row, column) == 0) {
354 if (this.isEnd(row, column)) {
362 this.insideEnd = function(row, column) {
363 if (this.compare(row, column) == 0) {
364 if (this.isStart(row, column)) {
372 this.compare = function(row, column) {
373 if (!this.isMultiLine()) {
374 if (row === this.start.row) {
375 return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
379 if (row < this.start.row)
382 if (row > this.end.row)
385 if (this.start.row === row)
386 return column >= this.start.column ? 0 : -1;
388 if (this.end.row === row)
389 return column <= this.end.column ? 0 : 1;
393 this.compareStart = function(row, column) {
394 if (this.start.row == row && this.start.column == column) {
397 return this.compare(row, column);
400 this.compareEnd = function(row, column) {
401 if (this.end.row == row && this.end.column == column) {
404 return this.compare(row, column);
407 this.compareInside = function(row, column) {
408 if (this.end.row == row && this.end.column == column) {
410 } else if (this.start.row == row && this.start.column == column) {
413 return this.compare(row, column);
416 this.clipRows = function(firstRow, lastRow) {
417 if (this.end.row > lastRow)
418 var end = {row: lastRow + 1, column: 0};
419 else if (this.end.row < firstRow)
420 var end = {row: firstRow, column: 0};
422 if (this.start.row > lastRow)
423 var start = {row: lastRow + 1, column: 0};
424 else if (this.start.row < firstRow)
425 var start = {row: firstRow, column: 0};
427 return Range.fromPoints(start || this.start, end || this.end);
429 this.extend = function(row, column) {
430 var cmp = this.compare(row, column);
435 var start = {row: row, column: column};
437 var end = {row: row, column: column};
439 return Range.fromPoints(start || this.start, end || this.end);
442 this.isEmpty = function() {
443 return (this.start.row === this.end.row && this.start.column === this.end.column);
445 this.isMultiLine = function() {
446 return (this.start.row !== this.end.row);
448 this.clone = function() {
449 return Range.fromPoints(this.start, this.end);
451 this.collapseRows = function() {
452 if (this.end.column == 0)
453 return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
455 return new Range(this.start.row, 0, this.end.row, 0);
457 this.toScreenRange = function(session) {
458 var screenPosStart = session.documentToScreenPosition(this.start);
459 var screenPosEnd = session.documentToScreenPosition(this.end);
462 screenPosStart.row, screenPosStart.column,
463 screenPosEnd.row, screenPosEnd.column
466 this.moveBy = function(row, column) {
467 this.start.row += row;
468 this.start.column += column;
470 this.end.column += column;
473 }).call(Range.prototype);
474 Range.fromPoints = function(start, end) {
475 return new Range(start.row, start.column, end.row, end.column);
477 Range.comparePoints = comparePoints;
479 Range.comparePoints = function(p1, p2) {
480 return p1.row - p2.row || p1.column - p2.column;
484 exports.Range = Range;
487 define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
490 function throwDeltaError(delta, errorText){
491 console.log("Invalid Delta:", delta);
492 throw "Invalid Delta: " + errorText;
495 function positionInDocument(docLines, position) {
496 return position.row >= 0 && position.row < docLines.length &&
497 position.column >= 0 && position.column <= docLines[position.row].length;
500 function validateDelta(docLines, delta) {
501 if (delta.action != "insert" && delta.action != "remove")
502 throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
503 if (!(delta.lines instanceof Array))
504 throwDeltaError(delta, "delta.lines must be an Array");
505 if (!delta.start || !delta.end)
506 throwDeltaError(delta, "delta.start/end must be an present");
507 var start = delta.start;
508 if (!positionInDocument(docLines, delta.start))
509 throwDeltaError(delta, "delta.start must be contained in document");
511 if (delta.action == "remove" && !positionInDocument(docLines, end))
512 throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
513 var numRangeRows = end.row - start.row;
514 var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
515 if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
516 throwDeltaError(delta, "delta.range must match delta lines");
519 exports.applyDelta = function(docLines, delta, doNotValidate) {
521 var row = delta.start.row;
522 var startColumn = delta.start.column;
523 var line = docLines[row] || "";
524 switch (delta.action) {
526 var lines = delta.lines;
527 if (lines.length === 1) {
528 docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
530 var args = [row, 1].concat(delta.lines);
531 docLines.splice.apply(docLines, args);
532 docLines[row] = line.substring(0, startColumn) + docLines[row];
533 docLines[row + delta.lines.length - 1] += line.substring(startColumn);
537 var endColumn = delta.end.column;
538 var endRow = delta.end.row;
539 if (row === endRow) {
540 docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
543 row, endRow - row + 1,
544 line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
552 define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
555 var EventEmitter = {};
556 var stopPropagation = function() { this.propagationStopped = true; };
557 var preventDefault = function() { this.defaultPrevented = true; };
560 EventEmitter._dispatchEvent = function(eventName, e) {
561 this._eventRegistry || (this._eventRegistry = {});
562 this._defaultHandlers || (this._defaultHandlers = {});
564 var listeners = this._eventRegistry[eventName] || [];
565 var defaultHandler = this._defaultHandlers[eventName];
566 if (!listeners.length && !defaultHandler)
569 if (typeof e != "object" || !e)
574 if (!e.stopPropagation)
575 e.stopPropagation = stopPropagation;
576 if (!e.preventDefault)
577 e.preventDefault = preventDefault;
579 listeners = listeners.slice();
580 for (var i=0; i<listeners.length; i++) {
581 listeners[i](e, this);
582 if (e.propagationStopped)
586 if (defaultHandler && !e.defaultPrevented)
587 return defaultHandler(e, this);
591 EventEmitter._signal = function(eventName, e) {
592 var listeners = (this._eventRegistry || {})[eventName];
595 listeners = listeners.slice();
596 for (var i=0; i<listeners.length; i++)
597 listeners[i](e, this);
600 EventEmitter.once = function(eventName, callback) {
602 callback && this.addEventListener(eventName, function newCallback() {
603 _self.removeEventListener(eventName, newCallback);
604 callback.apply(null, arguments);
609 EventEmitter.setDefaultHandler = function(eventName, callback) {
610 var handlers = this._defaultHandlers;
612 handlers = this._defaultHandlers = {_disabled_: {}};
614 if (handlers[eventName]) {
615 var old = handlers[eventName];
616 var disabled = handlers._disabled_[eventName];
618 handlers._disabled_[eventName] = disabled = [];
620 var i = disabled.indexOf(callback);
622 disabled.splice(i, 1);
624 handlers[eventName] = callback;
626 EventEmitter.removeDefaultHandler = function(eventName, callback) {
627 var handlers = this._defaultHandlers;
630 var disabled = handlers._disabled_[eventName];
632 if (handlers[eventName] == callback) {
633 var old = handlers[eventName];
635 this.setDefaultHandler(eventName, disabled.pop());
636 } else if (disabled) {
637 var i = disabled.indexOf(callback);
639 disabled.splice(i, 1);
644 EventEmitter.addEventListener = function(eventName, callback, capturing) {
645 this._eventRegistry = this._eventRegistry || {};
647 var listeners = this._eventRegistry[eventName];
649 listeners = this._eventRegistry[eventName] = [];
651 if (listeners.indexOf(callback) == -1)
652 listeners[capturing ? "unshift" : "push"](callback);
657 EventEmitter.removeListener =
658 EventEmitter.removeEventListener = function(eventName, callback) {
659 this._eventRegistry = this._eventRegistry || {};
661 var listeners = this._eventRegistry[eventName];
665 var index = listeners.indexOf(callback);
667 listeners.splice(index, 1);
670 EventEmitter.removeAllListeners = function(eventName) {
671 if (this._eventRegistry) this._eventRegistry[eventName] = [];
674 exports.EventEmitter = EventEmitter;
678 define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
681 var oop = require("./lib/oop");
682 var EventEmitter = require("./lib/event_emitter").EventEmitter;
684 var Anchor = exports.Anchor = function(doc, row, column) {
685 this.$onChange = this.onChange.bind(this);
688 if (typeof column == "undefined")
689 this.setPosition(row.row, row.column);
691 this.setPosition(row, column);
696 oop.implement(this, EventEmitter);
697 this.getPosition = function() {
698 return this.$clipPositionToDocument(this.row, this.column);
700 this.getDocument = function() {
701 return this.document;
703 this.$insertRight = false;
704 this.onChange = function(delta) {
705 if (delta.start.row == delta.end.row && delta.start.row != this.row)
708 if (delta.start.row > this.row)
711 var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
712 this.setPosition(point.row, point.column, true);
715 function $pointsInOrder(point1, point2, equalPointsInOrder) {
716 var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
717 return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
720 function $getTransformedPoint(delta, point, moveIfEqual) {
721 var deltaIsInsert = delta.action == "insert";
722 var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
723 var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
724 var deltaStart = delta.start;
725 var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
726 if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
732 if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
734 row: point.row + deltaRowShift,
735 column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
741 column: deltaStart.column
744 this.setPosition = function(row, column, noClip) {
752 pos = this.$clipPositionToDocument(row, column);
755 if (this.row == pos.row && this.column == pos.column)
764 this.column = pos.column;
765 this._signal("change", {
770 this.detach = function() {
771 this.document.removeEventListener("change", this.$onChange);
773 this.attach = function(doc) {
774 this.document = doc || this.document;
775 this.document.on("change", this.$onChange);
777 this.$clipPositionToDocument = function(row, column) {
780 if (row >= this.document.getLength()) {
781 pos.row = Math.max(0, this.document.getLength() - 1);
782 pos.column = this.document.getLine(pos.row).length;
790 pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
799 }).call(Anchor.prototype);
803 define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
806 var oop = require("./lib/oop");
807 var applyDelta = require("./apply_delta").applyDelta;
808 var EventEmitter = require("./lib/event_emitter").EventEmitter;
809 var Range = require("./range").Range;
810 var Anchor = require("./anchor").Anchor;
812 var Document = function(textOrLines) {
814 if (textOrLines.length === 0) {
816 } else if (Array.isArray(textOrLines)) {
817 this.insertMergedLines({row: 0, column: 0}, textOrLines);
819 this.insert({row: 0, column:0}, textOrLines);
825 oop.implement(this, EventEmitter);
826 this.setValue = function(text) {
827 var len = this.getLength() - 1;
828 this.remove(new Range(0, 0, len, this.getLine(len).length));
829 this.insert({row: 0, column: 0}, text);
831 this.getValue = function() {
832 return this.getAllLines().join(this.getNewLineCharacter());
834 this.createAnchor = function(row, column) {
835 return new Anchor(this, row, column);
837 if ("aaa".split(/a/).length === 0) {
838 this.$split = function(text) {
839 return text.replace(/\r\n|\r/g, "\n").split("\n");
842 this.$split = function(text) {
843 return text.split(/\r\n|\r|\n/);
848 this.$detectNewLine = function(text) {
849 var match = text.match(/^.*?(\r\n|\r|\n)/m);
850 this.$autoNewLine = match ? match[1] : "\n";
851 this._signal("changeNewLineMode");
853 this.getNewLineCharacter = function() {
854 switch (this.$newLineMode) {
860 return this.$autoNewLine || "\n";
864 this.$autoNewLine = "";
865 this.$newLineMode = "auto";
866 this.setNewLineMode = function(newLineMode) {
867 if (this.$newLineMode === newLineMode)
870 this.$newLineMode = newLineMode;
871 this._signal("changeNewLineMode");
873 this.getNewLineMode = function() {
874 return this.$newLineMode;
876 this.isNewLine = function(text) {
877 return (text == "\r\n" || text == "\r" || text == "\n");
879 this.getLine = function(row) {
880 return this.$lines[row] || "";
882 this.getLines = function(firstRow, lastRow) {
883 return this.$lines.slice(firstRow, lastRow + 1);
885 this.getAllLines = function() {
886 return this.getLines(0, this.getLength());
888 this.getLength = function() {
889 return this.$lines.length;
891 this.getTextRange = function(range) {
892 return this.getLinesForRange(range).join(this.getNewLineCharacter());
894 this.getLinesForRange = function(range) {
896 if (range.start.row === range.end.row) {
897 lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
899 lines = this.getLines(range.start.row, range.end.row);
900 lines[0] = (lines[0] || "").substring(range.start.column);
901 var l = lines.length - 1;
902 if (range.end.row - range.start.row == l)
903 lines[l] = lines[l].substring(0, range.end.column);
907 this.insertLines = function(row, lines) {
908 console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
909 return this.insertFullLines(row, lines);
911 this.removeLines = function(firstRow, lastRow) {
912 console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
913 return this.removeFullLines(firstRow, lastRow);
915 this.insertNewLine = function(position) {
916 console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
917 return this.insertMergedLines(position, ["", ""]);
919 this.insert = function(position, text) {
920 if (this.getLength() <= 1)
921 this.$detectNewLine(text);
923 return this.insertMergedLines(position, this.$split(text));
925 this.insertInLine = function(position, text) {
926 var start = this.clippedPos(position.row, position.column);
927 var end = this.pos(position.row, position.column + text.length);
936 return this.clonePos(end);
939 this.clippedPos = function(row, column) {
940 var length = this.getLength();
941 if (row === undefined) {
943 } else if (row < 0) {
945 } else if (row >= length) {
949 var line = this.getLine(row);
950 if (column == undefined)
951 column = line.length;
952 column = Math.min(Math.max(column, 0), line.length);
953 return {row: row, column: column};
956 this.clonePos = function(pos) {
957 return {row: pos.row, column: pos.column};
960 this.pos = function(row, column) {
961 return {row: row, column: column};
964 this.$clipPosition = function(position) {
965 var length = this.getLength();
966 if (position.row >= length) {
967 position.row = Math.max(0, length - 1);
968 position.column = this.getLine(length - 1).length;
970 position.row = Math.max(0, position.row);
971 position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
975 this.insertFullLines = function(row, lines) {
976 row = Math.min(Math.max(row, 0), this.getLength());
978 if (row < this.getLength()) {
979 lines = lines.concat([""]);
982 lines = [""].concat(lines);
984 column = this.$lines[row].length;
986 this.insertMergedLines({row: row, column: column}, lines);
988 this.insertMergedLines = function(position, lines) {
989 var start = this.clippedPos(position.row, position.column);
991 row: start.row + lines.length - 1,
992 column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
1002 return this.clonePos(end);
1004 this.remove = function(range) {
1005 var start = this.clippedPos(range.start.row, range.start.column);
1006 var end = this.clippedPos(range.end.row, range.end.column);
1011 lines: this.getLinesForRange({start: start, end: end})
1013 return this.clonePos(start);
1015 this.removeInLine = function(row, startColumn, endColumn) {
1016 var start = this.clippedPos(row, startColumn);
1017 var end = this.clippedPos(row, endColumn);
1023 lines: this.getLinesForRange({start: start, end: end})
1026 return this.clonePos(start);
1028 this.removeFullLines = function(firstRow, lastRow) {
1029 firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
1030 lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
1031 var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
1032 var deleteLastNewLine = lastRow < this.getLength() - 1;
1033 var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
1034 var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
1035 var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
1036 var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
1037 var range = new Range(startRow, startCol, endRow, endCol);
1038 var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
1044 lines: this.getLinesForRange(range)
1046 return deletedLines;
1048 this.removeNewLine = function(row) {
1049 if (row < this.getLength() - 1 && row >= 0) {
1051 start: this.pos(row, this.getLine(row).length),
1052 end: this.pos(row + 1, 0),
1058 this.replace = function(range, text) {
1059 if (!(range instanceof Range))
1060 range = Range.fromPoints(range.start, range.end);
1061 if (text.length === 0 && range.isEmpty())
1063 if (text == this.getTextRange(range))
1069 end = this.insert(range.start, text);
1077 this.applyDeltas = function(deltas) {
1078 for (var i=0; i<deltas.length; i++) {
1079 this.applyDelta(deltas[i]);
1082 this.revertDeltas = function(deltas) {
1083 for (var i=deltas.length-1; i>=0; i--) {
1084 this.revertDelta(deltas[i]);
1087 this.applyDelta = function(delta, doNotValidate) {
1088 var isInsert = delta.action == "insert";
1089 if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
1090 : !Range.comparePoints(delta.start, delta.end)) {
1094 if (isInsert && delta.lines.length > 20000)
1095 this.$splitAndapplyLargeDelta(delta, 20000);
1096 applyDelta(this.$lines, delta, doNotValidate);
1097 this._signal("change", delta);
1100 this.$splitAndapplyLargeDelta = function(delta, MAX) {
1101 var lines = delta.lines;
1102 var l = lines.length;
1103 var row = delta.start.row;
1104 var column = delta.start.column;
1105 var from = 0, to = 0;
1109 var chunk = lines.slice(from, to);
1111 delta.lines = chunk;
1112 delta.start.row = row + from;
1113 delta.start.column = column;
1118 start: this.pos(row + from, column),
1119 end: this.pos(row + to, column = 0),
1120 action: delta.action,
1125 this.revertDelta = function(delta) {
1127 start: this.clonePos(delta.start),
1128 end: this.clonePos(delta.end),
1129 action: (delta.action == "insert" ? "remove" : "insert"),
1130 lines: delta.lines.slice()
1133 this.indexToPosition = function(index, startRow) {
1134 var lines = this.$lines || this.getAllLines();
1135 var newlineLength = this.getNewLineCharacter().length;
1136 for (var i = startRow || 0, l = lines.length; i < l; i++) {
1137 index -= lines[i].length + newlineLength;
1139 return {row: i, column: index + lines[i].length + newlineLength};
1141 return {row: l-1, column: lines[l-1].length};
1143 this.positionToIndex = function(pos, startRow) {
1144 var lines = this.$lines || this.getAllLines();
1145 var newlineLength = this.getNewLineCharacter().length;
1147 var row = Math.min(pos.row, lines.length);
1148 for (var i = startRow || 0; i < row; ++i)
1149 index += lines[i].length + newlineLength;
1151 return index + pos.column;
1154 }).call(Document.prototype);
1156 exports.Document = Document;
1159 define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
1162 exports.last = function(a) {
1163 return a[a.length - 1];
1166 exports.stringReverse = function(string) {
1167 return string.split("").reverse().join("");
1170 exports.stringRepeat = function (string, count) {
1182 var trimBeginRegexp = /^\s\s*/;
1183 var trimEndRegexp = /\s\s*$/;
1185 exports.stringTrimLeft = function (string) {
1186 return string.replace(trimBeginRegexp, '');
1189 exports.stringTrimRight = function (string) {
1190 return string.replace(trimEndRegexp, '');
1193 exports.copyObject = function(obj) {
1195 for (var key in obj) {
1196 copy[key] = obj[key];
1201 exports.copyArray = function(array){
1203 for (var i=0, l=array.length; i<l; i++) {
1204 if (array[i] && typeof array[i] == "object")
1205 copy[i] = this.copyObject(array[i]);
1212 exports.deepCopy = function deepCopy(obj) {
1213 if (typeof obj !== "object" || !obj)
1216 if (Array.isArray(obj)) {
1218 for (var key = 0; key < obj.length; key++) {
1219 copy[key] = deepCopy(obj[key]);
1223 if (Object.prototype.toString.call(obj) !== "[object Object]")
1227 for (var key in obj)
1228 copy[key] = deepCopy(obj[key]);
1232 exports.arrayToMap = function(arr) {
1234 for (var i=0; i<arr.length; i++) {
1241 exports.createMap = function(props) {
1242 var map = Object.create(null);
1243 for (var i in props) {
1248 exports.arrayRemove = function(array, value) {
1249 for (var i = 0; i <= array.length; i++) {
1250 if (value === array[i]) {
1256 exports.escapeRegExp = function(str) {
1257 return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
1260 exports.escapeHTML = function(str) {
1261 return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
1264 exports.getMatchOffsets = function(string, regExp) {
1267 string.replace(regExp, function(str) {
1269 offset: arguments[arguments.length-2],
1276 exports.deferredCall = function(fcn) {
1278 var callback = function() {
1283 var deferred = function(timeout) {
1285 timer = setTimeout(callback, timeout || 0);
1289 deferred.schedule = deferred;
1291 deferred.call = function() {
1297 deferred.cancel = function() {
1298 clearTimeout(timer);
1303 deferred.isPending = function() {
1311 exports.delayedCall = function(fcn, defaultTimeout) {
1313 var callback = function() {
1318 var _self = function(timeout) {
1320 timer = setTimeout(callback, timeout || defaultTimeout);
1323 _self.delay = function(timeout) {
1324 timer && clearTimeout(timer);
1325 timer = setTimeout(callback, timeout || defaultTimeout);
1327 _self.schedule = _self;
1329 _self.call = function() {
1334 _self.cancel = function() {
1335 timer && clearTimeout(timer);
1339 _self.isPending = function() {
1347 define("ace/worker/mirror",["require","exports","module","ace/range","ace/document","ace/lib/lang"], function(require, exports, module) {
1350 var Range = require("../range").Range;
1351 var Document = require("../document").Document;
1352 var lang = require("../lib/lang");
1354 var Mirror = exports.Mirror = function(sender) {
1355 this.sender = sender;
1356 var doc = this.doc = new Document("");
1358 var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1361 sender.on("change", function(e) {
1363 if (data[0].start) {
1364 doc.applyDeltas(data);
1366 for (var i = 0; i < data.length; i += 2) {
1367 if (Array.isArray(data[i+1])) {
1368 var d = {action: "insert", start: data[i], lines: data[i+1]};
1370 var d = {action: "remove", start: data[i], end: data[i+1]};
1372 doc.applyDelta(d, true);
1376 return deferredUpdate.schedule(_self.$timeout);
1383 this.$timeout = 500;
1385 this.setTimeout = function(timeout) {
1386 this.$timeout = timeout;
1389 this.setValue = function(value) {
1390 this.doc.setValue(value);
1391 this.deferredUpdate.schedule(this.$timeout);
1394 this.getValue = function(callbackId) {
1395 this.sender.callback(this.doc.getValue(), callbackId);
1398 this.onUpdate = function() {
1401 this.isPending = function() {
1402 return this.deferredUpdate.isPending();
1405 }).call(Mirror.prototype);
1409 define("ace/mode/javascript/jshint",["require","exports","module"], function(require, exports, module) {
1410 module.exports = (function outer (modules, cache, entry) {
1411 var previousRequire = typeof require == "function" && require;
1412 function newRequire(name, jumped){
1414 if(!modules[name]) {
1415 var currentRequire = typeof require == "function" && require;
1416 if (!jumped && currentRequire) return currentRequire(name, true);
1417 if (previousRequire) return previousRequire(name, true);
1418 var err = new Error('Cannot find module \'' + name + '\'');
1419 err.code = 'MODULE_NOT_FOUND';
1422 var m = cache[name] = {exports:{}};
1423 modules[name][0].call(m.exports, function(x){
1424 var id = modules[name][1][x];
1425 return newRequire(id ? id : x);
1426 },m,m.exports,outer,modules,cache,entry);
1428 return cache[name].exports;
1430 for(var i=0;i<entry.length;i++) newRequire(entry[i]);
1431 return newRequire(entry[0]);
1433 ({"/node_modules/browserify/node_modules/events/events.js":[function(_dereq_,module,exports){
1435 function EventEmitter() {
1436 this._events = this._events || {};
1437 this._maxListeners = this._maxListeners || undefined;
1439 module.exports = EventEmitter;
1440 EventEmitter.EventEmitter = EventEmitter;
1442 EventEmitter.prototype._events = undefined;
1443 EventEmitter.prototype._maxListeners = undefined;
1444 EventEmitter.defaultMaxListeners = 10;
1445 EventEmitter.prototype.setMaxListeners = function(n) {
1446 if (!isNumber(n) || n < 0 || isNaN(n))
1447 throw TypeError('n must be a positive number');
1448 this._maxListeners = n;
1452 EventEmitter.prototype.emit = function(type) {
1453 var er, handler, len, args, i, listeners;
1457 if (type === 'error') {
1458 if (!this._events.error ||
1459 (isObject(this._events.error) && !this._events.error.length)) {
1461 if (er instanceof Error) {
1462 throw er; // Unhandled 'error' event
1464 throw TypeError('Uncaught, unspecified "error" event.');
1468 handler = this._events[type];
1470 if (isUndefined(handler))
1473 if (isFunction(handler)) {
1474 switch (arguments.length) {
1479 handler.call(this, arguments[1]);
1482 handler.call(this, arguments[1], arguments[2]);
1485 len = arguments.length;
1486 args = new Array(len - 1);
1487 for (i = 1; i < len; i++)
1488 args[i - 1] = arguments[i];
1489 handler.apply(this, args);
1491 } else if (isObject(handler)) {
1492 len = arguments.length;
1493 args = new Array(len - 1);
1494 for (i = 1; i < len; i++)
1495 args[i - 1] = arguments[i];
1497 listeners = handler.slice();
1498 len = listeners.length;
1499 for (i = 0; i < len; i++)
1500 listeners[i].apply(this, args);
1506 EventEmitter.prototype.addListener = function(type, listener) {
1509 if (!isFunction(listener))
1510 throw TypeError('listener must be a function');
1514 if (this._events.newListener)
1515 this.emit('newListener', type,
1516 isFunction(listener.listener) ?
1517 listener.listener : listener);
1519 if (!this._events[type])
1520 this._events[type] = listener;
1521 else if (isObject(this._events[type]))
1522 this._events[type].push(listener);
1524 this._events[type] = [this._events[type], listener];
1525 if (isObject(this._events[type]) && !this._events[type].warned) {
1527 if (!isUndefined(this._maxListeners)) {
1528 m = this._maxListeners;
1530 m = EventEmitter.defaultMaxListeners;
1533 if (m && m > 0 && this._events[type].length > m) {
1534 this._events[type].warned = true;
1535 console.error('(node) warning: possible EventEmitter memory ' +
1536 'leak detected. %d listeners added. ' +
1537 'Use emitter.setMaxListeners() to increase limit.',
1538 this._events[type].length);
1539 if (typeof console.trace === 'function') {
1548 EventEmitter.prototype.on = EventEmitter.prototype.addListener;
1550 EventEmitter.prototype.once = function(type, listener) {
1551 if (!isFunction(listener))
1552 throw TypeError('listener must be a function');
1557 this.removeListener(type, g);
1561 listener.apply(this, arguments);
1565 g.listener = listener;
1570 EventEmitter.prototype.removeListener = function(type, listener) {
1571 var list, position, length, i;
1573 if (!isFunction(listener))
1574 throw TypeError('listener must be a function');
1576 if (!this._events || !this._events[type])
1579 list = this._events[type];
1580 length = list.length;
1583 if (list === listener ||
1584 (isFunction(list.listener) && list.listener === listener)) {
1585 delete this._events[type];
1586 if (this._events.removeListener)
1587 this.emit('removeListener', type, listener);
1589 } else if (isObject(list)) {
1590 for (i = length; i-- > 0;) {
1591 if (list[i] === listener ||
1592 (list[i].listener && list[i].listener === listener)) {
1601 if (list.length === 1) {
1603 delete this._events[type];
1605 list.splice(position, 1);
1608 if (this._events.removeListener)
1609 this.emit('removeListener', type, listener);
1615 EventEmitter.prototype.removeAllListeners = function(type) {
1620 if (!this._events.removeListener) {
1621 if (arguments.length === 0)
1623 else if (this._events[type])
1624 delete this._events[type];
1627 if (arguments.length === 0) {
1628 for (key in this._events) {
1629 if (key === 'removeListener') continue;
1630 this.removeAllListeners(key);
1632 this.removeAllListeners('removeListener');
1637 listeners = this._events[type];
1639 if (isFunction(listeners)) {
1640 this.removeListener(type, listeners);
1642 while (listeners.length)
1643 this.removeListener(type, listeners[listeners.length - 1]);
1645 delete this._events[type];
1650 EventEmitter.prototype.listeners = function(type) {
1652 if (!this._events || !this._events[type])
1654 else if (isFunction(this._events[type]))
1655 ret = [this._events[type]];
1657 ret = this._events[type].slice();
1661 EventEmitter.listenerCount = function(emitter, type) {
1663 if (!emitter._events || !emitter._events[type])
1665 else if (isFunction(emitter._events[type]))
1668 ret = emitter._events[type].length;
1672 function isFunction(arg) {
1673 return typeof arg === 'function';
1676 function isNumber(arg) {
1677 return typeof arg === 'number';
1680 function isObject(arg) {
1681 return typeof arg === 'object' && arg !== null;
1684 function isUndefined(arg) {
1685 return arg === void 0;
1688 },{}],"/node_modules/jshint/data/ascii-identifier-data.js":[function(_dereq_,module,exports){
1689 var identifierStartTable = [];
1691 for (var i = 0; i < 128; i++) {
1692 identifierStartTable[i] =
1694 i >= 65 && i <= 90 || // A-Z
1696 i >= 97 && i <= 122; // a-z
1699 var identifierPartTable = [];
1701 for (var i = 0; i < 128; i++) {
1702 identifierPartTable[i] =
1703 identifierStartTable[i] || // $, _, A-Z, a-z
1704 i >= 48 && i <= 57; // 0-9
1708 asciiIdentifierStartTable: identifierStartTable,
1709 asciiIdentifierPartTable: identifierPartTable
1712 },{}],"/node_modules/jshint/lodash.js":[function(_dereq_,module,exports){
1718 var VERSION = '3.7.0';
1720 var FUNC_ERROR_TEXT = 'Expected a function';
1722 var argsTag = '[object Arguments]',
1723 arrayTag = '[object Array]',
1724 boolTag = '[object Boolean]',
1725 dateTag = '[object Date]',
1726 errorTag = '[object Error]',
1727 funcTag = '[object Function]',
1728 mapTag = '[object Map]',
1729 numberTag = '[object Number]',
1730 objectTag = '[object Object]',
1731 regexpTag = '[object RegExp]',
1732 setTag = '[object Set]',
1733 stringTag = '[object String]',
1734 weakMapTag = '[object WeakMap]';
1736 var arrayBufferTag = '[object ArrayBuffer]',
1737 float32Tag = '[object Float32Array]',
1738 float64Tag = '[object Float64Array]',
1739 int8Tag = '[object Int8Array]',
1740 int16Tag = '[object Int16Array]',
1741 int32Tag = '[object Int32Array]',
1742 uint8Tag = '[object Uint8Array]',
1743 uint8ClampedTag = '[object Uint8ClampedArray]',
1744 uint16Tag = '[object Uint16Array]',
1745 uint32Tag = '[object Uint32Array]';
1747 var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
1748 reIsPlainProp = /^\w*$/,
1749 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
1751 var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
1752 reHasRegExpChars = RegExp(reRegExpChars.source);
1754 var reEscapeChar = /\\(\\)?/g;
1756 var reFlags = /\w*$/;
1758 var reIsHostCtor = /^\[object .+?Constructor\]$/;
1760 var typedArrayTags = {};
1761 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1762 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1763 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1764 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1765 typedArrayTags[uint32Tag] = true;
1766 typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
1767 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1768 typedArrayTags[dateTag] = typedArrayTags[errorTag] =
1769 typedArrayTags[funcTag] = typedArrayTags[mapTag] =
1770 typedArrayTags[numberTag] = typedArrayTags[objectTag] =
1771 typedArrayTags[regexpTag] = typedArrayTags[setTag] =
1772 typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
1774 var cloneableTags = {};
1775 cloneableTags[argsTag] = cloneableTags[arrayTag] =
1776 cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
1777 cloneableTags[dateTag] = cloneableTags[float32Tag] =
1778 cloneableTags[float64Tag] = cloneableTags[int8Tag] =
1779 cloneableTags[int16Tag] = cloneableTags[int32Tag] =
1780 cloneableTags[numberTag] = cloneableTags[objectTag] =
1781 cloneableTags[regexpTag] = cloneableTags[stringTag] =
1782 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
1783 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
1784 cloneableTags[errorTag] = cloneableTags[funcTag] =
1785 cloneableTags[mapTag] = cloneableTags[setTag] =
1786 cloneableTags[weakMapTag] = false;
1793 var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
1795 var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
1797 var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;
1799 var freeSelf = objectTypes[typeof self] && self && self.Object && self;
1801 var freeWindow = objectTypes[typeof window] && window && window.Object && window;
1803 var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
1805 var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
1807 function baseFindIndex(array, predicate, fromRight) {
1808 var length = array.length,
1809 index = fromRight ? length : -1;
1811 while ((fromRight ? index-- : ++index < length)) {
1812 if (predicate(array[index], index, array)) {
1819 function baseIndexOf(array, value, fromIndex) {
1820 if (value !== value) {
1821 return indexOfNaN(array, fromIndex);
1823 var index = fromIndex - 1,
1824 length = array.length;
1826 while (++index < length) {
1827 if (array[index] === value) {
1834 function baseIsFunction(value) {
1835 return typeof value == 'function' || false;
1838 function baseToString(value) {
1839 if (typeof value == 'string') {
1842 return value == null ? '' : (value + '');
1845 function indexOfNaN(array, fromIndex, fromRight) {
1846 var length = array.length,
1847 index = fromIndex + (fromRight ? 0 : -1);
1849 while ((fromRight ? index-- : ++index < length)) {
1850 var other = array[index];
1851 if (other !== other) {
1858 function isObjectLike(value) {
1859 return !!value && typeof value == 'object';
1862 var arrayProto = Array.prototype,
1863 objectProto = Object.prototype;
1865 var fnToString = Function.prototype.toString;
1867 var hasOwnProperty = objectProto.hasOwnProperty;
1869 var objToString = objectProto.toString;
1871 var reIsNative = RegExp('^' +
1872 escapeRegExp(objToString)
1873 .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1876 var ArrayBuffer = isNative(ArrayBuffer = root.ArrayBuffer) && ArrayBuffer,
1877 bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
1879 getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols,
1880 getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
1881 push = arrayProto.push,
1882 preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions,
1883 propertyIsEnumerable = objectProto.propertyIsEnumerable,
1884 Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array;
1886 var Float64Array = (function() {
1888 var func = isNative(func = root.Float64Array) && func,
1889 result = new func(new ArrayBuffer(10), 0, 1) && func;
1894 var nativeAssign = (function() {
1895 var object = { '1': 0 },
1896 func = preventExtensions && isNative(func = Object.assign) && func;
1898 try { func(preventExtensions(object), 'xo'); } catch(e) {}
1899 return !object[1] && func;
1902 var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
1903 nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
1904 nativeMax = Math.max,
1905 nativeMin = Math.min;
1907 var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
1909 var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
1910 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
1911 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
1913 var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
1915 var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
1920 var support = lodash.support = {};
1923 var Ctor = function() { this.x = x; },
1924 object = { '0': x, 'length': x },
1927 Ctor.prototype = { 'valueOf': x, 'y': x };
1928 for (var key in new Ctor) { props.push(key); }
1930 support.funcDecomp = /\bthis\b/.test(function() { return this; });
1932 support.funcNames = typeof Function.name == 'string';
1935 support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
1937 support.nonEnumArgs = true;
1941 function arrayCopy(source, array) {
1943 length = source.length;
1945 array || (array = Array(length));
1946 while (++index < length) {
1947 array[index] = source[index];
1952 function arrayEach(array, iteratee) {
1954 length = array.length;
1956 while (++index < length) {
1957 if (iteratee(array[index], index, array) === false) {
1964 function arrayFilter(array, predicate) {
1966 length = array.length,
1970 while (++index < length) {
1971 var value = array[index];
1972 if (predicate(value, index, array)) {
1973 result[++resIndex] = value;
1979 function arrayMap(array, iteratee) {
1981 length = array.length,
1982 result = Array(length);
1984 while (++index < length) {
1985 result[index] = iteratee(array[index], index, array);
1990 function arrayMax(array) {
1992 length = array.length,
1993 result = NEGATIVE_INFINITY;
1995 while (++index < length) {
1996 var value = array[index];
1997 if (value > result) {
2004 function arraySome(array, predicate) {
2006 length = array.length;
2008 while (++index < length) {
2009 if (predicate(array[index], index, array)) {
2016 function assignWith(object, source, customizer) {
2017 var props = keys(source);
2018 push.apply(props, getSymbols(source));
2021 length = props.length;
2023 while (++index < length) {
2024 var key = props[index],
2025 value = object[key],
2026 result = customizer(value, source[key], key, object, source);
2028 if ((result === result ? (result !== value) : (value === value)) ||
2029 (value === undefined && !(key in object))) {
2030 object[key] = result;
2036 var baseAssign = nativeAssign || function(object, source) {
2037 return source == null
2039 : baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object));
2042 function baseCopy(source, props, object) {
2043 object || (object = {});
2046 length = props.length;
2048 while (++index < length) {
2049 var key = props[index];
2050 object[key] = source[key];
2055 function baseCallback(func, thisArg, argCount) {
2056 var type = typeof func;
2057 if (type == 'function') {
2058 return thisArg === undefined
2060 : bindCallback(func, thisArg, argCount);
2065 if (type == 'object') {
2066 return baseMatches(func);
2068 return thisArg === undefined
2070 : baseMatchesProperty(func, thisArg);
2073 function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
2076 result = object ? customizer(value, key, object) : customizer(value);
2078 if (result !== undefined) {
2081 if (!isObject(value)) {
2084 var isArr = isArray(value);
2086 result = initCloneArray(value);
2088 return arrayCopy(value, result);
2091 var tag = objToString.call(value),
2092 isFunc = tag == funcTag;
2094 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2095 result = initCloneObject(isFunc ? {} : value);
2097 return baseAssign(result, value);
2100 return cloneableTags[tag]
2101 ? initCloneByTag(value, tag, isDeep)
2102 : (object ? value : {});
2105 stackA || (stackA = []);
2106 stackB || (stackB = []);
2108 var length = stackA.length;
2110 if (stackA[length] == value) {
2111 return stackB[length];
2115 stackB.push(result);
2117 (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
2118 result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
2123 var baseEach = createBaseEach(baseForOwn);
2125 function baseFilter(collection, predicate) {
2127 baseEach(collection, function(value, index, collection) {
2128 if (predicate(value, index, collection)) {
2135 var baseFor = createBaseFor();
2137 function baseForIn(object, iteratee) {
2138 return baseFor(object, iteratee, keysIn);
2141 function baseForOwn(object, iteratee) {
2142 return baseFor(object, iteratee, keys);
2145 function baseGet(object, path, pathKey) {
2146 if (object == null) {
2149 if (pathKey !== undefined && pathKey in toObject(object)) {
2153 length = path.length;
2155 while (object != null && ++index < length) {
2156 var result = object = object[path[index]];
2161 function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
2162 if (value === other) {
2163 return value !== 0 || (1 / value == 1 / other);
2165 var valType = typeof value,
2166 othType = typeof other;
2168 if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
2169 value == null || other == null) {
2170 return value !== value && other !== other;
2172 return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
2175 function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
2176 var objIsArr = isArray(object),
2177 othIsArr = isArray(other),
2182 objTag = objToString.call(object);
2183 if (objTag == argsTag) {
2185 } else if (objTag != objectTag) {
2186 objIsArr = isTypedArray(object);
2190 othTag = objToString.call(other);
2191 if (othTag == argsTag) {
2193 } else if (othTag != objectTag) {
2194 othIsArr = isTypedArray(other);
2197 var objIsObj = objTag == objectTag,
2198 othIsObj = othTag == objectTag,
2199 isSameTag = objTag == othTag;
2201 if (isSameTag && !(objIsArr || objIsObj)) {
2202 return equalByTag(object, other, objTag);
2205 var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
2206 othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
2208 if (valWrapped || othWrapped) {
2209 return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
2215 stackA || (stackA = []);
2216 stackB || (stackB = []);
2218 var length = stackA.length;
2220 if (stackA[length] == object) {
2221 return stackB[length] == other;
2224 stackA.push(object);
2227 var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
2235 function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
2237 length = props.length,
2238 noCustomizer = !customizer;
2240 while (++index < length) {
2241 if ((noCustomizer && strictCompareFlags[index])
2242 ? values[index] !== object[props[index]]
2243 : !(props[index] in object)
2249 while (++index < length) {
2250 var key = props[index],
2251 objValue = object[key],
2252 srcValue = values[index];
2254 if (noCustomizer && strictCompareFlags[index]) {
2255 var result = objValue !== undefined || (key in object);
2257 result = customizer ? customizer(objValue, srcValue, key) : undefined;
2258 if (result === undefined) {
2259 result = baseIsEqual(srcValue, objValue, customizer, true);
2269 function baseMatches(source) {
2270 var props = keys(source),
2271 length = props.length;
2274 return constant(true);
2278 value = source[key];
2280 if (isStrictComparable(value)) {
2281 return function(object) {
2282 if (object == null) {
2285 return object[key] === value && (value !== undefined || (key in toObject(object)));
2289 var values = Array(length),
2290 strictCompareFlags = Array(length);
2293 value = source[props[length]];
2294 values[length] = value;
2295 strictCompareFlags[length] = isStrictComparable(value);
2297 return function(object) {
2298 return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
2302 function baseMatchesProperty(path, value) {
2303 var isArr = isArray(path),
2304 isCommon = isKey(path) && isStrictComparable(value),
2305 pathKey = (path + '');
2307 path = toPath(path);
2308 return function(object) {
2309 if (object == null) {
2313 object = toObject(object);
2314 if ((isArr || !isCommon) && !(key in object)) {
2315 object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
2316 if (object == null) {
2320 object = toObject(object);
2322 return object[key] === value
2323 ? (value !== undefined || (key in object))
2324 : baseIsEqual(value, object[key], null, true);
2328 function baseMerge(object, source, customizer, stackA, stackB) {
2329 if (!isObject(object)) {
2332 var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
2334 var props = keys(source);
2335 push.apply(props, getSymbols(source));
2337 arrayEach(props || source, function(srcValue, key) {
2340 srcValue = source[key];
2342 if (isObjectLike(srcValue)) {
2343 stackA || (stackA = []);
2344 stackB || (stackB = []);
2345 baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
2348 var value = object[key],
2349 result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
2350 isCommon = result === undefined;
2355 if ((isSrcArr || result !== undefined) &&
2356 (isCommon || (result === result ? (result !== value) : (value === value)))) {
2357 object[key] = result;
2364 function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
2365 var length = stackA.length,
2366 srcValue = source[key];
2369 if (stackA[length] == srcValue) {
2370 object[key] = stackB[length];
2374 var value = object[key],
2375 result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
2376 isCommon = result === undefined;
2380 if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
2381 result = isArray(value)
2383 : (getLength(value) ? arrayCopy(value) : []);
2385 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
2386 result = isArguments(value)
2387 ? toPlainObject(value)
2388 : (isPlainObject(value) ? value : {});
2394 stackA.push(srcValue);
2395 stackB.push(result);
2398 object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
2399 } else if (result === result ? (result !== value) : (value === value)) {
2400 object[key] = result;
2404 function baseProperty(key) {
2405 return function(object) {
2406 return object == null ? undefined : object[key];
2410 function basePropertyDeep(path) {
2411 var pathKey = (path + '');
2412 path = toPath(path);
2413 return function(object) {
2414 return baseGet(object, path, pathKey);
2418 function baseSlice(array, start, end) {
2420 length = array.length;
2422 start = start == null ? 0 : (+start || 0);
2424 start = -start > length ? 0 : (length + start);
2426 end = (end === undefined || end > length) ? length : (+end || 0);
2430 length = start > end ? 0 : ((end - start) >>> 0);
2433 var result = Array(length);
2434 while (++index < length) {
2435 result[index] = array[index + start];
2440 function baseSome(collection, predicate) {
2443 baseEach(collection, function(value, index, collection) {
2444 result = predicate(value, index, collection);
2450 function baseValues(object, props) {
2452 length = props.length,
2453 result = Array(length);
2455 while (++index < length) {
2456 result[index] = object[props[index]];
2461 function binaryIndex(array, value, retHighest) {
2463 high = array ? array.length : low;
2465 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
2466 while (low < high) {
2467 var mid = (low + high) >>> 1,
2468 computed = array[mid];
2470 if (retHighest ? (computed <= value) : (computed < value)) {
2478 return binaryIndexBy(array, value, identity, retHighest);
2481 function binaryIndexBy(array, value, iteratee, retHighest) {
2482 value = iteratee(value);
2485 high = array ? array.length : 0,
2486 valIsNaN = value !== value,
2487 valIsUndef = value === undefined;
2489 while (low < high) {
2490 var mid = floor((low + high) / 2),
2491 computed = iteratee(array[mid]),
2492 isReflexive = computed === computed;
2495 var setLow = isReflexive || retHighest;
2496 } else if (valIsUndef) {
2497 setLow = isReflexive && (retHighest || computed !== undefined);
2499 setLow = retHighest ? (computed <= value) : (computed < value);
2507 return nativeMin(high, MAX_ARRAY_INDEX);
2510 function bindCallback(func, thisArg, argCount) {
2511 if (typeof func != 'function') {
2514 if (thisArg === undefined) {
2518 case 1: return function(value) {
2519 return func.call(thisArg, value);
2521 case 3: return function(value, index, collection) {
2522 return func.call(thisArg, value, index, collection);
2524 case 4: return function(accumulator, value, index, collection) {
2525 return func.call(thisArg, accumulator, value, index, collection);
2527 case 5: return function(value, other, key, object, source) {
2528 return func.call(thisArg, value, other, key, object, source);
2532 return func.apply(thisArg, arguments);
2536 function bufferClone(buffer) {
2537 return bufferSlice.call(buffer, 0);
2540 bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
2541 var byteLength = buffer.byteLength,
2542 floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
2543 offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
2544 result = new ArrayBuffer(byteLength);
2547 var view = new Float64Array(result, 0, floatLength);
2548 view.set(new Float64Array(buffer, 0, floatLength));
2550 if (byteLength != offset) {
2551 view = new Uint8Array(result, offset);
2552 view.set(new Uint8Array(buffer, offset));
2558 function createAssigner(assigner) {
2559 return restParam(function(object, sources) {
2561 length = object == null ? 0 : sources.length,
2562 customizer = length > 2 && sources[length - 2],
2563 guard = length > 2 && sources[2],
2564 thisArg = length > 1 && sources[length - 1];
2566 if (typeof customizer == 'function') {
2567 customizer = bindCallback(customizer, thisArg, 5);
2570 customizer = typeof thisArg == 'function' ? thisArg : null;
2571 length -= (customizer ? 1 : 0);
2573 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
2574 customizer = length < 3 ? null : customizer;
2577 while (++index < length) {
2578 var source = sources[index];
2580 assigner(object, source, customizer);
2587 function createBaseEach(eachFunc, fromRight) {
2588 return function(collection, iteratee) {
2589 var length = collection ? getLength(collection) : 0;
2590 if (!isLength(length)) {
2591 return eachFunc(collection, iteratee);
2593 var index = fromRight ? length : -1,
2594 iterable = toObject(collection);
2596 while ((fromRight ? index-- : ++index < length)) {
2597 if (iteratee(iterable[index], index, iterable) === false) {
2605 function createBaseFor(fromRight) {
2606 return function(object, iteratee, keysFunc) {
2607 var iterable = toObject(object),
2608 props = keysFunc(object),
2609 length = props.length,
2610 index = fromRight ? length : -1;
2612 while ((fromRight ? index-- : ++index < length)) {
2613 var key = props[index];
2614 if (iteratee(iterable[key], key, iterable) === false) {
2622 function createFindIndex(fromRight) {
2623 return function(array, predicate, thisArg) {
2624 if (!(array && array.length)) {
2627 predicate = getCallback(predicate, thisArg, 3);
2628 return baseFindIndex(array, predicate, fromRight);
2632 function createForEach(arrayFunc, eachFunc) {
2633 return function(collection, iteratee, thisArg) {
2634 return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
2635 ? arrayFunc(collection, iteratee)
2636 : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
2640 function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
2642 arrLength = array.length,
2643 othLength = other.length,
2646 if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
2649 while (result && ++index < arrLength) {
2650 var arrValue = array[index],
2651 othValue = other[index];
2656 ? customizer(othValue, arrValue, index)
2657 : customizer(arrValue, othValue, index);
2659 if (result === undefined) {
2661 var othIndex = othLength;
2662 while (othIndex--) {
2663 othValue = other[othIndex];
2664 result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
2670 result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
2677 function equalByTag(object, other, tag) {
2681 return +object == +other;
2684 return object.name == other.name && object.message == other.message;
2687 return (object != +object)
2689 : (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
2693 return object == (other + '');
2698 function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
2699 var objProps = keys(object),
2700 objLength = objProps.length,
2701 othProps = keys(other),
2702 othLength = othProps.length;
2704 if (objLength != othLength && !isLoose) {
2707 var skipCtor = isLoose,
2710 while (++index < objLength) {
2711 var key = objProps[index],
2712 result = isLoose ? key in other : hasOwnProperty.call(other, key);
2715 var objValue = object[key],
2716 othValue = other[key];
2721 ? customizer(othValue, objValue, key)
2722 : customizer(objValue, othValue, key);
2724 if (result === undefined) {
2725 result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
2731 skipCtor || (skipCtor = key == 'constructor');
2734 var objCtor = object.constructor,
2735 othCtor = other.constructor;
2737 if (objCtor != othCtor &&
2738 ('constructor' in object && 'constructor' in other) &&
2739 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
2740 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
2747 function getCallback(func, thisArg, argCount) {
2748 var result = lodash.callback || callback;
2749 result = result === callback ? baseCallback : result;
2750 return argCount ? result(func, thisArg, argCount) : result;
2753 function getIndexOf(collection, target, fromIndex) {
2754 var result = lodash.indexOf || indexOf;
2755 result = result === indexOf ? baseIndexOf : result;
2756 return collection ? result(collection, target, fromIndex) : result;
2759 var getLength = baseProperty('length');
2761 var getSymbols = !getOwnPropertySymbols ? constant([]) : function(object) {
2762 return getOwnPropertySymbols(toObject(object));
2765 function initCloneArray(array) {
2766 var length = array.length,
2767 result = new array.constructor(length);
2769 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
2770 result.index = array.index;
2771 result.input = array.input;
2776 function initCloneObject(object) {
2777 var Ctor = object.constructor;
2778 if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
2784 function initCloneByTag(object, tag, isDeep) {
2785 var Ctor = object.constructor;
2787 case arrayBufferTag:
2788 return bufferClone(object);
2792 return new Ctor(+object);
2794 case float32Tag: case float64Tag:
2795 case int8Tag: case int16Tag: case int32Tag:
2796 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
2797 var buffer = object.buffer;
2798 return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
2802 return new Ctor(object);
2805 var result = new Ctor(object.source, reFlags.exec(object));
2806 result.lastIndex = object.lastIndex;
2811 function isIndex(value, length) {
2813 length = length == null ? MAX_SAFE_INTEGER : length;
2814 return value > -1 && value % 1 == 0 && value < length;
2817 function isIterateeCall(value, index, object) {
2818 if (!isObject(object)) {
2821 var type = typeof index;
2822 if (type == 'number') {
2823 var length = getLength(object),
2824 prereq = isLength(length) && isIndex(index, length);
2826 prereq = type == 'string' && index in object;
2829 var other = object[index];
2830 return value === value ? (value === other) : (other !== other);
2835 function isKey(value, object) {
2836 var type = typeof value;
2837 if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
2840 if (isArray(value)) {
2843 var result = !reIsDeepProp.test(value);
2844 return result || (object != null && value in toObject(object));
2847 function isLength(value) {
2848 return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2851 function isStrictComparable(value) {
2852 return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
2855 function shimIsPlainObject(value) {
2857 support = lodash.support;
2859 if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
2860 (!hasOwnProperty.call(value, 'constructor') &&
2861 (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
2865 baseForIn(value, function(subValue, key) {
2868 return result === undefined || hasOwnProperty.call(value, result);
2871 function shimKeys(object) {
2872 var props = keysIn(object),
2873 propsLength = props.length,
2874 length = propsLength && object.length,
2875 support = lodash.support;
2877 var allowIndexes = length && isLength(length) &&
2878 (isArray(object) || (support.nonEnumArgs && isArguments(object)));
2883 while (++index < propsLength) {
2884 var key = props[index];
2885 if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
2892 function toObject(value) {
2893 return isObject(value) ? value : Object(value);
2896 function toPath(value) {
2897 if (isArray(value)) {
2901 baseToString(value).replace(rePropName, function(match, number, quote, string) {
2902 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
2907 var findLastIndex = createFindIndex(true);
2909 function indexOf(array, value, fromIndex) {
2910 var length = array ? array.length : 0;
2914 if (typeof fromIndex == 'number') {
2915 fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
2916 } else if (fromIndex) {
2917 var index = binaryIndex(array, value),
2918 other = array[index];
2920 if (value === value ? (value === other) : (other !== other)) {
2925 return baseIndexOf(array, value, fromIndex || 0);
2928 function last(array) {
2929 var length = array ? array.length : 0;
2930 return length ? array[length - 1] : undefined;
2933 function slice(array, start, end) {
2934 var length = array ? array.length : 0;
2938 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
2942 return baseSlice(array, start, end);
2945 function unzip(array) {
2947 length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
2948 result = Array(length);
2950 while (++index < length) {
2951 result[index] = arrayMap(array, baseProperty(index));
2956 var zip = restParam(unzip);
2958 var forEach = createForEach(arrayEach, baseEach);
2960 function includes(collection, target, fromIndex, guard) {
2961 var length = collection ? getLength(collection) : 0;
2962 if (!isLength(length)) {
2963 collection = values(collection);
2964 length = collection.length;
2969 if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
2972 fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
2974 return (typeof collection == 'string' || !isArray(collection) && isString(collection))
2975 ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
2976 : (getIndexOf(collection, target, fromIndex) > -1);
2979 function reject(collection, predicate, thisArg) {
2980 var func = isArray(collection) ? arrayFilter : baseFilter;
2981 predicate = getCallback(predicate, thisArg, 3);
2982 return func(collection, function(value, index, collection) {
2983 return !predicate(value, index, collection);
2987 function some(collection, predicate, thisArg) {
2988 var func = isArray(collection) ? arraySome : baseSome;
2989 if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
2992 if (typeof predicate != 'function' || thisArg !== undefined) {
2993 predicate = getCallback(predicate, thisArg, 3);
2995 return func(collection, predicate);
2998 function restParam(func, start) {
2999 if (typeof func != 'function') {
3000 throw new TypeError(FUNC_ERROR_TEXT);
3002 start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
3004 var args = arguments,
3006 length = nativeMax(args.length - start, 0),
3007 rest = Array(length);
3009 while (++index < length) {
3010 rest[index] = args[start + index];
3013 case 0: return func.call(this, rest);
3014 case 1: return func.call(this, args[0], rest);
3015 case 2: return func.call(this, args[0], args[1], rest);
3017 var otherArgs = Array(start + 1);
3019 while (++index < start) {
3020 otherArgs[index] = args[index];
3022 otherArgs[start] = rest;
3023 return func.apply(this, otherArgs);
3027 function clone(value, isDeep, customizer, thisArg) {
3028 if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
3031 else if (typeof isDeep == 'function') {
3032 thisArg = customizer;
3033 customizer = isDeep;
3036 customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
3037 return baseClone(value, isDeep, customizer);
3040 function isArguments(value) {
3041 var length = isObjectLike(value) ? value.length : undefined;
3042 return isLength(length) && objToString.call(value) == argsTag;
3045 var isArray = nativeIsArray || function(value) {
3046 return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
3049 function isEmpty(value) {
3050 if (value == null) {
3053 var length = getLength(value);
3054 if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
3055 (isObjectLike(value) && isFunction(value.splice)))) {
3058 return !keys(value).length;
3061 var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
3062 return objToString.call(value) == funcTag;
3065 function isObject(value) {
3066 var type = typeof value;
3067 return type == 'function' || (!!value && type == 'object');
3070 function isNative(value) {
3071 if (value == null) {
3074 if (objToString.call(value) == funcTag) {
3075 return reIsNative.test(fnToString.call(value));
3077 return isObjectLike(value) && reIsHostCtor.test(value);
3080 function isNumber(value) {
3081 return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
3084 var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
3085 if (!(value && objToString.call(value) == objectTag)) {
3088 var valueOf = value.valueOf,
3089 objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
3092 ? (value == objProto || getPrototypeOf(value) == objProto)
3093 : shimIsPlainObject(value);
3096 function isString(value) {
3097 return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
3100 function isTypedArray(value) {
3101 return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
3104 function toPlainObject(value) {
3105 return baseCopy(value, keysIn(value));
3108 var assign = createAssigner(function(object, source, customizer) {
3110 ? assignWith(object, source, customizer)
3111 : baseAssign(object, source);
3114 function has(object, path) {
3115 if (object == null) {
3118 var result = hasOwnProperty.call(object, path);
3119 if (!result && !isKey(path)) {
3120 path = toPath(path);
3121 object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
3123 result = object != null && hasOwnProperty.call(object, path);
3128 var keys = !nativeKeys ? shimKeys : function(object) {
3130 var Ctor = object.constructor,
3131 length = object.length;
3133 if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
3134 (typeof object != 'function' && isLength(length))) {
3135 return shimKeys(object);
3137 return isObject(object) ? nativeKeys(object) : [];
3140 function keysIn(object) {
3141 if (object == null) {
3144 if (!isObject(object)) {
3145 object = Object(object);
3147 var length = object.length;
3148 length = (length && isLength(length) &&
3149 (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
3151 var Ctor = object.constructor,
3153 isProto = typeof Ctor == 'function' && Ctor.prototype === object,
3154 result = Array(length),
3155 skipIndexes = length > 0;
3157 while (++index < length) {
3158 result[index] = (index + '');
3160 for (var key in object) {
3161 if (!(skipIndexes && isIndex(key, length)) &&
3162 !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3169 var merge = createAssigner(baseMerge);
3171 function values(object) {
3172 return baseValues(object, keys(object));
3175 function escapeRegExp(string) {
3176 string = baseToString(string);
3177 return (string && reHasRegExpChars.test(string))
3178 ? string.replace(reRegExpChars, '\\$&')
3182 function callback(func, thisArg, guard) {
3183 if (guard && isIterateeCall(func, thisArg, guard)) {
3186 return baseCallback(func, thisArg);
3189 function constant(value) {
3195 function identity(value) {
3199 function property(path) {
3200 return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
3202 lodash.assign = assign;
3203 lodash.callback = callback;
3204 lodash.constant = constant;
3205 lodash.forEach = forEach;
3207 lodash.keysIn = keysIn;
3208 lodash.merge = merge;
3209 lodash.property = property;
3210 lodash.reject = reject;
3211 lodash.restParam = restParam;
3212 lodash.slice = slice;
3213 lodash.toPlainObject = toPlainObject;
3214 lodash.unzip = unzip;
3215 lodash.values = values;
3218 lodash.each = forEach;
3219 lodash.extend = assign;
3220 lodash.iteratee = callback;
3221 lodash.clone = clone;
3222 lodash.escapeRegExp = escapeRegExp;
3223 lodash.findLastIndex = findLastIndex;
3225 lodash.identity = identity;
3226 lodash.includes = includes;
3227 lodash.indexOf = indexOf;
3228 lodash.isArguments = isArguments;
3229 lodash.isArray = isArray;
3230 lodash.isEmpty = isEmpty;
3231 lodash.isFunction = isFunction;
3232 lodash.isNative = isNative;
3233 lodash.isNumber = isNumber;
3234 lodash.isObject = isObject;
3235 lodash.isPlainObject = isPlainObject;
3236 lodash.isString = isString;
3237 lodash.isTypedArray = isTypedArray;
3242 lodash.contains = includes;
3243 lodash.include = includes;
3245 lodash.VERSION = VERSION;
3246 if (freeExports && freeModule) {
3247 if (moduleExports) {
3248 (freeModule.exports = lodash)._ = lodash;
3251 freeExports._ = lodash;
3259 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3260 },{}],"/node_modules/jshint/src/jshint.js":[function(_dereq_,module,exports){
3262 var _ = _dereq_("../lodash");
3263 var events = _dereq_("events");
3264 var vars = _dereq_("./vars.js");
3265 var messages = _dereq_("./messages.js");
3266 var Lexer = _dereq_("./lex.js").Lexer;
3267 var reg = _dereq_("./reg.js");
3268 var state = _dereq_("./state.js").state;
3269 var style = _dereq_("./style.js");
3270 var options = _dereq_("./options.js");
3271 var scopeManager = _dereq_("./scope-manager.js");
3273 var JSHINT = (function() {
3276 var api, // Extension API
3293 declared, // Globals that were declared using /*global ... */ syntax.
3296 "closure", "exception", "global", "label",
3297 "outer", "unused", "var"
3300 functions, // All of the functions
3308 predefined, // Global variables defined by option
3314 emitter = new events.EventEmitter();
3316 function checkOption(name, t) {
3319 if (/^[+-]W\d{3}$/g.test(name)) {
3323 if (options.validNames.indexOf(name) === -1) {
3324 if (t.type !== "jslint" && !_.has(options.removed, name)) {
3325 error("E001", t, name);
3333 function isString(obj) {
3334 return Object.prototype.toString.call(obj) === "[object String]";
3337 function isIdentifier(tkn, value) {
3341 if (!tkn.identifier || tkn.value !== value)
3347 function isReserved(token) {
3348 if (!token.reserved) {
3351 var meta = token.meta;
3353 if (meta && meta.isFutureReservedWord && state.inES5()) {
3357 if (meta.strictOnly) {
3358 if (!state.option.strict && !state.isStrict()) {
3363 if (token.isProperty) {
3371 function supplant(str, data) {
3372 return str.replace(/\{([^{}]*)\}/g, function(a, b) {
3374 return typeof r === "string" || typeof r === "number" ? r : a;
3378 function combine(dest, src) {
3379 Object.keys(src).forEach(function(name) {
3380 if (_.has(JSHINT.blacklist, name)) return;
3381 dest[name] = src[name];
3385 function processenforceall() {
3386 if (state.option.enforceall) {
3387 for (var enforceopt in options.bool.enforcing) {
3388 if (state.option[enforceopt] === undefined &&
3389 !options.noenforceall[enforceopt]) {
3390 state.option[enforceopt] = true;
3393 for (var relaxopt in options.bool.relaxing) {
3394 if (state.option[relaxopt] === undefined) {
3395 state.option[relaxopt] = false;
3402 processenforceall();
3403 if (!state.option.esversion && !state.option.moz) {
3404 if (state.option.es3) {
3405 state.option.esversion = 3;
3406 } else if (state.option.esnext) {
3407 state.option.esversion = 6;
3409 state.option.esversion = 5;
3413 if (state.inES5()) {
3414 combine(predefined, vars.ecmaIdentifiers[5]);
3417 if (state.inES6()) {
3418 combine(predefined, vars.ecmaIdentifiers[6]);
3421 if (state.option.module) {
3422 if (state.option.strict === true) {
3423 state.option.strict = "global";
3425 if (!state.inES6()) {
3426 warning("W134", state.tokens.next, "module", 6);
3430 if (state.option.couch) {
3431 combine(predefined, vars.couch);
3434 if (state.option.qunit) {
3435 combine(predefined, vars.qunit);
3438 if (state.option.rhino) {
3439 combine(predefined, vars.rhino);
3442 if (state.option.shelljs) {
3443 combine(predefined, vars.shelljs);
3444 combine(predefined, vars.node);
3446 if (state.option.typed) {
3447 combine(predefined, vars.typed);
3450 if (state.option.phantom) {
3451 combine(predefined, vars.phantom);
3452 if (state.option.strict === true) {
3453 state.option.strict = "global";
3457 if (state.option.prototypejs) {
3458 combine(predefined, vars.prototypejs);
3461 if (state.option.node) {
3462 combine(predefined, vars.node);
3463 combine(predefined, vars.typed);
3464 if (state.option.strict === true) {
3465 state.option.strict = "global";
3469 if (state.option.devel) {
3470 combine(predefined, vars.devel);
3473 if (state.option.dojo) {
3474 combine(predefined, vars.dojo);
3477 if (state.option.browser) {
3478 combine(predefined, vars.browser);
3479 combine(predefined, vars.typed);
3482 if (state.option.browserify) {
3483 combine(predefined, vars.browser);
3484 combine(predefined, vars.typed);
3485 combine(predefined, vars.browserify);
3486 if (state.option.strict === true) {
3487 state.option.strict = "global";
3491 if (state.option.nonstandard) {
3492 combine(predefined, vars.nonstandard);
3495 if (state.option.jasmine) {
3496 combine(predefined, vars.jasmine);
3499 if (state.option.jquery) {
3500 combine(predefined, vars.jquery);
3503 if (state.option.mootools) {
3504 combine(predefined, vars.mootools);
3507 if (state.option.worker) {
3508 combine(predefined, vars.worker);
3511 if (state.option.wsh) {
3512 combine(predefined, vars.wsh);
3515 if (state.option.globalstrict && state.option.strict !== false) {
3516 state.option.strict = "global";
3519 if (state.option.yui) {
3520 combine(predefined, vars.yui);
3523 if (state.option.mocha) {
3524 combine(predefined, vars.mocha);
3527 function quit(code, line, chr) {
3528 var percentage = Math.floor((line / state.lines.length) * 100);
3529 var message = messages.errors[code].desc;
3532 name: "JSHintError",
3535 message: message + " (" + percentage + "% scanned).",
3541 function removeIgnoredMessages() {
3542 var ignored = state.ignoredLines;
3544 if (_.isEmpty(ignored)) return;
3545 JSHINT.errors = _.reject(JSHINT.errors, function(err) { return ignored[err.line] });
3548 function warning(code, t, a, b, c, d) {
3551 if (/^W\d{3}$/.test(code)) {
3552 if (state.ignored[code])
3555 msg = messages.warnings[code];
3556 } else if (/E\d{3}/.test(code)) {
3557 msg = messages.errors[code];
3558 } else if (/I\d{3}/.test(code)) {
3559 msg = messages.info[code];
3562 t = t || state.tokens.next || {};
3563 if (t.id === "(end)") { // `~
3564 t = state.tokens.curr;
3574 evidence: state.lines[l - 1] || "",
3577 scope: JSHINT.scope,
3584 w.reason = supplant(msg.desc, w);
3585 JSHINT.errors.push(w);
3587 removeIgnoredMessages();
3589 if (JSHINT.errors.length >= state.option.maxerr)
3590 quit("E043", l, ch);
3595 function warningAt(m, l, ch, a, b, c, d) {
3602 function error(m, t, a, b, c, d) {
3603 warning(m, t, a, b, c, d);
3606 function errorAt(m, l, ch, a, b, c, d) {
3612 function addInternalSrc(elem, src) {
3619 JSHINT.internals.push(i);
3623 function doOption() {
3624 var nt = state.tokens.next;
3625 var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g) || [];
3628 if (nt.type === "globals") {
3629 body.forEach(function(g, idx) {
3631 var key = (g[0] || "").trim();
3632 var val = (g[1] || "").trim();
3634 if (key === "-" || !key.length) {
3635 if (idx > 0 && idx === body.length - 1) {
3642 if (key.charAt(0) === "-") {
3646 JSHINT.blacklist[key] = key;
3647 delete predefined[key];
3649 predef[key] = (val === "true");
3653 combine(predefined, predef);
3655 for (var key in predef) {
3656 if (_.has(predef, key)) {
3662 if (nt.type === "exported") {
3663 body.forEach(function(e, idx) {
3665 if (idx > 0 && idx === body.length - 1) {
3672 state.funct["(scope)"].addExported(e);
3676 if (nt.type === "members") {
3677 membersOnly = membersOnly || {};
3679 body.forEach(function(m) {
3680 var ch1 = m.charAt(0);
3681 var ch2 = m.charAt(m.length - 1);
3683 if (ch1 === ch2 && (ch1 === "\"" || ch1 === "'")) {
3685 .substr(1, m.length - 2)
3686 .replace("\\\"", "\"");
3689 membersOnly[m] = false;
3703 if (nt.type === "jshint" || nt.type === "jslint") {
3704 body.forEach(function(g) {
3706 var key = (g[0] || "").trim();
3707 var val = (g[1] || "").trim();
3709 if (!checkOption(key, nt)) {
3713 if (numvals.indexOf(key) >= 0) {
3714 if (val !== "false") {
3717 if (typeof val !== "number" || !isFinite(val) || val <= 0 || Math.floor(val) !== val) {
3718 error("E032", nt, g[1].trim());
3722 state.option[key] = val;
3724 state.option[key] = key === "indent" ? 4 : false;
3730 if (key === "validthis") {
3732 if (state.funct["(global)"])
3733 return void error("E009");
3735 if (val !== "true" && val !== "false")
3736 return void error("E002", nt);
3738 state.option.validthis = (val === "true");
3742 if (key === "quotmark") {
3746 state.option.quotmark = (val === "true");
3750 state.option.quotmark = val;
3758 if (key === "shadow") {
3761 state.option.shadow = true;
3764 state.option.shadow = "outer";
3768 state.option.shadow = "inner";
3776 if (key === "unused") {
3779 state.option.unused = true;
3782 state.option.unused = false;
3786 state.option.unused = val;
3794 if (key === "latedef") {
3797 state.option.latedef = true;
3800 state.option.latedef = false;
3803 state.option.latedef = "nofunc";
3811 if (key === "ignore") {
3814 state.ignoredLines[nt.line] = true;
3815 removeIgnoredMessages();
3823 if (key === "strict") {
3826 state.option.strict = true;
3829 state.option.strict = false;
3834 state.option.strict = val;
3842 if (key === "module") {
3843 if (!hasParsedCode(state.funct)) {
3844 error("E055", state.tokens.next, "module");
3852 if (_.has(esversions, key)) {
3855 state.option.moz = false;
3856 state.option.esversion = esversions[key];
3859 if (!state.option.moz) {
3860 state.option.esversion = 5;
3869 if (key === "esversion") {
3872 if (state.inES5(true)) {
3877 state.option.moz = false;
3878 state.option.esversion = +val;
3881 state.option.moz = false;
3882 state.option.esversion = 6;
3887 if (!hasParsedCode(state.funct)) {
3888 error("E055", state.tokens.next, "esversion");
3893 var match = /^([+-])(W\d{3})$/g.exec(key);
3895 state.ignored[match[2]] = (match[1] === "-");
3900 if (val === "true" || val === "false") {
3901 if (nt.type === "jslint") {
3902 tn = options.renamed[key] || key;
3903 state.option[tn] = (val === "true");
3905 if (options.inverted[tn] !== undefined) {
3906 state.option[tn] = !state.option[tn];
3909 state.option[key] = (val === "true");
3912 if (key === "newcap") {
3913 state.option["(explicitNewcap)"] = true;
3926 var i = p || 0, j = lookahead.length, t;
3929 return lookahead[i];
3935 t = lookahead[j] = lex.token();
3939 if (!t && state.tokens.next.id === "(end)") {
3940 return state.tokens.next;
3946 function peekIgnoreEOL() {
3951 } while (t.id === "(endline)");
3955 function advance(id, t) {
3957 switch (state.tokens.curr.id) {
3959 if (state.tokens.next.id === ".") {
3960 warning("W005", state.tokens.curr);
3964 if (state.tokens.next.id === "-" || state.tokens.next.id === "--") {
3969 if (state.tokens.next.id === "+" || state.tokens.next.id === "++") {
3975 if (id && state.tokens.next.id !== id) {
3977 if (state.tokens.next.id === "(end)") {
3978 error("E019", t, t.id);
3980 error("E020", state.tokens.next, id, t.id, t.line, state.tokens.next.value);
3982 } else if (state.tokens.next.type !== "(identifier)" || state.tokens.next.value !== id) {
3983 warning("W116", state.tokens.next, id, state.tokens.next.value);
3987 state.tokens.prev = state.tokens.curr;
3988 state.tokens.curr = state.tokens.next;
3990 state.tokens.next = lookahead.shift() || lex.token();
3992 if (!state.tokens.next) { // No more tokens left, give up
3993 quit("E041", state.tokens.curr.line);
3996 if (state.tokens.next.id === "(end)" || state.tokens.next.id === "(error)") {
4000 if (state.tokens.next.check) {
4001 state.tokens.next.check();
4004 if (state.tokens.next.isSpecial) {
4005 if (state.tokens.next.type === "falls through") {
4006 state.tokens.curr.caseFallsThrough = true;
4011 if (state.tokens.next.id !== "(endline)") {
4018 function isInfix(token) {
4019 return token.infix || (!token.identifier && !token.template && !!token.led);
4022 function isEndOfExpr() {
4023 var curr = state.tokens.curr;
4024 var next = state.tokens.next;
4025 if (next.id === ";" || next.id === "}" || next.id === ":") {
4028 if (isInfix(next) === isInfix(curr) || (curr.id === "yield" && state.inMoz())) {
4029 return curr.line !== startLine(next);
4034 function isBeginOfExpr(prev) {
4035 return !prev.left && prev.arity !== "unary";
4038 function expression(rbp, initial) {
4039 var left, isArray = false, isObject = false, isLetExpr = false;
4041 state.nameStack.push();
4042 if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") {
4043 if (!state.inMoz()) {
4044 warning("W118", state.tokens.next, "let expressions");
4047 state.funct["(scope)"].stack();
4050 state.tokens.prev.fud();
4054 if (state.tokens.next.id === "(end)")
4055 error("E006", state.tokens.curr);
4059 state.tokens.prev.line !== startLine(state.tokens.curr) &&
4060 _.contains(["]", ")"], state.tokens.prev.id) &&
4061 _.contains(["[", "("], state.tokens.curr.id);
4064 warning("W014", state.tokens.curr, state.tokens.curr.id);
4069 state.funct["(verb)"] = state.tokens.curr.value;
4070 state.tokens.curr.beginsStmt = true;
4073 if (initial === true && state.tokens.curr.fud) {
4074 left = state.tokens.curr.fud();
4076 if (state.tokens.curr.nud) {
4077 left = state.tokens.curr.nud();
4079 error("E030", state.tokens.curr, state.tokens.curr.id);
4081 while ((rbp < state.tokens.next.lbp || state.tokens.next.type === "(template)") &&
4083 isArray = state.tokens.curr.value === "Array";
4084 isObject = state.tokens.curr.value === "Object";
4085 if (left && (left.value || (left.first && left.first.value))) {
4086 if (left.value !== "new" ||
4087 (left.first && left.first.value && left.first.value === ".")) {
4089 if (left.value !== state.tokens.curr.value) {
4097 if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
4098 warning("W009", state.tokens.curr);
4101 if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
4102 warning("W010", state.tokens.curr);
4105 if (left && state.tokens.curr.led) {
4106 left = state.tokens.curr.led(left);
4108 error("E033", state.tokens.curr, state.tokens.curr.id);
4113 state.funct["(scope)"].unstack();
4116 state.nameStack.pop();
4121 function startLine(token) {
4122 return token.startLine || token.line;
4125 function nobreaknonadjacent(left, right) {
4126 left = left || state.tokens.curr;
4127 right = right || state.tokens.next;
4128 if (!state.option.laxbreak && left.line !== startLine(right)) {
4129 warning("W014", right, right.value);
4133 function nolinebreak(t) {
4134 t = t || state.tokens.curr;
4135 if (t.line !== startLine(state.tokens.next)) {
4136 warning("E022", t, t.value);
4140 function nobreakcomma(left, right) {
4141 if (left.line !== startLine(right)) {
4142 if (!state.option.laxcomma) {
4145 comma.first = false;
4147 warning("W014", left, right.value);
4152 function comma(opts) {
4156 nobreakcomma(state.tokens.curr, state.tokens.next);
4159 nobreakcomma(state.tokens.prev, state.tokens.curr);
4162 if (state.tokens.next.identifier && !(opts.property && state.inES5())) {
4163 switch (state.tokens.next.value) {
4184 error("E024", state.tokens.next, state.tokens.next.value);
4189 if (state.tokens.next.type === "(punctuator)") {
4190 switch (state.tokens.next.value) {
4194 if (opts.allowTrailing) {
4198 error("E024", state.tokens.next, state.tokens.next.value);
4205 function symbol(s, p) {
4206 var x = state.syntax[s];
4207 if (!x || typeof x !== "object") {
4208 state.syntax[s] = x = {
4218 var x = symbol(s, 0);
4223 function stmt(s, f) {
4225 x.identifier = x.reserved = true;
4230 function blockstmt(s, f) {
4236 function reserveName(x) {
4237 var c = x.id.charAt(0);
4238 if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) {
4239 x.identifier = x.reserved = true;
4244 function prefix(s, f) {
4245 var x = symbol(s, 150);
4248 x.nud = (typeof f === "function") ? f : function() {
4249 this.arity = "unary";
4250 this.right = expression(150);
4252 if (this.id === "++" || this.id === "--") {
4253 if (state.option.plusplus) {
4254 warning("W016", this, this.id);
4255 } else if (this.right && (!this.right.identifier || isReserved(this.right)) &&
4256 this.right.id !== "." && this.right.id !== "[") {
4257 warning("W017", this);
4260 if (this.right && this.right.isMetaProperty) {
4261 error("E031", this);
4262 } else if (this.right && this.right.identifier) {
4263 state.funct["(scope)"].block.modify(this.right.value, this);
4273 function type(s, f) {
4280 function reserve(name, func) {
4281 var x = type(name, func);
4282 x.identifier = true;
4287 function FutureReservedWord(name, meta) {
4288 var x = type(name, (meta && meta.nud) || function() {
4293 meta.isFutureReservedWord = true;
4296 x.identifier = true;
4303 function reservevar(s, v) {
4304 return reserve(s, function() {
4305 if (typeof v === "function") {
4312 function infix(s, f, p, w) {
4313 var x = symbol(s, p);
4316 x.led = function(left) {
4318 nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
4320 if ((s === "in" || s === "instanceof") && left.id === "!") {
4321 warning("W018", left, "!");
4323 if (typeof f === "function") {
4324 return f(left, this);
4327 this.right = expression(p);
4334 function application(s) {
4335 var x = symbol(s, 42);
4337 x.led = function(left) {
4338 nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
4341 this.right = doFunction({ type: "arrow", loneArg: left });
4347 function relation(s, f) {
4348 var x = symbol(s, 100);
4350 x.led = function(left) {
4351 nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
4353 var right = this.right = expression(100);
4355 if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) {
4356 warning("W019", this);
4358 f.apply(this, [left, right]);
4361 if (!left || !right) {
4362 quit("E041", state.tokens.curr.line);
4365 if (left.id === "!") {
4366 warning("W018", left, "!");
4369 if (right.id === "!") {
4370 warning("W018", right, "!");
4378 function isPoorRelation(node) {
4380 ((node.type === "(number)" && +node.value === 0) ||
4381 (node.type === "(string)" && node.value === "") ||
4382 (node.type === "null" && !state.option.eqnull) ||
4383 node.type === "true" ||
4384 node.type === "false" ||
4385 node.type === "undefined");
4388 var typeofValues = {};
4389 typeofValues.legacy = [
4393 typeofValues.es3 = [
4394 "undefined", "boolean", "number", "string", "function", "object",
4396 typeofValues.es3 = typeofValues.es3.concat(typeofValues.legacy);
4397 typeofValues.es6 = typeofValues.es3.concat("symbol");
4398 function isTypoTypeof(left, right, state) {
4401 if (state.option.notypeof)
4404 if (!left || !right)
4407 values = state.inES6() ? typeofValues.es6 : typeofValues.es3;
4409 if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)")
4410 return !_.contains(values, left.value);
4415 function isGlobalEval(left, state) {
4416 var isGlobal = false;
4417 if (left.type === "this" && state.funct["(context)"] === null) {
4420 else if (left.type === "(identifier)") {
4421 if (state.option.node && left.value === "global") {
4425 else if (state.option.browser && (left.value === "window" || left.value === "document")) {
4433 function findNativePrototype(left) {
4435 "Array", "ArrayBuffer", "Boolean", "Collator", "DataView", "Date",
4436 "DateTimeFormat", "Error", "EvalError", "Float32Array", "Float64Array",
4437 "Function", "Infinity", "Intl", "Int16Array", "Int32Array", "Int8Array",
4438 "Iterator", "Number", "NumberFormat", "Object", "RangeError",
4439 "ReferenceError", "RegExp", "StopIteration", "String", "SyntaxError",
4440 "TypeError", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray",
4444 function walkPrototype(obj) {
4445 if (typeof obj !== "object") return;
4446 return obj.right === "prototype" ? obj : walkPrototype(obj.left);
4449 function walkNative(obj) {
4450 while (!obj.identifier && typeof obj.left === "object")
4453 if (obj.identifier && natives.indexOf(obj.value) >= 0)
4457 var prototype = walkPrototype(left);
4458 if (prototype) return walkNative(prototype);
4460 function checkLeftSideAssign(left, assignToken, options) {
4462 var allowDestructuring = options && options.allowDestructuring;
4464 assignToken = assignToken || left;
4466 if (state.option.freeze) {
4467 var nativeObject = findNativePrototype(left);
4469 warning("W121", left, nativeObject);
4472 if (left.identifier && !left.isMetaProperty) {
4473 state.funct["(scope)"].block.reassign(left.value, left);
4476 if (left.id === ".") {
4477 if (!left.left || left.left.value === "arguments" && !state.isStrict()) {
4478 warning("E031", assignToken);
4481 state.nameStack.set(state.tokens.prev);
4483 } else if (left.id === "{" || left.id === "[") {
4484 if (allowDestructuring && state.tokens.curr.left.destructAssign) {
4485 state.tokens.curr.left.destructAssign.forEach(function(t) {
4487 state.funct["(scope)"].block.modify(t.id, t.token);
4491 if (left.id === "{" || !left.left) {
4492 warning("E031", assignToken);
4493 } else if (left.left.value === "arguments" && !state.isStrict()) {
4494 warning("E031", assignToken);
4498 if (left.id === "[") {
4499 state.nameStack.set(left.right);
4503 } else if (left.isMetaProperty) {
4504 error("E031", assignToken);
4506 } else if (left.identifier && !isReserved(left)) {
4507 if (state.funct["(scope)"].labeltype(left.value) === "exception") {
4508 warning("W022", left);
4510 state.nameStack.set(left);
4514 if (left === state.syntax["function"]) {
4515 warning("W023", state.tokens.curr);
4521 function assignop(s, f, p) {
4522 var x = infix(s, typeof f === "function" ? f : function(left, that) {
4525 if (left && checkLeftSideAssign(left, that, { allowDestructuring: true })) {
4526 that.right = expression(10);
4530 error("E031", that);
4539 function bitwise(s, f, p) {
4540 var x = symbol(s, p);
4542 x.led = (typeof f === "function") ? f : function(left) {
4543 if (state.option.bitwise) {
4544 warning("W016", this, this.id);
4547 this.right = expression(p);
4553 function bitwiseassignop(s) {
4554 return assignop(s, function(left, that) {
4555 if (state.option.bitwise) {
4556 warning("W016", that, that.id);
4559 if (left && checkLeftSideAssign(left, that)) {
4560 that.right = expression(10);
4563 error("E031", that);
4567 function suffix(s) {
4568 var x = symbol(s, 150);
4570 x.led = function(left) {
4571 if (state.option.plusplus) {
4572 warning("W016", this, this.id);
4573 } else if ((!left.identifier || isReserved(left)) && left.id !== "." && left.id !== "[") {
4574 warning("W017", this);
4577 if (left.isMetaProperty) {
4578 error("E031", this);
4579 } else if (left && left.identifier) {
4580 state.funct["(scope)"].block.modify(left.value, left);
4589 function optionalidentifier(fnparam, prop, preserve) {
4590 if (!state.tokens.next.identifier) {
4598 var curr = state.tokens.curr;
4599 var val = state.tokens.curr.value;
4601 if (!isReserved(curr)) {
4606 if (state.inES5()) {
4611 if (fnparam && val === "undefined") {
4615 warning("W024", state.tokens.curr, state.tokens.curr.id);
4618 function identifier(fnparam, prop) {
4619 var i = optionalidentifier(fnparam, prop, false);
4623 if (state.tokens.next.value === "...") {
4624 if (!state.inES6(true)) {
4625 warning("W119", state.tokens.next, "spread/rest operator", "6");
4629 if (checkPunctuator(state.tokens.next, "...")) {
4630 warning("E024", state.tokens.next, "...");
4631 while (checkPunctuator(state.tokens.next, "...")) {
4636 if (!state.tokens.next.identifier) {
4637 warning("E024", state.tokens.curr, "...");
4641 return identifier(fnparam, prop);
4643 error("E030", state.tokens.next, state.tokens.next.value);
4644 if (state.tokens.next.id !== ";") {
4651 function reachable(controlToken) {
4653 if (state.tokens.next.id !== ";" || controlToken.inBracelessBlock) {
4660 } while (t.id !== "(end)" && t.id === "(comment)");
4665 if (t.id !== "(endline)") {
4666 if (t.id === "function") {
4667 if (state.option.latedef === true) {
4673 warning("W027", t, t.value, controlToken.value);
4679 function parseFinalSemicolon() {
4680 if (state.tokens.next.id !== ";") {
4681 if (state.tokens.next.isUnclosed) return advance();
4683 var sameLine = startLine(state.tokens.next) === state.tokens.curr.line &&
4684 state.tokens.next.id !== "(end)";
4685 var blockEnd = checkPunctuator(state.tokens.next, "}");
4687 if (sameLine && !blockEnd) {
4688 errorAt("E058", state.tokens.curr.line, state.tokens.curr.character);
4689 } else if (!state.option.asi) {
4690 if ((blockEnd && !state.option.lastsemic) || !sameLine) {
4691 warningAt("W033", state.tokens.curr.line, state.tokens.curr.character);
4699 function statement() {
4700 var i = indent, r, t = state.tokens.next, hasOwnScope = false;
4706 var res = isReserved(t);
4708 if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") {
4709 warning("W024", t, t.id);
4713 if (t.identifier && !res && peek().id === ":") {
4718 state.funct["(scope)"].stack();
4719 state.funct["(scope)"].block.addBreakLabel(t.value, { token: state.tokens.curr });
4721 if (!state.tokens.next.labelled && state.tokens.next.value !== "{") {
4722 warning("W028", state.tokens.next, t.value, state.tokens.next.value);
4725 state.tokens.next.label = t.value;
4726 t = state.tokens.next;
4730 var iscase = (state.funct["(verb)"] === "case" && state.tokens.curr.value === ":");
4731 block(true, true, false, false, iscase);
4735 r = expression(0, true);
4737 if (r && !(r.identifier && r.value === "function") &&
4738 !(r.type === "(punctuator)" && r.left &&
4739 r.left.identifier && r.left.value === "function")) {
4740 if (!state.isStrict() &&
4741 state.option.strict === "global") {
4747 if (!state.option.expr && (!r || !r.exps)) {
4748 warning("W030", state.tokens.curr);
4749 } else if (state.option.nonew && r && r.left && r.id === "(" && r.left.id === "new") {
4752 parseFinalSemicolon();
4757 state.funct["(scope)"].unstack();
4763 function statements() {
4766 while (!state.tokens.next.reach && state.tokens.next.id !== "(end)") {
4767 if (state.tokens.next.id === ";") {
4770 if (!p || (p.id !== "(" && p.id !== "[")) {
4776 a.push(statement());
4781 function directives() {
4784 while (state.tokens.next.id === "(string)") {
4786 if (p.id === "(endline)") {
4790 } while (pn.id === "(endline)");
4791 if (pn.id === ";") {
4793 } else if (pn.value === "[" || pn.value === ".") {
4795 } else if (!state.option.asi || pn.value === "(") {
4796 warning("W033", state.tokens.next);
4798 } else if (p.id === "." || p.id === "[") {
4800 } else if (p.id !== ";") {
4805 var directive = state.tokens.curr.value;
4806 if (state.directive[directive] ||
4807 (directive === "use strict" && state.option.strict === "implied")) {
4808 warning("W034", state.tokens.curr, directive);
4810 state.directive[directive] = true;
4817 if (state.isStrict()) {
4818 if (!state.option["(explicitNewcap)"]) {
4819 state.option.newcap = true;
4821 state.option.undef = true;
4824 function block(ordinary, stmt, isfunc, isfatarrow, iscase) {
4827 old_indent = indent,
4835 t = state.tokens.next;
4837 var metrics = state.funct["(metrics)"];
4838 metrics.nestedBlockDepth += 1;
4839 metrics.verifyMaxNestedBlockDepthPerFunction();
4841 if (state.tokens.next.id === "{") {
4843 state.funct["(scope)"].stack();
4845 line = state.tokens.curr.line;
4846 if (state.tokens.next.id !== "}") {
4847 indent += state.option.indent;
4848 while (!ordinary && state.tokens.next.from > indent) {
4849 indent += state.option.indent;
4854 for (d in state.directive) {
4855 if (_.has(state.directive, d)) {
4856 m[d] = state.directive[d];
4861 if (state.option.strict && state.funct["(context)"]["(global)"]) {
4862 if (!m["use strict"] && !state.isStrict()) {
4870 metrics.statementCount += a.length;
4872 indent -= state.option.indent;
4878 state.funct["(scope)"].validateParams();
4880 state.directive = m;
4884 state.funct["(scope)"].unstack();
4886 indent = old_indent;
4887 } else if (!ordinary) {
4889 state.funct["(scope)"].stack();
4892 if (stmt && !isfatarrow && !state.inMoz()) {
4893 error("W118", state.tokens.curr, "function closure expressions");
4897 for (d in state.directive) {
4898 if (_.has(state.directive, d)) {
4899 m[d] = state.directive[d];
4905 if (state.option.strict && state.funct["(context)"]["(global)"]) {
4906 if (!m["use strict"] && !state.isStrict()) {
4911 state.funct["(scope)"].unstack();
4913 error("E021", state.tokens.next, "{", state.tokens.next.value);
4916 state.funct["(noblockscopedvar)"] = state.tokens.next.id !== "for";
4917 state.funct["(scope)"].stack();
4919 if (!stmt || state.option.curly) {
4920 warning("W116", state.tokens.next, "{", state.tokens.next.value);
4923 state.tokens.next.inBracelessBlock = true;
4924 indent += state.option.indent;
4926 indent -= state.option.indent;
4928 state.funct["(scope)"].unstack();
4929 delete state.funct["(noblockscopedvar)"];
4931 switch (state.funct["(verb)"]) {
4940 state.funct["(verb)"] = null;
4944 if (ordinary && state.option.noempty && (!a || a.length === 0)) {
4945 warning("W035", state.tokens.prev);
4947 metrics.nestedBlockDepth -= 1;
4952 function countMember(m) {
4953 if (membersOnly && typeof membersOnly[m] !== "boolean") {
4954 warning("W036", state.tokens.curr, m);
4956 if (typeof member[m] === "number") {
4963 type("(number)", function() {
4967 type("(string)", function() {
4971 state.syntax["(identifier)"] = {
4972 type: "(identifier)",
4978 if (state.tokens.next.id === "=>") {
4982 if (!state.funct["(comparray)"].check(v)) {
4983 state.funct["(scope)"].block.use(v, state.tokens.curr);
4989 error("E033", state.tokens.next, state.tokens.next.value);
4993 var baseTemplateSyntax = {
4998 state.syntax["(template)"] = _.extend({
5000 nud: doTemplateLiteral,
5001 led: doTemplateLiteral,
5003 }, baseTemplateSyntax);
5005 state.syntax["(template middle)"] = _.extend({
5006 type: "(template middle)",
5009 }, baseTemplateSyntax);
5011 state.syntax["(template tail)"] = _.extend({
5012 type: "(template tail)",
5015 }, baseTemplateSyntax);
5017 state.syntax["(no subst template)"] = _.extend({
5019 nud: doTemplateLiteral,
5020 led: doTemplateLiteral,
5022 tail: true // mark as tail, since it's always the last component
5023 }, baseTemplateSyntax);
5025 type("(regexp)", function() {
5031 delim("(end)").reach = true;
5032 delim("(error)").reach = true;
5033 delim("}").reach = true;
5036 delim("\"").reach = true;
5037 delim("'").reach = true;
5039 delim(":").reach = true;
5043 reserve("case").reach = true;
5045 reserve("default").reach = true;
5047 reservevar("arguments", function(x) {
5048 if (state.isStrict() && state.funct["(global)"]) {
5053 reservevar("false");
5054 reservevar("Infinity");
5056 reservevar("this", function(x) {
5057 if (state.isStrict() && !isMethod() &&
5058 !state.option.validthis && ((state.funct["(statement)"] &&
5059 state.funct["(name)"].charAt(0) > "Z") || state.funct["(global)"])) {
5064 reservevar("undefined");
5066 assignop("=", "assign", 20);
5067 assignop("+=", "assignadd", 20);
5068 assignop("-=", "assignsub", 20);
5069 assignop("*=", "assignmult", 20);
5070 assignop("/=", "assigndiv", 20).nud = function() {
5073 assignop("%=", "assignmod", 20);
5075 bitwiseassignop("&=");
5076 bitwiseassignop("|=");
5077 bitwiseassignop("^=");
5078 bitwiseassignop("<<=");
5079 bitwiseassignop(">>=");
5080 bitwiseassignop(">>>=");
5081 infix(",", function(left, that) {
5083 that.exprs = [left];
5085 if (state.option.nocomma) {
5089 if (!comma({ peek: true })) {
5093 if (!(expr = expression(10))) {
5096 that.exprs.push(expr);
5097 if (state.tokens.next.value !== "," || !comma()) {
5104 infix("?", function(left, that) {
5105 increaseComplexityCount();
5107 that.right = expression(10);
5109 that["else"] = expression(10);
5113 var orPrecendence = 40;
5114 infix("||", function(left, that) {
5115 increaseComplexityCount();
5117 that.right = expression(orPrecendence);
5120 infix("&&", "and", 50);
5121 bitwise("|", "bitor", 70);
5122 bitwise("^", "bitxor", 80);
5123 bitwise("&", "bitand", 90);
5124 relation("==", function(left, right) {
5125 var eqnull = state.option.eqnull &&
5126 ((left && left.value) === "null" || (right && right.value) === "null");
5129 case !eqnull && state.option.eqeqeq:
5130 this.from = this.character;
5131 warning("W116", this, "===", "==");
5133 case isPoorRelation(left):
5134 warning("W041", this, "===", left.value);
5136 case isPoorRelation(right):
5137 warning("W041", this, "===", right.value);
5139 case isTypoTypeof(right, left, state):
5140 warning("W122", this, right.value);
5142 case isTypoTypeof(left, right, state):
5143 warning("W122", this, left.value);
5149 relation("===", function(left, right) {
5150 if (isTypoTypeof(right, left, state)) {
5151 warning("W122", this, right.value);
5152 } else if (isTypoTypeof(left, right, state)) {
5153 warning("W122", this, left.value);
5157 relation("!=", function(left, right) {
5158 var eqnull = state.option.eqnull &&
5159 ((left && left.value) === "null" || (right && right.value) === "null");
5161 if (!eqnull && state.option.eqeqeq) {
5162 this.from = this.character;
5163 warning("W116", this, "!==", "!=");
5164 } else if (isPoorRelation(left)) {
5165 warning("W041", this, "!==", left.value);
5166 } else if (isPoorRelation(right)) {
5167 warning("W041", this, "!==", right.value);
5168 } else if (isTypoTypeof(right, left, state)) {
5169 warning("W122", this, right.value);
5170 } else if (isTypoTypeof(left, right, state)) {
5171 warning("W122", this, left.value);
5175 relation("!==", function(left, right) {
5176 if (isTypoTypeof(right, left, state)) {
5177 warning("W122", this, right.value);
5178 } else if (isTypoTypeof(left, right, state)) {
5179 warning("W122", this, left.value);
5187 bitwise("<<", "shiftleft", 120);
5188 bitwise(">>", "shiftright", 120);
5189 bitwise(">>>", "shiftrightunsigned", 120);
5190 infix("in", "in", 120);
5191 infix("instanceof", "instanceof", 120);
5192 infix("+", function(left, that) {
5195 that.right = right = expression(130);
5197 if (left && right && left.id === "(string)" && right.id === "(string)") {
5198 left.value += right.value;
5199 left.character = right.character;
5200 if (!state.option.scripturl && reg.javascriptURL.test(left.value)) {
5201 warning("W050", left);
5209 prefix("+++", function() {
5211 this.arity = "unary";
5212 this.right = expression(150);
5215 infix("+++", function(left) {
5218 this.right = expression(130);
5221 infix("-", "sub", 130);
5223 prefix("---", function() {
5225 this.arity = "unary";
5226 this.right = expression(150);
5229 infix("---", function(left) {
5232 this.right = expression(130);
5235 infix("*", "mult", 140);
5236 infix("/", "div", 140);
5237 infix("%", "mod", 140);
5240 prefix("++", "preinc");
5241 state.syntax["++"].exps = true;
5244 prefix("--", "predec");
5245 state.syntax["--"].exps = true;
5246 prefix("delete", function() {
5247 var p = expression(10);
5252 if (p.id !== "." && p.id !== "[") {
5256 if (p.identifier && !state.isStrict()) {
5257 p.forgiveUndef = true;
5262 prefix("~", function() {
5263 if (state.option.bitwise) {
5264 warning("W016", this, "~");
5266 this.arity = "unary";
5267 this.right = expression(150);
5271 prefix("...", function() {
5272 if (!state.inES6(true)) {
5273 warning("W119", this, "spread/rest operator", "6");
5275 if (!state.tokens.next.identifier &&
5276 state.tokens.next.type !== "(string)" &&
5277 !checkPunctuators(state.tokens.next, ["[", "("])) {
5279 error("E030", state.tokens.next, state.tokens.next.value);
5285 prefix("!", function() {
5286 this.arity = "unary";
5287 this.right = expression(150);
5289 if (!this.right) { // '!' followed by nothing? Give up.
5290 quit("E041", this.line || 0);
5293 if (bang[this.right.id] === true) {
5294 warning("W018", this, "!");
5299 prefix("typeof", (function() {
5300 var p = expression(150);
5301 this.first = this.right = p;
5303 if (!p) { // 'typeof' followed by nothing? Give up.
5304 quit("E041", this.line || 0, this.character || 0);
5307 p.forgiveUndef = true;
5311 prefix("new", function() {
5312 var mp = metaProperty("target", function() {
5313 if (!state.inES6(true)) {
5314 warning("W119", state.tokens.prev, "new.target", "6");
5316 var inFunction, c = state.funct;
5318 inFunction = !c["(global)"];
5319 if (!c["(arrow)"]) { break; }
5323 warning("W136", state.tokens.prev, "new.target");
5326 if (mp) { return mp; }
5328 var c = expression(155), i;
5329 if (c && c.id !== "function") {
5338 warning("W053", state.tokens.prev, c.value);
5341 if (state.inES6()) {
5342 warning("W053", state.tokens.prev, c.value);
5346 if (!state.option.evil) {
5355 if (c.id !== "function") {
5356 i = c.value.substr(0, 1);
5357 if (state.option.newcap && (i < "A" || i > "Z") &&
5358 !state.funct["(scope)"].isPredefined(c.value)) {
5359 warning("W055", state.tokens.curr);
5364 if (c.id !== "." && c.id !== "[" && c.id !== "(") {
5365 warning("W056", state.tokens.curr);
5369 if (!state.option.supernew)
5370 warning("W057", this);
5372 if (state.tokens.next.id !== "(" && !state.option.supernew) {
5373 warning("W058", state.tokens.curr, state.tokens.curr.value);
5375 this.first = this.right = c;
5378 state.syntax["new"].exps = true;
5380 prefix("void").exps = true;
5382 infix(".", function(left, that) {
5383 var m = identifier(false, true);
5385 if (typeof m === "string") {
5392 if (m && m === "hasOwnProperty" && state.tokens.next.value === "=") {
5396 if (left && left.value === "arguments" && (m === "callee" || m === "caller")) {
5397 if (state.option.noarg)
5398 warning("W059", left, m);
5399 else if (state.isStrict())
5401 } else if (!state.option.evil && left && left.value === "document" &&
5402 (m === "write" || m === "writeln")) {
5403 warning("W060", left);
5406 if (!state.option.evil && (m === "eval" || m === "execScript")) {
5407 if (isGlobalEval(left, state)) {
5415 infix("(", function(left, that) {
5416 if (state.option.immed && left && !left.immed && left.id === "function") {
5424 if (left.type === "(identifier)") {
5425 if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
5426 if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) {
5427 if (left.value === "Math") {
5428 warning("W063", left);
5429 } else if (state.option.newcap) {
5430 warning("W064", left);
5437 if (state.tokens.next.id !== ")") {
5439 p[p.length] = expression(10);
5441 if (state.tokens.next.id !== ",") {
5450 if (typeof left === "object") {
5451 if (!state.inES5() && left.value === "parseInt" && n === 1) {
5452 warning("W065", state.tokens.curr);
5454 if (!state.option.evil) {
5455 if (left.value === "eval" || left.value === "Function" ||
5456 left.value === "execScript") {
5457 warning("W061", left);
5459 if (p[0] && [0].id === "(string)") {
5460 addInternalSrc(left, p[0].value);
5462 } else if (p[0] && p[0].id === "(string)" &&
5463 (left.value === "setTimeout" ||
5464 left.value === "setInterval")) {
5465 warning("W066", left);
5466 addInternalSrc(left, p[0].value);
5467 } else if (p[0] && p[0].id === "(string)" &&
5468 left.value === "." &&
5469 left.left.value === "window" &&
5470 (left.right === "setTimeout" ||
5471 left.right === "setInterval")) {
5472 warning("W066", left);
5473 addInternalSrc(left, p[0].value);
5476 if (!left.identifier && left.id !== "." && left.id !== "[" && left.id !== "=>" &&
5477 left.id !== "(" && left.id !== "&&" && left.id !== "||" && left.id !== "?" &&
5478 !(state.inES6() && left["(name)"])) {
5479 warning("W067", that);
5485 }, 155, true).exps = true;
5487 prefix("(", function() {
5488 var pn = state.tokens.next, pn1, i = -1;
5489 var ret, triggerFnExpr, first, last;
5491 var opening = state.tokens.curr;
5492 var preceeding = state.tokens.prev;
5493 var isNecessary = !state.option.singleGroups;
5496 if (pn.value === "(") {
5498 } else if (pn.value === ")") {
5505 } while (!(parens === 0 && pn1.value === ")") && pn.value !== ";" && pn.type !== "(end)");
5507 if (state.tokens.next.id === "function") {
5508 triggerFnExpr = state.tokens.next.immed = true;
5510 if (pn.value === "=>") {
5511 return doFunction({ type: "arrow", parsedOpening: true });
5516 if (state.tokens.next.id !== ")") {
5518 exprs.push(expression(10));
5520 if (state.tokens.next.id !== ",") {
5524 if (state.option.nocomma) {
5533 if (state.option.immed && exprs[0] && exprs[0].id === "function") {
5534 if (state.tokens.next.id !== "(" &&
5535 state.tokens.next.id !== "." && state.tokens.next.id !== "[") {
5536 warning("W068", this);
5540 if (!exprs.length) {
5543 if (exprs.length > 1) {
5544 ret = Object.create(state.syntax[","]);
5548 last = exprs[exprs.length - 1];
5551 isNecessary = preceeding.assign || preceeding.delim;
5554 ret = first = last = exprs[0];
5558 (opening.beginsStmt && (ret.id === "{" || triggerFnExpr || isFunctor(ret))) ||
5560 (!isEndOfExpr() || state.tokens.prev.id !== "}")) ||
5561 (isFunctor(ret) && !isEndOfExpr()) ||
5562 (ret.id === "{" && preceeding.id === "=>") ||
5563 (ret.type === "(number)" &&
5564 checkPunctuator(pn, ".") && /^\d+$/.test(ret.value));
5569 if (!isNecessary && (first.left || first.right || ret.exprs)) {
5571 (!isBeginOfExpr(preceeding) && first.lbp <= preceeding.lbp) ||
5572 (!isEndOfExpr() && last.lbp < state.tokens.next.lbp);
5576 warning("W126", opening);
5587 infix("[", function(left, that) {
5588 var e = expression(10), s;
5589 if (e && e.type === "(string)") {
5590 if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) {
5591 if (isGlobalEval(left, state)) {
5596 countMember(e.value);
5597 if (!state.option.sub && reg.identifier.test(e.value)) {
5598 s = state.syntax[e.value];
5599 if (!s || !isReserved(s)) {
5600 warning("W069", state.tokens.prev, e.value);
5606 if (e && e.value === "hasOwnProperty" && state.tokens.next.value === "=") {
5615 function comprehensiveArrayExpression() {
5618 state.funct["(comparray)"].stack();
5619 var reversed = false;
5620 if (state.tokens.next.value !== "for") {
5622 if (!state.inMoz()) {
5623 warning("W116", state.tokens.next, "for", state.tokens.next.value);
5625 state.funct["(comparray)"].setState("use");
5626 res.right = expression(10);
5630 if (state.tokens.next.value === "each") {
5632 if (!state.inMoz()) {
5633 warning("W118", state.tokens.curr, "for each");
5637 state.funct["(comparray)"].setState("define");
5638 res.left = expression(130);
5639 if (_.contains(["in", "of"], state.tokens.next.value)) {
5642 error("E045", state.tokens.curr);
5644 state.funct["(comparray)"].setState("generate");
5648 if (state.tokens.next.value === "if") {
5651 state.funct["(comparray)"].setState("filter");
5652 res.filter = expression(10);
5657 state.funct["(comparray)"].setState("use");
5658 res.right = expression(10);
5662 state.funct["(comparray)"].unstack();
5666 prefix("[", function() {
5667 var blocktype = lookupBlockType();
5668 if (blocktype.isCompArray) {
5669 if (!state.option.esnext && !state.inMoz()) {
5670 warning("W118", state.tokens.curr, "array comprehension");
5672 return comprehensiveArrayExpression();
5673 } else if (blocktype.isDestAssign) {
5674 this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
5677 var b = state.tokens.curr.line !== startLine(state.tokens.next);
5680 indent += state.option.indent;
5681 if (state.tokens.next.from === indent + state.option.indent) {
5682 indent += state.option.indent;
5685 while (state.tokens.next.id !== "(end)") {
5686 while (state.tokens.next.id === ",") {
5687 if (!state.option.elision) {
5688 if (!state.inES5()) {
5694 } while (state.tokens.next.id === ",");
5701 if (state.tokens.next.id === "]") {
5705 this.first.push(expression(10));
5706 if (state.tokens.next.id === ",") {
5707 comma({ allowTrailing: true });
5708 if (state.tokens.next.id === "]" && !state.inES5()) {
5709 warning("W070", state.tokens.curr);
5717 indent -= state.option.indent;
5724 function isMethod() {
5725 return state.funct["(statement)"] && state.funct["(statement)"].type === "class" ||
5726 state.funct["(context)"] && state.funct["(context)"]["(verb)"] === "class";
5730 function isPropertyName(token) {
5731 return token.identifier || token.id === "(string)" || token.id === "(number)";
5735 function propertyName(preserveOrToken) {
5737 var preserve = true;
5738 if (typeof preserveOrToken === "object") {
5739 id = preserveOrToken;
5741 preserve = preserveOrToken;
5742 id = optionalidentifier(false, true, preserve);
5746 if (state.tokens.next.id === "(string)") {
5747 id = state.tokens.next.value;
5751 } else if (state.tokens.next.id === "(number)") {
5752 id = state.tokens.next.value.toString();
5757 } else if (typeof id === "object") {
5758 if (id.id === "(string)" || id.id === "(identifier)") id = id.value;
5759 else if (id.id === "(number)") id = id.value.toString();
5762 if (id === "hasOwnProperty") {
5768 function functionparams(options) {
5774 var pastDefault = false;
5775 var pastRest = false;
5777 var loneArg = options && options.loneArg;
5779 if (loneArg && loneArg.identifier === true) {
5780 state.funct["(scope)"].addParam(loneArg.value, loneArg);
5781 return { arity: 1, params: [ loneArg.value ] };
5784 next = state.tokens.next;
5786 if (!options || !options.parsedOpening) {
5790 if (state.tokens.next.id === ")") {
5795 function addParam(addParamArgs) {
5796 state.funct["(scope)"].addParam.apply(state.funct["(scope)"], addParamArgs);
5801 var currentParams = [];
5803 if (_.contains(["{", "["], state.tokens.next.id)) {
5804 tokens = destructuringPattern();
5808 paramsIds.push(t.id);
5809 currentParams.push([t.id, t.token]);
5813 if (checkPunctuator(state.tokens.next, "...")) pastRest = true;
5814 ident = identifier(true);
5816 paramsIds.push(ident);
5817 currentParams.push([ident, state.tokens.curr]);
5819 while (!checkPunctuators(state.tokens.next, [",", ")"])) advance();
5823 if (state.tokens.next.id !== "=") {
5824 error("W138", state.tokens.current);
5827 if (state.tokens.next.id === "=") {
5828 if (!state.inES6()) {
5829 warning("W119", state.tokens.next, "default parameters", "6");
5835 currentParams.forEach(addParam);
5837 if (state.tokens.next.id === ",") {
5839 warning("W131", state.tokens.next);
5844 return { arity: arity, params: paramsIds };
5849 function functor(name, token, overwrites) {
5861 "(character)" : null,
5863 "(statement)" : null,
5866 "(comparray)" : null,
5867 "(generator)" : null,
5874 "(line)" : token.line,
5875 "(character)": token.character,
5876 "(metrics)" : createMetrics(token)
5880 _.extend(funct, overwrites);
5882 if (funct["(context)"]) {
5883 funct["(scope)"] = funct["(context)"]["(scope)"];
5884 funct["(comparray)"] = funct["(context)"]["(comparray)"];
5890 function isFunctor(token) {
5891 return "(scope)" in token;
5893 function hasParsedCode(funct) {
5894 return funct["(global)"] && !funct["(verb)"];
5897 function doTemplateLiteral(left) {
5898 var ctx = this.context;
5899 var noSubst = this.noSubst;
5900 var depth = this.depth;
5904 if (!state.tokens.next.template || state.tokens.next.depth > depth) {
5905 expression(0); // should probably have different rbp?
5919 if (state.tokens.curr.template && state.tokens.curr.tail &&
5920 state.tokens.curr.context === ctx) return true;
5921 var complete = (state.tokens.next.template && state.tokens.next.tail &&
5922 state.tokens.next.context === ctx);
5923 if (complete) advance();
5924 return complete || state.tokens.next.isUnclosed;
5927 function doFunction(options) {
5928 var f, token, name, statement, classExprBinding, isGenerator, isArrow, ignoreLoopFunc;
5929 var oldOption = state.option;
5930 var oldIgnored = state.ignored;
5933 name = options.name;
5934 statement = options.statement;
5935 classExprBinding = options.classExprBinding;
5936 isGenerator = options.type === "generator";
5937 isArrow = options.type === "arrow";
5938 ignoreLoopFunc = options.ignoreLoopFunc;
5941 state.option = Object.create(state.option);
5942 state.ignored = Object.create(state.ignored);
5944 state.funct = functor(name || state.nameStack.infer(), state.tokens.next, {
5945 "(statement)": statement,
5946 "(context)": state.funct,
5948 "(generator)": isGenerator
5952 token = state.tokens.curr;
5953 token.funct = state.funct;
5955 functions.push(state.funct);
5956 state.funct["(scope)"].stack("functionouter");
5957 var internallyAccessibleName = name || classExprBinding;
5958 if (internallyAccessibleName) {
5959 state.funct["(scope)"].block.add(internallyAccessibleName,
5960 classExprBinding ? "class" : "function", state.tokens.curr, false);
5962 state.funct["(scope)"].stack("functionparams");
5964 var paramsInfo = functionparams(options);
5967 state.funct["(params)"] = paramsInfo.params;
5968 state.funct["(metrics)"].arity = paramsInfo.arity;
5969 state.funct["(metrics)"].verifyMaxParametersPerFunction();
5971 state.funct["(metrics)"].arity = 0;
5975 if (!state.inES6(true)) {
5976 warning("W119", state.tokens.curr, "arrow function syntax (=>)", "6");
5979 if (!options.loneArg) {
5984 block(false, true, true, isArrow);
5986 if (!state.option.noyield && isGenerator &&
5987 state.funct["(generator)"] !== "yielded") {
5988 warning("W124", state.tokens.curr);
5991 state.funct["(metrics)"].verifyMaxStatementsPerFunction();
5992 state.funct["(metrics)"].verifyMaxComplexityPerFunction();
5993 state.funct["(unusedOption)"] = state.option.unused;
5994 state.option = oldOption;
5995 state.ignored = oldIgnored;
5996 state.funct["(last)"] = state.tokens.curr.line;
5997 state.funct["(lastcharacter)"] = state.tokens.curr.character;
5998 state.funct["(scope)"].unstack(); // also does usage and label checks
5999 state.funct["(scope)"].unstack();
6001 state.funct = state.funct["(context)"];
6003 if (!ignoreLoopFunc && !state.option.loopfunc && state.funct["(loopage)"]) {
6004 if (f["(isCapturing)"]) {
6005 warning("W083", token);
6012 function createMetrics(functionStartToken) {
6015 nestedBlockDepth: -1,
6019 verifyMaxStatementsPerFunction: function() {
6020 if (state.option.maxstatements &&
6021 this.statementCount > state.option.maxstatements) {
6022 warning("W071", functionStartToken, this.statementCount);
6026 verifyMaxParametersPerFunction: function() {
6027 if (_.isNumber(state.option.maxparams) &&
6028 this.arity > state.option.maxparams) {
6029 warning("W072", functionStartToken, this.arity);
6033 verifyMaxNestedBlockDepthPerFunction: function() {
6034 if (state.option.maxdepth &&
6035 this.nestedBlockDepth > 0 &&
6036 this.nestedBlockDepth === state.option.maxdepth + 1) {
6037 warning("W073", null, this.nestedBlockDepth);
6041 verifyMaxComplexityPerFunction: function() {
6042 var max = state.option.maxcomplexity;
6043 var cc = this.ComplexityCount;
6044 if (max && cc > max) {
6045 warning("W074", functionStartToken, cc);
6051 function increaseComplexityCount() {
6052 state.funct["(metrics)"].ComplexityCount += 1;
6055 function checkCondAssignment(expr) {
6060 if (id === "," && (expr = expr.exprs[expr.exprs.length - 1])) {
6062 paren = paren || expr.paren;
6075 if (!paren && !state.option.boss) {
6080 function checkProperties(props) {
6081 if (state.inES5()) {
6082 for (var name in props) {
6083 if (props[name] && props[name].setterToken && !props[name].getterToken) {
6084 warning("W078", props[name].setterToken);
6090 function metaProperty(name, c) {
6091 if (checkPunctuator(state.tokens.next, ".")) {
6092 var left = state.tokens.curr.id;
6094 var id = identifier();
6095 state.tokens.curr.isMetaProperty = true;
6097 error("E057", state.tokens.prev, left, id);
6101 return state.tokens.curr;
6106 x.nud = function() {
6107 var b, f, i, p, t, isGeneratorMethod = false, nextVal;
6108 var props = Object.create(null); // All properties, including accessors
6110 b = state.tokens.curr.line !== startLine(state.tokens.next);
6112 indent += state.option.indent;
6113 if (state.tokens.next.from === indent + state.option.indent) {
6114 indent += state.option.indent;
6118 var blocktype = lookupBlockType();
6119 if (blocktype.isDestAssign) {
6120 this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
6125 if (state.tokens.next.id === "}") {
6129 nextVal = state.tokens.next.value;
6130 if (state.tokens.next.identifier &&
6131 (peekIgnoreEOL().id === "," || peekIgnoreEOL().id === "}")) {
6132 if (!state.inES6()) {
6133 warning("W104", state.tokens.next, "object short notation", "6");
6135 i = propertyName(true);
6136 saveProperty(props, i, state.tokens.next);
6140 } else if (peek().id !== ":" && (nextVal === "get" || nextVal === "set")) {
6143 if (!state.inES5()) {
6148 if (!i && !state.inES6()) {
6152 saveAccessor(nextVal, props, i, state.tokens.curr);
6155 t = state.tokens.next;
6158 if (nextVal === "get" && i && p) {
6159 warning("W076", t, p[0], i);
6160 } else if (nextVal === "set" && i && (!p || p.length !== 1)) {
6161 warning("W077", t, i);
6164 if (state.tokens.next.value === "*" && state.tokens.next.type === "(punctuator)") {
6165 if (!state.inES6()) {
6166 warning("W104", state.tokens.next, "generator functions", "6");
6169 isGeneratorMethod = true;
6171 isGeneratorMethod = false;
6174 if (state.tokens.next.id === "[") {
6175 i = computedPropertyName();
6176 state.nameStack.set(i);
6178 state.nameStack.set(state.tokens.next);
6180 saveProperty(props, i, state.tokens.next);
6182 if (typeof i !== "string") {
6187 if (state.tokens.next.value === "(") {
6188 if (!state.inES6()) {
6189 warning("W104", state.tokens.curr, "concise methods", "6");
6191 doFunction({ type: isGeneratorMethod ? "generator" : null });
6200 if (state.tokens.next.id === ",") {
6201 comma({ allowTrailing: true, property: true });
6202 if (state.tokens.next.id === ",") {
6203 warning("W070", state.tokens.curr);
6204 } else if (state.tokens.next.id === "}" && !state.inES5()) {
6205 warning("W070", state.tokens.curr);
6212 indent -= state.option.indent;
6216 checkProperties(props);
6220 x.fud = function() {
6221 error("E036", state.tokens.curr);
6225 function destructuringPattern(options) {
6226 var isAssignment = options && options.assignment;
6228 if (!state.inES6()) {
6229 warning("W104", state.tokens.curr,
6230 isAssignment ? "destructuring assignment" : "destructuring binding", "6");
6233 return destructuringPatternRecursive(options);
6236 function destructuringPatternRecursive(options) {
6238 var identifiers = [];
6239 var openingParsed = options && options.openingParsed;
6240 var isAssignment = options && options.assignment;
6241 var recursiveOptions = isAssignment ? { assignment: isAssignment } : null;
6242 var firstToken = openingParsed ? state.tokens.curr : state.tokens.next;
6244 var nextInnerDE = function() {
6246 if (checkPunctuators(state.tokens.next, ["[", "{"])) {
6247 ids = destructuringPatternRecursive(recursiveOptions);
6248 for (var id in ids) {
6250 identifiers.push({ id: id.id, token: id.token });
6252 } else if (checkPunctuator(state.tokens.next, ",")) {
6253 identifiers.push({ id: null, token: state.tokens.curr });
6254 } else if (checkPunctuator(state.tokens.next, "(")) {
6259 var is_rest = checkPunctuator(state.tokens.next, "...");
6262 var identifierToken = is_rest ? peek(0) : state.tokens.next;
6263 if (!identifierToken.identifier) {
6264 warning("E030", identifierToken, identifierToken.value);
6266 var assignTarget = expression(155);
6268 checkLeftSideAssign(assignTarget);
6269 if (assignTarget.identifier) {
6270 ident = assignTarget.value;
6274 ident = identifier();
6277 identifiers.push({ id: ident, token: state.tokens.curr });
6283 var assignmentProperty = function() {
6285 if (checkPunctuator(state.tokens.next, "[")) {
6291 } else if (state.tokens.next.id === "(string)" ||
6292 state.tokens.next.id === "(number)") {
6298 if (checkPunctuator(state.tokens.next, ":")) {
6303 checkLeftSideAssign(state.tokens.curr);
6305 identifiers.push({ id: id, token: state.tokens.curr });
6309 if (checkPunctuator(firstToken, "[")) {
6310 if (!openingParsed) {
6313 if (checkPunctuator(state.tokens.next, "]")) {
6314 warning("W137", state.tokens.curr);
6316 var element_after_rest = false;
6317 while (!checkPunctuator(state.tokens.next, "]")) {
6318 if (nextInnerDE() && !element_after_rest &&
6319 checkPunctuator(state.tokens.next, ",")) {
6320 warning("W130", state.tokens.next);
6321 element_after_rest = true;
6323 if (checkPunctuator(state.tokens.next, "=")) {
6324 if (checkPunctuator(state.tokens.prev, "...")) {
6329 if (state.tokens.next.id === "undefined") {
6330 warning("W080", state.tokens.prev, state.tokens.prev.value);
6334 if (!checkPunctuator(state.tokens.next, "]")) {
6339 } else if (checkPunctuator(firstToken, "{")) {
6341 if (!openingParsed) {
6344 if (checkPunctuator(state.tokens.next, "}")) {
6345 warning("W137", state.tokens.curr);
6347 while (!checkPunctuator(state.tokens.next, "}")) {
6348 assignmentProperty();
6349 if (checkPunctuator(state.tokens.next, "=")) {
6351 if (state.tokens.next.id === "undefined") {
6352 warning("W080", state.tokens.prev, state.tokens.prev.value);
6356 if (!checkPunctuator(state.tokens.next, "}")) {
6358 if (checkPunctuator(state.tokens.next, "}")) {
6368 function destructuringPatternMatch(tokens, value) {
6369 var first = value.first;
6374 _.zip(tokens, Array.isArray(first) ? first : [ first ]).forEach(function(val) {
6379 token.first = value;
6380 else if (token && token.first && !value)
6381 warning("W080", token.first, token.first.value);
6385 function blockVariableStatement(type, statement, context) {
6387 var prefix = context && context.prefix;
6388 var inexport = context && context.inexport;
6389 var isLet = type === "let";
6390 var isConst = type === "const";
6391 var tokens, lone, value, letblock;
6393 if (!state.inES6()) {
6394 warning("W104", state.tokens.curr, type, "6");
6397 if (isLet && state.tokens.next.value === "(") {
6398 if (!state.inMoz()) {
6399 warning("W118", state.tokens.next, "let block");
6402 state.funct["(scope)"].stack();
6404 } else if (state.funct["(noblockscopedvar)"]) {
6405 error("E048", state.tokens.curr, isConst ? "Const" : "Let");
6408 statement.first = [];
6411 if (_.contains(["{", "["], state.tokens.next.value)) {
6412 tokens = destructuringPattern();
6415 tokens = [ { id: identifier(), token: state.tokens.curr } ];
6419 if (!prefix && isConst && state.tokens.next.id !== "=") {
6420 warning("E012", state.tokens.curr, state.tokens.curr.value);
6423 for (var t in tokens) {
6424 if (tokens.hasOwnProperty(t)) {
6426 if (state.funct["(scope)"].block.isGlobal()) {
6427 if (predefined[t.id] === false) {
6428 warning("W079", t.token, t.id);
6431 if (t.id && !state.funct["(noblockscopedvar)"]) {
6432 state.funct["(scope)"].addlabel(t.id, {
6435 names.push(t.token);
6437 if (lone && inexport) {
6438 state.funct["(scope)"].setExported(t.token.value, t.token);
6444 if (state.tokens.next.id === "=") {
6446 if (!prefix && state.tokens.next.id === "undefined") {
6447 warning("W080", state.tokens.prev, state.tokens.prev.value);
6449 if (!prefix && peek(0).id === "=" && state.tokens.next.identifier) {
6450 warning("W120", state.tokens.next, state.tokens.next.value);
6452 value = expression(prefix ? 120 : 10);
6454 tokens[0].first = value;
6456 destructuringPatternMatch(names, value);
6460 statement.first = statement.first.concat(names);
6462 if (state.tokens.next.id !== ",") {
6470 statement.block = true;
6471 state.funct["(scope)"].unstack();
6477 var conststatement = stmt("const", function(context) {
6478 return blockVariableStatement("const", this, context);
6480 conststatement.exps = true;
6482 var letstatement = stmt("let", function(context) {
6483 return blockVariableStatement("let", this, context);
6485 letstatement.exps = true;
6487 var varstatement = stmt("var", function(context) {
6488 var prefix = context && context.prefix;
6489 var inexport = context && context.inexport;
6490 var tokens, lone, value;
6491 var implied = context && context.implied;
6492 var report = !(context && context.ignore);
6497 if (_.contains(["{", "["], state.tokens.next.value)) {
6498 tokens = destructuringPattern();
6501 tokens = [ { id: identifier(), token: state.tokens.curr } ];
6505 if (!(prefix && implied) && report && state.option.varstmt) {
6506 warning("W132", this);
6509 this.first = this.first.concat(names);
6511 for (var t in tokens) {
6512 if (tokens.hasOwnProperty(t)) {
6514 if (!implied && state.funct["(global)"]) {
6515 if (predefined[t.id] === false) {
6516 warning("W079", t.token, t.id);
6517 } else if (state.option.futurehostile === false) {
6518 if ((!state.inES5() && vars.ecmaIdentifiers[5][t.id] === false) ||
6519 (!state.inES6() && vars.ecmaIdentifiers[6][t.id] === false)) {
6520 warning("W129", t.token, t.id);
6525 if (implied === "for") {
6527 if (!state.funct["(scope)"].has(t.id)) {
6528 if (report) warning("W088", t.token, t.id);
6530 state.funct["(scope)"].block.use(t.id, t.token);
6532 state.funct["(scope)"].addlabel(t.id, {
6536 if (lone && inexport) {
6537 state.funct["(scope)"].setExported(t.id, t.token);
6540 names.push(t.token);
6545 if (state.tokens.next.id === "=") {
6546 state.nameStack.set(state.tokens.curr);
6549 if (!prefix && report && !state.funct["(loopage)"] &&
6550 state.tokens.next.id === "undefined") {
6551 warning("W080", state.tokens.prev, state.tokens.prev.value);
6553 if (peek(0).id === "=" && state.tokens.next.identifier) {
6554 if (!prefix && report &&
6555 !state.funct["(params)"] ||
6556 state.funct["(params)"].indexOf(state.tokens.next.value) === -1) {
6557 warning("W120", state.tokens.next, state.tokens.next.value);
6560 value = expression(prefix ? 120 : 10);
6562 tokens[0].first = value;
6564 destructuringPatternMatch(names, value);
6568 if (state.tokens.next.id !== ",") {
6576 varstatement.exps = true;
6578 blockstmt("class", function() {
6579 return classdef.call(this, true);
6582 function classdef(isStatement) {
6583 if (!state.inES6()) {
6584 warning("W104", state.tokens.curr, "class", "6");
6587 this.name = identifier();
6589 state.funct["(scope)"].addlabel(this.name, {
6591 token: state.tokens.curr });
6592 } else if (state.tokens.next.identifier && state.tokens.next.value !== "extends") {
6593 this.name = identifier();
6594 this.namedExpr = true;
6596 this.name = state.nameStack.infer();
6602 function classtail(c) {
6603 var wasInClassBody = state.inClassBody;
6604 if (state.tokens.next.value === "extends") {
6606 c.heritage = expression(10);
6609 state.inClassBody = true;
6611 c.body = classbody(c);
6613 state.inClassBody = wasInClassBody;
6616 function classbody(c) {
6621 var props = Object.create(null);
6622 var staticProps = Object.create(null);
6624 for (var i = 0; state.tokens.next.id !== "}"; ++i) {
6625 name = state.tokens.next;
6627 isGenerator = false;
6629 if (name.id === ";") {
6635 if (name.id === "*") {
6638 name = state.tokens.next;
6640 if (name.id === "[") {
6641 name = computedPropertyName();
6643 } else if (isPropertyName(name)) {
6646 if (name.identifier && name.value === "static") {
6647 if (checkPunctuator(state.tokens.next, "*")) {
6651 if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
6652 computed = state.tokens.next.id === "[";
6654 name = state.tokens.next;
6655 if (state.tokens.next.id === "[") {
6656 name = computedPropertyName();
6661 if (name.identifier && (name.value === "get" || name.value === "set")) {
6662 if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
6663 computed = state.tokens.next.id === "[";
6665 name = state.tokens.next;
6666 if (state.tokens.next.id === "[") {
6667 name = computedPropertyName();
6672 warning("W052", state.tokens.next, state.tokens.next.value || state.tokens.next.type);
6677 if (!checkPunctuator(state.tokens.next, "(")) {
6678 error("E054", state.tokens.next, state.tokens.next.value);
6679 while (state.tokens.next.id !== "}" &&
6680 !checkPunctuator(state.tokens.next, "(")) {
6683 if (state.tokens.next.value !== "(") {
6684 doFunction({ statement: c });
6691 getset.value, isStatic ? staticProps : props, name.value, name, true, isStatic);
6693 if (name.value === "constructor") {
6694 state.nameStack.set(c);
6696 state.nameStack.set(name);
6698 saveProperty(isStatic ? staticProps : props, name.value, name, true, isStatic);
6702 if (getset && name.value === "constructor") {
6703 var propDesc = getset.value === "get" ? "class getter method" : "class setter method";
6704 error("E049", name, propDesc, "constructor");
6705 } else if (name.value === "prototype") {
6706 error("E049", name, "class method", "prototype");
6713 type: isGenerator ? "generator" : null,
6714 classExprBinding: c.namedExpr ? c.name : null
6718 checkProperties(props);
6721 blockstmt("function", function(context) {
6722 var inexport = context && context.inexport;
6723 var generator = false;
6724 if (state.tokens.next.value === "*") {
6726 if (state.inES6({ strict: true })) {
6729 warning("W119", state.tokens.curr, "function*", "6");
6733 warning("W082", state.tokens.curr);
6735 var i = optionalidentifier();
6737 state.funct["(scope)"].addlabel(i, {
6739 token: state.tokens.curr });
6741 if (i === undefined) {
6743 } else if (inexport) {
6744 state.funct["(scope)"].setExported(i, state.tokens.prev);
6750 type: generator ? "generator" : null,
6751 ignoreLoopFunc: inblock // a declaration may already have warned
6753 if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) {
6759 prefix("function", function() {
6760 var generator = false;
6762 if (state.tokens.next.value === "*") {
6763 if (!state.inES6()) {
6764 warning("W119", state.tokens.curr, "function*", "6");
6770 var i = optionalidentifier();
6771 doFunction({ name: i, type: generator ? "generator" : null });
6775 blockstmt("if", function() {
6776 var t = state.tokens.next;
6777 increaseComplexityCount();
6778 state.condition = true;
6780 var expr = expression(0);
6781 checkCondAssignment(expr);
6782 var forinifcheck = null;
6783 if (state.option.forin && state.forinifcheckneeded) {
6784 state.forinifcheckneeded = false; // We only need to analyze the first if inside the loop
6785 forinifcheck = state.forinifchecks[state.forinifchecks.length - 1];
6786 if (expr.type === "(punctuator)" && expr.value === "!") {
6787 forinifcheck.type = "(negative)";
6789 forinifcheck.type = "(positive)";
6794 state.condition = false;
6795 var s = block(true, true);
6796 if (forinifcheck && forinifcheck.type === "(negative)") {
6797 if (s && s[0] && s[0].type === "(identifier)" && s[0].value === "continue") {
6798 forinifcheck.type = "(negative-with-continue)";
6802 if (state.tokens.next.id === "else") {
6804 if (state.tokens.next.id === "if" || state.tokens.next.id === "switch") {
6813 blockstmt("try", function() {
6816 function doCatch() {
6820 state.funct["(scope)"].stack("catchparams");
6822 if (checkPunctuators(state.tokens.next, ["[", "{"])) {
6823 var tokens = destructuringPattern();
6824 _.each(tokens, function(token) {
6826 state.funct["(scope)"].addParam(token.id, token, "exception");
6829 } else if (state.tokens.next.type !== "(identifier)") {
6830 warning("E030", state.tokens.next, state.tokens.next.value);
6832 state.funct["(scope)"].addParam(identifier(), state.tokens.curr, "exception");
6835 if (state.tokens.next.value === "if") {
6836 if (!state.inMoz()) {
6837 warning("W118", state.tokens.curr, "catch filter");
6847 state.funct["(scope)"].unstack();
6852 while (state.tokens.next.id === "catch") {
6853 increaseComplexityCount();
6854 if (b && (!state.inMoz())) {
6855 warning("W118", state.tokens.next, "multiple catch blocks");
6861 if (state.tokens.next.id === "finally") {
6868 error("E021", state.tokens.next, "catch", state.tokens.next.value);
6874 blockstmt("while", function() {
6875 var t = state.tokens.next;
6876 state.funct["(breakage)"] += 1;
6877 state.funct["(loopage)"] += 1;
6878 increaseComplexityCount();
6880 checkCondAssignment(expression(0));
6883 state.funct["(breakage)"] -= 1;
6884 state.funct["(loopage)"] -= 1;
6888 blockstmt("with", function() {
6889 var t = state.tokens.next;
6890 if (state.isStrict()) {
6891 error("E010", state.tokens.curr);
6892 } else if (!state.option.withstmt) {
6893 warning("W085", state.tokens.curr);
6904 blockstmt("switch", function() {
6905 var t = state.tokens.next;
6907 var noindent = false;
6909 state.funct["(breakage)"] += 1;
6911 checkCondAssignment(expression(0));
6913 t = state.tokens.next;
6916 if (state.tokens.next.from === indent)
6920 indent += state.option.indent;
6925 switch (state.tokens.next.id) {
6927 switch (state.funct["(verb)"]) {
6937 if (!state.tokens.curr.caseFallsThrough) {
6938 warning("W086", state.tokens.curr, "case");
6943 this.cases.push(expression(0));
6944 increaseComplexityCount();
6947 state.funct["(verb)"] = "case";
6950 switch (state.funct["(verb)"]) {
6958 if (this.cases.length) {
6959 if (!state.tokens.curr.caseFallsThrough) {
6960 warning("W086", state.tokens.curr, "default");
6971 indent -= state.option.indent;
6974 state.funct["(breakage)"] -= 1;
6975 state.funct["(verb)"] = undefined;
6978 error("E023", state.tokens.next, "}");
6981 indent += state.option.indent;
6983 switch (state.tokens.curr.id) {
6992 error("E025", state.tokens.curr);
6996 if (state.tokens.curr.id === ":") {
6998 error("E024", state.tokens.curr, ":");
7001 error("E021", state.tokens.next, "case", state.tokens.next.value);
7005 indent -= state.option.indent;
7011 stmt("debugger", function() {
7012 if (!state.option.debug) {
7013 warning("W087", this);
7019 var x = stmt("do", function() {
7020 state.funct["(breakage)"] += 1;
7021 state.funct["(loopage)"] += 1;
7022 increaseComplexityCount();
7024 this.first = block(true, true);
7026 var t = state.tokens.next;
7028 checkCondAssignment(expression(0));
7030 state.funct["(breakage)"] -= 1;
7031 state.funct["(loopage)"] -= 1;
7038 blockstmt("for", function() {
7039 var s, t = state.tokens.next;
7040 var letscope = false;
7041 var foreachtok = null;
7043 if (t.value === "each") {
7046 if (!state.inMoz()) {
7047 warning("W118", state.tokens.curr, "for each");
7051 increaseComplexityCount();
7053 var nextop; // contains the token of the "in" or "of" operator
7055 var inof = ["in", "of"];
7056 var level = 0; // BindingPattern "level" --- level 0 === no BindingPattern
7057 var comma; // First comma punctuator at level 0
7058 var initializer; // First initializer at level 0
7059 if (checkPunctuators(state.tokens.next, ["{", "["])) ++level;
7063 if (checkPunctuators(nextop, ["{", "["])) ++level;
7064 else if (checkPunctuators(nextop, ["}", "]"])) --level;
7065 if (level < 0) break;
7067 if (!comma && checkPunctuator(nextop, ",")) comma = nextop;
7068 else if (!initializer && checkPunctuator(nextop, "=")) initializer = nextop;
7070 } while (level > 0 || !_.contains(inof, nextop.value) && nextop.value !== ";" &&
7071 nextop.type !== "(end)"); // Is this a JSCS bug? This looks really weird.
7072 if (_.contains(inof, nextop.value)) {
7073 if (!state.inES6() && nextop.value === "of") {
7074 warning("W104", nextop, "for of", "6");
7077 var ok = !(initializer || comma);
7079 error("W133", comma, nextop.value, "initializer is forbidden");
7083 error("W133", comma, nextop.value, "more than one ForBinding");
7086 if (state.tokens.next.id === "var") {
7088 state.tokens.curr.fud({ prefix: true });
7089 } else if (state.tokens.next.id === "let" || state.tokens.next.id === "const") {
7090 advance(state.tokens.next.id);
7092 state.funct["(scope)"].stack();
7093 state.tokens.curr.fud({ prefix: true });
7095 Object.create(varstatement).fud({ prefix: true, implied: "for", ignore: !ok });
7097 advance(nextop.value);
7101 if (nextop.value === "in" && state.option.forin) {
7102 state.forinifcheckneeded = true;
7104 if (state.forinifchecks === undefined) {
7105 state.forinifchecks = [];
7107 state.forinifchecks.push({
7112 state.funct["(breakage)"] += 1;
7113 state.funct["(loopage)"] += 1;
7115 s = block(true, true);
7117 if (nextop.value === "in" && state.option.forin) {
7118 if (state.forinifchecks && state.forinifchecks.length > 0) {
7119 var check = state.forinifchecks.pop();
7121 if (// No if statement or not the first statement in loop body
7122 s && s.length > 0 && (typeof s[0] !== "object" || s[0].value !== "if") ||
7123 check.type === "(positive)" && s.length > 1 ||
7124 check.type === "(negative)") {
7125 warning("W089", this);
7128 state.forinifcheckneeded = false;
7131 state.funct["(breakage)"] -= 1;
7132 state.funct["(loopage)"] -= 1;
7135 error("E045", foreachtok);
7137 if (state.tokens.next.id !== ";") {
7138 if (state.tokens.next.id === "var") {
7140 state.tokens.curr.fud();
7141 } else if (state.tokens.next.id === "let") {
7144 state.funct["(scope)"].stack();
7145 state.tokens.curr.fud();
7148 expression(0, "for");
7149 if (state.tokens.next.id !== ",") {
7156 nolinebreak(state.tokens.curr);
7158 state.funct["(loopage)"] += 1;
7159 if (state.tokens.next.id !== ";") {
7160 checkCondAssignment(expression(0));
7162 nolinebreak(state.tokens.curr);
7164 if (state.tokens.next.id === ";") {
7165 error("E021", state.tokens.next, ")", ";");
7167 if (state.tokens.next.id !== ")") {
7169 expression(0, "for");
7170 if (state.tokens.next.id !== ",") {
7177 state.funct["(breakage)"] += 1;
7179 state.funct["(breakage)"] -= 1;
7180 state.funct["(loopage)"] -= 1;
7184 state.funct["(scope)"].unstack();
7190 stmt("break", function() {
7191 var v = state.tokens.next.value;
7193 if (!state.option.asi)
7196 if (state.tokens.next.id !== ";" && !state.tokens.next.reach &&
7197 state.tokens.curr.line === startLine(state.tokens.next)) {
7198 if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
7199 warning("W090", state.tokens.next, v);
7201 this.first = state.tokens.next;
7204 if (state.funct["(breakage)"] === 0)
7205 warning("W052", state.tokens.next, this.value);
7214 stmt("continue", function() {
7215 var v = state.tokens.next.value;
7217 if (state.funct["(breakage)"] === 0)
7218 warning("W052", state.tokens.next, this.value);
7219 if (!state.funct["(loopage)"])
7220 warning("W052", state.tokens.next, this.value);
7222 if (!state.option.asi)
7225 if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
7226 if (state.tokens.curr.line === startLine(state.tokens.next)) {
7227 if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
7228 warning("W090", state.tokens.next, v);
7230 this.first = state.tokens.next;
7241 stmt("return", function() {
7242 if (this.line === startLine(state.tokens.next)) {
7243 if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
7244 this.first = expression(0);
7247 this.first.type === "(punctuator)" && this.first.value === "=" &&
7248 !this.first.paren && !state.option.boss) {
7249 warningAt("W093", this.first.line, this.first.character);
7253 if (state.tokens.next.type === "(punctuator)" &&
7254 ["[", "{", "+", "-"].indexOf(state.tokens.next.value) > -1) {
7255 nolinebreak(this); // always warn (Line breaking error)
7267 }(prefix("yield", function() {
7268 var prev = state.tokens.prev;
7269 if (state.inES6(true) && !state.funct["(generator)"]) {
7270 if (!("(catch)" === state.funct["(name)"] && state.funct["(context)"]["(generator)"])) {
7271 error("E046", state.tokens.curr, "yield");
7273 } else if (!state.inES6()) {
7274 warning("W104", state.tokens.curr, "yield", "6");
7276 state.funct["(generator)"] = "yielded";
7277 var delegatingYield = false;
7279 if (state.tokens.next.value === "*") {
7280 delegatingYield = true;
7284 if (this.line === startLine(state.tokens.next) || !state.inMoz()) {
7285 if (delegatingYield ||
7286 (state.tokens.next.id !== ";" && !state.option.asi &&
7287 !state.tokens.next.reach && state.tokens.next.nud)) {
7289 nobreaknonadjacent(state.tokens.curr, state.tokens.next);
7290 this.first = expression(10);
7292 if (this.first.type === "(punctuator)" && this.first.value === "=" &&
7293 !this.first.paren && !state.option.boss) {
7294 warningAt("W093", this.first.line, this.first.character);
7298 if (state.inMoz() && state.tokens.next.id !== ")" &&
7299 (prev.lbp > 30 || (!prev.assign && !isEndOfExpr()) || prev.id === "yield")) {
7300 error("E050", this);
7302 } else if (!state.option.asi) {
7303 nolinebreak(this); // always warn (Line breaking error)
7309 stmt("throw", function() {
7311 this.first = expression(20);
7318 stmt("import", function() {
7319 if (!state.inES6()) {
7320 warning("W119", state.tokens.curr, "import", "6");
7323 if (state.tokens.next.type === "(string)") {
7324 advance("(string)");
7328 if (state.tokens.next.identifier) {
7329 this.name = identifier();
7330 state.funct["(scope)"].addlabel(this.name, {
7332 token: state.tokens.curr });
7334 if (state.tokens.next.value === ",") {
7338 advance("(string)");
7343 if (state.tokens.next.id === "*") {
7346 if (state.tokens.next.identifier) {
7347 this.name = identifier();
7348 state.funct["(scope)"].addlabel(this.name, {
7350 token: state.tokens.curr });
7355 if (state.tokens.next.value === "}") {
7360 if (state.tokens.next.type === "default") {
7361 importName = "default";
7364 importName = identifier();
7366 if (state.tokens.next.value === "as") {
7368 importName = identifier();
7370 state.funct["(scope)"].addlabel(importName, {
7372 token: state.tokens.curr });
7374 if (state.tokens.next.value === ",") {
7376 } else if (state.tokens.next.value === "}") {
7380 error("E024", state.tokens.next, state.tokens.next.value);
7386 advance("(string)");
7390 stmt("export", function() {
7395 if (!state.inES6()) {
7396 warning("W119", state.tokens.curr, "export", "6");
7400 if (!state.funct["(scope)"].block.isGlobal()) {
7401 error("E053", state.tokens.curr);
7405 if (state.tokens.next.value === "*") {
7408 advance("(string)");
7412 if (state.tokens.next.type === "default") {
7413 state.nameStack.set(state.tokens.next);
7415 var exportType = state.tokens.next.id;
7416 if (exportType === "function" || exportType === "class") {
7424 identifier = token.value;
7427 state.funct["(scope)"].addlabel(identifier, {
7431 state.funct["(scope)"].setExported(identifier, token);
7437 if (state.tokens.next.value === "{") {
7439 var exportedTokens = [];
7441 if (!state.tokens.next.identifier) {
7442 error("E030", state.tokens.next, state.tokens.next.value);
7446 exportedTokens.push(state.tokens.curr);
7448 if (state.tokens.next.value === "as") {
7450 if (!state.tokens.next.identifier) {
7451 error("E030", state.tokens.next, state.tokens.next.value);
7456 if (state.tokens.next.value === ",") {
7458 } else if (state.tokens.next.value === "}") {
7462 error("E024", state.tokens.next, state.tokens.next.value);
7466 if (state.tokens.next.value === "from") {
7468 advance("(string)");
7470 exportedTokens.forEach(function(token) {
7471 state.funct["(scope)"].setExported(token.value, token);
7477 if (state.tokens.next.id === "var") {
7479 state.tokens.curr.fud({ inexport:true });
7480 } else if (state.tokens.next.id === "let") {
7482 state.tokens.curr.fud({ inexport:true });
7483 } else if (state.tokens.next.id === "const") {
7485 state.tokens.curr.fud({ inexport:true });
7486 } else if (state.tokens.next.id === "function") {
7488 advance("function");
7489 state.syntax["function"].fud({ inexport:true });
7490 } else if (state.tokens.next.id === "class") {
7493 var classNameToken = state.tokens.next;
7494 state.syntax["class"].fud();
7495 state.funct["(scope)"].setExported(classNameToken.value, classNameToken);
7497 error("E024", state.tokens.next, state.tokens.next.value);
7503 FutureReservedWord("abstract");
7504 FutureReservedWord("boolean");
7505 FutureReservedWord("byte");
7506 FutureReservedWord("char");
7507 FutureReservedWord("class", { es5: true, nud: classdef });
7508 FutureReservedWord("double");
7509 FutureReservedWord("enum", { es5: true });
7510 FutureReservedWord("export", { es5: true });
7511 FutureReservedWord("extends", { es5: true });
7512 FutureReservedWord("final");
7513 FutureReservedWord("float");
7514 FutureReservedWord("goto");
7515 FutureReservedWord("implements", { es5: true, strictOnly: true });
7516 FutureReservedWord("import", { es5: true });
7517 FutureReservedWord("int");
7518 FutureReservedWord("interface", { es5: true, strictOnly: true });
7519 FutureReservedWord("long");
7520 FutureReservedWord("native");
7521 FutureReservedWord("package", { es5: true, strictOnly: true });
7522 FutureReservedWord("private", { es5: true, strictOnly: true });
7523 FutureReservedWord("protected", { es5: true, strictOnly: true });
7524 FutureReservedWord("public", { es5: true, strictOnly: true });
7525 FutureReservedWord("short");
7526 FutureReservedWord("static", { es5: true, strictOnly: true });
7527 FutureReservedWord("super", { es5: true });
7528 FutureReservedWord("synchronized");
7529 FutureReservedWord("transient");
7530 FutureReservedWord("volatile");
7532 var lookupBlockType = function() {
7535 var bracketStack = 0;
7537 if (checkPunctuators(state.tokens.curr, ["[", "{"])) {
7541 prev = i === -1 ? state.tokens.curr : pn;
7542 pn = i === -1 ? state.tokens.next : peek(i);
7545 if (checkPunctuators(pn, ["[", "{"])) {
7547 } else if (checkPunctuators(pn, ["]", "}"])) {
7550 if (bracketStack === 1 && pn.identifier && pn.value === "for" &&
7551 !checkPunctuator(prev, ".")) {
7552 ret.isCompArray = true;
7556 if (bracketStack === 0 && checkPunctuators(pn, ["}", "]"])) {
7557 if (pn1.value === "=") {
7558 ret.isDestAssign = true;
7561 } else if (pn1.value === ".") {
7566 if (checkPunctuator(pn, ";")) {
7570 } while (bracketStack > 0 && pn.id !== "(end)");
7574 function saveProperty(props, name, tkn, isClass, isStatic) {
7575 var msg = ["key", "class method", "static class method"];
7576 msg = msg[(isClass || false) + (isStatic || false)];
7577 if (tkn.identifier) {
7581 if (props[name] && name !== "__proto__") {
7582 warning("W075", state.tokens.next, msg, name);
7584 props[name] = Object.create(null);
7587 props[name].basic = true;
7588 props[name].basictkn = tkn;
7590 function saveAccessor(accessorType, props, name, tkn, isClass, isStatic) {
7591 var flagName = accessorType === "get" ? "getterToken" : "setterToken";
7598 msg += accessorType + "ter method";
7603 state.tokens.curr.accessorType = accessorType;
7604 state.nameStack.set(tkn);
7607 if ((props[name].basic || props[name][flagName]) && name !== "__proto__") {
7608 warning("W075", state.tokens.next, msg, name);
7611 props[name] = Object.create(null);
7614 props[name][flagName] = tkn;
7617 function computedPropertyName() {
7619 if (!state.inES6()) {
7620 warning("W119", state.tokens.curr, "computed property names", "6");
7622 var value = expression(10);
7626 function checkPunctuators(token, values) {
7627 if (token.type === "(punctuator)") {
7628 return _.contains(values, token.value);
7632 function checkPunctuator(token, value) {
7633 return token.type === "(punctuator)" && token.value === value;
7635 function destructuringAssignOrJsonValue() {
7637 var block = lookupBlockType();
7638 if (block.notJson) {
7639 if (!state.inES6() && block.isDestAssign) {
7640 warning("W104", state.tokens.curr, "destructuring assignment", "6");
7644 state.option.laxbreak = true;
7645 state.jsonMode = true;
7650 var arrayComprehension = function() {
7651 var CompArray = function() {
7653 this.variables = [];
7657 function declare(v) {
7658 var l = _current.variables.filter(function(elt) {
7659 if (elt.value === v) {
7667 var l = _current.variables.filter(function(elt) {
7668 if (elt.value === v && !elt.undef) {
7669 if (elt.unused === true) {
7677 return { stack: function() {
7678 _current = new CompArray();
7679 _carrays.push(_current);
7681 unstack: function() {
7682 _current.variables.filter(function(v) {
7684 warning("W098", v.token, v.raw_text || v.value);
7686 state.funct["(scope)"].block.use(v.value, v.token);
7688 _carrays.splice(-1, 1);
7689 _current = _carrays[_carrays.length - 1];
7691 setState: function(s) {
7692 if (_.contains(["use", "define", "generate", "filter"], s))
7695 check: function(v) {
7699 if (_current && _current.mode === "use") {
7701 _current.variables.push({
7703 token: state.tokens.curr,
7710 } else if (_current && _current.mode === "define") {
7712 _current.variables.push({
7714 token: state.tokens.curr,
7721 } else if (_current && _current.mode === "generate") {
7722 state.funct["(scope)"].block.use(v, state.tokens.curr);
7724 } else if (_current && _current.mode === "filter") {
7726 state.funct["(scope)"].block.use(v, state.tokens.curr);
7735 function jsonValue() {
7736 function jsonObject() {
7737 var o = {}, t = state.tokens.next;
7739 if (state.tokens.next.id !== "}") {
7741 if (state.tokens.next.id === "(end)") {
7742 error("E026", state.tokens.next, t.line);
7743 } else if (state.tokens.next.id === "}") {
7744 warning("W094", state.tokens.curr);
7746 } else if (state.tokens.next.id === ",") {
7747 error("E028", state.tokens.next);
7748 } else if (state.tokens.next.id !== "(string)") {
7749 warning("W095", state.tokens.next, state.tokens.next.value);
7751 if (o[state.tokens.next.value] === true) {
7752 warning("W075", state.tokens.next, "key", state.tokens.next.value);
7753 } else if ((state.tokens.next.value === "__proto__" &&
7754 !state.option.proto) || (state.tokens.next.value === "__iterator__" &&
7755 !state.option.iterator)) {
7756 warning("W096", state.tokens.next, state.tokens.next.value);
7758 o[state.tokens.next.value] = true;
7763 if (state.tokens.next.id !== ",") {
7772 function jsonArray() {
7773 var t = state.tokens.next;
7775 if (state.tokens.next.id !== "]") {
7777 if (state.tokens.next.id === "(end)") {
7778 error("E027", state.tokens.next, t.line);
7779 } else if (state.tokens.next.id === "]") {
7780 warning("W094", state.tokens.curr);
7782 } else if (state.tokens.next.id === ",") {
7783 error("E028", state.tokens.next);
7786 if (state.tokens.next.id !== ",") {
7795 switch (state.tokens.next.id) {
7811 advance("(number)");
7814 error("E003", state.tokens.next);
7818 var escapeRegex = function(str) {
7819 return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
7821 var itself = function(s, o, g) {
7822 var i, k, x, reIgnoreStr, reIgnore;
7824 var newOptionObj = {};
7825 var newIgnoredObj = {};
7831 JSHINT.scope = o.scope;
7835 JSHINT.internals = [];
7836 JSHINT.blacklist = {};
7837 JSHINT.scope = "(main)";
7840 predefined = Object.create(null);
7841 combine(predefined, vars.ecmaIdentifiers[3]);
7842 combine(predefined, vars.reservedVars);
7844 combine(predefined, g || {});
7846 declared = Object.create(null);
7847 var exported = Object.create(null); // Variables that live outside the current file
7849 function each(obj, cb) {
7853 if (!Array.isArray(obj) && typeof obj === "object")
7854 obj = Object.keys(obj);
7860 each(o.predef || null, function(item) {
7863 if (item[0] === "-") {
7864 slice = item.slice(1);
7865 JSHINT.blacklist[slice] = slice;
7866 delete predefined[slice];
7868 prop = Object.getOwnPropertyDescriptor(o.predef, item);
7869 predefined[item] = prop ? prop.value : false;
7873 each(o.exported || null, function(item) {
7874 exported[item] = true;
7880 optionKeys = Object.keys(o);
7881 for (x = 0; x < optionKeys.length; x++) {
7882 if (/^-W\d{3}$/g.test(optionKeys[x])) {
7883 newIgnoredObj[optionKeys[x].slice(1)] = true;
7885 var optionKey = optionKeys[x];
7886 newOptionObj[optionKey] = o[optionKey];
7887 if ((optionKey === "esversion" && o[optionKey] === 5) ||
7888 (optionKey === "es5" && o[optionKey])) {
7892 if (optionKeys[x] === "newcap" && o[optionKey] === false)
7893 newOptionObj["(explicitNewcap)"] = true;
7898 state.option = newOptionObj;
7899 state.ignored = newIgnoredObj;
7901 state.option.indent = state.option.indent || 4;
7902 state.option.maxerr = state.option.maxerr || 50;
7906 var scopeManagerInst = scopeManager(state, predefined, exported, declared);
7907 scopeManagerInst.on("warning", function(ev) {
7908 warning.apply(null, [ ev.code, ev.token].concat(ev.data));
7911 scopeManagerInst.on("error", function(ev) {
7912 error.apply(null, [ ev.code, ev.token ].concat(ev.data));
7915 state.funct = functor("(global)", null, {
7917 "(scope)" : scopeManagerInst,
7918 "(comparray)" : arrayComprehension(),
7919 "(metrics)" : createMetrics(state.tokens.next)
7922 functions = [state.funct];
7930 if (!isString(s) && !Array.isArray(s)) {
7937 return state.jsonMode;
7940 getOption: function(name) {
7941 return state.option[name] || null;
7944 getCache: function(name) {
7945 return state.cache[name];
7948 setCache: function(name, value) {
7949 state.cache[name] = value;
7952 warn: function(code, data) {
7953 warningAt.apply(null, [ code, data.line, data.char ].concat(data.data));
7956 on: function(names, listener) {
7957 names.split(" ").forEach(function(name) {
7958 emitter.on(name, listener);
7963 emitter.removeAllListeners();
7964 (extraModules || []).forEach(function(func) {
7968 state.tokens.prev = state.tokens.curr = state.tokens.next = state.syntax["(begin)"];
7970 if (o && o.ignoreDelimiters) {
7972 if (!Array.isArray(o.ignoreDelimiters)) {
7973 o.ignoreDelimiters = [o.ignoreDelimiters];
7976 o.ignoreDelimiters.forEach(function(delimiterPair) {
7977 if (!delimiterPair.start || !delimiterPair.end)
7980 reIgnoreStr = escapeRegex(delimiterPair.start) +
7982 escapeRegex(delimiterPair.end);
7984 reIgnore = new RegExp(reIgnoreStr, "ig");
7986 s = s.replace(reIgnore, function(match) {
7987 return match.replace(/./g, " ");
7994 lex.on("warning", function(ev) {
7995 warningAt.apply(null, [ ev.code, ev.line, ev.character].concat(ev.data));
7998 lex.on("error", function(ev) {
7999 errorAt.apply(null, [ ev.code, ev.line, ev.character ].concat(ev.data));
8002 lex.on("fatal", function(ev) {
8003 quit("E041", ev.line, ev.from);
8006 lex.on("Identifier", function(ev) {
8007 emitter.emit("Identifier", ev);
8010 lex.on("String", function(ev) {
8011 emitter.emit("String", ev);
8014 lex.on("Number", function(ev) {
8015 emitter.emit("Number", ev);
8019 for (var name in o) {
8020 if (_.has(o, name)) {
8021 checkOption(name, state.tokens.curr);
8026 combine(predefined, g || {});
8031 switch (state.tokens.next.id) {
8034 destructuringAssignOrJsonValue();
8039 if (state.directive["use strict"]) {
8040 if (state.option.strict !== "global") {
8041 warning("W097", state.tokens.prev);
8048 if (state.tokens.next.id !== "(end)") {
8049 quit("E041", state.tokens.curr.line);
8052 state.funct["(scope)"].unstack();
8055 if (err && err.name === "JSHintError") {
8056 var nt = state.tokens.next || {};
8057 JSHINT.errors.push({
8061 reason : err.message,
8062 line : err.line || nt.line,
8063 character : err.character || nt.from
8070 if (JSHINT.scope === "(main)") {
8073 for (i = 0; i < JSHINT.internals.length; i += 1) {
8074 k = JSHINT.internals[i];
8076 itself(k.value, o, g);
8080 return JSHINT.errors.length === 0;
8082 itself.addModule = function(func) {
8083 extraModules.push(func);
8086 itself.addModule(style.register);
8087 itself.data = function() {
8090 options: state.option
8093 var fu, f, i, j, n, globals;
8095 if (itself.errors.length) {
8096 data.errors = itself.errors;
8099 if (state.jsonMode) {
8103 var impliedGlobals = state.funct["(scope)"].getImpliedGlobals();
8104 if (impliedGlobals.length > 0) {
8105 data.implieds = impliedGlobals;
8108 if (urls.length > 0) {
8112 globals = state.funct["(scope)"].getUsedOrDefinedGlobals();
8113 if (globals.length > 0) {
8114 data.globals = globals;
8117 for (i = 1; i < functions.length; i += 1) {
8121 for (j = 0; j < functionicity.length; j += 1) {
8122 fu[functionicity[j]] = [];
8125 for (j = 0; j < functionicity.length; j += 1) {
8126 if (fu[functionicity[j]].length === 0) {
8127 delete fu[functionicity[j]];
8131 fu.name = f["(name)"];
8132 fu.param = f["(params)"];
8133 fu.line = f["(line)"];
8134 fu.character = f["(character)"];
8135 fu.last = f["(last)"];
8136 fu.lastcharacter = f["(lastcharacter)"];
8139 complexity: f["(metrics)"].ComplexityCount,
8140 parameters: f["(metrics)"].arity,
8141 statements: f["(metrics)"].statementCount
8144 data.functions.push(fu);
8147 var unuseds = state.funct["(scope)"].getUnuseds();
8148 if (unuseds.length > 0) {
8149 data.unused = unuseds;
8153 if (typeof member[n] === "number") {
8154 data.member = member;
8162 itself.jshint = itself;
8166 if (typeof exports === "object" && exports) {
8167 exports.JSHINT = JSHINT;
8170 },{"../lodash":"/node_modules/jshint/lodash.js","./lex.js":"/node_modules/jshint/src/lex.js","./messages.js":"/node_modules/jshint/src/messages.js","./options.js":"/node_modules/jshint/src/options.js","./reg.js":"/node_modules/jshint/src/reg.js","./scope-manager.js":"/node_modules/jshint/src/scope-manager.js","./state.js":"/node_modules/jshint/src/state.js","./style.js":"/node_modules/jshint/src/style.js","./vars.js":"/node_modules/jshint/src/vars.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/lex.js":[function(_dereq_,module,exports){
8174 var _ = _dereq_("../lodash");
8175 var events = _dereq_("events");
8176 var reg = _dereq_("./reg.js");
8177 var state = _dereq_("./state.js").state;
8179 var unicodeData = _dereq_("../data/ascii-identifier-data.js");
8180 var asciiIdentifierStartTable = unicodeData.asciiIdentifierStartTable;
8181 var asciiIdentifierPartTable = unicodeData.asciiIdentifierPartTable;
8204 function asyncTrigger() {
8208 push: function(fn) {
8213 for (var check = 0; check < _checks.length; ++check) {
8217 _checks.splice(0, _checks.length);
8221 function Lexer(source) {
8224 if (typeof lines === "string") {
8226 .replace(/\r\n/g, "\n")
8227 .replace(/\r/g, "\n")
8231 if (lines[0] && lines[0].substr(0, 2) === "#!") {
8232 if (lines[0].indexOf("node") !== -1) {
8233 state.option.node = true;
8238 this.emitter = new events.EventEmitter();
8239 this.source = source;
8240 this.setLines(lines);
8247 this.inComment = false;
8249 this.templateStarts = [];
8251 for (var i = 0; i < state.option.indent; i += 1) {
8254 this.ignoreLinterErrors = false;
8260 inContext: function(ctxType) {
8261 return this.context.length > 0 && this.context[this.context.length - 1].type === ctxType;
8264 pushContext: function(ctxType) {
8265 this.context.push({ type: ctxType });
8268 popContext: function() {
8269 return this.context.pop();
8272 isContext: function(context) {
8273 return this.context.length > 0 && this.context[this.context.length - 1] === context;
8276 currentContext: function() {
8277 return this.context.length > 0 && this.context[this.context.length - 1];
8280 getLines: function() {
8281 this._lines = state.lines;
8285 setLines: function(val) {
8287 state.lines = this._lines;
8290 return this.input.charAt(i || 0);
8295 this.input = this.input.slice(i);
8297 on: function(names, listener) {
8298 names.split(" ").forEach(function(name) {
8299 this.emitter.on(name, listener);
8302 trigger: function() {
8303 this.emitter.emit.apply(this.emitter, Array.prototype.slice.call(arguments));
8305 triggerAsync: function(type, args, checks, fn) {
8306 checks.push(function() {
8308 this.trigger(type, args);
8312 scanPunctuator: function() {
8313 var ch1 = this.peek();
8318 if ((/^[0-9]$/).test(this.peek(1))) {
8321 if (this.peek(1) === "." && this.peek(2) === ".") {
8323 type: Token.Punctuator,
8337 type: Token.Punctuator,
8341 this.pushContext(Context.Block);
8343 type: Token.Punctuator,
8347 if (this.inContext(Context.Block)) {
8351 type: Token.Punctuator,
8356 type: Token.Punctuator,
8367 if (ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=") {
8369 type: Token.Punctuator,
8374 if (ch1 === "=" && ch2 === "=" && ch3 === "=") {
8376 type: Token.Punctuator,
8381 if (ch1 === "!" && ch2 === "=" && ch3 === "=") {
8383 type: Token.Punctuator,
8388 if (ch1 === ">" && ch2 === ">" && ch3 === ">") {
8390 type: Token.Punctuator,
8395 if (ch1 === "<" && ch2 === "<" && ch3 === "=") {
8397 type: Token.Punctuator,
8402 if (ch1 === ">" && ch2 === ">" && ch3 === "=") {
8404 type: Token.Punctuator,
8408 if (ch1 === "=" && ch2 === ">") {
8410 type: Token.Punctuator,
8414 if (ch1 === ch2 && ("+-<>&|".indexOf(ch1) >= 0)) {
8416 type: Token.Punctuator,
8421 if ("<>=!+-*%&|^".indexOf(ch1) >= 0) {
8424 type: Token.Punctuator,
8430 type: Token.Punctuator,
8438 type: Token.Punctuator,
8444 type: Token.Punctuator,
8451 scanComments: function() {
8452 var ch1 = this.peek();
8453 var ch2 = this.peek(1);
8454 var rest = this.input.substr(2);
8455 var startLine = this.line;
8456 var startChar = this.char;
8459 function commentToken(label, body, opt) {
8460 var special = ["jshint", "jslint", "members", "member", "globals", "global", "exported"];
8461 var isSpecial = false;
8462 var value = label + body;
8463 var commentType = "plain";
8466 if (opt.isMultiline) {
8470 body = body.replace(/\n/g, " ");
8472 if (label === "/*" && reg.fallsThrough.test(body)) {
8474 commentType = "falls through";
8477 special.forEach(function(str) {
8481 if (label === "//" && str !== "jshint") {
8485 if (body.charAt(str.length) === " " && body.substr(0, str.length) === str) {
8487 label = label + str;
8488 body = body.substr(str.length);
8491 if (!isSpecial && body.charAt(0) === " " && body.charAt(str.length + 1) === " " &&
8492 body.substr(1, str.length) === str) {
8494 label = label + " " + str;
8495 body = body.substr(str.length + 1);
8504 commentType = "members";
8507 commentType = "globals";
8510 var options = body.split(":").map(function(v) {
8511 return v.replace(/^\s+/, "").replace(/\s+$/, "");
8514 if (options.length === 2) {
8515 switch (options[0]) {
8517 switch (options[1]) {
8519 self.ignoringLinterErrors = true;
8523 self.ignoringLinterErrors = false;
8535 type: Token.Comment,
8536 commentType: commentType,
8539 isSpecial: isSpecial,
8540 isMultiline: opt.isMultiline || false,
8541 isMalformed: opt.isMalformed || false
8544 if (ch1 === "*" && ch2 === "/") {
8545 this.trigger("error", {
8548 character: startChar
8554 if (ch1 !== "/" || (ch2 !== "*" && ch2 !== "/")) {
8558 this.skip(this.input.length); // Skip to the EOL.
8559 return commentToken("//", rest);
8564 this.inComment = true;
8567 while (this.peek() !== "*" || this.peek(1) !== "/") {
8568 if (this.peek() === "") { // End of Line
8570 if (!this.nextLine()) {
8571 this.trigger("error", {
8574 character: startChar
8577 this.inComment = false;
8578 return commentToken("/*", body, {
8584 body += this.peek();
8590 this.inComment = false;
8591 return commentToken("/*", body, { isMultiline: true });
8594 scanKeyword: function() {
8595 var result = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input);
8597 "if", "in", "do", "var", "for", "new",
8598 "try", "let", "this", "else", "case",
8599 "void", "with", "enum", "while", "break",
8600 "catch", "throw", "const", "yield", "class",
8601 "super", "return", "typeof", "delete",
8602 "switch", "export", "import", "default",
8603 "finally", "extends", "function", "continue",
8604 "debugger", "instanceof"
8607 if (result && keywords.indexOf(result[0]) >= 0) {
8609 type: Token.Keyword,
8616 scanIdentifier: function() {
8621 function isNonAsciiIdentifierStart(code) {
8625 function isNonAsciiIdentifierPart(code) {
8629 function isHexDigit(str) {
8630 return (/^[0-9a-fA-F]$/).test(str);
8633 var readUnicodeEscapeSequence = function() {
8636 if (this.peek(index) !== "u") {
8640 var ch1 = this.peek(index + 1);
8641 var ch2 = this.peek(index + 2);
8642 var ch3 = this.peek(index + 3);
8643 var ch4 = this.peek(index + 4);
8646 if (isHexDigit(ch1) && isHexDigit(ch2) && isHexDigit(ch3) && isHexDigit(ch4)) {
8647 code = parseInt(ch1 + ch2 + ch3 + ch4, 16);
8649 if (asciiIdentifierPartTable[code] || isNonAsciiIdentifierPart(code)) {
8651 return "\\u" + ch1 + ch2 + ch3 + ch4;
8660 var getIdentifierStart = function() {
8661 var chr = this.peek(index);
8662 var code = chr.charCodeAt(0);
8665 return readUnicodeEscapeSequence();
8669 if (asciiIdentifierStartTable[code]) {
8677 if (isNonAsciiIdentifierStart(code)) {
8685 var getIdentifierPart = function() {
8686 var chr = this.peek(index);
8687 var code = chr.charCodeAt(0);
8690 return readUnicodeEscapeSequence();
8694 if (asciiIdentifierPartTable[code]) {
8702 if (isNonAsciiIdentifierPart(code)) {
8710 function removeEscapeSequences(id) {
8711 return id.replace(/\\u([0-9a-fA-F]{4})/g, function(m0, codepoint) {
8712 return String.fromCharCode(parseInt(codepoint, 16));
8716 char = getIdentifierStart();
8717 if (char === null) {
8723 char = getIdentifierPart();
8725 if (char === null) {
8735 type = Token.BooleanLiteral;
8738 type = Token.NullLiteral;
8741 type = Token.Identifier;
8746 value: removeEscapeSequences(id),
8748 tokenLength: id.length
8751 scanNumericLiteral: function() {
8754 var length = this.input.length;
8755 var char = this.peek(index);
8757 var isAllowedDigit = isDecimalDigit;
8759 var isLegacy = false;
8761 function isDecimalDigit(str) {
8762 return (/^[0-9]$/).test(str);
8765 function isOctalDigit(str) {
8766 return (/^[0-7]$/).test(str);
8769 function isBinaryDigit(str) {
8770 return (/^[01]$/).test(str);
8773 function isHexDigit(str) {
8774 return (/^[0-9a-fA-F]$/).test(str);
8777 function isIdentifierStart(ch) {
8778 return (ch === "$") || (ch === "_") || (ch === "\\") ||
8779 (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z");
8782 if (char !== "." && !isDecimalDigit(char)) {
8787 value = this.peek(index);
8789 char = this.peek(index);
8791 if (value === "0") {
8792 if (char === "x" || char === "X") {
8793 isAllowedDigit = isHexDigit;
8799 if (char === "o" || char === "O") {
8800 isAllowedDigit = isOctalDigit;
8803 if (!state.inES6(true)) {
8804 this.trigger("warning", {
8807 character: this.char,
8808 data: [ "Octal integer literal", "6" ]
8815 if (char === "b" || char === "B") {
8816 isAllowedDigit = isBinaryDigit;
8819 if (!state.inES6(true)) {
8820 this.trigger("warning", {
8823 character: this.char,
8824 data: [ "Binary integer literal", "6" ]
8831 if (isOctalDigit(char)) {
8832 isAllowedDigit = isOctalDigit;
8841 if (!isOctalDigit(char) && isDecimalDigit(char)) {
8847 while (index < length) {
8848 char = this.peek(index);
8850 if (isLegacy && isDecimalDigit(char)) {
8852 } else if (!isAllowedDigit(char)) {
8859 if (isAllowedDigit !== isDecimalDigit) {
8860 if (!isLegacy && value.length <= 2) { // 0x
8862 type: Token.NumericLiteral,
8868 if (index < length) {
8869 char = this.peek(index);
8870 if (isIdentifierStart(char)) {
8876 type: Token.NumericLiteral,
8889 while (index < length) {
8890 char = this.peek(index);
8891 if (!isDecimalDigit(char)) {
8899 if (char === "e" || char === "E") {
8902 char = this.peek(index);
8904 if (char === "+" || char === "-") {
8905 value += this.peek(index);
8909 char = this.peek(index);
8910 if (isDecimalDigit(char)) {
8914 while (index < length) {
8915 char = this.peek(index);
8916 if (!isDecimalDigit(char)) {
8927 if (index < length) {
8928 char = this.peek(index);
8929 if (isIdentifierStart(char)) {
8935 type: Token.NumericLiteral,
8938 isMalformed: !isFinite(value)
8941 scanEscapeSequence: function(checks) {
8942 var allowNewLine = false;
8945 var char = this.peek();
8949 this.triggerAsync("warning", {
8952 character: this.char,
8954 }, checks, function() {return state.jsonMode; });
8973 var n = parseInt(this.peek(1), 10);
8974 this.triggerAsync("warning", {
8977 character: this.char
8979 function() { return n >= 0 && n <= 7 && state.isStrict(); });
8982 var hexCode = this.input.substr(1, 4);
8983 var code = parseInt(hexCode, 16);
8985 this.trigger("warning", {
8988 character: this.char,
8989 data: [ "u" + hexCode ]
8992 char = String.fromCharCode(code);
8996 this.triggerAsync("warning", {
8999 character: this.char,
9001 }, checks, function() { return state.jsonMode; });
9006 var x = parseInt(this.input.substr(1, 2), 16);
9008 this.triggerAsync("warning", {
9011 character: this.char,
9013 }, checks, function() { return state.jsonMode; });
9015 char = String.fromCharCode(x);
9027 allowNewLine = true;
9032 return { char: char, jump: jump, allowNewLine: allowNewLine };
9034 scanTemplateLiteral: function(checks) {
9038 var startLine = this.line;
9039 var startChar = this.char;
9040 var depth = this.templateStarts.length;
9042 if (!state.inES6(true)) {
9044 } else if (this.peek() === "`") {
9045 tokenType = Token.TemplateHead;
9046 this.templateStarts.push({ line: this.line, char: this.char });
9047 depth = this.templateStarts.length;
9049 this.pushContext(Context.Template);
9050 } else if (this.inContext(Context.Template) && this.peek() === "}") {
9051 tokenType = Token.TemplateMiddle;
9056 while (this.peek() !== "`") {
9057 while ((ch = this.peek()) === "") {
9059 if (!this.nextLine()) {
9060 var startPos = this.templateStarts.pop();
9061 this.trigger("error", {
9063 line: startPos.line,
9064 character: startPos.char
9069 startLine: startLine,
9070 startChar: startChar,
9073 context: this.popContext()
9078 if (ch === '$' && this.peek(1) === '{') {
9084 startLine: startLine,
9085 startChar: startChar,
9088 context: this.currentContext()
9090 } else if (ch === '\\') {
9091 var escape = this.scanEscapeSequence(checks);
9092 value += escape.char;
9093 this.skip(escape.jump);
9094 } else if (ch !== '`') {
9099 tokenType = tokenType === Token.TemplateHead ? Token.NoSubstTemplate : Token.TemplateTail;
9101 this.templateStarts.pop();
9106 startLine: startLine,
9107 startChar: startChar,
9110 context: this.popContext()
9113 scanStringLiteral: function(checks) {
9114 var quote = this.peek();
9115 if (quote !== "\"" && quote !== "'") {
9118 this.triggerAsync("warning", {
9121 character: this.char // +1?
9122 }, checks, function() { return state.jsonMode && quote !== "\""; });
9125 var startLine = this.line;
9126 var startChar = this.char;
9127 var allowNewLine = false;
9131 while (this.peek() !== quote) {
9132 if (this.peek() === "") { // End Of Line
9134 if (!allowNewLine) {
9135 this.trigger("warning", {
9138 character: this.char
9141 allowNewLine = false;
9143 this.triggerAsync("warning", {
9146 character: this.char
9147 }, checks, function() { return !state.option.multistr; });
9149 this.triggerAsync("warning", {
9152 character: this.char
9153 }, checks, function() { return state.jsonMode && state.option.multistr; });
9156 if (!this.nextLine()) {
9157 this.trigger("error", {
9160 character: startChar
9164 type: Token.StringLiteral,
9166 startLine: startLine,
9167 startChar: startChar,
9173 } else { // Any character other than End Of Line
9175 allowNewLine = false;
9176 var char = this.peek();
9177 var jump = 1; // A length of a jump, after we're done
9180 this.trigger("warning", {
9183 character: this.char,
9184 data: [ "<non-printable>" ]
9187 if (char === "\\") {
9188 var parsed = this.scanEscapeSequence(checks);
9191 allowNewLine = parsed.allowNewLine;
9201 type: Token.StringLiteral,
9203 startLine: startLine,
9204 startChar: startChar,
9209 scanRegExp: function() {
9211 var length = this.input.length;
9212 var char = this.peek();
9216 var malformed = false;
9217 var isCharSet = false;
9220 var scanUnexpectedChars = function() {
9223 this.trigger("warning", {
9226 character: this.char
9231 this.trigger("warning", {
9234 character: this.char,
9239 if (!this.prereg || char !== "/") {
9246 while (index < length) {
9247 char = this.peek(index);
9253 if (this.peek(index - 1) !== "\\" || this.peek(index - 2) === "\\") {
9258 if (char === "\\") {
9260 char = this.peek(index);
9264 scanUnexpectedChars();
9271 if (char === "\\") {
9273 char = this.peek(index);
9277 scanUnexpectedChars();
9297 body = body.substr(0, body.length - 1);
9307 this.trigger("error", {
9310 character: this.from
9313 return void this.trigger("fatal", {
9319 while (index < length) {
9320 char = this.peek(index);
9321 if (!/[gim]/.test(char)) {
9330 new RegExp(body, flags.join(""));
9333 this.trigger("error", {
9336 character: this.char,
9337 data: [ err.message ] // Platform dependent!
9345 isMalformed: malformed
9348 scanNonBreakingSpaces: function() {
9349 return state.option.nonbsp ?
9350 this.input.search(/(\u00A0)/) : -1;
9352 scanUnsafeChars: function() {
9353 return this.input.search(reg.unsafeChars);
9355 next: function(checks) {
9356 this.from = this.char;
9358 if (/\s/.test(this.peek())) {
9361 while (/\s/.test(this.peek())) {
9367 var match = this.scanComments() ||
9368 this.scanStringLiteral(checks) ||
9369 this.scanTemplateLiteral(checks);
9376 this.scanRegExp() ||
9377 this.scanPunctuator() ||
9378 this.scanKeyword() ||
9379 this.scanIdentifier() ||
9380 this.scanNumericLiteral();
9383 this.skip(match.tokenLength || match.value.length);
9389 nextLine: function() {
9392 if (this.line >= this.getLines().length) {
9396 this.input = this.getLines()[this.line];
9401 var inputTrimmed = this.input.trim();
9403 var startsWith = function() {
9404 return _.some(arguments, function(prefix) {
9405 return inputTrimmed.indexOf(prefix) === 0;
9409 var endsWith = function() {
9410 return _.some(arguments, function(suffix) {
9411 return inputTrimmed.indexOf(suffix, inputTrimmed.length - suffix.length) !== -1;
9414 if (this.ignoringLinterErrors === true) {
9415 if (!startsWith("/*", "//") && !(this.inComment && endsWith("*/"))) {
9420 char = this.scanNonBreakingSpaces();
9422 this.trigger("warning", { code: "W125", line: this.line, character: char + 1 });
9425 this.input = this.input.replace(/\t/g, state.tab);
9426 char = this.scanUnsafeChars();
9429 this.trigger("warning", { code: "W100", line: this.line, character: char });
9432 if (!this.ignoringLinterErrors && state.option.maxlen &&
9433 state.option.maxlen < this.input.length) {
9434 var inComment = this.inComment ||
9435 startsWith.call(inputTrimmed, "//") ||
9436 startsWith.call(inputTrimmed, "/*");
9438 var shouldTriggerError = !inComment || !reg.maxlenException.test(inputTrimmed);
9440 if (shouldTriggerError) {
9441 this.trigger("warning", { code: "W101", line: this.line, character: this.input.length });
9451 var checks = asyncTrigger();
9455 function isReserved(token, isProperty) {
9456 if (!token.reserved) {
9459 var meta = token.meta;
9461 if (meta && meta.isFutureReservedWord && state.inES5()) {
9465 if (meta.strictOnly) {
9466 if (!state.option.strict && !state.isStrict()) {
9478 var create = function(type, value, isProperty, token) {
9481 if (type !== "(endline)" && type !== "(end)") {
9482 this.prereg = false;
9485 if (type === "(punctuator)") {
9494 this.prereg = false;
9500 obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
9503 if (type === "(identifier)") {
9504 if (value === "return" || value === "case" || value === "typeof") {
9508 if (_.has(state.syntax, value)) {
9509 obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
9510 if (!isReserved(obj, isProperty && type === "(identifier)")) {
9517 obj = Object.create(state.syntax[type]);
9520 obj.identifier = (type === "(identifier)");
9521 obj.type = obj.type || type;
9523 obj.line = this.line;
9524 obj.character = this.char;
9525 obj.from = this.from;
9526 if (obj.identifier && token) obj.raw_text = token.text || token.value;
9527 if (token && token.startLine && token.startLine !== this.line) {
9528 obj.startLine = token.startLine;
9530 if (token && token.context) {
9531 obj.context = token.context;
9533 if (token && token.depth) {
9534 obj.depth = token.depth;
9536 if (token && token.isUnclosed) {
9537 obj.isUnclosed = token.isUnclosed;
9540 if (isProperty && obj.identifier) {
9541 obj.isProperty = isProperty;
9544 obj.check = checks.check;
9550 if (!this.input.length) {
9551 if (this.nextLine()) {
9552 return create("(endline)", "");
9555 if (this.exhausted) {
9559 this.exhausted = true;
9560 return create("(end)", "");
9563 token = this.next(checks);
9566 if (this.input.length) {
9567 this.trigger("error", {
9570 character: this.char,
9571 data: [ this.peek() ]
9580 switch (token.type) {
9581 case Token.StringLiteral:
9582 this.triggerAsync("String", {
9586 startLine: token.startLine,
9587 startChar: token.startChar,
9590 }, checks, function() { return true; });
9592 return create("(string)", token.value, null, token);
9594 case Token.TemplateHead:
9595 this.trigger("TemplateHead", {
9599 startLine: token.startLine,
9600 startChar: token.startChar,
9603 return create("(template)", token.value, null, token);
9605 case Token.TemplateMiddle:
9606 this.trigger("TemplateMiddle", {
9610 startLine: token.startLine,
9611 startChar: token.startChar,
9614 return create("(template middle)", token.value, null, token);
9616 case Token.TemplateTail:
9617 this.trigger("TemplateTail", {
9621 startLine: token.startLine,
9622 startChar: token.startChar,
9625 return create("(template tail)", token.value, null, token);
9627 case Token.NoSubstTemplate:
9628 this.trigger("NoSubstTemplate", {
9632 startLine: token.startLine,
9633 startChar: token.startChar,
9636 return create("(no subst template)", token.value, null, token);
9638 case Token.Identifier:
9639 this.triggerAsync("Identifier", {
9644 raw_name: token.text,
9645 isProperty: state.tokens.curr.id === "."
9646 }, checks, function() { return true; });
9648 case Token.NullLiteral:
9649 case Token.BooleanLiteral:
9650 return create("(identifier)", token.value, state.tokens.curr.id === ".", token);
9652 case Token.NumericLiteral:
9653 if (token.isMalformed) {
9654 this.trigger("warning", {
9657 character: this.char,
9658 data: [ token.value ]
9662 this.triggerAsync("warning", {
9665 character: this.char,
9667 }, checks, function() { return token.base === 16 && state.jsonMode; });
9669 this.triggerAsync("warning", {
9672 character: this.char
9673 }, checks, function() {
9674 return state.isStrict() && token.base === 8 && token.isLegacy;
9677 this.trigger("Number", {
9683 isMalformed: token.malformed
9686 return create("(number)", token.value);
9689 return create("(regexp)", token.value);
9692 state.tokens.curr.comment = true;
9694 if (token.isSpecial) {
9699 type: token.commentType,
9700 isSpecial: token.isSpecial,
9702 character: this.char,
9713 return create("(punctuator)", token.value);
9719 exports.Lexer = Lexer;
9720 exports.Context = Context;
9722 },{"../data/ascii-identifier-data.js":"/node_modules/jshint/data/ascii-identifier-data.js","../lodash":"/node_modules/jshint/lodash.js","./reg.js":"/node_modules/jshint/src/reg.js","./state.js":"/node_modules/jshint/src/state.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/messages.js":[function(_dereq_,module,exports){
9725 var _ = _dereq_("../lodash");
9728 E001: "Bad option: '{a}'.",
9729 E002: "Bad option value.",
9730 E003: "Expected a JSON value.",
9731 E004: "Input is neither a string nor an array of strings.",
9732 E005: "Input is empty.",
9733 E006: "Unexpected early end of program.",
9734 E007: "Missing \"use strict\" statement.",
9735 E008: "Strict violation.",
9736 E009: "Option 'validthis' can't be used in a global scope.",
9737 E010: "'with' is not allowed in strict mode.",
9738 E011: "'{a}' has already been declared.",
9739 E012: "const '{a}' is initialized to 'undefined'.",
9740 E013: "Attempting to override '{a}' which is a constant.",
9741 E014: "A regular expression literal can be confused with '/='.",
9742 E015: "Unclosed regular expression.",
9743 E016: "Invalid regular expression.",
9744 E017: "Unclosed comment.",
9745 E018: "Unbegun comment.",
9746 E019: "Unmatched '{a}'.",
9747 E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
9748 E021: "Expected '{a}' and instead saw '{b}'.",
9749 E022: "Line breaking error '{a}'.",
9750 E023: "Missing '{a}'.",
9751 E024: "Unexpected '{a}'.",
9752 E025: "Missing ':' on a case clause.",
9753 E026: "Missing '}' to match '{' from line {a}.",
9754 E027: "Missing ']' to match '[' from line {a}.",
9755 E028: "Illegal comma.",
9756 E029: "Unclosed string.",
9757 E030: "Expected an identifier and instead saw '{a}'.",
9758 E031: "Bad assignment.", // FIXME: Rephrase
9759 E032: "Expected a small integer or 'false' and instead saw '{a}'.",
9760 E033: "Expected an operator and instead saw '{a}'.",
9761 E034: "get/set are ES5 features.",
9762 E035: "Missing property name.",
9763 E036: "Expected to see a statement and instead saw a block.",
9766 E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.",
9767 E040: "Each value should have its own case label.",
9768 E041: "Unrecoverable syntax error.",
9770 E043: "Too many errors.",
9772 E045: "Invalid for each loop.",
9773 E046: "A yield statement shall be within a generator function (with syntax: `function*`)",
9775 E048: "{a} declaration not directly within block.",
9776 E049: "A {a} cannot be named '{b}'.",
9777 E050: "Mozilla requires the yield expression to be parenthesized here.",
9779 E052: "Unclosed template literal.",
9780 E053: "Export declaration must be in global scope.",
9781 E054: "Class properties must be methods. Expected '(' but instead saw '{a}'.",
9782 E055: "The '{a}' option cannot be set after any executable code.",
9783 E056: "'{a}' was used before it was declared, which is illegal for '{b}' variables.",
9784 E057: "Invalid meta property: '{a}.{b}'.",
9785 E058: "Missing semicolon."
9789 W001: "'hasOwnProperty' is a really bad name.",
9790 W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
9791 W003: "'{a}' was used before it was defined.",
9792 W004: "'{a}' is already defined.",
9793 W005: "A dot following a number can be confused with a decimal point.",
9794 W006: "Confusing minuses.",
9795 W007: "Confusing plusses.",
9796 W008: "A leading decimal point can be confused with a dot: '{a}'.",
9797 W009: "The array literal notation [] is preferable.",
9798 W010: "The object literal notation {} is preferable.",
9802 W014: "Bad line breaking before '{a}'.",
9804 W016: "Unexpected use of '{a}'.",
9805 W017: "Bad operand.",
9806 W018: "Confusing use of '{a}'.",
9807 W019: "Use the isNaN function to compare with NaN.",
9809 W021: "Reassignment of '{a}', which is is a {b}. " +
9810 "Use 'var' or 'let' to declare bindings that may change.",
9811 W022: "Do not assign to the exception parameter.",
9812 W023: "Expected an identifier in an assignment and instead saw a function invocation.",
9813 W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
9814 W025: "Missing name in function declaration.",
9815 W026: "Inner functions should be listed at the top of the outer function.",
9816 W027: "Unreachable '{a}' after '{b}'.",
9817 W028: "Label '{a}' on {b} statement.",
9818 W030: "Expected an assignment or function call and instead saw an expression.",
9819 W031: "Do not use 'new' for side effects.",
9820 W032: "Unnecessary semicolon.",
9821 W033: "Missing semicolon.",
9822 W034: "Unnecessary directive \"{a}\".",
9823 W035: "Empty block.",
9824 W036: "Unexpected /*member '{a}'.",
9825 W037: "'{a}' is a statement label.",
9826 W038: "'{a}' used out of scope.",
9827 W039: "'{a}' is not allowed.",
9828 W040: "Possible strict violation.",
9829 W041: "Use '{a}' to compare with '{b}'.",
9830 W042: "Avoid EOL escaping.",
9831 W043: "Bad escaping of EOL. Use option multistr if needed.",
9832 W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */
9833 W045: "Bad number '{a}'.",
9834 W046: "Don't use extra leading zeros '{a}'.",
9835 W047: "A trailing decimal point can be confused with a dot: '{a}'.",
9836 W048: "Unexpected control character in regular expression.",
9837 W049: "Unexpected escaped character '{a}' in regular expression.",
9838 W050: "JavaScript URL.",
9839 W051: "Variables should not be deleted.",
9840 W052: "Unexpected '{a}'.",
9841 W053: "Do not use {a} as a constructor.",
9842 W054: "The Function constructor is a form of eval.",
9843 W055: "A constructor name should start with an uppercase letter.",
9844 W056: "Bad constructor.",
9845 W057: "Weird construction. Is 'new' necessary?",
9846 W058: "Missing '()' invoking a constructor.",
9847 W059: "Avoid arguments.{a}.",
9848 W060: "document.write can be a form of eval.",
9849 W061: "eval can be harmful.",
9850 W062: "Wrap an immediate function invocation in parens " +
9851 "to assist the reader in understanding that the expression " +
9852 "is the result of a function, and not the function itself.",
9853 W063: "Math is not a function.",
9854 W064: "Missing 'new' prefix when invoking a constructor.",
9855 W065: "Missing radix parameter.",
9856 W066: "Implied eval. Consider passing a function instead of a string.",
9857 W067: "Bad invocation.",
9858 W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
9859 W069: "['{a}'] is better written in dot notation.",
9860 W070: "Extra comma. (it breaks older versions of IE)",
9861 W071: "This function has too many statements. ({a})",
9862 W072: "This function has too many parameters. ({a})",
9863 W073: "Blocks are nested too deeply. ({a})",
9864 W074: "This function's cyclomatic complexity is too high. ({a})",
9865 W075: "Duplicate {a} '{b}'.",
9866 W076: "Unexpected parameter '{a}' in get {b} function.",
9867 W077: "Expected a single parameter in set {a} function.",
9868 W078: "Setter is defined without getter.",
9869 W079: "Redefinition of '{a}'.",
9870 W080: "It's not necessary to initialize '{a}' to 'undefined'.",
9872 W082: "Function declarations should not be placed in blocks. " +
9873 "Use a function expression or move the statement to the top of " +
9874 "the outer function.",
9875 W083: "Don't make functions within a loop.",
9876 W084: "Assignment in conditional expression",
9877 W085: "Don't use 'with'.",
9878 W086: "Expected a 'break' statement before '{a}'.",
9879 W087: "Forgotten 'debugger' statement?",
9880 W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.",
9881 W089: "The body of a for in should be wrapped in an if statement to filter " +
9882 "unwanted properties from the prototype.",
9883 W090: "'{a}' is not a statement label.",
9885 W093: "Did you mean to return a conditional instead of an assignment?",
9886 W094: "Unexpected comma.",
9887 W095: "Expected a string and instead saw {a}.",
9888 W096: "The '{a}' key may produce unexpected results.",
9889 W097: "Use the function form of \"use strict\".",
9890 W098: "'{a}' is defined but never used.",
9892 W100: "This character may get silently deleted by one or more browsers.",
9893 W101: "Line is too long.",
9895 W103: "The '{a}' property is deprecated.",
9896 W104: "'{a}' is available in ES{b} (use 'esversion: {b}') or Mozilla JS extensions (use moz).",
9897 W105: "Unexpected {a} in '{b}'.",
9898 W106: "Identifier '{a}' is not in camel case.",
9899 W107: "Script URL.",
9900 W108: "Strings must use doublequote.",
9901 W109: "Strings must use singlequote.",
9902 W110: "Mixed double and single quotes.",
9903 W112: "Unclosed string.",
9904 W113: "Control character in string: {a}.",
9906 W115: "Octal literals are not allowed in strict mode.",
9907 W116: "Expected '{a}' and instead saw '{b}'.",
9908 W117: "'{a}' is not defined.",
9909 W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).",
9910 W119: "'{a}' is only available in ES{b} (use 'esversion: {b}').",
9911 W120: "You might be leaking a variable ({a}) here.",
9912 W121: "Extending prototype of native object: '{a}'.",
9913 W122: "Invalid typeof value '{a}'",
9914 W123: "'{a}' is already defined in outer scope.",
9915 W124: "A generator function shall contain a yield statement.",
9916 W125: "This line contains non-breaking spaces: http://jshint.com/doc/options/#nonbsp",
9917 W126: "Unnecessary grouping operator.",
9918 W127: "Unexpected use of a comma operator.",
9919 W128: "Empty array elements require elision=true.",
9920 W129: "'{a}' is defined in a future version of JavaScript. Use a " +
9921 "different variable name to avoid migration issues.",
9922 W130: "Invalid element after rest element.",
9923 W131: "Invalid parameter after rest parameter.",
9924 W132: "`var` declarations are forbidden. Use `let` or `const` instead.",
9925 W133: "Invalid for-{a} loop left-hand-side: {b}.",
9926 W134: "The '{a}' option is only available when linting ECMAScript {b} code.",
9927 W135: "{a} may not be supported by non-browser environments.",
9928 W136: "'{a}' must be in function scope.",
9929 W137: "Empty destructuring.",
9930 W138: "Regular parameters should not come after default parameters."
9934 I001: "Comma warnings can be turned off with 'laxcomma'.",
9936 I003: "ES5 option is now set per default"
9939 exports.errors = {};
9940 exports.warnings = {};
9943 _.each(errors, function(desc, code) {
9944 exports.errors[code] = { code: code, desc: desc };
9947 _.each(warnings, function(desc, code) {
9948 exports.warnings[code] = { code: code, desc: desc };
9951 _.each(info, function(desc, code) {
9952 exports.info[code] = { code: code, desc: desc };
9955 },{"../lodash":"/node_modules/jshint/lodash.js"}],"/node_modules/jshint/src/name-stack.js":[function(_dereq_,module,exports){
9958 function NameStack() {
9962 Object.defineProperty(NameStack.prototype, "length", {
9964 return this._stack.length;
9967 NameStack.prototype.push = function() {
9968 this._stack.push(null);
9970 NameStack.prototype.pop = function() {
9973 NameStack.prototype.set = function(token) {
9974 this._stack[this.length - 1] = token;
9976 NameStack.prototype.infer = function() {
9977 var nameToken = this._stack[this.length - 1];
9980 if (!nameToken || nameToken.type === "class") {
9981 nameToken = this._stack[this.length - 2];
9988 type = nameToken.type;
9990 if (type !== "(string)" && type !== "(number)" && type !== "(identifier)" && type !== "default") {
9991 return "(expression)";
9994 if (nameToken.accessorType) {
9995 prefix = nameToken.accessorType + " ";
9998 return prefix + nameToken.value;
10001 module.exports = NameStack;
10003 },{}],"/node_modules/jshint/src/options.js":[function(_dereq_,module,exports){
10012 futurehostile: true,
10027 singleGroups: false,
10037 globalstrict: true,
10065 prototypejs : true,
10071 nonstandard : true,
10080 onecase : true, // if one case switch statements should be allowed
10081 regexp : true, // if the . should not be allowed in regexp literals
10082 regexdash : true // if unescaped first/last dash (-) inside brackets
10094 maxstatements: false,
10097 maxcomplexity: false,
10103 ignore : false, // start/end ignoring lines of code, bypassing the lexer
10105 ignoreDelimiters: false, // array of start/end delimiters used to ignore
10108 exports.inverted = {
10119 exports.validNames = Object.keys(exports.val)
10120 .concat(Object.keys(exports.bool.relaxing))
10121 .concat(Object.keys(exports.bool.enforcing))
10122 .concat(Object.keys(exports.bool.obsolete))
10123 .concat(Object.keys(exports.bool.environments));
10124 exports.renamed = {
10130 exports.removed = {
10139 exports.noenforceall = {
10144 },{}],"/node_modules/jshint/src/reg.js":[function(_dereq_,module,exports){
10147 exports.unsafeString =
10148 /@cc|<\/?|script|\]\s*\]|<\s*!|</i;
10149 exports.unsafeChars =
10150 /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
10152 /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
10154 exports.needEscGlobal =
10155 /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
10156 exports.starSlash = /\*\//;
10157 exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
10158 exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
10159 exports.fallsThrough = /^\s*falls?\sthrough\s*$/;
10160 exports.maxlenException = /^(?:(?:\/\/|\/\*|\*) ?)?[^ ]+$/;
10162 },{}],"/node_modules/jshint/src/scope-manager.js":[function(_dereq_,module,exports){
10165 var _ = _dereq_("../lodash");
10166 var events = _dereq_("events");
10168 var scopeManager = function(state, predefined, exported, declared) {
10171 var _scopeStack = [];
10173 function _newScope(type) {
10175 "(labels)": Object.create(null),
10176 "(usages)": Object.create(null),
10177 "(breakLabels)": Object.create(null),
10178 "(parent)": _current,
10180 "(params)": (type === "functionparams" || type === "catchparams") ? [] : null
10182 _scopeStack.push(_current);
10185 _newScope("global");
10186 _current["(predefined)"] = predefined;
10188 var _currentFunctBody = _current; // this is the block after the params = function
10190 var usedPredefinedAndGlobals = Object.create(null);
10191 var impliedGlobals = Object.create(null);
10193 var emitter = new events.EventEmitter();
10195 function warning(code, token) {
10196 emitter.emit("warning", {
10199 data: _.slice(arguments, 2)
10203 function error(code, token) {
10204 emitter.emit("warning", {
10207 data: _.slice(arguments, 2)
10211 function _setupUsages(labelName) {
10212 if (!_current["(usages)"][labelName]) {
10213 _current["(usages)"][labelName] = {
10215 "(reassigned)": [],
10221 var _getUnusedOption = function(unused_opt) {
10222 if (unused_opt === undefined) {
10223 unused_opt = state.option.unused;
10226 if (unused_opt === true) {
10227 unused_opt = "last-param";
10233 var _warnUnused = function(name, tkn, type, unused_opt) {
10234 var line = tkn.line;
10235 var chr = tkn.from;
10236 var raw_name = tkn.raw_text || name;
10238 unused_opt = _getUnusedOption(unused_opt);
10240 var warnable_types = {
10242 "last-param": ["var", "param"],
10243 "strict": ["var", "param", "last-param"]
10247 if (warnable_types[unused_opt] && warnable_types[unused_opt].indexOf(type) !== -1) {
10248 warning("W098", { line: line, from: chr }, raw_name);
10251 if (unused_opt || type === "var") {
10259 function _checkForUnused() {
10260 if (_current["(type)"] === "functionparams") {
10264 var curentLabels = _current["(labels)"];
10265 for (var labelName in curentLabels) {
10266 if (curentLabels[labelName]) {
10267 if (curentLabels[labelName]["(type)"] !== "exception" &&
10268 curentLabels[labelName]["(unused)"]) {
10269 _warnUnused(labelName, curentLabels[labelName]["(token)"], "var");
10274 function _checkParams() {
10275 var params = _current["(params)"];
10281 var param = params.pop();
10285 var label = _current["(labels)"][param];
10287 unused_opt = _getUnusedOption(state.funct["(unusedOption)"]);
10288 if (param === "undefined")
10291 if (label["(unused)"]) {
10292 _warnUnused(param, label["(token)"], "param", state.funct["(unusedOption)"]);
10293 } else if (unused_opt === "last-param") {
10297 param = params.pop();
10300 function _getLabel(labelName) {
10301 for (var i = _scopeStack.length - 1 ; i >= 0; --i) {
10302 var scopeLabels = _scopeStack[i]["(labels)"];
10303 if (scopeLabels[labelName]) {
10304 return scopeLabels;
10309 function usedSoFarInCurrentFunction(labelName) {
10310 for (var i = _scopeStack.length - 1; i >= 0; i--) {
10311 var current = _scopeStack[i];
10312 if (current["(usages)"][labelName]) {
10313 return current["(usages)"][labelName];
10315 if (current === _currentFunctBody) {
10322 function _checkOuterShadow(labelName, token) {
10323 if (state.option.shadow !== "outer") {
10327 var isGlobal = _currentFunctBody["(type)"] === "global",
10328 isNewFunction = _current["(type)"] === "functionparams";
10330 var outsideCurrentFunction = !isGlobal;
10331 for (var i = 0; i < _scopeStack.length; i++) {
10332 var stackItem = _scopeStack[i];
10334 if (!isNewFunction && _scopeStack[i + 1] === _currentFunctBody) {
10335 outsideCurrentFunction = false;
10337 if (outsideCurrentFunction && stackItem["(labels)"][labelName]) {
10338 warning("W123", token, labelName);
10340 if (stackItem["(breakLabels)"][labelName]) {
10341 warning("W123", token, labelName);
10346 function _latedefWarning(type, labelName, token) {
10347 if (state.option.latedef) {
10348 if ((state.option.latedef === true && type === "function") ||
10349 type !== "function") {
10350 warning("W003", token, labelName);
10355 var scopeManagerInst = {
10357 on: function(names, listener) {
10358 names.split(" ").forEach(function(name) {
10359 emitter.on(name, listener);
10363 isPredefined: function(labelName) {
10364 return !this.has(labelName) && _.has(_scopeStack[0]["(predefined)"], labelName);
10366 stack: function(type) {
10367 var previousScope = _current;
10370 if (!type && previousScope["(type)"] === "functionparams") {
10372 _current["(isFuncBody)"] = true;
10373 _current["(context)"] = _currentFunctBody;
10374 _currentFunctBody = _current;
10378 unstack: function() {
10379 var subScope = _scopeStack.length > 1 ? _scopeStack[_scopeStack.length - 2] : null;
10380 var isUnstackingFunctionBody = _current === _currentFunctBody,
10381 isUnstackingFunctionParams = _current["(type)"] === "functionparams",
10382 isUnstackingFunctionOuter = _current["(type)"] === "functionouter";
10385 var currentUsages = _current["(usages)"];
10386 var currentLabels = _current["(labels)"];
10387 var usedLabelNameList = Object.keys(currentUsages);
10389 if (currentUsages.__proto__ && usedLabelNameList.indexOf("__proto__") === -1) {
10390 usedLabelNameList.push("__proto__");
10393 for (i = 0; i < usedLabelNameList.length; i++) {
10394 var usedLabelName = usedLabelNameList[i];
10396 var usage = currentUsages[usedLabelName];
10397 var usedLabel = currentLabels[usedLabelName];
10399 var usedLabelType = usedLabel["(type)"];
10401 if (usedLabel["(useOutsideOfScope)"] && !state.option.funcscope) {
10402 var usedTokens = usage["(tokens)"];
10404 for (j = 0; j < usedTokens.length; j++) {
10405 if (usedLabel["(function)"] === usedTokens[j]["(function)"]) {
10406 error("W038", usedTokens[j], usedLabelName);
10411 _current["(labels)"][usedLabelName]["(unused)"] = false;
10412 if (usedLabelType === "const" && usage["(modified)"]) {
10413 for (j = 0; j < usage["(modified)"].length; j++) {
10414 error("E013", usage["(modified)"][j], usedLabelName);
10417 if ((usedLabelType === "function" || usedLabelType === "class") &&
10418 usage["(reassigned)"]) {
10419 for (j = 0; j < usage["(reassigned)"].length; j++) {
10420 error("W021", usage["(reassigned)"][j], usedLabelName, usedLabelType);
10426 if (isUnstackingFunctionOuter) {
10427 state.funct["(isCapturing)"] = true;
10431 if (!subScope["(usages)"][usedLabelName]) {
10432 subScope["(usages)"][usedLabelName] = usage;
10433 if (isUnstackingFunctionBody) {
10434 subScope["(usages)"][usedLabelName]["(onlyUsedSubFunction)"] = true;
10437 var subScopeUsage = subScope["(usages)"][usedLabelName];
10438 subScopeUsage["(modified)"] = subScopeUsage["(modified)"].concat(usage["(modified)"]);
10439 subScopeUsage["(tokens)"] = subScopeUsage["(tokens)"].concat(usage["(tokens)"]);
10440 subScopeUsage["(reassigned)"] =
10441 subScopeUsage["(reassigned)"].concat(usage["(reassigned)"]);
10442 subScopeUsage["(onlyUsedSubFunction)"] = false;
10445 if (typeof _current["(predefined)"][usedLabelName] === "boolean") {
10446 delete declared[usedLabelName];
10447 usedPredefinedAndGlobals[usedLabelName] = marker;
10448 if (_current["(predefined)"][usedLabelName] === false && usage["(reassigned)"]) {
10449 for (j = 0; j < usage["(reassigned)"].length; j++) {
10450 warning("W020", usage["(reassigned)"][j]);
10455 if (usage["(tokens)"]) {
10456 for (j = 0; j < usage["(tokens)"].length; j++) {
10457 var undefinedToken = usage["(tokens)"][j];
10458 if (!undefinedToken.forgiveUndef) {
10459 if (state.option.undef && !undefinedToken.ignoreUndef) {
10460 warning("W117", undefinedToken, usedLabelName);
10462 if (impliedGlobals[usedLabelName]) {
10463 impliedGlobals[usedLabelName].line.push(undefinedToken.line);
10465 impliedGlobals[usedLabelName] = {
10466 name: usedLabelName,
10467 line: [undefinedToken.line]
10477 Object.keys(declared)
10478 .forEach(function(labelNotUsed) {
10479 _warnUnused(labelNotUsed, declared[labelNotUsed], "var");
10482 if (subScope && !isUnstackingFunctionBody &&
10483 !isUnstackingFunctionParams && !isUnstackingFunctionOuter) {
10484 var labelNames = Object.keys(currentLabels);
10485 for (i = 0; i < labelNames.length; i++) {
10487 var defLabelName = labelNames[i];
10488 if (!currentLabels[defLabelName]["(blockscoped)"] &&
10489 currentLabels[defLabelName]["(type)"] !== "exception" &&
10490 !this.funct.has(defLabelName, { excludeCurrent: true })) {
10491 subScope["(labels)"][defLabelName] = currentLabels[defLabelName];
10492 if (_currentFunctBody["(type)"] !== "global") {
10493 subScope["(labels)"][defLabelName]["(useOutsideOfScope)"] = true;
10495 delete currentLabels[defLabelName];
10503 if (isUnstackingFunctionBody) {
10504 _currentFunctBody = _scopeStack[_.findLastIndex(_scopeStack, function(scope) {
10505 return scope["(isFuncBody)"] || scope["(type)"] === "global";
10509 _current = subScope;
10511 addParam: function(labelName, token, type) {
10512 type = type || "param";
10514 if (type === "exception") {
10515 var previouslyDefinedLabelType = this.funct.labeltype(labelName);
10516 if (previouslyDefinedLabelType && previouslyDefinedLabelType !== "exception") {
10517 if (!state.option.node) {
10518 warning("W002", state.tokens.next, labelName);
10522 if (_.has(_current["(labels)"], labelName)) {
10523 _current["(labels)"][labelName].duplicated = true;
10525 _checkOuterShadow(labelName, token, type);
10527 _current["(labels)"][labelName] = {
10530 "(unused)": true };
10532 _current["(params)"].push(labelName);
10535 if (_.has(_current["(usages)"], labelName)) {
10536 var usage = _current["(usages)"][labelName];
10537 if (usage["(onlyUsedSubFunction)"]) {
10538 _latedefWarning(type, labelName, token);
10540 warning("E056", token, labelName, type);
10545 validateParams: function() {
10546 if (_currentFunctBody["(type)"] === "global") {
10550 var isStrict = state.isStrict();
10551 var currentFunctParamScope = _currentFunctBody["(parent)"];
10553 if (!currentFunctParamScope["(params)"]) {
10557 currentFunctParamScope["(params)"].forEach(function(labelName) {
10558 var label = currentFunctParamScope["(labels)"][labelName];
10560 if (label && label.duplicated) {
10562 warning("E011", label["(token)"], labelName);
10563 } else if (state.option.shadow !== true) {
10564 warning("W004", label["(token)"], labelName);
10570 getUsedOrDefinedGlobals: function() {
10571 var list = Object.keys(usedPredefinedAndGlobals);
10572 if (usedPredefinedAndGlobals.__proto__ === marker &&
10573 list.indexOf("__proto__") === -1) {
10574 list.push("__proto__");
10579 getImpliedGlobals: function() {
10580 var values = _.values(impliedGlobals);
10581 var hasProto = false;
10582 if (impliedGlobals.__proto__) {
10583 hasProto = values.some(function(value) {
10584 return value.name === "__proto__";
10588 values.push(impliedGlobals.__proto__);
10594 getUnuseds: function() {
10598 has: function(labelName) {
10599 return Boolean(_getLabel(labelName));
10602 labeltype: function(labelName) {
10603 var scopeLabels = _getLabel(labelName);
10605 return scopeLabels[labelName]["(type)"];
10609 addExported: function(labelName) {
10610 var globalLabels = _scopeStack[0]["(labels)"];
10611 if (_.has(declared, labelName)) {
10612 delete declared[labelName];
10613 } else if (_.has(globalLabels, labelName)) {
10614 globalLabels[labelName]["(unused)"] = false;
10616 for (var i = 1; i < _scopeStack.length; i++) {
10617 var scope = _scopeStack[i];
10618 if (!scope["(type)"]) {
10619 if (_.has(scope["(labels)"], labelName) &&
10620 !scope["(labels)"][labelName]["(blockscoped)"]) {
10621 scope["(labels)"][labelName]["(unused)"] = false;
10628 exported[labelName] = true;
10631 setExported: function(labelName, token) {
10632 this.block.use(labelName, token);
10634 addlabel: function(labelName, opts) {
10636 var type = opts.type;
10637 var token = opts.token;
10638 var isblockscoped = type === "let" || type === "const" || type === "class";
10639 var isexported = (isblockscoped ? _current : _currentFunctBody)["(type)"] === "global" &&
10640 _.has(exported, labelName);
10641 _checkOuterShadow(labelName, token, type);
10642 if (isblockscoped) {
10644 var declaredInCurrentScope = _current["(labels)"][labelName];
10645 if (!declaredInCurrentScope && _current === _currentFunctBody &&
10646 _current["(type)"] !== "global") {
10647 declaredInCurrentScope = !!_currentFunctBody["(parent)"]["(labels)"][labelName];
10649 if (!declaredInCurrentScope && _current["(usages)"][labelName]) {
10650 var usage = _current["(usages)"][labelName];
10651 if (usage["(onlyUsedSubFunction)"]) {
10652 _latedefWarning(type, labelName, token);
10654 warning("E056", token, labelName, type);
10657 if (declaredInCurrentScope) {
10658 warning("E011", token, labelName);
10660 else if (state.option.shadow === "outer") {
10661 if (scopeManagerInst.funct.has(labelName)) {
10662 warning("W004", token, labelName);
10666 scopeManagerInst.block.add(labelName, type, token, !isexported);
10670 var declaredInCurrentFunctionScope = scopeManagerInst.funct.has(labelName);
10671 if (!declaredInCurrentFunctionScope && usedSoFarInCurrentFunction(labelName)) {
10672 _latedefWarning(type, labelName, token);
10674 if (scopeManagerInst.funct.has(labelName, { onlyBlockscoped: true })) {
10675 warning("E011", token, labelName);
10676 } else if (state.option.shadow !== true) {
10677 if (declaredInCurrentFunctionScope && labelName !== "__proto__") {
10678 if (_currentFunctBody["(type)"] !== "global") {
10679 warning("W004", token, labelName);
10684 scopeManagerInst.funct.add(labelName, type, token, !isexported);
10686 if (_currentFunctBody["(type)"] === "global") {
10687 usedPredefinedAndGlobals[labelName] = marker;
10693 labeltype: function(labelName, options) {
10694 var onlyBlockscoped = options && options.onlyBlockscoped;
10695 var excludeParams = options && options.excludeParams;
10696 var currentScopeIndex = _scopeStack.length - (options && options.excludeCurrent ? 2 : 1);
10697 for (var i = currentScopeIndex; i >= 0; i--) {
10698 var current = _scopeStack[i];
10699 if (current["(labels)"][labelName] &&
10700 (!onlyBlockscoped || current["(labels)"][labelName]["(blockscoped)"])) {
10701 return current["(labels)"][labelName]["(type)"];
10703 var scopeCheck = excludeParams ? _scopeStack[ i - 1 ] : current;
10704 if (scopeCheck && scopeCheck["(type)"] === "functionparams") {
10710 hasBreakLabel: function(labelName) {
10711 for (var i = _scopeStack.length - 1; i >= 0; i--) {
10712 var current = _scopeStack[i];
10714 if (current["(breakLabels)"][labelName]) {
10717 if (current["(type)"] === "functionparams") {
10723 has: function(labelName, options) {
10724 return Boolean(this.labeltype(labelName, options));
10726 add: function(labelName, type, tok, unused) {
10727 _current["(labels)"][labelName] = {
10730 "(blockscoped)": false,
10731 "(function)": _currentFunctBody,
10732 "(unused)": unused };
10737 isGlobal: function() {
10738 return _current["(type)"] === "global";
10741 use: function(labelName, token) {
10742 var paramScope = _currentFunctBody["(parent)"];
10743 if (paramScope && paramScope["(labels)"][labelName] &&
10744 paramScope["(labels)"][labelName]["(type)"] === "param") {
10745 if (!scopeManagerInst.funct.has(labelName,
10746 { excludeParams: true, onlyBlockscoped: true })) {
10747 paramScope["(labels)"][labelName]["(unused)"] = false;
10751 if (token && (state.ignored.W117 || state.option.undef === false)) {
10752 token.ignoreUndef = true;
10755 _setupUsages(labelName);
10758 token["(function)"] = _currentFunctBody;
10759 _current["(usages)"][labelName]["(tokens)"].push(token);
10763 reassign: function(labelName, token) {
10765 this.modify(labelName, token);
10767 _current["(usages)"][labelName]["(reassigned)"].push(token);
10770 modify: function(labelName, token) {
10772 _setupUsages(labelName);
10774 _current["(usages)"][labelName]["(modified)"].push(token);
10776 add: function(labelName, type, tok, unused) {
10777 _current["(labels)"][labelName] = {
10780 "(blockscoped)": true,
10781 "(unused)": unused };
10784 addBreakLabel: function(labelName, opts) {
10785 var token = opts.token;
10786 if (scopeManagerInst.funct.hasBreakLabel(labelName)) {
10787 warning("E011", token, labelName);
10789 else if (state.option.shadow === "outer") {
10790 if (scopeManagerInst.funct.has(labelName)) {
10791 warning("W004", token, labelName);
10793 _checkOuterShadow(labelName, token);
10796 _current["(breakLabels)"][labelName] = token;
10800 return scopeManagerInst;
10803 module.exports = scopeManager;
10805 },{"../lodash":"/node_modules/jshint/lodash.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/state.js":[function(_dereq_,module,exports){
10807 var NameStack = _dereq_("./name-stack.js");
10811 isStrict: function() {
10812 return this.directive["use strict"] || this.inClassBody ||
10813 this.option.module || this.option.strict === "implied";
10816 inMoz: function() {
10817 return this.option.moz;
10819 inES6: function() {
10820 return this.option.moz || this.option.esversion >= 6;
10822 inES5: function(strict) {
10824 return (!this.option.esversion || this.option.esversion === 5) && !this.option.moz;
10826 return !this.option.esversion || this.option.esversion >= 5 || this.option.moz;
10830 reset: function() {
10840 this.directive = {};
10841 this.jsonMode = false;
10842 this.jsonWarnings = [];
10845 this.cache = {}; // Node.JS doesn't have Map. Sniff.
10846 this.ignoredLines = {};
10847 this.forinifcheckneeded = false;
10848 this.nameStack = new NameStack();
10849 this.inClassBody = false;
10853 exports.state = state;
10855 },{"./name-stack.js":"/node_modules/jshint/src/name-stack.js"}],"/node_modules/jshint/src/style.js":[function(_dereq_,module,exports){
10858 exports.register = function(linter) {
10860 linter.on("Identifier", function style_scanProto(data) {
10861 if (linter.getOption("proto")) {
10865 if (data.name === "__proto__") {
10866 linter.warn("W103", {
10869 data: [ data.name, "6" ]
10874 linter.on("Identifier", function style_scanIterator(data) {
10875 if (linter.getOption("iterator")) {
10879 if (data.name === "__iterator__") {
10880 linter.warn("W103", {
10883 data: [ data.name ]
10888 linter.on("Identifier", function style_scanCamelCase(data) {
10889 if (!linter.getOption("camelcase")) {
10893 if (data.name.replace(/^_+|_+$/g, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) {
10894 linter.warn("W106", {
10897 data: [ data.name ]
10902 linter.on("String", function style_scanQuotes(data) {
10903 var quotmark = linter.getOption("quotmark");
10910 if (quotmark === "single" && data.quote !== "'") {
10914 if (quotmark === "double" && data.quote !== "\"") {
10918 if (quotmark === true) {
10919 if (!linter.getCache("quotmark")) {
10920 linter.setCache("quotmark", data.quote);
10923 if (linter.getCache("quotmark") !== data.quote) {
10929 linter.warn(code, {
10936 linter.on("Number", function style_scanNumbers(data) {
10937 if (data.value.charAt(0) === ".") {
10938 linter.warn("W008", {
10941 data: [ data.value ]
10945 if (data.value.substr(data.value.length - 1) === ".") {
10946 linter.warn("W047", {
10949 data: [ data.value ]
10953 if (/^00+/.test(data.value)) {
10954 linter.warn("W046", {
10957 data: [ data.value ]
10962 linter.on("String", function style_scanJavaScriptURLs(data) {
10963 var re = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
10965 if (linter.getOption("scripturl")) {
10969 if (re.test(data.value)) {
10970 linter.warn("W107", {
10978 },{}],"/node_modules/jshint/src/vars.js":[function(_dereq_,module,exports){
10982 exports.reservedVars = {
10987 exports.ecmaIdentifiers = {
10993 decodeURIComponent : false,
10995 encodeURIComponent : false,
11000 hasOwnProperty : false,
11007 parseFloat : false,
11008 RangeError : false,
11009 ReferenceError : false,
11012 SyntaxError : false,
11031 exports.browser = {
11034 addEventListener : false,
11035 applicationCache : false,
11039 cancelAnimationFrame : false,
11040 CanvasGradient : false,
11041 CanvasPattern : false,
11042 CanvasRenderingContext2D: false,
11044 clearInterval : false,
11045 clearTimeout : false,
11049 CustomEvent : false,
11051 defaultStatus : false,
11054 DocumentFragment : false,
11056 ElementTimeControl : false,
11060 FileReader : false,
11064 getComputedStyle : false,
11065 HTMLElement : false,
11066 HTMLAnchorElement : false,
11067 HTMLBaseElement : false,
11068 HTMLBlockquoteElement: false,
11069 HTMLBodyElement : false,
11070 HTMLBRElement : false,
11071 HTMLButtonElement : false,
11072 HTMLCanvasElement : false,
11073 HTMLCollection : false,
11074 HTMLDirectoryElement : false,
11075 HTMLDivElement : false,
11076 HTMLDListElement : false,
11077 HTMLFieldSetElement : false,
11078 HTMLFontElement : false,
11079 HTMLFormElement : false,
11080 HTMLFrameElement : false,
11081 HTMLFrameSetElement : false,
11082 HTMLHeadElement : false,
11083 HTMLHeadingElement : false,
11084 HTMLHRElement : false,
11085 HTMLHtmlElement : false,
11086 HTMLIFrameElement : false,
11087 HTMLImageElement : false,
11088 HTMLInputElement : false,
11089 HTMLIsIndexElement : false,
11090 HTMLLabelElement : false,
11091 HTMLLayerElement : false,
11092 HTMLLegendElement : false,
11093 HTMLLIElement : false,
11094 HTMLLinkElement : false,
11095 HTMLMapElement : false,
11096 HTMLMenuElement : false,
11097 HTMLMetaElement : false,
11098 HTMLModElement : false,
11099 HTMLObjectElement : false,
11100 HTMLOListElement : false,
11101 HTMLOptGroupElement : false,
11102 HTMLOptionElement : false,
11103 HTMLParagraphElement : false,
11104 HTMLParamElement : false,
11105 HTMLPreElement : false,
11106 HTMLQuoteElement : false,
11107 HTMLScriptElement : false,
11108 HTMLSelectElement : false,
11109 HTMLStyleElement : false,
11110 HTMLTableCaptionElement: false,
11111 HTMLTableCellElement : false,
11112 HTMLTableColElement : false,
11113 HTMLTableElement : false,
11114 HTMLTableRowElement : false,
11115 HTMLTableSectionElement: false,
11116 HTMLTemplateElement : false,
11117 HTMLTextAreaElement : false,
11118 HTMLTitleElement : false,
11119 HTMLUListElement : false,
11120 HTMLVideoElement : false,
11125 localStorage : false,
11127 matchMedia : false,
11128 MessageChannel : false,
11129 MessageEvent : false,
11130 MessagePort : false,
11131 MouseEvent : false,
11134 MutationObserver : false,
11137 NodeFilter : false,
11139 Notification : false,
11141 onbeforeunload : true,
11149 openDatabase : false,
11153 performance : false,
11156 requestAnimationFrame : false,
11157 removeEventListener : false,
11164 sessionStorage : false,
11165 setInterval : false,
11166 setTimeout : false,
11167 SharedWorker : false,
11169 SVGAElement : false,
11170 SVGAltGlyphDefElement: false,
11171 SVGAltGlyphElement : false,
11172 SVGAltGlyphItemElement: false,
11174 SVGAnimateColorElement: false,
11175 SVGAnimateElement : false,
11176 SVGAnimateMotionElement: false,
11177 SVGAnimateTransformElement: false,
11178 SVGAnimatedAngle : false,
11179 SVGAnimatedBoolean : false,
11180 SVGAnimatedEnumeration: false,
11181 SVGAnimatedInteger : false,
11182 SVGAnimatedLength : false,
11183 SVGAnimatedLengthList: false,
11184 SVGAnimatedNumber : false,
11185 SVGAnimatedNumberList: false,
11186 SVGAnimatedPathData : false,
11187 SVGAnimatedPoints : false,
11188 SVGAnimatedPreserveAspectRatio: false,
11189 SVGAnimatedRect : false,
11190 SVGAnimatedString : false,
11191 SVGAnimatedTransformList: false,
11192 SVGAnimationElement : false,
11193 SVGCSSRule : false,
11194 SVGCircleElement : false,
11195 SVGClipPathElement : false,
11197 SVGColorProfileElement: false,
11198 SVGColorProfileRule : false,
11199 SVGComponentTransferFunctionElement: false,
11200 SVGCursorElement : false,
11201 SVGDefsElement : false,
11202 SVGDescElement : false,
11203 SVGDocument : false,
11204 SVGElement : false,
11205 SVGElementInstance : false,
11206 SVGElementInstanceList: false,
11207 SVGEllipseElement : false,
11208 SVGExternalResourcesRequired: false,
11209 SVGFEBlendElement : false,
11210 SVGFEColorMatrixElement: false,
11211 SVGFEComponentTransferElement: false,
11212 SVGFECompositeElement: false,
11213 SVGFEConvolveMatrixElement: false,
11214 SVGFEDiffuseLightingElement: false,
11215 SVGFEDisplacementMapElement: false,
11216 SVGFEDistantLightElement: false,
11217 SVGFEFloodElement : false,
11218 SVGFEFuncAElement : false,
11219 SVGFEFuncBElement : false,
11220 SVGFEFuncGElement : false,
11221 SVGFEFuncRElement : false,
11222 SVGFEGaussianBlurElement: false,
11223 SVGFEImageElement : false,
11224 SVGFEMergeElement : false,
11225 SVGFEMergeNodeElement: false,
11226 SVGFEMorphologyElement: false,
11227 SVGFEOffsetElement : false,
11228 SVGFEPointLightElement: false,
11229 SVGFESpecularLightingElement: false,
11230 SVGFESpotLightElement: false,
11231 SVGFETileElement : false,
11232 SVGFETurbulenceElement: false,
11233 SVGFilterElement : false,
11234 SVGFilterPrimitiveStandardAttributes: false,
11235 SVGFitToViewBox : false,
11236 SVGFontElement : false,
11237 SVGFontFaceElement : false,
11238 SVGFontFaceFormatElement: false,
11239 SVGFontFaceNameElement: false,
11240 SVGFontFaceSrcElement: false,
11241 SVGFontFaceUriElement: false,
11242 SVGForeignObjectElement: false,
11243 SVGGElement : false,
11244 SVGGlyphElement : false,
11245 SVGGlyphRefElement : false,
11246 SVGGradientElement : false,
11247 SVGHKernElement : false,
11248 SVGICCColor : false,
11249 SVGImageElement : false,
11250 SVGLangSpace : false,
11252 SVGLengthList : false,
11253 SVGLineElement : false,
11254 SVGLinearGradientElement: false,
11255 SVGLocatable : false,
11256 SVGMPathElement : false,
11257 SVGMarkerElement : false,
11258 SVGMaskElement : false,
11260 SVGMetadataElement : false,
11261 SVGMissingGlyphElement: false,
11263 SVGNumberList : false,
11265 SVGPathElement : false,
11266 SVGPathSeg : false,
11267 SVGPathSegArcAbs : false,
11268 SVGPathSegArcRel : false,
11269 SVGPathSegClosePath : false,
11270 SVGPathSegCurvetoCubicAbs: false,
11271 SVGPathSegCurvetoCubicRel: false,
11272 SVGPathSegCurvetoCubicSmoothAbs: false,
11273 SVGPathSegCurvetoCubicSmoothRel: false,
11274 SVGPathSegCurvetoQuadraticAbs: false,
11275 SVGPathSegCurvetoQuadraticRel: false,
11276 SVGPathSegCurvetoQuadraticSmoothAbs: false,
11277 SVGPathSegCurvetoQuadraticSmoothRel: false,
11278 SVGPathSegLinetoAbs : false,
11279 SVGPathSegLinetoHorizontalAbs: false,
11280 SVGPathSegLinetoHorizontalRel: false,
11281 SVGPathSegLinetoRel : false,
11282 SVGPathSegLinetoVerticalAbs: false,
11283 SVGPathSegLinetoVerticalRel: false,
11284 SVGPathSegList : false,
11285 SVGPathSegMovetoAbs : false,
11286 SVGPathSegMovetoRel : false,
11287 SVGPatternElement : false,
11289 SVGPointList : false,
11290 SVGPolygonElement : false,
11291 SVGPolylineElement : false,
11292 SVGPreserveAspectRatio: false,
11293 SVGRadialGradientElement: false,
11295 SVGRectElement : false,
11296 SVGRenderingIntent : false,
11297 SVGSVGElement : false,
11298 SVGScriptElement : false,
11299 SVGSetElement : false,
11300 SVGStopElement : false,
11301 SVGStringList : false,
11302 SVGStylable : false,
11303 SVGStyleElement : false,
11304 SVGSwitchElement : false,
11305 SVGSymbolElement : false,
11306 SVGTRefElement : false,
11307 SVGTSpanElement : false,
11309 SVGTextContentElement: false,
11310 SVGTextElement : false,
11311 SVGTextPathElement : false,
11312 SVGTextPositioningElement: false,
11313 SVGTitleElement : false,
11314 SVGTransform : false,
11315 SVGTransformList : false,
11316 SVGTransformable : false,
11317 SVGURIReference : false,
11318 SVGUnitTypes : false,
11319 SVGUseElement : false,
11320 SVGVKernElement : false,
11321 SVGViewElement : false,
11322 SVGViewSpec : false,
11323 SVGZoomAndPan : false,
11325 TextDecoder : false,
11326 TextEncoder : false,
11330 WebGLActiveInfo : false,
11331 WebGLBuffer : false,
11332 WebGLContextEvent : false,
11333 WebGLFramebuffer : false,
11334 WebGLProgram : false,
11335 WebGLRenderbuffer : false,
11336 WebGLRenderingContext: false,
11337 WebGLShader : false,
11338 WebGLShaderPrecisionFormat: false,
11339 WebGLTexture : false,
11340 WebGLUniformLocation : false,
11345 XDomainRequest : false,
11346 XMLHttpRequest : false,
11347 XMLSerializer : false,
11348 XPathEvaluator : false,
11349 XPathException : false,
11350 XPathExpression : false,
11351 XPathNamespace : false,
11352 XPathNSResolver : false,
11353 XPathResult : false
11366 importScripts : true,
11367 postMessage : true,
11369 FileReaderSync : true
11371 exports.nonstandard = {
11391 __filename : false,
11403 clearTimeout : true,
11404 setInterval : true,
11405 clearInterval : true,
11406 setImmediate : true, // v0.9.1+
11407 clearImmediate: true // v0.9.1+
11410 exports.browserify = {
11411 __filename : false,
11421 exports.phantom = {
11425 console : true, // in examples, but undocumented
11426 exports : true // v1.7+
11435 notDeepEqual : false,
11437 notPropEqual : false,
11438 notStrictEqual : false,
11445 strictEqual : false,
11451 defineClass : false,
11452 deserialize : false,
11455 importClass : false,
11456 importPackage: false,
11465 runCommand : false,
11474 exports.shelljs = {
11503 ArrayBuffer : false,
11504 ArrayBufferView : false,
11506 Float32Array : false,
11507 Float64Array : false,
11508 Int16Array : false,
11509 Int32Array : false,
11511 Uint16Array : false,
11512 Uint32Array : false,
11513 Uint8Array : false,
11514 Uint8ClampedArray : false
11518 ActiveXObject : true,
11521 ScriptEngine : true,
11522 ScriptEngineBuildVersion : true,
11523 ScriptEngineMajorVersion : true,
11524 ScriptEngineMinorVersion : true,
11528 XDomainRequest : true
11544 exports.mootools = {
11568 IframeShim : false,
11569 InputValidator: false,
11570 instanceOf : false,
11592 exports.prototypejs = {
11600 "$continue" : false,
11605 Enumerable : false,
11612 ObjectRange : false,
11613 PeriodicalExecuter: false,
11620 Autocompleter : false,
11624 Draggables : false,
11625 Droppables : false,
11628 SortableObserver : false,
11630 Scriptaculous : false
11649 beforeEach : false,
11655 suiteSetup : false,
11656 suiteTeardown : false
11659 exports.jasmine = {
11665 beforeEach : false,
11667 setFixtures : false,
11668 loadFixtures: false,
11682 },{}]},{},["/node_modules/jshint/src/jshint.js"]);
11686 define("ace/mode/javascript_worker",["require","exports","module","ace/lib/oop","ace/worker/mirror","ace/mode/javascript/jshint"], function(require, exports, module) {
11689 var oop = require("../lib/oop");
11690 var Mirror = require("../worker/mirror").Mirror;
11691 var lint = require("./javascript/jshint").JSHINT;
11693 function startRegex(arr) {
11694 return RegExp("^(" + arr.join("|") + ")");
11697 var disabledWarningsRe = startRegex([
11698 "Bad for in variable '(.+)'.",
11699 'Missing "use strict"'
11701 var errorsRe = startRegex([
11704 "Confusing (plus|minus)",
11705 "\\{a\\} unterminated regular expression",
11710 "Missing space after",
11711 "Missing operator at"
11713 var infoRe = startRegex([
11714 "Expected an assignment",
11715 "Bad escapement of EOL",
11716 "Unexpected comma",
11717 "Unexpected space",
11718 "Missing radix parameter.",
11719 "A leading decimal point can",
11720 "\\['{a}'\\] is better written in dot notation.",
11721 "'{a}' used out of scope"
11724 var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
11725 Mirror.call(this, sender);
11726 this.setTimeout(500);
11730 oop.inherits(JavaScriptWorker, Mirror);
11733 this.setOptions = function(options) {
11734 this.options = options || {
11750 this.doc.getValue() && this.deferredUpdate.schedule(100);
11753 this.changeOptions = function(newOptions) {
11754 oop.mixin(this.options, newOptions);
11755 this.doc.getValue() && this.deferredUpdate.schedule(100);
11758 this.isValidJS = function(str) {
11760 eval("throw 0;" + str);
11768 this.onUpdate = function() {
11769 var value = this.doc.getValue();
11770 value = value.replace(/^#!.*\n/, "\n");
11772 return this.sender.emit("annotate", []);
11775 var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
11776 lint(value, this.options, this.options.globals);
11777 var results = lint.errors;
11779 var errorAdded = false;
11780 for (var i = 0; i < results.length; i++) {
11781 var error = results[i];
11784 var raw = error.raw;
11785 var type = "warning";
11787 if (raw == "Missing semicolon.") {
11788 var str = error.evidence.substr(error.character);
11789 str = str.charAt(str.search(/\S/));
11790 if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
11791 error.reason = 'Missing ";" before statement';
11797 else if (disabledWarningsRe.test(raw)) {
11800 else if (infoRe.test(raw)) {
11803 else if (errorsRe.test(raw)) {
11805 type = maxErrorLevel;
11807 else if (raw == "'{a}' is not defined.") {
11810 else if (raw == "'{a}' is defined but never used.") {
11816 column: error.character-1,
11817 text: error.reason,
11826 this.sender.emit("annotate", errors);
11829 }).call(JavaScriptWorker.prototype);
11833 define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
11835 function Empty() {}
11837 if (!Function.prototype.bind) {
11838 Function.prototype.bind = function bind(that) { // .length is 1
11840 if (typeof target != "function") {
11841 throw new TypeError("Function.prototype.bind called on incompatible " + target);
11843 var args = slice.call(arguments, 1); // for normal call
11844 var bound = function () {
11846 if (this instanceof bound) {
11848 var result = target.apply(
11850 args.concat(slice.call(arguments))
11852 if (Object(result) === result) {
11858 return target.apply(
11860 args.concat(slice.call(arguments))
11866 if(target.prototype) {
11867 Empty.prototype = target.prototype;
11868 bound.prototype = new Empty();
11869 Empty.prototype = null;
11874 var call = Function.prototype.call;
11875 var prototypeOfArray = Array.prototype;
11876 var prototypeOfObject = Object.prototype;
11877 var slice = prototypeOfArray.slice;
11878 var _toString = call.bind(prototypeOfObject.toString);
11879 var owns = call.bind(prototypeOfObject.hasOwnProperty);
11884 var supportsAccessors;
11885 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
11886 defineGetter = call.bind(prototypeOfObject.__defineGetter__);
11887 defineSetter = call.bind(prototypeOfObject.__defineSetter__);
11888 lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
11889 lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
11891 if ([1,2].splice(0).length != 2) {
11892 if(function() { // test IE < 9 to splice bug - see issue #138
11893 function makeArray(l) {
11894 var a = new Array(l+2);
11898 var array = [], lengthBefore;
11900 array.splice.apply(array, makeArray(20));
11901 array.splice.apply(array, makeArray(26));
11903 lengthBefore = array.length; //46
11904 array.splice(5, 0, "XXX"); // add one element
11906 lengthBefore + 1 == array.length
11908 if (lengthBefore + 1 == array.length) {
11909 return true;// has right splice implementation without bugs
11912 var array_splice = Array.prototype.splice;
11913 Array.prototype.splice = function(start, deleteCount) {
11914 if (!arguments.length) {
11917 return array_splice.apply(this, [
11918 start === void 0 ? 0 : start,
11919 deleteCount === void 0 ? (this.length - start) : deleteCount
11920 ].concat(slice.call(arguments, 2)))
11924 Array.prototype.splice = function(pos, removeCount){
11925 var length = this.length;
11929 } else if (pos == void 0) {
11931 } else if (pos < 0) {
11932 pos = Math.max(length + pos, 0);
11935 if (!(pos+removeCount < length))
11936 removeCount = length - pos;
11938 var removed = this.slice(pos, pos+removeCount);
11939 var insert = slice.call(arguments, 2);
11940 var add = insert.length;
11941 if (pos === length) {
11943 this.push.apply(this, insert);
11946 var remove = Math.min(removeCount, length - pos);
11947 var tailOldPos = pos + remove;
11948 var tailNewPos = tailOldPos + add - remove;
11949 var tailCount = length - tailOldPos;
11950 var lengthAfterRemove = length - remove;
11952 if (tailNewPos < tailOldPos) { // case A
11953 for (var i = 0; i < tailCount; ++i) {
11954 this[tailNewPos+i] = this[tailOldPos+i];
11956 } else if (tailNewPos > tailOldPos) { // case B
11957 for (i = tailCount; i--; ) {
11958 this[tailNewPos+i] = this[tailOldPos+i];
11960 } // else, add == remove (nothing to do)
11962 if (add && pos === lengthAfterRemove) {
11963 this.length = lengthAfterRemove; // truncate array
11964 this.push.apply(this, insert);
11966 this.length = lengthAfterRemove + add; // reserves space
11967 for (i = 0; i < add; ++i) {
11968 this[pos+i] = insert[i];
11976 if (!Array.isArray) {
11977 Array.isArray = function isArray(obj) {
11978 return _toString(obj) == "[object Array]";
11981 var boxedString = Object("a"),
11982 splitString = boxedString[0] != "a" || !(0 in boxedString);
11984 if (!Array.prototype.forEach) {
11985 Array.prototype.forEach = function forEach(fun /*, thisp*/) {
11986 var object = toObject(this),
11987 self = splitString && _toString(this) == "[object String]" ?
11990 thisp = arguments[1],
11992 length = self.length >>> 0;
11993 if (_toString(fun) != "[object Function]") {
11994 throw new TypeError(); // TODO message
11997 while (++i < length) {
11999 fun.call(thisp, self[i], i, object);
12004 if (!Array.prototype.map) {
12005 Array.prototype.map = function map(fun /*, thisp*/) {
12006 var object = toObject(this),
12007 self = splitString && _toString(this) == "[object String]" ?
12010 length = self.length >>> 0,
12011 result = Array(length),
12012 thisp = arguments[1];
12013 if (_toString(fun) != "[object Function]") {
12014 throw new TypeError(fun + " is not a function");
12017 for (var i = 0; i < length; i++) {
12019 result[i] = fun.call(thisp, self[i], i, object);
12024 if (!Array.prototype.filter) {
12025 Array.prototype.filter = function filter(fun /*, thisp */) {
12026 var object = toObject(this),
12027 self = splitString && _toString(this) == "[object String]" ?
12030 length = self.length >>> 0,
12033 thisp = arguments[1];
12034 if (_toString(fun) != "[object Function]") {
12035 throw new TypeError(fun + " is not a function");
12038 for (var i = 0; i < length; i++) {
12041 if (fun.call(thisp, value, i, object)) {
12042 result.push(value);
12049 if (!Array.prototype.every) {
12050 Array.prototype.every = function every(fun /*, thisp */) {
12051 var object = toObject(this),
12052 self = splitString && _toString(this) == "[object String]" ?
12055 length = self.length >>> 0,
12056 thisp = arguments[1];
12057 if (_toString(fun) != "[object Function]") {
12058 throw new TypeError(fun + " is not a function");
12061 for (var i = 0; i < length; i++) {
12062 if (i in self && !fun.call(thisp, self[i], i, object)) {
12069 if (!Array.prototype.some) {
12070 Array.prototype.some = function some(fun /*, thisp */) {
12071 var object = toObject(this),
12072 self = splitString && _toString(this) == "[object String]" ?
12075 length = self.length >>> 0,
12076 thisp = arguments[1];
12077 if (_toString(fun) != "[object Function]") {
12078 throw new TypeError(fun + " is not a function");
12081 for (var i = 0; i < length; i++) {
12082 if (i in self && fun.call(thisp, self[i], i, object)) {
12089 if (!Array.prototype.reduce) {
12090 Array.prototype.reduce = function reduce(fun /*, initial*/) {
12091 var object = toObject(this),
12092 self = splitString && _toString(this) == "[object String]" ?
12095 length = self.length >>> 0;
12096 if (_toString(fun) != "[object Function]") {
12097 throw new TypeError(fun + " is not a function");
12099 if (!length && arguments.length == 1) {
12100 throw new TypeError("reduce of empty array with no initial value");
12105 if (arguments.length >= 2) {
12106 result = arguments[1];
12110 result = self[i++];
12113 if (++i >= length) {
12114 throw new TypeError("reduce of empty array with no initial value");
12119 for (; i < length; i++) {
12121 result = fun.call(void 0, result, self[i], i, object);
12128 if (!Array.prototype.reduceRight) {
12129 Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
12130 var object = toObject(this),
12131 self = splitString && _toString(this) == "[object String]" ?
12134 length = self.length >>> 0;
12135 if (_toString(fun) != "[object Function]") {
12136 throw new TypeError(fun + " is not a function");
12138 if (!length && arguments.length == 1) {
12139 throw new TypeError("reduceRight of empty array with no initial value");
12142 var result, i = length - 1;
12143 if (arguments.length >= 2) {
12144 result = arguments[1];
12148 result = self[i--];
12152 throw new TypeError("reduceRight of empty array with no initial value");
12159 result = fun.call(void 0, result, self[i], i, object);
12166 if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
12167 Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
12168 var self = splitString && _toString(this) == "[object String]" ?
12171 length = self.length >>> 0;
12178 if (arguments.length > 1) {
12179 i = toInteger(arguments[1]);
12181 i = i >= 0 ? i : Math.max(0, length + i);
12182 for (; i < length; i++) {
12183 if (i in self && self[i] === sought) {
12190 if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
12191 Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
12192 var self = splitString && _toString(this) == "[object String]" ?
12195 length = self.length >>> 0;
12200 var i = length - 1;
12201 if (arguments.length > 1) {
12202 i = Math.min(i, toInteger(arguments[1]));
12204 i = i >= 0 ? i : length - Math.abs(i);
12205 for (; i >= 0; i--) {
12206 if (i in self && sought === self[i]) {
12213 if (!Object.getPrototypeOf) {
12214 Object.getPrototypeOf = function getPrototypeOf(object) {
12215 return object.__proto__ || (
12216 object.constructor ?
12217 object.constructor.prototype :
12222 if (!Object.getOwnPropertyDescriptor) {
12223 var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
12225 Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
12226 if ((typeof object != "object" && typeof object != "function") || object === null)
12227 throw new TypeError(ERR_NON_OBJECT + object);
12228 if (!owns(object, property))
12231 var descriptor, getter, setter;
12232 descriptor = { enumerable: true, configurable: true };
12233 if (supportsAccessors) {
12234 var prototype = object.__proto__;
12235 object.__proto__ = prototypeOfObject;
12237 var getter = lookupGetter(object, property);
12238 var setter = lookupSetter(object, property);
12239 object.__proto__ = prototype;
12241 if (getter || setter) {
12242 if (getter) descriptor.get = getter;
12243 if (setter) descriptor.set = setter;
12247 descriptor.value = object[property];
12251 if (!Object.getOwnPropertyNames) {
12252 Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
12253 return Object.keys(object);
12256 if (!Object.create) {
12258 if (Object.prototype.__proto__ === null) {
12259 createEmpty = function () {
12260 return { "__proto__": null };
12263 createEmpty = function () {
12265 for (var i in empty)
12267 empty.constructor =
12268 empty.hasOwnProperty =
12269 empty.propertyIsEnumerable =
12270 empty.isPrototypeOf =
12271 empty.toLocaleString =
12274 empty.__proto__ = null;
12279 Object.create = function create(prototype, properties) {
12281 if (prototype === null) {
12282 object = createEmpty();
12284 if (typeof prototype != "object")
12285 throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
12286 var Type = function () {};
12287 Type.prototype = prototype;
12288 object = new Type();
12289 object.__proto__ = prototype;
12291 if (properties !== void 0)
12292 Object.defineProperties(object, properties);
12297 function doesDefinePropertyWork(object) {
12299 Object.defineProperty(object, "sentinel", {});
12300 return "sentinel" in object;
12301 } catch (exception) {
12304 if (Object.defineProperty) {
12305 var definePropertyWorksOnObject = doesDefinePropertyWork({});
12306 var definePropertyWorksOnDom = typeof document == "undefined" ||
12307 doesDefinePropertyWork(document.createElement("div"));
12308 if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
12309 var definePropertyFallback = Object.defineProperty;
12313 if (!Object.defineProperty || definePropertyFallback) {
12314 var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
12315 var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
12316 var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
12317 "on this javascript engine";
12319 Object.defineProperty = function defineProperty(object, property, descriptor) {
12320 if ((typeof object != "object" && typeof object != "function") || object === null)
12321 throw new TypeError(ERR_NON_OBJECT_TARGET + object);
12322 if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
12323 throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
12324 if (definePropertyFallback) {
12326 return definePropertyFallback.call(Object, object, property, descriptor);
12327 } catch (exception) {
12330 if (owns(descriptor, "value")) {
12332 if (supportsAccessors && (lookupGetter(object, property) ||
12333 lookupSetter(object, property)))
12335 var prototype = object.__proto__;
12336 object.__proto__ = prototypeOfObject;
12337 delete object[property];
12338 object[property] = descriptor.value;
12339 object.__proto__ = prototype;
12341 object[property] = descriptor.value;
12344 if (!supportsAccessors)
12345 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
12346 if (owns(descriptor, "get"))
12347 defineGetter(object, property, descriptor.get);
12348 if (owns(descriptor, "set"))
12349 defineSetter(object, property, descriptor.set);
12355 if (!Object.defineProperties) {
12356 Object.defineProperties = function defineProperties(object, properties) {
12357 for (var property in properties) {
12358 if (owns(properties, property))
12359 Object.defineProperty(object, property, properties[property]);
12364 if (!Object.seal) {
12365 Object.seal = function seal(object) {
12369 if (!Object.freeze) {
12370 Object.freeze = function freeze(object) {
12375 Object.freeze(function () {});
12376 } catch (exception) {
12377 Object.freeze = (function freeze(freezeObject) {
12378 return function freeze(object) {
12379 if (typeof object == "function") {
12382 return freezeObject(object);
12387 if (!Object.preventExtensions) {
12388 Object.preventExtensions = function preventExtensions(object) {
12392 if (!Object.isSealed) {
12393 Object.isSealed = function isSealed(object) {
12397 if (!Object.isFrozen) {
12398 Object.isFrozen = function isFrozen(object) {
12402 if (!Object.isExtensible) {
12403 Object.isExtensible = function isExtensible(object) {
12404 if (Object(object) === object) {
12405 throw new TypeError(); // TODO message
12408 while (owns(object, name)) {
12411 object[name] = true;
12412 var returnValue = owns(object, name);
12413 delete object[name];
12414 return returnValue;
12417 if (!Object.keys) {
12418 var hasDontEnumBug = true,
12425 "propertyIsEnumerable",
12428 dontEnumsLength = dontEnums.length;
12430 for (var key in {"toString": null}) {
12431 hasDontEnumBug = false;
12434 Object.keys = function keys(object) {
12437 (typeof object != "object" && typeof object != "function") ||
12440 throw new TypeError("Object.keys called on a non-object");
12444 for (var name in object) {
12445 if (owns(object, name)) {
12450 if (hasDontEnumBug) {
12451 for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
12452 var dontEnum = dontEnums[i];
12453 if (owns(object, dontEnum)) {
12454 keys.push(dontEnum);
12463 Date.now = function now() {
12464 return new Date().getTime();
12467 var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
12468 "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
12470 if (!String.prototype.trim || ws.trim()) {
12471 ws = "[" + ws + "]";
12472 var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
12473 trimEndRegexp = new RegExp(ws + ws + "*$");
12474 String.prototype.trim = function trim() {
12475 return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
12479 function toInteger(n) {
12481 if (n !== n) { // isNaN
12483 } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
12484 n = (n > 0 || -1) * Math.floor(Math.abs(n));
12489 function isPrimitive(input) {
12490 var type = typeof input;
12493 type === "undefined" ||
12494 type === "boolean" ||
12495 type === "number" ||
12500 function toPrimitive(input) {
12501 var val, valueOf, toString;
12502 if (isPrimitive(input)) {
12505 valueOf = input.valueOf;
12506 if (typeof valueOf === "function") {
12507 val = valueOf.call(input);
12508 if (isPrimitive(val)) {
12512 toString = input.toString;
12513 if (typeof toString === "function") {
12514 val = toString.call(input);
12515 if (isPrimitive(val)) {
12519 throw new TypeError();
12521 var toObject = function (o) {
12522 if (o == null) { // this matches both null and undefined
12523 throw new TypeError("can't convert "+o+" to object");