1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/system/gonk/tests/marionette/ril_jshint/jshint.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,11096 @@ 1.4 +//2.1.3 1.5 +var JSHINT; 1.6 +(function () { 1.7 +var require; 1.8 +require=(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){ 1.9 +// shim for using process in browser 1.10 + 1.11 +var process = module.exports = {}; 1.12 + 1.13 +process.nextTick = (function () { 1.14 + var canSetImmediate = typeof window !== 'undefined' 1.15 + && window.setImmediate; 1.16 + var canPost = typeof window !== 'undefined' 1.17 + && window.postMessage && window.addEventListener 1.18 + ; 1.19 + 1.20 + if (canSetImmediate) { 1.21 + return function (f) { return window.setImmediate(f) }; 1.22 + } 1.23 + 1.24 + if (canPost) { 1.25 + var queue = []; 1.26 + window.addEventListener('message', function (ev) { 1.27 + if (ev.source === window && ev.data === 'process-tick') { 1.28 + ev.stopPropagation(); 1.29 + if (queue.length > 0) { 1.30 + var fn = queue.shift(); 1.31 + fn(); 1.32 + } 1.33 + } 1.34 + }, true); 1.35 + 1.36 + return function nextTick(fn) { 1.37 + queue.push(fn); 1.38 + window.postMessage('process-tick', '*'); 1.39 + }; 1.40 + } 1.41 + 1.42 + return function nextTick(fn) { 1.43 + setTimeout(fn, 0); 1.44 + }; 1.45 +})(); 1.46 + 1.47 +process.title = 'browser'; 1.48 +process.browser = true; 1.49 +process.env = {}; 1.50 +process.argv = []; 1.51 + 1.52 +process.binding = function (name) { 1.53 + throw new Error('process.binding is not supported'); 1.54 +} 1.55 + 1.56 +// TODO(shtylman) 1.57 +process.cwd = function () { return '/' }; 1.58 +process.chdir = function (dir) { 1.59 + throw new Error('process.chdir is not supported'); 1.60 +}; 1.61 + 1.62 +},{}],2:[function(require,module,exports){ 1.63 +(function(process){if (!process.EventEmitter) process.EventEmitter = function () {}; 1.64 + 1.65 +var EventEmitter = exports.EventEmitter = process.EventEmitter; 1.66 +var isArray = typeof Array.isArray === 'function' 1.67 + ? Array.isArray 1.68 + : function (xs) { 1.69 + return Object.prototype.toString.call(xs) === '[object Array]' 1.70 + } 1.71 +; 1.72 +function indexOf (xs, x) { 1.73 + if (xs.indexOf) return xs.indexOf(x); 1.74 + for (var i = 0; i < xs.length; i++) { 1.75 + if (x === xs[i]) return i; 1.76 + } 1.77 + return -1; 1.78 +} 1.79 + 1.80 +// By default EventEmitters will print a warning if more than 1.81 +// 10 listeners are added to it. This is a useful default which 1.82 +// helps finding memory leaks. 1.83 +// 1.84 +// Obviously not all Emitters should be limited to 10. This function allows 1.85 +// that to be increased. Set to zero for unlimited. 1.86 +var defaultMaxListeners = 10; 1.87 +EventEmitter.prototype.setMaxListeners = function(n) { 1.88 + if (!this._events) this._events = {}; 1.89 + this._events.maxListeners = n; 1.90 +}; 1.91 + 1.92 + 1.93 +EventEmitter.prototype.emit = function(type) { 1.94 + // If there is no 'error' event listener then throw. 1.95 + if (type === 'error') { 1.96 + if (!this._events || !this._events.error || 1.97 + (isArray(this._events.error) && !this._events.error.length)) 1.98 + { 1.99 + if (arguments[1] instanceof Error) { 1.100 + throw arguments[1]; // Unhandled 'error' event 1.101 + } else { 1.102 + throw new Error("Uncaught, unspecified 'error' event."); 1.103 + } 1.104 + return false; 1.105 + } 1.106 + } 1.107 + 1.108 + if (!this._events) return false; 1.109 + var handler = this._events[type]; 1.110 + if (!handler) return false; 1.111 + 1.112 + if (typeof handler == 'function') { 1.113 + switch (arguments.length) { 1.114 + // fast cases 1.115 + case 1: 1.116 + handler.call(this); 1.117 + break; 1.118 + case 2: 1.119 + handler.call(this, arguments[1]); 1.120 + break; 1.121 + case 3: 1.122 + handler.call(this, arguments[1], arguments[2]); 1.123 + break; 1.124 + // slower 1.125 + default: 1.126 + var args = Array.prototype.slice.call(arguments, 1); 1.127 + handler.apply(this, args); 1.128 + } 1.129 + return true; 1.130 + 1.131 + } else if (isArray(handler)) { 1.132 + var args = Array.prototype.slice.call(arguments, 1); 1.133 + 1.134 + var listeners = handler.slice(); 1.135 + for (var i = 0, l = listeners.length; i < l; i++) { 1.136 + listeners[i].apply(this, args); 1.137 + } 1.138 + return true; 1.139 + 1.140 + } else { 1.141 + return false; 1.142 + } 1.143 +}; 1.144 + 1.145 +// EventEmitter is defined in src/node_events.cc 1.146 +// EventEmitter.prototype.emit() is also defined there. 1.147 +EventEmitter.prototype.addListener = function(type, listener) { 1.148 + if ('function' !== typeof listener) { 1.149 + throw new Error('addListener only takes instances of Function'); 1.150 + } 1.151 + 1.152 + if (!this._events) this._events = {}; 1.153 + 1.154 + // To avoid recursion in the case that type == "newListeners"! Before 1.155 + // adding it to the listeners, first emit "newListeners". 1.156 + this.emit('newListener', type, listener); 1.157 + 1.158 + if (!this._events[type]) { 1.159 + // Optimize the case of one listener. Don't need the extra array object. 1.160 + this._events[type] = listener; 1.161 + } else if (isArray(this._events[type])) { 1.162 + 1.163 + // Check for listener leak 1.164 + if (!this._events[type].warned) { 1.165 + var m; 1.166 + if (this._events.maxListeners !== undefined) { 1.167 + m = this._events.maxListeners; 1.168 + } else { 1.169 + m = defaultMaxListeners; 1.170 + } 1.171 + 1.172 + if (m && m > 0 && this._events[type].length > m) { 1.173 + this._events[type].warned = true; 1.174 + console.error('(node) warning: possible EventEmitter memory ' + 1.175 + 'leak detected. %d listeners added. ' + 1.176 + 'Use emitter.setMaxListeners() to increase limit.', 1.177 + this._events[type].length); 1.178 + console.trace(); 1.179 + } 1.180 + } 1.181 + 1.182 + // If we've already got an array, just append. 1.183 + this._events[type].push(listener); 1.184 + } else { 1.185 + // Adding the second element, need to change to array. 1.186 + this._events[type] = [this._events[type], listener]; 1.187 + } 1.188 + 1.189 + return this; 1.190 +}; 1.191 + 1.192 +EventEmitter.prototype.on = EventEmitter.prototype.addListener; 1.193 + 1.194 +EventEmitter.prototype.once = function(type, listener) { 1.195 + var self = this; 1.196 + self.on(type, function g() { 1.197 + self.removeListener(type, g); 1.198 + listener.apply(this, arguments); 1.199 + }); 1.200 + 1.201 + return this; 1.202 +}; 1.203 + 1.204 +EventEmitter.prototype.removeListener = function(type, listener) { 1.205 + if ('function' !== typeof listener) { 1.206 + throw new Error('removeListener only takes instances of Function'); 1.207 + } 1.208 + 1.209 + // does not use listeners(), so no side effect of creating _events[type] 1.210 + if (!this._events || !this._events[type]) return this; 1.211 + 1.212 + var list = this._events[type]; 1.213 + 1.214 + if (isArray(list)) { 1.215 + var i = indexOf(list, listener); 1.216 + if (i < 0) return this; 1.217 + list.splice(i, 1); 1.218 + if (list.length == 0) 1.219 + delete this._events[type]; 1.220 + } else if (this._events[type] === listener) { 1.221 + delete this._events[type]; 1.222 + } 1.223 + 1.224 + return this; 1.225 +}; 1.226 + 1.227 +EventEmitter.prototype.removeAllListeners = function(type) { 1.228 + if (arguments.length === 0) { 1.229 + this._events = {}; 1.230 + return this; 1.231 + } 1.232 + 1.233 + // does not use listeners(), so no side effect of creating _events[type] 1.234 + if (type && this._events && this._events[type]) this._events[type] = null; 1.235 + return this; 1.236 +}; 1.237 + 1.238 +EventEmitter.prototype.listeners = function(type) { 1.239 + if (!this._events) this._events = {}; 1.240 + if (!this._events[type]) this._events[type] = []; 1.241 + if (!isArray(this._events[type])) { 1.242 + this._events[type] = [this._events[type]]; 1.243 + } 1.244 + return this._events[type]; 1.245 +}; 1.246 + 1.247 +})(require("__browserify_process")) 1.248 +},{"__browserify_process":1}],3:[function(require,module,exports){ 1.249 +(function(){// jshint -W001 1.250 + 1.251 +"use strict"; 1.252 + 1.253 +// Identifiers provided by the ECMAScript standard. 1.254 + 1.255 +exports.reservedVars = { 1.256 + arguments : false, 1.257 + NaN : false 1.258 +}; 1.259 + 1.260 +exports.ecmaIdentifiers = { 1.261 + Array : false, 1.262 + Boolean : false, 1.263 + Date : false, 1.264 + decodeURI : false, 1.265 + decodeURIComponent : false, 1.266 + encodeURI : false, 1.267 + encodeURIComponent : false, 1.268 + Error : false, 1.269 + "eval" : false, 1.270 + EvalError : false, 1.271 + Function : false, 1.272 + hasOwnProperty : false, 1.273 + isFinite : false, 1.274 + isNaN : false, 1.275 + JSON : false, 1.276 + Math : false, 1.277 + Map : false, 1.278 + Number : false, 1.279 + Object : false, 1.280 + parseInt : false, 1.281 + parseFloat : false, 1.282 + RangeError : false, 1.283 + ReferenceError : false, 1.284 + RegExp : false, 1.285 + Set : false, 1.286 + String : false, 1.287 + SyntaxError : false, 1.288 + TypeError : false, 1.289 + URIError : false, 1.290 + WeakMap : false 1.291 +}; 1.292 + 1.293 +// Global variables commonly provided by a web browser environment. 1.294 + 1.295 +exports.browser = { 1.296 + ArrayBuffer : false, 1.297 + ArrayBufferView : false, 1.298 + Audio : false, 1.299 + Blob : false, 1.300 + addEventListener : false, 1.301 + applicationCache : false, 1.302 + atob : false, 1.303 + blur : false, 1.304 + btoa : false, 1.305 + clearInterval : false, 1.306 + clearTimeout : false, 1.307 + close : false, 1.308 + closed : false, 1.309 + DataView : false, 1.310 + DOMParser : false, 1.311 + defaultStatus : false, 1.312 + document : false, 1.313 + Element : false, 1.314 + ElementTimeControl : false, 1.315 + event : false, 1.316 + FileReader : false, 1.317 + Float32Array : false, 1.318 + Float64Array : false, 1.319 + FormData : false, 1.320 + focus : false, 1.321 + frames : false, 1.322 + getComputedStyle : false, 1.323 + HTMLElement : false, 1.324 + HTMLAnchorElement : false, 1.325 + HTMLBaseElement : false, 1.326 + HTMLBlockquoteElement: false, 1.327 + HTMLBodyElement : false, 1.328 + HTMLBRElement : false, 1.329 + HTMLButtonElement : false, 1.330 + HTMLCanvasElement : false, 1.331 + HTMLDirectoryElement : false, 1.332 + HTMLDivElement : false, 1.333 + HTMLDListElement : false, 1.334 + HTMLFieldSetElement : false, 1.335 + HTMLFontElement : false, 1.336 + HTMLFormElement : false, 1.337 + HTMLFrameElement : false, 1.338 + HTMLFrameSetElement : false, 1.339 + HTMLHeadElement : false, 1.340 + HTMLHeadingElement : false, 1.341 + HTMLHRElement : false, 1.342 + HTMLHtmlElement : false, 1.343 + HTMLIFrameElement : false, 1.344 + HTMLImageElement : false, 1.345 + HTMLInputElement : false, 1.346 + HTMLIsIndexElement : false, 1.347 + HTMLLabelElement : false, 1.348 + HTMLLayerElement : false, 1.349 + HTMLLegendElement : false, 1.350 + HTMLLIElement : false, 1.351 + HTMLLinkElement : false, 1.352 + HTMLMapElement : false, 1.353 + HTMLMenuElement : false, 1.354 + HTMLMetaElement : false, 1.355 + HTMLModElement : false, 1.356 + HTMLObjectElement : false, 1.357 + HTMLOListElement : false, 1.358 + HTMLOptGroupElement : false, 1.359 + HTMLOptionElement : false, 1.360 + HTMLParagraphElement : false, 1.361 + HTMLParamElement : false, 1.362 + HTMLPreElement : false, 1.363 + HTMLQuoteElement : false, 1.364 + HTMLScriptElement : false, 1.365 + HTMLSelectElement : false, 1.366 + HTMLStyleElement : false, 1.367 + HTMLTableCaptionElement: false, 1.368 + HTMLTableCellElement : false, 1.369 + HTMLTableColElement : false, 1.370 + HTMLTableElement : false, 1.371 + HTMLTableRowElement : false, 1.372 + HTMLTableSectionElement: false, 1.373 + HTMLTextAreaElement : false, 1.374 + HTMLTitleElement : false, 1.375 + HTMLUListElement : false, 1.376 + HTMLVideoElement : false, 1.377 + history : false, 1.378 + Int16Array : false, 1.379 + Int32Array : false, 1.380 + Int8Array : false, 1.381 + Image : false, 1.382 + length : false, 1.383 + localStorage : false, 1.384 + location : false, 1.385 + MessageChannel : false, 1.386 + MessageEvent : false, 1.387 + MessagePort : false, 1.388 + moveBy : false, 1.389 + moveTo : false, 1.390 + MutationObserver : false, 1.391 + name : false, 1.392 + Node : false, 1.393 + NodeFilter : false, 1.394 + navigator : false, 1.395 + onbeforeunload : true, 1.396 + onblur : true, 1.397 + onerror : true, 1.398 + onfocus : true, 1.399 + onload : true, 1.400 + onresize : true, 1.401 + onunload : true, 1.402 + open : false, 1.403 + openDatabase : false, 1.404 + opener : false, 1.405 + Option : false, 1.406 + parent : false, 1.407 + print : false, 1.408 + removeEventListener : false, 1.409 + resizeBy : false, 1.410 + resizeTo : false, 1.411 + screen : false, 1.412 + scroll : false, 1.413 + scrollBy : false, 1.414 + scrollTo : false, 1.415 + sessionStorage : false, 1.416 + setInterval : false, 1.417 + setTimeout : false, 1.418 + SharedWorker : false, 1.419 + status : false, 1.420 + SVGAElement : false, 1.421 + SVGAltGlyphDefElement: false, 1.422 + SVGAltGlyphElement : false, 1.423 + SVGAltGlyphItemElement: false, 1.424 + SVGAngle : false, 1.425 + SVGAnimateColorElement: false, 1.426 + SVGAnimateElement : false, 1.427 + SVGAnimateMotionElement: false, 1.428 + SVGAnimateTransformElement: false, 1.429 + SVGAnimatedAngle : false, 1.430 + SVGAnimatedBoolean : false, 1.431 + SVGAnimatedEnumeration: false, 1.432 + SVGAnimatedInteger : false, 1.433 + SVGAnimatedLength : false, 1.434 + SVGAnimatedLengthList: false, 1.435 + SVGAnimatedNumber : false, 1.436 + SVGAnimatedNumberList: false, 1.437 + SVGAnimatedPathData : false, 1.438 + SVGAnimatedPoints : false, 1.439 + SVGAnimatedPreserveAspectRatio: false, 1.440 + SVGAnimatedRect : false, 1.441 + SVGAnimatedString : false, 1.442 + SVGAnimatedTransformList: false, 1.443 + SVGAnimationElement : false, 1.444 + SVGCSSRule : false, 1.445 + SVGCircleElement : false, 1.446 + SVGClipPathElement : false, 1.447 + SVGColor : false, 1.448 + SVGColorProfileElement: false, 1.449 + SVGColorProfileRule : false, 1.450 + SVGComponentTransferFunctionElement: false, 1.451 + SVGCursorElement : false, 1.452 + SVGDefsElement : false, 1.453 + SVGDescElement : false, 1.454 + SVGDocument : false, 1.455 + SVGElement : false, 1.456 + SVGElementInstance : false, 1.457 + SVGElementInstanceList: false, 1.458 + SVGEllipseElement : false, 1.459 + SVGExternalResourcesRequired: false, 1.460 + SVGFEBlendElement : false, 1.461 + SVGFEColorMatrixElement: false, 1.462 + SVGFEComponentTransferElement: false, 1.463 + SVGFECompositeElement: false, 1.464 + SVGFEConvolveMatrixElement: false, 1.465 + SVGFEDiffuseLightingElement: false, 1.466 + SVGFEDisplacementMapElement: false, 1.467 + SVGFEDistantLightElement: false, 1.468 + SVGFEDropShadowElement: false, 1.469 + SVGFEFloodElement : false, 1.470 + SVGFEFuncAElement : false, 1.471 + SVGFEFuncBElement : false, 1.472 + SVGFEFuncGElement : false, 1.473 + SVGFEFuncRElement : false, 1.474 + SVGFEGaussianBlurElement: false, 1.475 + SVGFEImageElement : false, 1.476 + SVGFEMergeElement : false, 1.477 + SVGFEMergeNodeElement: false, 1.478 + SVGFEMorphologyElement: false, 1.479 + SVGFEOffsetElement : false, 1.480 + SVGFEPointLightElement: false, 1.481 + SVGFESpecularLightingElement: false, 1.482 + SVGFESpotLightElement: false, 1.483 + SVGFETileElement : false, 1.484 + SVGFETurbulenceElement: false, 1.485 + SVGFilterElement : false, 1.486 + SVGFilterPrimitiveStandardAttributes: false, 1.487 + SVGFitToViewBox : false, 1.488 + SVGFontElement : false, 1.489 + SVGFontFaceElement : false, 1.490 + SVGFontFaceFormatElement: false, 1.491 + SVGFontFaceNameElement: false, 1.492 + SVGFontFaceSrcElement: false, 1.493 + SVGFontFaceUriElement: false, 1.494 + SVGForeignObjectElement: false, 1.495 + SVGGElement : false, 1.496 + SVGGlyphElement : false, 1.497 + SVGGlyphRefElement : false, 1.498 + SVGGradientElement : false, 1.499 + SVGHKernElement : false, 1.500 + SVGICCColor : false, 1.501 + SVGImageElement : false, 1.502 + SVGLangSpace : false, 1.503 + SVGLength : false, 1.504 + SVGLengthList : false, 1.505 + SVGLineElement : false, 1.506 + SVGLinearGradientElement: false, 1.507 + SVGLocatable : false, 1.508 + SVGMPathElement : false, 1.509 + SVGMarkerElement : false, 1.510 + SVGMaskElement : false, 1.511 + SVGMatrix : false, 1.512 + SVGMetadataElement : false, 1.513 + SVGMissingGlyphElement: false, 1.514 + SVGNumber : false, 1.515 + SVGNumberList : false, 1.516 + SVGPaint : false, 1.517 + SVGPathElement : false, 1.518 + SVGPathSeg : false, 1.519 + SVGPathSegArcAbs : false, 1.520 + SVGPathSegArcRel : false, 1.521 + SVGPathSegClosePath : false, 1.522 + SVGPathSegCurvetoCubicAbs: false, 1.523 + SVGPathSegCurvetoCubicRel: false, 1.524 + SVGPathSegCurvetoCubicSmoothAbs: false, 1.525 + SVGPathSegCurvetoCubicSmoothRel: false, 1.526 + SVGPathSegCurvetoQuadraticAbs: false, 1.527 + SVGPathSegCurvetoQuadraticRel: false, 1.528 + SVGPathSegCurvetoQuadraticSmoothAbs: false, 1.529 + SVGPathSegCurvetoQuadraticSmoothRel: false, 1.530 + SVGPathSegLinetoAbs : false, 1.531 + SVGPathSegLinetoHorizontalAbs: false, 1.532 + SVGPathSegLinetoHorizontalRel: false, 1.533 + SVGPathSegLinetoRel : false, 1.534 + SVGPathSegLinetoVerticalAbs: false, 1.535 + SVGPathSegLinetoVerticalRel: false, 1.536 + SVGPathSegList : false, 1.537 + SVGPathSegMovetoAbs : false, 1.538 + SVGPathSegMovetoRel : false, 1.539 + SVGPatternElement : false, 1.540 + SVGPoint : false, 1.541 + SVGPointList : false, 1.542 + SVGPolygonElement : false, 1.543 + SVGPolylineElement : false, 1.544 + SVGPreserveAspectRatio: false, 1.545 + SVGRadialGradientElement: false, 1.546 + SVGRect : false, 1.547 + SVGRectElement : false, 1.548 + SVGRenderingIntent : false, 1.549 + SVGSVGElement : false, 1.550 + SVGScriptElement : false, 1.551 + SVGSetElement : false, 1.552 + SVGStopElement : false, 1.553 + SVGStringList : false, 1.554 + SVGStylable : false, 1.555 + SVGStyleElement : false, 1.556 + SVGSwitchElement : false, 1.557 + SVGSymbolElement : false, 1.558 + SVGTRefElement : false, 1.559 + SVGTSpanElement : false, 1.560 + SVGTests : false, 1.561 + SVGTextContentElement: false, 1.562 + SVGTextElement : false, 1.563 + SVGTextPathElement : false, 1.564 + SVGTextPositioningElement: false, 1.565 + SVGTitleElement : false, 1.566 + SVGTransform : false, 1.567 + SVGTransformList : false, 1.568 + SVGTransformable : false, 1.569 + SVGURIReference : false, 1.570 + SVGUnitTypes : false, 1.571 + SVGUseElement : false, 1.572 + SVGVKernElement : false, 1.573 + SVGViewElement : false, 1.574 + SVGViewSpec : false, 1.575 + SVGZoomAndPan : false, 1.576 + TimeEvent : false, 1.577 + top : false, 1.578 + Uint16Array : false, 1.579 + Uint32Array : false, 1.580 + Uint8Array : false, 1.581 + Uint8ClampedArray : false, 1.582 + WebSocket : false, 1.583 + window : false, 1.584 + Worker : false, 1.585 + XMLHttpRequest : false, 1.586 + XMLSerializer : false, 1.587 + XPathEvaluator : false, 1.588 + XPathException : false, 1.589 + XPathExpression : false, 1.590 + XPathNSResolver : false, 1.591 + XPathResult : false 1.592 +}; 1.593 + 1.594 +exports.devel = { 1.595 + alert : false, 1.596 + confirm: false, 1.597 + console: false, 1.598 + Debug : false, 1.599 + opera : false, 1.600 + prompt : false 1.601 +}; 1.602 + 1.603 +exports.worker = { 1.604 + importScripts: true, 1.605 + postMessage : true, 1.606 + self : true 1.607 +}; 1.608 + 1.609 +// Widely adopted global names that are not part of ECMAScript standard 1.610 +exports.nonstandard = { 1.611 + escape : false, 1.612 + unescape: false 1.613 +}; 1.614 + 1.615 +// Globals provided by popular JavaScript environments. 1.616 + 1.617 +exports.couch = { 1.618 + "require" : false, 1.619 + respond : false, 1.620 + getRow : false, 1.621 + emit : false, 1.622 + send : false, 1.623 + start : false, 1.624 + sum : false, 1.625 + log : false, 1.626 + exports : false, 1.627 + module : false, 1.628 + provides : false 1.629 +}; 1.630 + 1.631 +exports.node = { 1.632 + __filename : false, 1.633 + __dirname : false, 1.634 + Buffer : false, 1.635 + DataView : false, 1.636 + console : false, 1.637 + exports : true, // In Node it is ok to exports = module.exports = foo(); 1.638 + GLOBAL : false, 1.639 + global : false, 1.640 + module : false, 1.641 + process : false, 1.642 + require : false, 1.643 + setTimeout : false, 1.644 + clearTimeout : false, 1.645 + setInterval : false, 1.646 + clearInterval : false, 1.647 + setImmediate : false, // v0.9.1+ 1.648 + clearImmediate: false // v0.9.1+ 1.649 +}; 1.650 + 1.651 +exports.phantom = { 1.652 + phantom : true, 1.653 + require : true, 1.654 + WebPage : true 1.655 +}; 1.656 + 1.657 +exports.rhino = { 1.658 + defineClass : false, 1.659 + deserialize : false, 1.660 + gc : false, 1.661 + help : false, 1.662 + importPackage: false, 1.663 + "java" : false, 1.664 + load : false, 1.665 + loadClass : false, 1.666 + print : false, 1.667 + quit : false, 1.668 + readFile : false, 1.669 + readUrl : false, 1.670 + runCommand : false, 1.671 + seal : false, 1.672 + serialize : false, 1.673 + spawn : false, 1.674 + sync : false, 1.675 + toint32 : false, 1.676 + version : false 1.677 +}; 1.678 + 1.679 +exports.wsh = { 1.680 + ActiveXObject : true, 1.681 + Enumerator : true, 1.682 + GetObject : true, 1.683 + ScriptEngine : true, 1.684 + ScriptEngineBuildVersion : true, 1.685 + ScriptEngineMajorVersion : true, 1.686 + ScriptEngineMinorVersion : true, 1.687 + VBArray : true, 1.688 + WSH : true, 1.689 + WScript : true, 1.690 + XDomainRequest : true 1.691 +}; 1.692 + 1.693 +// Globals provided by popular JavaScript libraries. 1.694 + 1.695 +exports.dojo = { 1.696 + dojo : false, 1.697 + dijit : false, 1.698 + dojox : false, 1.699 + define : false, 1.700 + "require": false 1.701 +}; 1.702 + 1.703 +exports.jquery = { 1.704 + "$" : false, 1.705 + jQuery : false 1.706 +}; 1.707 + 1.708 +exports.mootools = { 1.709 + "$" : false, 1.710 + "$$" : false, 1.711 + Asset : false, 1.712 + Browser : false, 1.713 + Chain : false, 1.714 + Class : false, 1.715 + Color : false, 1.716 + Cookie : false, 1.717 + Core : false, 1.718 + Document : false, 1.719 + DomReady : false, 1.720 + DOMEvent : false, 1.721 + DOMReady : false, 1.722 + Drag : false, 1.723 + Element : false, 1.724 + Elements : false, 1.725 + Event : false, 1.726 + Events : false, 1.727 + Fx : false, 1.728 + Group : false, 1.729 + Hash : false, 1.730 + HtmlTable : false, 1.731 + Iframe : false, 1.732 + IframeShim : false, 1.733 + InputValidator: false, 1.734 + instanceOf : false, 1.735 + Keyboard : false, 1.736 + Locale : false, 1.737 + Mask : false, 1.738 + MooTools : false, 1.739 + Native : false, 1.740 + Options : false, 1.741 + OverText : false, 1.742 + Request : false, 1.743 + Scroller : false, 1.744 + Slick : false, 1.745 + Slider : false, 1.746 + Sortables : false, 1.747 + Spinner : false, 1.748 + Swiff : false, 1.749 + Tips : false, 1.750 + Type : false, 1.751 + typeOf : false, 1.752 + URI : false, 1.753 + Window : false 1.754 +}; 1.755 + 1.756 +exports.prototypejs = { 1.757 + "$" : false, 1.758 + "$$" : false, 1.759 + "$A" : false, 1.760 + "$F" : false, 1.761 + "$H" : false, 1.762 + "$R" : false, 1.763 + "$break" : false, 1.764 + "$continue" : false, 1.765 + "$w" : false, 1.766 + Abstract : false, 1.767 + Ajax : false, 1.768 + Class : false, 1.769 + Enumerable : false, 1.770 + Element : false, 1.771 + Event : false, 1.772 + Field : false, 1.773 + Form : false, 1.774 + Hash : false, 1.775 + Insertion : false, 1.776 + ObjectRange : false, 1.777 + PeriodicalExecuter: false, 1.778 + Position : false, 1.779 + Prototype : false, 1.780 + Selector : false, 1.781 + Template : false, 1.782 + Toggle : false, 1.783 + Try : false, 1.784 + Autocompleter : false, 1.785 + Builder : false, 1.786 + Control : false, 1.787 + Draggable : false, 1.788 + Draggables : false, 1.789 + Droppables : false, 1.790 + Effect : false, 1.791 + Sortable : false, 1.792 + SortableObserver : false, 1.793 + Sound : false, 1.794 + Scriptaculous : false 1.795 +}; 1.796 + 1.797 +exports.yui = { 1.798 + YUI : false, 1.799 + Y : false, 1.800 + YUI_config: false 1.801 +}; 1.802 + 1.803 + 1.804 +})() 1.805 +},{}],4:[function(require,module,exports){ 1.806 +"use strict"; 1.807 + 1.808 +var state = { 1.809 + syntax: {}, 1.810 + 1.811 + reset: function () { 1.812 + this.tokens = { 1.813 + prev: null, 1.814 + next: null, 1.815 + curr: null 1.816 + }; 1.817 + 1.818 + this.option = {}; 1.819 + this.ignored = {}; 1.820 + this.directive = {}; 1.821 + this.jsonMode = false; 1.822 + this.jsonWarnings = []; 1.823 + this.lines = []; 1.824 + this.tab = ""; 1.825 + this.cache = {}; // Node.JS doesn't have Map. Sniff. 1.826 + } 1.827 +}; 1.828 + 1.829 +exports.state = state; 1.830 + 1.831 +},{}],5:[function(require,module,exports){ 1.832 +(function(){"use strict"; 1.833 + 1.834 +exports.register = function (linter) { 1.835 + // Check for properties named __proto__. This special property was 1.836 + // deprecated and then re-introduced for ES6. 1.837 + 1.838 + linter.on("Identifier", function style_scanProto(data) { 1.839 + if (linter.getOption("proto")) { 1.840 + return; 1.841 + } 1.842 + 1.843 + if (data.name === "__proto__") { 1.844 + linter.warn("W103", { 1.845 + line: data.line, 1.846 + char: data.char, 1.847 + data: [ data.name ] 1.848 + }); 1.849 + } 1.850 + }); 1.851 + 1.852 + // Check for properties named __iterator__. This is a special property 1.853 + // available only in browsers with JavaScript 1.7 implementation. 1.854 + 1.855 + linter.on("Identifier", function style_scanIterator(data) { 1.856 + if (linter.getOption("iterator")) { 1.857 + return; 1.858 + } 1.859 + 1.860 + if (data.name === "__iterator__") { 1.861 + linter.warn("W104", { 1.862 + line: data.line, 1.863 + char: data.char, 1.864 + data: [ data.name ] 1.865 + }); 1.866 + } 1.867 + }); 1.868 + 1.869 + // Check for dangling underscores. 1.870 + 1.871 + linter.on("Identifier", function style_scanDangling(data) { 1.872 + if (!linter.getOption("nomen")) { 1.873 + return; 1.874 + } 1.875 + 1.876 + // Underscore.js 1.877 + if (data.name === "_") { 1.878 + return; 1.879 + } 1.880 + 1.881 + // In Node, __dirname and __filename should be ignored. 1.882 + if (linter.getOption("node")) { 1.883 + if (/^(__dirname|__filename)$/.test(data.name) && !data.isProperty) { 1.884 + return; 1.885 + } 1.886 + } 1.887 + 1.888 + if (/^(_+.*|.*_+)$/.test(data.name)) { 1.889 + linter.warn("W105", { 1.890 + line: data.line, 1.891 + char: data.from, 1.892 + data: [ "dangling '_'", data.name ] 1.893 + }); 1.894 + } 1.895 + }); 1.896 + 1.897 + // Check that all identifiers are using camelCase notation. 1.898 + // Exceptions: names like MY_VAR and _myVar. 1.899 + 1.900 + linter.on("Identifier", function style_scanCamelCase(data) { 1.901 + if (!linter.getOption("camelcase")) { 1.902 + return; 1.903 + } 1.904 + 1.905 + if (data.name.replace(/^_+/, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) { 1.906 + linter.warn("W106", { 1.907 + line: data.line, 1.908 + char: data.from, 1.909 + data: [ data.name ] 1.910 + }); 1.911 + } 1.912 + }); 1.913 + 1.914 + // Enforce consistency in style of quoting. 1.915 + 1.916 + linter.on("String", function style_scanQuotes(data) { 1.917 + var quotmark = linter.getOption("quotmark"); 1.918 + var code; 1.919 + 1.920 + if (!quotmark) { 1.921 + return; 1.922 + } 1.923 + 1.924 + // If quotmark is set to 'single' warn about all double-quotes. 1.925 + 1.926 + if (quotmark === "single" && data.quote !== "'") { 1.927 + code = "W109"; 1.928 + } 1.929 + 1.930 + // If quotmark is set to 'double' warn about all single-quotes. 1.931 + 1.932 + if (quotmark === "double" && data.quote !== "\"") { 1.933 + code = "W108"; 1.934 + } 1.935 + 1.936 + // If quotmark is set to true, remember the first quotation style 1.937 + // and then warn about all others. 1.938 + 1.939 + if (quotmark === true) { 1.940 + if (!linter.getCache("quotmark")) { 1.941 + linter.setCache("quotmark", data.quote); 1.942 + } 1.943 + 1.944 + if (linter.getCache("quotmark") !== data.quote) { 1.945 + code = "W110"; 1.946 + } 1.947 + } 1.948 + 1.949 + if (code) { 1.950 + linter.warn(code, { 1.951 + line: data.line, 1.952 + char: data.char, 1.953 + }); 1.954 + } 1.955 + }); 1.956 + 1.957 + linter.on("Number", function style_scanNumbers(data) { 1.958 + if (data.value.charAt(0) === ".") { 1.959 + // Warn about a leading decimal point. 1.960 + linter.warn("W008", { 1.961 + line: data.line, 1.962 + char: data.char, 1.963 + data: [ data.value ] 1.964 + }); 1.965 + } 1.966 + 1.967 + if (data.value.substr(data.value.length - 1) === ".") { 1.968 + // Warn about a trailing decimal point. 1.969 + linter.warn("W047", { 1.970 + line: data.line, 1.971 + char: data.char, 1.972 + data: [ data.value ] 1.973 + }); 1.974 + } 1.975 + 1.976 + if (/^00+/.test(data.value)) { 1.977 + // Multiple leading zeroes. 1.978 + linter.warn("W046", { 1.979 + line: data.line, 1.980 + char: data.char, 1.981 + data: [ data.value ] 1.982 + }); 1.983 + } 1.984 + }); 1.985 + 1.986 + // Warn about script URLs. 1.987 + 1.988 + linter.on("String", function style_scanJavaScriptURLs(data) { 1.989 + var re = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i; 1.990 + 1.991 + if (linter.getOption("scripturl")) { 1.992 + return; 1.993 + } 1.994 + 1.995 + if (re.test(data.value)) { 1.996 + linter.warn("W107", { 1.997 + line: data.line, 1.998 + char: data.char 1.999 + }); 1.1000 + } 1.1001 + }); 1.1002 +}; 1.1003 +})() 1.1004 +},{}],6:[function(require,module,exports){ 1.1005 +/* 1.1006 + * Regular expressions. Some of these are stupidly long. 1.1007 + */ 1.1008 + 1.1009 +/*jshint maxlen:1000 */ 1.1010 + 1.1011 +"use string"; 1.1012 + 1.1013 +// Unsafe comment or string (ax) 1.1014 +exports.unsafeString = 1.1015 + /@cc|<\/?|script|\]\s*\]|<\s*!|</i; 1.1016 + 1.1017 +// Unsafe characters that are silently deleted by one or more browsers (cx) 1.1018 +exports.unsafeChars = 1.1019 + /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/; 1.1020 + 1.1021 +// Characters in strings that need escaping (nx and nxg) 1.1022 +exports.needEsc = 1.1023 + /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/; 1.1024 + 1.1025 +exports.needEscGlobal = 1.1026 + /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; 1.1027 + 1.1028 +// Star slash (lx) 1.1029 +exports.starSlash = /\*\//; 1.1030 + 1.1031 +// Identifier (ix) 1.1032 +exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/; 1.1033 + 1.1034 +// JavaScript URL (jx) 1.1035 +exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i; 1.1036 + 1.1037 +// Catches /* falls through */ comments (ft) 1.1038 +//exports.fallsThrough = /^\s*\/\*\s*falls?\sthrough\s*\*\/\s*$/; 1.1039 +exports.fallsThrough = /^\s*\/\/\s*Falls?\sthrough.*\s*$/; 1.1040 + 1.1041 +},{}],7:[function(require,module,exports){ 1.1042 +(function(global){/*global window, global*/ 1.1043 +var util = require("util") 1.1044 +var assert = require("assert") 1.1045 + 1.1046 +var slice = Array.prototype.slice 1.1047 +var console 1.1048 +var times = {} 1.1049 + 1.1050 +if (typeof global !== "undefined" && global.console) { 1.1051 + console = global.console 1.1052 +} else if (typeof window !== "undefined" && window.console) { 1.1053 + console = window.console 1.1054 +} else { 1.1055 + console = window.console = {} 1.1056 +} 1.1057 + 1.1058 +var functions = [ 1.1059 + [log, "log"] 1.1060 + , [info, "info"] 1.1061 + , [warn, "warn"] 1.1062 + , [error, "error"] 1.1063 + , [time, "time"] 1.1064 + , [timeEnd, "timeEnd"] 1.1065 + , [trace, "trace"] 1.1066 + , [dir, "dir"] 1.1067 + , [assert, "assert"] 1.1068 +] 1.1069 + 1.1070 +for (var i = 0; i < functions.length; i++) { 1.1071 + var tuple = functions[i] 1.1072 + var f = tuple[0] 1.1073 + var name = tuple[1] 1.1074 + 1.1075 + if (!console[name]) { 1.1076 + console[name] = f 1.1077 + } 1.1078 +} 1.1079 + 1.1080 +module.exports = console 1.1081 + 1.1082 +function log() {} 1.1083 + 1.1084 +function info() { 1.1085 + console.log.apply(console, arguments) 1.1086 +} 1.1087 + 1.1088 +function warn() { 1.1089 + console.log.apply(console, arguments) 1.1090 +} 1.1091 + 1.1092 +function error() { 1.1093 + console.warn.apply(console, arguments) 1.1094 +} 1.1095 + 1.1096 +function time(label) { 1.1097 + times[label] = Date.now() 1.1098 +} 1.1099 + 1.1100 +function timeEnd(label) { 1.1101 + var time = times[label] 1.1102 + if (!time) { 1.1103 + throw new Error("No such label: " + label) 1.1104 + } 1.1105 + 1.1106 + var duration = Date.now() - time 1.1107 + console.log(label + ": " + duration + "ms") 1.1108 +} 1.1109 + 1.1110 +function trace() { 1.1111 + var err = new Error() 1.1112 + err.name = "Trace" 1.1113 + err.message = util.format.apply(null, arguments) 1.1114 + console.error(err.stack) 1.1115 +} 1.1116 + 1.1117 +function dir(object) { 1.1118 + console.log(util.inspect(object) + "\n") 1.1119 +} 1.1120 + 1.1121 +function assert(expression) { 1.1122 + if (!expression) { 1.1123 + var arr = slice.call(arguments, 1) 1.1124 + assert.ok(false, util.format.apply(null, arr)) 1.1125 + } 1.1126 +} 1.1127 + 1.1128 +})(window) 1.1129 +},{"util":8,"assert":9}],10:[function(require,module,exports){ 1.1130 +(function(){/* 1.1131 + * Lexical analysis and token construction. 1.1132 + */ 1.1133 + 1.1134 +"use strict"; 1.1135 + 1.1136 +var _ = require("underscore"); 1.1137 +var events = require("events"); 1.1138 +var reg = require("./reg.js"); 1.1139 +var state = require("./state.js").state; 1.1140 + 1.1141 +// Some of these token types are from JavaScript Parser API 1.1142 +// while others are specific to JSHint parser. 1.1143 +// JS Parser API: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API 1.1144 + 1.1145 +var Token = { 1.1146 + Identifier: 1, 1.1147 + Punctuator: 2, 1.1148 + NumericLiteral: 3, 1.1149 + StringLiteral: 4, 1.1150 + Comment: 5, 1.1151 + Keyword: 6, 1.1152 + NullLiteral: 7, 1.1153 + BooleanLiteral: 8, 1.1154 + RegExp: 9 1.1155 +}; 1.1156 + 1.1157 +// This is auto generated from the unicode tables. 1.1158 +// The tables are at: 1.1159 +// http://www.fileformat.info/info/unicode/category/Lu/list.htm 1.1160 +// http://www.fileformat.info/info/unicode/category/Ll/list.htm 1.1161 +// http://www.fileformat.info/info/unicode/category/Lt/list.htm 1.1162 +// http://www.fileformat.info/info/unicode/category/Lm/list.htm 1.1163 +// http://www.fileformat.info/info/unicode/category/Lo/list.htm 1.1164 +// http://www.fileformat.info/info/unicode/category/Nl/list.htm 1.1165 + 1.1166 +var unicodeLetterTable = [ 1.1167 + 170, 170, 181, 181, 186, 186, 192, 214, 1.1168 + 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 1.1169 + 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 1.1170 + 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1.1171 + 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1.1172 + 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1.1173 + 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1.1174 + 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 1.1175 + 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2308, 2361, 1.1176 + 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 1.1177 + 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 1.1178 + 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 1.1179 + 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 1.1180 + 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 1.1181 + 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 1.1182 + 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 1.1183 + 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 1.1184 + 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 1.1185 + 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 1.1186 + 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 1.1187 + 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 1.1188 + 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 1.1189 + 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 1.1190 + 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 1.1191 + 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 1.1192 + 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 1.1193 + 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 1.1194 + 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 1.1195 + 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 1.1196 + 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 1.1197 + 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 1.1198 + 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 1.1199 + 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4304, 4346, 1.1200 + 4348, 4348, 4352, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 1.1201 + 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 1.1202 + 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 1.1203 + 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 1.1204 + 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 1.1205 + 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 1.1206 + 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 1.1207 + 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 1.1208 + 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 1.1209 + 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7104, 7141, 1.1210 + 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 1.1211 + 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 1.1212 + 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 1.1213 + 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 1.1214 + 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 1.1215 + 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 1.1216 + 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 1.1217 + 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 1.1218 + 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 1.1219 + 11360, 11492, 11499, 11502, 11520, 11557, 11568, 11621, 1.1220 + 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 1.1221 + 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 1.1222 + 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 1.1223 + 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 1.1224 + 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 1.1225 + 12593, 12686, 12704, 12730, 12784, 12799, 13312, 13312, 1.1226 + 19893, 19893, 19968, 19968, 40907, 40907, 40960, 42124, 1.1227 + 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 1.1228 + 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 1.1229 + 42786, 42888, 42891, 42894, 42896, 42897, 42912, 42921, 1.1230 + 43002, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 1.1231 + 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 1.1232 + 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 1.1233 + 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 1.1234 + 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 1.1235 + 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 1.1236 + 43739, 43741, 43777, 43782, 43785, 43790, 43793, 43798, 1.1237 + 43808, 43814, 43816, 43822, 43968, 44002, 44032, 44032, 1.1238 + 55203, 55203, 55216, 55238, 55243, 55291, 63744, 64045, 1.1239 + 64048, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 1.1240 + 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 1.1241 + 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 1.1242 + 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 1.1243 + 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 1.1244 + 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 1.1245 + 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 1.1246 + 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 1.1247 + 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66334, 1.1248 + 66352, 66378, 66432, 66461, 66464, 66499, 66504, 66511, 1.1249 + 66513, 66517, 66560, 66717, 67584, 67589, 67592, 67592, 1.1250 + 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 1.1251 + 67840, 67861, 67872, 67897, 68096, 68096, 68112, 68115, 1.1252 + 68117, 68119, 68121, 68147, 68192, 68220, 68352, 68405, 1.1253 + 68416, 68437, 68448, 68466, 68608, 68680, 69635, 69687, 1.1254 + 69763, 69807, 73728, 74606, 74752, 74850, 77824, 78894, 1.1255 + 92160, 92728, 110592, 110593, 119808, 119892, 119894, 119964, 1.1256 + 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 1.1257 + 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 1.1258 + 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 1.1259 + 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 1.1260 + 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 1.1261 + 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 1.1262 + 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 1.1263 + 131072, 131072, 173782, 173782, 173824, 173824, 177972, 177972, 1.1264 + 177984, 177984, 178205, 178205, 194560, 195101 1.1265 +]; 1.1266 + 1.1267 +var identifierStartTable = []; 1.1268 + 1.1269 +for (var i = 0; i < 128; i++) { 1.1270 + identifierStartTable[i] = 1.1271 + i === 36 || // $ 1.1272 + i >= 65 && i <= 90 || // A-Z 1.1273 + i === 95 || // _ 1.1274 + i >= 97 && i <= 122; // a-z 1.1275 +} 1.1276 + 1.1277 +var identifierPartTable = []; 1.1278 + 1.1279 +for (var i = 0; i < 128; i++) { 1.1280 + identifierPartTable[i] = 1.1281 + identifierStartTable[i] || // $, _, A-Z, a-z 1.1282 + i >= 48 && i <= 57; // 0-9 1.1283 +} 1.1284 + 1.1285 +// Object that handles postponed lexing verifications that checks the parsed 1.1286 +// environment state. 1.1287 + 1.1288 +function asyncTrigger() { 1.1289 + var _checks = []; 1.1290 + 1.1291 + return { 1.1292 + push: function (fn) { 1.1293 + _checks.push(fn); 1.1294 + }, 1.1295 + 1.1296 + check: function () { 1.1297 + for (var check in _checks) { 1.1298 + _checks[check](); 1.1299 + } 1.1300 + 1.1301 + _checks.splice(0, _checks.length); 1.1302 + } 1.1303 + }; 1.1304 +} 1.1305 + 1.1306 +/* 1.1307 + * Lexer for JSHint. 1.1308 + * 1.1309 + * This object does a char-by-char scan of the provided source code 1.1310 + * and produces a sequence of tokens. 1.1311 + * 1.1312 + * var lex = new Lexer("var i = 0;"); 1.1313 + * lex.start(); 1.1314 + * lex.token(); // returns the next token 1.1315 + * 1.1316 + * You have to use the token() method to move the lexer forward 1.1317 + * but you don't have to use its return value to get tokens. In addition 1.1318 + * to token() method returning the next token, the Lexer object also 1.1319 + * emits events. 1.1320 + * 1.1321 + * lex.on("Identifier", function (data) { 1.1322 + * if (data.name.indexOf("_") >= 0) { 1.1323 + * // Produce a warning. 1.1324 + * } 1.1325 + * }); 1.1326 + * 1.1327 + * Note that the token() method returns tokens in a JSLint-compatible 1.1328 + * format while the event emitter uses a slightly modified version of 1.1329 + * Mozilla's JavaScript Parser API. Eventually, we will move away from 1.1330 + * JSLint format. 1.1331 + */ 1.1332 +function Lexer(source) { 1.1333 + var lines = source; 1.1334 + 1.1335 + if (typeof lines === "string") { 1.1336 + lines = lines 1.1337 + .replace(/\r\n/g, "\n") 1.1338 + .replace(/\r/g, "\n") 1.1339 + .split("\n"); 1.1340 + } 1.1341 + 1.1342 + // If the first line is a shebang (#!), make it a blank and move on. 1.1343 + // Shebangs are used by Node scripts. 1.1344 + 1.1345 + if (lines[0] && lines[0].substr(0, 2) === "#!") { 1.1346 + lines[0] = ""; 1.1347 + } 1.1348 + 1.1349 + this.emitter = new events.EventEmitter(); 1.1350 + this.source = source; 1.1351 + this.lines = lines; 1.1352 + this.prereg = true; 1.1353 + 1.1354 + this.line = 0; 1.1355 + this.char = 1; 1.1356 + this.from = 1; 1.1357 + this.input = ""; 1.1358 + 1.1359 + for (var i = 0; i < state.option.indent; i += 1) { 1.1360 + state.tab += " "; 1.1361 + } 1.1362 +} 1.1363 + 1.1364 +Lexer.prototype = { 1.1365 + _lines: [], 1.1366 + 1.1367 + get lines() { 1.1368 + this._lines = state.lines; 1.1369 + return this._lines; 1.1370 + }, 1.1371 + 1.1372 + set lines(val) { 1.1373 + this._lines = val; 1.1374 + state.lines = this._lines; 1.1375 + }, 1.1376 + 1.1377 + /* 1.1378 + * Return the next i character without actually moving the 1.1379 + * char pointer. 1.1380 + */ 1.1381 + peek: function (i) { 1.1382 + return this.input.charAt(i || 0); 1.1383 + }, 1.1384 + 1.1385 + /* 1.1386 + * Move the char pointer forward i times. 1.1387 + */ 1.1388 + skip: function (i) { 1.1389 + i = i || 1; 1.1390 + this.char += i; 1.1391 + this.input = this.input.slice(i); 1.1392 + }, 1.1393 + 1.1394 + /* 1.1395 + * Subscribe to a token event. The API for this method is similar 1.1396 + * Underscore.js i.e. you can subscribe to multiple events with 1.1397 + * one call: 1.1398 + * 1.1399 + * lex.on("Identifier Number", function (data) { 1.1400 + * // ... 1.1401 + * }); 1.1402 + */ 1.1403 + on: function (names, listener) { 1.1404 + names.split(" ").forEach(function (name) { 1.1405 + this.emitter.on(name, listener); 1.1406 + }.bind(this)); 1.1407 + }, 1.1408 + 1.1409 + /* 1.1410 + * Trigger a token event. All arguments will be passed to each 1.1411 + * listener. 1.1412 + */ 1.1413 + trigger: function () { 1.1414 + this.emitter.emit.apply(this.emitter, Array.prototype.slice.call(arguments)); 1.1415 + }, 1.1416 + 1.1417 + /* 1.1418 + * Postpone a token event. the checking condition is set as 1.1419 + * last parameter, and the trigger function is called in a 1.1420 + * stored callback. To be later called using the check() function 1.1421 + * by the parser. This avoids parser's peek() to give the lexer 1.1422 + * a false context. 1.1423 + */ 1.1424 + triggerAsync: function (type, args, checks, fn) { 1.1425 + checks.push(function () { 1.1426 + if (fn()) { 1.1427 + this.trigger(type, args); 1.1428 + } 1.1429 + }.bind(this)); 1.1430 + }, 1.1431 + 1.1432 + /* 1.1433 + * Extract a punctuator out of the next sequence of characters 1.1434 + * or return 'null' if its not possible. 1.1435 + * 1.1436 + * This method's implementation was heavily influenced by the 1.1437 + * scanPunctuator function in the Esprima parser's source code. 1.1438 + */ 1.1439 + scanPunctuator: function () { 1.1440 + var ch1 = this.peek(); 1.1441 + var ch2, ch3, ch4; 1.1442 + 1.1443 + switch (ch1) { 1.1444 + // Most common single-character punctuators 1.1445 + case ".": 1.1446 + if ((/^[0-9]$/).test(this.peek(1))) { 1.1447 + return null; 1.1448 + } 1.1449 + if (this.peek(1) === "." && this.peek(2) === ".") { 1.1450 + return { 1.1451 + type: Token.Punctuator, 1.1452 + value: "..." 1.1453 + }; 1.1454 + } 1.1455 + /* falls through */ 1.1456 + case "(": 1.1457 + case ")": 1.1458 + case ";": 1.1459 + case ",": 1.1460 + case "{": 1.1461 + case "}": 1.1462 + case "[": 1.1463 + case "]": 1.1464 + case ":": 1.1465 + case "~": 1.1466 + case "?": 1.1467 + return { 1.1468 + type: Token.Punctuator, 1.1469 + value: ch1 1.1470 + }; 1.1471 + 1.1472 + // A pound sign (for Node shebangs) 1.1473 + case "#": 1.1474 + return { 1.1475 + type: Token.Punctuator, 1.1476 + value: ch1 1.1477 + }; 1.1478 + 1.1479 + // We're at the end of input 1.1480 + case "": 1.1481 + return null; 1.1482 + } 1.1483 + 1.1484 + // Peek more characters 1.1485 + 1.1486 + ch2 = this.peek(1); 1.1487 + ch3 = this.peek(2); 1.1488 + ch4 = this.peek(3); 1.1489 + 1.1490 + // 4-character punctuator: >>>= 1.1491 + 1.1492 + if (ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=") { 1.1493 + return { 1.1494 + type: Token.Punctuator, 1.1495 + value: ">>>=" 1.1496 + }; 1.1497 + } 1.1498 + 1.1499 + // 3-character punctuators: === !== >>> <<= >>= 1.1500 + 1.1501 + if (ch1 === "=" && ch2 === "=" && ch3 === "=") { 1.1502 + return { 1.1503 + type: Token.Punctuator, 1.1504 + value: "===" 1.1505 + }; 1.1506 + } 1.1507 + 1.1508 + if (ch1 === "!" && ch2 === "=" && ch3 === "=") { 1.1509 + return { 1.1510 + type: Token.Punctuator, 1.1511 + value: "!==" 1.1512 + }; 1.1513 + } 1.1514 + 1.1515 + if (ch1 === ">" && ch2 === ">" && ch3 === ">") { 1.1516 + return { 1.1517 + type: Token.Punctuator, 1.1518 + value: ">>>" 1.1519 + }; 1.1520 + } 1.1521 + 1.1522 + if (ch1 === "<" && ch2 === "<" && ch3 === "=") { 1.1523 + return { 1.1524 + type: Token.Punctuator, 1.1525 + value: "<<=" 1.1526 + }; 1.1527 + } 1.1528 + 1.1529 + if (ch1 === ">" && ch2 === ">" && ch3 === "=") { 1.1530 + return { 1.1531 + type: Token.Punctuator, 1.1532 + value: ">>=" 1.1533 + }; 1.1534 + } 1.1535 + 1.1536 + // Fat arrow punctuator 1.1537 + if (ch1 === "=" && ch2 === ">") { 1.1538 + return { 1.1539 + type: Token.Punctuator, 1.1540 + value: ch1 + ch2 1.1541 + }; 1.1542 + } 1.1543 + 1.1544 + // 2-character punctuators: <= >= == != ++ -- << >> && || 1.1545 + // += -= *= %= &= |= ^= (but not /=, see below) 1.1546 + if (ch1 === ch2 && ("+-<>&|".indexOf(ch1) >= 0)) { 1.1547 + return { 1.1548 + type: Token.Punctuator, 1.1549 + value: ch1 + ch2 1.1550 + }; 1.1551 + } 1.1552 + 1.1553 + if ("<>=!+-*%&|^".indexOf(ch1) >= 0) { 1.1554 + if (ch2 === "=") { 1.1555 + return { 1.1556 + type: Token.Punctuator, 1.1557 + value: ch1 + ch2 1.1558 + }; 1.1559 + } 1.1560 + 1.1561 + return { 1.1562 + type: Token.Punctuator, 1.1563 + value: ch1 1.1564 + }; 1.1565 + } 1.1566 + 1.1567 + // Special case: /=. We need to make sure that this is an 1.1568 + // operator and not a regular expression. 1.1569 + 1.1570 + if (ch1 === "/") { 1.1571 + if (ch2 === "=" && /\/=(?!(\S*\/[gim]?))/.test(this.input)) { 1.1572 + // /= is not a part of a regular expression, return it as a 1.1573 + // punctuator. 1.1574 + return { 1.1575 + type: Token.Punctuator, 1.1576 + value: "/=" 1.1577 + }; 1.1578 + } 1.1579 + 1.1580 + return { 1.1581 + type: Token.Punctuator, 1.1582 + value: "/" 1.1583 + }; 1.1584 + } 1.1585 + 1.1586 + return null; 1.1587 + }, 1.1588 + 1.1589 + /* 1.1590 + * Extract a comment out of the next sequence of characters and/or 1.1591 + * lines or return 'null' if its not possible. Since comments can 1.1592 + * span across multiple lines this method has to move the char 1.1593 + * pointer. 1.1594 + * 1.1595 + * In addition to normal JavaScript comments (// and /*) this method 1.1596 + * also recognizes JSHint- and JSLint-specific comments such as 1.1597 + * /*jshint, /*jslint, /*globals and so on. 1.1598 + */ 1.1599 + scanComments: function () { 1.1600 + var ch1 = this.peek(); 1.1601 + var ch2 = this.peek(1); 1.1602 + var rest = this.input.substr(2); 1.1603 + var startLine = this.line; 1.1604 + var startChar = this.char; 1.1605 + 1.1606 + // Create a comment token object and make sure it 1.1607 + // has all the data JSHint needs to work with special 1.1608 + // comments. 1.1609 + 1.1610 + function commentToken(label, body, opt) { 1.1611 + var special = ["jshint", "jslint", "members", "member", "globals", "global", "exported"]; 1.1612 + var isSpecial = false; 1.1613 + var value = label + body; 1.1614 + var commentType = "plain"; 1.1615 + opt = opt || {}; 1.1616 + 1.1617 + if (opt.isMultiline) { 1.1618 + value += "*/"; 1.1619 + } 1.1620 + 1.1621 + special.forEach(function (str) { 1.1622 + if (isSpecial) { 1.1623 + return; 1.1624 + } 1.1625 + 1.1626 + // Don't recognize any special comments other than jshint for single-line 1.1627 + // comments. This introduced many problems with legit comments. 1.1628 + if (label === "//" && str !== "jshint") { 1.1629 + return; 1.1630 + } 1.1631 + 1.1632 + if (body.substr(0, str.length) === str) { 1.1633 + isSpecial = true; 1.1634 + label = label + str; 1.1635 + body = body.substr(str.length); 1.1636 + } 1.1637 + 1.1638 + if (!isSpecial && body.charAt(0) === " " && body.substr(1, str.length) === str) { 1.1639 + isSpecial = true; 1.1640 + label = label + " " + str; 1.1641 + body = body.substr(str.length + 1); 1.1642 + } 1.1643 + 1.1644 + if (!isSpecial) { 1.1645 + return; 1.1646 + } 1.1647 + 1.1648 + switch (str) { 1.1649 + case "member": 1.1650 + commentType = "members"; 1.1651 + break; 1.1652 + case "global": 1.1653 + commentType = "globals"; 1.1654 + break; 1.1655 + default: 1.1656 + commentType = str; 1.1657 + } 1.1658 + }); 1.1659 + 1.1660 + return { 1.1661 + type: Token.Comment, 1.1662 + commentType: commentType, 1.1663 + value: value, 1.1664 + body: body, 1.1665 + isSpecial: isSpecial, 1.1666 + isMultiline: opt.isMultiline || false, 1.1667 + isMalformed: opt.isMalformed || false 1.1668 + }; 1.1669 + } 1.1670 + 1.1671 + // End of unbegun comment. Raise an error and skip that input. 1.1672 + if (ch1 === "*" && ch2 === "/") { 1.1673 + this.trigger("error", { 1.1674 + code: "E018", 1.1675 + line: startLine, 1.1676 + character: startChar 1.1677 + }); 1.1678 + 1.1679 + this.skip(2); 1.1680 + return null; 1.1681 + } 1.1682 + 1.1683 + // Comments must start either with // or /* 1.1684 + if (ch1 !== "/" || (ch2 !== "*" && ch2 !== "/")) { 1.1685 + return null; 1.1686 + } 1.1687 + 1.1688 + // One-line comment 1.1689 + if (ch2 === "/") { 1.1690 + this.skip(this.input.length); // Skip to the EOL. 1.1691 + return commentToken("//", rest); 1.1692 + } 1.1693 + 1.1694 + var body = ""; 1.1695 + 1.1696 + /* Multi-line comment */ 1.1697 + if (ch2 === "*") { 1.1698 + this.skip(2); 1.1699 + 1.1700 + while (this.peek() !== "*" || this.peek(1) !== "/") { 1.1701 + if (this.peek() === "") { // End of Line 1.1702 + body += "\n"; 1.1703 + 1.1704 + // If we hit EOF and our comment is still unclosed, 1.1705 + // trigger an error and end the comment implicitly. 1.1706 + if (!this.nextLine()) { 1.1707 + this.trigger("error", { 1.1708 + code: "E017", 1.1709 + line: startLine, 1.1710 + character: startChar 1.1711 + }); 1.1712 + 1.1713 + return commentToken("/*", body, { 1.1714 + isMultiline: true, 1.1715 + isMalformed: true 1.1716 + }); 1.1717 + } 1.1718 + } else { 1.1719 + body += this.peek(); 1.1720 + this.skip(); 1.1721 + } 1.1722 + } 1.1723 + 1.1724 + this.skip(2); 1.1725 + return commentToken("/*", body, { isMultiline: true }); 1.1726 + } 1.1727 + }, 1.1728 + 1.1729 + /* 1.1730 + * Extract a keyword out of the next sequence of characters or 1.1731 + * return 'null' if its not possible. 1.1732 + */ 1.1733 + scanKeyword: function () { 1.1734 + var result = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input); 1.1735 + var keywords = [ 1.1736 + "if", "in", "do", "var", "for", "new", 1.1737 + "try", "let", "this", "else", "case", 1.1738 + "void", "with", "enum", "while", "break", 1.1739 + "catch", "throw", "const", "yield", "class", 1.1740 + "super", "return", "typeof", "delete", 1.1741 + "switch", "export", "import", "default", 1.1742 + "finally", "extends", "function", "continue", 1.1743 + "debugger", "instanceof" 1.1744 + ]; 1.1745 + 1.1746 + if (result && keywords.indexOf(result[0]) >= 0) { 1.1747 + return { 1.1748 + type: Token.Keyword, 1.1749 + value: result[0] 1.1750 + }; 1.1751 + } 1.1752 + 1.1753 + return null; 1.1754 + }, 1.1755 + 1.1756 + /* 1.1757 + * Extract a JavaScript identifier out of the next sequence of 1.1758 + * characters or return 'null' if its not possible. In addition, 1.1759 + * to Identifier this method can also produce BooleanLiteral 1.1760 + * (true/false) and NullLiteral (null). 1.1761 + */ 1.1762 + scanIdentifier: function () { 1.1763 + var id = ""; 1.1764 + var index = 0; 1.1765 + var type, char; 1.1766 + 1.1767 + // Detects any character in the Unicode categories "Uppercase 1.1768 + // letter (Lu)", "Lowercase letter (Ll)", "Titlecase letter 1.1769 + // (Lt)", "Modifier letter (Lm)", "Other letter (Lo)", or 1.1770 + // "Letter number (Nl)". 1.1771 + // 1.1772 + // Both approach and unicodeLetterTable were borrowed from 1.1773 + // Google's Traceur. 1.1774 + 1.1775 + function isUnicodeLetter(code) { 1.1776 + for (var i = 0; i < unicodeLetterTable.length;) { 1.1777 + if (code < unicodeLetterTable[i++]) { 1.1778 + return false; 1.1779 + } 1.1780 + 1.1781 + if (code <= unicodeLetterTable[i++]) { 1.1782 + return true; 1.1783 + } 1.1784 + } 1.1785 + 1.1786 + return false; 1.1787 + } 1.1788 + 1.1789 + function isHexDigit(str) { 1.1790 + return (/^[0-9a-fA-F]$/).test(str); 1.1791 + } 1.1792 + 1.1793 + var readUnicodeEscapeSequence = function () { 1.1794 + /*jshint validthis:true */ 1.1795 + index += 1; 1.1796 + 1.1797 + if (this.peek(index) !== "u") { 1.1798 + return null; 1.1799 + } 1.1800 + 1.1801 + var ch1 = this.peek(index + 1); 1.1802 + var ch2 = this.peek(index + 2); 1.1803 + var ch3 = this.peek(index + 3); 1.1804 + var ch4 = this.peek(index + 4); 1.1805 + var code; 1.1806 + 1.1807 + if (isHexDigit(ch1) && isHexDigit(ch2) && isHexDigit(ch3) && isHexDigit(ch4)) { 1.1808 + code = parseInt(ch1 + ch2 + ch3 + ch4, 16); 1.1809 + 1.1810 + if (isUnicodeLetter(code)) { 1.1811 + index += 5; 1.1812 + return "\\u" + ch1 + ch2 + ch3 + ch4; 1.1813 + } 1.1814 + 1.1815 + return null; 1.1816 + } 1.1817 + 1.1818 + return null; 1.1819 + }.bind(this); 1.1820 + 1.1821 + var getIdentifierStart = function () { 1.1822 + /*jshint validthis:true */ 1.1823 + var chr = this.peek(index); 1.1824 + var code = chr.charCodeAt(0); 1.1825 + 1.1826 + if (code === 92) { 1.1827 + return readUnicodeEscapeSequence(); 1.1828 + } 1.1829 + 1.1830 + if (code < 128) { 1.1831 + if (identifierStartTable[code]) { 1.1832 + index += 1; 1.1833 + return chr; 1.1834 + } 1.1835 + 1.1836 + return null; 1.1837 + } 1.1838 + 1.1839 + if (isUnicodeLetter(code)) { 1.1840 + index += 1; 1.1841 + return chr; 1.1842 + } 1.1843 + 1.1844 + return null; 1.1845 + }.bind(this); 1.1846 + 1.1847 + var getIdentifierPart = function () { 1.1848 + /*jshint validthis:true */ 1.1849 + var chr = this.peek(index); 1.1850 + var code = chr.charCodeAt(0); 1.1851 + 1.1852 + if (code === 92) { 1.1853 + return readUnicodeEscapeSequence(); 1.1854 + } 1.1855 + 1.1856 + if (code < 128) { 1.1857 + if (identifierPartTable[code]) { 1.1858 + index += 1; 1.1859 + return chr; 1.1860 + } 1.1861 + 1.1862 + return null; 1.1863 + } 1.1864 + 1.1865 + if (isUnicodeLetter(code)) { 1.1866 + index += 1; 1.1867 + return chr; 1.1868 + } 1.1869 + 1.1870 + return null; 1.1871 + }.bind(this); 1.1872 + 1.1873 + char = getIdentifierStart(); 1.1874 + if (char === null) { 1.1875 + return null; 1.1876 + } 1.1877 + 1.1878 + id = char; 1.1879 + for (;;) { 1.1880 + char = getIdentifierPart(); 1.1881 + 1.1882 + if (char === null) { 1.1883 + break; 1.1884 + } 1.1885 + 1.1886 + id += char; 1.1887 + } 1.1888 + 1.1889 + switch (id) { 1.1890 + case "true": 1.1891 + case "false": 1.1892 + type = Token.BooleanLiteral; 1.1893 + break; 1.1894 + case "null": 1.1895 + type = Token.NullLiteral; 1.1896 + break; 1.1897 + default: 1.1898 + type = Token.Identifier; 1.1899 + } 1.1900 + 1.1901 + return { 1.1902 + type: type, 1.1903 + value: id 1.1904 + }; 1.1905 + }, 1.1906 + 1.1907 + /* 1.1908 + * Extract a numeric literal out of the next sequence of 1.1909 + * characters or return 'null' if its not possible. This method 1.1910 + * supports all numeric literals described in section 7.8.3 1.1911 + * of the EcmaScript 5 specification. 1.1912 + * 1.1913 + * This method's implementation was heavily influenced by the 1.1914 + * scanNumericLiteral function in the Esprima parser's source code. 1.1915 + */ 1.1916 + scanNumericLiteral: function () { 1.1917 + var index = 0; 1.1918 + var value = ""; 1.1919 + var length = this.input.length; 1.1920 + var char = this.peek(index); 1.1921 + var bad; 1.1922 + 1.1923 + function isDecimalDigit(str) { 1.1924 + return (/^[0-9]$/).test(str); 1.1925 + } 1.1926 + 1.1927 + function isOctalDigit(str) { 1.1928 + return (/^[0-7]$/).test(str); 1.1929 + } 1.1930 + 1.1931 + function isHexDigit(str) { 1.1932 + return (/^[0-9a-fA-F]$/).test(str); 1.1933 + } 1.1934 + 1.1935 + function isIdentifierStart(ch) { 1.1936 + return (ch === "$") || (ch === "_") || (ch === "\\") || 1.1937 + (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z"); 1.1938 + } 1.1939 + 1.1940 + // Numbers must start either with a decimal digit or a point. 1.1941 + 1.1942 + if (char !== "." && !isDecimalDigit(char)) { 1.1943 + return null; 1.1944 + } 1.1945 + 1.1946 + if (char !== ".") { 1.1947 + value = this.peek(index); 1.1948 + index += 1; 1.1949 + char = this.peek(index); 1.1950 + 1.1951 + if (value === "0") { 1.1952 + // Base-16 numbers. 1.1953 + if (char === "x" || char === "X") { 1.1954 + index += 1; 1.1955 + value += char; 1.1956 + 1.1957 + while (index < length) { 1.1958 + char = this.peek(index); 1.1959 + if (!isHexDigit(char)) { 1.1960 + break; 1.1961 + } 1.1962 + value += char; 1.1963 + index += 1; 1.1964 + } 1.1965 + 1.1966 + if (value.length <= 2) { // 0x 1.1967 + return { 1.1968 + type: Token.NumericLiteral, 1.1969 + value: value, 1.1970 + isMalformed: true 1.1971 + }; 1.1972 + } 1.1973 + 1.1974 + if (index < length) { 1.1975 + char = this.peek(index); 1.1976 + if (isIdentifierStart(char)) { 1.1977 + return null; 1.1978 + } 1.1979 + } 1.1980 + 1.1981 + return { 1.1982 + type: Token.NumericLiteral, 1.1983 + value: value, 1.1984 + base: 16, 1.1985 + isMalformed: false 1.1986 + }; 1.1987 + } 1.1988 + 1.1989 + // Base-8 numbers. 1.1990 + if (isOctalDigit(char)) { 1.1991 + index += 1; 1.1992 + value += char; 1.1993 + bad = false; 1.1994 + 1.1995 + while (index < length) { 1.1996 + char = this.peek(index); 1.1997 + 1.1998 + // Numbers like '019' (note the 9) are not valid octals 1.1999 + // but we still parse them and mark as malformed. 1.2000 + 1.2001 + if (isDecimalDigit(char)) { 1.2002 + bad = true; 1.2003 + } else if (!isOctalDigit(char)) { 1.2004 + break; 1.2005 + } 1.2006 + value += char; 1.2007 + index += 1; 1.2008 + } 1.2009 + 1.2010 + if (index < length) { 1.2011 + char = this.peek(index); 1.2012 + if (isIdentifierStart(char)) { 1.2013 + return null; 1.2014 + } 1.2015 + } 1.2016 + 1.2017 + return { 1.2018 + type: Token.NumericLiteral, 1.2019 + value: value, 1.2020 + base: 8, 1.2021 + isMalformed: false 1.2022 + }; 1.2023 + } 1.2024 + 1.2025 + // Decimal numbers that start with '0' such as '09' are illegal 1.2026 + // but we still parse them and return as malformed. 1.2027 + 1.2028 + if (isDecimalDigit(char)) { 1.2029 + index += 1; 1.2030 + value += char; 1.2031 + } 1.2032 + } 1.2033 + 1.2034 + while (index < length) { 1.2035 + char = this.peek(index); 1.2036 + if (!isDecimalDigit(char)) { 1.2037 + break; 1.2038 + } 1.2039 + value += char; 1.2040 + index += 1; 1.2041 + } 1.2042 + } 1.2043 + 1.2044 + // Decimal digits. 1.2045 + 1.2046 + if (char === ".") { 1.2047 + value += char; 1.2048 + index += 1; 1.2049 + 1.2050 + while (index < length) { 1.2051 + char = this.peek(index); 1.2052 + if (!isDecimalDigit(char)) { 1.2053 + break; 1.2054 + } 1.2055 + value += char; 1.2056 + index += 1; 1.2057 + } 1.2058 + } 1.2059 + 1.2060 + // Exponent part. 1.2061 + 1.2062 + if (char === "e" || char === "E") { 1.2063 + value += char; 1.2064 + index += 1; 1.2065 + char = this.peek(index); 1.2066 + 1.2067 + if (char === "+" || char === "-") { 1.2068 + value += this.peek(index); 1.2069 + index += 1; 1.2070 + } 1.2071 + 1.2072 + char = this.peek(index); 1.2073 + if (isDecimalDigit(char)) { 1.2074 + value += char; 1.2075 + index += 1; 1.2076 + 1.2077 + while (index < length) { 1.2078 + char = this.peek(index); 1.2079 + if (!isDecimalDigit(char)) { 1.2080 + break; 1.2081 + } 1.2082 + value += char; 1.2083 + index += 1; 1.2084 + } 1.2085 + } else { 1.2086 + return null; 1.2087 + } 1.2088 + } 1.2089 + 1.2090 + if (index < length) { 1.2091 + char = this.peek(index); 1.2092 + if (isIdentifierStart(char)) { 1.2093 + return null; 1.2094 + } 1.2095 + } 1.2096 + 1.2097 + return { 1.2098 + type: Token.NumericLiteral, 1.2099 + value: value, 1.2100 + base: 10, 1.2101 + isMalformed: !isFinite(value) 1.2102 + }; 1.2103 + }, 1.2104 + 1.2105 + /* 1.2106 + * Extract a string out of the next sequence of characters and/or 1.2107 + * lines or return 'null' if its not possible. Since strings can 1.2108 + * span across multiple lines this method has to move the char 1.2109 + * pointer. 1.2110 + * 1.2111 + * This method recognizes pseudo-multiline JavaScript strings: 1.2112 + * 1.2113 + * var str = "hello\ 1.2114 + * world"; 1.2115 + */ 1.2116 + scanStringLiteral: function (checks) { 1.2117 + /*jshint loopfunc:true */ 1.2118 + var quote = this.peek(); 1.2119 + 1.2120 + // String must start with a quote. 1.2121 + if (quote !== "\"" && quote !== "'") { 1.2122 + return null; 1.2123 + } 1.2124 + 1.2125 + // In JSON strings must always use double quotes. 1.2126 + this.triggerAsync("warning", { 1.2127 + code: "W108", 1.2128 + line: this.line, 1.2129 + character: this.char // +1? 1.2130 + }, checks, function () { return state.jsonMode && quote !== "\""; }); 1.2131 + 1.2132 + var value = ""; 1.2133 + var startLine = this.line; 1.2134 + var startChar = this.char; 1.2135 + var allowNewLine = false; 1.2136 + 1.2137 + this.skip(); 1.2138 + 1.2139 + while (this.peek() !== quote) { 1.2140 + while (this.peek() === "") { // End Of Line 1.2141 + 1.2142 + // If an EOL is not preceded by a backslash, show a warning 1.2143 + // and proceed like it was a legit multi-line string where 1.2144 + // author simply forgot to escape the newline symbol. 1.2145 + // 1.2146 + // Another approach is to implicitly close a string on EOL 1.2147 + // but it generates too many false positives. 1.2148 + 1.2149 + if (!allowNewLine) { 1.2150 + this.trigger("warning", { 1.2151 + code: "W112", 1.2152 + line: this.line, 1.2153 + character: this.char 1.2154 + }); 1.2155 + } else { 1.2156 + allowNewLine = false; 1.2157 + 1.2158 + // Otherwise show a warning if multistr option was not set. 1.2159 + // For JSON, show warning no matter what. 1.2160 + 1.2161 + this.triggerAsync("warning", { 1.2162 + code: "W043", 1.2163 + line: this.line, 1.2164 + character: this.char 1.2165 + }, checks, function () { return !state.option.multistr; }); 1.2166 + 1.2167 + this.triggerAsync("warning", { 1.2168 + code: "W042", 1.2169 + line: this.line, 1.2170 + character: this.char 1.2171 + }, checks, function () { return state.jsonMode && state.option.multistr; }); 1.2172 + } 1.2173 + 1.2174 + // If we get an EOF inside of an unclosed string, show an 1.2175 + // error and implicitly close it at the EOF point. 1.2176 + 1.2177 + if (!this.nextLine()) { 1.2178 + this.trigger("error", { 1.2179 + code: "E029", 1.2180 + line: startLine, 1.2181 + character: startChar 1.2182 + }); 1.2183 + 1.2184 + return { 1.2185 + type: Token.StringLiteral, 1.2186 + value: value, 1.2187 + isUnclosed: true, 1.2188 + quote: quote 1.2189 + }; 1.2190 + } 1.2191 + } 1.2192 + 1.2193 + allowNewLine = false; 1.2194 + var char = this.peek(); 1.2195 + var jump = 1; // A length of a jump, after we're done 1.2196 + // parsing this character. 1.2197 + 1.2198 + if (char < " ") { 1.2199 + // Warn about a control character in a string. 1.2200 + this.trigger("warning", { 1.2201 + code: "W113", 1.2202 + line: this.line, 1.2203 + character: this.char, 1.2204 + data: [ "<non-printable>" ] 1.2205 + }); 1.2206 + } 1.2207 + 1.2208 + // Special treatment for some escaped characters. 1.2209 + 1.2210 + if (char === "\\") { 1.2211 + this.skip(); 1.2212 + char = this.peek(); 1.2213 + 1.2214 + switch (char) { 1.2215 + case "'": 1.2216 + this.triggerAsync("warning", { 1.2217 + code: "W114", 1.2218 + line: this.line, 1.2219 + character: this.char, 1.2220 + data: [ "\\'" ] 1.2221 + }, checks, function () {return state.jsonMode; }); 1.2222 + break; 1.2223 + case "b": 1.2224 + char = "\b"; 1.2225 + break; 1.2226 + case "f": 1.2227 + char = "\f"; 1.2228 + break; 1.2229 + case "n": 1.2230 + char = "\n"; 1.2231 + break; 1.2232 + case "r": 1.2233 + char = "\r"; 1.2234 + break; 1.2235 + case "t": 1.2236 + char = "\t"; 1.2237 + break; 1.2238 + case "0": 1.2239 + char = "\0"; 1.2240 + 1.2241 + // Octal literals fail in strict mode. 1.2242 + // Check if the number is between 00 and 07. 1.2243 + var n = parseInt(this.peek(1), 10); 1.2244 + this.triggerAsync("warning", { 1.2245 + code: "W115", 1.2246 + line: this.line, 1.2247 + character: this.char 1.2248 + }, checks, 1.2249 + function () { return n >= 0 && n <= 7 && state.directive["use strict"]; }); 1.2250 + break; 1.2251 + case "u": 1.2252 + char = String.fromCharCode(parseInt(this.input.substr(1, 4), 16)); 1.2253 + jump = 5; 1.2254 + break; 1.2255 + case "v": 1.2256 + this.triggerAsync("warning", { 1.2257 + code: "W114", 1.2258 + line: this.line, 1.2259 + character: this.char, 1.2260 + data: [ "\\v" ] 1.2261 + }, checks, function () { return state.jsonMode; }); 1.2262 + 1.2263 + char = "\v"; 1.2264 + break; 1.2265 + case "x": 1.2266 + var x = parseInt(this.input.substr(1, 2), 16); 1.2267 + 1.2268 + this.triggerAsync("warning", { 1.2269 + code: "W114", 1.2270 + line: this.line, 1.2271 + character: this.char, 1.2272 + data: [ "\\x-" ] 1.2273 + }, checks, function () { return state.jsonMode; }); 1.2274 + 1.2275 + char = String.fromCharCode(x); 1.2276 + jump = 3; 1.2277 + break; 1.2278 + case "\\": 1.2279 + case "\"": 1.2280 + case "/": 1.2281 + break; 1.2282 + case "": 1.2283 + allowNewLine = true; 1.2284 + char = ""; 1.2285 + break; 1.2286 + case "!": 1.2287 + if (value.slice(value.length - 2) === "<") { 1.2288 + break; 1.2289 + } 1.2290 + 1.2291 + /*falls through */ 1.2292 + default: 1.2293 + // Weird escaping. 1.2294 + this.trigger("warning", { 1.2295 + code: "W044", 1.2296 + line: this.line, 1.2297 + character: this.char 1.2298 + }); 1.2299 + } 1.2300 + } 1.2301 + 1.2302 + value += char; 1.2303 + this.skip(jump); 1.2304 + } 1.2305 + 1.2306 + this.skip(); 1.2307 + return { 1.2308 + type: Token.StringLiteral, 1.2309 + value: value, 1.2310 + isUnclosed: false, 1.2311 + quote: quote 1.2312 + }; 1.2313 + }, 1.2314 + 1.2315 + /* 1.2316 + * Extract a regular expression out of the next sequence of 1.2317 + * characters and/or lines or return 'null' if its not possible. 1.2318 + * 1.2319 + * This method is platform dependent: it accepts almost any 1.2320 + * regular expression values but then tries to compile and run 1.2321 + * them using system's RegExp object. This means that there are 1.2322 + * rare edge cases where one JavaScript engine complains about 1.2323 + * your regular expression while others don't. 1.2324 + */ 1.2325 + scanRegExp: function () { 1.2326 + var index = 0; 1.2327 + var length = this.input.length; 1.2328 + var char = this.peek(); 1.2329 + var value = char; 1.2330 + var body = ""; 1.2331 + var flags = []; 1.2332 + var malformed = false; 1.2333 + var isCharSet = false; 1.2334 + var terminated; 1.2335 + 1.2336 + var scanUnexpectedChars = function () { 1.2337 + // Unexpected control character 1.2338 + if (char < " ") { 1.2339 + malformed = true; 1.2340 + this.trigger("warning", { 1.2341 + code: "W048", 1.2342 + line: this.line, 1.2343 + character: this.char 1.2344 + }); 1.2345 + } 1.2346 + 1.2347 + // Unexpected escaped character 1.2348 + if (char === "<") { 1.2349 + malformed = true; 1.2350 + this.trigger("warning", { 1.2351 + code: "W049", 1.2352 + line: this.line, 1.2353 + character: this.char, 1.2354 + data: [ char ] 1.2355 + }); 1.2356 + } 1.2357 + }.bind(this); 1.2358 + 1.2359 + // Regular expressions must start with '/' 1.2360 + if (!this.prereg || char !== "/") { 1.2361 + return null; 1.2362 + } 1.2363 + 1.2364 + index += 1; 1.2365 + terminated = false; 1.2366 + 1.2367 + // Try to get everything in between slashes. A couple of 1.2368 + // cases aside (see scanUnexpectedChars) we don't really 1.2369 + // care whether the resulting expression is valid or not. 1.2370 + // We will check that later using the RegExp object. 1.2371 + 1.2372 + while (index < length) { 1.2373 + char = this.peek(index); 1.2374 + value += char; 1.2375 + body += char; 1.2376 + 1.2377 + if (isCharSet) { 1.2378 + if (char === "]") { 1.2379 + if (this.peek(index - 1) !== "\\" || this.peek(index - 2) === "\\") { 1.2380 + isCharSet = false; 1.2381 + } 1.2382 + } 1.2383 + 1.2384 + if (char === "\\") { 1.2385 + index += 1; 1.2386 + char = this.peek(index); 1.2387 + body += char; 1.2388 + value += char; 1.2389 + 1.2390 + scanUnexpectedChars(); 1.2391 + } 1.2392 + 1.2393 + index += 1; 1.2394 + continue; 1.2395 + } 1.2396 + 1.2397 + if (char === "\\") { 1.2398 + index += 1; 1.2399 + char = this.peek(index); 1.2400 + body += char; 1.2401 + value += char; 1.2402 + 1.2403 + scanUnexpectedChars(); 1.2404 + 1.2405 + if (char === "/") { 1.2406 + index += 1; 1.2407 + continue; 1.2408 + } 1.2409 + 1.2410 + if (char === "[") { 1.2411 + index += 1; 1.2412 + continue; 1.2413 + } 1.2414 + } 1.2415 + 1.2416 + if (char === "[") { 1.2417 + isCharSet = true; 1.2418 + index += 1; 1.2419 + continue; 1.2420 + } 1.2421 + 1.2422 + if (char === "/") { 1.2423 + body = body.substr(0, body.length - 1); 1.2424 + terminated = true; 1.2425 + index += 1; 1.2426 + break; 1.2427 + } 1.2428 + 1.2429 + index += 1; 1.2430 + } 1.2431 + 1.2432 + // A regular expression that was never closed is an 1.2433 + // error from which we cannot recover. 1.2434 + 1.2435 + if (!terminated) { 1.2436 + this.trigger("error", { 1.2437 + code: "E015", 1.2438 + line: this.line, 1.2439 + character: this.from 1.2440 + }); 1.2441 + 1.2442 + return void this.trigger("fatal", { 1.2443 + line: this.line, 1.2444 + from: this.from 1.2445 + }); 1.2446 + } 1.2447 + 1.2448 + // Parse flags (if any). 1.2449 + 1.2450 + while (index < length) { 1.2451 + char = this.peek(index); 1.2452 + if (!/[gim]/.test(char)) { 1.2453 + break; 1.2454 + } 1.2455 + flags.push(char); 1.2456 + value += char; 1.2457 + index += 1; 1.2458 + } 1.2459 + 1.2460 + // Check regular expression for correctness. 1.2461 + 1.2462 + try { 1.2463 + new RegExp(body, flags.join("")); 1.2464 + } catch (err) { 1.2465 + malformed = true; 1.2466 + this.trigger("error", { 1.2467 + code: "E016", 1.2468 + line: this.line, 1.2469 + character: this.char, 1.2470 + data: [ err.message ] // Platform dependent! 1.2471 + }); 1.2472 + } 1.2473 + 1.2474 + return { 1.2475 + type: Token.RegExp, 1.2476 + value: value, 1.2477 + flags: flags, 1.2478 + isMalformed: malformed 1.2479 + }; 1.2480 + }, 1.2481 + 1.2482 + /* 1.2483 + * Scan for any occurence of mixed tabs and spaces. If smarttabs option 1.2484 + * is on, ignore tabs followed by spaces. 1.2485 + * 1.2486 + * Tabs followed by one space followed by a block comment are allowed. 1.2487 + */ 1.2488 + scanMixedSpacesAndTabs: function () { 1.2489 + var at, match; 1.2490 + 1.2491 + if (state.option.smarttabs) { 1.2492 + // Negative look-behind for "//" 1.2493 + match = this.input.match(/(\/\/|^\s?\*)? \t/); 1.2494 + at = match && !match[1] ? 0 : -1; 1.2495 + } else { 1.2496 + at = this.input.search(/ \t|\t [^\*]/); 1.2497 + } 1.2498 + 1.2499 + return at; 1.2500 + }, 1.2501 + 1.2502 + /* 1.2503 + * Scan for characters that get silently deleted by one or more browsers. 1.2504 + */ 1.2505 + scanUnsafeChars: function () { 1.2506 + return this.input.search(reg.unsafeChars); 1.2507 + }, 1.2508 + 1.2509 + /* 1.2510 + * Produce the next raw token or return 'null' if no tokens can be matched. 1.2511 + * This method skips over all space characters. 1.2512 + */ 1.2513 + next: function (checks) { 1.2514 + this.from = this.char; 1.2515 + 1.2516 + // Move to the next non-space character. 1.2517 + var start; 1.2518 + if (/\s/.test(this.peek())) { 1.2519 + start = this.char; 1.2520 + 1.2521 + while (/\s/.test(this.peek())) { 1.2522 + this.from += 1; 1.2523 + this.skip(); 1.2524 + } 1.2525 + 1.2526 + if (this.peek() === "") { // EOL 1.2527 + if (!/^\s*$/.test(this.lines[this.line - 1]) && state.option.trailing) { 1.2528 + this.trigger("warning", { code: "W102", line: this.line, character: start }); 1.2529 + } 1.2530 + } 1.2531 + } 1.2532 + 1.2533 + // Methods that work with multi-line structures and move the 1.2534 + // character pointer. 1.2535 + 1.2536 + var match = this.scanComments() || 1.2537 + this.scanStringLiteral(checks); 1.2538 + 1.2539 + if (match) { 1.2540 + return match; 1.2541 + } 1.2542 + 1.2543 + // Methods that don't move the character pointer. 1.2544 + 1.2545 + match = 1.2546 + this.scanRegExp() || 1.2547 + this.scanPunctuator() || 1.2548 + this.scanKeyword() || 1.2549 + this.scanIdentifier() || 1.2550 + this.scanNumericLiteral(); 1.2551 + 1.2552 + if (match) { 1.2553 + this.skip(match.value.length); 1.2554 + return match; 1.2555 + } 1.2556 + 1.2557 + // No token could be matched, give up. 1.2558 + 1.2559 + return null; 1.2560 + }, 1.2561 + 1.2562 + /* 1.2563 + * Switch to the next line and reset all char pointers. Once 1.2564 + * switched, this method also checks for mixed spaces and tabs 1.2565 + * and other minor warnings. 1.2566 + */ 1.2567 + nextLine: function () { 1.2568 + var char; 1.2569 + 1.2570 + if (this.line >= this.lines.length) { 1.2571 + return false; 1.2572 + } 1.2573 + 1.2574 + this.input = this.lines[this.line]; 1.2575 + this.line += 1; 1.2576 + this.char = 1; 1.2577 + this.from = 1; 1.2578 + 1.2579 + char = this.scanMixedSpacesAndTabs(); 1.2580 + if (char >= 0) { 1.2581 + this.trigger("warning", { code: "W099", line: this.line, character: char + 1 }); 1.2582 + } 1.2583 + 1.2584 + this.input = this.input.replace(/\t/g, state.tab); 1.2585 + char = this.scanUnsafeChars(); 1.2586 + 1.2587 + if (char >= 0) { 1.2588 + this.trigger("warning", { code: "W100", line: this.line, character: char }); 1.2589 + } 1.2590 + 1.2591 + // If there is a limit on line length, warn when lines get too 1.2592 + // long. 1.2593 + 1.2594 + if (state.option.maxlen && state.option.maxlen < this.input.length) { 1.2595 + this.trigger("warning", { code: "W101", line: this.line, character: this.input.length }); 1.2596 + } 1.2597 + 1.2598 + return true; 1.2599 + }, 1.2600 + 1.2601 + /* 1.2602 + * This is simply a synonym for nextLine() method with a friendlier 1.2603 + * public name. 1.2604 + */ 1.2605 + start: function () { 1.2606 + this.nextLine(); 1.2607 + }, 1.2608 + 1.2609 + /* 1.2610 + * Produce the next token. This function is called by advance() to get 1.2611 + * the next token. It retuns a token in a JSLint-compatible format. 1.2612 + */ 1.2613 + token: function () { 1.2614 + /*jshint loopfunc:true */ 1.2615 + var checks = asyncTrigger(); 1.2616 + var token; 1.2617 + 1.2618 + 1.2619 + function isReserved(token, isProperty) { 1.2620 + if (!token.reserved) { 1.2621 + return false; 1.2622 + } 1.2623 + 1.2624 + if (token.meta && token.meta.isFutureReservedWord) { 1.2625 + // ES3 FutureReservedWord in an ES5 environment. 1.2626 + if (state.option.inES5(true) && !token.meta.es5) { 1.2627 + return false; 1.2628 + } 1.2629 + 1.2630 + // Some ES5 FutureReservedWord identifiers are active only 1.2631 + // within a strict mode environment. 1.2632 + if (token.meta.strictOnly) { 1.2633 + if (!state.option.strict && !state.directive["use strict"]) { 1.2634 + return false; 1.2635 + } 1.2636 + } 1.2637 + 1.2638 + if (isProperty) { 1.2639 + return false; 1.2640 + } 1.2641 + } 1.2642 + 1.2643 + return true; 1.2644 + } 1.2645 + 1.2646 + // Produce a token object. 1.2647 + var create = function (type, value, isProperty) { 1.2648 + /*jshint validthis:true */ 1.2649 + var obj; 1.2650 + 1.2651 + if (type !== "(endline)" && type !== "(end)") { 1.2652 + this.prereg = false; 1.2653 + } 1.2654 + 1.2655 + if (type === "(punctuator)") { 1.2656 + switch (value) { 1.2657 + case ".": 1.2658 + case ")": 1.2659 + case "~": 1.2660 + case "#": 1.2661 + case "]": 1.2662 + this.prereg = false; 1.2663 + break; 1.2664 + default: 1.2665 + this.prereg = true; 1.2666 + } 1.2667 + 1.2668 + obj = Object.create(state.syntax[value] || state.syntax["(error)"]); 1.2669 + } 1.2670 + 1.2671 + if (type === "(identifier)") { 1.2672 + if (value === "return" || value === "case" || value === "typeof") { 1.2673 + this.prereg = true; 1.2674 + } 1.2675 + 1.2676 + if (_.has(state.syntax, value)) { 1.2677 + obj = Object.create(state.syntax[value] || state.syntax["(error)"]); 1.2678 + 1.2679 + // If this can't be a reserved keyword, reset the object. 1.2680 + if (!isReserved(obj, isProperty && type === "(identifier)")) { 1.2681 + obj = null; 1.2682 + } 1.2683 + } 1.2684 + } 1.2685 + 1.2686 + if (!obj) { 1.2687 + obj = Object.create(state.syntax[type]); 1.2688 + } 1.2689 + 1.2690 + obj.identifier = (type === "(identifier)"); 1.2691 + obj.type = obj.type || type; 1.2692 + obj.value = value; 1.2693 + obj.line = this.line; 1.2694 + obj.character = this.char; 1.2695 + obj.from = this.from; 1.2696 + 1.2697 + if (isProperty && obj.identifier) { 1.2698 + obj.isProperty = isProperty; 1.2699 + } 1.2700 + 1.2701 + obj.check = checks.check; 1.2702 + 1.2703 + return obj; 1.2704 + }.bind(this); 1.2705 + 1.2706 + for (;;) { 1.2707 + if (!this.input.length) { 1.2708 + return create(this.nextLine() ? "(endline)" : "(end)", ""); 1.2709 + } 1.2710 + 1.2711 + token = this.next(checks); 1.2712 + 1.2713 + if (!token) { 1.2714 + if (this.input.length) { 1.2715 + // Unexpected character. 1.2716 + this.trigger("error", { 1.2717 + code: "E024", 1.2718 + line: this.line, 1.2719 + character: this.char, 1.2720 + data: [ this.peek() ] 1.2721 + }); 1.2722 + 1.2723 + this.input = ""; 1.2724 + } 1.2725 + 1.2726 + continue; 1.2727 + } 1.2728 + 1.2729 + switch (token.type) { 1.2730 + case Token.StringLiteral: 1.2731 + this.triggerAsync("String", { 1.2732 + line: this.line, 1.2733 + char: this.char, 1.2734 + from: this.from, 1.2735 + value: token.value, 1.2736 + quote: token.quote 1.2737 + }, checks, function () { return true; }); 1.2738 + 1.2739 + return create("(string)", token.value); 1.2740 + case Token.Identifier: 1.2741 + this.trigger("Identifier", { 1.2742 + line: this.line, 1.2743 + char: this.char, 1.2744 + from: this.form, 1.2745 + name: token.value, 1.2746 + isProperty: state.tokens.curr.id === "." 1.2747 + }); 1.2748 + 1.2749 + /* falls through */ 1.2750 + case Token.Keyword: 1.2751 + case Token.NullLiteral: 1.2752 + case Token.BooleanLiteral: 1.2753 + return create("(identifier)", token.value, state.tokens.curr.id === "."); 1.2754 + 1.2755 + case Token.NumericLiteral: 1.2756 + if (token.isMalformed) { 1.2757 + this.trigger("warning", { 1.2758 + code: "W045", 1.2759 + line: this.line, 1.2760 + character: this.char, 1.2761 + data: [ token.value ] 1.2762 + }); 1.2763 + } 1.2764 + 1.2765 + this.triggerAsync("warning", { 1.2766 + code: "W114", 1.2767 + line: this.line, 1.2768 + character: this.char, 1.2769 + data: [ "0x-" ] 1.2770 + }, checks, function () { return token.base === 16 && state.jsonMode; }); 1.2771 + 1.2772 + this.triggerAsync("warning", { 1.2773 + code: "W115", 1.2774 + line: this.line, 1.2775 + character: this.char 1.2776 + }, checks, function () { 1.2777 + return state.directive["use strict"] && token.base === 8; 1.2778 + }); 1.2779 + 1.2780 + this.trigger("Number", { 1.2781 + line: this.line, 1.2782 + char: this.char, 1.2783 + from: this.from, 1.2784 + value: token.value, 1.2785 + base: token.base, 1.2786 + isMalformed: token.malformed 1.2787 + }); 1.2788 + 1.2789 + return create("(number)", token.value); 1.2790 + 1.2791 + case Token.RegExp: 1.2792 + return create("(regexp)", token.value); 1.2793 + 1.2794 + case Token.Comment: 1.2795 + state.tokens.curr.comment = true; 1.2796 + 1.2797 + if (token.isSpecial) { 1.2798 + return { 1.2799 + value: token.value, 1.2800 + body: token.body, 1.2801 + type: token.commentType, 1.2802 + isSpecial: token.isSpecial, 1.2803 + line: this.line, 1.2804 + character: this.char, 1.2805 + from: this.from 1.2806 + }; 1.2807 + } 1.2808 + 1.2809 + break; 1.2810 + 1.2811 + case "": 1.2812 + break; 1.2813 + 1.2814 + default: 1.2815 + return create("(punctuator)", token.value); 1.2816 + } 1.2817 + } 1.2818 + } 1.2819 +}; 1.2820 + 1.2821 +exports.Lexer = Lexer; 1.2822 + 1.2823 +})() 1.2824 +},{"events":2,"./reg.js":6,"./state.js":4,"underscore":11}],"jshint":[function(require,module,exports){ 1.2825 +module.exports=require('E/GbHF'); 1.2826 +},{}],"E/GbHF":[function(require,module,exports){ 1.2827 +(function(){/*! 1.2828 + * JSHint, by JSHint Community. 1.2829 + * 1.2830 + * This file (and this file only) is licensed under the same slightly modified 1.2831 + * MIT license that JSLint is. It stops evil-doers everywhere: 1.2832 + * 1.2833 + * Copyright (c) 2002 Douglas Crockford (www.JSLint.com) 1.2834 + * 1.2835 + * Permission is hereby granted, free of charge, to any person obtaining 1.2836 + * a copy of this software and associated documentation files (the "Software"), 1.2837 + * to deal in the Software without restriction, including without limitation 1.2838 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1.2839 + * and/or sell copies of the Software, and to permit persons to whom 1.2840 + * the Software is furnished to do so, subject to the following conditions: 1.2841 + * 1.2842 + * The above copyright notice and this permission notice shall be included 1.2843 + * in all copies or substantial portions of the Software. 1.2844 + * 1.2845 + * The Software shall be used for Good, not Evil. 1.2846 + * 1.2847 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.2848 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.2849 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1.2850 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1.2851 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1.2852 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 1.2853 + * DEALINGS IN THE SOFTWARE. 1.2854 + * 1.2855 + */ 1.2856 + 1.2857 +/*jshint quotmark:double */ 1.2858 +/*global console:true */ 1.2859 +/*exported console */ 1.2860 + 1.2861 +var _ = require("underscore"); 1.2862 +var events = require("events"); 1.2863 +var vars = require("../shared/vars.js"); 1.2864 +var messages = require("../shared/messages.js"); 1.2865 +var Lexer = require("./lex.js").Lexer; 1.2866 +var reg = require("./reg.js"); 1.2867 +var state = require("./state.js").state; 1.2868 +var style = require("./style.js"); 1.2869 + 1.2870 +// We need this module here because environments such as IE and Rhino 1.2871 +// don't necessarilly expose the 'console' API and browserify uses 1.2872 +// it to log things. It's a sad state of affair, really. 1.2873 +var console = require("console-browserify"); 1.2874 + 1.2875 +// We build the application inside a function so that we produce only a singleton 1.2876 +// variable. That function will be invoked immediately, and its return value is 1.2877 +// the JSHINT function itself. 1.2878 + 1.2879 +var JSHINT = (function () { 1.2880 + "use strict"; 1.2881 + 1.2882 + var anonname, // The guessed name for anonymous functions. 1.2883 + api, // Extension API 1.2884 + 1.2885 + // These are operators that should not be used with the ! operator. 1.2886 + bang = { 1.2887 + "<" : true, 1.2888 + "<=" : true, 1.2889 + "==" : true, 1.2890 + "===": true, 1.2891 + "!==": true, 1.2892 + "!=" : true, 1.2893 + ">" : true, 1.2894 + ">=" : true, 1.2895 + "+" : true, 1.2896 + "-" : true, 1.2897 + "*" : true, 1.2898 + "/" : true, 1.2899 + "%" : true 1.2900 + }, 1.2901 + 1.2902 + // These are the JSHint boolean options. 1.2903 + boolOptions = { 1.2904 + asi : true, // if automatic semicolon insertion should be tolerated 1.2905 + bitwise : true, // if bitwise operators should not be allowed 1.2906 + boss : true, // if advanced usage of assignments should be allowed 1.2907 + browser : true, // if the standard browser globals should be predefined 1.2908 + camelcase : true, // if identifiers should be required in camel case 1.2909 + couch : true, // if CouchDB globals should be predefined 1.2910 + curly : true, // if curly braces around all blocks should be required 1.2911 + debug : true, // if debugger statements should be allowed 1.2912 + devel : true, // if logging globals should be predefined (console, alert, etc.) 1.2913 + dojo : true, // if Dojo Toolkit globals should be predefined 1.2914 + eqeqeq : true, // if === should be required 1.2915 + eqnull : true, // if == null comparisons should be tolerated 1.2916 + es3 : true, // if ES3 syntax should be allowed 1.2917 + es5 : true, // if ES5 syntax should be allowed (is now set per default) 1.2918 + esnext : true, // if es.next specific syntax should be allowed 1.2919 + moz : true, // if mozilla specific syntax should be allowed 1.2920 + evil : true, // if eval should be allowed 1.2921 + expr : true, // if ExpressionStatement should be allowed as Programs 1.2922 + forin : true, // if for in statements must filter 1.2923 + funcscope : true, // if only function scope should be used for scope tests 1.2924 + gcl : true, // if JSHint should be compatible with Google Closure Linter 1.2925 + globalstrict: true, // if global "use strict"; should be allowed (also enables 'strict') 1.2926 + immed : true, // if immediate invocations must be wrapped in parens 1.2927 + iterator : true, // if the `__iterator__` property should be allowed 1.2928 + jquery : true, // if jQuery globals should be predefined 1.2929 + lastsemic : true, // if semicolons may be ommitted for the trailing 1.2930 + // statements inside of a one-line blocks. 1.2931 + laxbreak : true, // if line breaks should not be checked 1.2932 + laxcomma : true, // if line breaks should not be checked around commas 1.2933 + loopfunc : true, // if functions should be allowed to be defined within 1.2934 + // loops 1.2935 + mootools : true, // if MooTools globals should be predefined 1.2936 + multistr : true, // allow multiline strings 1.2937 + newcap : true, // if constructor names must be capitalized 1.2938 + noarg : true, // if arguments.caller and arguments.callee should be 1.2939 + // disallowed 1.2940 + node : true, // if the Node.js environment globals should be 1.2941 + // predefined 1.2942 + noempty : true, // if empty blocks should be disallowed 1.2943 + nonew : true, // if using `new` for side-effects should be disallowed 1.2944 + nonstandard : true, // if non-standard (but widely adopted) globals should 1.2945 + // be predefined 1.2946 + nomen : true, // if names should be checked 1.2947 + onevar : true, // if only one var statement per function should be 1.2948 + // allowed 1.2949 + passfail : true, // if the scan should stop on first error 1.2950 + phantom : true, // if PhantomJS symbols should be allowed 1.2951 + plusplus : true, // if increment/decrement should not be allowed 1.2952 + proto : true, // if the `__proto__` property should be allowed 1.2953 + prototypejs : true, // if Prototype and Scriptaculous globals should be 1.2954 + // predefined 1.2955 + rhino : true, // if the Rhino environment globals should be predefined 1.2956 + undef : true, // if variables should be declared before used 1.2957 + scripturl : true, // if script-targeted URLs should be tolerated 1.2958 + shadow : true, // if variable shadowing should be tolerated 1.2959 + smarttabs : true, // if smarttabs should be tolerated 1.2960 + // (http://www.emacswiki.org/emacs/SmartTabs) 1.2961 + strict : true, // require the "use strict"; pragma 1.2962 + sub : true, // if all forms of subscript notation are tolerated 1.2963 + supernew : true, // if `new function () { ... };` and `new Object;` 1.2964 + // should be tolerated 1.2965 + trailing : true, // if trailing whitespace rules apply 1.2966 + validthis : true, // if 'this' inside a non-constructor function is valid. 1.2967 + // This is a function scoped option only. 1.2968 + withstmt : true, // if with statements should be allowed 1.2969 + white : true, // if strict whitespace rules apply 1.2970 + worker : true, // if Web Worker script symbols should be allowed 1.2971 + wsh : true, // if the Windows Scripting Host environment globals 1.2972 + // should be predefined 1.2973 + yui : true, // YUI variables should be predefined 1.2974 + 1.2975 + // Obsolete options 1.2976 + onecase : true, // if one case switch statements should be allowed 1.2977 + regexp : true, // if the . should not be allowed in regexp literals 1.2978 + regexdash : true // if unescaped first/last dash (-) inside brackets 1.2979 + // should be tolerated 1.2980 + }, 1.2981 + 1.2982 + // These are the JSHint options that can take any value 1.2983 + // (we use this object to detect invalid options) 1.2984 + valOptions = { 1.2985 + maxlen : false, 1.2986 + indent : false, 1.2987 + maxerr : false, 1.2988 + predef : false, 1.2989 + quotmark : false, //'single'|'double'|true 1.2990 + scope : false, 1.2991 + maxstatements: false, // {int} max statements per function 1.2992 + maxdepth : false, // {int} max nested block depth per function 1.2993 + maxparams : false, // {int} max params per function 1.2994 + maxcomplexity: false, // {int} max cyclomatic complexity per function 1.2995 + unused : true, // warn if variables are unused. Available options: 1.2996 + // false - don't check for unused variables 1.2997 + // true - "vars" + check last function param 1.2998 + // "vars" - skip checking unused function params 1.2999 + // "strict" - "vars" + check all function params 1.3000 + latedef : false // warn if the variable is used before its definition 1.3001 + // false - don't emit any warnings 1.3002 + // true - warn if any variable is used before its definition 1.3003 + // "nofunc" - warn for any variable but function declarations 1.3004 + }, 1.3005 + 1.3006 + // These are JSHint boolean options which are shared with JSLint 1.3007 + // where the definition in JSHint is opposite JSLint 1.3008 + invertedOptions = { 1.3009 + bitwise : true, 1.3010 + forin : true, 1.3011 + newcap : true, 1.3012 + nomen : true, 1.3013 + plusplus: true, 1.3014 + regexp : true, 1.3015 + undef : true, 1.3016 + white : true, 1.3017 + 1.3018 + // Inverted and renamed, use JSHint name here 1.3019 + eqeqeq : true, 1.3020 + onevar : true, 1.3021 + strict : true 1.3022 + }, 1.3023 + 1.3024 + // These are JSHint boolean options which are shared with JSLint 1.3025 + // where the name has been changed but the effect is unchanged 1.3026 + renamedOptions = { 1.3027 + eqeq : "eqeqeq", 1.3028 + vars : "onevar", 1.3029 + windows: "wsh", 1.3030 + sloppy : "strict" 1.3031 + }, 1.3032 + 1.3033 + declared, // Globals that were declared using /*global ... */ syntax. 1.3034 + exported, // Variables that are used outside of the current file. 1.3035 + 1.3036 + functionicity = [ 1.3037 + "closure", "exception", "global", "label", 1.3038 + "outer", "unused", "var" 1.3039 + ], 1.3040 + 1.3041 + funct, // The current function 1.3042 + functions, // All of the functions 1.3043 + 1.3044 + global, // The global scope 1.3045 + implied, // Implied globals 1.3046 + inblock, 1.3047 + indent, 1.3048 + lookahead, 1.3049 + lex, 1.3050 + member, 1.3051 + membersOnly, 1.3052 + noreach, 1.3053 + predefined, // Global variables defined by option 1.3054 + 1.3055 + scope, // The current scope 1.3056 + stack, 1.3057 + unuseds, 1.3058 + urls, 1.3059 + warnings, 1.3060 + 1.3061 + extraModules = [], 1.3062 + emitter = new events.EventEmitter(); 1.3063 + 1.3064 + function checkOption(name, t) { 1.3065 + name = name.trim(); 1.3066 + 1.3067 + if (/^[+-]W\d{3}$/g.test(name)) { 1.3068 + return true; 1.3069 + } 1.3070 + 1.3071 + if (valOptions[name] === undefined && boolOptions[name] === undefined) { 1.3072 + if (t.type !== "jslint") { 1.3073 + error("E001", t, name); 1.3074 + return false; 1.3075 + } 1.3076 + } 1.3077 + 1.3078 + return true; 1.3079 + } 1.3080 + 1.3081 + function isString(obj) { 1.3082 + return Object.prototype.toString.call(obj) === "[object String]"; 1.3083 + } 1.3084 + 1.3085 + function isIdentifier(tkn, value) { 1.3086 + if (!tkn) 1.3087 + return false; 1.3088 + 1.3089 + if (!tkn.identifier || tkn.value !== value) 1.3090 + return false; 1.3091 + 1.3092 + return true; 1.3093 + } 1.3094 + 1.3095 + function isReserved(token) { 1.3096 + if (!token.reserved) { 1.3097 + return false; 1.3098 + } 1.3099 + 1.3100 + if (token.meta && token.meta.isFutureReservedWord) { 1.3101 + // ES3 FutureReservedWord in an ES5 environment. 1.3102 + if (state.option.inES5(true) && !token.meta.es5) { 1.3103 + return false; 1.3104 + } 1.3105 + 1.3106 + // Some ES5 FutureReservedWord identifiers are active only 1.3107 + // within a strict mode environment. 1.3108 + if (token.meta.strictOnly) { 1.3109 + if (!state.option.strict && !state.directive["use strict"]) { 1.3110 + return false; 1.3111 + } 1.3112 + } 1.3113 + 1.3114 + if (token.isProperty) { 1.3115 + return false; 1.3116 + } 1.3117 + } 1.3118 + 1.3119 + return true; 1.3120 + } 1.3121 + 1.3122 + function supplant(str, data) { 1.3123 + return str.replace(/\{([^{}]*)\}/g, function (a, b) { 1.3124 + var r = data[b]; 1.3125 + return typeof r === "string" || typeof r === "number" ? r : a; 1.3126 + }); 1.3127 + } 1.3128 + 1.3129 + function combine(t, o) { 1.3130 + var n; 1.3131 + for (n in o) { 1.3132 + if (_.has(o, n) && !_.has(JSHINT.blacklist, n)) { 1.3133 + t[n] = o[n]; 1.3134 + } 1.3135 + } 1.3136 + } 1.3137 + 1.3138 + function updatePredefined() { 1.3139 + Object.keys(JSHINT.blacklist).forEach(function (key) { 1.3140 + delete predefined[key]; 1.3141 + }); 1.3142 + } 1.3143 + 1.3144 + function assume() { 1.3145 + if (state.option.es5) { 1.3146 + warning("I003"); 1.3147 + } 1.3148 + if (state.option.couch) { 1.3149 + combine(predefined, vars.couch); 1.3150 + } 1.3151 + 1.3152 + if (state.option.rhino) { 1.3153 + combine(predefined, vars.rhino); 1.3154 + } 1.3155 + 1.3156 + if (state.option.phantom) { 1.3157 + combine(predefined, vars.phantom); 1.3158 + } 1.3159 + 1.3160 + if (state.option.prototypejs) { 1.3161 + combine(predefined, vars.prototypejs); 1.3162 + } 1.3163 + 1.3164 + if (state.option.node) { 1.3165 + combine(predefined, vars.node); 1.3166 + } 1.3167 + 1.3168 + if (state.option.devel) { 1.3169 + combine(predefined, vars.devel); 1.3170 + } 1.3171 + 1.3172 + if (state.option.dojo) { 1.3173 + combine(predefined, vars.dojo); 1.3174 + } 1.3175 + 1.3176 + if (state.option.browser) { 1.3177 + combine(predefined, vars.browser); 1.3178 + } 1.3179 + 1.3180 + if (state.option.nonstandard) { 1.3181 + combine(predefined, vars.nonstandard); 1.3182 + } 1.3183 + 1.3184 + if (state.option.jquery) { 1.3185 + combine(predefined, vars.jquery); 1.3186 + } 1.3187 + 1.3188 + if (state.option.mootools) { 1.3189 + combine(predefined, vars.mootools); 1.3190 + } 1.3191 + 1.3192 + if (state.option.worker) { 1.3193 + combine(predefined, vars.worker); 1.3194 + } 1.3195 + 1.3196 + if (state.option.wsh) { 1.3197 + combine(predefined, vars.wsh); 1.3198 + } 1.3199 + 1.3200 + if (state.option.globalstrict && state.option.strict !== false) { 1.3201 + state.option.strict = true; 1.3202 + } 1.3203 + 1.3204 + if (state.option.yui) { 1.3205 + combine(predefined, vars.yui); 1.3206 + } 1.3207 + 1.3208 + // Let's assume that chronologically ES3 < ES5 < ES6/ESNext < Moz 1.3209 + 1.3210 + state.option.inMoz = function (strict) { 1.3211 + if (strict) { 1.3212 + return state.option.moz && !state.option.esnext; 1.3213 + } 1.3214 + return state.option.moz; 1.3215 + }; 1.3216 + 1.3217 + state.option.inESNext = function (strict) { 1.3218 + if (strict) { 1.3219 + return !state.option.moz && state.option.esnext; 1.3220 + } 1.3221 + return state.option.moz || state.option.esnext; 1.3222 + }; 1.3223 + 1.3224 + state.option.inES5 = function (/* strict */) { 1.3225 + return !state.option.es3; 1.3226 + }; 1.3227 + 1.3228 + state.option.inES3 = function (strict) { 1.3229 + if (strict) { 1.3230 + return !state.option.moz && !state.option.esnext && state.option.es3; 1.3231 + } 1.3232 + return state.option.es3; 1.3233 + }; 1.3234 + } 1.3235 + 1.3236 + // Produce an error warning. 1.3237 + function quit(code, line, chr) { 1.3238 + var percentage = Math.floor((line / state.lines.length) * 100); 1.3239 + var message = messages.errors[code].desc; 1.3240 + 1.3241 + throw { 1.3242 + name: "JSHintError", 1.3243 + line: line, 1.3244 + character: chr, 1.3245 + message: message + " (" + percentage + "% scanned).", 1.3246 + raw: message 1.3247 + }; 1.3248 + } 1.3249 + 1.3250 + function isundef(scope, code, token, a) { 1.3251 + return JSHINT.undefs.push([scope, code, token, a]); 1.3252 + } 1.3253 + 1.3254 + function warning(code, t, a, b, c, d) { 1.3255 + var ch, l, w, msg; 1.3256 + 1.3257 + if (/^W\d{3}$/.test(code)) { 1.3258 + if (state.ignored[code]) 1.3259 + return; 1.3260 + 1.3261 + msg = messages.warnings[code]; 1.3262 + } else if (/E\d{3}/.test(code)) { 1.3263 + msg = messages.errors[code]; 1.3264 + } else if (/I\d{3}/.test(code)) { 1.3265 + msg = messages.info[code]; 1.3266 + } 1.3267 + 1.3268 + t = t || state.tokens.next; 1.3269 + if (t.id === "(end)") { // `~ 1.3270 + t = state.tokens.curr; 1.3271 + } 1.3272 + 1.3273 + l = t.line || 0; 1.3274 + ch = t.from || 0; 1.3275 + 1.3276 + w = { 1.3277 + id: "(error)", 1.3278 + raw: msg.desc, 1.3279 + code: msg.code, 1.3280 + evidence: state.lines[l - 1] || "", 1.3281 + line: l, 1.3282 + character: ch, 1.3283 + scope: JSHINT.scope, 1.3284 + a: a, 1.3285 + b: b, 1.3286 + c: c, 1.3287 + d: d 1.3288 + }; 1.3289 + 1.3290 + w.reason = supplant(msg.desc, w); 1.3291 + JSHINT.errors.push(w); 1.3292 + 1.3293 + if (state.option.passfail) { 1.3294 + quit("E042", l, ch); 1.3295 + } 1.3296 + 1.3297 + warnings += 1; 1.3298 + if (warnings >= state.option.maxerr) { 1.3299 + quit("E043", l, ch); 1.3300 + } 1.3301 + 1.3302 + return w; 1.3303 + } 1.3304 + 1.3305 + function warningAt(m, l, ch, a, b, c, d) { 1.3306 + return warning(m, { 1.3307 + line: l, 1.3308 + from: ch 1.3309 + }, a, b, c, d); 1.3310 + } 1.3311 + 1.3312 + function error(m, t, a, b, c, d) { 1.3313 + warning(m, t, a, b, c, d); 1.3314 + } 1.3315 + 1.3316 + function errorAt(m, l, ch, a, b, c, d) { 1.3317 + return error(m, { 1.3318 + line: l, 1.3319 + from: ch 1.3320 + }, a, b, c, d); 1.3321 + } 1.3322 + 1.3323 + // Tracking of "internal" scripts, like eval containing a static string 1.3324 + function addInternalSrc(elem, src) { 1.3325 + var i; 1.3326 + i = { 1.3327 + id: "(internal)", 1.3328 + elem: elem, 1.3329 + value: src 1.3330 + }; 1.3331 + JSHINT.internals.push(i); 1.3332 + return i; 1.3333 + } 1.3334 + 1.3335 + function addlabel(t, type, tkn, islet) { 1.3336 + // Define t in the current function in the current scope. 1.3337 + if (type === "exception") { 1.3338 + if (_.has(funct["(context)"], t)) { 1.3339 + if (funct[t] !== true && !state.option.node) { 1.3340 + warning("W002", state.tokens.next, t); 1.3341 + } 1.3342 + } 1.3343 + } 1.3344 + 1.3345 + if (_.has(funct, t) && !funct["(global)"]) { 1.3346 + if (funct[t] === true) { 1.3347 + if (state.option.latedef) { 1.3348 + if ((state.option.latedef === true && _.contains([funct[t], type], "unction")) || 1.3349 + !_.contains([funct[t], type], "unction")) { 1.3350 + warning("W003", state.tokens.next, t); 1.3351 + } 1.3352 + } 1.3353 + } else { 1.3354 + if (!state.option.shadow && type !== "exception" || 1.3355 + (funct["(blockscope)"].getlabel(t))) { 1.3356 + warning("W004", state.tokens.next, t); 1.3357 + } 1.3358 + } 1.3359 + } 1.3360 + 1.3361 + // a double definition of a let variable in same block throws a TypeError 1.3362 + //if (funct["(blockscope)"] && funct["(blockscope)"].current.has(t)) { 1.3363 + // error("E044", state.tokens.next, t); 1.3364 + //} 1.3365 + 1.3366 + // if the identifier is from a let, adds it only to the current blockscope 1.3367 + if (islet) { 1.3368 + funct["(blockscope)"].current.add(t, type, state.tokens.curr); 1.3369 + } else { 1.3370 + 1.3371 + funct[t] = type; 1.3372 + 1.3373 + if (tkn) { 1.3374 + funct["(tokens)"][t] = tkn; 1.3375 + } 1.3376 + 1.3377 + if (funct["(global)"]) { 1.3378 + global[t] = funct; 1.3379 + if (_.has(implied, t)) { 1.3380 + if (state.option.latedef) { 1.3381 + if ((state.option.latedef === true && _.contains([funct[t], type], "unction")) || 1.3382 + !_.contains([funct[t], type], "unction")) { 1.3383 + warning("W003", state.tokens.next, t); 1.3384 + } 1.3385 + } 1.3386 + 1.3387 + delete implied[t]; 1.3388 + } 1.3389 + } else { 1.3390 + scope[t] = funct; 1.3391 + } 1.3392 + } 1.3393 + } 1.3394 + 1.3395 + function doOption() { 1.3396 + var nt = state.tokens.next; 1.3397 + var body = nt.body.split(",").map(function (s) { return s.trim(); }); 1.3398 + var predef = {}; 1.3399 + 1.3400 + if (nt.type === "globals") { 1.3401 + body.forEach(function (g) { 1.3402 + g = g.split(":"); 1.3403 + var key = g[0]; 1.3404 + var val = g[1]; 1.3405 + 1.3406 + if (key.charAt(0) === "-") { 1.3407 + key = key.slice(1); 1.3408 + val = false; 1.3409 + 1.3410 + JSHINT.blacklist[key] = key; 1.3411 + updatePredefined(); 1.3412 + } else { 1.3413 + predef[key] = (val === "true"); 1.3414 + } 1.3415 + }); 1.3416 + 1.3417 + combine(predefined, predef); 1.3418 + 1.3419 + for (var key in predef) { 1.3420 + if (_.has(predef, key)) { 1.3421 + declared[key] = nt; 1.3422 + } 1.3423 + } 1.3424 + } 1.3425 + 1.3426 + if (nt.type === "exported") { 1.3427 + body.forEach(function (e) { 1.3428 + exported[e] = true; 1.3429 + }); 1.3430 + } 1.3431 + 1.3432 + if (nt.type === "members") { 1.3433 + membersOnly = membersOnly || {}; 1.3434 + 1.3435 + body.forEach(function (m) { 1.3436 + var ch1 = m.charAt(0); 1.3437 + var ch2 = m.charAt(m.length - 1); 1.3438 + 1.3439 + if (ch1 === ch2 && (ch1 === "\"" || ch1 === "'")) { 1.3440 + m = m 1.3441 + .substr(1, m.length - 2) 1.3442 + .replace("\\b", "\b") 1.3443 + .replace("\\t", "\t") 1.3444 + .replace("\\n", "\n") 1.3445 + .replace("\\v", "\v") 1.3446 + .replace("\\f", "\f") 1.3447 + .replace("\\r", "\r") 1.3448 + .replace("\\\\", "\\") 1.3449 + .replace("\\\"", "\""); 1.3450 + } 1.3451 + 1.3452 + membersOnly[m] = false; 1.3453 + }); 1.3454 + } 1.3455 + 1.3456 + var numvals = [ 1.3457 + "maxstatements", 1.3458 + "maxparams", 1.3459 + "maxdepth", 1.3460 + "maxcomplexity", 1.3461 + "maxerr", 1.3462 + "maxlen", 1.3463 + "indent" 1.3464 + ]; 1.3465 + 1.3466 + if (nt.type === "jshint" || nt.type === "jslint") { 1.3467 + body.forEach(function (g) { 1.3468 + g = g.split(":"); 1.3469 + var key = (g[0] || "").trim(); 1.3470 + var val = (g[1] || "").trim(); 1.3471 + 1.3472 + if (!checkOption(key, nt)) { 1.3473 + return; 1.3474 + } 1.3475 + 1.3476 + if (numvals.indexOf(key) >= 0) { 1.3477 + 1.3478 + // GH988 - numeric options can be disabled by setting them to `false` 1.3479 + if (val !== "false") { 1.3480 + val = +val; 1.3481 + 1.3482 + if (typeof val !== "number" || !isFinite(val) || val <= 0 || Math.floor(val) !== val) { 1.3483 + error("E032", nt, g[1].trim()); 1.3484 + return; 1.3485 + } 1.3486 + 1.3487 + if (key === "indent") { 1.3488 + state.option["(explicitIndent)"] = true; 1.3489 + } 1.3490 + state.option[key] = val; 1.3491 + } else { 1.3492 + if (key === "indent") { 1.3493 + state.option["(explicitIndent)"] = false; 1.3494 + } else { 1.3495 + state.option[key] = false; 1.3496 + } 1.3497 + } 1.3498 + 1.3499 + return; 1.3500 + } 1.3501 + 1.3502 + if (key === "validthis") { 1.3503 + // `validthis` is valid only within a function scope. 1.3504 + if (funct["(global)"]) { 1.3505 + error("E009"); 1.3506 + } else { 1.3507 + if (val === "true" || val === "false") { 1.3508 + state.option.validthis = (val === "true"); 1.3509 + } else { 1.3510 + error("E002", nt); 1.3511 + } 1.3512 + } 1.3513 + return; 1.3514 + } 1.3515 + 1.3516 + if (key === "quotmark") { 1.3517 + switch (val) { 1.3518 + case "true": 1.3519 + case "false": 1.3520 + state.option.quotmark = (val === "true"); 1.3521 + break; 1.3522 + case "double": 1.3523 + case "single": 1.3524 + state.option.quotmark = val; 1.3525 + break; 1.3526 + default: 1.3527 + error("E002", nt); 1.3528 + } 1.3529 + return; 1.3530 + } 1.3531 + 1.3532 + if (key === "unused") { 1.3533 + switch (val) { 1.3534 + case "true": 1.3535 + state.option.unused = true; 1.3536 + break; 1.3537 + case "false": 1.3538 + state.option.unused = false; 1.3539 + break; 1.3540 + case "vars": 1.3541 + case "strict": 1.3542 + state.option.unused = val; 1.3543 + break; 1.3544 + default: 1.3545 + error("E002", nt); 1.3546 + } 1.3547 + return; 1.3548 + } 1.3549 + 1.3550 + if (key === "latedef") { 1.3551 + switch (val) { 1.3552 + case "true": 1.3553 + state.option.latedef = true; 1.3554 + break; 1.3555 + case "false": 1.3556 + state.option.latedef = false; 1.3557 + break; 1.3558 + case "nofunc": 1.3559 + state.option.latedef = "nofunc"; 1.3560 + break; 1.3561 + default: 1.3562 + error("E002", nt); 1.3563 + } 1.3564 + return; 1.3565 + } 1.3566 + 1.3567 + var match = /^([+-])(W\d{3})$/g.exec(key); 1.3568 + if (match) { 1.3569 + // ignore for -W..., unignore for +W... 1.3570 + state.ignored[match[2]] = (match[1] === "-"); 1.3571 + return; 1.3572 + } 1.3573 + 1.3574 + var tn; 1.3575 + if (val === "true" || val === "false") { 1.3576 + if (nt.type === "jslint") { 1.3577 + tn = renamedOptions[key] || key; 1.3578 + state.option[tn] = (val === "true"); 1.3579 + 1.3580 + if (invertedOptions[tn] !== undefined) { 1.3581 + state.option[tn] = !state.option[tn]; 1.3582 + } 1.3583 + } else { 1.3584 + state.option[key] = (val === "true"); 1.3585 + } 1.3586 + 1.3587 + if (key === "newcap") { 1.3588 + state.option["(explicitNewcap)"] = true; 1.3589 + } 1.3590 + return; 1.3591 + } 1.3592 + 1.3593 + error("E002", nt); 1.3594 + }); 1.3595 + 1.3596 + assume(); 1.3597 + } 1.3598 + } 1.3599 + 1.3600 + // We need a peek function. If it has an argument, it peeks that much farther 1.3601 + // ahead. It is used to distinguish 1.3602 + // for ( var i in ... 1.3603 + // from 1.3604 + // for ( var i = ... 1.3605 + 1.3606 + function peek(p) { 1.3607 + var i = p || 0, j = 0, t; 1.3608 + 1.3609 + while (j <= i) { 1.3610 + t = lookahead[j]; 1.3611 + if (!t) { 1.3612 + t = lookahead[j] = lex.token(); 1.3613 + } 1.3614 + j += 1; 1.3615 + } 1.3616 + return t; 1.3617 + } 1.3618 + 1.3619 + // Produce the next token. It looks for programming errors. 1.3620 + 1.3621 + function advance(id, t) { 1.3622 + switch (state.tokens.curr.id) { 1.3623 + case "(number)": 1.3624 + if (state.tokens.next.id === ".") { 1.3625 + warning("W005", state.tokens.curr); 1.3626 + } 1.3627 + break; 1.3628 + case "-": 1.3629 + if (state.tokens.next.id === "-" || state.tokens.next.id === "--") { 1.3630 + warning("W006"); 1.3631 + } 1.3632 + break; 1.3633 + case "+": 1.3634 + if (state.tokens.next.id === "+" || state.tokens.next.id === "++") { 1.3635 + warning("W007"); 1.3636 + } 1.3637 + break; 1.3638 + } 1.3639 + 1.3640 + if (state.tokens.curr.type === "(string)" || state.tokens.curr.identifier) { 1.3641 + anonname = state.tokens.curr.value; 1.3642 + } 1.3643 + 1.3644 + if (id && state.tokens.next.id !== id) { 1.3645 + if (t) { 1.3646 + if (state.tokens.next.id === "(end)") { 1.3647 + error("E019", t, t.id); 1.3648 + } else { 1.3649 + error("E020", state.tokens.next, id, t.id, t.line, state.tokens.next.value); 1.3650 + } 1.3651 + } else if (state.tokens.next.type !== "(identifier)" || state.tokens.next.value !== id) { 1.3652 + warning("W116", state.tokens.next, id, state.tokens.next.value); 1.3653 + } 1.3654 + } 1.3655 + 1.3656 + state.tokens.prev = state.tokens.curr; 1.3657 + state.tokens.curr = state.tokens.next; 1.3658 + for (;;) { 1.3659 + state.tokens.next = lookahead.shift() || lex.token(); 1.3660 + 1.3661 + if (!state.tokens.next) { // No more tokens left, give up 1.3662 + quit("E041", state.tokens.curr.line); 1.3663 + } 1.3664 + 1.3665 + if (state.tokens.next.id === "(end)" || state.tokens.next.id === "(error)") { 1.3666 + return; 1.3667 + } 1.3668 + 1.3669 + if (state.tokens.next.check) { 1.3670 + state.tokens.next.check(); 1.3671 + } 1.3672 + 1.3673 + if (state.tokens.next.isSpecial) { 1.3674 + doOption(); 1.3675 + } else { 1.3676 + if (state.tokens.next.id !== "(endline)") { 1.3677 + break; 1.3678 + } 1.3679 + } 1.3680 + } 1.3681 + } 1.3682 + 1.3683 + // This is the heart of JSHINT, the Pratt parser. In addition to parsing, it 1.3684 + // is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is 1.3685 + // like .nud except that it is only used on the first token of a statement. 1.3686 + // Having .fud makes it much easier to define statement-oriented languages like 1.3687 + // JavaScript. I retained Pratt's nomenclature. 1.3688 + 1.3689 + // .nud Null denotation 1.3690 + // .fud First null denotation 1.3691 + // .led Left denotation 1.3692 + // lbp Left binding power 1.3693 + // rbp Right binding power 1.3694 + 1.3695 + // They are elements of the parsing method called Top Down Operator Precedence. 1.3696 + 1.3697 + function expression(rbp, initial) { 1.3698 + var left, isArray = false, isObject = false, isLetExpr = false; 1.3699 + 1.3700 + // if current expression is a let expression 1.3701 + if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") { 1.3702 + if (!state.option.inMoz(true)) { 1.3703 + warning("W118", state.tokens.next, "let expressions"); 1.3704 + } 1.3705 + isLetExpr = true; 1.3706 + // create a new block scope we use only for the current expression 1.3707 + funct["(blockscope)"].stack(); 1.3708 + advance("let"); 1.3709 + advance("("); 1.3710 + state.syntax["let"].fud.call(state.syntax["let"].fud, false); 1.3711 + advance(")"); 1.3712 + } 1.3713 + 1.3714 + if (state.tokens.next.id === "(end)") 1.3715 + error("E006", state.tokens.curr); 1.3716 + 1.3717 + advance(); 1.3718 + 1.3719 + if (initial) { 1.3720 + anonname = "anonymous"; 1.3721 + funct["(verb)"] = state.tokens.curr.value; 1.3722 + } 1.3723 + 1.3724 + if (initial === true && state.tokens.curr.fud) { 1.3725 + left = state.tokens.curr.fud(); 1.3726 + } else { 1.3727 + if (state.tokens.curr.nud) { 1.3728 + left = state.tokens.curr.nud(); 1.3729 + } else { 1.3730 + error("E030", state.tokens.curr, state.tokens.curr.id); 1.3731 + } 1.3732 + 1.3733 + var end_of_expr = state.tokens.next.identifier && 1.3734 + !state.tokens.curr.led && 1.3735 + state.tokens.curr.line !== state.tokens.next.line; 1.3736 + while (rbp < state.tokens.next.lbp && !end_of_expr) { 1.3737 + isArray = state.tokens.curr.value === "Array"; 1.3738 + isObject = state.tokens.curr.value === "Object"; 1.3739 + 1.3740 + // #527, new Foo.Array(), Foo.Array(), new Foo.Object(), Foo.Object() 1.3741 + // Line breaks in IfStatement heads exist to satisfy the checkJSHint 1.3742 + // "Line too long." error. 1.3743 + if (left && (left.value || (left.first && left.first.value))) { 1.3744 + // If the left.value is not "new", or the left.first.value is a "." 1.3745 + // then safely assume that this is not "new Array()" and possibly 1.3746 + // not "new Object()"... 1.3747 + if (left.value !== "new" || 1.3748 + (left.first && left.first.value && left.first.value === ".")) { 1.3749 + isArray = false; 1.3750 + // ...In the case of Object, if the left.value and state.tokens.curr.value 1.3751 + // are not equal, then safely assume that this not "new Object()" 1.3752 + if (left.value !== state.tokens.curr.value) { 1.3753 + isObject = false; 1.3754 + } 1.3755 + } 1.3756 + } 1.3757 + 1.3758 + advance(); 1.3759 + 1.3760 + if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") { 1.3761 + warning("W009", state.tokens.curr); 1.3762 + } 1.3763 + 1.3764 + if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") { 1.3765 + warning("W010", state.tokens.curr); 1.3766 + } 1.3767 + 1.3768 + if (left && state.tokens.curr.led) { 1.3769 + left = state.tokens.curr.led(left); 1.3770 + } else { 1.3771 + error("E033", state.tokens.curr, state.tokens.curr.id); 1.3772 + } 1.3773 + } 1.3774 + } 1.3775 + if (isLetExpr) { 1.3776 + funct["(blockscope)"].unstack(); 1.3777 + } 1.3778 + return left; 1.3779 + } 1.3780 + 1.3781 + 1.3782 +// Functions for conformance of style. 1.3783 + 1.3784 + function adjacent(left, right) { 1.3785 + left = left || state.tokens.curr; 1.3786 + right = right || state.tokens.next; 1.3787 + if (state.option.white) { 1.3788 + if (left.character !== right.from && left.line === right.line) { 1.3789 + left.from += (left.character - left.from); 1.3790 + warning("W011", left, left.value); 1.3791 + } 1.3792 + } 1.3793 + } 1.3794 + 1.3795 + function nobreak(left, right) { 1.3796 + left = left || state.tokens.curr; 1.3797 + right = right || state.tokens.next; 1.3798 + if (state.option.white && (left.character !== right.from || left.line !== right.line)) { 1.3799 + warning("W012", right, right.value); 1.3800 + } 1.3801 + } 1.3802 + 1.3803 + function nospace(left, right) { 1.3804 + left = left || state.tokens.curr; 1.3805 + right = right || state.tokens.next; 1.3806 + if (state.option.white && !left.comment) { 1.3807 + if (left.line === right.line) { 1.3808 + adjacent(left, right); 1.3809 + } 1.3810 + } 1.3811 + } 1.3812 + 1.3813 + function nonadjacent(left, right) { 1.3814 + if (state.option.white) { 1.3815 + left = left || state.tokens.curr; 1.3816 + right = right || state.tokens.next; 1.3817 + 1.3818 + if (left.value === ";" && right.value === ";") { 1.3819 + return; 1.3820 + } 1.3821 + 1.3822 + if (left.line === right.line && left.character === right.from) { 1.3823 + left.from += (left.character - left.from); 1.3824 + warning("W013", left, left.value); 1.3825 + } 1.3826 + } 1.3827 + } 1.3828 + 1.3829 + function nobreaknonadjacent(left, right) { 1.3830 + left = left || state.tokens.curr; 1.3831 + right = right || state.tokens.next; 1.3832 + if (!state.option.laxbreak && left.line !== right.line) { 1.3833 + warning("W014", right, right.id); 1.3834 + } else if (state.option.white) { 1.3835 + left = left || state.tokens.curr; 1.3836 + right = right || state.tokens.next; 1.3837 + if (left.character === right.from) { 1.3838 + left.from += (left.character - left.from); 1.3839 + warning("W013", left, left.value); 1.3840 + } 1.3841 + } 1.3842 + } 1.3843 + 1.3844 + function indentation(bias) { 1.3845 + if (!state.option.white && !state.option["(explicitIndent)"]) { 1.3846 + return; 1.3847 + } 1.3848 + 1.3849 + if (state.tokens.next.id === "(end)") { 1.3850 + return; 1.3851 + } 1.3852 + 1.3853 + var i = indent + (bias || 0); 1.3854 + if (state.tokens.next.from !== i) { 1.3855 + warning("W015", state.tokens.next, state.tokens.next.value, i, state.tokens.next.from); 1.3856 + } 1.3857 + } 1.3858 + 1.3859 + function nolinebreak(t) { 1.3860 + t = t || state.tokens.curr; 1.3861 + if (t.line !== state.tokens.next.line) { 1.3862 + warning("E022", t, t.value); 1.3863 + } 1.3864 + } 1.3865 + 1.3866 + 1.3867 + function comma(opts) { 1.3868 + opts = opts || {}; 1.3869 + 1.3870 + if (!opts.peek) { 1.3871 + if (state.tokens.curr.line !== state.tokens.next.line) { 1.3872 + if (!state.option.laxcomma) { 1.3873 + if (comma.first) { 1.3874 + warning("I001"); 1.3875 + comma.first = false; 1.3876 + } 1.3877 + warning("W014", state.tokens.curr, state.tokens.next.value); 1.3878 + } 1.3879 + } else if (!state.tokens.curr.comment && 1.3880 + state.tokens.curr.character !== state.tokens.next.from && state.option.white) { 1.3881 + state.tokens.curr.from += (state.tokens.curr.character - state.tokens.curr.from); 1.3882 + warning("W011", state.tokens.curr, state.tokens.curr.value); 1.3883 + } 1.3884 + 1.3885 + advance(","); 1.3886 + } 1.3887 + 1.3888 + // TODO: This is a temporary solution to fight against false-positives in 1.3889 + // arrays and objects with trailing commas (see GH-363). The best solution 1.3890 + // would be to extract all whitespace rules out of parser. 1.3891 + 1.3892 + if (state.tokens.next.value !== "]" && state.tokens.next.value !== "}") { 1.3893 + nonadjacent(state.tokens.curr, state.tokens.next); 1.3894 + } 1.3895 + 1.3896 + if (state.tokens.next.identifier && !(opts.property && state.option.inES5())) { 1.3897 + // Keywords that cannot follow a comma operator. 1.3898 + switch (state.tokens.next.value) { 1.3899 + case "break": 1.3900 + case "case": 1.3901 + case "catch": 1.3902 + case "continue": 1.3903 + case "default": 1.3904 + case "do": 1.3905 + case "else": 1.3906 + case "finally": 1.3907 + case "for": 1.3908 + case "if": 1.3909 + case "in": 1.3910 + case "instanceof": 1.3911 + case "return": 1.3912 + case "yield": 1.3913 + case "switch": 1.3914 + case "throw": 1.3915 + case "try": 1.3916 + case "var": 1.3917 + case "let": 1.3918 + case "while": 1.3919 + case "with": 1.3920 + error("E024", state.tokens.next, state.tokens.next.value); 1.3921 + return false; 1.3922 + } 1.3923 + } 1.3924 + 1.3925 + if (state.tokens.next.type === "(punctuator)") { 1.3926 + switch (state.tokens.next.value) { 1.3927 + case "}": 1.3928 + case "]": 1.3929 + case ",": 1.3930 + if (opts.allowTrailing) { 1.3931 + return true; 1.3932 + } 1.3933 + 1.3934 + /* falls through */ 1.3935 + case ")": 1.3936 + error("E024", state.tokens.next, state.tokens.next.value); 1.3937 + return false; 1.3938 + } 1.3939 + } 1.3940 + return true; 1.3941 + } 1.3942 + 1.3943 + // Functional constructors for making the symbols that will be inherited by 1.3944 + // tokens. 1.3945 + 1.3946 + function symbol(s, p) { 1.3947 + var x = state.syntax[s]; 1.3948 + if (!x || typeof x !== "object") { 1.3949 + state.syntax[s] = x = { 1.3950 + id: s, 1.3951 + lbp: p, 1.3952 + value: s 1.3953 + }; 1.3954 + } 1.3955 + return x; 1.3956 + } 1.3957 + 1.3958 + function delim(s) { 1.3959 + return symbol(s, 0); 1.3960 + } 1.3961 + 1.3962 + function stmt(s, f) { 1.3963 + var x = delim(s); 1.3964 + x.identifier = x.reserved = true; 1.3965 + x.fud = f; 1.3966 + return x; 1.3967 + } 1.3968 + 1.3969 + function blockstmt(s, f) { 1.3970 + var x = stmt(s, f); 1.3971 + x.block = true; 1.3972 + return x; 1.3973 + } 1.3974 + 1.3975 + function reserveName(x) { 1.3976 + var c = x.id.charAt(0); 1.3977 + if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) { 1.3978 + x.identifier = x.reserved = true; 1.3979 + } 1.3980 + return x; 1.3981 + } 1.3982 + 1.3983 + function prefix(s, f) { 1.3984 + var x = symbol(s, 150); 1.3985 + reserveName(x); 1.3986 + x.nud = (typeof f === "function") ? f : function () { 1.3987 + this.right = expression(150); 1.3988 + this.arity = "unary"; 1.3989 + if (this.id === "++" || this.id === "--") { 1.3990 + if (state.option.plusplus) { 1.3991 + warning("W016", this, this.id); 1.3992 + } else if ((!this.right.identifier || isReserved(this.right)) && 1.3993 + this.right.id !== "." && this.right.id !== "[") { 1.3994 + warning("W017", this); 1.3995 + } 1.3996 + } 1.3997 + return this; 1.3998 + }; 1.3999 + return x; 1.4000 + } 1.4001 + 1.4002 + function type(s, f) { 1.4003 + var x = delim(s); 1.4004 + x.type = s; 1.4005 + x.nud = f; 1.4006 + return x; 1.4007 + } 1.4008 + 1.4009 + function reserve(name, func) { 1.4010 + var x = type(name, func); 1.4011 + x.identifier = true; 1.4012 + x.reserved = true; 1.4013 + return x; 1.4014 + } 1.4015 + 1.4016 + function FutureReservedWord(name, meta) { 1.4017 + var x = type(name, (meta && meta.nud) || function () { 1.4018 + return this; 1.4019 + }); 1.4020 + 1.4021 + meta = meta || {}; 1.4022 + meta.isFutureReservedWord = true; 1.4023 + 1.4024 + x.value = name; 1.4025 + x.identifier = true; 1.4026 + x.reserved = true; 1.4027 + x.meta = meta; 1.4028 + 1.4029 + return x; 1.4030 + } 1.4031 + 1.4032 + function reservevar(s, v) { 1.4033 + return reserve(s, function () { 1.4034 + if (typeof v === "function") { 1.4035 + v(this); 1.4036 + } 1.4037 + return this; 1.4038 + }); 1.4039 + } 1.4040 + 1.4041 + function infix(s, f, p, w) { 1.4042 + var x = symbol(s, p); 1.4043 + reserveName(x); 1.4044 + x.led = function (left) { 1.4045 + if (!w) { 1.4046 + nobreaknonadjacent(state.tokens.prev, state.tokens.curr); 1.4047 + nonadjacent(state.tokens.curr, state.tokens.next); 1.4048 + } 1.4049 + if (s === "in" && left.id === "!") { 1.4050 + warning("W018", left, "!"); 1.4051 + } 1.4052 + if (typeof f === "function") { 1.4053 + return f(left, this); 1.4054 + } else { 1.4055 + this.left = left; 1.4056 + this.right = expression(p); 1.4057 + return this; 1.4058 + } 1.4059 + }; 1.4060 + return x; 1.4061 + } 1.4062 + 1.4063 + 1.4064 + function application(s) { 1.4065 + var x = symbol(s, 42); 1.4066 + 1.4067 + x.led = function (left) { 1.4068 + if (!state.option.inESNext()) { 1.4069 + warning("W104", state.tokens.curr, "arrow function syntax (=>)"); 1.4070 + } 1.4071 + 1.4072 + nobreaknonadjacent(state.tokens.prev, state.tokens.curr); 1.4073 + nonadjacent(state.tokens.curr, state.tokens.next); 1.4074 + 1.4075 + this.left = left; 1.4076 + this.right = doFunction(undefined, undefined, false, left); 1.4077 + return this; 1.4078 + }; 1.4079 + return x; 1.4080 + } 1.4081 + 1.4082 + function relation(s, f) { 1.4083 + var x = symbol(s, 100); 1.4084 + 1.4085 + x.led = function (left) { 1.4086 + nobreaknonadjacent(state.tokens.prev, state.tokens.curr); 1.4087 + nonadjacent(state.tokens.curr, state.tokens.next); 1.4088 + var right = expression(100); 1.4089 + 1.4090 + if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) { 1.4091 + warning("W019", this); 1.4092 + } else if (f) { 1.4093 + f.apply(this, [left, right]); 1.4094 + } 1.4095 + 1.4096 + if (!left || !right) { 1.4097 + quit("E041", state.tokens.curr.line); 1.4098 + } 1.4099 + 1.4100 + if (left.id === "!") { 1.4101 + warning("W018", left, "!"); 1.4102 + } 1.4103 + 1.4104 + if (right.id === "!") { 1.4105 + warning("W018", right, "!"); 1.4106 + } 1.4107 + 1.4108 + this.left = left; 1.4109 + this.right = right; 1.4110 + return this; 1.4111 + }; 1.4112 + return x; 1.4113 + } 1.4114 + 1.4115 + function isPoorRelation(node) { 1.4116 + return node && 1.4117 + ((node.type === "(number)" && +node.value === 0) || 1.4118 + (node.type === "(string)" && node.value === "") || 1.4119 + (node.type === "null" && !state.option.eqnull) || 1.4120 + node.type === "true" || 1.4121 + node.type === "false" || 1.4122 + node.type === "undefined"); 1.4123 + } 1.4124 + 1.4125 + function assignop(s) { 1.4126 + symbol(s, 20).exps = true; 1.4127 + 1.4128 + return infix(s, function (left, that) { 1.4129 + that.left = left; 1.4130 + 1.4131 + if (left) { 1.4132 + if (predefined[left.value] === false && 1.4133 + scope[left.value]["(global)"] === true) { 1.4134 + warning("W020", left); 1.4135 + } else if (left["function"]) { 1.4136 + warning("W021", left, left.value); 1.4137 + } 1.4138 + 1.4139 + if (funct[left.value] === "const") { 1.4140 + error("E013", left, left.value); 1.4141 + } 1.4142 + 1.4143 + if (left.id === ".") { 1.4144 + if (!left.left) { 1.4145 + warning("E031", that); 1.4146 + } else if (left.left.value === "arguments" && !state.directive["use strict"]) { 1.4147 + warning("E031", that); 1.4148 + } 1.4149 + 1.4150 + that.right = expression(19); 1.4151 + return that; 1.4152 + } else if (left.id === "[") { 1.4153 + if (state.tokens.curr.left.first) { 1.4154 + state.tokens.curr.left.first.forEach(function (t) { 1.4155 + if (funct[t.value] === "const") { 1.4156 + error("E013", t, t.value); 1.4157 + } 1.4158 + }); 1.4159 + } else if (!left.left) { 1.4160 + warning("E031", that); 1.4161 + } else if (left.left.value === "arguments" && !state.directive["use strict"]) { 1.4162 + warning("E031", that); 1.4163 + } 1.4164 + that.right = expression(19); 1.4165 + return that; 1.4166 + } else if (left.identifier && !isReserved(left)) { 1.4167 + if (funct[left.value] === "exception") { 1.4168 + warning("W022", left); 1.4169 + } 1.4170 + that.right = expression(19); 1.4171 + return that; 1.4172 + } 1.4173 + 1.4174 + if (left === state.syntax["function"]) { 1.4175 + warning("W023", state.tokens.curr); 1.4176 + } 1.4177 + } 1.4178 + 1.4179 + error("E031", that); 1.4180 + }, 20); 1.4181 + } 1.4182 + 1.4183 + 1.4184 + function bitwise(s, f, p) { 1.4185 + var x = symbol(s, p); 1.4186 + reserveName(x); 1.4187 + x.led = (typeof f === "function") ? f : function (left) { 1.4188 + if (state.option.bitwise) { 1.4189 + warning("W016", this, this.id); 1.4190 + } 1.4191 + this.left = left; 1.4192 + this.right = expression(p); 1.4193 + return this; 1.4194 + }; 1.4195 + return x; 1.4196 + } 1.4197 + 1.4198 + 1.4199 + function bitwiseassignop(s) { 1.4200 + symbol(s, 20).exps = true; 1.4201 + return infix(s, function (left, that) { 1.4202 + if (state.option.bitwise) { 1.4203 + warning("W016", that, that.id); 1.4204 + } 1.4205 + nonadjacent(state.tokens.prev, state.tokens.curr); 1.4206 + nonadjacent(state.tokens.curr, state.tokens.next); 1.4207 + if (left) { 1.4208 + if (left.id === "." || left.id === "[" || 1.4209 + (left.identifier && !isReserved(left))) { 1.4210 + expression(19); 1.4211 + return that; 1.4212 + } 1.4213 + if (left === state.syntax["function"]) { 1.4214 + warning("W023", state.tokens.curr); 1.4215 + } 1.4216 + return that; 1.4217 + } 1.4218 + error("E031", that); 1.4219 + }, 20); 1.4220 + } 1.4221 + 1.4222 + 1.4223 + function suffix(s) { 1.4224 + var x = symbol(s, 150); 1.4225 + 1.4226 + x.led = function (left) { 1.4227 + if (state.option.plusplus) { 1.4228 + warning("W016", this, this.id); 1.4229 + } else if ((!left.identifier || isReserved(left)) && left.id !== "." && left.id !== "[") { 1.4230 + warning("W017", this); 1.4231 + } 1.4232 + 1.4233 + this.left = left; 1.4234 + return this; 1.4235 + }; 1.4236 + return x; 1.4237 + } 1.4238 + 1.4239 + // fnparam means that this identifier is being defined as a function 1.4240 + // argument (see identifier()) 1.4241 + // prop means that this identifier is that of an object property 1.4242 + 1.4243 + function optionalidentifier(fnparam, prop) { 1.4244 + if (!state.tokens.next.identifier) { 1.4245 + return; 1.4246 + } 1.4247 + 1.4248 + advance(); 1.4249 + 1.4250 + var curr = state.tokens.curr; 1.4251 + var meta = curr.meta || {}; 1.4252 + var val = state.tokens.curr.value; 1.4253 + 1.4254 + if (!isReserved(curr)) { 1.4255 + return val; 1.4256 + } 1.4257 + 1.4258 + if (prop) { 1.4259 + if (state.option.inES5() || meta.isFutureReservedWord) { 1.4260 + return val; 1.4261 + } 1.4262 + } 1.4263 + 1.4264 + if (fnparam && val === "undefined") { 1.4265 + return val; 1.4266 + } 1.4267 + 1.4268 + // Display an info message about reserved words as properties 1.4269 + // and ES5 but do it only once. 1.4270 + if (prop && !api.getCache("displayed:I002")) { 1.4271 + api.setCache("displayed:I002", true); 1.4272 + warning("I002"); 1.4273 + } 1.4274 + 1.4275 + warning("W024", state.tokens.curr, state.tokens.curr.id); 1.4276 + return val; 1.4277 + } 1.4278 + 1.4279 + // fnparam means that this identifier is being defined as a function 1.4280 + // argument 1.4281 + // prop means that this identifier is that of an object property 1.4282 + function identifier(fnparam, prop) { 1.4283 + var i = optionalidentifier(fnparam, prop); 1.4284 + if (i) { 1.4285 + return i; 1.4286 + } 1.4287 + if (state.tokens.curr.id === "function" && state.tokens.next.id === "(") { 1.4288 + warning("W025"); 1.4289 + } else { 1.4290 + error("E030", state.tokens.next, state.tokens.next.value); 1.4291 + } 1.4292 + } 1.4293 + 1.4294 + 1.4295 + function reachable(s) { 1.4296 + var i = 0, t; 1.4297 + if (state.tokens.next.id !== ";" || noreach) { 1.4298 + return; 1.4299 + } 1.4300 + for (;;) { 1.4301 + t = peek(i); 1.4302 + if (t.reach) { 1.4303 + return; 1.4304 + } 1.4305 + if (t.id !== "(endline)") { 1.4306 + if (t.id === "function") { 1.4307 + if (!state.option.latedef) { 1.4308 + break; 1.4309 + } 1.4310 + 1.4311 + warning("W026", t); 1.4312 + break; 1.4313 + } 1.4314 + 1.4315 + warning("W027", t, t.value, s); 1.4316 + break; 1.4317 + } 1.4318 + i += 1; 1.4319 + } 1.4320 + } 1.4321 + 1.4322 + 1.4323 + function statement(noindent) { 1.4324 + var values; 1.4325 + var i = indent, r, s = scope, t = state.tokens.next; 1.4326 + 1.4327 + if (t.id === ";") { 1.4328 + advance(";"); 1.4329 + return; 1.4330 + } 1.4331 + 1.4332 + // Is this a labelled statement? 1.4333 + var res = isReserved(t); 1.4334 + 1.4335 + // We're being more tolerant here: if someone uses 1.4336 + // a FutureReservedWord as a label, we warn but proceed 1.4337 + // anyway. 1.4338 + 1.4339 + if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") { 1.4340 + warning("W024", t, t.id); 1.4341 + res = false; 1.4342 + } 1.4343 + 1.4344 + // detect a destructuring assignment 1.4345 + if (_.has(["[", "{"], t.value)) { 1.4346 + if (lookupBlockType().isDestAssign) { 1.4347 + if (!state.option.inESNext()) { 1.4348 + warning("W104", state.tokens.curr, "destructuring expression"); 1.4349 + } 1.4350 + values = destructuringExpression(); 1.4351 + values.forEach(function (tok) { 1.4352 + isundef(funct, "W117", tok.token, tok.id); 1.4353 + }); 1.4354 + advance("="); 1.4355 + destructuringExpressionMatch(values, expression(5, true)); 1.4356 + advance(";"); 1.4357 + return; 1.4358 + } 1.4359 + } 1.4360 + if (t.identifier && !res && peek().id === ":") { 1.4361 + advance(); 1.4362 + advance(":"); 1.4363 + scope = Object.create(s); 1.4364 + addlabel(t.value, "label"); 1.4365 + 1.4366 + if (!state.tokens.next.labelled && state.tokens.next.value !== "{") { 1.4367 + warning("W028", state.tokens.next, t.value, state.tokens.next.value); 1.4368 + } 1.4369 + 1.4370 + state.tokens.next.label = t.value; 1.4371 + t = state.tokens.next; 1.4372 + } 1.4373 + 1.4374 + // Is it a lonely block? 1.4375 + 1.4376 + if (t.id === "{") { 1.4377 + // Is it a switch case block? 1.4378 + // 1.4379 + // switch (foo) { 1.4380 + // case bar: { <= here. 1.4381 + // ... 1.4382 + // } 1.4383 + // } 1.4384 + var iscase = (funct["(verb)"] === "case" && state.tokens.curr.value === ":"); 1.4385 + block(true, true, false, false, iscase); 1.4386 + return; 1.4387 + } 1.4388 + 1.4389 + // Parse the statement. 1.4390 + 1.4391 + if (!noindent) { 1.4392 + indentation(); 1.4393 + } 1.4394 + r = expression(0, true); 1.4395 + 1.4396 + // Look for the final semicolon. 1.4397 + 1.4398 + if (!t.block) { 1.4399 + if (!state.option.expr && (!r || !r.exps)) { 1.4400 + warning("W030", state.tokens.curr); 1.4401 + } else if (state.option.nonew && r && r.left && r.id === "(" && r.left.id === "new") { 1.4402 + warning("W031", t); 1.4403 + } 1.4404 + 1.4405 + if (state.tokens.next.id !== ";") { 1.4406 + if (!state.option.asi) { 1.4407 + // If this is the last statement in a block that ends on 1.4408 + // the same line *and* option lastsemic is on, ignore the warning. 1.4409 + // Otherwise, complain about missing semicolon. 1.4410 + if (!state.option.lastsemic || state.tokens.next.id !== "}" || 1.4411 + state.tokens.next.line !== state.tokens.curr.line) { 1.4412 + warningAt("W033", state.tokens.curr.line, state.tokens.curr.character); 1.4413 + } 1.4414 + } 1.4415 + } else { 1.4416 + adjacent(state.tokens.curr, state.tokens.next); 1.4417 + advance(";"); 1.4418 + nonadjacent(state.tokens.curr, state.tokens.next); 1.4419 + } 1.4420 + } 1.4421 + 1.4422 + // Restore the indentation. 1.4423 + 1.4424 + indent = i; 1.4425 + scope = s; 1.4426 + return r; 1.4427 + } 1.4428 + 1.4429 + 1.4430 + function statements(startLine) { 1.4431 + var a = [], p; 1.4432 + 1.4433 + while (!state.tokens.next.reach && state.tokens.next.id !== "(end)") { 1.4434 + if (state.tokens.next.id === ";") { 1.4435 + p = peek(); 1.4436 + 1.4437 + if (!p || (p.id !== "(" && p.id !== "[")) { 1.4438 + warning("W032"); 1.4439 + } 1.4440 + 1.4441 + advance(";"); 1.4442 + } else { 1.4443 + a.push(statement(startLine === state.tokens.next.line)); 1.4444 + } 1.4445 + } 1.4446 + return a; 1.4447 + } 1.4448 + 1.4449 + 1.4450 + /* 1.4451 + * read all directives 1.4452 + * recognizes a simple form of asi, but always 1.4453 + * warns, if it is used 1.4454 + */ 1.4455 + function directives() { 1.4456 + var i, p, pn; 1.4457 + 1.4458 + for (;;) { 1.4459 + if (state.tokens.next.id === "(string)") { 1.4460 + p = peek(0); 1.4461 + if (p.id === "(endline)") { 1.4462 + i = 1; 1.4463 + do { 1.4464 + pn = peek(i); 1.4465 + i = i + 1; 1.4466 + } while (pn.id === "(endline)"); 1.4467 + 1.4468 + if (pn.id !== ";") { 1.4469 + if (pn.id !== "(string)" && pn.id !== "(number)" && 1.4470 + pn.id !== "(regexp)" && pn.identifier !== true && 1.4471 + pn.id !== "}") { 1.4472 + break; 1.4473 + } 1.4474 + warning("W033", state.tokens.next); 1.4475 + } else { 1.4476 + p = pn; 1.4477 + } 1.4478 + } else if (p.id === "}") { 1.4479 + // Directive with no other statements, warn about missing semicolon 1.4480 + warning("W033", p); 1.4481 + } else if (p.id !== ";") { 1.4482 + break; 1.4483 + } 1.4484 + 1.4485 + indentation(); 1.4486 + advance(); 1.4487 + if (state.directive[state.tokens.curr.value]) { 1.4488 + warning("W034", state.tokens.curr, state.tokens.curr.value); 1.4489 + } 1.4490 + 1.4491 + if (state.tokens.curr.value === "use strict") { 1.4492 + if (!state.option["(explicitNewcap)"]) 1.4493 + state.option.newcap = true; 1.4494 + state.option.undef = true; 1.4495 + } 1.4496 + 1.4497 + // there's no directive negation, so always set to true 1.4498 + state.directive[state.tokens.curr.value] = true; 1.4499 + 1.4500 + if (p.id === ";") { 1.4501 + advance(";"); 1.4502 + } 1.4503 + continue; 1.4504 + } 1.4505 + break; 1.4506 + } 1.4507 + } 1.4508 + 1.4509 + 1.4510 + /* 1.4511 + * Parses a single block. A block is a sequence of statements wrapped in 1.4512 + * braces. 1.4513 + * 1.4514 + * ordinary - true for everything but function bodies and try blocks. 1.4515 + * stmt - true if block can be a single statement (e.g. in if/for/while). 1.4516 + * isfunc - true if block is a function body 1.4517 + * isfatarrow - 1.4518 + * iscase - true if block is a switch case block 1.4519 + */ 1.4520 + function block(ordinary, stmt, isfunc, isfatarrow, iscase) { 1.4521 + var a, 1.4522 + b = inblock, 1.4523 + old_indent = indent, 1.4524 + m, 1.4525 + s = scope, 1.4526 + t, 1.4527 + line, 1.4528 + d; 1.4529 + 1.4530 + inblock = ordinary; 1.4531 + 1.4532 + if (!ordinary || !state.option.funcscope) 1.4533 + scope = Object.create(scope); 1.4534 + 1.4535 + nonadjacent(state.tokens.curr, state.tokens.next); 1.4536 + t = state.tokens.next; 1.4537 + 1.4538 + var metrics = funct["(metrics)"]; 1.4539 + metrics.nestedBlockDepth += 1; 1.4540 + metrics.verifyMaxNestedBlockDepthPerFunction(); 1.4541 + 1.4542 + if (state.tokens.next.id === "{") { 1.4543 + advance("{"); 1.4544 + 1.4545 + // create a new block scope 1.4546 + funct["(blockscope)"].stack(); 1.4547 + 1.4548 + line = state.tokens.curr.line; 1.4549 + if (state.tokens.next.id !== "}") { 1.4550 + indent += state.option.indent; 1.4551 + while (!ordinary && state.tokens.next.from > indent) { 1.4552 + indent += state.option.indent; 1.4553 + } 1.4554 + 1.4555 + if (isfunc) { 1.4556 + m = {}; 1.4557 + for (d in state.directive) { 1.4558 + if (_.has(state.directive, d)) { 1.4559 + m[d] = state.directive[d]; 1.4560 + } 1.4561 + } 1.4562 + directives(); 1.4563 + 1.4564 + if (state.option.strict && funct["(context)"]["(global)"]) { 1.4565 + if (!m["use strict"] && !state.directive["use strict"]) { 1.4566 + warning("E007"); 1.4567 + } 1.4568 + } 1.4569 + } 1.4570 + 1.4571 + a = statements(line); 1.4572 + 1.4573 + metrics.statementCount += a.length; 1.4574 + 1.4575 + if (isfunc) { 1.4576 + state.directive = m; 1.4577 + } 1.4578 + 1.4579 + indent -= state.option.indent; 1.4580 + if (line !== state.tokens.next.line) { 1.4581 + indentation(); 1.4582 + } 1.4583 + } else if (line !== state.tokens.next.line) { 1.4584 + indentation(); 1.4585 + } 1.4586 + advance("}", t); 1.4587 + 1.4588 + funct["(blockscope)"].unstack(); 1.4589 + 1.4590 + indent = old_indent; 1.4591 + } else if (!ordinary) { 1.4592 + if (isfunc) { 1.4593 + m = {}; 1.4594 + if (stmt && !isfatarrow && !state.option.inMoz(true)) { 1.4595 + error("W118", state.tokens.curr, "function closure expressions"); 1.4596 + } 1.4597 + 1.4598 + if (!stmt) { 1.4599 + for (d in state.directive) { 1.4600 + if (_.has(state.directive, d)) { 1.4601 + m[d] = state.directive[d]; 1.4602 + } 1.4603 + } 1.4604 + } 1.4605 + expression(5); 1.4606 + 1.4607 + if (state.option.strict && funct["(context)"]["(global)"]) { 1.4608 + if (!m["use strict"] && !state.directive["use strict"]) { 1.4609 + warning("E007"); 1.4610 + } 1.4611 + } 1.4612 + } else { 1.4613 + error("E021", state.tokens.next, "{", state.tokens.next.value); 1.4614 + } 1.4615 + } else { 1.4616 + 1.4617 + // check to avoid let declaration not within a block 1.4618 + funct["(nolet)"] = true; 1.4619 + 1.4620 + if (!stmt || state.option.curly) { 1.4621 + warning("W116", state.tokens.next, "{", state.tokens.next.value); 1.4622 + } 1.4623 + 1.4624 + noreach = true; 1.4625 + indent += state.option.indent; 1.4626 + // test indentation only if statement is in new line 1.4627 + a = [statement(state.tokens.next.line === state.tokens.curr.line)]; 1.4628 + indent -= state.option.indent; 1.4629 + noreach = false; 1.4630 + 1.4631 + delete funct["(nolet)"]; 1.4632 + } 1.4633 + // If it is a "break" in switch case, don't clear and let it propagate out. 1.4634 + if (!(iscase && funct["(verb)"] === "break")) funct["(verb)"] = null; 1.4635 + 1.4636 + if (!ordinary || !state.option.funcscope) scope = s; 1.4637 + inblock = b; 1.4638 + if (ordinary && state.option.noempty && (!a || a.length === 0)) { 1.4639 + warning("W035"); 1.4640 + } 1.4641 + metrics.nestedBlockDepth -= 1; 1.4642 + return a; 1.4643 + } 1.4644 + 1.4645 + 1.4646 + function countMember(m) { 1.4647 + if (membersOnly && typeof membersOnly[m] !== "boolean") { 1.4648 + warning("W036", state.tokens.curr, m); 1.4649 + } 1.4650 + if (typeof member[m] === "number") { 1.4651 + member[m] += 1; 1.4652 + } else { 1.4653 + member[m] = 1; 1.4654 + } 1.4655 + } 1.4656 + 1.4657 + 1.4658 + function note_implied(tkn) { 1.4659 + var name = tkn.value, line = tkn.line, a = implied[name]; 1.4660 + if (typeof a === "function") { 1.4661 + a = false; 1.4662 + } 1.4663 + 1.4664 + if (!a) { 1.4665 + a = [line]; 1.4666 + implied[name] = a; 1.4667 + } else if (a[a.length - 1] !== line) { 1.4668 + a.push(line); 1.4669 + } 1.4670 + } 1.4671 + 1.4672 + 1.4673 + // Build the syntax table by declaring the syntactic elements of the language. 1.4674 + 1.4675 + type("(number)", function () { 1.4676 + return this; 1.4677 + }); 1.4678 + 1.4679 + type("(string)", function () { 1.4680 + return this; 1.4681 + }); 1.4682 + 1.4683 + state.syntax["(identifier)"] = { 1.4684 + type: "(identifier)", 1.4685 + lbp: 0, 1.4686 + identifier: true, 1.4687 + nud: function () { 1.4688 + var v = this.value, 1.4689 + s = scope[v], 1.4690 + f; 1.4691 + 1.4692 + if (typeof s === "function") { 1.4693 + // Protection against accidental inheritance. 1.4694 + s = undefined; 1.4695 + } else if (typeof s === "boolean") { 1.4696 + f = funct; 1.4697 + funct = functions[0]; 1.4698 + addlabel(v, "var"); 1.4699 + s = funct; 1.4700 + funct = f; 1.4701 + } 1.4702 + var block; 1.4703 + if (_.has(funct, "(blockscope)")) { 1.4704 + block = funct["(blockscope)"].getlabel(v); 1.4705 + } 1.4706 + 1.4707 + // The name is in scope and defined in the current function. 1.4708 + if (funct === s || block) { 1.4709 + // Change 'unused' to 'var', and reject labels. 1.4710 + // the name is in a block scope 1.4711 + switch (block ? block[v]["(type)"] : funct[v]) { 1.4712 + case "unused": 1.4713 + if (block) block[v]["(type)"] = "var"; 1.4714 + else funct[v] = "var"; 1.4715 + break; 1.4716 + case "unction": 1.4717 + if (block) block[v]["(type)"] = "function"; 1.4718 + else funct[v] = "function"; 1.4719 + this["function"] = true; 1.4720 + break; 1.4721 + case "function": 1.4722 + this["function"] = true; 1.4723 + break; 1.4724 + case "label": 1.4725 + warning("W037", state.tokens.curr, v); 1.4726 + break; 1.4727 + } 1.4728 + } else if (funct["(global)"]) { 1.4729 + // The name is not defined in the function. If we are in the global 1.4730 + // scope, then we have an undefined variable. 1.4731 + // 1.4732 + // Operators typeof and delete do not raise runtime errors even if 1.4733 + // the base object of a reference is null so no need to display warning 1.4734 + // if we're inside of typeof or delete. 1.4735 + 1.4736 + if (typeof predefined[v] !== "boolean") { 1.4737 + // Attempting to subscript a null reference will throw an 1.4738 + // error, even within the typeof and delete operators 1.4739 + if (!(anonname === "typeof" || anonname === "delete") || 1.4740 + (state.tokens.next && (state.tokens.next.value === "." || 1.4741 + state.tokens.next.value === "["))) { 1.4742 + 1.4743 + // if we're in a list comprehension, variables are declared 1.4744 + // locally and used before being defined. So we check 1.4745 + // the presence of the given variable in the comp array 1.4746 + // before declaring it undefined. 1.4747 + 1.4748 + if (!funct["(comparray)"].check(v)) { 1.4749 + isundef(funct, "W117", state.tokens.curr, v); 1.4750 + } 1.4751 + } 1.4752 + } 1.4753 + 1.4754 + note_implied(state.tokens.curr); 1.4755 + } else { 1.4756 + // If the name is already defined in the current 1.4757 + // function, but not as outer, then there is a scope error. 1.4758 + 1.4759 + switch (funct[v]) { 1.4760 + case "closure": 1.4761 + case "function": 1.4762 + case "var": 1.4763 + case "unused": 1.4764 + warning("W038", state.tokens.curr, v); 1.4765 + break; 1.4766 + case "label": 1.4767 + warning("W037", state.tokens.curr, v); 1.4768 + break; 1.4769 + case "outer": 1.4770 + case "global": 1.4771 + break; 1.4772 + default: 1.4773 + // If the name is defined in an outer function, make an outer entry, 1.4774 + // and if it was unused, make it var. 1.4775 + if (s === true) { 1.4776 + funct[v] = true; 1.4777 + } else if (s === null) { 1.4778 + warning("W039", state.tokens.curr, v); 1.4779 + note_implied(state.tokens.curr); 1.4780 + } else if (typeof s !== "object") { 1.4781 + // Operators typeof and delete do not raise runtime errors even 1.4782 + // if the base object of a reference is null so no need to 1.4783 + // 1.4784 + // display warning if we're inside of typeof or delete. 1.4785 + // Attempting to subscript a null reference will throw an 1.4786 + // error, even within the typeof and delete operators 1.4787 + if (!(anonname === "typeof" || anonname === "delete") || 1.4788 + (state.tokens.next && 1.4789 + (state.tokens.next.value === "." || state.tokens.next.value === "["))) { 1.4790 + 1.4791 + isundef(funct, "W117", state.tokens.curr, v); 1.4792 + } 1.4793 + funct[v] = true; 1.4794 + note_implied(state.tokens.curr); 1.4795 + } else { 1.4796 + switch (s[v]) { 1.4797 + case "function": 1.4798 + case "unction": 1.4799 + this["function"] = true; 1.4800 + s[v] = "closure"; 1.4801 + funct[v] = s["(global)"] ? "global" : "outer"; 1.4802 + break; 1.4803 + case "var": 1.4804 + case "unused": 1.4805 + s[v] = "closure"; 1.4806 + funct[v] = s["(global)"] ? "global" : "outer"; 1.4807 + break; 1.4808 + case "closure": 1.4809 + funct[v] = s["(global)"] ? "global" : "outer"; 1.4810 + break; 1.4811 + case "label": 1.4812 + warning("W037", state.tokens.curr, v); 1.4813 + } 1.4814 + } 1.4815 + } 1.4816 + } 1.4817 + return this; 1.4818 + }, 1.4819 + led: function () { 1.4820 + error("E033", state.tokens.next, state.tokens.next.value); 1.4821 + } 1.4822 + }; 1.4823 + 1.4824 + type("(regexp)", function () { 1.4825 + return this; 1.4826 + }); 1.4827 + 1.4828 + // ECMAScript parser 1.4829 + 1.4830 + delim("(endline)"); 1.4831 + delim("(begin)"); 1.4832 + delim("(end)").reach = true; 1.4833 + delim("(error)").reach = true; 1.4834 + delim("}").reach = true; 1.4835 + delim(")"); 1.4836 + delim("]"); 1.4837 + delim("\"").reach = true; 1.4838 + delim("'").reach = true; 1.4839 + delim(";"); 1.4840 + delim(":").reach = true; 1.4841 + delim("#"); 1.4842 + 1.4843 + reserve("else"); 1.4844 + reserve("case").reach = true; 1.4845 + reserve("catch"); 1.4846 + reserve("default").reach = true; 1.4847 + reserve("finally"); 1.4848 + reservevar("arguments", function (x) { 1.4849 + if (state.directive["use strict"] && funct["(global)"]) { 1.4850 + warning("E008", x); 1.4851 + } 1.4852 + }); 1.4853 + reservevar("eval"); 1.4854 + reservevar("false"); 1.4855 + reservevar("Infinity"); 1.4856 + reservevar("null"); 1.4857 + reservevar("this", function (x) { 1.4858 + if (state.directive["use strict"] && !state.option.validthis && ((funct["(statement)"] && 1.4859 + funct["(name)"].charAt(0) > "Z") || funct["(global)"])) { 1.4860 + warning("W040", x); 1.4861 + } 1.4862 + }); 1.4863 + reservevar("true"); 1.4864 + reservevar("undefined"); 1.4865 + 1.4866 + assignop("=", "assign", 20); 1.4867 + assignop("+=", "assignadd", 20); 1.4868 + assignop("-=", "assignsub", 20); 1.4869 + assignop("*=", "assignmult", 20); 1.4870 + assignop("/=", "assigndiv", 20).nud = function () { 1.4871 + error("E014"); 1.4872 + }; 1.4873 + assignop("%=", "assignmod", 20); 1.4874 + 1.4875 + bitwiseassignop("&=", "assignbitand", 20); 1.4876 + bitwiseassignop("|=", "assignbitor", 20); 1.4877 + bitwiseassignop("^=", "assignbitxor", 20); 1.4878 + bitwiseassignop("<<=", "assignshiftleft", 20); 1.4879 + bitwiseassignop(">>=", "assignshiftright", 20); 1.4880 + bitwiseassignop(">>>=", "assignshiftrightunsigned", 20); 1.4881 + infix(",", function (left, that) { 1.4882 + var expr; 1.4883 + that.exprs = [left]; 1.4884 + if (!comma({peek: true})) { 1.4885 + return that; 1.4886 + } 1.4887 + while (true) { 1.4888 + if (!(expr = expression(5))) { 1.4889 + break; 1.4890 + } 1.4891 + that.exprs.push(expr); 1.4892 + if (state.tokens.next.value !== "," || !comma()) { 1.4893 + break; 1.4894 + } 1.4895 + } 1.4896 + return that; 1.4897 + }, 5, true); 1.4898 + infix("?", function (left, that) { 1.4899 + that.left = left; 1.4900 + that.right = expression(10); 1.4901 + advance(":"); 1.4902 + that["else"] = expression(10); 1.4903 + return that; 1.4904 + }, 30); 1.4905 + 1.4906 + infix("||", "or", 40); 1.4907 + infix("&&", "and", 50); 1.4908 + bitwise("|", "bitor", 70); 1.4909 + bitwise("^", "bitxor", 80); 1.4910 + bitwise("&", "bitand", 90); 1.4911 + relation("==", function (left, right) { 1.4912 + var eqnull = state.option.eqnull && (left.value === "null" || right.value === "null"); 1.4913 + 1.4914 + if (!eqnull && state.option.eqeqeq) 1.4915 + warning("W116", this, "===", "=="); 1.4916 + else if (isPoorRelation(left)) 1.4917 + warning("W041", this, "===", left.value); 1.4918 + else if (isPoorRelation(right)) 1.4919 + warning("W041", this, "===", right.value); 1.4920 + 1.4921 + return this; 1.4922 + }); 1.4923 + relation("==="); 1.4924 + relation("!=", function (left, right) { 1.4925 + var eqnull = state.option.eqnull && 1.4926 + (left.value === "null" || right.value === "null"); 1.4927 + 1.4928 + if (!eqnull && state.option.eqeqeq) { 1.4929 + warning("W116", this, "!==", "!="); 1.4930 + } else if (isPoorRelation(left)) { 1.4931 + warning("W041", this, "!==", left.value); 1.4932 + } else if (isPoorRelation(right)) { 1.4933 + warning("W041", this, "!==", right.value); 1.4934 + } 1.4935 + return this; 1.4936 + }); 1.4937 + relation("!=="); 1.4938 + relation("<"); 1.4939 + relation(">"); 1.4940 + relation("<="); 1.4941 + relation(">="); 1.4942 + bitwise("<<", "shiftleft", 120); 1.4943 + bitwise(">>", "shiftright", 120); 1.4944 + bitwise(">>>", "shiftrightunsigned", 120); 1.4945 + infix("in", "in", 120); 1.4946 + infix("instanceof", "instanceof", 120); 1.4947 + infix("+", function (left, that) { 1.4948 + var right = expression(130); 1.4949 + if (left && right && left.id === "(string)" && right.id === "(string)") { 1.4950 + left.value += right.value; 1.4951 + left.character = right.character; 1.4952 + if (!state.option.scripturl && reg.javascriptURL.test(left.value)) { 1.4953 + warning("W050", left); 1.4954 + } 1.4955 + return left; 1.4956 + } 1.4957 + that.left = left; 1.4958 + that.right = right; 1.4959 + return that; 1.4960 + }, 130); 1.4961 + prefix("+", "num"); 1.4962 + prefix("+++", function () { 1.4963 + warning("W007"); 1.4964 + this.right = expression(150); 1.4965 + this.arity = "unary"; 1.4966 + return this; 1.4967 + }); 1.4968 + infix("+++", function (left) { 1.4969 + warning("W007"); 1.4970 + this.left = left; 1.4971 + this.right = expression(130); 1.4972 + return this; 1.4973 + }, 130); 1.4974 + infix("-", "sub", 130); 1.4975 + prefix("-", "neg"); 1.4976 + prefix("---", function () { 1.4977 + warning("W006"); 1.4978 + this.right = expression(150); 1.4979 + this.arity = "unary"; 1.4980 + return this; 1.4981 + }); 1.4982 + infix("---", function (left) { 1.4983 + warning("W006"); 1.4984 + this.left = left; 1.4985 + this.right = expression(130); 1.4986 + return this; 1.4987 + }, 130); 1.4988 + infix("*", "mult", 140); 1.4989 + infix("/", "div", 140); 1.4990 + infix("%", "mod", 140); 1.4991 + 1.4992 + suffix("++", "postinc"); 1.4993 + prefix("++", "preinc"); 1.4994 + state.syntax["++"].exps = true; 1.4995 + 1.4996 + suffix("--", "postdec"); 1.4997 + prefix("--", "predec"); 1.4998 + state.syntax["--"].exps = true; 1.4999 + prefix("delete", function () { 1.5000 + var p = expression(5); 1.5001 + if (!p || (p.id !== "." && p.id !== "[")) { 1.5002 + warning("W051"); 1.5003 + } 1.5004 + this.first = p; 1.5005 + return this; 1.5006 + }).exps = true; 1.5007 + 1.5008 + prefix("~", function () { 1.5009 + if (state.option.bitwise) { 1.5010 + warning("W052", this, "~"); 1.5011 + } 1.5012 + expression(150); 1.5013 + return this; 1.5014 + }); 1.5015 + 1.5016 + prefix("...", function () { 1.5017 + if (!state.option.inESNext()) { 1.5018 + warning("W104", this, "spread/rest operator"); 1.5019 + } 1.5020 + if (!state.tokens.next.identifier) { 1.5021 + error("E030", state.tokens.next, state.tokens.next.value); 1.5022 + } 1.5023 + expression(150); 1.5024 + return this; 1.5025 + }); 1.5026 + 1.5027 + prefix("!", function () { 1.5028 + this.right = expression(150); 1.5029 + this.arity = "unary"; 1.5030 + 1.5031 + if (!this.right) { // '!' followed by nothing? Give up. 1.5032 + quit("E041", this.line || 0); 1.5033 + } 1.5034 + 1.5035 + if (bang[this.right.id] === true) { 1.5036 + warning("W018", this, "!"); 1.5037 + } 1.5038 + return this; 1.5039 + }); 1.5040 + 1.5041 + prefix("typeof", "typeof"); 1.5042 + prefix("new", function () { 1.5043 + var c = expression(155), i; 1.5044 + if (c && c.id !== "function") { 1.5045 + if (c.identifier) { 1.5046 + c["new"] = true; 1.5047 + switch (c.value) { 1.5048 + case "Number": 1.5049 + case "String": 1.5050 + case "Boolean": 1.5051 + case "Math": 1.5052 + case "JSON": 1.5053 + warning("W053", state.tokens.prev, c.value); 1.5054 + break; 1.5055 + case "Function": 1.5056 + if (!state.option.evil) { 1.5057 + warning("W054"); 1.5058 + } 1.5059 + break; 1.5060 + case "Date": 1.5061 + case "RegExp": 1.5062 + break; 1.5063 + default: 1.5064 + if (c.id !== "function") { 1.5065 + i = c.value.substr(0, 1); 1.5066 + if (state.option.newcap && (i < "A" || i > "Z") && !_.has(global, c.value)) { 1.5067 + warning("W055", state.tokens.curr); 1.5068 + } 1.5069 + } 1.5070 + } 1.5071 + } else { 1.5072 + if (c.id !== "." && c.id !== "[" && c.id !== "(") { 1.5073 + warning("W056", state.tokens.curr); 1.5074 + } 1.5075 + } 1.5076 + } else { 1.5077 + if (!state.option.supernew) 1.5078 + warning("W057", this); 1.5079 + } 1.5080 + adjacent(state.tokens.curr, state.tokens.next); 1.5081 + if (state.tokens.next.id !== "(" && !state.option.supernew) { 1.5082 + warning("W058", state.tokens.curr, state.tokens.curr.value); 1.5083 + } 1.5084 + this.first = c; 1.5085 + return this; 1.5086 + }); 1.5087 + state.syntax["new"].exps = true; 1.5088 + 1.5089 + prefix("void").exps = true; 1.5090 + 1.5091 + infix(".", function (left, that) { 1.5092 + adjacent(state.tokens.prev, state.tokens.curr); 1.5093 + nobreak(); 1.5094 + var m = identifier(false, true); 1.5095 + 1.5096 + if (typeof m === "string") { 1.5097 + countMember(m); 1.5098 + } 1.5099 + 1.5100 + that.left = left; 1.5101 + that.right = m; 1.5102 + 1.5103 + if (m && m === "hasOwnProperty" && state.tokens.next.value === "=") { 1.5104 + warning("W001"); 1.5105 + } 1.5106 + 1.5107 + if (left && left.value === "arguments" && (m === "callee" || m === "caller")) { 1.5108 + if (state.option.noarg) 1.5109 + warning("W059", left, m); 1.5110 + else if (state.directive["use strict"]) 1.5111 + error("E008"); 1.5112 + } else if (!state.option.evil && left && left.value === "document" && 1.5113 + (m === "write" || m === "writeln")) { 1.5114 + warning("W060", left); 1.5115 + } 1.5116 + 1.5117 + if (!state.option.evil && (m === "eval" || m === "execScript")) { 1.5118 + warning("W061"); 1.5119 + } 1.5120 + 1.5121 + return that; 1.5122 + }, 160, true); 1.5123 + 1.5124 + infix("(", function (left, that) { 1.5125 + if (state.tokens.prev.id !== "}" && state.tokens.prev.id !== ")") { 1.5126 + nobreak(state.tokens.prev, state.tokens.curr); 1.5127 + } 1.5128 + 1.5129 + nospace(); 1.5130 + if (state.option.immed && left && !left.immed && left.id === "function") { 1.5131 + warning("W062"); 1.5132 + } 1.5133 + 1.5134 + var n = 0; 1.5135 + var p = []; 1.5136 + 1.5137 + if (left) { 1.5138 + if (left.type === "(identifier)") { 1.5139 + if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) { 1.5140 + if ("Number String Boolean Date Object".indexOf(left.value) === -1) { 1.5141 + if (left.value === "Math") { 1.5142 + warning("W063", left); 1.5143 + } else if (state.option.newcap) { 1.5144 + warning("W064", left); 1.5145 + } 1.5146 + } 1.5147 + } 1.5148 + } 1.5149 + } 1.5150 + 1.5151 + if (state.tokens.next.id !== ")") { 1.5152 + for (;;) { 1.5153 + p[p.length] = expression(10); 1.5154 + n += 1; 1.5155 + if (state.tokens.next.id !== ",") { 1.5156 + break; 1.5157 + } 1.5158 + comma(); 1.5159 + } 1.5160 + } 1.5161 + 1.5162 + advance(")"); 1.5163 + nospace(state.tokens.prev, state.tokens.curr); 1.5164 + 1.5165 + if (typeof left === "object") { 1.5166 + if (left.value === "parseInt" && n === 1) { 1.5167 + warning("W065", state.tokens.curr); 1.5168 + } 1.5169 + if (!state.option.evil) { 1.5170 + if (left.value === "eval" || left.value === "Function" || 1.5171 + left.value === "execScript") { 1.5172 + warning("W061", left); 1.5173 + 1.5174 + if (p[0] && [0].id === "(string)") { 1.5175 + addInternalSrc(left, p[0].value); 1.5176 + } 1.5177 + } else if (p[0] && p[0].id === "(string)" && 1.5178 + (left.value === "setTimeout" || 1.5179 + left.value === "setInterval")) { 1.5180 + warning("W066", left); 1.5181 + addInternalSrc(left, p[0].value); 1.5182 + 1.5183 + // window.setTimeout/setInterval 1.5184 + } else if (p[0] && p[0].id === "(string)" && 1.5185 + left.value === "." && 1.5186 + left.left.value === "window" && 1.5187 + (left.right === "setTimeout" || 1.5188 + left.right === "setInterval")) { 1.5189 + warning("W066", left); 1.5190 + addInternalSrc(left, p[0].value); 1.5191 + } 1.5192 + } 1.5193 + if (!left.identifier && left.id !== "." && left.id !== "[" && 1.5194 + left.id !== "(" && left.id !== "&&" && left.id !== "||" && 1.5195 + left.id !== "?") { 1.5196 + warning("W067", left); 1.5197 + } 1.5198 + } 1.5199 + 1.5200 + that.left = left; 1.5201 + return that; 1.5202 + }, 155, true).exps = true; 1.5203 + 1.5204 + prefix("(", function () { 1.5205 + nospace(); 1.5206 + var bracket, brackets = []; 1.5207 + var pn, pn1, i = 0; 1.5208 + 1.5209 + do { 1.5210 + pn = peek(i); 1.5211 + i += 1; 1.5212 + pn1 = peek(i); 1.5213 + i += 1; 1.5214 + } while (pn.value !== ")" && pn1.value !== "=>" && pn1.value !== ";" && pn1.type !== "(end)"); 1.5215 + 1.5216 + if (state.tokens.next.id === "function") { 1.5217 + state.tokens.next.immed = true; 1.5218 + } 1.5219 + 1.5220 + var exprs = []; 1.5221 + 1.5222 + if (state.tokens.next.id !== ")") { 1.5223 + for (;;) { 1.5224 + if (pn1.value === "=>" && state.tokens.next.value === "{") { 1.5225 + bracket = state.tokens.next; 1.5226 + bracket.left = destructuringExpression(); 1.5227 + brackets.push(bracket); 1.5228 + for (var t in bracket.left) { 1.5229 + exprs.push(bracket.left[t].token); 1.5230 + } 1.5231 + } else { 1.5232 + exprs.push(expression(5)); 1.5233 + } 1.5234 + if (state.tokens.next.id !== ",") { 1.5235 + break; 1.5236 + } 1.5237 + comma(); 1.5238 + } 1.5239 + } 1.5240 + 1.5241 + advance(")", this); 1.5242 + nospace(state.tokens.prev, state.tokens.curr); 1.5243 + if (state.option.immed && exprs[0] && exprs[0].id === "function") { 1.5244 + if (state.tokens.next.id !== "(" && 1.5245 + (state.tokens.next.id !== "." || (peek().value !== "call" && peek().value !== "apply"))) { 1.5246 + warning("W068", this); 1.5247 + } 1.5248 + } 1.5249 + 1.5250 + if (state.tokens.next.value === "=>") { 1.5251 + return exprs; 1.5252 + } 1.5253 + if (!exprs.length) { 1.5254 + return; 1.5255 + } 1.5256 + exprs[exprs.length - 1].paren = true; 1.5257 + if (exprs.length > 1) { 1.5258 + return Object.create(state.syntax[","], { exprs: { value: exprs } }); 1.5259 + } 1.5260 + return exprs[0]; 1.5261 + }); 1.5262 + 1.5263 + application("=>"); 1.5264 + 1.5265 + infix("[", function (left, that) { 1.5266 + nobreak(state.tokens.prev, state.tokens.curr); 1.5267 + nospace(); 1.5268 + var e = expression(5), s; 1.5269 + if (e && e.type === "(string)") { 1.5270 + if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) { 1.5271 + warning("W061", that); 1.5272 + } 1.5273 + 1.5274 + countMember(e.value); 1.5275 + if (!state.option.sub && reg.identifier.test(e.value)) { 1.5276 + s = state.syntax[e.value]; 1.5277 + if (!s || !isReserved(s)) { 1.5278 + warning("W069", state.tokens.prev, e.value); 1.5279 + } 1.5280 + } 1.5281 + } 1.5282 + advance("]", that); 1.5283 + 1.5284 + if (e && e.value === "hasOwnProperty" && state.tokens.next.value === "=") { 1.5285 + warning("W001"); 1.5286 + } 1.5287 + 1.5288 + nospace(state.tokens.prev, state.tokens.curr); 1.5289 + that.left = left; 1.5290 + that.right = e; 1.5291 + return that; 1.5292 + }, 160, true); 1.5293 + 1.5294 + function comprehensiveArrayExpression() { 1.5295 + var res = {}; 1.5296 + res.exps = true; 1.5297 + funct["(comparray)"].stack(); 1.5298 + 1.5299 + res.right = expression(5); 1.5300 + advance("for"); 1.5301 + if (state.tokens.next.value === "each") { 1.5302 + advance("each"); 1.5303 + if (!state.option.inMoz(true)) { 1.5304 + warning("W118", state.tokens.curr, "for each"); 1.5305 + } 1.5306 + } 1.5307 + advance("("); 1.5308 + funct["(comparray)"].setState("define"); 1.5309 + res.left = expression(5); 1.5310 + advance(")"); 1.5311 + if (state.tokens.next.value === "if") { 1.5312 + advance("if"); 1.5313 + advance("("); 1.5314 + funct["(comparray)"].setState("filter"); 1.5315 + res.filter = expression(5); 1.5316 + advance(")"); 1.5317 + } 1.5318 + advance("]"); 1.5319 + funct["(comparray)"].unstack(); 1.5320 + return res; 1.5321 + } 1.5322 + 1.5323 + prefix("[", function () { 1.5324 + var blocktype = lookupBlockType(true); 1.5325 + if (blocktype.isCompArray) { 1.5326 + if (!state.option.inMoz(true)) { 1.5327 + warning("W118", state.tokens.curr, "array comprehension"); 1.5328 + } 1.5329 + return comprehensiveArrayExpression(); 1.5330 + } else if (blocktype.isDestAssign && !state.option.inESNext()) { 1.5331 + warning("W104", state.tokens.curr, "destructuring assignment"); 1.5332 + } 1.5333 + var b = state.tokens.curr.line !== state.tokens.next.line; 1.5334 + this.first = []; 1.5335 + if (b) { 1.5336 + indent += state.option.indent; 1.5337 + if (state.tokens.next.from === indent + state.option.indent) { 1.5338 + indent += state.option.indent; 1.5339 + } 1.5340 + } 1.5341 + while (state.tokens.next.id !== "(end)") { 1.5342 + while (state.tokens.next.id === ",") { 1.5343 + if (!state.option.inES5()) 1.5344 + warning("W070"); 1.5345 + advance(","); 1.5346 + } 1.5347 + if (state.tokens.next.id === "]") { 1.5348 + break; 1.5349 + } 1.5350 + if (b && state.tokens.curr.line !== state.tokens.next.line) { 1.5351 + indentation(); 1.5352 + } 1.5353 + this.first.push(expression(10)); 1.5354 + if (state.tokens.next.id === ",") { 1.5355 + comma({ allowTrailing: true }); 1.5356 + if (state.tokens.next.id === "]" && !state.option.inES5(true)) { 1.5357 + warning("W070", state.tokens.curr); 1.5358 + break; 1.5359 + } 1.5360 + } else { 1.5361 + break; 1.5362 + } 1.5363 + } 1.5364 + if (b) { 1.5365 + indent -= state.option.indent; 1.5366 + indentation(); 1.5367 + } 1.5368 + advance("]", this); 1.5369 + return this; 1.5370 + }, 160); 1.5371 + 1.5372 + 1.5373 + function property_name() { 1.5374 + var id = optionalidentifier(false, true); 1.5375 + 1.5376 + if (!id) { 1.5377 + if (state.tokens.next.id === "(string)") { 1.5378 + id = state.tokens.next.value; 1.5379 + advance(); 1.5380 + } else if (state.tokens.next.id === "(number)") { 1.5381 + id = state.tokens.next.value.toString(); 1.5382 + advance(); 1.5383 + } 1.5384 + } 1.5385 + 1.5386 + if (id === "hasOwnProperty") { 1.5387 + warning("W001"); 1.5388 + } 1.5389 + 1.5390 + return id; 1.5391 + } 1.5392 + 1.5393 + 1.5394 + function functionparams(parsed) { 1.5395 + var curr, next; 1.5396 + var params = []; 1.5397 + var ident; 1.5398 + var tokens = []; 1.5399 + var t; 1.5400 + 1.5401 + if (parsed) { 1.5402 + if (parsed instanceof Array) { 1.5403 + for (var i in parsed) { 1.5404 + curr = parsed[i]; 1.5405 + if (_.contains(["{", "["], curr.id)) { 1.5406 + for (t in curr.left) { 1.5407 + t = tokens[t]; 1.5408 + if (t.id) { 1.5409 + params.push(t.id); 1.5410 + addlabel(t.id, "unused", t.token); 1.5411 + } 1.5412 + } 1.5413 + } else if (curr.value === "...") { 1.5414 + if (!state.option.inESNext()) { 1.5415 + warning("W104", curr, "spread/rest operator"); 1.5416 + } 1.5417 + continue; 1.5418 + } else { 1.5419 + addlabel(curr.value, "unused", curr); 1.5420 + } 1.5421 + } 1.5422 + return params; 1.5423 + } else { 1.5424 + if (parsed.identifier === true) { 1.5425 + addlabel(parsed.value, "unused", parsed); 1.5426 + return [parsed]; 1.5427 + } 1.5428 + } 1.5429 + } 1.5430 + 1.5431 + next = state.tokens.next; 1.5432 + 1.5433 + advance("("); 1.5434 + nospace(); 1.5435 + 1.5436 + if (state.tokens.next.id === ")") { 1.5437 + advance(")"); 1.5438 + return; 1.5439 + } 1.5440 + 1.5441 + for (;;) { 1.5442 + if (_.contains(["{", "["], state.tokens.next.id)) { 1.5443 + tokens = destructuringExpression(); 1.5444 + for (t in tokens) { 1.5445 + t = tokens[t]; 1.5446 + if (t.id) { 1.5447 + params.push(t.id); 1.5448 + addlabel(t.id, "unused", t.token); 1.5449 + } 1.5450 + } 1.5451 + } else if (state.tokens.next.value === "...") { 1.5452 + if (!state.option.inESNext()) { 1.5453 + warning("W104", state.tokens.next, "spread/rest operator"); 1.5454 + } 1.5455 + advance("..."); 1.5456 + nospace(); 1.5457 + ident = identifier(true); 1.5458 + params.push(ident); 1.5459 + addlabel(ident, "unused", state.tokens.curr); 1.5460 + } else { 1.5461 + ident = identifier(true); 1.5462 + params.push(ident); 1.5463 + addlabel(ident, "unused", state.tokens.curr); 1.5464 + } 1.5465 + if (state.tokens.next.id === ",") { 1.5466 + comma(); 1.5467 + } else { 1.5468 + advance(")", next); 1.5469 + nospace(state.tokens.prev, state.tokens.curr); 1.5470 + return params; 1.5471 + } 1.5472 + } 1.5473 + } 1.5474 + 1.5475 + 1.5476 + function doFunction(name, statement, generator, fatarrowparams) { 1.5477 + var f; 1.5478 + var oldOption = state.option; 1.5479 + var oldIgnored = state.ignored; 1.5480 + var oldScope = scope; 1.5481 + 1.5482 + state.option = Object.create(state.option); 1.5483 + state.ignored = Object.create(state.ignored); 1.5484 + scope = Object.create(scope); 1.5485 + 1.5486 + funct = { 1.5487 + "(name)" : name || "\"" + anonname + "\"", 1.5488 + "(line)" : state.tokens.next.line, 1.5489 + "(character)" : state.tokens.next.character, 1.5490 + "(context)" : funct, 1.5491 + "(breakage)" : 0, 1.5492 + "(loopage)" : 0, 1.5493 + "(metrics)" : createMetrics(state.tokens.next), 1.5494 + "(scope)" : scope, 1.5495 + "(statement)" : statement, 1.5496 + "(tokens)" : {}, 1.5497 + "(blockscope)": funct["(blockscope)"], 1.5498 + "(comparray)" : funct["(comparray)"] 1.5499 + }; 1.5500 + 1.5501 + if (generator) { 1.5502 + funct["(generator)"] = true; 1.5503 + } 1.5504 + 1.5505 + f = funct; 1.5506 + state.tokens.curr.funct = funct; 1.5507 + 1.5508 + functions.push(funct); 1.5509 + 1.5510 + if (name) { 1.5511 + addlabel(name, "function"); 1.5512 + } 1.5513 + 1.5514 + funct["(params)"] = functionparams(fatarrowparams); 1.5515 + 1.5516 + funct["(metrics)"].verifyMaxParametersPerFunction(funct["(params)"]); 1.5517 + 1.5518 + block(false, true, true, fatarrowparams ? true:false); 1.5519 + 1.5520 + if (generator && funct["(generator)"] !== "yielded") { 1.5521 + error("E047", state.tokens.curr); 1.5522 + } 1.5523 + 1.5524 + funct["(metrics)"].verifyMaxStatementsPerFunction(); 1.5525 + funct["(metrics)"].verifyMaxComplexityPerFunction(); 1.5526 + funct["(unusedOption)"] = state.option.unused; 1.5527 + 1.5528 + scope = oldScope; 1.5529 + state.option = oldOption; 1.5530 + state.ignored = oldIgnored; 1.5531 + funct["(last)"] = state.tokens.curr.line; 1.5532 + funct["(lastcharacter)"] = state.tokens.curr.character; 1.5533 + funct = funct["(context)"]; 1.5534 + 1.5535 + return f; 1.5536 + } 1.5537 + 1.5538 + function createMetrics(functionStartToken) { 1.5539 + return { 1.5540 + statementCount: 0, 1.5541 + nestedBlockDepth: -1, 1.5542 + ComplexityCount: 1, 1.5543 + verifyMaxStatementsPerFunction: function () { 1.5544 + if (state.option.maxstatements && 1.5545 + this.statementCount > state.option.maxstatements) { 1.5546 + warning("W071", functionStartToken, this.statementCount); 1.5547 + } 1.5548 + }, 1.5549 + 1.5550 + verifyMaxParametersPerFunction: function (params) { 1.5551 + params = params || []; 1.5552 + 1.5553 + if (state.option.maxparams && params.length > state.option.maxparams) { 1.5554 + warning("W072", functionStartToken, params.length); 1.5555 + } 1.5556 + }, 1.5557 + 1.5558 + verifyMaxNestedBlockDepthPerFunction: function () { 1.5559 + if (state.option.maxdepth && 1.5560 + this.nestedBlockDepth > 0 && 1.5561 + this.nestedBlockDepth === state.option.maxdepth + 1) { 1.5562 + warning("W073", null, this.nestedBlockDepth); 1.5563 + } 1.5564 + }, 1.5565 + 1.5566 + verifyMaxComplexityPerFunction: function () { 1.5567 + var max = state.option.maxcomplexity; 1.5568 + var cc = this.ComplexityCount; 1.5569 + if (max && cc > max) { 1.5570 + warning("W074", functionStartToken, cc); 1.5571 + } 1.5572 + } 1.5573 + }; 1.5574 + } 1.5575 + 1.5576 + function increaseComplexityCount() { 1.5577 + funct["(metrics)"].ComplexityCount += 1; 1.5578 + } 1.5579 + 1.5580 + // Parse assignments that were found instead of conditionals. 1.5581 + // For example: if (a = 1) { ... } 1.5582 + 1.5583 + function checkCondAssignment(expr) { 1.5584 + var id = expr.id; 1.5585 + if (id === ",") { 1.5586 + expr = expr.exprs[expr.exprs.length - 1]; 1.5587 + id = expr.id; 1.5588 + } 1.5589 + switch (id) { 1.5590 + case "=": 1.5591 + case "+=": 1.5592 + case "-=": 1.5593 + case "*=": 1.5594 + case "%=": 1.5595 + case "&=": 1.5596 + case "|=": 1.5597 + case "^=": 1.5598 + case "/=": 1.5599 + if (!expr.paren && !state.option.boss) { 1.5600 + warning("W084"); 1.5601 + } 1.5602 + } 1.5603 + } 1.5604 + 1.5605 + 1.5606 + (function (x) { 1.5607 + x.nud = function (isclassdef) { 1.5608 + var b, f, i, p, t, g; 1.5609 + var props = {}; // All properties, including accessors 1.5610 + var tag = ""; 1.5611 + 1.5612 + function saveProperty(name, tkn) { 1.5613 + if (props[name] && _.has(props, name)) 1.5614 + warning("W075", state.tokens.next, i); 1.5615 + else 1.5616 + props[name] = {}; 1.5617 + 1.5618 + props[name].basic = true; 1.5619 + props[name].basictkn = tkn; 1.5620 + } 1.5621 + 1.5622 + function saveSetter(name, tkn) { 1.5623 + if (props[name] && _.has(props, name)) { 1.5624 + if (props[name].basic || props[name].setter) 1.5625 + warning("W075", state.tokens.next, i); 1.5626 + } else { 1.5627 + props[name] = {}; 1.5628 + } 1.5629 + 1.5630 + props[name].setter = true; 1.5631 + props[name].setterToken = tkn; 1.5632 + } 1.5633 + 1.5634 + function saveGetter(name) { 1.5635 + if (props[name] && _.has(props, name)) { 1.5636 + if (props[name].basic || props[name].getter) 1.5637 + warning("W075", state.tokens.next, i); 1.5638 + } else { 1.5639 + props[name] = {}; 1.5640 + } 1.5641 + 1.5642 + props[name].getter = true; 1.5643 + props[name].getterToken = state.tokens.curr; 1.5644 + } 1.5645 + 1.5646 + b = state.tokens.curr.line !== state.tokens.next.line; 1.5647 + if (b) { 1.5648 + indent += state.option.indent; 1.5649 + if (state.tokens.next.from === indent + state.option.indent) { 1.5650 + indent += state.option.indent; 1.5651 + } 1.5652 + } 1.5653 + 1.5654 + for (;;) { 1.5655 + if (state.tokens.next.id === "}") { 1.5656 + break; 1.5657 + } 1.5658 + 1.5659 + if (b) { 1.5660 + indentation(); 1.5661 + } 1.5662 + 1.5663 + if (isclassdef && state.tokens.next.value === "static") { 1.5664 + advance("static"); 1.5665 + tag = "static "; 1.5666 + } 1.5667 + 1.5668 + if (state.tokens.next.value === "get" && peek().id !== ":") { 1.5669 + advance("get"); 1.5670 + 1.5671 + if (!state.option.inES5(!isclassdef)) { 1.5672 + error("E034"); 1.5673 + } 1.5674 + 1.5675 + i = property_name(); 1.5676 + if (!i) { 1.5677 + error("E035"); 1.5678 + } 1.5679 + 1.5680 + // It is a Syntax Error if PropName of MethodDefinition is 1.5681 + // "constructor" and SpecialMethod of MethodDefinition is true. 1.5682 + if (isclassdef && i === "constructor") { 1.5683 + error("E049", state.tokens.next, "class getter method", i); 1.5684 + } 1.5685 + 1.5686 + saveGetter(tag + i); 1.5687 + t = state.tokens.next; 1.5688 + adjacent(state.tokens.curr, state.tokens.next); 1.5689 + f = doFunction(); 1.5690 + p = f["(params)"]; 1.5691 + 1.5692 + if (p) { 1.5693 + warning("W076", t, p[0], i); 1.5694 + } 1.5695 + 1.5696 + adjacent(state.tokens.curr, state.tokens.next); 1.5697 + } else if (state.tokens.next.value === "set" && peek().id !== ":") { 1.5698 + advance("set"); 1.5699 + 1.5700 + if (!state.option.inES5(!isclassdef)) { 1.5701 + error("E034"); 1.5702 + } 1.5703 + 1.5704 + i = property_name(); 1.5705 + if (!i) { 1.5706 + error("E035"); 1.5707 + } 1.5708 + 1.5709 + // It is a Syntax Error if PropName of MethodDefinition is 1.5710 + // "constructor" and SpecialMethod of MethodDefinition is true. 1.5711 + if (isclassdef && i === "constructor") { 1.5712 + error("E049", state.tokens.next, "class setter method", i); 1.5713 + } 1.5714 + 1.5715 + saveSetter(tag + i, state.tokens.next); 1.5716 + t = state.tokens.next; 1.5717 + adjacent(state.tokens.curr, state.tokens.next); 1.5718 + f = doFunction(); 1.5719 + p = f["(params)"]; 1.5720 + 1.5721 + if (!p || p.length !== 1) { 1.5722 + warning("W077", t, i); 1.5723 + } 1.5724 + } else { 1.5725 + g = false; 1.5726 + if (state.tokens.next.value === "*" && state.tokens.next.type === "(punctuator)") { 1.5727 + if (!state.option.inESNext()) { 1.5728 + warning("W104", state.tokens.next, "generator functions"); 1.5729 + } 1.5730 + advance("*"); 1.5731 + g = true; 1.5732 + } 1.5733 + i = property_name(); 1.5734 + saveProperty(tag + i, state.tokens.next); 1.5735 + 1.5736 + if (typeof i !== "string") { 1.5737 + break; 1.5738 + } 1.5739 + 1.5740 + if (state.tokens.next.value === "(") { 1.5741 + if (!state.option.inESNext()) { 1.5742 + warning("W104", state.tokens.curr, "concise methods"); 1.5743 + } 1.5744 + doFunction(i, undefined, g); 1.5745 + } else if (!isclassdef) { 1.5746 + advance(":"); 1.5747 + nonadjacent(state.tokens.curr, state.tokens.next); 1.5748 + expression(10); 1.5749 + } 1.5750 + } 1.5751 + // It is a Syntax Error if PropName of MethodDefinition is "prototype". 1.5752 + if (isclassdef && i === "prototype") { 1.5753 + error("E049", state.tokens.next, "class method", i); 1.5754 + } 1.5755 + 1.5756 + countMember(i); 1.5757 + if (isclassdef) { 1.5758 + tag = ""; 1.5759 + continue; 1.5760 + } 1.5761 + if (state.tokens.next.id === ",") { 1.5762 + comma({ allowTrailing: true, property: true }); 1.5763 + if (state.tokens.next.id === ",") { 1.5764 + warning("W070", state.tokens.curr); 1.5765 + } else if (state.tokens.next.id === "}" && !state.option.inES5(true)) { 1.5766 + warning("W070", state.tokens.curr); 1.5767 + } 1.5768 + } else { 1.5769 + break; 1.5770 + } 1.5771 + } 1.5772 + if (b) { 1.5773 + indent -= state.option.indent; 1.5774 + indentation(); 1.5775 + } 1.5776 + advance("}", this); 1.5777 + 1.5778 + // Check for lonely setters if in the ES5 mode. 1.5779 + if (state.option.inES5()) { 1.5780 + for (var name in props) { 1.5781 + if (_.has(props, name) && props[name].setter && !props[name].getter) { 1.5782 + warning("W078", props[name].setterToken); 1.5783 + } 1.5784 + } 1.5785 + } 1.5786 + return this; 1.5787 + }; 1.5788 + x.fud = function () { 1.5789 + error("E036", state.tokens.curr); 1.5790 + }; 1.5791 + }(delim("{"))); 1.5792 + 1.5793 + function destructuringExpression() { 1.5794 + var id, ids; 1.5795 + var identifiers = []; 1.5796 + if (!state.option.inESNext()) { 1.5797 + warning("W104", state.tokens.curr, "destructuring expression"); 1.5798 + } 1.5799 + var nextInnerDE = function () { 1.5800 + var ident; 1.5801 + if (_.contains(["[", "{"], state.tokens.next.value)) { 1.5802 + ids = destructuringExpression(); 1.5803 + for (var id in ids) { 1.5804 + id = ids[id]; 1.5805 + identifiers.push({ id: id.id, token: id.token }); 1.5806 + } 1.5807 + } else if (state.tokens.next.value === ",") { 1.5808 + identifiers.push({ id: null, token: state.tokens.curr }); 1.5809 + } else { 1.5810 + ident = identifier(); 1.5811 + if (ident) 1.5812 + identifiers.push({ id: ident, token: state.tokens.curr }); 1.5813 + } 1.5814 + }; 1.5815 + if (state.tokens.next.value === "[") { 1.5816 + advance("["); 1.5817 + nextInnerDE(); 1.5818 + while (state.tokens.next.value !== "]") { 1.5819 + advance(","); 1.5820 + nextInnerDE(); 1.5821 + } 1.5822 + advance("]"); 1.5823 + } else if (state.tokens.next.value === "{") { 1.5824 + advance("{"); 1.5825 + id = identifier(); 1.5826 + if (state.tokens.next.value === ":") { 1.5827 + advance(":"); 1.5828 + nextInnerDE(); 1.5829 + } else { 1.5830 + identifiers.push({ id: id, token: state.tokens.curr }); 1.5831 + } 1.5832 + while (state.tokens.next.value !== "}") { 1.5833 + advance(","); 1.5834 + id = identifier(); 1.5835 + if (state.tokens.next.value === ":") { 1.5836 + advance(":"); 1.5837 + nextInnerDE(); 1.5838 + } else { 1.5839 + identifiers.push({ id: id, token: state.tokens.curr }); 1.5840 + } 1.5841 + } 1.5842 + advance("}"); 1.5843 + } 1.5844 + return identifiers; 1.5845 + } 1.5846 + function destructuringExpressionMatch(tokens, value) { 1.5847 + if (value.first) { 1.5848 + _.zip(tokens, value.first).forEach(function (val) { 1.5849 + var token = val[0]; 1.5850 + var value = val[1]; 1.5851 + if (token && value) { 1.5852 + token.first = value; 1.5853 + } else if (token && token.first && !value) { 1.5854 + warning("W080", token.first, token.first.value); 1.5855 + } /* else { 1.5856 + XXX value is discarded: wouldn't it need a warning ? 1.5857 + } */ 1.5858 + }); 1.5859 + } 1.5860 + } 1.5861 + 1.5862 + var conststatement = stmt("const", function (prefix) { 1.5863 + var tokens, value; 1.5864 + // state variable to know if it is a lone identifier, or a destructuring statement. 1.5865 + var lone; 1.5866 + 1.5867 + if (!state.option.inESNext()) { 1.5868 + warning("W104", state.tokens.curr, "const"); 1.5869 + } 1.5870 + 1.5871 + this.first = []; 1.5872 + for (;;) { 1.5873 + var names = []; 1.5874 + nonadjacent(state.tokens.curr, state.tokens.next); 1.5875 + if (_.contains(["{", "["], state.tokens.next.value)) { 1.5876 + tokens = destructuringExpression(); 1.5877 + lone = false; 1.5878 + } else { 1.5879 + tokens = [ { id: identifier(), token: state.tokens.curr } ]; 1.5880 + lone = true; 1.5881 + } 1.5882 + for (var t in tokens) { 1.5883 + t = tokens[t]; 1.5884 + if (funct[t.id] === "const") { 1.5885 + warning("E011", null, t.id); 1.5886 + } 1.5887 + if (funct["(global)"] && predefined[t.id] === false) { 1.5888 + warning("W079", t.token, t.id); 1.5889 + } 1.5890 + if (t.id) { 1.5891 + addlabel(t.id, "const"); 1.5892 + names.push(t.token); 1.5893 + } 1.5894 + } 1.5895 + if (prefix) { 1.5896 + break; 1.5897 + } 1.5898 + 1.5899 + this.first = this.first.concat(names); 1.5900 + 1.5901 + if (state.tokens.next.id !== "=") { 1.5902 + warning("E012", state.tokens.curr, state.tokens.curr.value); 1.5903 + } 1.5904 + 1.5905 + if (state.tokens.next.id === "=") { 1.5906 + nonadjacent(state.tokens.curr, state.tokens.next); 1.5907 + advance("="); 1.5908 + nonadjacent(state.tokens.curr, state.tokens.next); 1.5909 + if (state.tokens.next.id === "undefined") { 1.5910 + warning("W080", state.tokens.prev, state.tokens.prev.value); 1.5911 + } 1.5912 + if (peek(0).id === "=" && state.tokens.next.identifier) { 1.5913 + error("E037", state.tokens.next, state.tokens.next.value); 1.5914 + } 1.5915 + value = expression(5); 1.5916 + if (lone) { 1.5917 + tokens[0].first = value; 1.5918 + } else { 1.5919 + destructuringExpressionMatch(names, value); 1.5920 + } 1.5921 + } 1.5922 + 1.5923 + if (state.tokens.next.id !== ",") { 1.5924 + break; 1.5925 + } 1.5926 + comma(); 1.5927 + } 1.5928 + return this; 1.5929 + }); 1.5930 + conststatement.exps = true; 1.5931 + var varstatement = stmt("var", function (prefix) { 1.5932 + // JavaScript does not have block scope. It only has function scope. So, 1.5933 + // declaring a variable in a block can have unexpected consequences. 1.5934 + var tokens, lone, value; 1.5935 + 1.5936 + if (funct["(onevar)"] && state.option.onevar) { 1.5937 + warning("W081"); 1.5938 + } else if (!funct["(global)"]) { 1.5939 + funct["(onevar)"] = true; 1.5940 + } 1.5941 + 1.5942 + this.first = []; 1.5943 + for (;;) { 1.5944 + var names = []; 1.5945 + nonadjacent(state.tokens.curr, state.tokens.next); 1.5946 + if (_.contains(["{", "["], state.tokens.next.value)) { 1.5947 + tokens = destructuringExpression(); 1.5948 + lone = false; 1.5949 + } else { 1.5950 + tokens = [ { id: identifier(), token: state.tokens.curr } ]; 1.5951 + lone = true; 1.5952 + } 1.5953 + for (var t in tokens) { 1.5954 + t = tokens[t]; 1.5955 + if (state.option.inESNext() && funct[t.id] === "const") { 1.5956 + warning("E011", null, t.id); 1.5957 + } 1.5958 + if (funct["(global)"] && predefined[t.id] === false) { 1.5959 + warning("W079", t.token, t.id); 1.5960 + } 1.5961 + if (t.id) { 1.5962 + addlabel(t.id, "unused", t.token); 1.5963 + names.push(t.token); 1.5964 + } 1.5965 + } 1.5966 + if (prefix) { 1.5967 + break; 1.5968 + } 1.5969 + 1.5970 + this.first = this.first.concat(names); 1.5971 + 1.5972 + if (state.tokens.next.id === "=") { 1.5973 + nonadjacent(state.tokens.curr, state.tokens.next); 1.5974 + advance("="); 1.5975 + nonadjacent(state.tokens.curr, state.tokens.next); 1.5976 + if (state.tokens.next.id === "undefined") { 1.5977 + warning("W080", state.tokens.prev, state.tokens.prev.value); 1.5978 + } 1.5979 + if (peek(0).id === "=" && state.tokens.next.identifier) { 1.5980 + error("E038", state.tokens.next, state.tokens.next.value); 1.5981 + } 1.5982 + value = expression(5); 1.5983 + if (lone) { 1.5984 + tokens[0].first = value; 1.5985 + } else { 1.5986 + destructuringExpressionMatch(names, value); 1.5987 + } 1.5988 + } 1.5989 + 1.5990 + if (state.tokens.next.id !== ",") { 1.5991 + break; 1.5992 + } 1.5993 + comma(); 1.5994 + } 1.5995 + return this; 1.5996 + }); 1.5997 + varstatement.exps = true; 1.5998 + var letstatement = stmt("let", function (prefix) { 1.5999 + var tokens, lone, value, letblock; 1.6000 + 1.6001 + if (!state.option.inESNext()) { 1.6002 + warning("W104", state.tokens.curr, "let"); 1.6003 + } 1.6004 + 1.6005 + if (state.tokens.next.value === "(") { 1.6006 + if (!state.option.inMoz(true)) { 1.6007 + warning("W118", state.tokens.next, "let block"); 1.6008 + } 1.6009 + advance("("); 1.6010 + funct["(blockscope)"].stack(); 1.6011 + letblock = true; 1.6012 + } else if (funct["(nolet)"]) { 1.6013 + error("E048", state.tokens.curr); 1.6014 + } 1.6015 + 1.6016 + if (funct["(onevar)"] && state.option.onevar) { 1.6017 + warning("W081"); 1.6018 + } else if (!funct["(global)"]) { 1.6019 + funct["(onevar)"] = true; 1.6020 + } 1.6021 + 1.6022 + this.first = []; 1.6023 + for (;;) { 1.6024 + var names = []; 1.6025 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6026 + if (_.contains(["{", "["], state.tokens.next.value)) { 1.6027 + tokens = destructuringExpression(); 1.6028 + lone = false; 1.6029 + } else { 1.6030 + tokens = [ { id: identifier(), token: state.tokens.curr.value } ]; 1.6031 + lone = true; 1.6032 + } 1.6033 + for (var t in tokens) { 1.6034 + t = tokens[t]; 1.6035 + if (state.option.inESNext() && funct[t.id] === "const") { 1.6036 + warning("E011", null, t.id); 1.6037 + } 1.6038 + if (funct["(global)"] && predefined[t.id] === false) { 1.6039 + warning("W079", t.token, t.id); 1.6040 + } 1.6041 + if (t.id && !funct["(nolet)"]) { 1.6042 + addlabel(t.id, "unused", t.token, true); 1.6043 + names.push(t.token); 1.6044 + } 1.6045 + } 1.6046 + if (prefix) { 1.6047 + break; 1.6048 + } 1.6049 + 1.6050 + this.first = this.first.concat(names); 1.6051 + 1.6052 + if (state.tokens.next.id === "=") { 1.6053 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6054 + advance("="); 1.6055 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6056 + if (state.tokens.next.id === "undefined") { 1.6057 + warning("W080", state.tokens.prev, state.tokens.prev.value); 1.6058 + } 1.6059 + if (peek(0).id === "=" && state.tokens.next.identifier) { 1.6060 + error("E037", state.tokens.next, state.tokens.next.value); 1.6061 + } 1.6062 + value = expression(5); 1.6063 + if (lone) { 1.6064 + tokens[0].first = value; 1.6065 + } else { 1.6066 + destructuringExpressionMatch(names, value); 1.6067 + } 1.6068 + } 1.6069 + 1.6070 + if (state.tokens.next.id !== ",") { 1.6071 + break; 1.6072 + } 1.6073 + comma(); 1.6074 + } 1.6075 + if (letblock) { 1.6076 + advance(")"); 1.6077 + block(true, true); 1.6078 + this.block = true; 1.6079 + funct["(blockscope)"].unstack(); 1.6080 + } 1.6081 + 1.6082 + return this; 1.6083 + }); 1.6084 + letstatement.exps = true; 1.6085 + 1.6086 + blockstmt("class", function () { 1.6087 + return classdef.call(this, true); 1.6088 + }); 1.6089 + 1.6090 + function classdef(stmt) { 1.6091 + /*jshint validthis:true */ 1.6092 + if (!state.option.inESNext()) { 1.6093 + warning("W104", state.tokens.curr, "class"); 1.6094 + } 1.6095 + if (stmt) { 1.6096 + // BindingIdentifier 1.6097 + this.name = identifier(); 1.6098 + addlabel(this.name, "unused", state.tokens.curr); 1.6099 + } else if (state.tokens.next.identifier && state.tokens.next.value !== "extends") { 1.6100 + // BindingIdentifier(opt) 1.6101 + this.name = identifier(); 1.6102 + } 1.6103 + classtail(this); 1.6104 + return this; 1.6105 + } 1.6106 + 1.6107 + function classtail(c) { 1.6108 + var strictness = state.directive["use strict"]; 1.6109 + 1.6110 + // ClassHeritage(opt) 1.6111 + if (state.tokens.next.value === "extends") { 1.6112 + advance("extends"); 1.6113 + c.heritage = expression(10); 1.6114 + } 1.6115 + 1.6116 + // A ClassBody is always strict code. 1.6117 + state.directive["use strict"] = true; 1.6118 + advance("{"); 1.6119 + // ClassBody(opt) 1.6120 + c.body = state.syntax["{"].nud(true); 1.6121 + state.directive["use strict"] = strictness; 1.6122 + } 1.6123 + 1.6124 + blockstmt("function", function () { 1.6125 + var generator = false; 1.6126 + if (state.tokens.next.value === "*") { 1.6127 + advance("*"); 1.6128 + if (state.option.inESNext(true)) { 1.6129 + generator = true; 1.6130 + } else { 1.6131 + warning("W119", state.tokens.curr, "function*"); 1.6132 + } 1.6133 + } 1.6134 + if (inblock) { 1.6135 + warning("W082", state.tokens.curr); 1.6136 + 1.6137 + } 1.6138 + var i = identifier(); 1.6139 + if (funct[i] === "const") { 1.6140 + warning("E011", null, i); 1.6141 + } 1.6142 + adjacent(state.tokens.curr, state.tokens.next); 1.6143 + addlabel(i, "unction", state.tokens.curr); 1.6144 + 1.6145 + doFunction(i, { statement: true }, generator); 1.6146 + if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) { 1.6147 + error("E039"); 1.6148 + } 1.6149 + return this; 1.6150 + }); 1.6151 + 1.6152 + prefix("function", function () { 1.6153 + var generator = false; 1.6154 + if (state.tokens.next.value === "*") { 1.6155 + if (!state.option.inESNext()) { 1.6156 + warning("W119", state.tokens.curr, "function*"); 1.6157 + } 1.6158 + advance("*"); 1.6159 + generator = true; 1.6160 + } 1.6161 + var i = optionalidentifier(); 1.6162 + if (i || state.option.gcl) { 1.6163 + adjacent(state.tokens.curr, state.tokens.next); 1.6164 + } else { 1.6165 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6166 + } 1.6167 + doFunction(i, undefined, generator); 1.6168 + if (!state.option.loopfunc && funct["(loopage)"]) { 1.6169 + warning("W083"); 1.6170 + } 1.6171 + return this; 1.6172 + }); 1.6173 + 1.6174 + blockstmt("if", function () { 1.6175 + var t = state.tokens.next; 1.6176 + increaseComplexityCount(); 1.6177 + state.condition = true; 1.6178 + advance("("); 1.6179 + nonadjacent(this, t); 1.6180 + nospace(); 1.6181 + checkCondAssignment(expression(0)); 1.6182 + advance(")", t); 1.6183 + state.condition = false; 1.6184 + nospace(state.tokens.prev, state.tokens.curr); 1.6185 + block(true, true); 1.6186 + if (state.tokens.next.id === "else") { 1.6187 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6188 + advance("else"); 1.6189 + if (state.tokens.next.id === "if" || state.tokens.next.id === "switch") { 1.6190 + statement(true); 1.6191 + } else { 1.6192 + block(true, true); 1.6193 + } 1.6194 + } 1.6195 + return this; 1.6196 + }); 1.6197 + 1.6198 + blockstmt("try", function () { 1.6199 + var b; 1.6200 + 1.6201 + function doCatch() { 1.6202 + var oldScope = scope; 1.6203 + var e; 1.6204 + 1.6205 + advance("catch"); 1.6206 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6207 + advance("("); 1.6208 + 1.6209 + scope = Object.create(oldScope); 1.6210 + 1.6211 + e = state.tokens.next.value; 1.6212 + if (state.tokens.next.type !== "(identifier)") { 1.6213 + e = null; 1.6214 + warning("E030", state.tokens.next, e); 1.6215 + } 1.6216 + 1.6217 + advance(); 1.6218 + 1.6219 + funct = { 1.6220 + "(name)" : "(catch)", 1.6221 + "(line)" : state.tokens.next.line, 1.6222 + "(character)": state.tokens.next.character, 1.6223 + "(context)" : funct, 1.6224 + "(breakage)" : funct["(breakage)"], 1.6225 + "(loopage)" : funct["(loopage)"], 1.6226 + "(scope)" : scope, 1.6227 + "(statement)": false, 1.6228 + "(metrics)" : createMetrics(state.tokens.next), 1.6229 + "(catch)" : true, 1.6230 + "(tokens)" : {}, 1.6231 + "(blockscope)": funct["(blockscope)"], 1.6232 + "(comparray)": funct["(comparray)"] 1.6233 + }; 1.6234 + 1.6235 + if (e) { 1.6236 + addlabel(e, "exception"); 1.6237 + } 1.6238 + 1.6239 + if (state.tokens.next.value === "if") { 1.6240 + if (!state.option.inMoz(true)) { 1.6241 + warning("W118", state.tokens.curr, "catch filter"); 1.6242 + } 1.6243 + advance("if"); 1.6244 + expression(0); 1.6245 + } 1.6246 + 1.6247 + advance(")"); 1.6248 + 1.6249 + state.tokens.curr.funct = funct; 1.6250 + functions.push(funct); 1.6251 + 1.6252 + block(false); 1.6253 + 1.6254 + scope = oldScope; 1.6255 + 1.6256 + funct["(last)"] = state.tokens.curr.line; 1.6257 + funct["(lastcharacter)"] = state.tokens.curr.character; 1.6258 + funct = funct["(context)"]; 1.6259 + } 1.6260 + 1.6261 + block(false); 1.6262 + 1.6263 + while (state.tokens.next.id === "catch") { 1.6264 + increaseComplexityCount(); 1.6265 + if (b && (!state.option.inMoz(true))) { 1.6266 + warning("W118", state.tokens.next, "multiple catch blocks"); 1.6267 + } 1.6268 + doCatch(); 1.6269 + b = true; 1.6270 + } 1.6271 + 1.6272 + if (state.tokens.next.id === "finally") { 1.6273 + advance("finally"); 1.6274 + block(false); 1.6275 + return; 1.6276 + } 1.6277 + 1.6278 + if (!b) { 1.6279 + error("E021", state.tokens.next, "catch", state.tokens.next.value); 1.6280 + } 1.6281 + 1.6282 + return this; 1.6283 + }); 1.6284 + 1.6285 + blockstmt("while", function () { 1.6286 + var t = state.tokens.next; 1.6287 + funct["(breakage)"] += 1; 1.6288 + funct["(loopage)"] += 1; 1.6289 + increaseComplexityCount(); 1.6290 + advance("("); 1.6291 + nonadjacent(this, t); 1.6292 + nospace(); 1.6293 + checkCondAssignment(expression(0)); 1.6294 + advance(")", t); 1.6295 + nospace(state.tokens.prev, state.tokens.curr); 1.6296 + block(true, true); 1.6297 + funct["(breakage)"] -= 1; 1.6298 + funct["(loopage)"] -= 1; 1.6299 + return this; 1.6300 + }).labelled = true; 1.6301 + 1.6302 + blockstmt("with", function () { 1.6303 + var t = state.tokens.next; 1.6304 + if (state.directive["use strict"]) { 1.6305 + error("E010", state.tokens.curr); 1.6306 + } else if (!state.option.withstmt) { 1.6307 + warning("W085", state.tokens.curr); 1.6308 + } 1.6309 + 1.6310 + advance("("); 1.6311 + nonadjacent(this, t); 1.6312 + nospace(); 1.6313 + expression(0); 1.6314 + advance(")", t); 1.6315 + nospace(state.tokens.prev, state.tokens.curr); 1.6316 + block(true, true); 1.6317 + 1.6318 + return this; 1.6319 + }); 1.6320 + 1.6321 + blockstmt("switch", function () { 1.6322 + var t = state.tokens.next, 1.6323 + g = false; 1.6324 + funct["(breakage)"] += 1; 1.6325 + advance("("); 1.6326 + nonadjacent(this, t); 1.6327 + nospace(); 1.6328 + checkCondAssignment(expression(0)); 1.6329 + advance(")", t); 1.6330 + nospace(state.tokens.prev, state.tokens.curr); 1.6331 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6332 + t = state.tokens.next; 1.6333 + advance("{"); 1.6334 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6335 + indent += state.option.indent; 1.6336 + this.cases = []; 1.6337 + 1.6338 + for (;;) { 1.6339 + switch (state.tokens.next.id) { 1.6340 + case "case": 1.6341 + switch (funct["(verb)"]) { 1.6342 + case "yield": 1.6343 + case "break": 1.6344 + case "case": 1.6345 + case "continue": 1.6346 + case "return": 1.6347 + case "switch": 1.6348 + case "throw": 1.6349 + break; 1.6350 + default: 1.6351 + // You can tell JSHint that you don't use break intentionally by 1.6352 + // adding a comment /* falls through */ on a line just before 1.6353 + // the next `case`. 1.6354 + if (!reg.fallsThrough.test(state.lines[state.tokens.next.line - 2])) { 1.6355 + warning("W086", state.tokens.curr, "case"); 1.6356 + } 1.6357 + } 1.6358 + indentation(-state.option.indent); 1.6359 + advance("case"); 1.6360 + this.cases.push(expression(20)); 1.6361 + increaseComplexityCount(); 1.6362 + g = true; 1.6363 + advance(":"); 1.6364 + funct["(verb)"] = "case"; 1.6365 + break; 1.6366 + case "default": 1.6367 + switch (funct["(verb)"]) { 1.6368 + case "yield": 1.6369 + case "break": 1.6370 + case "continue": 1.6371 + case "return": 1.6372 + case "throw": 1.6373 + break; 1.6374 + default: 1.6375 + // Do not display a warning if 'default' is the first statement or if 1.6376 + // there is a special /* falls through */ comment. 1.6377 + if (this.cases.length) { 1.6378 + if (!reg.fallsThrough.test(state.lines[state.tokens.next.line - 2])) { 1.6379 + warning("W086", state.tokens.curr, "default"); 1.6380 + } 1.6381 + } 1.6382 + } 1.6383 + indentation(-state.option.indent); 1.6384 + advance("default"); 1.6385 + g = true; 1.6386 + advance(":"); 1.6387 + break; 1.6388 + case "}": 1.6389 + indent -= state.option.indent; 1.6390 + indentation(); 1.6391 + advance("}", t); 1.6392 + funct["(breakage)"] -= 1; 1.6393 + funct["(verb)"] = undefined; 1.6394 + return; 1.6395 + case "(end)": 1.6396 + error("E023", state.tokens.next, "}"); 1.6397 + return; 1.6398 + default: 1.6399 + if (g) { 1.6400 + switch (state.tokens.curr.id) { 1.6401 + case ",": 1.6402 + error("E040"); 1.6403 + return; 1.6404 + case ":": 1.6405 + g = false; 1.6406 + statements(); 1.6407 + break; 1.6408 + default: 1.6409 + error("E025", state.tokens.curr); 1.6410 + return; 1.6411 + } 1.6412 + } else { 1.6413 + if (state.tokens.curr.id === ":") { 1.6414 + advance(":"); 1.6415 + error("E024", state.tokens.curr, ":"); 1.6416 + statements(); 1.6417 + } else { 1.6418 + error("E021", state.tokens.next, "case", state.tokens.next.value); 1.6419 + return; 1.6420 + } 1.6421 + } 1.6422 + } 1.6423 + } 1.6424 + }).labelled = true; 1.6425 + 1.6426 + stmt("debugger", function () { 1.6427 + if (!state.option.debug) { 1.6428 + warning("W087"); 1.6429 + } 1.6430 + return this; 1.6431 + }).exps = true; 1.6432 + 1.6433 + (function () { 1.6434 + var x = stmt("do", function () { 1.6435 + funct["(breakage)"] += 1; 1.6436 + funct["(loopage)"] += 1; 1.6437 + increaseComplexityCount(); 1.6438 + 1.6439 + this.first = block(true, true); 1.6440 + advance("while"); 1.6441 + var t = state.tokens.next; 1.6442 + nonadjacent(state.tokens.curr, t); 1.6443 + advance("("); 1.6444 + nospace(); 1.6445 + checkCondAssignment(expression(0)); 1.6446 + advance(")", t); 1.6447 + nospace(state.tokens.prev, state.tokens.curr); 1.6448 + funct["(breakage)"] -= 1; 1.6449 + funct["(loopage)"] -= 1; 1.6450 + return this; 1.6451 + }); 1.6452 + x.labelled = true; 1.6453 + x.exps = true; 1.6454 + }()); 1.6455 + 1.6456 + blockstmt("for", function () { 1.6457 + var s, t = state.tokens.next; 1.6458 + var letscope = false; 1.6459 + var foreachtok = null; 1.6460 + 1.6461 + if (t.value === "each") { 1.6462 + foreachtok = t; 1.6463 + advance("each"); 1.6464 + if (!state.option.inMoz(true)) { 1.6465 + warning("W118", state.tokens.curr, "for each"); 1.6466 + } 1.6467 + } 1.6468 + 1.6469 + funct["(breakage)"] += 1; 1.6470 + funct["(loopage)"] += 1; 1.6471 + increaseComplexityCount(); 1.6472 + advance("("); 1.6473 + nonadjacent(this, t); 1.6474 + nospace(); 1.6475 + 1.6476 + // what kind of for(…) statement it is? for(…of…)? for(…in…)? for(…;…;…)? 1.6477 + var nextop; // contains the token of the "in" or "of" operator 1.6478 + var i = 0; 1.6479 + var inof = ["in", "of"]; 1.6480 + do { 1.6481 + nextop = peek(i); 1.6482 + ++i; 1.6483 + } while (!_.contains(inof, nextop.value) && nextop.value !== ";" && 1.6484 + nextop.type !== "(end)"); 1.6485 + 1.6486 + // if we're in a for (… in|of …) statement 1.6487 + if (_.contains(inof, nextop.value)) { 1.6488 + if (!state.option.inESNext() && nextop.value === "of") { 1.6489 + error("W104", nextop, "for of"); 1.6490 + } 1.6491 + if (state.tokens.next.id === "var") { 1.6492 + advance("var"); 1.6493 + state.syntax["var"].fud.call(state.syntax["var"].fud, true); 1.6494 + } else if (state.tokens.next.id === "let") { 1.6495 + advance("let"); 1.6496 + // create a new block scope 1.6497 + letscope = true; 1.6498 + funct["(blockscope)"].stack(); 1.6499 + state.syntax["let"].fud.call(state.syntax["let"].fud, true); 1.6500 + } else { 1.6501 + switch (funct[state.tokens.next.value]) { 1.6502 + case "unused": 1.6503 + funct[state.tokens.next.value] = "var"; 1.6504 + break; 1.6505 + case "var": 1.6506 + break; 1.6507 + default: 1.6508 + if (!funct["(blockscope)"].getlabel(state.tokens.next.value)) 1.6509 + warning("W088", state.tokens.next, state.tokens.next.value); 1.6510 + } 1.6511 + advance(); 1.6512 + } 1.6513 + advance(nextop.value); 1.6514 + expression(20); 1.6515 + advance(")", t); 1.6516 + s = block(true, true); 1.6517 + if (state.option.forin && s && (s.length > 1 || typeof s[0] !== "object" || 1.6518 + s[0].value !== "if")) { 1.6519 + warning("W089", this); 1.6520 + } 1.6521 + funct["(breakage)"] -= 1; 1.6522 + funct["(loopage)"] -= 1; 1.6523 + } else { 1.6524 + if (foreachtok) { 1.6525 + error("E045", foreachtok); 1.6526 + } 1.6527 + if (state.tokens.next.id !== ";") { 1.6528 + if (state.tokens.next.id === "var") { 1.6529 + advance("var"); 1.6530 + state.syntax["var"].fud.call(state.syntax["var"].fud); 1.6531 + } else if (state.tokens.next.id === "let") { 1.6532 + advance("let"); 1.6533 + // create a new block scope 1.6534 + letscope = true; 1.6535 + funct["(blockscope)"].stack(); 1.6536 + state.syntax["let"].fud.call(state.syntax["let"].fud); 1.6537 + } else { 1.6538 + for (;;) { 1.6539 + expression(0, "for"); 1.6540 + if (state.tokens.next.id !== ",") { 1.6541 + break; 1.6542 + } 1.6543 + comma(); 1.6544 + } 1.6545 + } 1.6546 + } 1.6547 + nolinebreak(state.tokens.curr); 1.6548 + advance(";"); 1.6549 + if (state.tokens.next.id !== ";") { 1.6550 + checkCondAssignment(expression(0)); 1.6551 + } 1.6552 + nolinebreak(state.tokens.curr); 1.6553 + advance(";"); 1.6554 + if (state.tokens.next.id === ";") { 1.6555 + error("E021", state.tokens.next, ")", ";"); 1.6556 + } 1.6557 + if (state.tokens.next.id !== ")") { 1.6558 + for (;;) { 1.6559 + expression(0, "for"); 1.6560 + if (state.tokens.next.id !== ",") { 1.6561 + break; 1.6562 + } 1.6563 + comma(); 1.6564 + } 1.6565 + } 1.6566 + advance(")", t); 1.6567 + nospace(state.tokens.prev, state.tokens.curr); 1.6568 + block(true, true); 1.6569 + funct["(breakage)"] -= 1; 1.6570 + funct["(loopage)"] -= 1; 1.6571 + 1.6572 + } 1.6573 + // unstack loop blockscope 1.6574 + if (letscope) { 1.6575 + funct["(blockscope)"].unstack(); 1.6576 + } 1.6577 + return this; 1.6578 + }).labelled = true; 1.6579 + 1.6580 + 1.6581 + stmt("break", function () { 1.6582 + var v = state.tokens.next.value; 1.6583 + 1.6584 + if (funct["(breakage)"] === 0) 1.6585 + warning("W052", state.tokens.next, this.value); 1.6586 + 1.6587 + if (!state.option.asi) 1.6588 + nolinebreak(this); 1.6589 + 1.6590 + if (state.tokens.next.id !== ";") { 1.6591 + if (state.tokens.curr.line === state.tokens.next.line) { 1.6592 + if (funct[v] !== "label") { 1.6593 + warning("W090", state.tokens.next, v); 1.6594 + } else if (scope[v] !== funct) { 1.6595 + warning("W091", state.tokens.next, v); 1.6596 + } 1.6597 + this.first = state.tokens.next; 1.6598 + advance(); 1.6599 + } 1.6600 + } 1.6601 + reachable("break"); 1.6602 + return this; 1.6603 + }).exps = true; 1.6604 + 1.6605 + 1.6606 + stmt("continue", function () { 1.6607 + var v = state.tokens.next.value; 1.6608 + 1.6609 + if (funct["(breakage)"] === 0) 1.6610 + warning("W052", state.tokens.next, this.value); 1.6611 + 1.6612 + if (!state.option.asi) 1.6613 + nolinebreak(this); 1.6614 + 1.6615 + if (state.tokens.next.id !== ";") { 1.6616 + if (state.tokens.curr.line === state.tokens.next.line) { 1.6617 + if (funct[v] !== "label") { 1.6618 + warning("W090", state.tokens.next, v); 1.6619 + } else if (scope[v] !== funct) { 1.6620 + warning("W091", state.tokens.next, v); 1.6621 + } 1.6622 + this.first = state.tokens.next; 1.6623 + advance(); 1.6624 + } 1.6625 + } else if (!funct["(loopage)"]) { 1.6626 + warning("W052", state.tokens.next, this.value); 1.6627 + } 1.6628 + reachable("continue"); 1.6629 + return this; 1.6630 + }).exps = true; 1.6631 + 1.6632 + 1.6633 + stmt("return", function () { 1.6634 + if (this.line === state.tokens.next.line) { 1.6635 + if (state.tokens.next.id === "(regexp)") 1.6636 + warning("W092"); 1.6637 + 1.6638 + if (state.tokens.next.id !== ";" && !state.tokens.next.reach) { 1.6639 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6640 + this.first = expression(0); 1.6641 + 1.6642 + if (this.first && 1.6643 + this.first.type === "(punctuator)" && this.first.value === "=" && !state.option.boss) { 1.6644 + warningAt("W093", this.first.line, this.first.character); 1.6645 + } 1.6646 + } 1.6647 + } else { 1.6648 + if (state.tokens.next.type === "(punctuator)" && 1.6649 + ["[", "{", "+", "-"].indexOf(state.tokens.next.value) > -1) { 1.6650 + nolinebreak(this); // always warn (Line breaking error) 1.6651 + } 1.6652 + } 1.6653 + reachable("return"); 1.6654 + return this; 1.6655 + }).exps = true; 1.6656 + 1.6657 + stmt("yield", function () { 1.6658 + if (state.option.inESNext(true) && funct["(generator)"] !== true) { 1.6659 + error("E046", state.tokens.curr, "yield"); 1.6660 + } else if (!state.option.inESNext()) { 1.6661 + warning("W104", state.tokens.curr, "yield"); 1.6662 + } 1.6663 + funct["(generator)"] = "yielded"; 1.6664 + if (this.line === state.tokens.next.line) { 1.6665 + if (state.tokens.next.id === "(regexp)") 1.6666 + warning("W092"); 1.6667 + 1.6668 + if (state.tokens.next.id !== ";" && !state.tokens.next.reach) { 1.6669 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6670 + this.first = expression(0); 1.6671 + 1.6672 + if (this.first.type === "(punctuator)" && this.first.value === "=" && !state.option.boss) { 1.6673 + warningAt("W093", this.first.line, this.first.character); 1.6674 + } 1.6675 + } 1.6676 + } else if (!state.option.asi) { 1.6677 + nolinebreak(this); // always warn (Line breaking error) 1.6678 + } 1.6679 + return this; 1.6680 + }).exps = true; 1.6681 + 1.6682 + 1.6683 + stmt("throw", function () { 1.6684 + nolinebreak(this); 1.6685 + nonadjacent(state.tokens.curr, state.tokens.next); 1.6686 + this.first = expression(20); 1.6687 + reachable("throw"); 1.6688 + return this; 1.6689 + }).exps = true; 1.6690 + 1.6691 + // Future Reserved Words 1.6692 + 1.6693 + FutureReservedWord("abstract"); 1.6694 + FutureReservedWord("boolean"); 1.6695 + FutureReservedWord("byte"); 1.6696 + FutureReservedWord("char"); 1.6697 + FutureReservedWord("class", { es5: true, nud: classdef }); 1.6698 + FutureReservedWord("double"); 1.6699 + FutureReservedWord("enum", { es5: true }); 1.6700 + FutureReservedWord("export", { es5: true }); 1.6701 + FutureReservedWord("extends", { es5: true }); 1.6702 + FutureReservedWord("final"); 1.6703 + FutureReservedWord("float"); 1.6704 + FutureReservedWord("goto"); 1.6705 + FutureReservedWord("implements", { es5: true, strictOnly: true }); 1.6706 + FutureReservedWord("import", { es5: true }); 1.6707 + FutureReservedWord("int"); 1.6708 + FutureReservedWord("interface", { es5: true, strictOnly: true }); 1.6709 + FutureReservedWord("long"); 1.6710 + FutureReservedWord("native"); 1.6711 + FutureReservedWord("package", { es5: true, strictOnly: true }); 1.6712 + FutureReservedWord("private", { es5: true, strictOnly: true }); 1.6713 + FutureReservedWord("protected", { es5: true, strictOnly: true }); 1.6714 + FutureReservedWord("public", { es5: true, strictOnly: true }); 1.6715 + FutureReservedWord("short"); 1.6716 + FutureReservedWord("static", { es5: true, strictOnly: true }); 1.6717 + FutureReservedWord("super", { es5: true }); 1.6718 + FutureReservedWord("synchronized"); 1.6719 + FutureReservedWord("throws"); 1.6720 + FutureReservedWord("transient"); 1.6721 + FutureReservedWord("volatile"); 1.6722 + 1.6723 + // this function is used to determine wether a squarebracket or a curlybracket 1.6724 + // expression is a comprehension array, destructuring assignment or a json value. 1.6725 + 1.6726 + var lookupBlockType = function () { 1.6727 + var pn, pn1; 1.6728 + var i = 0; 1.6729 + var bracketStack = 0; 1.6730 + var ret = {}; 1.6731 + if (_.contains(["[", "{"], state.tokens.curr.value)) 1.6732 + bracketStack += 1; 1.6733 + if (_.contains(["[", "{"], state.tokens.next.value)) 1.6734 + bracketStack += 1; 1.6735 + if (_.contains(["]", "}"], state.tokens.next.value)) 1.6736 + bracketStack -= 1; 1.6737 + do { 1.6738 + pn = peek(i); 1.6739 + pn1 = peek(i + 1); 1.6740 + i = i + 1; 1.6741 + if (_.contains(["[", "{"], pn.value)) { 1.6742 + bracketStack += 1; 1.6743 + } else if (_.contains(["]", "}"], pn.value)) { 1.6744 + bracketStack -= 1; 1.6745 + } 1.6746 + if (pn.identifier && pn.value === "for" && bracketStack === 1) { 1.6747 + ret.isCompArray = true; 1.6748 + ret.notJson = true; 1.6749 + break; 1.6750 + } 1.6751 + if (_.contains(["}", "]"], pn.value) && pn1.value === "=") { 1.6752 + ret.isDestAssign = true; 1.6753 + ret.notJson = true; 1.6754 + break; 1.6755 + } 1.6756 + if (pn.value === ";") { 1.6757 + ret.isBlock = true; 1.6758 + ret.notJson = true; 1.6759 + } 1.6760 + } while (bracketStack > 0 && pn.id !== "(end)" && i < 15); 1.6761 + return ret; 1.6762 + }; 1.6763 + 1.6764 + // Check whether this function has been reached for a destructuring assign with undeclared values 1.6765 + function destructuringAssignOrJsonValue() { 1.6766 + // lookup for the assignment (esnext only) 1.6767 + // if it has semicolons, it is a block, so go parse it as a block 1.6768 + // or it's not a block, but there are assignments, check for undeclared variables 1.6769 + 1.6770 + var block = lookupBlockType(); 1.6771 + if (block.notJson) { 1.6772 + if (!state.option.inESNext() && block.isDestAssign) { 1.6773 + warning("W104", state.tokens.curr, "destructuring assignment"); 1.6774 + } 1.6775 + statements(); 1.6776 + // otherwise parse json value 1.6777 + } else { 1.6778 + state.option.laxbreak = true; 1.6779 + state.jsonMode = true; 1.6780 + jsonValue(); 1.6781 + } 1.6782 + } 1.6783 + 1.6784 + // array comprehension parsing function 1.6785 + // parses and defines the three states of the list comprehension in order 1.6786 + // to avoid defining global variables, but keeping them to the list comprehension scope 1.6787 + // only. The order of the states are as follows: 1.6788 + // * "use" which will be the returned iterative part of the list comprehension 1.6789 + // * "define" which will define the variables local to the list comprehension 1.6790 + // * "filter" which will help filter out values 1.6791 + 1.6792 + var arrayComprehension = function () { 1.6793 + var CompArray = function () { 1.6794 + this.mode = "use"; 1.6795 + this.variables = []; 1.6796 + }; 1.6797 + var _carrays = []; 1.6798 + var _current; 1.6799 + function declare(v) { 1.6800 + var l = _current.variables.filter(function (elt) { 1.6801 + // if it has, change its undef state 1.6802 + if (elt.value === v) { 1.6803 + elt.undef = false; 1.6804 + return v; 1.6805 + } 1.6806 + }).length; 1.6807 + return l !== 0; 1.6808 + } 1.6809 + function use(v) { 1.6810 + var l = _current.variables.filter(function (elt) { 1.6811 + // and if it has been defined 1.6812 + if (elt.value === v && !elt.undef) { 1.6813 + if (elt.unused === true) { 1.6814 + elt.unused = false; 1.6815 + } 1.6816 + return v; 1.6817 + } 1.6818 + }).length; 1.6819 + // otherwise we warn about it 1.6820 + return (l === 0); 1.6821 + } 1.6822 + return {stack: function () { 1.6823 + _current = new CompArray(); 1.6824 + _carrays.push(_current); 1.6825 + }, 1.6826 + unstack: function () { 1.6827 + _current.variables.filter(function (v) { 1.6828 + if (v.unused) 1.6829 + warning("W098", v.token, v.value); 1.6830 + if (v.undef) 1.6831 + isundef(v.funct, "W117", v.token, v.value); 1.6832 + }); 1.6833 + _carrays.splice(_carrays[_carrays.length - 1], 1); 1.6834 + _current = _carrays[_carrays.length - 1]; 1.6835 + }, 1.6836 + setState: function (s) { 1.6837 + if (_.contains(["use", "define", "filter"], s)) 1.6838 + _current.mode = s; 1.6839 + }, 1.6840 + check: function (v) { 1.6841 + // When we are in "use" state of the list comp, we enqueue that var 1.6842 + if (_current && _current.mode === "use") { 1.6843 + _current.variables.push({funct: funct, 1.6844 + token: state.tokens.curr, 1.6845 + value: v, 1.6846 + undef: true, 1.6847 + unused: false}); 1.6848 + return true; 1.6849 + // When we are in "define" state of the list comp, 1.6850 + } else if (_current && _current.mode === "define") { 1.6851 + // check if the variable has been used previously 1.6852 + if (!declare(v)) { 1.6853 + _current.variables.push({funct: funct, 1.6854 + token: state.tokens.curr, 1.6855 + value: v, 1.6856 + undef: false, 1.6857 + unused: true}); 1.6858 + } 1.6859 + return true; 1.6860 + // When we are in "filter" state, 1.6861 + } else if (_current && _current.mode === "filter") { 1.6862 + // we check whether current variable has been declared 1.6863 + if (use(v)) { 1.6864 + // if not we warn about it 1.6865 + isundef(funct, "W117", state.tokens.curr, v); 1.6866 + } 1.6867 + return true; 1.6868 + } 1.6869 + return false; 1.6870 + } 1.6871 + }; 1.6872 + }; 1.6873 + 1.6874 + 1.6875 + // Parse JSON 1.6876 + 1.6877 + function jsonValue() { 1.6878 + 1.6879 + function jsonObject() { 1.6880 + var o = {}, t = state.tokens.next; 1.6881 + advance("{"); 1.6882 + if (state.tokens.next.id !== "}") { 1.6883 + for (;;) { 1.6884 + if (state.tokens.next.id === "(end)") { 1.6885 + error("E026", state.tokens.next, t.line); 1.6886 + } else if (state.tokens.next.id === "}") { 1.6887 + warning("W094", state.tokens.curr); 1.6888 + break; 1.6889 + } else if (state.tokens.next.id === ",") { 1.6890 + error("E028", state.tokens.next); 1.6891 + } else if (state.tokens.next.id !== "(string)") { 1.6892 + warning("W095", state.tokens.next, state.tokens.next.value); 1.6893 + } 1.6894 + if (o[state.tokens.next.value] === true) { 1.6895 + warning("W075", state.tokens.next, state.tokens.next.value); 1.6896 + } else if ((state.tokens.next.value === "__proto__" && 1.6897 + !state.option.proto) || (state.tokens.next.value === "__iterator__" && 1.6898 + !state.option.iterator)) { 1.6899 + warning("W096", state.tokens.next, state.tokens.next.value); 1.6900 + } else { 1.6901 + o[state.tokens.next.value] = true; 1.6902 + } 1.6903 + advance(); 1.6904 + advance(":"); 1.6905 + jsonValue(); 1.6906 + if (state.tokens.next.id !== ",") { 1.6907 + break; 1.6908 + } 1.6909 + advance(","); 1.6910 + } 1.6911 + } 1.6912 + advance("}"); 1.6913 + } 1.6914 + 1.6915 + function jsonArray() { 1.6916 + var t = state.tokens.next; 1.6917 + advance("["); 1.6918 + if (state.tokens.next.id !== "]") { 1.6919 + for (;;) { 1.6920 + if (state.tokens.next.id === "(end)") { 1.6921 + error("E027", state.tokens.next, t.line); 1.6922 + } else if (state.tokens.next.id === "]") { 1.6923 + warning("W094", state.tokens.curr); 1.6924 + break; 1.6925 + } else if (state.tokens.next.id === ",") { 1.6926 + error("E028", state.tokens.next); 1.6927 + } 1.6928 + jsonValue(); 1.6929 + if (state.tokens.next.id !== ",") { 1.6930 + break; 1.6931 + } 1.6932 + advance(","); 1.6933 + } 1.6934 + } 1.6935 + advance("]"); 1.6936 + } 1.6937 + 1.6938 + switch (state.tokens.next.id) { 1.6939 + case "{": 1.6940 + jsonObject(); 1.6941 + break; 1.6942 + case "[": 1.6943 + jsonArray(); 1.6944 + break; 1.6945 + case "true": 1.6946 + case "false": 1.6947 + case "null": 1.6948 + case "(number)": 1.6949 + case "(string)": 1.6950 + advance(); 1.6951 + break; 1.6952 + case "-": 1.6953 + advance("-"); 1.6954 + if (state.tokens.curr.character !== state.tokens.next.from) { 1.6955 + warning("W011", state.tokens.curr); 1.6956 + } 1.6957 + adjacent(state.tokens.curr, state.tokens.next); 1.6958 + advance("(number)"); 1.6959 + break; 1.6960 + default: 1.6961 + error("E003", state.tokens.next); 1.6962 + } 1.6963 + } 1.6964 + 1.6965 + var blockScope = function () { 1.6966 + var _current = {}; 1.6967 + var _variables = [_current]; 1.6968 + 1.6969 + function _checkBlockLabels() { 1.6970 + for (var t in _current) { 1.6971 + if (_current[t]["(type)"] === "unused") { 1.6972 + if (state.option.unused) { 1.6973 + var tkn = _current[t]["(token)"]; 1.6974 + var line = tkn.line; 1.6975 + var chr = tkn.character; 1.6976 + warningAt("W098", line, chr, t); 1.6977 + } 1.6978 + } 1.6979 + } 1.6980 + } 1.6981 + 1.6982 + return { 1.6983 + stack: function () { 1.6984 + _current = {}; 1.6985 + _variables.push(_current); 1.6986 + }, 1.6987 + 1.6988 + unstack: function () { 1.6989 + _checkBlockLabels(); 1.6990 + _variables.splice(_variables.length - 1, 1); 1.6991 + _current = _.last(_variables); 1.6992 + }, 1.6993 + 1.6994 + getlabel: function (l) { 1.6995 + for (var i = _variables.length - 1 ; i >= 0; --i) { 1.6996 + if (_.has(_variables[i], l)) { 1.6997 + return _variables[i]; 1.6998 + } 1.6999 + } 1.7000 + }, 1.7001 + 1.7002 + current: { 1.7003 + has: function (t) { 1.7004 + return _.has(_current, t); 1.7005 + }, 1.7006 + add: function (t, type, tok) { 1.7007 + _current[t] = { "(type)" : type, 1.7008 + "(token)": tok }; 1.7009 + } 1.7010 + } 1.7011 + }; 1.7012 + }; 1.7013 + 1.7014 + // The actual JSHINT function itself. 1.7015 + var itself = function (s, o, g) { 1.7016 + var a, i, k, x; 1.7017 + var optionKeys; 1.7018 + var newOptionObj = {}; 1.7019 + var newIgnoredObj = {}; 1.7020 + 1.7021 + state.reset(); 1.7022 + 1.7023 + if (o && o.scope) { 1.7024 + JSHINT.scope = o.scope; 1.7025 + } else { 1.7026 + JSHINT.errors = []; 1.7027 + JSHINT.undefs = []; 1.7028 + JSHINT.internals = []; 1.7029 + JSHINT.blacklist = {}; 1.7030 + JSHINT.scope = "(main)"; 1.7031 + } 1.7032 + 1.7033 + predefined = Object.create(null); 1.7034 + combine(predefined, vars.ecmaIdentifiers); 1.7035 + combine(predefined, vars.reservedVars); 1.7036 + 1.7037 + combine(predefined, g || {}); 1.7038 + 1.7039 + declared = Object.create(null); 1.7040 + exported = Object.create(null); 1.7041 + 1.7042 + if (o) { 1.7043 + a = o.predef; 1.7044 + if (a) { 1.7045 + if (!Array.isArray(a) && typeof a === "object") { 1.7046 + a = Object.keys(a); 1.7047 + } 1.7048 + 1.7049 + a.forEach(function (item) { 1.7050 + var slice, prop; 1.7051 + 1.7052 + if (item[0] === "-") { 1.7053 + slice = item.slice(1); 1.7054 + JSHINT.blacklist[slice] = slice; 1.7055 + } else { 1.7056 + prop = Object.getOwnPropertyDescriptor(o.predef, item); 1.7057 + predefined[item] = prop ? prop.value : false; 1.7058 + } 1.7059 + }); 1.7060 + } 1.7061 + 1.7062 + optionKeys = Object.keys(o); 1.7063 + for (x = 0; x < optionKeys.length; x++) { 1.7064 + if (/^-W\d{3}$/g.test(optionKeys[x])) { 1.7065 + newIgnoredObj[optionKeys[x].slice(1)] = true; 1.7066 + } else { 1.7067 + newOptionObj[optionKeys[x]] = o[optionKeys[x]]; 1.7068 + 1.7069 + if (optionKeys[x] === "newcap" && o[optionKeys[x]] === false) 1.7070 + newOptionObj["(explicitNewcap)"] = true; 1.7071 + 1.7072 + if (optionKeys[x] === "indent") 1.7073 + newOptionObj["(explicitIndent)"] = o[optionKeys[x]] === false ? false : true; 1.7074 + } 1.7075 + } 1.7076 + } 1.7077 + 1.7078 + state.option = newOptionObj; 1.7079 + state.ignored = newIgnoredObj; 1.7080 + 1.7081 + state.option.indent = state.option.indent || 4; 1.7082 + state.option.maxerr = state.option.maxerr || 50; 1.7083 + 1.7084 + indent = 1; 1.7085 + global = Object.create(predefined); 1.7086 + scope = global; 1.7087 + funct = { 1.7088 + "(global)": true, 1.7089 + "(name)": "(global)", 1.7090 + "(scope)": scope, 1.7091 + "(breakage)": 0, 1.7092 + "(loopage)": 0, 1.7093 + "(tokens)": {}, 1.7094 + "(metrics)": createMetrics(state.tokens.next), 1.7095 + "(blockscope)": blockScope(), 1.7096 + "(comparray)": arrayComprehension() 1.7097 + }; 1.7098 + functions = [funct]; 1.7099 + urls = []; 1.7100 + stack = null; 1.7101 + member = {}; 1.7102 + membersOnly = null; 1.7103 + implied = {}; 1.7104 + inblock = false; 1.7105 + lookahead = []; 1.7106 + warnings = 0; 1.7107 + unuseds = []; 1.7108 + 1.7109 + if (!isString(s) && !Array.isArray(s)) { 1.7110 + errorAt("E004", 0); 1.7111 + return false; 1.7112 + } 1.7113 + 1.7114 + api = { 1.7115 + get isJSON() { 1.7116 + return state.jsonMode; 1.7117 + }, 1.7118 + 1.7119 + getOption: function (name) { 1.7120 + return state.option[name] || null; 1.7121 + }, 1.7122 + 1.7123 + getCache: function (name) { 1.7124 + return state.cache[name]; 1.7125 + }, 1.7126 + 1.7127 + setCache: function (name, value) { 1.7128 + state.cache[name] = value; 1.7129 + }, 1.7130 + 1.7131 + warn: function (code, data) { 1.7132 + warningAt.apply(null, [ code, data.line, data.char ].concat(data.data)); 1.7133 + }, 1.7134 + 1.7135 + on: function (names, listener) { 1.7136 + names.split(" ").forEach(function (name) { 1.7137 + emitter.on(name, listener); 1.7138 + }.bind(this)); 1.7139 + } 1.7140 + }; 1.7141 + 1.7142 + emitter.removeAllListeners(); 1.7143 + (extraModules || []).forEach(function (func) { 1.7144 + func(api); 1.7145 + }); 1.7146 + 1.7147 + state.tokens.prev = state.tokens.curr = state.tokens.next = state.syntax["(begin)"]; 1.7148 + 1.7149 + lex = new Lexer(s); 1.7150 + 1.7151 + lex.on("warning", function (ev) { 1.7152 + warningAt.apply(null, [ ev.code, ev.line, ev.character].concat(ev.data)); 1.7153 + }); 1.7154 + 1.7155 + lex.on("error", function (ev) { 1.7156 + errorAt.apply(null, [ ev.code, ev.line, ev.character ].concat(ev.data)); 1.7157 + }); 1.7158 + 1.7159 + lex.on("fatal", function (ev) { 1.7160 + quit("E041", ev.line, ev.from); 1.7161 + }); 1.7162 + 1.7163 + lex.on("Identifier", function (ev) { 1.7164 + emitter.emit("Identifier", ev); 1.7165 + }); 1.7166 + 1.7167 + lex.on("String", function (ev) { 1.7168 + emitter.emit("String", ev); 1.7169 + }); 1.7170 + 1.7171 + lex.on("Number", function (ev) { 1.7172 + emitter.emit("Number", ev); 1.7173 + }); 1.7174 + 1.7175 + lex.start(); 1.7176 + 1.7177 + // Check options 1.7178 + for (var name in o) { 1.7179 + if (_.has(o, name)) { 1.7180 + checkOption(name, state.tokens.curr); 1.7181 + } 1.7182 + } 1.7183 + 1.7184 + assume(); 1.7185 + 1.7186 + // combine the passed globals after we've assumed all our options 1.7187 + combine(predefined, g || {}); 1.7188 + 1.7189 + //reset values 1.7190 + comma.first = true; 1.7191 + 1.7192 + try { 1.7193 + advance(); 1.7194 + switch (state.tokens.next.id) { 1.7195 + case "{": 1.7196 + case "[": 1.7197 + destructuringAssignOrJsonValue(); 1.7198 + break; 1.7199 + default: 1.7200 + directives(); 1.7201 + 1.7202 + if (state.directive["use strict"]) { 1.7203 + if (!state.option.globalstrict && !state.option.node) { 1.7204 + warning("W097", state.tokens.prev); 1.7205 + } 1.7206 + } 1.7207 + 1.7208 + statements(); 1.7209 + } 1.7210 + advance((state.tokens.next && state.tokens.next.value !== ".") ? "(end)" : undefined); 1.7211 + funct["(blockscope)"].unstack(); 1.7212 + 1.7213 + var markDefined = function (name, context) { 1.7214 + do { 1.7215 + if (typeof context[name] === "string") { 1.7216 + // JSHINT marks unused variables as 'unused' and 1.7217 + // unused function declaration as 'unction'. This 1.7218 + // code changes such instances back 'var' and 1.7219 + // 'closure' so that the code in JSHINT.data() 1.7220 + // doesn't think they're unused. 1.7221 + 1.7222 + if (context[name] === "unused") 1.7223 + context[name] = "var"; 1.7224 + else if (context[name] === "unction") 1.7225 + context[name] = "closure"; 1.7226 + 1.7227 + return true; 1.7228 + } 1.7229 + 1.7230 + context = context["(context)"]; 1.7231 + } while (context); 1.7232 + 1.7233 + return false; 1.7234 + }; 1.7235 + 1.7236 + var clearImplied = function (name, line) { 1.7237 + if (!implied[name]) 1.7238 + return; 1.7239 + 1.7240 + var newImplied = []; 1.7241 + for (var i = 0; i < implied[name].length; i += 1) { 1.7242 + if (implied[name][i] !== line) 1.7243 + newImplied.push(implied[name][i]); 1.7244 + } 1.7245 + 1.7246 + if (newImplied.length === 0) 1.7247 + delete implied[name]; 1.7248 + else 1.7249 + implied[name] = newImplied; 1.7250 + }; 1.7251 + 1.7252 + var warnUnused = function (name, tkn, type, unused_opt) { 1.7253 + var line = tkn.line; 1.7254 + var chr = tkn.character; 1.7255 + 1.7256 + if (unused_opt === undefined) { 1.7257 + unused_opt = state.option.unused; 1.7258 + } 1.7259 + 1.7260 + if (unused_opt === true) { 1.7261 + unused_opt = "last-param"; 1.7262 + } 1.7263 + 1.7264 + var warnable_types = { 1.7265 + "vars": ["var"], 1.7266 + "last-param": ["var", "param"], 1.7267 + "strict": ["var", "param", "last-param"] 1.7268 + }; 1.7269 + 1.7270 + if (unused_opt) { 1.7271 + if (warnable_types[unused_opt] && warnable_types[unused_opt].indexOf(type) !== -1) { 1.7272 + warningAt("W098", line, chr, name); 1.7273 + } 1.7274 + } 1.7275 + 1.7276 + unuseds.push({ 1.7277 + name: name, 1.7278 + line: line, 1.7279 + character: chr 1.7280 + }); 1.7281 + }; 1.7282 + 1.7283 + var checkUnused = function (func, key) { 1.7284 + var type = func[key]; 1.7285 + var tkn = func["(tokens)"][key]; 1.7286 + 1.7287 + if (key.charAt(0) === "(") 1.7288 + return; 1.7289 + 1.7290 + if (type !== "unused" && type !== "unction") 1.7291 + return; 1.7292 + 1.7293 + // Params are checked separately from other variables. 1.7294 + if (func["(params)"] && func["(params)"].indexOf(key) !== -1) 1.7295 + return; 1.7296 + 1.7297 + // Variable is in global scope and defined as exported. 1.7298 + if (func["(global)"] && _.has(exported, key)) { 1.7299 + return; 1.7300 + } 1.7301 + 1.7302 + warnUnused(key, tkn, "var"); 1.7303 + }; 1.7304 + 1.7305 + // Check queued 'x is not defined' instances to see if they're still undefined. 1.7306 + for (i = 0; i < JSHINT.undefs.length; i += 1) { 1.7307 + k = JSHINT.undefs[i].slice(0); 1.7308 + 1.7309 + if (markDefined(k[2].value, k[0])) { 1.7310 + clearImplied(k[2].value, k[2].line); 1.7311 + } else if (state.option.undef) { 1.7312 + warning.apply(warning, k.slice(1)); 1.7313 + } 1.7314 + } 1.7315 + 1.7316 + functions.forEach(function (func) { 1.7317 + if (func["(unusedOption)"] === false) { 1.7318 + return; 1.7319 + } 1.7320 + 1.7321 + for (var key in func) { 1.7322 + if (_.has(func, key)) { 1.7323 + checkUnused(func, key); 1.7324 + } 1.7325 + } 1.7326 + 1.7327 + if (!func["(params)"]) 1.7328 + return; 1.7329 + 1.7330 + var params = func["(params)"].slice(); 1.7331 + var param = params.pop(); 1.7332 + var type, unused_opt; 1.7333 + 1.7334 + while (param) { 1.7335 + type = func[param]; 1.7336 + unused_opt = func["(unusedOption)"] || state.option.unused; 1.7337 + unused_opt = unused_opt === true ? "last-param" : unused_opt; 1.7338 + 1.7339 + // 'undefined' is a special case for (function (window, undefined) { ... })(); 1.7340 + // patterns. 1.7341 + 1.7342 + if (param === "undefined") 1.7343 + return; 1.7344 + 1.7345 + if (type === "unused" || type === "unction") { 1.7346 + warnUnused(param, func["(tokens)"][param], "param", func["(unusedOption)"]); 1.7347 + } else if (unused_opt === "last-param") { 1.7348 + return; 1.7349 + } 1.7350 + 1.7351 + param = params.pop(); 1.7352 + } 1.7353 + }); 1.7354 + 1.7355 + for (var key in declared) { 1.7356 + if (_.has(declared, key) && !_.has(global, key)) { 1.7357 + warnUnused(key, declared[key], "var"); 1.7358 + } 1.7359 + } 1.7360 + 1.7361 + } catch (err) { 1.7362 + if (err && err.name === "JSHintError") { 1.7363 + var nt = state.tokens.next || {}; 1.7364 + JSHINT.errors.push({ 1.7365 + scope : "(main)", 1.7366 + raw : err.raw, 1.7367 + reason : err.message, 1.7368 + line : err.line || nt.line, 1.7369 + character : err.character || nt.from 1.7370 + }, null); 1.7371 + } else { 1.7372 + throw err; 1.7373 + } 1.7374 + } 1.7375 + 1.7376 + // Loop over the listed "internals", and check them as well. 1.7377 + 1.7378 + if (JSHINT.scope === "(main)") { 1.7379 + o = o || {}; 1.7380 + 1.7381 + for (i = 0; i < JSHINT.internals.length; i += 1) { 1.7382 + k = JSHINT.internals[i]; 1.7383 + o.scope = k.elem; 1.7384 + itself(k.value, o, g); 1.7385 + } 1.7386 + } 1.7387 + 1.7388 + return JSHINT.errors.length === 0; 1.7389 + }; 1.7390 + 1.7391 + // Modules. 1.7392 + itself.addModule = function (func) { 1.7393 + extraModules.push(func); 1.7394 + }; 1.7395 + 1.7396 + itself.addModule(style.register); 1.7397 + 1.7398 + // Data summary. 1.7399 + itself.data = function () { 1.7400 + var data = { 1.7401 + functions: [], 1.7402 + options: state.option 1.7403 + }; 1.7404 + var implieds = []; 1.7405 + var members = []; 1.7406 + var fu, f, i, j, n, globals; 1.7407 + 1.7408 + if (itself.errors.length) { 1.7409 + data.errors = itself.errors; 1.7410 + } 1.7411 + 1.7412 + if (state.jsonMode) { 1.7413 + data.json = true; 1.7414 + } 1.7415 + 1.7416 + for (n in implied) { 1.7417 + if (_.has(implied, n)) { 1.7418 + implieds.push({ 1.7419 + name: n, 1.7420 + line: implied[n] 1.7421 + }); 1.7422 + } 1.7423 + } 1.7424 + 1.7425 + if (implieds.length > 0) { 1.7426 + data.implieds = implieds; 1.7427 + } 1.7428 + 1.7429 + if (urls.length > 0) { 1.7430 + data.urls = urls; 1.7431 + } 1.7432 + 1.7433 + globals = Object.keys(scope); 1.7434 + if (globals.length > 0) { 1.7435 + data.globals = globals; 1.7436 + } 1.7437 + 1.7438 + for (i = 1; i < functions.length; i += 1) { 1.7439 + f = functions[i]; 1.7440 + fu = {}; 1.7441 + 1.7442 + for (j = 0; j < functionicity.length; j += 1) { 1.7443 + fu[functionicity[j]] = []; 1.7444 + } 1.7445 + 1.7446 + for (j = 0; j < functionicity.length; j += 1) { 1.7447 + if (fu[functionicity[j]].length === 0) { 1.7448 + delete fu[functionicity[j]]; 1.7449 + } 1.7450 + } 1.7451 + 1.7452 + fu.name = f["(name)"]; 1.7453 + fu.param = f["(params)"]; 1.7454 + fu.line = f["(line)"]; 1.7455 + fu.character = f["(character)"]; 1.7456 + fu.last = f["(last)"]; 1.7457 + fu.lastcharacter = f["(lastcharacter)"]; 1.7458 + data.functions.push(fu); 1.7459 + } 1.7460 + 1.7461 + if (unuseds.length > 0) { 1.7462 + data.unused = unuseds; 1.7463 + } 1.7464 + 1.7465 + members = []; 1.7466 + for (n in member) { 1.7467 + if (typeof member[n] === "number") { 1.7468 + data.member = member; 1.7469 + break; 1.7470 + } 1.7471 + } 1.7472 + 1.7473 + return data; 1.7474 + }; 1.7475 + 1.7476 + itself.jshint = itself; 1.7477 + 1.7478 + return itself; 1.7479 +}()); 1.7480 + 1.7481 +// Make JSHINT a Node module, if possible. 1.7482 +if (typeof exports === "object" && exports) { 1.7483 + exports.JSHINT = JSHINT; 1.7484 +} 1.7485 + 1.7486 +})() 1.7487 +},{"events":2,"../shared/vars.js":3,"./lex.js":10,"./reg.js":6,"./state.js":4,"../shared/messages.js":12,"./style.js":5,"console-browserify":7,"underscore":11}],12:[function(require,module,exports){ 1.7488 +(function(){"use strict"; 1.7489 + 1.7490 +var _ = require("underscore"); 1.7491 + 1.7492 +var errors = { 1.7493 + // JSHint options 1.7494 + E001: "Bad option: '{a}'.", 1.7495 + E002: "Bad option value.", 1.7496 + 1.7497 + // JSHint input 1.7498 + E003: "Expected a JSON value.", 1.7499 + E004: "Input is neither a string nor an array of strings.", 1.7500 + E005: "Input is empty.", 1.7501 + E006: "Unexpected early end of program.", 1.7502 + 1.7503 + // Strict mode 1.7504 + E007: "Missing \"use strict\" statement.", 1.7505 + E008: "Strict violation.", 1.7506 + E009: "Option 'validthis' can't be used in a global scope.", 1.7507 + E010: "'with' is not allowed in strict mode.", 1.7508 + 1.7509 + // Constants 1.7510 + E011: "const '{a}' has already been declared.", 1.7511 + E012: "const '{a}' is initialized to 'undefined'.", 1.7512 + E013: "Attempting to override '{a}' which is a constant.", 1.7513 + 1.7514 + // Regular expressions 1.7515 + E014: "A regular expression literal can be confused with '/='.", 1.7516 + E015: "Unclosed regular expression.", 1.7517 + E016: "Invalid regular expression.", 1.7518 + 1.7519 + // Tokens 1.7520 + E017: "Unclosed comment.", 1.7521 + E018: "Unbegun comment.", 1.7522 + E019: "Unmatched '{a}'.", 1.7523 + E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.", 1.7524 + E021: "Expected '{a}' and instead saw '{b}'.", 1.7525 + E022: "Line breaking error '{a}'.", 1.7526 + E023: "Missing '{a}'.", 1.7527 + E024: "Unexpected '{a}'.", 1.7528 + E025: "Missing ':' on a case clause.", 1.7529 + E026: "Missing '}' to match '{' from line {a}.", 1.7530 + E027: "Missing ']' to match '[' form line {a}.", 1.7531 + E028: "Illegal comma.", 1.7532 + E029: "Unclosed string.", 1.7533 + 1.7534 + // Everything else 1.7535 + E030: "Expected an identifier and instead saw '{a}'.", 1.7536 + E031: "Bad assignment.", // FIXME: Rephrase 1.7537 + E032: "Expected a small integer or 'false' and instead saw '{a}'.", 1.7538 + E033: "Expected an operator and instead saw '{a}'.", 1.7539 + E034: "get/set are ES5 features.", 1.7540 + E035: "Missing property name.", 1.7541 + E036: "Expected to see a statement and instead saw a block.", 1.7542 + E037: "Constant {a} was not declared correctly.", 1.7543 + E038: "Variable {a} was not declared correctly.", 1.7544 + E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.", 1.7545 + E040: "Each value should have its own case label.", 1.7546 + E041: "Unrecoverable syntax error.", 1.7547 + E042: "Stopping.", 1.7548 + E043: "Too many errors.", 1.7549 + E044: "'{a}' is already defined and can't be redefined.", 1.7550 + E045: "Invalid for each loop.", 1.7551 + E046: "A yield statement shall be within a generator function (with syntax: `function*`)", 1.7552 + E047: "A generator function shall contain a yield statement.", 1.7553 + E048: "Let declaration not directly within block.", 1.7554 + E049: "A {a} cannot be named '{b}'." 1.7555 +}; 1.7556 + 1.7557 +var warnings = { 1.7558 + W001: "'hasOwnProperty' is a really bad name.", 1.7559 + W002: "Value of '{a}' may be overwritten in IE.", 1.7560 + W003: "'{a}' was used before it was defined.", 1.7561 + W004: "'{a}' is already defined.", 1.7562 + W005: "A dot following a number can be confused with a decimal point.", 1.7563 + W006: "Confusing minuses.", 1.7564 + W007: "Confusing pluses.", 1.7565 + W008: "A leading decimal point can be confused with a dot: '{a}'.", 1.7566 + W009: "The array literal notation [] is preferrable.", 1.7567 + W010: "The object literal notation {} is preferrable.", 1.7568 + W011: "Unexpected space after '{a}'.", 1.7569 + W012: "Unexpected space before '{a}'.", 1.7570 + W013: "Missing space after '{a}'.", 1.7571 + W014: "Bad line breaking before '{a}'.", 1.7572 + W015: "Expected '{a}' to have an indentation at {b} instead at {c}.", 1.7573 + W016: "Unexpected use of '{a}'.", 1.7574 + W017: "Bad operand.", 1.7575 + W018: "Confusing use of '{a}'.", 1.7576 + W019: "Use the isNaN function to compare with NaN.", 1.7577 + W020: "Read only.", 1.7578 + W021: "'{a}' is a function.", 1.7579 + W022: "Do not assign to the exception parameter.", 1.7580 + W023: "Expected an identifier in an assignment and instead saw a function invocation.", 1.7581 + W024: "Expected an identifier and instead saw '{a}' (a reserved word).", 1.7582 + W025: "Missing name in function declaration.", 1.7583 + W026: "Inner functions should be listed at the top of the outer function.", 1.7584 + W027: "Unreachable '{a}' after '{b}'.", 1.7585 + W028: "Label '{a}' on {b} statement.", 1.7586 + W030: "Expected an assignment or function call and instead saw an expression.", 1.7587 + W031: "Do not use 'new' for side effects.", 1.7588 + W032: "Unnecessary semicolon.", 1.7589 + W033: "Missing semicolon.", 1.7590 + W034: "Unnecessary directive \"{a}\".", 1.7591 + W035: "Empty block.", 1.7592 + W036: "Unexpected /*member '{a}'.", 1.7593 + W037: "'{a}' is a statement label.", 1.7594 + W038: "'{a}' used out of scope.", 1.7595 + W039: "'{a}' is not allowed.", 1.7596 + W040: "Possible strict violation.", 1.7597 + W041: "Use '{a}' to compare with '{b}'.", 1.7598 + W042: "Avoid EOL escaping.", 1.7599 + W043: "Bad escaping of EOL. Use option multistr if needed.", 1.7600 + W044: "Bad or unnecessary escaping.", 1.7601 + W045: "Bad number '{a}'.", 1.7602 + W046: "Don't use extra leading zeros '{a}'.", 1.7603 + W047: "A trailing decimal point can be confused with a dot: '{a}'.", 1.7604 + W048: "Unexpected control character in regular expression.", 1.7605 + W049: "Unexpected escaped character '{a}' in regular expression.", 1.7606 + W050: "JavaScript URL.", 1.7607 + W051: "Variables should not be deleted.", 1.7608 + W052: "Unexpected '{a}'.", 1.7609 + W053: "Do not use {a} as a constructor.", 1.7610 + W054: "The Function constructor is a form of eval.", 1.7611 + W055: "A constructor name should start with an uppercase letter.", 1.7612 + W056: "Bad constructor.", 1.7613 + W057: "Weird construction. Is 'new' unnecessary?", 1.7614 + W058: "Missing '()' invoking a constructor.", 1.7615 + W059: "Avoid arguments.{a}.", 1.7616 + W060: "document.write can be a form of eval.", 1.7617 + W061: "eval can be harmful.", 1.7618 + W062: "Wrap an immediate function invocation in parens " + 1.7619 + "to assist the reader in understanding that the expression " + 1.7620 + "is the result of a function, and not the function itself.", 1.7621 + W063: "Math is not a function.", 1.7622 + W064: "Missing 'new' prefix when invoking a constructor.", 1.7623 + W065: "Missing radix parameter.", 1.7624 + W066: "Implied eval. Consider passing a function instead of a string.", 1.7625 + W067: "Bad invocation.", 1.7626 + W068: "Wrapping non-IIFE function literals in parens is unnecessary.", 1.7627 + W069: "['{a}'] is better written in dot notation.", 1.7628 + W070: "Extra comma. (it breaks older versions of IE)", 1.7629 + W071: "This function has too many statements. ({a})", 1.7630 + W072: "This function has too many parameters. ({a})", 1.7631 + W073: "Blocks are nested too deeply. ({a})", 1.7632 + W074: "This function's cyclomatic complexity is too high. ({a})", 1.7633 + W075: "Duplicate key '{a}'.", 1.7634 + W076: "Unexpected parameter '{a}' in get {b} function.", 1.7635 + W077: "Expected a single parameter in set {a} function.", 1.7636 + W078: "Setter is defined without getter.", 1.7637 + W079: "Redefinition of '{a}'.", 1.7638 + W080: "It's not necessary to initialize '{a}' to 'undefined'.", 1.7639 + W081: "Too many var statements.", 1.7640 + W082: "Function declarations should not be placed in blocks. " + 1.7641 + "Use a function expression or move the statement to the top of " + 1.7642 + "the outer function.", 1.7643 + W083: "Don't make functions within a loop.", 1.7644 + W084: "Expected a conditional expression and instead saw an assignment.", 1.7645 + W085: "Don't use 'with'.", 1.7646 + W086: "Expected a 'break' statement before '{a}'.", 1.7647 + W087: "Forgotten 'debugger' statement?", 1.7648 + W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.", 1.7649 + W089: "The body of a for in should be wrapped in an if statement to filter " + 1.7650 + "unwanted properties from the prototype.", 1.7651 + W090: "'{a}' is not a statement label.", 1.7652 + W091: "'{a}' is out of scope.", 1.7653 + W092: "Wrap the /regexp/ literal in parens to disambiguate the slash operator.", 1.7654 + W093: "Did you mean to return a conditional instead of an assignment?", 1.7655 + W094: "Unexpected comma.", 1.7656 + W095: "Expected a string and instead saw {a}.", 1.7657 + W096: "The '{a}' key may produce unexpected results.", 1.7658 + W097: "Use the function form of \"use strict\".", 1.7659 + W098: "'{a}' is defined but never used.", 1.7660 + W099: "Mixed spaces and tabs.", 1.7661 + W100: "This character may get silently deleted by one or more browsers.", 1.7662 + W101: "Line is too long.", 1.7663 + W102: "Trailing whitespace.", 1.7664 + W103: "The '{a}' property is deprecated.", 1.7665 + W104: "'{a}' is only available in JavaScript 1.7.", 1.7666 + W105: "Unexpected {a} in '{b}'.", 1.7667 + W106: "Identifier '{a}' is not in camel case.", 1.7668 + W107: "Script URL.", 1.7669 + W108: "Strings must use doublequote.", 1.7670 + W109: "Strings must use singlequote.", 1.7671 + W110: "Mixed double and single quotes.", 1.7672 + W112: "Unclosed string.", 1.7673 + W113: "Control character in string: {a}.", 1.7674 + W114: "Avoid {a}.", 1.7675 + W115: "Octal literals are not allowed in strict mode.", 1.7676 + W116: "Expected '{a}' and instead saw '{b}'.", 1.7677 + W117: "'{a}' is not defined.", 1.7678 + W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).", 1.7679 + W119: "'{a}' is only available in ES6 (use esnext option)." 1.7680 +}; 1.7681 + 1.7682 +var info = { 1.7683 + I001: "Comma warnings can be turned off with 'laxcomma'.", 1.7684 + I002: "Reserved words as properties can be used under the 'es5' option.", 1.7685 + I003: "ES5 option is now set per default" 1.7686 +}; 1.7687 + 1.7688 +exports.errors = {}; 1.7689 +exports.warnings = {}; 1.7690 +exports.info = {}; 1.7691 + 1.7692 +_.each(errors, function (desc, code) { 1.7693 + exports.errors[code] = { code: code, desc: desc }; 1.7694 +}); 1.7695 + 1.7696 +_.each(warnings, function (desc, code) { 1.7697 + exports.warnings[code] = { code: code, desc: desc }; 1.7698 +}); 1.7699 + 1.7700 +_.each(info, function (desc, code) { 1.7701 + exports.info[code] = { code: code, desc: desc }; 1.7702 +}); 1.7703 + 1.7704 +})() 1.7705 +},{"underscore":11}],8:[function(require,module,exports){ 1.7706 +var events = require('events'); 1.7707 + 1.7708 +exports.isArray = isArray; 1.7709 +exports.isDate = function(obj){return Object.prototype.toString.call(obj) === '[object Date]'}; 1.7710 +exports.isRegExp = function(obj){return Object.prototype.toString.call(obj) === '[object RegExp]'}; 1.7711 + 1.7712 + 1.7713 +exports.print = function () {}; 1.7714 +exports.puts = function () {}; 1.7715 +exports.debug = function() {}; 1.7716 + 1.7717 +exports.inspect = function(obj, showHidden, depth, colors) { 1.7718 + var seen = []; 1.7719 + 1.7720 + var stylize = function(str, styleType) { 1.7721 + // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics 1.7722 + var styles = 1.7723 + { 'bold' : [1, 22], 1.7724 + 'italic' : [3, 23], 1.7725 + 'underline' : [4, 24], 1.7726 + 'inverse' : [7, 27], 1.7727 + 'white' : [37, 39], 1.7728 + 'grey' : [90, 39], 1.7729 + 'black' : [30, 39], 1.7730 + 'blue' : [34, 39], 1.7731 + 'cyan' : [36, 39], 1.7732 + 'green' : [32, 39], 1.7733 + 'magenta' : [35, 39], 1.7734 + 'red' : [31, 39], 1.7735 + 'yellow' : [33, 39] }; 1.7736 + 1.7737 + var style = 1.7738 + { 'special': 'cyan', 1.7739 + 'number': 'blue', 1.7740 + 'boolean': 'yellow', 1.7741 + 'undefined': 'grey', 1.7742 + 'null': 'bold', 1.7743 + 'string': 'green', 1.7744 + 'date': 'magenta', 1.7745 + // "name": intentionally not styling 1.7746 + 'regexp': 'red' }[styleType]; 1.7747 + 1.7748 + if (style) { 1.7749 + return '\033[' + styles[style][0] + 'm' + str + 1.7750 + '\033[' + styles[style][1] + 'm'; 1.7751 + } else { 1.7752 + return str; 1.7753 + } 1.7754 + }; 1.7755 + if (! colors) { 1.7756 + stylize = function(str, styleType) { return str; }; 1.7757 + } 1.7758 + 1.7759 + function format(value, recurseTimes) { 1.7760 + // Provide a hook for user-specified inspect functions. 1.7761 + // Check that value is an object with an inspect function on it 1.7762 + if (value && typeof value.inspect === 'function' && 1.7763 + // Filter out the util module, it's inspect function is special 1.7764 + value !== exports && 1.7765 + // Also filter out any prototype objects using the circular check. 1.7766 + !(value.constructor && value.constructor.prototype === value)) { 1.7767 + return value.inspect(recurseTimes); 1.7768 + } 1.7769 + 1.7770 + // Primitive types cannot have properties 1.7771 + switch (typeof value) { 1.7772 + case 'undefined': 1.7773 + return stylize('undefined', 'undefined'); 1.7774 + 1.7775 + case 'string': 1.7776 + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') 1.7777 + .replace(/'/g, "\\'") 1.7778 + .replace(/\\"/g, '"') + '\''; 1.7779 + return stylize(simple, 'string'); 1.7780 + 1.7781 + case 'number': 1.7782 + return stylize('' + value, 'number'); 1.7783 + 1.7784 + case 'boolean': 1.7785 + return stylize('' + value, 'boolean'); 1.7786 + } 1.7787 + // For some reason typeof null is "object", so special case here. 1.7788 + if (value === null) { 1.7789 + return stylize('null', 'null'); 1.7790 + } 1.7791 + 1.7792 + // Look up the keys of the object. 1.7793 + var visible_keys = Object_keys(value); 1.7794 + var keys = showHidden ? Object_getOwnPropertyNames(value) : visible_keys; 1.7795 + 1.7796 + // Functions without properties can be shortcutted. 1.7797 + if (typeof value === 'function' && keys.length === 0) { 1.7798 + if (isRegExp(value)) { 1.7799 + return stylize('' + value, 'regexp'); 1.7800 + } else { 1.7801 + var name = value.name ? ': ' + value.name : ''; 1.7802 + return stylize('[Function' + name + ']', 'special'); 1.7803 + } 1.7804 + } 1.7805 + 1.7806 + // Dates without properties can be shortcutted 1.7807 + if (isDate(value) && keys.length === 0) { 1.7808 + return stylize(value.toUTCString(), 'date'); 1.7809 + } 1.7810 + 1.7811 + var base, type, braces; 1.7812 + // Determine the object type 1.7813 + if (isArray(value)) { 1.7814 + type = 'Array'; 1.7815 + braces = ['[', ']']; 1.7816 + } else { 1.7817 + type = 'Object'; 1.7818 + braces = ['{', '}']; 1.7819 + } 1.7820 + 1.7821 + // Make functions say that they are functions 1.7822 + if (typeof value === 'function') { 1.7823 + var n = value.name ? ': ' + value.name : ''; 1.7824 + base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']'; 1.7825 + } else { 1.7826 + base = ''; 1.7827 + } 1.7828 + 1.7829 + // Make dates with properties first say the date 1.7830 + if (isDate(value)) { 1.7831 + base = ' ' + value.toUTCString(); 1.7832 + } 1.7833 + 1.7834 + if (keys.length === 0) { 1.7835 + return braces[0] + base + braces[1]; 1.7836 + } 1.7837 + 1.7838 + if (recurseTimes < 0) { 1.7839 + if (isRegExp(value)) { 1.7840 + return stylize('' + value, 'regexp'); 1.7841 + } else { 1.7842 + return stylize('[Object]', 'special'); 1.7843 + } 1.7844 + } 1.7845 + 1.7846 + seen.push(value); 1.7847 + 1.7848 + var output = keys.map(function(key) { 1.7849 + var name, str; 1.7850 + if (value.__lookupGetter__) { 1.7851 + if (value.__lookupGetter__(key)) { 1.7852 + if (value.__lookupSetter__(key)) { 1.7853 + str = stylize('[Getter/Setter]', 'special'); 1.7854 + } else { 1.7855 + str = stylize('[Getter]', 'special'); 1.7856 + } 1.7857 + } else { 1.7858 + if (value.__lookupSetter__(key)) { 1.7859 + str = stylize('[Setter]', 'special'); 1.7860 + } 1.7861 + } 1.7862 + } 1.7863 + if (visible_keys.indexOf(key) < 0) { 1.7864 + name = '[' + key + ']'; 1.7865 + } 1.7866 + if (!str) { 1.7867 + if (seen.indexOf(value[key]) < 0) { 1.7868 + if (recurseTimes === null) { 1.7869 + str = format(value[key]); 1.7870 + } else { 1.7871 + str = format(value[key], recurseTimes - 1); 1.7872 + } 1.7873 + if (str.indexOf('\n') > -1) { 1.7874 + if (isArray(value)) { 1.7875 + str = str.split('\n').map(function(line) { 1.7876 + return ' ' + line; 1.7877 + }).join('\n').substr(2); 1.7878 + } else { 1.7879 + str = '\n' + str.split('\n').map(function(line) { 1.7880 + return ' ' + line; 1.7881 + }).join('\n'); 1.7882 + } 1.7883 + } 1.7884 + } else { 1.7885 + str = stylize('[Circular]', 'special'); 1.7886 + } 1.7887 + } 1.7888 + if (typeof name === 'undefined') { 1.7889 + if (type === 'Array' && key.match(/^\d+$/)) { 1.7890 + return str; 1.7891 + } 1.7892 + name = JSON.stringify('' + key); 1.7893 + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { 1.7894 + name = name.substr(1, name.length - 2); 1.7895 + name = stylize(name, 'name'); 1.7896 + } else { 1.7897 + name = name.replace(/'/g, "\\'") 1.7898 + .replace(/\\"/g, '"') 1.7899 + .replace(/(^"|"$)/g, "'"); 1.7900 + name = stylize(name, 'string'); 1.7901 + } 1.7902 + } 1.7903 + 1.7904 + return name + ': ' + str; 1.7905 + }); 1.7906 + 1.7907 + seen.pop(); 1.7908 + 1.7909 + var numLinesEst = 0; 1.7910 + var length = output.reduce(function(prev, cur) { 1.7911 + numLinesEst++; 1.7912 + if (cur.indexOf('\n') >= 0) numLinesEst++; 1.7913 + return prev + cur.length + 1; 1.7914 + }, 0); 1.7915 + 1.7916 + if (length > 50) { 1.7917 + output = braces[0] + 1.7918 + (base === '' ? '' : base + '\n ') + 1.7919 + ' ' + 1.7920 + output.join(',\n ') + 1.7921 + ' ' + 1.7922 + braces[1]; 1.7923 + 1.7924 + } else { 1.7925 + output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; 1.7926 + } 1.7927 + 1.7928 + return output; 1.7929 + } 1.7930 + return format(obj, (typeof depth === 'undefined' ? 2 : depth)); 1.7931 +}; 1.7932 + 1.7933 + 1.7934 +function isArray(ar) { 1.7935 + return ar instanceof Array || 1.7936 + Array.isArray(ar) || 1.7937 + (ar && ar !== Object.prototype && isArray(ar.__proto__)); 1.7938 +} 1.7939 + 1.7940 + 1.7941 +function isRegExp(re) { 1.7942 + return re instanceof RegExp || 1.7943 + (typeof re === 'object' && Object.prototype.toString.call(re) === '[object RegExp]'); 1.7944 +} 1.7945 + 1.7946 + 1.7947 +function isDate(d) { 1.7948 + if (d instanceof Date) return true; 1.7949 + if (typeof d !== 'object') return false; 1.7950 + var properties = Date.prototype && Object_getOwnPropertyNames(Date.prototype); 1.7951 + var proto = d.__proto__ && Object_getOwnPropertyNames(d.__proto__); 1.7952 + return JSON.stringify(proto) === JSON.stringify(properties); 1.7953 +} 1.7954 + 1.7955 +function pad(n) { 1.7956 + return n < 10 ? '0' + n.toString(10) : n.toString(10); 1.7957 +} 1.7958 + 1.7959 +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 1.7960 + 'Oct', 'Nov', 'Dec']; 1.7961 + 1.7962 +// 26 Feb 16:19:34 1.7963 +function timestamp() { 1.7964 + var d = new Date(); 1.7965 + var time = [pad(d.getHours()), 1.7966 + pad(d.getMinutes()), 1.7967 + pad(d.getSeconds())].join(':'); 1.7968 + return [d.getDate(), months[d.getMonth()], time].join(' '); 1.7969 +} 1.7970 + 1.7971 +exports.log = function (msg) {}; 1.7972 + 1.7973 +exports.pump = null; 1.7974 + 1.7975 +var Object_keys = Object.keys || function (obj) { 1.7976 + var res = []; 1.7977 + for (var key in obj) res.push(key); 1.7978 + return res; 1.7979 +}; 1.7980 + 1.7981 +var Object_getOwnPropertyNames = Object.getOwnPropertyNames || function (obj) { 1.7982 + var res = []; 1.7983 + for (var key in obj) { 1.7984 + if (Object.hasOwnProperty.call(obj, key)) res.push(key); 1.7985 + } 1.7986 + return res; 1.7987 +}; 1.7988 + 1.7989 +var Object_create = Object.create || function (prototype, properties) { 1.7990 + // from es5-shim 1.7991 + var object; 1.7992 + if (prototype === null) { 1.7993 + object = { '__proto__' : null }; 1.7994 + } 1.7995 + else { 1.7996 + if (typeof prototype !== 'object') { 1.7997 + throw new TypeError( 1.7998 + 'typeof prototype[' + (typeof prototype) + '] != \'object\'' 1.7999 + ); 1.8000 + } 1.8001 + var Type = function () {}; 1.8002 + Type.prototype = prototype; 1.8003 + object = new Type(); 1.8004 + object.__proto__ = prototype; 1.8005 + } 1.8006 + if (typeof properties !== 'undefined' && Object.defineProperties) { 1.8007 + Object.defineProperties(object, properties); 1.8008 + } 1.8009 + return object; 1.8010 +}; 1.8011 + 1.8012 +exports.inherits = function(ctor, superCtor) { 1.8013 + ctor.super_ = superCtor; 1.8014 + ctor.prototype = Object_create(superCtor.prototype, { 1.8015 + constructor: { 1.8016 + value: ctor, 1.8017 + enumerable: false, 1.8018 + writable: true, 1.8019 + configurable: true 1.8020 + } 1.8021 + }); 1.8022 +}; 1.8023 + 1.8024 +var formatRegExp = /%[sdj%]/g; 1.8025 +exports.format = function(f) { 1.8026 + if (typeof f !== 'string') { 1.8027 + var objects = []; 1.8028 + for (var i = 0; i < arguments.length; i++) { 1.8029 + objects.push(exports.inspect(arguments[i])); 1.8030 + } 1.8031 + return objects.join(' '); 1.8032 + } 1.8033 + 1.8034 + var i = 1; 1.8035 + var args = arguments; 1.8036 + var len = args.length; 1.8037 + var str = String(f).replace(formatRegExp, function(x) { 1.8038 + if (x === '%%') return '%'; 1.8039 + if (i >= len) return x; 1.8040 + switch (x) { 1.8041 + case '%s': return String(args[i++]); 1.8042 + case '%d': return Number(args[i++]); 1.8043 + case '%j': return JSON.stringify(args[i++]); 1.8044 + default: 1.8045 + return x; 1.8046 + } 1.8047 + }); 1.8048 + for(var x = args[i]; i < len; x = args[++i]){ 1.8049 + if (x === null || typeof x !== 'object') { 1.8050 + str += ' ' + x; 1.8051 + } else { 1.8052 + str += ' ' + exports.inspect(x); 1.8053 + } 1.8054 + } 1.8055 + return str; 1.8056 +}; 1.8057 + 1.8058 +},{"events":2}],9:[function(require,module,exports){ 1.8059 +(function(){// UTILITY 1.8060 +var util = require('util'); 1.8061 +var Buffer = require("buffer").Buffer; 1.8062 +var pSlice = Array.prototype.slice; 1.8063 + 1.8064 +function objectKeys(object) { 1.8065 + if (Object.keys) return Object.keys(object); 1.8066 + var result = []; 1.8067 + for (var name in object) { 1.8068 + if (Object.prototype.hasOwnProperty.call(object, name)) { 1.8069 + result.push(name); 1.8070 + } 1.8071 + } 1.8072 + return result; 1.8073 +} 1.8074 + 1.8075 +// 1. The assert module provides functions that throw 1.8076 +// AssertionError's when particular conditions are not met. The 1.8077 +// assert module must conform to the following interface. 1.8078 + 1.8079 +var assert = module.exports = ok; 1.8080 + 1.8081 +// 2. The AssertionError is defined in assert. 1.8082 +// new assert.AssertionError({ message: message, 1.8083 +// actual: actual, 1.8084 +// expected: expected }) 1.8085 + 1.8086 +assert.AssertionError = function AssertionError(options) { 1.8087 + this.name = 'AssertionError'; 1.8088 + this.message = options.message; 1.8089 + this.actual = options.actual; 1.8090 + this.expected = options.expected; 1.8091 + this.operator = options.operator; 1.8092 + var stackStartFunction = options.stackStartFunction || fail; 1.8093 + 1.8094 + if (Error.captureStackTrace) { 1.8095 + Error.captureStackTrace(this, stackStartFunction); 1.8096 + } 1.8097 +}; 1.8098 +util.inherits(assert.AssertionError, Error); 1.8099 + 1.8100 +function replacer(key, value) { 1.8101 + if (value === undefined) { 1.8102 + return '' + value; 1.8103 + } 1.8104 + if (typeof value === 'number' && (isNaN(value) || !isFinite(value))) { 1.8105 + return value.toString(); 1.8106 + } 1.8107 + if (typeof value === 'function' || value instanceof RegExp) { 1.8108 + return value.toString(); 1.8109 + } 1.8110 + return value; 1.8111 +} 1.8112 + 1.8113 +function truncate(s, n) { 1.8114 + if (typeof s == 'string') { 1.8115 + return s.length < n ? s : s.slice(0, n); 1.8116 + } else { 1.8117 + return s; 1.8118 + } 1.8119 +} 1.8120 + 1.8121 +assert.AssertionError.prototype.toString = function() { 1.8122 + if (this.message) { 1.8123 + return [this.name + ':', this.message].join(' '); 1.8124 + } else { 1.8125 + return [ 1.8126 + this.name + ':', 1.8127 + truncate(JSON.stringify(this.actual, replacer), 128), 1.8128 + this.operator, 1.8129 + truncate(JSON.stringify(this.expected, replacer), 128) 1.8130 + ].join(' '); 1.8131 + } 1.8132 +}; 1.8133 + 1.8134 +// assert.AssertionError instanceof Error 1.8135 + 1.8136 +assert.AssertionError.__proto__ = Error.prototype; 1.8137 + 1.8138 +// At present only the three keys mentioned above are used and 1.8139 +// understood by the spec. Implementations or sub modules can pass 1.8140 +// other keys to the AssertionError's constructor - they will be 1.8141 +// ignored. 1.8142 + 1.8143 +// 3. All of the following functions must throw an AssertionError 1.8144 +// when a corresponding condition is not met, with a message that 1.8145 +// may be undefined if not provided. All assertion methods provide 1.8146 +// both the actual and expected values to the assertion error for 1.8147 +// display purposes. 1.8148 + 1.8149 +function fail(actual, expected, message, operator, stackStartFunction) { 1.8150 + throw new assert.AssertionError({ 1.8151 + message: message, 1.8152 + actual: actual, 1.8153 + expected: expected, 1.8154 + operator: operator, 1.8155 + stackStartFunction: stackStartFunction 1.8156 + }); 1.8157 +} 1.8158 + 1.8159 +// EXTENSION! allows for well behaved errors defined elsewhere. 1.8160 +assert.fail = fail; 1.8161 + 1.8162 +// 4. Pure assertion tests whether a value is truthy, as determined 1.8163 +// by !!guard. 1.8164 +// assert.ok(guard, message_opt); 1.8165 +// This statement is equivalent to assert.equal(true, guard, 1.8166 +// message_opt);. To test strictly for the value true, use 1.8167 +// assert.strictEqual(true, guard, message_opt);. 1.8168 + 1.8169 +function ok(value, message) { 1.8170 + if (!!!value) fail(value, true, message, '==', assert.ok); 1.8171 +} 1.8172 +assert.ok = ok; 1.8173 + 1.8174 +// 5. The equality assertion tests shallow, coercive equality with 1.8175 +// ==. 1.8176 +// assert.equal(actual, expected, message_opt); 1.8177 + 1.8178 +assert.equal = function equal(actual, expected, message) { 1.8179 + if (actual != expected) fail(actual, expected, message, '==', assert.equal); 1.8180 +}; 1.8181 + 1.8182 +// 6. The non-equality assertion tests for whether two objects are not equal 1.8183 +// with != assert.notEqual(actual, expected, message_opt); 1.8184 + 1.8185 +assert.notEqual = function notEqual(actual, expected, message) { 1.8186 + if (actual == expected) { 1.8187 + fail(actual, expected, message, '!=', assert.notEqual); 1.8188 + } 1.8189 +}; 1.8190 + 1.8191 +// 7. The equivalence assertion tests a deep equality relation. 1.8192 +// assert.deepEqual(actual, expected, message_opt); 1.8193 + 1.8194 +assert.deepEqual = function deepEqual(actual, expected, message) { 1.8195 + if (!_deepEqual(actual, expected)) { 1.8196 + fail(actual, expected, message, 'deepEqual', assert.deepEqual); 1.8197 + } 1.8198 +}; 1.8199 + 1.8200 +function _deepEqual(actual, expected) { 1.8201 + // 7.1. All identical values are equivalent, as determined by ===. 1.8202 + if (actual === expected) { 1.8203 + return true; 1.8204 + 1.8205 + } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { 1.8206 + if (actual.length != expected.length) return false; 1.8207 + 1.8208 + for (var i = 0; i < actual.length; i++) { 1.8209 + if (actual[i] !== expected[i]) return false; 1.8210 + } 1.8211 + 1.8212 + return true; 1.8213 + 1.8214 + // 7.2. If the expected value is a Date object, the actual value is 1.8215 + // equivalent if it is also a Date object that refers to the same time. 1.8216 + } else if (actual instanceof Date && expected instanceof Date) { 1.8217 + return actual.getTime() === expected.getTime(); 1.8218 + 1.8219 + // 7.3. Other pairs that do not both pass typeof value == 'object', 1.8220 + // equivalence is determined by ==. 1.8221 + } else if (typeof actual != 'object' && typeof expected != 'object') { 1.8222 + return actual == expected; 1.8223 + 1.8224 + // 7.4. For all other Object pairs, including Array objects, equivalence is 1.8225 + // determined by having the same number of owned properties (as verified 1.8226 + // with Object.prototype.hasOwnProperty.call), the same set of keys 1.8227 + // (although not necessarily the same order), equivalent values for every 1.8228 + // corresponding key, and an identical 'prototype' property. Note: this 1.8229 + // accounts for both named and indexed properties on Arrays. 1.8230 + } else { 1.8231 + return objEquiv(actual, expected); 1.8232 + } 1.8233 +} 1.8234 + 1.8235 +function isUndefinedOrNull(value) { 1.8236 + return value === null || value === undefined; 1.8237 +} 1.8238 + 1.8239 +function isArguments(object) { 1.8240 + return Object.prototype.toString.call(object) == '[object Arguments]'; 1.8241 +} 1.8242 + 1.8243 +function objEquiv(a, b) { 1.8244 + if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) 1.8245 + return false; 1.8246 + // an identical 'prototype' property. 1.8247 + if (a.prototype !== b.prototype) return false; 1.8248 + //~~~I've managed to break Object.keys through screwy arguments passing. 1.8249 + // Converting to array solves the problem. 1.8250 + if (isArguments(a)) { 1.8251 + if (!isArguments(b)) { 1.8252 + return false; 1.8253 + } 1.8254 + a = pSlice.call(a); 1.8255 + b = pSlice.call(b); 1.8256 + return _deepEqual(a, b); 1.8257 + } 1.8258 + try { 1.8259 + var ka = objectKeys(a), 1.8260 + kb = objectKeys(b), 1.8261 + key, i; 1.8262 + } catch (e) {//happens when one is a string literal and the other isn't 1.8263 + return false; 1.8264 + } 1.8265 + // having the same number of owned properties (keys incorporates 1.8266 + // hasOwnProperty) 1.8267 + if (ka.length != kb.length) 1.8268 + return false; 1.8269 + //the same set of keys (although not necessarily the same order), 1.8270 + ka.sort(); 1.8271 + kb.sort(); 1.8272 + //~~~cheap key test 1.8273 + for (i = ka.length - 1; i >= 0; i--) { 1.8274 + if (ka[i] != kb[i]) 1.8275 + return false; 1.8276 + } 1.8277 + //equivalent values for every corresponding key, and 1.8278 + //~~~possibly expensive deep test 1.8279 + for (i = ka.length - 1; i >= 0; i--) { 1.8280 + key = ka[i]; 1.8281 + if (!_deepEqual(a[key], b[key])) return false; 1.8282 + } 1.8283 + return true; 1.8284 +} 1.8285 + 1.8286 +// 8. The non-equivalence assertion tests for any deep inequality. 1.8287 +// assert.notDeepEqual(actual, expected, message_opt); 1.8288 + 1.8289 +assert.notDeepEqual = function notDeepEqual(actual, expected, message) { 1.8290 + if (_deepEqual(actual, expected)) { 1.8291 + fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); 1.8292 + } 1.8293 +}; 1.8294 + 1.8295 +// 9. The strict equality assertion tests strict equality, as determined by ===. 1.8296 +// assert.strictEqual(actual, expected, message_opt); 1.8297 + 1.8298 +assert.strictEqual = function strictEqual(actual, expected, message) { 1.8299 + if (actual !== expected) { 1.8300 + fail(actual, expected, message, '===', assert.strictEqual); 1.8301 + } 1.8302 +}; 1.8303 + 1.8304 +// 10. The strict non-equality assertion tests for strict inequality, as 1.8305 +// determined by !==. assert.notStrictEqual(actual, expected, message_opt); 1.8306 + 1.8307 +assert.notStrictEqual = function notStrictEqual(actual, expected, message) { 1.8308 + if (actual === expected) { 1.8309 + fail(actual, expected, message, '!==', assert.notStrictEqual); 1.8310 + } 1.8311 +}; 1.8312 + 1.8313 +function expectedException(actual, expected) { 1.8314 + if (!actual || !expected) { 1.8315 + return false; 1.8316 + } 1.8317 + 1.8318 + if (expected instanceof RegExp) { 1.8319 + return expected.test(actual); 1.8320 + } else if (actual instanceof expected) { 1.8321 + return true; 1.8322 + } else if (expected.call({}, actual) === true) { 1.8323 + return true; 1.8324 + } 1.8325 + 1.8326 + return false; 1.8327 +} 1.8328 + 1.8329 +function _throws(shouldThrow, block, expected, message) { 1.8330 + var actual; 1.8331 + 1.8332 + if (typeof expected === 'string') { 1.8333 + message = expected; 1.8334 + expected = null; 1.8335 + } 1.8336 + 1.8337 + try { 1.8338 + block(); 1.8339 + } catch (e) { 1.8340 + actual = e; 1.8341 + } 1.8342 + 1.8343 + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + 1.8344 + (message ? ' ' + message : '.'); 1.8345 + 1.8346 + if (shouldThrow && !actual) { 1.8347 + fail('Missing expected exception' + message); 1.8348 + } 1.8349 + 1.8350 + if (!shouldThrow && expectedException(actual, expected)) { 1.8351 + fail('Got unwanted exception' + message); 1.8352 + } 1.8353 + 1.8354 + if ((shouldThrow && actual && expected && 1.8355 + !expectedException(actual, expected)) || (!shouldThrow && actual)) { 1.8356 + throw actual; 1.8357 + } 1.8358 +} 1.8359 + 1.8360 +// 11. Expected to throw an error: 1.8361 +// assert.throws(block, Error_opt, message_opt); 1.8362 + 1.8363 +assert.throws = function(block, /*optional*/error, /*optional*/message) { 1.8364 + _throws.apply(this, [true].concat(pSlice.call(arguments))); 1.8365 +}; 1.8366 + 1.8367 +// EXTENSION! This is annoying to write outside this module. 1.8368 +assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { 1.8369 + _throws.apply(this, [false].concat(pSlice.call(arguments))); 1.8370 +}; 1.8371 + 1.8372 +assert.ifError = function(err) { if (err) {throw err;}}; 1.8373 + 1.8374 +})() 1.8375 +},{"util":8,"buffer":13}],11:[function(require,module,exports){ 1.8376 +(function(){// Underscore.js 1.4.4 1.8377 +// http://underscorejs.org 1.8378 +// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. 1.8379 +// Underscore may be freely distributed under the MIT license. 1.8380 + 1.8381 +(function() { 1.8382 + 1.8383 + // Baseline setup 1.8384 + // -------------- 1.8385 + 1.8386 + // Establish the root object, `window` in the browser, or `global` on the server. 1.8387 + var root = this; 1.8388 + 1.8389 + // Save the previous value of the `_` variable. 1.8390 + var previousUnderscore = root._; 1.8391 + 1.8392 + // Establish the object that gets returned to break out of a loop iteration. 1.8393 + var breaker = {}; 1.8394 + 1.8395 + // Save bytes in the minified (but not gzipped) version: 1.8396 + var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; 1.8397 + 1.8398 + // Create quick reference variables for speed access to core prototypes. 1.8399 + var push = ArrayProto.push, 1.8400 + slice = ArrayProto.slice, 1.8401 + concat = ArrayProto.concat, 1.8402 + toString = ObjProto.toString, 1.8403 + hasOwnProperty = ObjProto.hasOwnProperty; 1.8404 + 1.8405 + // All **ECMAScript 5** native function implementations that we hope to use 1.8406 + // are declared here. 1.8407 + var 1.8408 + nativeForEach = ArrayProto.forEach, 1.8409 + nativeMap = ArrayProto.map, 1.8410 + nativeReduce = ArrayProto.reduce, 1.8411 + nativeReduceRight = ArrayProto.reduceRight, 1.8412 + nativeFilter = ArrayProto.filter, 1.8413 + nativeEvery = ArrayProto.every, 1.8414 + nativeSome = ArrayProto.some, 1.8415 + nativeIndexOf = ArrayProto.indexOf, 1.8416 + nativeLastIndexOf = ArrayProto.lastIndexOf, 1.8417 + nativeIsArray = Array.isArray, 1.8418 + nativeKeys = Object.keys, 1.8419 + nativeBind = FuncProto.bind; 1.8420 + 1.8421 + // Create a safe reference to the Underscore object for use below. 1.8422 + var _ = function(obj) { 1.8423 + if (obj instanceof _) return obj; 1.8424 + if (!(this instanceof _)) return new _(obj); 1.8425 + this._wrapped = obj; 1.8426 + }; 1.8427 + 1.8428 + // Export the Underscore object for **Node.js**, with 1.8429 + // backwards-compatibility for the old `require()` API. If we're in 1.8430 + // the browser, add `_` as a global object via a string identifier, 1.8431 + // for Closure Compiler "advanced" mode. 1.8432 + if (typeof exports !== 'undefined') { 1.8433 + if (typeof module !== 'undefined' && module.exports) { 1.8434 + exports = module.exports = _; 1.8435 + } 1.8436 + exports._ = _; 1.8437 + } else { 1.8438 + root._ = _; 1.8439 + } 1.8440 + 1.8441 + // Current version. 1.8442 + _.VERSION = '1.4.4'; 1.8443 + 1.8444 + // Collection Functions 1.8445 + // -------------------- 1.8446 + 1.8447 + // The cornerstone, an `each` implementation, aka `forEach`. 1.8448 + // Handles objects with the built-in `forEach`, arrays, and raw objects. 1.8449 + // Delegates to **ECMAScript 5**'s native `forEach` if available. 1.8450 + var each = _.each = _.forEach = function(obj, iterator, context) { 1.8451 + if (obj == null) return; 1.8452 + if (nativeForEach && obj.forEach === nativeForEach) { 1.8453 + obj.forEach(iterator, context); 1.8454 + } else if (obj.length === +obj.length) { 1.8455 + for (var i = 0, l = obj.length; i < l; i++) { 1.8456 + if (iterator.call(context, obj[i], i, obj) === breaker) return; 1.8457 + } 1.8458 + } else { 1.8459 + for (var key in obj) { 1.8460 + if (_.has(obj, key)) { 1.8461 + if (iterator.call(context, obj[key], key, obj) === breaker) return; 1.8462 + } 1.8463 + } 1.8464 + } 1.8465 + }; 1.8466 + 1.8467 + // Return the results of applying the iterator to each element. 1.8468 + // Delegates to **ECMAScript 5**'s native `map` if available. 1.8469 + _.map = _.collect = function(obj, iterator, context) { 1.8470 + var results = []; 1.8471 + if (obj == null) return results; 1.8472 + if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); 1.8473 + each(obj, function(value, index, list) { 1.8474 + results[results.length] = iterator.call(context, value, index, list); 1.8475 + }); 1.8476 + return results; 1.8477 + }; 1.8478 + 1.8479 + var reduceError = 'Reduce of empty array with no initial value'; 1.8480 + 1.8481 + // **Reduce** builds up a single result from a list of values, aka `inject`, 1.8482 + // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. 1.8483 + _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { 1.8484 + var initial = arguments.length > 2; 1.8485 + if (obj == null) obj = []; 1.8486 + if (nativeReduce && obj.reduce === nativeReduce) { 1.8487 + if (context) iterator = _.bind(iterator, context); 1.8488 + return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); 1.8489 + } 1.8490 + each(obj, function(value, index, list) { 1.8491 + if (!initial) { 1.8492 + memo = value; 1.8493 + initial = true; 1.8494 + } else { 1.8495 + memo = iterator.call(context, memo, value, index, list); 1.8496 + } 1.8497 + }); 1.8498 + if (!initial) throw new TypeError(reduceError); 1.8499 + return memo; 1.8500 + }; 1.8501 + 1.8502 + // The right-associative version of reduce, also known as `foldr`. 1.8503 + // Delegates to **ECMAScript 5**'s native `reduceRight` if available. 1.8504 + _.reduceRight = _.foldr = function(obj, iterator, memo, context) { 1.8505 + var initial = arguments.length > 2; 1.8506 + if (obj == null) obj = []; 1.8507 + if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { 1.8508 + if (context) iterator = _.bind(iterator, context); 1.8509 + return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); 1.8510 + } 1.8511 + var length = obj.length; 1.8512 + if (length !== +length) { 1.8513 + var keys = _.keys(obj); 1.8514 + length = keys.length; 1.8515 + } 1.8516 + each(obj, function(value, index, list) { 1.8517 + index = keys ? keys[--length] : --length; 1.8518 + if (!initial) { 1.8519 + memo = obj[index]; 1.8520 + initial = true; 1.8521 + } else { 1.8522 + memo = iterator.call(context, memo, obj[index], index, list); 1.8523 + } 1.8524 + }); 1.8525 + if (!initial) throw new TypeError(reduceError); 1.8526 + return memo; 1.8527 + }; 1.8528 + 1.8529 + // Return the first value which passes a truth test. Aliased as `detect`. 1.8530 + _.find = _.detect = function(obj, iterator, context) { 1.8531 + var result; 1.8532 + any(obj, function(value, index, list) { 1.8533 + if (iterator.call(context, value, index, list)) { 1.8534 + result = value; 1.8535 + return true; 1.8536 + } 1.8537 + }); 1.8538 + return result; 1.8539 + }; 1.8540 + 1.8541 + // Return all the elements that pass a truth test. 1.8542 + // Delegates to **ECMAScript 5**'s native `filter` if available. 1.8543 + // Aliased as `select`. 1.8544 + _.filter = _.select = function(obj, iterator, context) { 1.8545 + var results = []; 1.8546 + if (obj == null) return results; 1.8547 + if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); 1.8548 + each(obj, function(value, index, list) { 1.8549 + if (iterator.call(context, value, index, list)) results[results.length] = value; 1.8550 + }); 1.8551 + return results; 1.8552 + }; 1.8553 + 1.8554 + // Return all the elements for which a truth test fails. 1.8555 + _.reject = function(obj, iterator, context) { 1.8556 + return _.filter(obj, function(value, index, list) { 1.8557 + return !iterator.call(context, value, index, list); 1.8558 + }, context); 1.8559 + }; 1.8560 + 1.8561 + // Determine whether all of the elements match a truth test. 1.8562 + // Delegates to **ECMAScript 5**'s native `every` if available. 1.8563 + // Aliased as `all`. 1.8564 + _.every = _.all = function(obj, iterator, context) { 1.8565 + iterator || (iterator = _.identity); 1.8566 + var result = true; 1.8567 + if (obj == null) return result; 1.8568 + if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); 1.8569 + each(obj, function(value, index, list) { 1.8570 + if (!(result = result && iterator.call(context, value, index, list))) return breaker; 1.8571 + }); 1.8572 + return !!result; 1.8573 + }; 1.8574 + 1.8575 + // Determine if at least one element in the object matches a truth test. 1.8576 + // Delegates to **ECMAScript 5**'s native `some` if available. 1.8577 + // Aliased as `any`. 1.8578 + var any = _.some = _.any = function(obj, iterator, context) { 1.8579 + iterator || (iterator = _.identity); 1.8580 + var result = false; 1.8581 + if (obj == null) return result; 1.8582 + if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); 1.8583 + each(obj, function(value, index, list) { 1.8584 + if (result || (result = iterator.call(context, value, index, list))) return breaker; 1.8585 + }); 1.8586 + return !!result; 1.8587 + }; 1.8588 + 1.8589 + // Determine if the array or object contains a given value (using `===`). 1.8590 + // Aliased as `include`. 1.8591 + _.contains = _.include = function(obj, target) { 1.8592 + if (obj == null) return false; 1.8593 + if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; 1.8594 + return any(obj, function(value) { 1.8595 + return value === target; 1.8596 + }); 1.8597 + }; 1.8598 + 1.8599 + // Invoke a method (with arguments) on every item in a collection. 1.8600 + _.invoke = function(obj, method) { 1.8601 + var args = slice.call(arguments, 2); 1.8602 + var isFunc = _.isFunction(method); 1.8603 + return _.map(obj, function(value) { 1.8604 + return (isFunc ? method : value[method]).apply(value, args); 1.8605 + }); 1.8606 + }; 1.8607 + 1.8608 + // Convenience version of a common use case of `map`: fetching a property. 1.8609 + _.pluck = function(obj, key) { 1.8610 + return _.map(obj, function(value){ return value[key]; }); 1.8611 + }; 1.8612 + 1.8613 + // Convenience version of a common use case of `filter`: selecting only objects 1.8614 + // containing specific `key:value` pairs. 1.8615 + _.where = function(obj, attrs, first) { 1.8616 + if (_.isEmpty(attrs)) return first ? null : []; 1.8617 + return _[first ? 'find' : 'filter'](obj, function(value) { 1.8618 + for (var key in attrs) { 1.8619 + if (attrs[key] !== value[key]) return false; 1.8620 + } 1.8621 + return true; 1.8622 + }); 1.8623 + }; 1.8624 + 1.8625 + // Convenience version of a common use case of `find`: getting the first object 1.8626 + // containing specific `key:value` pairs. 1.8627 + _.findWhere = function(obj, attrs) { 1.8628 + return _.where(obj, attrs, true); 1.8629 + }; 1.8630 + 1.8631 + // Return the maximum element or (element-based computation). 1.8632 + // Can't optimize arrays of integers longer than 65,535 elements. 1.8633 + // See: https://bugs.webkit.org/show_bug.cgi?id=80797 1.8634 + _.max = function(obj, iterator, context) { 1.8635 + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { 1.8636 + return Math.max.apply(Math, obj); 1.8637 + } 1.8638 + if (!iterator && _.isEmpty(obj)) return -Infinity; 1.8639 + var result = {computed : -Infinity, value: -Infinity}; 1.8640 + each(obj, function(value, index, list) { 1.8641 + var computed = iterator ? iterator.call(context, value, index, list) : value; 1.8642 + computed >= result.computed && (result = {value : value, computed : computed}); 1.8643 + }); 1.8644 + return result.value; 1.8645 + }; 1.8646 + 1.8647 + // Return the minimum element (or element-based computation). 1.8648 + _.min = function(obj, iterator, context) { 1.8649 + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { 1.8650 + return Math.min.apply(Math, obj); 1.8651 + } 1.8652 + if (!iterator && _.isEmpty(obj)) return Infinity; 1.8653 + var result = {computed : Infinity, value: Infinity}; 1.8654 + each(obj, function(value, index, list) { 1.8655 + var computed = iterator ? iterator.call(context, value, index, list) : value; 1.8656 + computed < result.computed && (result = {value : value, computed : computed}); 1.8657 + }); 1.8658 + return result.value; 1.8659 + }; 1.8660 + 1.8661 + // Shuffle an array. 1.8662 + _.shuffle = function(obj) { 1.8663 + var rand; 1.8664 + var index = 0; 1.8665 + var shuffled = []; 1.8666 + each(obj, function(value) { 1.8667 + rand = _.random(index++); 1.8668 + shuffled[index - 1] = shuffled[rand]; 1.8669 + shuffled[rand] = value; 1.8670 + }); 1.8671 + return shuffled; 1.8672 + }; 1.8673 + 1.8674 + // An internal function to generate lookup iterators. 1.8675 + var lookupIterator = function(value) { 1.8676 + return _.isFunction(value) ? value : function(obj){ return obj[value]; }; 1.8677 + }; 1.8678 + 1.8679 + // Sort the object's values by a criterion produced by an iterator. 1.8680 + _.sortBy = function(obj, value, context) { 1.8681 + var iterator = lookupIterator(value); 1.8682 + return _.pluck(_.map(obj, function(value, index, list) { 1.8683 + return { 1.8684 + value : value, 1.8685 + index : index, 1.8686 + criteria : iterator.call(context, value, index, list) 1.8687 + }; 1.8688 + }).sort(function(left, right) { 1.8689 + var a = left.criteria; 1.8690 + var b = right.criteria; 1.8691 + if (a !== b) { 1.8692 + if (a > b || a === void 0) return 1; 1.8693 + if (a < b || b === void 0) return -1; 1.8694 + } 1.8695 + return left.index < right.index ? -1 : 1; 1.8696 + }), 'value'); 1.8697 + }; 1.8698 + 1.8699 + // An internal function used for aggregate "group by" operations. 1.8700 + var group = function(obj, value, context, behavior) { 1.8701 + var result = {}; 1.8702 + var iterator = lookupIterator(value || _.identity); 1.8703 + each(obj, function(value, index) { 1.8704 + var key = iterator.call(context, value, index, obj); 1.8705 + behavior(result, key, value); 1.8706 + }); 1.8707 + return result; 1.8708 + }; 1.8709 + 1.8710 + // Groups the object's values by a criterion. Pass either a string attribute 1.8711 + // to group by, or a function that returns the criterion. 1.8712 + _.groupBy = function(obj, value, context) { 1.8713 + return group(obj, value, context, function(result, key, value) { 1.8714 + (_.has(result, key) ? result[key] : (result[key] = [])).push(value); 1.8715 + }); 1.8716 + }; 1.8717 + 1.8718 + // Counts instances of an object that group by a certain criterion. Pass 1.8719 + // either a string attribute to count by, or a function that returns the 1.8720 + // criterion. 1.8721 + _.countBy = function(obj, value, context) { 1.8722 + return group(obj, value, context, function(result, key) { 1.8723 + if (!_.has(result, key)) result[key] = 0; 1.8724 + result[key]++; 1.8725 + }); 1.8726 + }; 1.8727 + 1.8728 + // Use a comparator function to figure out the smallest index at which 1.8729 + // an object should be inserted so as to maintain order. Uses binary search. 1.8730 + _.sortedIndex = function(array, obj, iterator, context) { 1.8731 + iterator = iterator == null ? _.identity : lookupIterator(iterator); 1.8732 + var value = iterator.call(context, obj); 1.8733 + var low = 0, high = array.length; 1.8734 + while (low < high) { 1.8735 + var mid = (low + high) >>> 1; 1.8736 + iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; 1.8737 + } 1.8738 + return low; 1.8739 + }; 1.8740 + 1.8741 + // Safely convert anything iterable into a real, live array. 1.8742 + _.toArray = function(obj) { 1.8743 + if (!obj) return []; 1.8744 + if (_.isArray(obj)) return slice.call(obj); 1.8745 + if (obj.length === +obj.length) return _.map(obj, _.identity); 1.8746 + return _.values(obj); 1.8747 + }; 1.8748 + 1.8749 + // Return the number of elements in an object. 1.8750 + _.size = function(obj) { 1.8751 + if (obj == null) return 0; 1.8752 + return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; 1.8753 + }; 1.8754 + 1.8755 + // Array Functions 1.8756 + // --------------- 1.8757 + 1.8758 + // Get the first element of an array. Passing **n** will return the first N 1.8759 + // values in the array. Aliased as `head` and `take`. The **guard** check 1.8760 + // allows it to work with `_.map`. 1.8761 + _.first = _.head = _.take = function(array, n, guard) { 1.8762 + if (array == null) return void 0; 1.8763 + return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; 1.8764 + }; 1.8765 + 1.8766 + // Returns everything but the last entry of the array. Especially useful on 1.8767 + // the arguments object. Passing **n** will return all the values in 1.8768 + // the array, excluding the last N. The **guard** check allows it to work with 1.8769 + // `_.map`. 1.8770 + _.initial = function(array, n, guard) { 1.8771 + return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); 1.8772 + }; 1.8773 + 1.8774 + // Get the last element of an array. Passing **n** will return the last N 1.8775 + // values in the array. The **guard** check allows it to work with `_.map`. 1.8776 + _.last = function(array, n, guard) { 1.8777 + if (array == null) return void 0; 1.8778 + if ((n != null) && !guard) { 1.8779 + return slice.call(array, Math.max(array.length - n, 0)); 1.8780 + } else { 1.8781 + return array[array.length - 1]; 1.8782 + } 1.8783 + }; 1.8784 + 1.8785 + // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. 1.8786 + // Especially useful on the arguments object. Passing an **n** will return 1.8787 + // the rest N values in the array. The **guard** 1.8788 + // check allows it to work with `_.map`. 1.8789 + _.rest = _.tail = _.drop = function(array, n, guard) { 1.8790 + return slice.call(array, (n == null) || guard ? 1 : n); 1.8791 + }; 1.8792 + 1.8793 + // Trim out all falsy values from an array. 1.8794 + _.compact = function(array) { 1.8795 + return _.filter(array, _.identity); 1.8796 + }; 1.8797 + 1.8798 + // Internal implementation of a recursive `flatten` function. 1.8799 + var flatten = function(input, shallow, output) { 1.8800 + each(input, function(value) { 1.8801 + if (_.isArray(value)) { 1.8802 + shallow ? push.apply(output, value) : flatten(value, shallow, output); 1.8803 + } else { 1.8804 + output.push(value); 1.8805 + } 1.8806 + }); 1.8807 + return output; 1.8808 + }; 1.8809 + 1.8810 + // Return a completely flattened version of an array. 1.8811 + _.flatten = function(array, shallow) { 1.8812 + return flatten(array, shallow, []); 1.8813 + }; 1.8814 + 1.8815 + // Return a version of the array that does not contain the specified value(s). 1.8816 + _.without = function(array) { 1.8817 + return _.difference(array, slice.call(arguments, 1)); 1.8818 + }; 1.8819 + 1.8820 + // Produce a duplicate-free version of the array. If the array has already 1.8821 + // been sorted, you have the option of using a faster algorithm. 1.8822 + // Aliased as `unique`. 1.8823 + _.uniq = _.unique = function(array, isSorted, iterator, context) { 1.8824 + if (_.isFunction(isSorted)) { 1.8825 + context = iterator; 1.8826 + iterator = isSorted; 1.8827 + isSorted = false; 1.8828 + } 1.8829 + var initial = iterator ? _.map(array, iterator, context) : array; 1.8830 + var results = []; 1.8831 + var seen = []; 1.8832 + each(initial, function(value, index) { 1.8833 + if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { 1.8834 + seen.push(value); 1.8835 + results.push(array[index]); 1.8836 + } 1.8837 + }); 1.8838 + return results; 1.8839 + }; 1.8840 + 1.8841 + // Produce an array that contains the union: each distinct element from all of 1.8842 + // the passed-in arrays. 1.8843 + _.union = function() { 1.8844 + return _.uniq(concat.apply(ArrayProto, arguments)); 1.8845 + }; 1.8846 + 1.8847 + // Produce an array that contains every item shared between all the 1.8848 + // passed-in arrays. 1.8849 + _.intersection = function(array) { 1.8850 + var rest = slice.call(arguments, 1); 1.8851 + return _.filter(_.uniq(array), function(item) { 1.8852 + return _.every(rest, function(other) { 1.8853 + return _.indexOf(other, item) >= 0; 1.8854 + }); 1.8855 + }); 1.8856 + }; 1.8857 + 1.8858 + // Take the difference between one array and a number of other arrays. 1.8859 + // Only the elements present in just the first array will remain. 1.8860 + _.difference = function(array) { 1.8861 + var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); 1.8862 + return _.filter(array, function(value){ return !_.contains(rest, value); }); 1.8863 + }; 1.8864 + 1.8865 + // Zip together multiple lists into a single array -- elements that share 1.8866 + // an index go together. 1.8867 + _.zip = function() { 1.8868 + var args = slice.call(arguments); 1.8869 + var length = _.max(_.pluck(args, 'length')); 1.8870 + var results = new Array(length); 1.8871 + for (var i = 0; i < length; i++) { 1.8872 + results[i] = _.pluck(args, "" + i); 1.8873 + } 1.8874 + return results; 1.8875 + }; 1.8876 + 1.8877 + // Converts lists into objects. Pass either a single array of `[key, value]` 1.8878 + // pairs, or two parallel arrays of the same length -- one of keys, and one of 1.8879 + // the corresponding values. 1.8880 + _.object = function(list, values) { 1.8881 + if (list == null) return {}; 1.8882 + var result = {}; 1.8883 + for (var i = 0, l = list.length; i < l; i++) { 1.8884 + if (values) { 1.8885 + result[list[i]] = values[i]; 1.8886 + } else { 1.8887 + result[list[i][0]] = list[i][1]; 1.8888 + } 1.8889 + } 1.8890 + return result; 1.8891 + }; 1.8892 + 1.8893 + // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), 1.8894 + // we need this function. Return the position of the first occurrence of an 1.8895 + // item in an array, or -1 if the item is not included in the array. 1.8896 + // Delegates to **ECMAScript 5**'s native `indexOf` if available. 1.8897 + // If the array is large and already in sort order, pass `true` 1.8898 + // for **isSorted** to use binary search. 1.8899 + _.indexOf = function(array, item, isSorted) { 1.8900 + if (array == null) return -1; 1.8901 + var i = 0, l = array.length; 1.8902 + if (isSorted) { 1.8903 + if (typeof isSorted == 'number') { 1.8904 + i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); 1.8905 + } else { 1.8906 + i = _.sortedIndex(array, item); 1.8907 + return array[i] === item ? i : -1; 1.8908 + } 1.8909 + } 1.8910 + if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); 1.8911 + for (; i < l; i++) if (array[i] === item) return i; 1.8912 + return -1; 1.8913 + }; 1.8914 + 1.8915 + // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. 1.8916 + _.lastIndexOf = function(array, item, from) { 1.8917 + if (array == null) return -1; 1.8918 + var hasIndex = from != null; 1.8919 + if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { 1.8920 + return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); 1.8921 + } 1.8922 + var i = (hasIndex ? from : array.length); 1.8923 + while (i--) if (array[i] === item) return i; 1.8924 + return -1; 1.8925 + }; 1.8926 + 1.8927 + // Generate an integer Array containing an arithmetic progression. A port of 1.8928 + // the native Python `range()` function. See 1.8929 + // [the Python documentation](http://docs.python.org/library/functions.html#range). 1.8930 + _.range = function(start, stop, step) { 1.8931 + if (arguments.length <= 1) { 1.8932 + stop = start || 0; 1.8933 + start = 0; 1.8934 + } 1.8935 + step = arguments[2] || 1; 1.8936 + 1.8937 + var len = Math.max(Math.ceil((stop - start) / step), 0); 1.8938 + var idx = 0; 1.8939 + var range = new Array(len); 1.8940 + 1.8941 + while(idx < len) { 1.8942 + range[idx++] = start; 1.8943 + start += step; 1.8944 + } 1.8945 + 1.8946 + return range; 1.8947 + }; 1.8948 + 1.8949 + // Function (ahem) Functions 1.8950 + // ------------------ 1.8951 + 1.8952 + // Create a function bound to a given object (assigning `this`, and arguments, 1.8953 + // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if 1.8954 + // available. 1.8955 + _.bind = function(func, context) { 1.8956 + if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); 1.8957 + var args = slice.call(arguments, 2); 1.8958 + return function() { 1.8959 + return func.apply(context, args.concat(slice.call(arguments))); 1.8960 + }; 1.8961 + }; 1.8962 + 1.8963 + // Partially apply a function by creating a version that has had some of its 1.8964 + // arguments pre-filled, without changing its dynamic `this` context. 1.8965 + _.partial = function(func) { 1.8966 + var args = slice.call(arguments, 1); 1.8967 + return function() { 1.8968 + return func.apply(this, args.concat(slice.call(arguments))); 1.8969 + }; 1.8970 + }; 1.8971 + 1.8972 + // Bind all of an object's methods to that object. Useful for ensuring that 1.8973 + // all callbacks defined on an object belong to it. 1.8974 + _.bindAll = function(obj) { 1.8975 + var funcs = slice.call(arguments, 1); 1.8976 + if (funcs.length === 0) funcs = _.functions(obj); 1.8977 + each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); 1.8978 + return obj; 1.8979 + }; 1.8980 + 1.8981 + // Memoize an expensive function by storing its results. 1.8982 + _.memoize = function(func, hasher) { 1.8983 + var memo = {}; 1.8984 + hasher || (hasher = _.identity); 1.8985 + return function() { 1.8986 + var key = hasher.apply(this, arguments); 1.8987 + return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); 1.8988 + }; 1.8989 + }; 1.8990 + 1.8991 + // Delays a function for the given number of milliseconds, and then calls 1.8992 + // it with the arguments supplied. 1.8993 + _.delay = function(func, wait) { 1.8994 + var args = slice.call(arguments, 2); 1.8995 + return setTimeout(function(){ return func.apply(null, args); }, wait); 1.8996 + }; 1.8997 + 1.8998 + // Defers a function, scheduling it to run after the current call stack has 1.8999 + // cleared. 1.9000 + _.defer = function(func) { 1.9001 + return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); 1.9002 + }; 1.9003 + 1.9004 + // Returns a function, that, when invoked, will only be triggered at most once 1.9005 + // during a given window of time. 1.9006 + _.throttle = function(func, wait) { 1.9007 + var context, args, timeout, result; 1.9008 + var previous = 0; 1.9009 + var later = function() { 1.9010 + previous = new Date; 1.9011 + timeout = null; 1.9012 + result = func.apply(context, args); 1.9013 + }; 1.9014 + return function() { 1.9015 + var now = new Date; 1.9016 + var remaining = wait - (now - previous); 1.9017 + context = this; 1.9018 + args = arguments; 1.9019 + if (remaining <= 0) { 1.9020 + clearTimeout(timeout); 1.9021 + timeout = null; 1.9022 + previous = now; 1.9023 + result = func.apply(context, args); 1.9024 + } else if (!timeout) { 1.9025 + timeout = setTimeout(later, remaining); 1.9026 + } 1.9027 + return result; 1.9028 + }; 1.9029 + }; 1.9030 + 1.9031 + // Returns a function, that, as long as it continues to be invoked, will not 1.9032 + // be triggered. The function will be called after it stops being called for 1.9033 + // N milliseconds. If `immediate` is passed, trigger the function on the 1.9034 + // leading edge, instead of the trailing. 1.9035 + _.debounce = function(func, wait, immediate) { 1.9036 + var timeout, result; 1.9037 + return function() { 1.9038 + var context = this, args = arguments; 1.9039 + var later = function() { 1.9040 + timeout = null; 1.9041 + if (!immediate) result = func.apply(context, args); 1.9042 + }; 1.9043 + var callNow = immediate && !timeout; 1.9044 + clearTimeout(timeout); 1.9045 + timeout = setTimeout(later, wait); 1.9046 + if (callNow) result = func.apply(context, args); 1.9047 + return result; 1.9048 + }; 1.9049 + }; 1.9050 + 1.9051 + // Returns a function that will be executed at most one time, no matter how 1.9052 + // often you call it. Useful for lazy initialization. 1.9053 + _.once = function(func) { 1.9054 + var ran = false, memo; 1.9055 + return function() { 1.9056 + if (ran) return memo; 1.9057 + ran = true; 1.9058 + memo = func.apply(this, arguments); 1.9059 + func = null; 1.9060 + return memo; 1.9061 + }; 1.9062 + }; 1.9063 + 1.9064 + // Returns the first function passed as an argument to the second, 1.9065 + // allowing you to adjust arguments, run code before and after, and 1.9066 + // conditionally execute the original function. 1.9067 + _.wrap = function(func, wrapper) { 1.9068 + return function() { 1.9069 + var args = [func]; 1.9070 + push.apply(args, arguments); 1.9071 + return wrapper.apply(this, args); 1.9072 + }; 1.9073 + }; 1.9074 + 1.9075 + // Returns a function that is the composition of a list of functions, each 1.9076 + // consuming the return value of the function that follows. 1.9077 + _.compose = function() { 1.9078 + var funcs = arguments; 1.9079 + return function() { 1.9080 + var args = arguments; 1.9081 + for (var i = funcs.length - 1; i >= 0; i--) { 1.9082 + args = [funcs[i].apply(this, args)]; 1.9083 + } 1.9084 + return args[0]; 1.9085 + }; 1.9086 + }; 1.9087 + 1.9088 + // Returns a function that will only be executed after being called N times. 1.9089 + _.after = function(times, func) { 1.9090 + if (times <= 0) return func(); 1.9091 + return function() { 1.9092 + if (--times < 1) { 1.9093 + return func.apply(this, arguments); 1.9094 + } 1.9095 + }; 1.9096 + }; 1.9097 + 1.9098 + // Object Functions 1.9099 + // ---------------- 1.9100 + 1.9101 + // Retrieve the names of an object's properties. 1.9102 + // Delegates to **ECMAScript 5**'s native `Object.keys` 1.9103 + _.keys = nativeKeys || function(obj) { 1.9104 + if (obj !== Object(obj)) throw new TypeError('Invalid object'); 1.9105 + var keys = []; 1.9106 + for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; 1.9107 + return keys; 1.9108 + }; 1.9109 + 1.9110 + // Retrieve the values of an object's properties. 1.9111 + _.values = function(obj) { 1.9112 + var values = []; 1.9113 + for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); 1.9114 + return values; 1.9115 + }; 1.9116 + 1.9117 + // Convert an object into a list of `[key, value]` pairs. 1.9118 + _.pairs = function(obj) { 1.9119 + var pairs = []; 1.9120 + for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); 1.9121 + return pairs; 1.9122 + }; 1.9123 + 1.9124 + // Invert the keys and values of an object. The values must be serializable. 1.9125 + _.invert = function(obj) { 1.9126 + var result = {}; 1.9127 + for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; 1.9128 + return result; 1.9129 + }; 1.9130 + 1.9131 + // Return a sorted list of the function names available on the object. 1.9132 + // Aliased as `methods` 1.9133 + _.functions = _.methods = function(obj) { 1.9134 + var names = []; 1.9135 + for (var key in obj) { 1.9136 + if (_.isFunction(obj[key])) names.push(key); 1.9137 + } 1.9138 + return names.sort(); 1.9139 + }; 1.9140 + 1.9141 + // Extend a given object with all the properties in passed-in object(s). 1.9142 + _.extend = function(obj) { 1.9143 + each(slice.call(arguments, 1), function(source) { 1.9144 + if (source) { 1.9145 + for (var prop in source) { 1.9146 + obj[prop] = source[prop]; 1.9147 + } 1.9148 + } 1.9149 + }); 1.9150 + return obj; 1.9151 + }; 1.9152 + 1.9153 + // Return a copy of the object only containing the whitelisted properties. 1.9154 + _.pick = function(obj) { 1.9155 + var copy = {}; 1.9156 + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); 1.9157 + each(keys, function(key) { 1.9158 + if (key in obj) copy[key] = obj[key]; 1.9159 + }); 1.9160 + return copy; 1.9161 + }; 1.9162 + 1.9163 + // Return a copy of the object without the blacklisted properties. 1.9164 + _.omit = function(obj) { 1.9165 + var copy = {}; 1.9166 + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); 1.9167 + for (var key in obj) { 1.9168 + if (!_.contains(keys, key)) copy[key] = obj[key]; 1.9169 + } 1.9170 + return copy; 1.9171 + }; 1.9172 + 1.9173 + // Fill in a given object with default properties. 1.9174 + _.defaults = function(obj) { 1.9175 + each(slice.call(arguments, 1), function(source) { 1.9176 + if (source) { 1.9177 + for (var prop in source) { 1.9178 + if (obj[prop] == null) obj[prop] = source[prop]; 1.9179 + } 1.9180 + } 1.9181 + }); 1.9182 + return obj; 1.9183 + }; 1.9184 + 1.9185 + // Create a (shallow-cloned) duplicate of an object. 1.9186 + _.clone = function(obj) { 1.9187 + if (!_.isObject(obj)) return obj; 1.9188 + return _.isArray(obj) ? obj.slice() : _.extend({}, obj); 1.9189 + }; 1.9190 + 1.9191 + // Invokes interceptor with the obj, and then returns obj. 1.9192 + // The primary purpose of this method is to "tap into" a method chain, in 1.9193 + // order to perform operations on intermediate results within the chain. 1.9194 + _.tap = function(obj, interceptor) { 1.9195 + interceptor(obj); 1.9196 + return obj; 1.9197 + }; 1.9198 + 1.9199 + // Internal recursive comparison function for `isEqual`. 1.9200 + var eq = function(a, b, aStack, bStack) { 1.9201 + // Identical objects are equal. `0 === -0`, but they aren't identical. 1.9202 + // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. 1.9203 + if (a === b) return a !== 0 || 1 / a == 1 / b; 1.9204 + // A strict comparison is necessary because `null == undefined`. 1.9205 + if (a == null || b == null) return a === b; 1.9206 + // Unwrap any wrapped objects. 1.9207 + if (a instanceof _) a = a._wrapped; 1.9208 + if (b instanceof _) b = b._wrapped; 1.9209 + // Compare `[[Class]]` names. 1.9210 + var className = toString.call(a); 1.9211 + if (className != toString.call(b)) return false; 1.9212 + switch (className) { 1.9213 + // Strings, numbers, dates, and booleans are compared by value. 1.9214 + case '[object String]': 1.9215 + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is 1.9216 + // equivalent to `new String("5")`. 1.9217 + return a == String(b); 1.9218 + case '[object Number]': 1.9219 + // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for 1.9220 + // other numeric values. 1.9221 + return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); 1.9222 + case '[object Date]': 1.9223 + case '[object Boolean]': 1.9224 + // Coerce dates and booleans to numeric primitive values. Dates are compared by their 1.9225 + // millisecond representations. Note that invalid dates with millisecond representations 1.9226 + // of `NaN` are not equivalent. 1.9227 + return +a == +b; 1.9228 + // RegExps are compared by their source patterns and flags. 1.9229 + case '[object RegExp]': 1.9230 + return a.source == b.source && 1.9231 + a.global == b.global && 1.9232 + a.multiline == b.multiline && 1.9233 + a.ignoreCase == b.ignoreCase; 1.9234 + } 1.9235 + if (typeof a != 'object' || typeof b != 'object') return false; 1.9236 + // Assume equality for cyclic structures. The algorithm for detecting cyclic 1.9237 + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. 1.9238 + var length = aStack.length; 1.9239 + while (length--) { 1.9240 + // Linear search. Performance is inversely proportional to the number of 1.9241 + // unique nested structures. 1.9242 + if (aStack[length] == a) return bStack[length] == b; 1.9243 + } 1.9244 + // Add the first object to the stack of traversed objects. 1.9245 + aStack.push(a); 1.9246 + bStack.push(b); 1.9247 + var size = 0, result = true; 1.9248 + // Recursively compare objects and arrays. 1.9249 + if (className == '[object Array]') { 1.9250 + // Compare array lengths to determine if a deep comparison is necessary. 1.9251 + size = a.length; 1.9252 + result = size == b.length; 1.9253 + if (result) { 1.9254 + // Deep compare the contents, ignoring non-numeric properties. 1.9255 + while (size--) { 1.9256 + if (!(result = eq(a[size], b[size], aStack, bStack))) break; 1.9257 + } 1.9258 + } 1.9259 + } else { 1.9260 + // Objects with different constructors are not equivalent, but `Object`s 1.9261 + // from different frames are. 1.9262 + var aCtor = a.constructor, bCtor = b.constructor; 1.9263 + if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && 1.9264 + _.isFunction(bCtor) && (bCtor instanceof bCtor))) { 1.9265 + return false; 1.9266 + } 1.9267 + // Deep compare objects. 1.9268 + for (var key in a) { 1.9269 + if (_.has(a, key)) { 1.9270 + // Count the expected number of properties. 1.9271 + size++; 1.9272 + // Deep compare each member. 1.9273 + if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; 1.9274 + } 1.9275 + } 1.9276 + // Ensure that both objects contain the same number of properties. 1.9277 + if (result) { 1.9278 + for (key in b) { 1.9279 + if (_.has(b, key) && !(size--)) break; 1.9280 + } 1.9281 + result = !size; 1.9282 + } 1.9283 + } 1.9284 + // Remove the first object from the stack of traversed objects. 1.9285 + aStack.pop(); 1.9286 + bStack.pop(); 1.9287 + return result; 1.9288 + }; 1.9289 + 1.9290 + // Perform a deep comparison to check if two objects are equal. 1.9291 + _.isEqual = function(a, b) { 1.9292 + return eq(a, b, [], []); 1.9293 + }; 1.9294 + 1.9295 + // Is a given array, string, or object empty? 1.9296 + // An "empty" object has no enumerable own-properties. 1.9297 + _.isEmpty = function(obj) { 1.9298 + if (obj == null) return true; 1.9299 + if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; 1.9300 + for (var key in obj) if (_.has(obj, key)) return false; 1.9301 + return true; 1.9302 + }; 1.9303 + 1.9304 + // Is a given value a DOM element? 1.9305 + _.isElement = function(obj) { 1.9306 + return !!(obj && obj.nodeType === 1); 1.9307 + }; 1.9308 + 1.9309 + // Is a given value an array? 1.9310 + // Delegates to ECMA5's native Array.isArray 1.9311 + _.isArray = nativeIsArray || function(obj) { 1.9312 + return toString.call(obj) == '[object Array]'; 1.9313 + }; 1.9314 + 1.9315 + // Is a given variable an object? 1.9316 + _.isObject = function(obj) { 1.9317 + return obj === Object(obj); 1.9318 + }; 1.9319 + 1.9320 + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. 1.9321 + each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { 1.9322 + _['is' + name] = function(obj) { 1.9323 + return toString.call(obj) == '[object ' + name + ']'; 1.9324 + }; 1.9325 + }); 1.9326 + 1.9327 + // Define a fallback version of the method in browsers (ahem, IE), where 1.9328 + // there isn't any inspectable "Arguments" type. 1.9329 + if (!_.isArguments(arguments)) { 1.9330 + _.isArguments = function(obj) { 1.9331 + return !!(obj && _.has(obj, 'callee')); 1.9332 + }; 1.9333 + } 1.9334 + 1.9335 + // Optimize `isFunction` if appropriate. 1.9336 + if (typeof (/./) !== 'function') { 1.9337 + _.isFunction = function(obj) { 1.9338 + return typeof obj === 'function'; 1.9339 + }; 1.9340 + } 1.9341 + 1.9342 + // Is a given object a finite number? 1.9343 + _.isFinite = function(obj) { 1.9344 + return isFinite(obj) && !isNaN(parseFloat(obj)); 1.9345 + }; 1.9346 + 1.9347 + // Is the given value `NaN`? (NaN is the only number which does not equal itself). 1.9348 + _.isNaN = function(obj) { 1.9349 + return _.isNumber(obj) && obj != +obj; 1.9350 + }; 1.9351 + 1.9352 + // Is a given value a boolean? 1.9353 + _.isBoolean = function(obj) { 1.9354 + return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; 1.9355 + }; 1.9356 + 1.9357 + // Is a given value equal to null? 1.9358 + _.isNull = function(obj) { 1.9359 + return obj === null; 1.9360 + }; 1.9361 + 1.9362 + // Is a given variable undefined? 1.9363 + _.isUndefined = function(obj) { 1.9364 + return obj === void 0; 1.9365 + }; 1.9366 + 1.9367 + // Shortcut function for checking if an object has a given property directly 1.9368 + // on itself (in other words, not on a prototype). 1.9369 + _.has = function(obj, key) { 1.9370 + return hasOwnProperty.call(obj, key); 1.9371 + }; 1.9372 + 1.9373 + // Utility Functions 1.9374 + // ----------------- 1.9375 + 1.9376 + // Run Underscore.js in *noConflict* mode, returning the `_` variable to its 1.9377 + // previous owner. Returns a reference to the Underscore object. 1.9378 + _.noConflict = function() { 1.9379 + root._ = previousUnderscore; 1.9380 + return this; 1.9381 + }; 1.9382 + 1.9383 + // Keep the identity function around for default iterators. 1.9384 + _.identity = function(value) { 1.9385 + return value; 1.9386 + }; 1.9387 + 1.9388 + // Run a function **n** times. 1.9389 + _.times = function(n, iterator, context) { 1.9390 + var accum = Array(n); 1.9391 + for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); 1.9392 + return accum; 1.9393 + }; 1.9394 + 1.9395 + // Return a random integer between min and max (inclusive). 1.9396 + _.random = function(min, max) { 1.9397 + if (max == null) { 1.9398 + max = min; 1.9399 + min = 0; 1.9400 + } 1.9401 + return min + Math.floor(Math.random() * (max - min + 1)); 1.9402 + }; 1.9403 + 1.9404 + // List of HTML entities for escaping. 1.9405 + var entityMap = { 1.9406 + escape: { 1.9407 + '&': '&', 1.9408 + '<': '<', 1.9409 + '>': '>', 1.9410 + '"': '"', 1.9411 + "'": ''', 1.9412 + '/': '/' 1.9413 + } 1.9414 + }; 1.9415 + entityMap.unescape = _.invert(entityMap.escape); 1.9416 + 1.9417 + // Regexes containing the keys and values listed immediately above. 1.9418 + var entityRegexes = { 1.9419 + escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), 1.9420 + unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') 1.9421 + }; 1.9422 + 1.9423 + // Functions for escaping and unescaping strings to/from HTML interpolation. 1.9424 + _.each(['escape', 'unescape'], function(method) { 1.9425 + _[method] = function(string) { 1.9426 + if (string == null) return ''; 1.9427 + return ('' + string).replace(entityRegexes[method], function(match) { 1.9428 + return entityMap[method][match]; 1.9429 + }); 1.9430 + }; 1.9431 + }); 1.9432 + 1.9433 + // If the value of the named property is a function then invoke it; 1.9434 + // otherwise, return it. 1.9435 + _.result = function(object, property) { 1.9436 + if (object == null) return null; 1.9437 + var value = object[property]; 1.9438 + return _.isFunction(value) ? value.call(object) : value; 1.9439 + }; 1.9440 + 1.9441 + // Add your own custom functions to the Underscore object. 1.9442 + _.mixin = function(obj) { 1.9443 + each(_.functions(obj), function(name){ 1.9444 + var func = _[name] = obj[name]; 1.9445 + _.prototype[name] = function() { 1.9446 + var args = [this._wrapped]; 1.9447 + push.apply(args, arguments); 1.9448 + return result.call(this, func.apply(_, args)); 1.9449 + }; 1.9450 + }); 1.9451 + }; 1.9452 + 1.9453 + // Generate a unique integer id (unique within the entire client session). 1.9454 + // Useful for temporary DOM ids. 1.9455 + var idCounter = 0; 1.9456 + _.uniqueId = function(prefix) { 1.9457 + var id = ++idCounter + ''; 1.9458 + return prefix ? prefix + id : id; 1.9459 + }; 1.9460 + 1.9461 + // By default, Underscore uses ERB-style template delimiters, change the 1.9462 + // following template settings to use alternative delimiters. 1.9463 + _.templateSettings = { 1.9464 + evaluate : /<%([\s\S]+?)%>/g, 1.9465 + interpolate : /<%=([\s\S]+?)%>/g, 1.9466 + escape : /<%-([\s\S]+?)%>/g 1.9467 + }; 1.9468 + 1.9469 + // When customizing `templateSettings`, if you don't want to define an 1.9470 + // interpolation, evaluation or escaping regex, we need one that is 1.9471 + // guaranteed not to match. 1.9472 + var noMatch = /(.)^/; 1.9473 + 1.9474 + // Certain characters need to be escaped so that they can be put into a 1.9475 + // string literal. 1.9476 + var escapes = { 1.9477 + "'": "'", 1.9478 + '\\': '\\', 1.9479 + '\r': 'r', 1.9480 + '\n': 'n', 1.9481 + '\t': 't', 1.9482 + '\u2028': 'u2028', 1.9483 + '\u2029': 'u2029' 1.9484 + }; 1.9485 + 1.9486 + var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; 1.9487 + 1.9488 + // JavaScript micro-templating, similar to John Resig's implementation. 1.9489 + // Underscore templating handles arbitrary delimiters, preserves whitespace, 1.9490 + // and correctly escapes quotes within interpolated code. 1.9491 + _.template = function(text, data, settings) { 1.9492 + var render; 1.9493 + settings = _.defaults({}, settings, _.templateSettings); 1.9494 + 1.9495 + // Combine delimiters into one regular expression via alternation. 1.9496 + var matcher = new RegExp([ 1.9497 + (settings.escape || noMatch).source, 1.9498 + (settings.interpolate || noMatch).source, 1.9499 + (settings.evaluate || noMatch).source 1.9500 + ].join('|') + '|$', 'g'); 1.9501 + 1.9502 + // Compile the template source, escaping string literals appropriately. 1.9503 + var index = 0; 1.9504 + var source = "__p+='"; 1.9505 + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { 1.9506 + source += text.slice(index, offset) 1.9507 + .replace(escaper, function(match) { return '\\' + escapes[match]; }); 1.9508 + 1.9509 + if (escape) { 1.9510 + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; 1.9511 + } 1.9512 + if (interpolate) { 1.9513 + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; 1.9514 + } 1.9515 + if (evaluate) { 1.9516 + source += "';\n" + evaluate + "\n__p+='"; 1.9517 + } 1.9518 + index = offset + match.length; 1.9519 + return match; 1.9520 + }); 1.9521 + source += "';\n"; 1.9522 + 1.9523 + // If a variable is not specified, place data values in local scope. 1.9524 + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; 1.9525 + 1.9526 + source = "var __t,__p='',__j=Array.prototype.join," + 1.9527 + "print=function(){__p+=__j.call(arguments,'');};\n" + 1.9528 + source + "return __p;\n"; 1.9529 + 1.9530 + try { 1.9531 + render = new Function(settings.variable || 'obj', '_', source); 1.9532 + } catch (e) { 1.9533 + e.source = source; 1.9534 + throw e; 1.9535 + } 1.9536 + 1.9537 + if (data) return render(data, _); 1.9538 + var template = function(data) { 1.9539 + return render.call(this, data, _); 1.9540 + }; 1.9541 + 1.9542 + // Provide the compiled function source as a convenience for precompilation. 1.9543 + template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; 1.9544 + 1.9545 + return template; 1.9546 + }; 1.9547 + 1.9548 + // Add a "chain" function, which will delegate to the wrapper. 1.9549 + _.chain = function(obj) { 1.9550 + return _(obj).chain(); 1.9551 + }; 1.9552 + 1.9553 + // OOP 1.9554 + // --------------- 1.9555 + // If Underscore is called as a function, it returns a wrapped object that 1.9556 + // can be used OO-style. This wrapper holds altered versions of all the 1.9557 + // underscore functions. Wrapped objects may be chained. 1.9558 + 1.9559 + // Helper function to continue chaining intermediate results. 1.9560 + var result = function(obj) { 1.9561 + return this._chain ? _(obj).chain() : obj; 1.9562 + }; 1.9563 + 1.9564 + // Add all of the Underscore functions to the wrapper object. 1.9565 + _.mixin(_); 1.9566 + 1.9567 + // Add all mutator Array functions to the wrapper. 1.9568 + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { 1.9569 + var method = ArrayProto[name]; 1.9570 + _.prototype[name] = function() { 1.9571 + var obj = this._wrapped; 1.9572 + method.apply(obj, arguments); 1.9573 + if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; 1.9574 + return result.call(this, obj); 1.9575 + }; 1.9576 + }); 1.9577 + 1.9578 + // Add all accessor Array functions to the wrapper. 1.9579 + each(['concat', 'join', 'slice'], function(name) { 1.9580 + var method = ArrayProto[name]; 1.9581 + _.prototype[name] = function() { 1.9582 + return result.call(this, method.apply(this._wrapped, arguments)); 1.9583 + }; 1.9584 + }); 1.9585 + 1.9586 + _.extend(_.prototype, { 1.9587 + 1.9588 + // Start chaining a wrapped Underscore object. 1.9589 + chain: function() { 1.9590 + this._chain = true; 1.9591 + return this; 1.9592 + }, 1.9593 + 1.9594 + // Extracts the result from a wrapped and chained object. 1.9595 + value: function() { 1.9596 + return this._wrapped; 1.9597 + } 1.9598 + 1.9599 + }); 1.9600 + 1.9601 +}).call(this); 1.9602 + 1.9603 +})() 1.9604 +},{}],14:[function(require,module,exports){ 1.9605 +exports.readIEEE754 = function(buffer, offset, isBE, mLen, nBytes) { 1.9606 + var e, m, 1.9607 + eLen = nBytes * 8 - mLen - 1, 1.9608 + eMax = (1 << eLen) - 1, 1.9609 + eBias = eMax >> 1, 1.9610 + nBits = -7, 1.9611 + i = isBE ? 0 : (nBytes - 1), 1.9612 + d = isBE ? 1 : -1, 1.9613 + s = buffer[offset + i]; 1.9614 + 1.9615 + i += d; 1.9616 + 1.9617 + e = s & ((1 << (-nBits)) - 1); 1.9618 + s >>= (-nBits); 1.9619 + nBits += eLen; 1.9620 + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); 1.9621 + 1.9622 + m = e & ((1 << (-nBits)) - 1); 1.9623 + e >>= (-nBits); 1.9624 + nBits += mLen; 1.9625 + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); 1.9626 + 1.9627 + if (e === 0) { 1.9628 + e = 1 - eBias; 1.9629 + } else if (e === eMax) { 1.9630 + return m ? NaN : ((s ? -1 : 1) * Infinity); 1.9631 + } else { 1.9632 + m = m + Math.pow(2, mLen); 1.9633 + e = e - eBias; 1.9634 + } 1.9635 + return (s ? -1 : 1) * m * Math.pow(2, e - mLen); 1.9636 +}; 1.9637 + 1.9638 +exports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) { 1.9639 + var e, m, c, 1.9640 + eLen = nBytes * 8 - mLen - 1, 1.9641 + eMax = (1 << eLen) - 1, 1.9642 + eBias = eMax >> 1, 1.9643 + rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), 1.9644 + i = isBE ? (nBytes - 1) : 0, 1.9645 + d = isBE ? -1 : 1, 1.9646 + s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; 1.9647 + 1.9648 + value = Math.abs(value); 1.9649 + 1.9650 + if (isNaN(value) || value === Infinity) { 1.9651 + m = isNaN(value) ? 1 : 0; 1.9652 + e = eMax; 1.9653 + } else { 1.9654 + e = Math.floor(Math.log(value) / Math.LN2); 1.9655 + if (value * (c = Math.pow(2, -e)) < 1) { 1.9656 + e--; 1.9657 + c *= 2; 1.9658 + } 1.9659 + if (e + eBias >= 1) { 1.9660 + value += rt / c; 1.9661 + } else { 1.9662 + value += rt * Math.pow(2, 1 - eBias); 1.9663 + } 1.9664 + if (value * c >= 2) { 1.9665 + e++; 1.9666 + c /= 2; 1.9667 + } 1.9668 + 1.9669 + if (e + eBias >= eMax) { 1.9670 + m = 0; 1.9671 + e = eMax; 1.9672 + } else if (e + eBias >= 1) { 1.9673 + m = (value * c - 1) * Math.pow(2, mLen); 1.9674 + e = e + eBias; 1.9675 + } else { 1.9676 + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); 1.9677 + e = 0; 1.9678 + } 1.9679 + } 1.9680 + 1.9681 + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); 1.9682 + 1.9683 + e = (e << mLen) | m; 1.9684 + eLen += mLen; 1.9685 + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); 1.9686 + 1.9687 + buffer[offset + i - d] |= s * 128; 1.9688 +}; 1.9689 + 1.9690 +},{}],13:[function(require,module,exports){ 1.9691 +(function(){function SlowBuffer (size) { 1.9692 + this.length = size; 1.9693 +}; 1.9694 + 1.9695 +var assert = require('assert'); 1.9696 + 1.9697 +exports.INSPECT_MAX_BYTES = 50; 1.9698 + 1.9699 + 1.9700 +function toHex(n) { 1.9701 + if (n < 16) return '0' + n.toString(16); 1.9702 + return n.toString(16); 1.9703 +} 1.9704 + 1.9705 +function utf8ToBytes(str) { 1.9706 + var byteArray = []; 1.9707 + for (var i = 0; i < str.length; i++) 1.9708 + if (str.charCodeAt(i) <= 0x7F) 1.9709 + byteArray.push(str.charCodeAt(i)); 1.9710 + else { 1.9711 + var h = encodeURIComponent(str.charAt(i)).substr(1).split('%'); 1.9712 + for (var j = 0; j < h.length; j++) 1.9713 + byteArray.push(parseInt(h[j], 16)); 1.9714 + } 1.9715 + 1.9716 + return byteArray; 1.9717 +} 1.9718 + 1.9719 +function asciiToBytes(str) { 1.9720 + var byteArray = [] 1.9721 + for (var i = 0; i < str.length; i++ ) 1.9722 + // Node's code seems to be doing this and not & 0x7F.. 1.9723 + byteArray.push( str.charCodeAt(i) & 0xFF ); 1.9724 + 1.9725 + return byteArray; 1.9726 +} 1.9727 + 1.9728 +function base64ToBytes(str) { 1.9729 + return require("base64-js").toByteArray(str); 1.9730 +} 1.9731 + 1.9732 +SlowBuffer.byteLength = function (str, encoding) { 1.9733 + switch (encoding || "utf8") { 1.9734 + case 'hex': 1.9735 + return str.length / 2; 1.9736 + 1.9737 + case 'utf8': 1.9738 + case 'utf-8': 1.9739 + return utf8ToBytes(str).length; 1.9740 + 1.9741 + case 'ascii': 1.9742 + case 'binary': 1.9743 + return str.length; 1.9744 + 1.9745 + case 'base64': 1.9746 + return base64ToBytes(str).length; 1.9747 + 1.9748 + default: 1.9749 + throw new Error('Unknown encoding'); 1.9750 + } 1.9751 +}; 1.9752 + 1.9753 +function blitBuffer(src, dst, offset, length) { 1.9754 + var pos, i = 0; 1.9755 + while (i < length) { 1.9756 + if ((i+offset >= dst.length) || (i >= src.length)) 1.9757 + break; 1.9758 + 1.9759 + dst[i + offset] = src[i]; 1.9760 + i++; 1.9761 + } 1.9762 + return i; 1.9763 +} 1.9764 + 1.9765 +SlowBuffer.prototype.utf8Write = function (string, offset, length) { 1.9766 + var bytes, pos; 1.9767 + return SlowBuffer._charsWritten = blitBuffer(utf8ToBytes(string), this, offset, length); 1.9768 +}; 1.9769 + 1.9770 +SlowBuffer.prototype.asciiWrite = function (string, offset, length) { 1.9771 + var bytes, pos; 1.9772 + return SlowBuffer._charsWritten = blitBuffer(asciiToBytes(string), this, offset, length); 1.9773 +}; 1.9774 + 1.9775 +SlowBuffer.prototype.binaryWrite = SlowBuffer.prototype.asciiWrite; 1.9776 + 1.9777 +SlowBuffer.prototype.base64Write = function (string, offset, length) { 1.9778 + var bytes, pos; 1.9779 + return SlowBuffer._charsWritten = blitBuffer(base64ToBytes(string), this, offset, length); 1.9780 +}; 1.9781 + 1.9782 +SlowBuffer.prototype.base64Slice = function (start, end) { 1.9783 + var bytes = Array.prototype.slice.apply(this, arguments) 1.9784 + return require("base64-js").fromByteArray(bytes); 1.9785 +} 1.9786 + 1.9787 +function decodeUtf8Char(str) { 1.9788 + try { 1.9789 + return decodeURIComponent(str); 1.9790 + } catch (err) { 1.9791 + return String.fromCharCode(0xFFFD); // UTF 8 invalid char 1.9792 + } 1.9793 +} 1.9794 + 1.9795 +SlowBuffer.prototype.utf8Slice = function () { 1.9796 + var bytes = Array.prototype.slice.apply(this, arguments); 1.9797 + var res = ""; 1.9798 + var tmp = ""; 1.9799 + var i = 0; 1.9800 + while (i < bytes.length) { 1.9801 + if (bytes[i] <= 0x7F) { 1.9802 + res += decodeUtf8Char(tmp) + String.fromCharCode(bytes[i]); 1.9803 + tmp = ""; 1.9804 + } else 1.9805 + tmp += "%" + bytes[i].toString(16); 1.9806 + 1.9807 + i++; 1.9808 + } 1.9809 + 1.9810 + return res + decodeUtf8Char(tmp); 1.9811 +} 1.9812 + 1.9813 +SlowBuffer.prototype.asciiSlice = function () { 1.9814 + var bytes = Array.prototype.slice.apply(this, arguments); 1.9815 + var ret = ""; 1.9816 + for (var i = 0; i < bytes.length; i++) 1.9817 + ret += String.fromCharCode(bytes[i]); 1.9818 + return ret; 1.9819 +} 1.9820 + 1.9821 +SlowBuffer.prototype.binarySlice = SlowBuffer.prototype.asciiSlice; 1.9822 + 1.9823 +SlowBuffer.prototype.inspect = function() { 1.9824 + var out = [], 1.9825 + len = this.length; 1.9826 + for (var i = 0; i < len; i++) { 1.9827 + out[i] = toHex(this[i]); 1.9828 + if (i == exports.INSPECT_MAX_BYTES) { 1.9829 + out[i + 1] = '...'; 1.9830 + break; 1.9831 + } 1.9832 + } 1.9833 + return '<SlowBuffer ' + out.join(' ') + '>'; 1.9834 +}; 1.9835 + 1.9836 + 1.9837 +SlowBuffer.prototype.hexSlice = function(start, end) { 1.9838 + var len = this.length; 1.9839 + 1.9840 + if (!start || start < 0) start = 0; 1.9841 + if (!end || end < 0 || end > len) end = len; 1.9842 + 1.9843 + var out = ''; 1.9844 + for (var i = start; i < end; i++) { 1.9845 + out += toHex(this[i]); 1.9846 + } 1.9847 + return out; 1.9848 +}; 1.9849 + 1.9850 + 1.9851 +SlowBuffer.prototype.toString = function(encoding, start, end) { 1.9852 + encoding = String(encoding || 'utf8').toLowerCase(); 1.9853 + start = +start || 0; 1.9854 + if (typeof end == 'undefined') end = this.length; 1.9855 + 1.9856 + // Fastpath empty strings 1.9857 + if (+end == start) { 1.9858 + return ''; 1.9859 + } 1.9860 + 1.9861 + switch (encoding) { 1.9862 + case 'hex': 1.9863 + return this.hexSlice(start, end); 1.9864 + 1.9865 + case 'utf8': 1.9866 + case 'utf-8': 1.9867 + return this.utf8Slice(start, end); 1.9868 + 1.9869 + case 'ascii': 1.9870 + return this.asciiSlice(start, end); 1.9871 + 1.9872 + case 'binary': 1.9873 + return this.binarySlice(start, end); 1.9874 + 1.9875 + case 'base64': 1.9876 + return this.base64Slice(start, end); 1.9877 + 1.9878 + case 'ucs2': 1.9879 + case 'ucs-2': 1.9880 + return this.ucs2Slice(start, end); 1.9881 + 1.9882 + default: 1.9883 + throw new Error('Unknown encoding'); 1.9884 + } 1.9885 +}; 1.9886 + 1.9887 + 1.9888 +SlowBuffer.prototype.hexWrite = function(string, offset, length) { 1.9889 + offset = +offset || 0; 1.9890 + var remaining = this.length - offset; 1.9891 + if (!length) { 1.9892 + length = remaining; 1.9893 + } else { 1.9894 + length = +length; 1.9895 + if (length > remaining) { 1.9896 + length = remaining; 1.9897 + } 1.9898 + } 1.9899 + 1.9900 + // must be an even number of digits 1.9901 + var strLen = string.length; 1.9902 + if (strLen % 2) { 1.9903 + throw new Error('Invalid hex string'); 1.9904 + } 1.9905 + if (length > strLen / 2) { 1.9906 + length = strLen / 2; 1.9907 + } 1.9908 + for (var i = 0; i < length; i++) { 1.9909 + var byte = parseInt(string.substr(i * 2, 2), 16); 1.9910 + if (isNaN(byte)) throw new Error('Invalid hex string'); 1.9911 + this[offset + i] = byte; 1.9912 + } 1.9913 + SlowBuffer._charsWritten = i * 2; 1.9914 + return i; 1.9915 +}; 1.9916 + 1.9917 + 1.9918 +SlowBuffer.prototype.write = function(string, offset, length, encoding) { 1.9919 + // Support both (string, offset, length, encoding) 1.9920 + // and the legacy (string, encoding, offset, length) 1.9921 + if (isFinite(offset)) { 1.9922 + if (!isFinite(length)) { 1.9923 + encoding = length; 1.9924 + length = undefined; 1.9925 + } 1.9926 + } else { // legacy 1.9927 + var swap = encoding; 1.9928 + encoding = offset; 1.9929 + offset = length; 1.9930 + length = swap; 1.9931 + } 1.9932 + 1.9933 + offset = +offset || 0; 1.9934 + var remaining = this.length - offset; 1.9935 + if (!length) { 1.9936 + length = remaining; 1.9937 + } else { 1.9938 + length = +length; 1.9939 + if (length > remaining) { 1.9940 + length = remaining; 1.9941 + } 1.9942 + } 1.9943 + encoding = String(encoding || 'utf8').toLowerCase(); 1.9944 + 1.9945 + switch (encoding) { 1.9946 + case 'hex': 1.9947 + return this.hexWrite(string, offset, length); 1.9948 + 1.9949 + case 'utf8': 1.9950 + case 'utf-8': 1.9951 + return this.utf8Write(string, offset, length); 1.9952 + 1.9953 + case 'ascii': 1.9954 + return this.asciiWrite(string, offset, length); 1.9955 + 1.9956 + case 'binary': 1.9957 + return this.binaryWrite(string, offset, length); 1.9958 + 1.9959 + case 'base64': 1.9960 + return this.base64Write(string, offset, length); 1.9961 + 1.9962 + case 'ucs2': 1.9963 + case 'ucs-2': 1.9964 + return this.ucs2Write(string, offset, length); 1.9965 + 1.9966 + default: 1.9967 + throw new Error('Unknown encoding'); 1.9968 + } 1.9969 +}; 1.9970 + 1.9971 + 1.9972 +// slice(start, end) 1.9973 +SlowBuffer.prototype.slice = function(start, end) { 1.9974 + if (end === undefined) end = this.length; 1.9975 + 1.9976 + if (end > this.length) { 1.9977 + throw new Error('oob'); 1.9978 + } 1.9979 + if (start > end) { 1.9980 + throw new Error('oob'); 1.9981 + } 1.9982 + 1.9983 + return new Buffer(this, end - start, +start); 1.9984 +}; 1.9985 + 1.9986 +SlowBuffer.prototype.copy = function(target, targetstart, sourcestart, sourceend) { 1.9987 + var temp = []; 1.9988 + for (var i=sourcestart; i<sourceend; i++) { 1.9989 + assert.ok(typeof this[i] !== 'undefined', "copying undefined buffer bytes!"); 1.9990 + temp.push(this[i]); 1.9991 + } 1.9992 + 1.9993 + for (var i=targetstart; i<targetstart+temp.length; i++) { 1.9994 + target[i] = temp[i-targetstart]; 1.9995 + } 1.9996 +}; 1.9997 + 1.9998 +SlowBuffer.prototype.fill = function(value, start, end) { 1.9999 + if (end > this.length) { 1.10000 + throw new Error('oob'); 1.10001 + } 1.10002 + if (start > end) { 1.10003 + throw new Error('oob'); 1.10004 + } 1.10005 + 1.10006 + for (var i = start; i < end; i++) { 1.10007 + this[i] = value; 1.10008 + } 1.10009 +} 1.10010 + 1.10011 +function coerce(length) { 1.10012 + // Coerce length to a number (possibly NaN), round up 1.10013 + // in case it's fractional (e.g. 123.456) then do a 1.10014 + // double negate to coerce a NaN to 0. Easy, right? 1.10015 + length = ~~Math.ceil(+length); 1.10016 + return length < 0 ? 0 : length; 1.10017 +} 1.10018 + 1.10019 + 1.10020 +// Buffer 1.10021 + 1.10022 +function Buffer(subject, encoding, offset) { 1.10023 + if (!(this instanceof Buffer)) { 1.10024 + return new Buffer(subject, encoding, offset); 1.10025 + } 1.10026 + 1.10027 + var type; 1.10028 + 1.10029 + // Are we slicing? 1.10030 + if (typeof offset === 'number') { 1.10031 + this.length = coerce(encoding); 1.10032 + this.parent = subject; 1.10033 + this.offset = offset; 1.10034 + } else { 1.10035 + // Find the length 1.10036 + switch (type = typeof subject) { 1.10037 + case 'number': 1.10038 + this.length = coerce(subject); 1.10039 + break; 1.10040 + 1.10041 + case 'string': 1.10042 + this.length = Buffer.byteLength(subject, encoding); 1.10043 + break; 1.10044 + 1.10045 + case 'object': // Assume object is an array 1.10046 + this.length = coerce(subject.length); 1.10047 + break; 1.10048 + 1.10049 + default: 1.10050 + throw new Error('First argument needs to be a number, ' + 1.10051 + 'array or string.'); 1.10052 + } 1.10053 + 1.10054 + if (this.length > Buffer.poolSize) { 1.10055 + // Big buffer, just alloc one. 1.10056 + this.parent = new SlowBuffer(this.length); 1.10057 + this.offset = 0; 1.10058 + 1.10059 + } else { 1.10060 + // Small buffer. 1.10061 + if (!pool || pool.length - pool.used < this.length) allocPool(); 1.10062 + this.parent = pool; 1.10063 + this.offset = pool.used; 1.10064 + pool.used += this.length; 1.10065 + } 1.10066 + 1.10067 + // Treat array-ish objects as a byte array. 1.10068 + if (isArrayIsh(subject)) { 1.10069 + for (var i = 0; i < this.length; i++) { 1.10070 + if (subject instanceof Buffer) { 1.10071 + this.parent[i + this.offset] = subject.readUInt8(i); 1.10072 + } 1.10073 + else { 1.10074 + this.parent[i + this.offset] = subject[i]; 1.10075 + } 1.10076 + } 1.10077 + } else if (type == 'string') { 1.10078 + // We are a string 1.10079 + this.length = this.write(subject, 0, encoding); 1.10080 + } 1.10081 + } 1.10082 + 1.10083 +} 1.10084 + 1.10085 +function isArrayIsh(subject) { 1.10086 + return Array.isArray(subject) || Buffer.isBuffer(subject) || 1.10087 + subject && typeof subject === 'object' && 1.10088 + typeof subject.length === 'number'; 1.10089 +} 1.10090 + 1.10091 +exports.SlowBuffer = SlowBuffer; 1.10092 +exports.Buffer = Buffer; 1.10093 + 1.10094 +Buffer.poolSize = 8 * 1024; 1.10095 +var pool; 1.10096 + 1.10097 +function allocPool() { 1.10098 + pool = new SlowBuffer(Buffer.poolSize); 1.10099 + pool.used = 0; 1.10100 +} 1.10101 + 1.10102 + 1.10103 +// Static methods 1.10104 +Buffer.isBuffer = function isBuffer(b) { 1.10105 + return b instanceof Buffer || b instanceof SlowBuffer; 1.10106 +}; 1.10107 + 1.10108 +Buffer.concat = function (list, totalLength) { 1.10109 + if (!Array.isArray(list)) { 1.10110 + throw new Error("Usage: Buffer.concat(list, [totalLength])\n \ 1.10111 + list should be an Array."); 1.10112 + } 1.10113 + 1.10114 + if (list.length === 0) { 1.10115 + return new Buffer(0); 1.10116 + } else if (list.length === 1) { 1.10117 + return list[0]; 1.10118 + } 1.10119 + 1.10120 + if (typeof totalLength !== 'number') { 1.10121 + totalLength = 0; 1.10122 + for (var i = 0; i < list.length; i++) { 1.10123 + var buf = list[i]; 1.10124 + totalLength += buf.length; 1.10125 + } 1.10126 + } 1.10127 + 1.10128 + var buffer = new Buffer(totalLength); 1.10129 + var pos = 0; 1.10130 + for (var i = 0; i < list.length; i++) { 1.10131 + var buf = list[i]; 1.10132 + buf.copy(buffer, pos); 1.10133 + pos += buf.length; 1.10134 + } 1.10135 + return buffer; 1.10136 +}; 1.10137 + 1.10138 +// Inspect 1.10139 +Buffer.prototype.inspect = function inspect() { 1.10140 + var out = [], 1.10141 + len = this.length; 1.10142 + 1.10143 + for (var i = 0; i < len; i++) { 1.10144 + out[i] = toHex(this.parent[i + this.offset]); 1.10145 + if (i == exports.INSPECT_MAX_BYTES) { 1.10146 + out[i + 1] = '...'; 1.10147 + break; 1.10148 + } 1.10149 + } 1.10150 + 1.10151 + return '<Buffer ' + out.join(' ') + '>'; 1.10152 +}; 1.10153 + 1.10154 + 1.10155 +Buffer.prototype.get = function get(i) { 1.10156 + if (i < 0 || i >= this.length) throw new Error('oob'); 1.10157 + return this.parent[this.offset + i]; 1.10158 +}; 1.10159 + 1.10160 + 1.10161 +Buffer.prototype.set = function set(i, v) { 1.10162 + if (i < 0 || i >= this.length) throw new Error('oob'); 1.10163 + return this.parent[this.offset + i] = v; 1.10164 +}; 1.10165 + 1.10166 + 1.10167 +// write(string, offset = 0, length = buffer.length-offset, encoding = 'utf8') 1.10168 +Buffer.prototype.write = function(string, offset, length, encoding) { 1.10169 + // Support both (string, offset, length, encoding) 1.10170 + // and the legacy (string, encoding, offset, length) 1.10171 + if (isFinite(offset)) { 1.10172 + if (!isFinite(length)) { 1.10173 + encoding = length; 1.10174 + length = undefined; 1.10175 + } 1.10176 + } else { // legacy 1.10177 + var swap = encoding; 1.10178 + encoding = offset; 1.10179 + offset = length; 1.10180 + length = swap; 1.10181 + } 1.10182 + 1.10183 + offset = +offset || 0; 1.10184 + var remaining = this.length - offset; 1.10185 + if (!length) { 1.10186 + length = remaining; 1.10187 + } else { 1.10188 + length = +length; 1.10189 + if (length > remaining) { 1.10190 + length = remaining; 1.10191 + } 1.10192 + } 1.10193 + encoding = String(encoding || 'utf8').toLowerCase(); 1.10194 + 1.10195 + var ret; 1.10196 + switch (encoding) { 1.10197 + case 'hex': 1.10198 + ret = this.parent.hexWrite(string, this.offset + offset, length); 1.10199 + break; 1.10200 + 1.10201 + case 'utf8': 1.10202 + case 'utf-8': 1.10203 + ret = this.parent.utf8Write(string, this.offset + offset, length); 1.10204 + break; 1.10205 + 1.10206 + case 'ascii': 1.10207 + ret = this.parent.asciiWrite(string, this.offset + offset, length); 1.10208 + break; 1.10209 + 1.10210 + case 'binary': 1.10211 + ret = this.parent.binaryWrite(string, this.offset + offset, length); 1.10212 + break; 1.10213 + 1.10214 + case 'base64': 1.10215 + // Warning: maxLength not taken into account in base64Write 1.10216 + ret = this.parent.base64Write(string, this.offset + offset, length); 1.10217 + break; 1.10218 + 1.10219 + case 'ucs2': 1.10220 + case 'ucs-2': 1.10221 + ret = this.parent.ucs2Write(string, this.offset + offset, length); 1.10222 + break; 1.10223 + 1.10224 + default: 1.10225 + throw new Error('Unknown encoding'); 1.10226 + } 1.10227 + 1.10228 + Buffer._charsWritten = SlowBuffer._charsWritten; 1.10229 + 1.10230 + return ret; 1.10231 +}; 1.10232 + 1.10233 + 1.10234 +// toString(encoding, start=0, end=buffer.length) 1.10235 +Buffer.prototype.toString = function(encoding, start, end) { 1.10236 + encoding = String(encoding || 'utf8').toLowerCase(); 1.10237 + 1.10238 + if (typeof start == 'undefined' || start < 0) { 1.10239 + start = 0; 1.10240 + } else if (start > this.length) { 1.10241 + start = this.length; 1.10242 + } 1.10243 + 1.10244 + if (typeof end == 'undefined' || end > this.length) { 1.10245 + end = this.length; 1.10246 + } else if (end < 0) { 1.10247 + end = 0; 1.10248 + } 1.10249 + 1.10250 + start = start + this.offset; 1.10251 + end = end + this.offset; 1.10252 + 1.10253 + switch (encoding) { 1.10254 + case 'hex': 1.10255 + return this.parent.hexSlice(start, end); 1.10256 + 1.10257 + case 'utf8': 1.10258 + case 'utf-8': 1.10259 + return this.parent.utf8Slice(start, end); 1.10260 + 1.10261 + case 'ascii': 1.10262 + return this.parent.asciiSlice(start, end); 1.10263 + 1.10264 + case 'binary': 1.10265 + return this.parent.binarySlice(start, end); 1.10266 + 1.10267 + case 'base64': 1.10268 + return this.parent.base64Slice(start, end); 1.10269 + 1.10270 + case 'ucs2': 1.10271 + case 'ucs-2': 1.10272 + return this.parent.ucs2Slice(start, end); 1.10273 + 1.10274 + default: 1.10275 + throw new Error('Unknown encoding'); 1.10276 + } 1.10277 +}; 1.10278 + 1.10279 + 1.10280 +// byteLength 1.10281 +Buffer.byteLength = SlowBuffer.byteLength; 1.10282 + 1.10283 + 1.10284 +// fill(value, start=0, end=buffer.length) 1.10285 +Buffer.prototype.fill = function fill(value, start, end) { 1.10286 + value || (value = 0); 1.10287 + start || (start = 0); 1.10288 + end || (end = this.length); 1.10289 + 1.10290 + if (typeof value === 'string') { 1.10291 + value = value.charCodeAt(0); 1.10292 + } 1.10293 + if (!(typeof value === 'number') || isNaN(value)) { 1.10294 + throw new Error('value is not a number'); 1.10295 + } 1.10296 + 1.10297 + if (end < start) throw new Error('end < start'); 1.10298 + 1.10299 + // Fill 0 bytes; we're done 1.10300 + if (end === start) return 0; 1.10301 + if (this.length == 0) return 0; 1.10302 + 1.10303 + if (start < 0 || start >= this.length) { 1.10304 + throw new Error('start out of bounds'); 1.10305 + } 1.10306 + 1.10307 + if (end < 0 || end > this.length) { 1.10308 + throw new Error('end out of bounds'); 1.10309 + } 1.10310 + 1.10311 + return this.parent.fill(value, 1.10312 + start + this.offset, 1.10313 + end + this.offset); 1.10314 +}; 1.10315 + 1.10316 + 1.10317 +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 1.10318 +Buffer.prototype.copy = function(target, target_start, start, end) { 1.10319 + var source = this; 1.10320 + start || (start = 0); 1.10321 + end || (end = this.length); 1.10322 + target_start || (target_start = 0); 1.10323 + 1.10324 + if (end < start) throw new Error('sourceEnd < sourceStart'); 1.10325 + 1.10326 + // Copy 0 bytes; we're done 1.10327 + if (end === start) return 0; 1.10328 + if (target.length == 0 || source.length == 0) return 0; 1.10329 + 1.10330 + if (target_start < 0 || target_start >= target.length) { 1.10331 + throw new Error('targetStart out of bounds'); 1.10332 + } 1.10333 + 1.10334 + if (start < 0 || start >= source.length) { 1.10335 + throw new Error('sourceStart out of bounds'); 1.10336 + } 1.10337 + 1.10338 + if (end < 0 || end > source.length) { 1.10339 + throw new Error('sourceEnd out of bounds'); 1.10340 + } 1.10341 + 1.10342 + // Are we oob? 1.10343 + if (end > this.length) { 1.10344 + end = this.length; 1.10345 + } 1.10346 + 1.10347 + if (target.length - target_start < end - start) { 1.10348 + end = target.length - target_start + start; 1.10349 + } 1.10350 + 1.10351 + return this.parent.copy(target.parent, 1.10352 + target_start + target.offset, 1.10353 + start + this.offset, 1.10354 + end + this.offset); 1.10355 +}; 1.10356 + 1.10357 + 1.10358 +// slice(start, end) 1.10359 +Buffer.prototype.slice = function(start, end) { 1.10360 + if (end === undefined) end = this.length; 1.10361 + if (end > this.length) throw new Error('oob'); 1.10362 + if (start > end) throw new Error('oob'); 1.10363 + 1.10364 + return new Buffer(this.parent, end - start, +start + this.offset); 1.10365 +}; 1.10366 + 1.10367 + 1.10368 +// Legacy methods for backwards compatibility. 1.10369 + 1.10370 +Buffer.prototype.utf8Slice = function(start, end) { 1.10371 + return this.toString('utf8', start, end); 1.10372 +}; 1.10373 + 1.10374 +Buffer.prototype.binarySlice = function(start, end) { 1.10375 + return this.toString('binary', start, end); 1.10376 +}; 1.10377 + 1.10378 +Buffer.prototype.asciiSlice = function(start, end) { 1.10379 + return this.toString('ascii', start, end); 1.10380 +}; 1.10381 + 1.10382 +Buffer.prototype.utf8Write = function(string, offset) { 1.10383 + return this.write(string, offset, 'utf8'); 1.10384 +}; 1.10385 + 1.10386 +Buffer.prototype.binaryWrite = function(string, offset) { 1.10387 + return this.write(string, offset, 'binary'); 1.10388 +}; 1.10389 + 1.10390 +Buffer.prototype.asciiWrite = function(string, offset) { 1.10391 + return this.write(string, offset, 'ascii'); 1.10392 +}; 1.10393 + 1.10394 +Buffer.prototype.readUInt8 = function(offset, noAssert) { 1.10395 + var buffer = this; 1.10396 + 1.10397 + if (!noAssert) { 1.10398 + assert.ok(offset !== undefined && offset !== null, 1.10399 + 'missing offset'); 1.10400 + 1.10401 + assert.ok(offset < buffer.length, 1.10402 + 'Trying to read beyond buffer length'); 1.10403 + } 1.10404 + 1.10405 + if (offset >= buffer.length) return; 1.10406 + 1.10407 + return buffer.parent[buffer.offset + offset]; 1.10408 +}; 1.10409 + 1.10410 +function readUInt16(buffer, offset, isBigEndian, noAssert) { 1.10411 + var val = 0; 1.10412 + 1.10413 + 1.10414 + if (!noAssert) { 1.10415 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10416 + 'missing or invalid endian'); 1.10417 + 1.10418 + assert.ok(offset !== undefined && offset !== null, 1.10419 + 'missing offset'); 1.10420 + 1.10421 + assert.ok(offset + 1 < buffer.length, 1.10422 + 'Trying to read beyond buffer length'); 1.10423 + } 1.10424 + 1.10425 + if (offset >= buffer.length) return 0; 1.10426 + 1.10427 + if (isBigEndian) { 1.10428 + val = buffer.parent[buffer.offset + offset] << 8; 1.10429 + if (offset + 1 < buffer.length) { 1.10430 + val |= buffer.parent[buffer.offset + offset + 1]; 1.10431 + } 1.10432 + } else { 1.10433 + val = buffer.parent[buffer.offset + offset]; 1.10434 + if (offset + 1 < buffer.length) { 1.10435 + val |= buffer.parent[buffer.offset + offset + 1] << 8; 1.10436 + } 1.10437 + } 1.10438 + 1.10439 + return val; 1.10440 +} 1.10441 + 1.10442 +Buffer.prototype.readUInt16LE = function(offset, noAssert) { 1.10443 + return readUInt16(this, offset, false, noAssert); 1.10444 +}; 1.10445 + 1.10446 +Buffer.prototype.readUInt16BE = function(offset, noAssert) { 1.10447 + return readUInt16(this, offset, true, noAssert); 1.10448 +}; 1.10449 + 1.10450 +function readUInt32(buffer, offset, isBigEndian, noAssert) { 1.10451 + var val = 0; 1.10452 + 1.10453 + if (!noAssert) { 1.10454 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10455 + 'missing or invalid endian'); 1.10456 + 1.10457 + assert.ok(offset !== undefined && offset !== null, 1.10458 + 'missing offset'); 1.10459 + 1.10460 + assert.ok(offset + 3 < buffer.length, 1.10461 + 'Trying to read beyond buffer length'); 1.10462 + } 1.10463 + 1.10464 + if (offset >= buffer.length) return 0; 1.10465 + 1.10466 + if (isBigEndian) { 1.10467 + if (offset + 1 < buffer.length) 1.10468 + val = buffer.parent[buffer.offset + offset + 1] << 16; 1.10469 + if (offset + 2 < buffer.length) 1.10470 + val |= buffer.parent[buffer.offset + offset + 2] << 8; 1.10471 + if (offset + 3 < buffer.length) 1.10472 + val |= buffer.parent[buffer.offset + offset + 3]; 1.10473 + val = val + (buffer.parent[buffer.offset + offset] << 24 >>> 0); 1.10474 + } else { 1.10475 + if (offset + 2 < buffer.length) 1.10476 + val = buffer.parent[buffer.offset + offset + 2] << 16; 1.10477 + if (offset + 1 < buffer.length) 1.10478 + val |= buffer.parent[buffer.offset + offset + 1] << 8; 1.10479 + val |= buffer.parent[buffer.offset + offset]; 1.10480 + if (offset + 3 < buffer.length) 1.10481 + val = val + (buffer.parent[buffer.offset + offset + 3] << 24 >>> 0); 1.10482 + } 1.10483 + 1.10484 + return val; 1.10485 +} 1.10486 + 1.10487 +Buffer.prototype.readUInt32LE = function(offset, noAssert) { 1.10488 + return readUInt32(this, offset, false, noAssert); 1.10489 +}; 1.10490 + 1.10491 +Buffer.prototype.readUInt32BE = function(offset, noAssert) { 1.10492 + return readUInt32(this, offset, true, noAssert); 1.10493 +}; 1.10494 + 1.10495 + 1.10496 +/* 1.10497 + * Signed integer types, yay team! A reminder on how two's complement actually 1.10498 + * works. The first bit is the signed bit, i.e. tells us whether or not the 1.10499 + * number should be positive or negative. If the two's complement value is 1.10500 + * positive, then we're done, as it's equivalent to the unsigned representation. 1.10501 + * 1.10502 + * Now if the number is positive, you're pretty much done, you can just leverage 1.10503 + * the unsigned translations and return those. Unfortunately, negative numbers 1.10504 + * aren't quite that straightforward. 1.10505 + * 1.10506 + * At first glance, one might be inclined to use the traditional formula to 1.10507 + * translate binary numbers between the positive and negative values in two's 1.10508 + * complement. (Though it doesn't quite work for the most negative value) 1.10509 + * Mainly: 1.10510 + * - invert all the bits 1.10511 + * - add one to the result 1.10512 + * 1.10513 + * Of course, this doesn't quite work in Javascript. Take for example the value 1.10514 + * of -128. This could be represented in 16 bits (big-endian) as 0xff80. But of 1.10515 + * course, Javascript will do the following: 1.10516 + * 1.10517 + * > ~0xff80 1.10518 + * -65409 1.10519 + * 1.10520 + * Whoh there, Javascript, that's not quite right. But wait, according to 1.10521 + * Javascript that's perfectly correct. When Javascript ends up seeing the 1.10522 + * constant 0xff80, it has no notion that it is actually a signed number. It 1.10523 + * assumes that we've input the unsigned value 0xff80. Thus, when it does the 1.10524 + * binary negation, it casts it into a signed value, (positive 0xff80). Then 1.10525 + * when you perform binary negation on that, it turns it into a negative number. 1.10526 + * 1.10527 + * Instead, we're going to have to use the following general formula, that works 1.10528 + * in a rather Javascript friendly way. I'm glad we don't support this kind of 1.10529 + * weird numbering scheme in the kernel. 1.10530 + * 1.10531 + * (BIT-MAX - (unsigned)val + 1) * -1 1.10532 + * 1.10533 + * The astute observer, may think that this doesn't make sense for 8-bit numbers 1.10534 + * (really it isn't necessary for them). However, when you get 16-bit numbers, 1.10535 + * you do. Let's go back to our prior example and see how this will look: 1.10536 + * 1.10537 + * (0xffff - 0xff80 + 1) * -1 1.10538 + * (0x007f + 1) * -1 1.10539 + * (0x0080) * -1 1.10540 + */ 1.10541 +Buffer.prototype.readInt8 = function(offset, noAssert) { 1.10542 + var buffer = this; 1.10543 + var neg; 1.10544 + 1.10545 + if (!noAssert) { 1.10546 + assert.ok(offset !== undefined && offset !== null, 1.10547 + 'missing offset'); 1.10548 + 1.10549 + assert.ok(offset < buffer.length, 1.10550 + 'Trying to read beyond buffer length'); 1.10551 + } 1.10552 + 1.10553 + if (offset >= buffer.length) return; 1.10554 + 1.10555 + neg = buffer.parent[buffer.offset + offset] & 0x80; 1.10556 + if (!neg) { 1.10557 + return (buffer.parent[buffer.offset + offset]); 1.10558 + } 1.10559 + 1.10560 + return ((0xff - buffer.parent[buffer.offset + offset] + 1) * -1); 1.10561 +}; 1.10562 + 1.10563 +function readInt16(buffer, offset, isBigEndian, noAssert) { 1.10564 + var neg, val; 1.10565 + 1.10566 + if (!noAssert) { 1.10567 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10568 + 'missing or invalid endian'); 1.10569 + 1.10570 + assert.ok(offset !== undefined && offset !== null, 1.10571 + 'missing offset'); 1.10572 + 1.10573 + assert.ok(offset + 1 < buffer.length, 1.10574 + 'Trying to read beyond buffer length'); 1.10575 + } 1.10576 + 1.10577 + val = readUInt16(buffer, offset, isBigEndian, noAssert); 1.10578 + neg = val & 0x8000; 1.10579 + if (!neg) { 1.10580 + return val; 1.10581 + } 1.10582 + 1.10583 + return (0xffff - val + 1) * -1; 1.10584 +} 1.10585 + 1.10586 +Buffer.prototype.readInt16LE = function(offset, noAssert) { 1.10587 + return readInt16(this, offset, false, noAssert); 1.10588 +}; 1.10589 + 1.10590 +Buffer.prototype.readInt16BE = function(offset, noAssert) { 1.10591 + return readInt16(this, offset, true, noAssert); 1.10592 +}; 1.10593 + 1.10594 +function readInt32(buffer, offset, isBigEndian, noAssert) { 1.10595 + var neg, val; 1.10596 + 1.10597 + if (!noAssert) { 1.10598 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10599 + 'missing or invalid endian'); 1.10600 + 1.10601 + assert.ok(offset !== undefined && offset !== null, 1.10602 + 'missing offset'); 1.10603 + 1.10604 + assert.ok(offset + 3 < buffer.length, 1.10605 + 'Trying to read beyond buffer length'); 1.10606 + } 1.10607 + 1.10608 + val = readUInt32(buffer, offset, isBigEndian, noAssert); 1.10609 + neg = val & 0x80000000; 1.10610 + if (!neg) { 1.10611 + return (val); 1.10612 + } 1.10613 + 1.10614 + return (0xffffffff - val + 1) * -1; 1.10615 +} 1.10616 + 1.10617 +Buffer.prototype.readInt32LE = function(offset, noAssert) { 1.10618 + return readInt32(this, offset, false, noAssert); 1.10619 +}; 1.10620 + 1.10621 +Buffer.prototype.readInt32BE = function(offset, noAssert) { 1.10622 + return readInt32(this, offset, true, noAssert); 1.10623 +}; 1.10624 + 1.10625 +function readFloat(buffer, offset, isBigEndian, noAssert) { 1.10626 + if (!noAssert) { 1.10627 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10628 + 'missing or invalid endian'); 1.10629 + 1.10630 + assert.ok(offset + 3 < buffer.length, 1.10631 + 'Trying to read beyond buffer length'); 1.10632 + } 1.10633 + 1.10634 + return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian, 1.10635 + 23, 4); 1.10636 +} 1.10637 + 1.10638 +Buffer.prototype.readFloatLE = function(offset, noAssert) { 1.10639 + return readFloat(this, offset, false, noAssert); 1.10640 +}; 1.10641 + 1.10642 +Buffer.prototype.readFloatBE = function(offset, noAssert) { 1.10643 + return readFloat(this, offset, true, noAssert); 1.10644 +}; 1.10645 + 1.10646 +function readDouble(buffer, offset, isBigEndian, noAssert) { 1.10647 + if (!noAssert) { 1.10648 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10649 + 'missing or invalid endian'); 1.10650 + 1.10651 + assert.ok(offset + 7 < buffer.length, 1.10652 + 'Trying to read beyond buffer length'); 1.10653 + } 1.10654 + 1.10655 + return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian, 1.10656 + 52, 8); 1.10657 +} 1.10658 + 1.10659 +Buffer.prototype.readDoubleLE = function(offset, noAssert) { 1.10660 + return readDouble(this, offset, false, noAssert); 1.10661 +}; 1.10662 + 1.10663 +Buffer.prototype.readDoubleBE = function(offset, noAssert) { 1.10664 + return readDouble(this, offset, true, noAssert); 1.10665 +}; 1.10666 + 1.10667 + 1.10668 +/* 1.10669 + * We have to make sure that the value is a valid integer. This means that it is 1.10670 + * non-negative. It has no fractional component and that it does not exceed the 1.10671 + * maximum allowed value. 1.10672 + * 1.10673 + * value The number to check for validity 1.10674 + * 1.10675 + * max The maximum value 1.10676 + */ 1.10677 +function verifuint(value, max) { 1.10678 + assert.ok(typeof (value) == 'number', 1.10679 + 'cannot write a non-number as a number'); 1.10680 + 1.10681 + assert.ok(value >= 0, 1.10682 + 'specified a negative value for writing an unsigned value'); 1.10683 + 1.10684 + assert.ok(value <= max, 'value is larger than maximum value for type'); 1.10685 + 1.10686 + assert.ok(Math.floor(value) === value, 'value has a fractional component'); 1.10687 +} 1.10688 + 1.10689 +Buffer.prototype.writeUInt8 = function(value, offset, noAssert) { 1.10690 + var buffer = this; 1.10691 + 1.10692 + if (!noAssert) { 1.10693 + assert.ok(value !== undefined && value !== null, 1.10694 + 'missing value'); 1.10695 + 1.10696 + assert.ok(offset !== undefined && offset !== null, 1.10697 + 'missing offset'); 1.10698 + 1.10699 + assert.ok(offset < buffer.length, 1.10700 + 'trying to write beyond buffer length'); 1.10701 + 1.10702 + verifuint(value, 0xff); 1.10703 + } 1.10704 + 1.10705 + if (offset < buffer.length) { 1.10706 + buffer.parent[buffer.offset + offset] = value; 1.10707 + } 1.10708 +}; 1.10709 + 1.10710 +function writeUInt16(buffer, value, offset, isBigEndian, noAssert) { 1.10711 + if (!noAssert) { 1.10712 + assert.ok(value !== undefined && value !== null, 1.10713 + 'missing value'); 1.10714 + 1.10715 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10716 + 'missing or invalid endian'); 1.10717 + 1.10718 + assert.ok(offset !== undefined && offset !== null, 1.10719 + 'missing offset'); 1.10720 + 1.10721 + assert.ok(offset + 1 < buffer.length, 1.10722 + 'trying to write beyond buffer length'); 1.10723 + 1.10724 + verifuint(value, 0xffff); 1.10725 + } 1.10726 + 1.10727 + for (var i = 0; i < Math.min(buffer.length - offset, 2); i++) { 1.10728 + buffer.parent[buffer.offset + offset + i] = 1.10729 + (value & (0xff << (8 * (isBigEndian ? 1 - i : i)))) >>> 1.10730 + (isBigEndian ? 1 - i : i) * 8; 1.10731 + } 1.10732 + 1.10733 +} 1.10734 + 1.10735 +Buffer.prototype.writeUInt16LE = function(value, offset, noAssert) { 1.10736 + writeUInt16(this, value, offset, false, noAssert); 1.10737 +}; 1.10738 + 1.10739 +Buffer.prototype.writeUInt16BE = function(value, offset, noAssert) { 1.10740 + writeUInt16(this, value, offset, true, noAssert); 1.10741 +}; 1.10742 + 1.10743 +function writeUInt32(buffer, value, offset, isBigEndian, noAssert) { 1.10744 + if (!noAssert) { 1.10745 + assert.ok(value !== undefined && value !== null, 1.10746 + 'missing value'); 1.10747 + 1.10748 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10749 + 'missing or invalid endian'); 1.10750 + 1.10751 + assert.ok(offset !== undefined && offset !== null, 1.10752 + 'missing offset'); 1.10753 + 1.10754 + assert.ok(offset + 3 < buffer.length, 1.10755 + 'trying to write beyond buffer length'); 1.10756 + 1.10757 + verifuint(value, 0xffffffff); 1.10758 + } 1.10759 + 1.10760 + for (var i = 0; i < Math.min(buffer.length - offset, 4); i++) { 1.10761 + buffer.parent[buffer.offset + offset + i] = 1.10762 + (value >>> (isBigEndian ? 3 - i : i) * 8) & 0xff; 1.10763 + } 1.10764 +} 1.10765 + 1.10766 +Buffer.prototype.writeUInt32LE = function(value, offset, noAssert) { 1.10767 + writeUInt32(this, value, offset, false, noAssert); 1.10768 +}; 1.10769 + 1.10770 +Buffer.prototype.writeUInt32BE = function(value, offset, noAssert) { 1.10771 + writeUInt32(this, value, offset, true, noAssert); 1.10772 +}; 1.10773 + 1.10774 + 1.10775 +/* 1.10776 + * We now move onto our friends in the signed number category. Unlike unsigned 1.10777 + * numbers, we're going to have to worry a bit more about how we put values into 1.10778 + * arrays. Since we are only worrying about signed 32-bit values, we're in 1.10779 + * slightly better shape. Unfortunately, we really can't do our favorite binary 1.10780 + * & in this system. It really seems to do the wrong thing. For example: 1.10781 + * 1.10782 + * > -32 & 0xff 1.10783 + * 224 1.10784 + * 1.10785 + * What's happening above is really: 0xe0 & 0xff = 0xe0. However, the results of 1.10786 + * this aren't treated as a signed number. Ultimately a bad thing. 1.10787 + * 1.10788 + * What we're going to want to do is basically create the unsigned equivalent of 1.10789 + * our representation and pass that off to the wuint* functions. To do that 1.10790 + * we're going to do the following: 1.10791 + * 1.10792 + * - if the value is positive 1.10793 + * we can pass it directly off to the equivalent wuint 1.10794 + * - if the value is negative 1.10795 + * we do the following computation: 1.10796 + * mb + val + 1, where 1.10797 + * mb is the maximum unsigned value in that byte size 1.10798 + * val is the Javascript negative integer 1.10799 + * 1.10800 + * 1.10801 + * As a concrete value, take -128. In signed 16 bits this would be 0xff80. If 1.10802 + * you do out the computations: 1.10803 + * 1.10804 + * 0xffff - 128 + 1 1.10805 + * 0xffff - 127 1.10806 + * 0xff80 1.10807 + * 1.10808 + * You can then encode this value as the signed version. This is really rather 1.10809 + * hacky, but it should work and get the job done which is our goal here. 1.10810 + */ 1.10811 + 1.10812 +/* 1.10813 + * A series of checks to make sure we actually have a signed 32-bit number 1.10814 + */ 1.10815 +function verifsint(value, max, min) { 1.10816 + assert.ok(typeof (value) == 'number', 1.10817 + 'cannot write a non-number as a number'); 1.10818 + 1.10819 + assert.ok(value <= max, 'value larger than maximum allowed value'); 1.10820 + 1.10821 + assert.ok(value >= min, 'value smaller than minimum allowed value'); 1.10822 + 1.10823 + assert.ok(Math.floor(value) === value, 'value has a fractional component'); 1.10824 +} 1.10825 + 1.10826 +function verifIEEE754(value, max, min) { 1.10827 + assert.ok(typeof (value) == 'number', 1.10828 + 'cannot write a non-number as a number'); 1.10829 + 1.10830 + assert.ok(value <= max, 'value larger than maximum allowed value'); 1.10831 + 1.10832 + assert.ok(value >= min, 'value smaller than minimum allowed value'); 1.10833 +} 1.10834 + 1.10835 +Buffer.prototype.writeInt8 = function(value, offset, noAssert) { 1.10836 + var buffer = this; 1.10837 + 1.10838 + if (!noAssert) { 1.10839 + assert.ok(value !== undefined && value !== null, 1.10840 + 'missing value'); 1.10841 + 1.10842 + assert.ok(offset !== undefined && offset !== null, 1.10843 + 'missing offset'); 1.10844 + 1.10845 + assert.ok(offset < buffer.length, 1.10846 + 'Trying to write beyond buffer length'); 1.10847 + 1.10848 + verifsint(value, 0x7f, -0x80); 1.10849 + } 1.10850 + 1.10851 + if (value >= 0) { 1.10852 + buffer.writeUInt8(value, offset, noAssert); 1.10853 + } else { 1.10854 + buffer.writeUInt8(0xff + value + 1, offset, noAssert); 1.10855 + } 1.10856 +}; 1.10857 + 1.10858 +function writeInt16(buffer, value, offset, isBigEndian, noAssert) { 1.10859 + if (!noAssert) { 1.10860 + assert.ok(value !== undefined && value !== null, 1.10861 + 'missing value'); 1.10862 + 1.10863 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10864 + 'missing or invalid endian'); 1.10865 + 1.10866 + assert.ok(offset !== undefined && offset !== null, 1.10867 + 'missing offset'); 1.10868 + 1.10869 + assert.ok(offset + 1 < buffer.length, 1.10870 + 'Trying to write beyond buffer length'); 1.10871 + 1.10872 + verifsint(value, 0x7fff, -0x8000); 1.10873 + } 1.10874 + 1.10875 + if (value >= 0) { 1.10876 + writeUInt16(buffer, value, offset, isBigEndian, noAssert); 1.10877 + } else { 1.10878 + writeUInt16(buffer, 0xffff + value + 1, offset, isBigEndian, noAssert); 1.10879 + } 1.10880 +} 1.10881 + 1.10882 +Buffer.prototype.writeInt16LE = function(value, offset, noAssert) { 1.10883 + writeInt16(this, value, offset, false, noAssert); 1.10884 +}; 1.10885 + 1.10886 +Buffer.prototype.writeInt16BE = function(value, offset, noAssert) { 1.10887 + writeInt16(this, value, offset, true, noAssert); 1.10888 +}; 1.10889 + 1.10890 +function writeInt32(buffer, value, offset, isBigEndian, noAssert) { 1.10891 + if (!noAssert) { 1.10892 + assert.ok(value !== undefined && value !== null, 1.10893 + 'missing value'); 1.10894 + 1.10895 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10896 + 'missing or invalid endian'); 1.10897 + 1.10898 + assert.ok(offset !== undefined && offset !== null, 1.10899 + 'missing offset'); 1.10900 + 1.10901 + assert.ok(offset + 3 < buffer.length, 1.10902 + 'Trying to write beyond buffer length'); 1.10903 + 1.10904 + verifsint(value, 0x7fffffff, -0x80000000); 1.10905 + } 1.10906 + 1.10907 + if (value >= 0) { 1.10908 + writeUInt32(buffer, value, offset, isBigEndian, noAssert); 1.10909 + } else { 1.10910 + writeUInt32(buffer, 0xffffffff + value + 1, offset, isBigEndian, noAssert); 1.10911 + } 1.10912 +} 1.10913 + 1.10914 +Buffer.prototype.writeInt32LE = function(value, offset, noAssert) { 1.10915 + writeInt32(this, value, offset, false, noAssert); 1.10916 +}; 1.10917 + 1.10918 +Buffer.prototype.writeInt32BE = function(value, offset, noAssert) { 1.10919 + writeInt32(this, value, offset, true, noAssert); 1.10920 +}; 1.10921 + 1.10922 +function writeFloat(buffer, value, offset, isBigEndian, noAssert) { 1.10923 + if (!noAssert) { 1.10924 + assert.ok(value !== undefined && value !== null, 1.10925 + 'missing value'); 1.10926 + 1.10927 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10928 + 'missing or invalid endian'); 1.10929 + 1.10930 + assert.ok(offset !== undefined && offset !== null, 1.10931 + 'missing offset'); 1.10932 + 1.10933 + assert.ok(offset + 3 < buffer.length, 1.10934 + 'Trying to write beyond buffer length'); 1.10935 + 1.10936 + verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38); 1.10937 + } 1.10938 + 1.10939 + require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian, 1.10940 + 23, 4); 1.10941 +} 1.10942 + 1.10943 +Buffer.prototype.writeFloatLE = function(value, offset, noAssert) { 1.10944 + writeFloat(this, value, offset, false, noAssert); 1.10945 +}; 1.10946 + 1.10947 +Buffer.prototype.writeFloatBE = function(value, offset, noAssert) { 1.10948 + writeFloat(this, value, offset, true, noAssert); 1.10949 +}; 1.10950 + 1.10951 +function writeDouble(buffer, value, offset, isBigEndian, noAssert) { 1.10952 + if (!noAssert) { 1.10953 + assert.ok(value !== undefined && value !== null, 1.10954 + 'missing value'); 1.10955 + 1.10956 + assert.ok(typeof (isBigEndian) === 'boolean', 1.10957 + 'missing or invalid endian'); 1.10958 + 1.10959 + assert.ok(offset !== undefined && offset !== null, 1.10960 + 'missing offset'); 1.10961 + 1.10962 + assert.ok(offset + 7 < buffer.length, 1.10963 + 'Trying to write beyond buffer length'); 1.10964 + 1.10965 + verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308); 1.10966 + } 1.10967 + 1.10968 + require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian, 1.10969 + 52, 8); 1.10970 +} 1.10971 + 1.10972 +Buffer.prototype.writeDoubleLE = function(value, offset, noAssert) { 1.10973 + writeDouble(this, value, offset, false, noAssert); 1.10974 +}; 1.10975 + 1.10976 +Buffer.prototype.writeDoubleBE = function(value, offset, noAssert) { 1.10977 + writeDouble(this, value, offset, true, noAssert); 1.10978 +}; 1.10979 + 1.10980 +SlowBuffer.prototype.readUInt8 = Buffer.prototype.readUInt8; 1.10981 +SlowBuffer.prototype.readUInt16LE = Buffer.prototype.readUInt16LE; 1.10982 +SlowBuffer.prototype.readUInt16BE = Buffer.prototype.readUInt16BE; 1.10983 +SlowBuffer.prototype.readUInt32LE = Buffer.prototype.readUInt32LE; 1.10984 +SlowBuffer.prototype.readUInt32BE = Buffer.prototype.readUInt32BE; 1.10985 +SlowBuffer.prototype.readInt8 = Buffer.prototype.readInt8; 1.10986 +SlowBuffer.prototype.readInt16LE = Buffer.prototype.readInt16LE; 1.10987 +SlowBuffer.prototype.readInt16BE = Buffer.prototype.readInt16BE; 1.10988 +SlowBuffer.prototype.readInt32LE = Buffer.prototype.readInt32LE; 1.10989 +SlowBuffer.prototype.readInt32BE = Buffer.prototype.readInt32BE; 1.10990 +SlowBuffer.prototype.readFloatLE = Buffer.prototype.readFloatLE; 1.10991 +SlowBuffer.prototype.readFloatBE = Buffer.prototype.readFloatBE; 1.10992 +SlowBuffer.prototype.readDoubleLE = Buffer.prototype.readDoubleLE; 1.10993 +SlowBuffer.prototype.readDoubleBE = Buffer.prototype.readDoubleBE; 1.10994 +SlowBuffer.prototype.writeUInt8 = Buffer.prototype.writeUInt8; 1.10995 +SlowBuffer.prototype.writeUInt16LE = Buffer.prototype.writeUInt16LE; 1.10996 +SlowBuffer.prototype.writeUInt16BE = Buffer.prototype.writeUInt16BE; 1.10997 +SlowBuffer.prototype.writeUInt32LE = Buffer.prototype.writeUInt32LE; 1.10998 +SlowBuffer.prototype.writeUInt32BE = Buffer.prototype.writeUInt32BE; 1.10999 +SlowBuffer.prototype.writeInt8 = Buffer.prototype.writeInt8; 1.11000 +SlowBuffer.prototype.writeInt16LE = Buffer.prototype.writeInt16LE; 1.11001 +SlowBuffer.prototype.writeInt16BE = Buffer.prototype.writeInt16BE; 1.11002 +SlowBuffer.prototype.writeInt32LE = Buffer.prototype.writeInt32LE; 1.11003 +SlowBuffer.prototype.writeInt32BE = Buffer.prototype.writeInt32BE; 1.11004 +SlowBuffer.prototype.writeFloatLE = Buffer.prototype.writeFloatLE; 1.11005 +SlowBuffer.prototype.writeFloatBE = Buffer.prototype.writeFloatBE; 1.11006 +SlowBuffer.prototype.writeDoubleLE = Buffer.prototype.writeDoubleLE; 1.11007 +SlowBuffer.prototype.writeDoubleBE = Buffer.prototype.writeDoubleBE; 1.11008 + 1.11009 +})() 1.11010 +},{"assert":9,"./buffer_ieee754":14,"base64-js":15}],15:[function(require,module,exports){ 1.11011 +(function (exports) { 1.11012 + 'use strict'; 1.11013 + 1.11014 + var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; 1.11015 + 1.11016 + function b64ToByteArray(b64) { 1.11017 + var i, j, l, tmp, placeHolders, arr; 1.11018 + 1.11019 + if (b64.length % 4 > 0) { 1.11020 + throw 'Invalid string. Length must be a multiple of 4'; 1.11021 + } 1.11022 + 1.11023 + // the number of equal signs (place holders) 1.11024 + // if there are two placeholders, than the two characters before it 1.11025 + // represent one byte 1.11026 + // if there is only one, then the three characters before it represent 2 bytes 1.11027 + // this is just a cheap hack to not do indexOf twice 1.11028 + placeHolders = b64.indexOf('='); 1.11029 + placeHolders = placeHolders > 0 ? b64.length - placeHolders : 0; 1.11030 + 1.11031 + // base64 is 4/3 + up to two characters of the original data 1.11032 + arr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders); 1.11033 + 1.11034 + // if there are placeholders, only get up to the last complete 4 chars 1.11035 + l = placeHolders > 0 ? b64.length - 4 : b64.length; 1.11036 + 1.11037 + for (i = 0, j = 0; i < l; i += 4, j += 3) { 1.11038 + tmp = (lookup.indexOf(b64[i]) << 18) | (lookup.indexOf(b64[i + 1]) << 12) | (lookup.indexOf(b64[i + 2]) << 6) | lookup.indexOf(b64[i + 3]); 1.11039 + arr.push((tmp & 0xFF0000) >> 16); 1.11040 + arr.push((tmp & 0xFF00) >> 8); 1.11041 + arr.push(tmp & 0xFF); 1.11042 + } 1.11043 + 1.11044 + if (placeHolders === 2) { 1.11045 + tmp = (lookup.indexOf(b64[i]) << 2) | (lookup.indexOf(b64[i + 1]) >> 4); 1.11046 + arr.push(tmp & 0xFF); 1.11047 + } else if (placeHolders === 1) { 1.11048 + tmp = (lookup.indexOf(b64[i]) << 10) | (lookup.indexOf(b64[i + 1]) << 4) | (lookup.indexOf(b64[i + 2]) >> 2); 1.11049 + arr.push((tmp >> 8) & 0xFF); 1.11050 + arr.push(tmp & 0xFF); 1.11051 + } 1.11052 + 1.11053 + return arr; 1.11054 + } 1.11055 + 1.11056 + function uint8ToBase64(uint8) { 1.11057 + var i, 1.11058 + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes 1.11059 + output = "", 1.11060 + temp, length; 1.11061 + 1.11062 + function tripletToBase64 (num) { 1.11063 + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; 1.11064 + }; 1.11065 + 1.11066 + // go through the array every three bytes, we'll deal with trailing stuff later 1.11067 + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { 1.11068 + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); 1.11069 + output += tripletToBase64(temp); 1.11070 + } 1.11071 + 1.11072 + // pad the end with zeros, but make sure to not forget the extra bytes 1.11073 + switch (extraBytes) { 1.11074 + case 1: 1.11075 + temp = uint8[uint8.length - 1]; 1.11076 + output += lookup[temp >> 2]; 1.11077 + output += lookup[(temp << 4) & 0x3F]; 1.11078 + output += '=='; 1.11079 + break; 1.11080 + case 2: 1.11081 + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]); 1.11082 + output += lookup[temp >> 10]; 1.11083 + output += lookup[(temp >> 4) & 0x3F]; 1.11084 + output += lookup[(temp << 2) & 0x3F]; 1.11085 + output += '='; 1.11086 + break; 1.11087 + } 1.11088 + 1.11089 + return output; 1.11090 + } 1.11091 + 1.11092 + module.exports.toByteArray = b64ToByteArray; 1.11093 + module.exports.fromByteArray = uint8ToBase64; 1.11094 +}()); 1.11095 + 1.11096 +},{}]},{},["E/GbHF"]) 1.11097 +; 1.11098 +JSHINT = require('jshint').JSHINT; 1.11099 +}());