@samitouri / QOS-React-2 / commits / 1d4371a1d2

[docs] Replace JSXTransformer with babel/browser

Closes #4131

Vipul A M committed Jun 15, 2015 at 17:26 UTC 1d4371a1d259bf418ab57d66f6746fcdfa21c5d5
5 files changed +6 -15921
docs/Gemfile.lock
+3
@@ -80,3 +80,6 @@ DEPENDENCIES
80 rake
81 rb-fsevent
82 sanitize (~> 2.0)
83 +
84 +BUNDLED WITH
85 + 1.10.1
docs/Rakefile
+1
@@ -4,6 +4,7 @@ require('yaml')
4
5 desc "generate js from jsx"
6 task :js do
7 + system "cp ../node_modules/babel/node_modules/babel-core/browser.min.js ./js/babel-browser.min.js"
8 system "../node_modules/.bin/babel _js --out-dir=js"
9 end
10
docs/_js/live_editor.js
+1 -1
@@ -91,7 +91,7 @@ var ReactPlayground = React.createClass({
91 getDefaultProps: function() {
92 return {
93 transformer: function(code) {
94 - return JSXTransformer.transform(code).code;
94 + return babel.transform(code).code;
95 },
96 editorTabTitle: 'Live JSX Editor',
97 showCompiledJSTab: true,
docs/_layouts/default.html
+1 -1
@@ -31,7 +31,7 @@
31 <script src="/react/js/codemirror.js"></script>
32 <script src="/react/js/javascript.js"></script>
33 <script src="/react/js/react.js"></script>
34 - <script src="/react/js/JSXTransformer.js"></script>
34 + <script src="/react/js/babel-browser.min.js"></script>
35 <script src="/react/js/live_editor.js"></script>
36 </head>
37 <body>
docs/js/JSXTransformer.js deleted
-15919
@@ -1,15919 +0,0 @@
1 -/**
2 - * JSXTransformer v0.13.3
3 - */
4 -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
5 -/**
6 - * Copyright 2013-2015, Facebook, Inc.
7 - * All rights reserved.
8 - *
9 - * This source code is licensed under the BSD-style license found in the
10 - * LICENSE file in the root directory of this source tree. An additional grant
11 - * of patent rights can be found in the PATENTS file in the same directory.
12 - */
13 -/* jshint browser: true */
14 -/* jslint evil: true */
15 -/*eslint-disable no-eval */
16 -/*eslint-disable block-scoped-var */
17 -
18 -'use strict';
19 -
20 -var ReactTools = _dereq_('../main');
21 -var inlineSourceMap = _dereq_('./inline-source-map');
22 -
23 -var headEl;
24 -var dummyAnchor;
25 -var inlineScriptCount = 0;
26 -
27 -// The source-map library relies on Object.defineProperty, but IE8 doesn't
28 -// support it fully even with es5-sham. Indeed, es5-sham's defineProperty
29 -// throws when Object.prototype.__defineGetter__ is missing, so we skip building
30 -// the source map in that case.
31 -var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
32 -
33 -/**
34 - * Run provided code through jstransform.
35 - *
36 - * @param {string} source Original source code
37 - * @param {object?} options Options to pass to jstransform
38 - * @return {object} object as returned from jstransform
39 - */
40 -function transformReact(source, options) {
41 - options = options || {};
42 -
43 - // Force the sourcemaps option manually. We don't want to use it if it will
44 - // break (see above note about supportsAccessors). We'll only override the
45 - // value here if sourceMap was specified and is truthy. This guarantees that
46 - // we won't override any user intent (since this method is exposed publicly).
47 - if (options.sourceMap) {
48 - options.sourceMap = supportsAccessors;
49 - }
50 -
51 - // Otherwise just pass all options straight through to react-tools.
52 - return ReactTools.transformWithDetails(source, options);
53 -}
54 -
55 -/**
56 - * Eval provided source after transforming it.
57 - *
58 - * @param {string} source Original source code
59 - * @param {object?} options Options to pass to jstransform
60 - */
61 -function exec(source, options) {
62 - return eval(transformReact(source, options).code);
63 -}
64 -
65 -/**
66 - * This method returns a nicely formated line of code pointing to the exact
67 - * location of the error `e`. The line is limited in size so big lines of code
68 - * are also shown in a readable way.
69 - *
70 - * Example:
71 - * ... x', overflow:'scroll'}} id={} onScroll={this.scroll} class=" ...
72 - * ^
73 - *
74 - * @param {string} code The full string of code
75 - * @param {Error} e The error being thrown
76 - * @return {string} formatted message
77 - * @internal
78 - */
79 -function createSourceCodeErrorMessage(code, e) {
80 - var sourceLines = code.split('\n');
81 - // e.lineNumber is non-standard so we can't depend on its availability. If
82 - // we're in a browser where it isn't supported, don't even bother trying to
83 - // format anything. We may also hit a case where the line number is reported
84 - // incorrectly and is outside the bounds of the actual code. Handle that too.
85 - if (!e.lineNumber || e.lineNumber > sourceLines.length) {
86 - return '';
87 - }
88 - var erroneousLine = sourceLines[e.lineNumber - 1];
89 -
90 - // Removes any leading indenting spaces and gets the number of
91 - // chars indenting the `erroneousLine`
92 - var indentation = 0;
93 - erroneousLine = erroneousLine.replace(/^\s+/, function(leadingSpaces) {
94 - indentation = leadingSpaces.length;
95 - return '';
96 - });
97 -
98 - // Defines the number of characters that are going to show
99 - // before and after the erroneous code
100 - var LIMIT = 30;
101 - var errorColumn = e.column - indentation;
102 -
103 - if (errorColumn > LIMIT) {
104 - erroneousLine = '... ' + erroneousLine.slice(errorColumn - LIMIT);
105 - errorColumn = 4 + LIMIT;
106 - }
107 - if (erroneousLine.length - errorColumn > LIMIT) {
108 - erroneousLine = erroneousLine.slice(0, errorColumn + LIMIT) + ' ...';
109 - }
110 - var message = '\n\n' + erroneousLine + '\n';
111 - message += new Array(errorColumn - 1).join(' ') + '^';
112 - return message;
113 -}
114 -
115 -/**
116 - * Actually transform the code.
117 - *
118 - * @param {string} code
119 - * @param {string?} url
120 - * @param {object?} options
121 - * @return {string} The transformed code.
122 - * @internal
123 - */
124 -function transformCode(code, url, options) {
125 - try {
126 - var transformed = transformReact(code, options);
127 - } catch(e) {
128 - e.message += '\n at ';
129 - if (url) {
130 - if ('fileName' in e) {
131 - // We set `fileName` if it's supported by this error object and
132 - // a `url` was provided.
133 - // The error will correctly point to `url` in Firefox.
134 - e.fileName = url;
135 - }
136 - e.message += url + ':' + e.lineNumber + ':' + e.columnNumber;
137 - } else {
138 - e.message += location.href;
139 - }
140 - e.message += createSourceCodeErrorMessage(code, e);
141 - throw e;
142 - }
143 -
144 - if (!transformed.sourceMap) {
145 - return transformed.code;
146 - }
147 -
148 - var source;
149 - if (url == null) {
150 - source = 'Inline JSX script';
151 - inlineScriptCount++;
152 - if (inlineScriptCount > 1) {
153 - source += ' (' + inlineScriptCount + ')';
154 - }
155 - } else if (dummyAnchor) {
156 - // Firefox has problems when the sourcemap source is a proper URL with a
157 - // protocol and hostname, so use the pathname. We could use just the
158 - // filename, but hopefully using the full path will prevent potential
159 - // issues where the same filename exists in multiple directories.
160 - dummyAnchor.href = url;
161 - source = dummyAnchor.pathname.substr(1);
162 - }
163 -
164 - return (
165 - transformed.code +
166 - '\n' +
167 - inlineSourceMap(transformed.sourceMap, code, source)
168 - );
169 -}
170 -
171 -
172 -/**
173 - * Appends a script element at the end of the <head> with the content of code,
174 - * after transforming it.
175 - *
176 - * @param {string} code The original source code
177 - * @param {string?} url Where the code came from. null if inline
178 - * @param {object?} options Options to pass to jstransform
179 - * @internal
180 - */
181 -function run(code, url, options) {
182 - var scriptEl = document.createElement('script');
183 - scriptEl.text = transformCode(code, url, options);
184 - headEl.appendChild(scriptEl);
185 -}
186 -
187 -/**
188 - * Load script from the provided url and pass the content to the callback.
189 - *
190 - * @param {string} url The location of the script src
191 - * @param {function} callback Function to call with the content of url
192 - * @internal
193 - */
194 -function load(url, successCallback, errorCallback) {
195 - var xhr;
196 - xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP')
197 - : new XMLHttpRequest();
198 -
199 - // async, however scripts will be executed in the order they are in the
200 - // DOM to mirror normal script loading.
201 - xhr.open('GET', url, true);
202 - if ('overrideMimeType' in xhr) {
203 - xhr.overrideMimeType('text/plain');
204 - }
205 - xhr.onreadystatechange = function() {
206 - if (xhr.readyState === 4) {
207 - if (xhr.status === 0 || xhr.status === 200) {
208 - successCallback(xhr.responseText);
209 - } else {
210 - errorCallback();
211 - throw new Error('Could not load ' + url);
212 - }
213 - }
214 - };
215 - return xhr.send(null);
216 -}
217 -
218 -/**
219 - * Loop over provided script tags and get the content, via innerHTML if an
220 - * inline script, or by using XHR. Transforms are applied if needed. The scripts
221 - * are executed in the order they are found on the page.
222 - *
223 - * @param {array} scripts The <script> elements to load and run.
224 - * @internal
225 - */
226 -function loadScripts(scripts) {
227 - var result = [];
228 - var count = scripts.length;
229 -
230 - function check() {
231 - var script, i;
232 -
233 - for (i = 0; i < count; i++) {
234 - script = result[i];
235 -
236 - if (script.loaded && !script.executed) {
237 - script.executed = true;
238 - run(script.content, script.url, script.options);
239 - } else if (!script.loaded && !script.error && !script.async) {
240 - break;
241 - }
242 - }
243 - }
244 -
245 - scripts.forEach(function(script, i) {
246 - var options = {
247 - sourceMap: true
248 - };
249 - if (/;harmony=true(;|$)/.test(script.type)) {
250 - options.harmony = true;
251 - }
252 - if (/;stripTypes=true(;|$)/.test(script.type)) {
253 - options.stripTypes = true;
254 - }
255 -
256 - // script.async is always true for non-javascript script tags
257 - var async = script.hasAttribute('async');
258 -
259 - if (script.src) {
260 - result[i] = {
261 - async: async,
262 - error: false,
263 - executed: false,
264 - content: null,
265 - loaded: false,
266 - url: script.src,
267 - options: options
268 - };
269 -
270 - load(script.src, function(content) {
271 - result[i].loaded = true;
272 - result[i].content = content;
273 - check();
274 - }, function() {
275 - result[i].error = true;
276 - check();
277 - });
278 - } else {
279 - result[i] = {
280 - async: async,
281 - error: false,
282 - executed: false,
283 - content: script.innerHTML,
284 - loaded: true,
285 - url: null,
286 - options: options
287 - };
288 - }
289 - });
290 -
291 - check();
292 -}
293 -
294 -/**
295 - * Find and run all script tags with type="text/jsx".
296 - *
297 - * @internal
298 - */
299 -function runScripts() {
300 - var scripts = document.getElementsByTagName('script');
301 -
302 - // Array.prototype.slice cannot be used on NodeList on IE8
303 - var jsxScripts = [];
304 - for (var i = 0; i < scripts.length; i++) {
305 - if (/^text\/jsx(;|$)/.test(scripts.item(i).type)) {
306 - jsxScripts.push(scripts.item(i));
307 - }
308 - }
309 -
310 - if (jsxScripts.length < 1) {
311 - return;
312 - }
313 -
314 - console.warn(
315 - 'You are using the in-browser JSX transformer. Be sure to precompile ' +
316 - 'your JSX for production - ' +
317 - 'http://facebook.github.io/react/docs/tooling-integration.html#jsx'
318 - );
319 -
320 - loadScripts(jsxScripts);
321 -}
322 -
323 -// Listen for load event if we're in a browser and then kick off finding and
324 -// running of scripts.
325 -if (typeof window !== 'undefined' && window !== null) {
326 - headEl = document.getElementsByTagName('head')[0];
327 - dummyAnchor = document.createElement('a');
328 -
329 - if (window.addEventListener) {
330 - window.addEventListener('DOMContentLoaded', runScripts, false);
331 - } else {
332 - window.attachEvent('onload', runScripts);
333 - }
334 -}
335 -
336 -module.exports = {
337 - transform: transformReact,
338 - exec: exec
339 -};
340 -
341 -},{"../main":2,"./inline-source-map":41}],2:[function(_dereq_,module,exports){
342 -/**
343 - * Copyright 2013-2015, Facebook, Inc.
344 - * All rights reserved.
345 - *
346 - * This source code is licensed under the BSD-style license found in the
347 - * LICENSE file in the root directory of this source tree. An additional grant
348 - * of patent rights can be found in the PATENTS file in the same directory.
349 - */
350 -
351 -'use strict';
352 -/*eslint-disable no-undef*/
353 -var visitors = _dereq_('./vendor/fbtransform/visitors');
354 -var transform = _dereq_('jstransform').transform;
355 -var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
356 -var inlineSourceMap = _dereq_('./vendor/inline-source-map');
357 -
358 -module.exports = {
359 - transform: function(input, options) {
360 - options = processOptions(options);
361 - var output = innerTransform(input, options);
362 - var result = output.code;
363 - if (options.sourceMap) {
364 - var map = inlineSourceMap(
365 - output.sourceMap,
366 - input,
367 - options.filename
368 - );
369 - result += '\n' + map;
370 - }
371 - return result;
372 - },
373 - transformWithDetails: function(input, options) {
374 - options = processOptions(options);
375 - var output = innerTransform(input, options);
376 - var result = {};
377 - result.code = output.code;
378 - if (options.sourceMap) {
379 - result.sourceMap = output.sourceMap.toJSON();
380 - }
381 - if (options.filename) {
382 - result.sourceMap.sources = [options.filename];
383 - }
384 - return result;
385 - }
386 -};
387 -
388 -/**
389 - * Only copy the values that we need. We'll do some preprocessing to account for
390 - * converting command line flags to options that jstransform can actually use.
391 - */
392 -function processOptions(opts) {
393 - opts = opts || {};
394 - var options = {};
395 -
396 - options.harmony = opts.harmony;
397 - options.stripTypes = opts.stripTypes;
398 - options.sourceMap = opts.sourceMap;
399 - options.filename = opts.sourceFilename;
400 -
401 - if (opts.es6module) {
402 - options.sourceType = 'module';
403 - }
404 - if (opts.nonStrictEs6module) {
405 - options.sourceType = 'nonStrictModule';
406 - }
407 -
408 - // Instead of doing any fancy validation, only look for 'es3'. If we have
409 - // that, then use it. Otherwise use 'es5'.
410 - options.es3 = opts.target === 'es3';
411 - options.es5 = !options.es3;
412 -
413 - return options;
414 -}
415 -
416 -function innerTransform(input, options) {
417 - var visitorSets = ['react'];
418 - if (options.harmony) {
419 - visitorSets.push('harmony');
420 - }
421 -
422 - if (options.es3) {
423 - visitorSets.push('es3');
424 - }
425 -
426 - if (options.stripTypes) {
427 - // Stripping types needs to happen before the other transforms
428 - // unfortunately, due to bad interactions. For example,
429 - // es6-rest-param-visitors conflict with stripping rest param type
430 - // annotation
431 - input = transform(typesSyntax.visitorList, input, options).code;
432 - }
433 -
434 - var visitorList = visitors.getVisitorsBySet(visitorSets);
435 - return transform(visitorList, input, options);
436 -}
437 -
438 -},{"./vendor/fbtransform/visitors":40,"./vendor/inline-source-map":41,"jstransform":22,"jstransform/visitors/type-syntax":36}],3:[function(_dereq_,module,exports){
439 -/*!
440 - * The buffer module from node.js, for the browser.
441 - *
442 - * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
443 - * @license MIT
444 - */
445 -
446 -var base64 = _dereq_('base64-js')
447 -var ieee754 = _dereq_('ieee754')
448 -var isArray = _dereq_('is-array')
449 -
450 -exports.Buffer = Buffer
451 -exports.SlowBuffer = SlowBuffer
452 -exports.INSPECT_MAX_BYTES = 50
453 -Buffer.poolSize = 8192 // not used by this implementation
454 -
455 -var kMaxLength = 0x3fffffff
456 -var rootParent = {}
457 -
458 -/**
459 - * If `Buffer.TYPED_ARRAY_SUPPORT`:
460 - * === true Use Uint8Array implementation (fastest)
461 - * === false Use Object implementation (most compatible, even IE6)
462 - *
463 - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
464 - * Opera 11.6+, iOS 4.2+.
465 - *
466 - * Note:
467 - *
468 - * - Implementation must support adding new properties to `Uint8Array` instances.
469 - * Firefox 4-29 lacked support, fixed in Firefox 30+.
470 - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
471 - *
472 - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
473 - *
474 - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
475 - * incorrect length in some situations.
476 - *
477 - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will
478 - * get the Object implementation, which is slower but will work correctly.
479 - */
480 -Buffer.TYPED_ARRAY_SUPPORT = (function () {
481 - try {
482 - var buf = new ArrayBuffer(0)
483 - var arr = new Uint8Array(buf)
484 - arr.foo = function () { return 42 }
485 - return arr.foo() === 42 && // typed array instances can be augmented
486 - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
487 - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
488 - } catch (e) {
489 - return false
490 - }
491 -})()
492 -
493 -/**
494 - * Class: Buffer
495 - * =============
496 - *
497 - * The Buffer constructor returns instances of `Uint8Array` that are augmented
498 - * with function properties for all the node `Buffer` API functions. We use
499 - * `Uint8Array` so that square bracket notation works as expected -- it returns
500 - * a single octet.
501 - *
502 - * By augmenting the instances, we can avoid modifying the `Uint8Array`
503 - * prototype.
504 - */
505 -function Buffer (subject, encoding) {
506 - var self = this
507 - if (!(self instanceof Buffer)) return new Buffer(subject, encoding)
508 -
509 - var type = typeof subject
510 - var length
511 -
512 - if (type === 'number') {
513 - length = +subject
514 - } else if (type === 'string') {
515 - length = Buffer.byteLength(subject, encoding)
516 - } else if (type === 'object' && subject !== null) {
517 - // assume object is array-like
518 - if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data
519 - length = +subject.length
520 - } else {
521 - throw new TypeError('must start with number, buffer, array or string')
522 - }
523 -
524 - if (length > kMaxLength) {
525 - throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x' +
526 - kMaxLength.toString(16) + ' bytes')
527 - }
528 -
529 - if (length < 0) length = 0
530 - else length >>>= 0 // coerce to uint32
531 -
532 - if (Buffer.TYPED_ARRAY_SUPPORT) {
533 - // Preferred: Return an augmented `Uint8Array` instance for best performance
534 - self = Buffer._augment(new Uint8Array(length)) // eslint-disable-line consistent-this
535 - } else {
536 - // Fallback: Return THIS instance of Buffer (created by `new`)
537 - self.length = length
538 - self._isBuffer = true
539 - }
540 -
541 - var i
542 - if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
543 - // Speed optimization -- use set if we're copying from a typed array
544 - self._set(subject)
545 - } else if (isArrayish(subject)) {
546 - // Treat array-ish objects as a byte array
547 - if (Buffer.isBuffer(subject)) {
548 - for (i = 0; i < length; i++) {
549 - self[i] = subject.readUInt8(i)
550 - }
551 - } else {
552 - for (i = 0; i < length; i++) {
553 - self[i] = ((subject[i] % 256) + 256) % 256
554 - }
555 - }
556 - } else if (type === 'string') {
557 - self.write(subject, 0, encoding)
558 - } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT) {
559 - for (i = 0; i < length; i++) {
560 - self[i] = 0
561 - }
562 - }
563 -
564 - if (length > 0 && length <= Buffer.poolSize) self.parent = rootParent
565 -
566 - return self
567 -}
568 -
569 -function SlowBuffer (subject, encoding) {
570 - if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
571 -
572 - var buf = new Buffer(subject, encoding)
573 - delete buf.parent
574 - return buf
575 -}
576 -
577 -Buffer.isBuffer = function isBuffer (b) {
578 - return !!(b != null && b._isBuffer)
579 -}
580 -
581 -Buffer.compare = function compare (a, b) {
582 - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
583 - throw new TypeError('Arguments must be Buffers')
584 - }
585 -
586 - if (a === b) return 0
587 -
588 - var x = a.length
589 - var y = b.length
590 - for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
591 - if (i !== len) {
592 - x = a[i]
593 - y = b[i]
594 - }
595 - if (x < y) return -1
596 - if (y < x) return 1
597 - return 0
598 -}
599 -
600 -Buffer.isEncoding = function isEncoding (encoding) {
601 - switch (String(encoding).toLowerCase()) {
602 - case 'hex':
603 - case 'utf8':
604 - case 'utf-8':
605 - case 'ascii':
606 - case 'binary':
607 - case 'base64':
608 - case 'raw':
609 - case 'ucs2':
610 - case 'ucs-2':
611 - case 'utf16le':
612 - case 'utf-16le':
613 - return true
614 - default:
615 - return false
616 - }
617 -}
618 -
619 -Buffer.concat = function concat (list, totalLength) {
620 - if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
621 -
622 - if (list.length === 0) {
623 - return new Buffer(0)
624 - } else if (list.length === 1) {
625 - return list[0]
626 - }
627 -
628 - var i
629 - if (totalLength === undefined) {
630 - totalLength = 0
631 - for (i = 0; i < list.length; i++) {
632 - totalLength += list[i].length
633 - }
634 - }
635 -
636 - var buf = new Buffer(totalLength)
637 - var pos = 0
638 - for (i = 0; i < list.length; i++) {
639 - var item = list[i]
640 - item.copy(buf, pos)
641 - pos += item.length
642 - }
643 - return buf
644 -}
645 -
646 -Buffer.byteLength = function byteLength (str, encoding) {
647 - var ret
648 - str = str + ''
649 - switch (encoding || 'utf8') {
650 - case 'ascii':
651 - case 'binary':
652 - case 'raw':
653 - ret = str.length
654 - break
655 - case 'ucs2':
656 - case 'ucs-2':
657 - case 'utf16le':
658 - case 'utf-16le':
659 - ret = str.length * 2
660 - break
661 - case 'hex':
662 - ret = str.length >>> 1
663 - break
664 - case 'utf8':
665 - case 'utf-8':
666 - ret = utf8ToBytes(str).length
667 - break
668 - case 'base64':
669 - ret = base64ToBytes(str).length
670 - break
671 - default:
672 - ret = str.length
673 - }
674 - return ret
675 -}
676 -
677 -// pre-set for values that may exist in the future
678 -Buffer.prototype.length = undefined
679 -Buffer.prototype.parent = undefined
680 -
681 -// toString(encoding, start=0, end=buffer.length)
682 -Buffer.prototype.toString = function toString (encoding, start, end) {
683 - var loweredCase = false
684 -
685 - start = start >>> 0
686 - end = end === undefined || end === Infinity ? this.length : end >>> 0
687 -
688 - if (!encoding) encoding = 'utf8'
689 - if (start < 0) start = 0
690 - if (end > this.length) end = this.length
691 - if (end <= start) return ''
692 -
693 - while (true) {
694 - switch (encoding) {
695 - case 'hex':
696 - return hexSlice(this, start, end)
697 -
698 - case 'utf8':
699 - case 'utf-8':
700 - return utf8Slice(this, start, end)
701 -
702 - case 'ascii':
703 - return asciiSlice(this, start, end)
704 -
705 - case 'binary':
706 - return binarySlice(this, start, end)
707 -
708 - case 'base64':
709 - return base64Slice(this, start, end)
710 -
711 - case 'ucs2':
712 - case 'ucs-2':
713 - case 'utf16le':
714 - case 'utf-16le':
715 - return utf16leSlice(this, start, end)
716 -
717 - default:
718 - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
719 - encoding = (encoding + '').toLowerCase()
720 - loweredCase = true
721 - }
722 - }
723 -}
724 -
725 -Buffer.prototype.equals = function equals (b) {
726 - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
727 - if (this === b) return true
728 - return Buffer.compare(this, b) === 0
729 -}
730 -
731 -Buffer.prototype.inspect = function inspect () {
732 - var str = ''
733 - var max = exports.INSPECT_MAX_BYTES
734 - if (this.length > 0) {
735 - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
736 - if (this.length > max) str += ' ... '
737 - }
738 - return '<Buffer ' + str + '>'
739 -}
740 -
741 -Buffer.prototype.compare = function compare (b) {
742 - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
743 - if (this === b) return 0
744 - return Buffer.compare(this, b)
745 -}
746 -
747 -Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
748 - if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
749 - else if (byteOffset < -0x80000000) byteOffset = -0x80000000
750 - byteOffset >>= 0
751 -
752 - if (this.length === 0) return -1
753 - if (byteOffset >= this.length) return -1
754 -
755 - // Negative offsets start from the end of the buffer
756 - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
757 -
758 - if (typeof val === 'string') {
759 - if (val.length === 0) return -1 // special case: looking for empty string always fails
760 - return String.prototype.indexOf.call(this, val, byteOffset)
761 - }
762 - if (Buffer.isBuffer(val)) {
763 - return arrayIndexOf(this, val, byteOffset)
764 - }
765 - if (typeof val === 'number') {
766 - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
767 - return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
768 - }
769 - return arrayIndexOf(this, [ val ], byteOffset)
770 - }
771 -
772 - function arrayIndexOf (arr, val, byteOffset) {
773 - var foundIndex = -1
774 - for (var i = 0; byteOffset + i < arr.length; i++) {
775 - if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
776 - if (foundIndex === -1) foundIndex = i
777 - if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
778 - } else {
779 - foundIndex = -1
780 - }
781 - }
782 - return -1
783 - }
784 -
785 - throw new TypeError('val must be string, number or Buffer')
786 -}
787 -
788 -// `get` will be removed in Node 0.13+
789 -Buffer.prototype.get = function get (offset) {
790 - console.log('.get() is deprecated. Access using array indexes instead.')
791 - return this.readUInt8(offset)
792 -}
793 -
794 -// `set` will be removed in Node 0.13+
795 -Buffer.prototype.set = function set (v, offset) {
796 - console.log('.set() is deprecated. Access using array indexes instead.')
797 - return this.writeUInt8(v, offset)
798 -}
799 -
800 -function hexWrite (buf, string, offset, length) {
801 - offset = Number(offset) || 0
802 - var remaining = buf.length - offset
803 - if (!length) {
804 - length = remaining
805 - } else {
806 - length = Number(length)
807 - if (length > remaining) {
808 - length = remaining
809 - }
810 - }
811 -
812 - // must be an even number of digits
813 - var strLen = string.length
814 - if (strLen % 2 !== 0) throw new Error('Invalid hex string')
815 -
816 - if (length > strLen / 2) {
817 - length = strLen / 2
818 - }
819 - for (var i = 0; i < length; i++) {
820 - var parsed = parseInt(string.substr(i * 2, 2), 16)
821 - if (isNaN(parsed)) throw new Error('Invalid hex string')
822 - buf[offset + i] = parsed
823 - }
824 - return i
825 -}
826 -
827 -function utf8Write (buf, string, offset, length) {
828 - var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
829 - return charsWritten
830 -}
831 -
832 -function asciiWrite (buf, string, offset, length) {
833 - var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
834 - return charsWritten
835 -}
836 -
837 -function binaryWrite (buf, string, offset, length) {
838 - return asciiWrite(buf, string, offset, length)
839 -}
840 -
841 -function base64Write (buf, string, offset, length) {
842 - var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
843 - return charsWritten
844 -}
845 -
846 -function utf16leWrite (buf, string, offset, length) {
847 - var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
848 - return charsWritten
849 -}
850 -
851 -Buffer.prototype.write = function write (string, offset, length, encoding) {
852 - // Support both (string, offset, length, encoding)
853 - // and the legacy (string, encoding, offset, length)
854 - if (isFinite(offset)) {
855 - if (!isFinite(length)) {
856 - encoding = length
857 - length = undefined
858 - }
859 - } else { // legacy
860 - var swap = encoding
861 - encoding = offset
862 - offset = length
863 - length = swap
864 - }
865 -
866 - offset = Number(offset) || 0
867 -
868 - if (length < 0 || offset < 0 || offset > this.length) {
869 - throw new RangeError('attempt to write outside buffer bounds')
870 - }
871 -
872 - var remaining = this.length - offset
873 - if (!length) {
874 - length = remaining
875 - } else {
876 - length = Number(length)
877 - if (length > remaining) {
878 - length = remaining
879 - }
880 - }
881 - encoding = String(encoding || 'utf8').toLowerCase()
882 -
883 - var ret
884 - switch (encoding) {
885 - case 'hex':
886 - ret = hexWrite(this, string, offset, length)
887 - break
888 - case 'utf8':
889 - case 'utf-8':
890 - ret = utf8Write(this, string, offset, length)
891 - break
892 - case 'ascii':
893 - ret = asciiWrite(this, string, offset, length)
894 - break
895 - case 'binary':
896 - ret = binaryWrite(this, string, offset, length)
897 - break
898 - case 'base64':
899 - ret = base64Write(this, string, offset, length)
900 - break
901 - case 'ucs2':
902 - case 'ucs-2':
903 - case 'utf16le':
904 - case 'utf-16le':
905 - ret = utf16leWrite(this, string, offset, length)
906 - break
907 - default:
908 - throw new TypeError('Unknown encoding: ' + encoding)
909 - }
910 - return ret
911 -}
912 -
913 -Buffer.prototype.toJSON = function toJSON () {
914 - return {
915 - type: 'Buffer',
916 - data: Array.prototype.slice.call(this._arr || this, 0)
917 - }
918 -}
919 -
920 -function base64Slice (buf, start, end) {
921 - if (start === 0 && end === buf.length) {
922 - return base64.fromByteArray(buf)
923 - } else {
924 - return base64.fromByteArray(buf.slice(start, end))
925 - }
926 -}
927 -
928 -function utf8Slice (buf, start, end) {
929 - var res = ''
930 - var tmp = ''
931 - end = Math.min(buf.length, end)
932 -
933 - for (var i = start; i < end; i++) {
934 - if (buf[i] <= 0x7F) {
935 - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
936 - tmp = ''
937 - } else {
938 - tmp += '%' + buf[i].toString(16)
939 - }
940 - }
941 -
942 - return res + decodeUtf8Char(tmp)
943 -}
944 -
945 -function asciiSlice (buf, start, end) {
946 - var ret = ''
947 - end = Math.min(buf.length, end)
948 -
949 - for (var i = start; i < end; i++) {
950 - ret += String.fromCharCode(buf[i] & 0x7F)
951 - }
952 - return ret
953 -}
954 -
955 -function binarySlice (buf, start, end) {
956 - var ret = ''
957 - end = Math.min(buf.length, end)
958 -
959 - for (var i = start; i < end; i++) {
960 - ret += String.fromCharCode(buf[i])
961 - }
962 - return ret
963 -}
964 -
965 -function hexSlice (buf, start, end) {
966 - var len = buf.length
967 -
968 - if (!start || start < 0) start = 0
969 - if (!end || end < 0 || end > len) end = len
970 -
971 - var out = ''
972 - for (var i = start; i < end; i++) {
973 - out += toHex(buf[i])
974 - }
975 - return out
976 -}
977 -
978 -function utf16leSlice (buf, start, end) {
979 - var bytes = buf.slice(start, end)
980 - var res = ''
981 - for (var i = 0; i < bytes.length; i += 2) {
982 - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
983 - }
984 - return res
985 -}
986 -
987 -Buffer.prototype.slice = function slice (start, end) {
988 - var len = this.length
989 - start = ~~start
990 - end = end === undefined ? len : ~~end
991 -
992 - if (start < 0) {
993 - start += len
994 - if (start < 0) start = 0
995 - } else if (start > len) {
996 - start = len
997 - }
998 -
999 - if (end < 0) {
1000 - end += len
1001 - if (end < 0) end = 0
1002 - } else if (end > len) {
1003 - end = len
1004 - }
1005 -
1006 - if (end < start) end = start
1007 -
1008 - var newBuf
1009 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1010 - newBuf = Buffer._augment(this.subarray(start, end))
1011 - } else {
1012 - var sliceLen = end - start
1013 - newBuf = new Buffer(sliceLen, undefined)
1014 - for (var i = 0; i < sliceLen; i++) {
1015 - newBuf[i] = this[i + start]
1016 - }
1017 - }
1018 -
1019 - if (newBuf.length) newBuf.parent = this.parent || this
1020 -
1021 - return newBuf
1022 -}
1023 -
1024 -/*
1025 - * Need to make sure that buffer isn't trying to write out of bounds.
1026 - */
1027 -function checkOffset (offset, ext, length) {
1028 - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1029 - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1030 -}
1031 -
1032 -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1033 - offset = offset >>> 0
1034 - byteLength = byteLength >>> 0
1035 - if (!noAssert) checkOffset(offset, byteLength, this.length)
1036 -
1037 - var val = this[offset]
1038 - var mul = 1
1039 - var i = 0
1040 - while (++i < byteLength && (mul *= 0x100)) {
1041 - val += this[offset + i] * mul
1042 - }
1043 -
1044 - return val
1045 -}
1046 -
1047 -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1048 - offset = offset >>> 0
1049 - byteLength = byteLength >>> 0
1050 - if (!noAssert) {
1051 - checkOffset(offset, byteLength, this.length)
1052 - }
1053 -
1054 - var val = this[offset + --byteLength]
1055 - var mul = 1
1056 - while (byteLength > 0 && (mul *= 0x100)) {
1057 - val += this[offset + --byteLength] * mul
1058 - }
1059 -
1060 - return val
1061 -}
1062 -
1063 -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1064 - if (!noAssert) checkOffset(offset, 1, this.length)
1065 - return this[offset]
1066 -}
1067 -
1068 -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1069 - if (!noAssert) checkOffset(offset, 2, this.length)
1070 - return this[offset] | (this[offset + 1] << 8)
1071 -}
1072 -
1073 -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1074 - if (!noAssert) checkOffset(offset, 2, this.length)
1075 - return (this[offset] << 8) | this[offset + 1]
1076 -}
1077 -
1078 -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1079 - if (!noAssert) checkOffset(offset, 4, this.length)
1080 -
1081 - return ((this[offset]) |
1082 - (this[offset + 1] << 8) |
1083 - (this[offset + 2] << 16)) +
1084 - (this[offset + 3] * 0x1000000)
1085 -}
1086 -
1087 -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1088 - if (!noAssert) checkOffset(offset, 4, this.length)
1089 -
1090 - return (this[offset] * 0x1000000) +
1091 - ((this[offset + 1] << 16) |
1092 - (this[offset + 2] << 8) |
1093 - this[offset + 3])
1094 -}
1095 -
1096 -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1097 - offset = offset >>> 0
1098 - byteLength = byteLength >>> 0
1099 - if (!noAssert) checkOffset(offset, byteLength, this.length)
1100 -
1101 - var val = this[offset]
1102 - var mul = 1
1103 - var i = 0
1104 - while (++i < byteLength && (mul *= 0x100)) {
1105 - val += this[offset + i] * mul
1106 - }
1107 - mul *= 0x80
1108 -
1109 - if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1110 -
1111 - return val
1112 -}
1113 -
1114 -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1115 - offset = offset >>> 0
1116 - byteLength = byteLength >>> 0
1117 - if (!noAssert) checkOffset(offset, byteLength, this.length)
1118 -
1119 - var i = byteLength
1120 - var mul = 1
1121 - var val = this[offset + --i]
1122 - while (i > 0 && (mul *= 0x100)) {
1123 - val += this[offset + --i] * mul
1124 - }
1125 - mul *= 0x80
1126 -
1127 - if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1128 -
1129 - return val
1130 -}
1131 -
1132 -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1133 - if (!noAssert) checkOffset(offset, 1, this.length)
1134 - if (!(this[offset] & 0x80)) return (this[offset])
1135 - return ((0xff - this[offset] + 1) * -1)
1136 -}
1137 -
1138 -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1139 - if (!noAssert) checkOffset(offset, 2, this.length)
1140 - var val = this[offset] | (this[offset + 1] << 8)
1141 - return (val & 0x8000) ? val | 0xFFFF0000 : val
1142 -}
1143 -
1144 -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1145 - if (!noAssert) checkOffset(offset, 2, this.length)
1146 - var val = this[offset + 1] | (this[offset] << 8)
1147 - return (val & 0x8000) ? val | 0xFFFF0000 : val
1148 -}
1149 -
1150 -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1151 - if (!noAssert) checkOffset(offset, 4, this.length)
1152 -
1153 - return (this[offset]) |
1154 - (this[offset + 1] << 8) |
1155 - (this[offset + 2] << 16) |
1156 - (this[offset + 3] << 24)
1157 -}
1158 -
1159 -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1160 - if (!noAssert) checkOffset(offset, 4, this.length)
1161 -
1162 - return (this[offset] << 24) |
1163 - (this[offset + 1] << 16) |
1164 - (this[offset + 2] << 8) |
1165 - (this[offset + 3])
1166 -}
1167 -
1168 -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1169 - if (!noAssert) checkOffset(offset, 4, this.length)
1170 - return ieee754.read(this, offset, true, 23, 4)
1171 -}
1172 -
1173 -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1174 - if (!noAssert) checkOffset(offset, 4, this.length)
1175 - return ieee754.read(this, offset, false, 23, 4)
1176 -}
1177 -
1178 -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1179 - if (!noAssert) checkOffset(offset, 8, this.length)
1180 - return ieee754.read(this, offset, true, 52, 8)
1181 -}
1182 -
1183 -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1184 - if (!noAssert) checkOffset(offset, 8, this.length)
1185 - return ieee754.read(this, offset, false, 52, 8)
1186 -}
1187 -
1188 -function checkInt (buf, value, offset, ext, max, min) {
1189 - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
1190 - if (value > max || value < min) throw new RangeError('value is out of bounds')
1191 - if (offset + ext > buf.length) throw new RangeError('index out of range')
1192 -}
1193 -
1194 -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1195 - value = +value
1196 - offset = offset >>> 0
1197 - byteLength = byteLength >>> 0
1198 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1199 -
1200 - var mul = 1
1201 - var i = 0
1202 - this[offset] = value & 0xFF
1203 - while (++i < byteLength && (mul *= 0x100)) {
1204 - this[offset + i] = (value / mul) >>> 0 & 0xFF
1205 - }
1206 -
1207 - return offset + byteLength
1208 -}
1209 -
1210 -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1211 - value = +value
1212 - offset = offset >>> 0
1213 - byteLength = byteLength >>> 0
1214 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1215 -
1216 - var i = byteLength - 1
1217 - var mul = 1
1218 - this[offset + i] = value & 0xFF
1219 - while (--i >= 0 && (mul *= 0x100)) {
1220 - this[offset + i] = (value / mul) >>> 0 & 0xFF
1221 - }
1222 -
1223 - return offset + byteLength
1224 -}
1225 -
1226 -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1227 - value = +value
1228 - offset = offset >>> 0
1229 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1230 - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1231 - this[offset] = value
1232 - return offset + 1
1233 -}
1234 -
1235 -function objectWriteUInt16 (buf, value, offset, littleEndian) {
1236 - if (value < 0) value = 0xffff + value + 1
1237 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
1238 - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1239 - (littleEndian ? i : 1 - i) * 8
1240 - }
1241 -}
1242 -
1243 -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1244 - value = +value
1245 - offset = offset >>> 0
1246 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1247 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1248 - this[offset] = value
1249 - this[offset + 1] = (value >>> 8)
1250 - } else {
1251 - objectWriteUInt16(this, value, offset, true)
1252 - }
1253 - return offset + 2
1254 -}
1255 -
1256 -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1257 - value = +value
1258 - offset = offset >>> 0
1259 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1260 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1261 - this[offset] = (value >>> 8)
1262 - this[offset + 1] = value
1263 - } else {
1264 - objectWriteUInt16(this, value, offset, false)
1265 - }
1266 - return offset + 2
1267 -}
1268 -
1269 -function objectWriteUInt32 (buf, value, offset, littleEndian) {
1270 - if (value < 0) value = 0xffffffff + value + 1
1271 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
1272 - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1273 - }
1274 -}
1275 -
1276 -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1277 - value = +value
1278 - offset = offset >>> 0
1279 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1280 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1281 - this[offset + 3] = (value >>> 24)
1282 - this[offset + 2] = (value >>> 16)
1283 - this[offset + 1] = (value >>> 8)
1284 - this[offset] = value
1285 - } else {
1286 - objectWriteUInt32(this, value, offset, true)
1287 - }
1288 - return offset + 4
1289 -}
1290 -
1291 -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1292 - value = +value
1293 - offset = offset >>> 0
1294 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1295 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1296 - this[offset] = (value >>> 24)
1297 - this[offset + 1] = (value >>> 16)
1298 - this[offset + 2] = (value >>> 8)
1299 - this[offset + 3] = value
1300 - } else {
1301 - objectWriteUInt32(this, value, offset, false)
1302 - }
1303 - return offset + 4
1304 -}
1305 -
1306 -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1307 - value = +value
1308 - offset = offset >>> 0
1309 - if (!noAssert) {
1310 - checkInt(
1311 - this, value, offset, byteLength,
1312 - Math.pow(2, 8 * byteLength - 1) - 1,
1313 - -Math.pow(2, 8 * byteLength - 1)
1314 - )
1315 - }
1316 -
1317 - var i = 0
1318 - var mul = 1
1319 - var sub = value < 0 ? 1 : 0
1320 - this[offset] = value & 0xFF
1321 - while (++i < byteLength && (mul *= 0x100)) {
1322 - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1323 - }
1324 -
1325 - return offset + byteLength
1326 -}
1327 -
1328 -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1329 - value = +value
1330 - offset = offset >>> 0
1331 - if (!noAssert) {
1332 - checkInt(
1333 - this, value, offset, byteLength,
1334 - Math.pow(2, 8 * byteLength - 1) - 1,
1335 - -Math.pow(2, 8 * byteLength - 1)
1336 - )
1337 - }
1338 -
1339 - var i = byteLength - 1
1340 - var mul = 1
1341 - var sub = value < 0 ? 1 : 0
1342 - this[offset + i] = value & 0xFF
1343 - while (--i >= 0 && (mul *= 0x100)) {
1344 - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1345 - }
1346 -
1347 - return offset + byteLength
1348 -}
1349 -
1350 -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1351 - value = +value
1352 - offset = offset >>> 0
1353 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1354 - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1355 - if (value < 0) value = 0xff + value + 1
1356 - this[offset] = value
1357 - return offset + 1
1358 -}
1359 -
1360 -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1361 - value = +value
1362 - offset = offset >>> 0
1363 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1364 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1365 - this[offset] = value
1366 - this[offset + 1] = (value >>> 8)
1367 - } else {
1368 - objectWriteUInt16(this, value, offset, true)
1369 - }
1370 - return offset + 2
1371 -}
1372 -
1373 -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1374 - value = +value
1375 - offset = offset >>> 0
1376 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1377 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1378 - this[offset] = (value >>> 8)
1379 - this[offset + 1] = value
1380 - } else {
1381 - objectWriteUInt16(this, value, offset, false)
1382 - }
1383 - return offset + 2
1384 -}
1385 -
1386 -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1387 - value = +value
1388 - offset = offset >>> 0
1389 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1390 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1391 - this[offset] = value
1392 - this[offset + 1] = (value >>> 8)
1393 - this[offset + 2] = (value >>> 16)
1394 - this[offset + 3] = (value >>> 24)
1395 - } else {
1396 - objectWriteUInt32(this, value, offset, true)
1397 - }
1398 - return offset + 4
1399 -}
1400 -
1401 -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1402 - value = +value
1403 - offset = offset >>> 0
1404 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1405 - if (value < 0) value = 0xffffffff + value + 1
1406 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1407 - this[offset] = (value >>> 24)
1408 - this[offset + 1] = (value >>> 16)
1409 - this[offset + 2] = (value >>> 8)
1410 - this[offset + 3] = value
1411 - } else {
1412 - objectWriteUInt32(this, value, offset, false)
1413 - }
1414 - return offset + 4
1415 -}
1416 -
1417 -function checkIEEE754 (buf, value, offset, ext, max, min) {
1418 - if (value > max || value < min) throw new RangeError('value is out of bounds')
1419 - if (offset + ext > buf.length) throw new RangeError('index out of range')
1420 - if (offset < 0) throw new RangeError('index out of range')
1421 -}
1422 -
1423 -function writeFloat (buf, value, offset, littleEndian, noAssert) {
1424 - if (!noAssert) {
1425 - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1426 - }
1427 - ieee754.write(buf, value, offset, littleEndian, 23, 4)
1428 - return offset + 4
1429 -}
1430 -
1431 -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1432 - return writeFloat(this, value, offset, true, noAssert)
1433 -}
1434 -
1435 -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1436 - return writeFloat(this, value, offset, false, noAssert)
1437 -}
1438 -
1439 -function writeDouble (buf, value, offset, littleEndian, noAssert) {
1440 - if (!noAssert) {
1441 - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1442 - }
1443 - ieee754.write(buf, value, offset, littleEndian, 52, 8)
1444 - return offset + 8
1445 -}
1446 -
1447 -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1448 - return writeDouble(this, value, offset, true, noAssert)
1449 -}
1450 -
1451 -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1452 - return writeDouble(this, value, offset, false, noAssert)
1453 -}
1454 -
1455 -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1456 -Buffer.prototype.copy = function copy (target, target_start, start, end) {
1457 - if (!start) start = 0
1458 - if (!end && end !== 0) end = this.length
1459 - if (target_start >= target.length) target_start = target.length
1460 - if (!target_start) target_start = 0
1461 - if (end > 0 && end < start) end = start
1462 -
1463 - // Copy 0 bytes; we're done
1464 - if (end === start) return 0
1465 - if (target.length === 0 || this.length === 0) return 0
1466 -
1467 - // Fatal error conditions
1468 - if (target_start < 0) {
1469 - throw new RangeError('targetStart out of bounds')
1470 - }
1471 - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
1472 - if (end < 0) throw new RangeError('sourceEnd out of bounds')
1473 -
1474 - // Are we oob?
1475 - if (end > this.length) end = this.length
1476 - if (target.length - target_start < end - start) {
1477 - end = target.length - target_start + start
1478 - }
1479 -
1480 - var len = end - start
1481 -
1482 - if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
1483 - for (var i = 0; i < len; i++) {
1484 - target[i + target_start] = this[i + start]
1485 - }
1486 - } else {
1487 - target._set(this.subarray(start, start + len), target_start)
1488 - }
1489 -
1490 - return len
1491 -}
1492 -
1493 -// fill(value, start=0, end=buffer.length)
1494 -Buffer.prototype.fill = function fill (value, start, end) {
1495 - if (!value) value = 0
1496 - if (!start) start = 0
1497 - if (!end) end = this.length
1498 -
1499 - if (end < start) throw new RangeError('end < start')
1500 -
1501 - // Fill 0 bytes; we're done
1502 - if (end === start) return
1503 - if (this.length === 0) return
1504 -
1505 - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
1506 - if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
1507 -
1508 - var i
1509 - if (typeof value === 'number') {
1510 - for (i = start; i < end; i++) {
1511 - this[i] = value
1512 - }
1513 - } else {
1514 - var bytes = utf8ToBytes(value.toString())
1515 - var len = bytes.length
1516 - for (i = start; i < end; i++) {
1517 - this[i] = bytes[i % len]
1518 - }
1519 - }
1520 -
1521 - return this
1522 -}
1523 -
1524 -/**
1525 - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
1526 - * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
1527 - */
1528 -Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
1529 - if (typeof Uint8Array !== 'undefined') {
1530 - if (Buffer.TYPED_ARRAY_SUPPORT) {
1531 - return (new Buffer(this)).buffer
1532 - } else {
1533 - var buf = new Uint8Array(this.length)
1534 - for (var i = 0, len = buf.length; i < len; i += 1) {
1535 - buf[i] = this[i]
1536 - }
1537 - return buf.buffer
1538 - }
1539 - } else {
1540 - throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
1541 - }
1542 -}
1543 -
1544 -// HELPER FUNCTIONS
1545 -// ================
1546 -
1547 -var BP = Buffer.prototype
1548 -
1549 -/**
1550 - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
1551 - */
1552 -Buffer._augment = function _augment (arr) {
1553 - arr.constructor = Buffer
1554 - arr._isBuffer = true
1555 -
1556 - // save reference to original Uint8Array set method before overwriting
1557 - arr._set = arr.set
1558 -
1559 - // deprecated, will be removed in node 0.13+
1560 - arr.get = BP.get
1561 - arr.set = BP.set
1562 -
1563 - arr.write = BP.write
1564 - arr.toString = BP.toString
1565 - arr.toLocaleString = BP.toString
1566 - arr.toJSON = BP.toJSON
1567 - arr.equals = BP.equals
1568 - arr.compare = BP.compare
1569 - arr.indexOf = BP.indexOf
1570 - arr.copy = BP.copy
1571 - arr.slice = BP.slice
1572 - arr.readUIntLE = BP.readUIntLE
1573 - arr.readUIntBE = BP.readUIntBE
1574 - arr.readUInt8 = BP.readUInt8
1575 - arr.readUInt16LE = BP.readUInt16LE
1576 - arr.readUInt16BE = BP.readUInt16BE
1577 - arr.readUInt32LE = BP.readUInt32LE
1578 - arr.readUInt32BE = BP.readUInt32BE
1579 - arr.readIntLE = BP.readIntLE
1580 - arr.readIntBE = BP.readIntBE
1581 - arr.readInt8 = BP.readInt8
1582 - arr.readInt16LE = BP.readInt16LE
1583 - arr.readInt16BE = BP.readInt16BE
1584 - arr.readInt32LE = BP.readInt32LE
1585 - arr.readInt32BE = BP.readInt32BE
1586 - arr.readFloatLE = BP.readFloatLE
1587 - arr.readFloatBE = BP.readFloatBE
1588 - arr.readDoubleLE = BP.readDoubleLE
1589 - arr.readDoubleBE = BP.readDoubleBE
1590 - arr.writeUInt8 = BP.writeUInt8
1591 - arr.writeUIntLE = BP.writeUIntLE
1592 - arr.writeUIntBE = BP.writeUIntBE
1593 - arr.writeUInt16LE = BP.writeUInt16LE
1594 - arr.writeUInt16BE = BP.writeUInt16BE
1595 - arr.writeUInt32LE = BP.writeUInt32LE
1596 - arr.writeUInt32BE = BP.writeUInt32BE
1597 - arr.writeIntLE = BP.writeIntLE
1598 - arr.writeIntBE = BP.writeIntBE
1599 - arr.writeInt8 = BP.writeInt8
1600 - arr.writeInt16LE = BP.writeInt16LE
1601 - arr.writeInt16BE = BP.writeInt16BE
1602 - arr.writeInt32LE = BP.writeInt32LE
1603 - arr.writeInt32BE = BP.writeInt32BE
1604 - arr.writeFloatLE = BP.writeFloatLE
1605 - arr.writeFloatBE = BP.writeFloatBE
1606 - arr.writeDoubleLE = BP.writeDoubleLE
1607 - arr.writeDoubleBE = BP.writeDoubleBE
1608 - arr.fill = BP.fill
1609 - arr.inspect = BP.inspect
1610 - arr.toArrayBuffer = BP.toArrayBuffer
1611 -
1612 - return arr
1613 -}
1614 -
1615 -var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
1616 -
1617 -function base64clean (str) {
1618 - // Node strips out invalid characters like \n and \t from the string, base64-js does not
1619 - str = stringtrim(str).replace(INVALID_BASE64_RE, '')
1620 - // Node converts strings with length < 2 to ''
1621 - if (str.length < 2) return ''
1622 - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1623 - while (str.length % 4 !== 0) {
1624 - str = str + '='
1625 - }
1626 - return str
1627 -}
1628 -
1629 -function stringtrim (str) {
1630 - if (str.trim) return str.trim()
1631 - return str.replace(/^\s+|\s+$/g, '')
1632 -}
1633 -
1634 -function isArrayish (subject) {
1635 - return isArray(subject) || Buffer.isBuffer(subject) ||
1636 - subject && typeof subject === 'object' &&
1637 - typeof subject.length === 'number'
1638 -}
1639 -
1640 -function toHex (n) {
1641 - if (n < 16) return '0' + n.toString(16)
1642 - return n.toString(16)
1643 -}
1644 -
1645 -function utf8ToBytes (string, units) {
1646 - units = units || Infinity
1647 - var codePoint
1648 - var length = string.length
1649 - var leadSurrogate = null
1650 - var bytes = []
1651 - var i = 0
1652 -
1653 - for (; i < length; i++) {
1654 - codePoint = string.charCodeAt(i)
1655 -
1656 - // is surrogate component
1657 - if (codePoint > 0xD7FF && codePoint < 0xE000) {
1658 - // last char was a lead
1659 - if (leadSurrogate) {
1660 - // 2 leads in a row
1661 - if (codePoint < 0xDC00) {
1662 - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1663 - leadSurrogate = codePoint
1664 - continue
1665 - } else {
1666 - // valid surrogate pair
1667 - codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
1668 - leadSurrogate = null
1669 - }
1670 - } else {
1671 - // no lead yet
1672 -
1673 - if (codePoint > 0xDBFF) {
1674 - // unexpected trail
1675 - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1676 - continue
1677 - } else if (i + 1 === length) {
1678 - // unpaired lead
1679 - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1680 - continue
1681 - } else {
1682 - // valid lead
1683 - leadSurrogate = codePoint
1684 - continue
1685 - }
1686 - }
1687 - } else if (leadSurrogate) {
1688 - // valid bmp char, but last char was a lead
1689 - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1690 - leadSurrogate = null
1691 - }
1692 -
1693 - // encode utf8
1694 - if (codePoint < 0x80) {
1695 - if ((units -= 1) < 0) break
1696 - bytes.push(codePoint)
1697 - } else if (codePoint < 0x800) {
1698 - if ((units -= 2) < 0) break
1699 - bytes.push(
1700 - codePoint >> 0x6 | 0xC0,
1701 - codePoint & 0x3F | 0x80
1702 - )
1703 - } else if (codePoint < 0x10000) {
1704 - if ((units -= 3) < 0) break
1705 - bytes.push(
1706 - codePoint >> 0xC | 0xE0,
1707 - codePoint >> 0x6 & 0x3F | 0x80,
1708 - codePoint & 0x3F | 0x80
1709 - )
1710 - } else if (codePoint < 0x200000) {
1711 - if ((units -= 4) < 0) break
1712 - bytes.push(
1713 - codePoint >> 0x12 | 0xF0,
1714 - codePoint >> 0xC & 0x3F | 0x80,
1715 - codePoint >> 0x6 & 0x3F | 0x80,
1716 - codePoint & 0x3F | 0x80
1717 - )
1718 - } else {
1719 - throw new Error('Invalid code point')
1720 - }
1721 - }
1722 -
1723 - return bytes
1724 -}
1725 -
1726 -function asciiToBytes (str) {
1727 - var byteArray = []
1728 - for (var i = 0; i < str.length; i++) {
1729 - // Node's code seems to be doing this and not & 0x7F..
1730 - byteArray.push(str.charCodeAt(i) & 0xFF)
1731 - }
1732 - return byteArray
1733 -}
1734 -
1735 -function utf16leToBytes (str, units) {
1736 - var c, hi, lo
1737 - var byteArray = []
1738 - for (var i = 0; i < str.length; i++) {
1739 - if ((units -= 2) < 0) break
1740 -
1741 - c = str.charCodeAt(i)
1742 - hi = c >> 8
1743 - lo = c % 256
1744 - byteArray.push(lo)
1745 - byteArray.push(hi)
1746 - }
1747 -
1748 - return byteArray
1749 -}
1750 -
1751 -function base64ToBytes (str) {
1752 - return base64.toByteArray(base64clean(str))
1753 -}
1754 -
1755 -function blitBuffer (src, dst, offset, length) {
1756 - for (var i = 0; i < length; i++) {
1757 - if ((i + offset >= dst.length) || (i >= src.length)) break
1758 - dst[i + offset] = src[i]
1759 - }
1760 - return i
1761 -}
1762 -
1763 -function decodeUtf8Char (str) {
1764 - try {
1765 - return decodeURIComponent(str)
1766 - } catch (err) {
1767 - return String.fromCharCode(0xFFFD) // UTF 8 invalid char
1768 - }
1769 -}
1770 -
1771 -},{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(_dereq_,module,exports){
1772 -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1773 -
1774 -;(function (exports) {
1775 - 'use strict';
1776 -
1777 - var Arr = (typeof Uint8Array !== 'undefined')
1778 - ? Uint8Array
1779 - : Array
1780 -
1781 - var PLUS = '+'.charCodeAt(0)
1782 - var SLASH = '/'.charCodeAt(0)
1783 - var NUMBER = '0'.charCodeAt(0)
1784 - var LOWER = 'a'.charCodeAt(0)
1785 - var UPPER = 'A'.charCodeAt(0)
1786 - var PLUS_URL_SAFE = '-'.charCodeAt(0)
1787 - var SLASH_URL_SAFE = '_'.charCodeAt(0)
1788 -
1789 - function decode (elt) {
1790 - var code = elt.charCodeAt(0)
1791 - if (code === PLUS ||
1792 - code === PLUS_URL_SAFE)
1793 - return 62 // '+'
1794 - if (code === SLASH ||
1795 - code === SLASH_URL_SAFE)
1796 - return 63 // '/'
1797 - if (code < NUMBER)
1798 - return -1 //no match
1799 - if (code < NUMBER + 10)
1800 - return code - NUMBER + 26 + 26
1801 - if (code < UPPER + 26)
1802 - return code - UPPER
1803 - if (code < LOWER + 26)
1804 - return code - LOWER + 26
1805 - }
1806 -
1807 - function b64ToByteArray (b64) {
1808 - var i, j, l, tmp, placeHolders, arr
1809 -
1810 - if (b64.length % 4 > 0) {
1811 - throw new Error('Invalid string. Length must be a multiple of 4')
1812 - }
1813 -
1814 - // the number of equal signs (place holders)
1815 - // if there are two placeholders, than the two characters before it
1816 - // represent one byte
1817 - // if there is only one, then the three characters before it represent 2 bytes
1818 - // this is just a cheap hack to not do indexOf twice
1819 - var len = b64.length
1820 - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
1821 -
1822 - // base64 is 4/3 + up to two characters of the original data
1823 - arr = new Arr(b64.length * 3 / 4 - placeHolders)
1824 -
1825 - // if there are placeholders, only get up to the last complete 4 chars
1826 - l = placeHolders > 0 ? b64.length - 4 : b64.length
1827 -
1828 - var L = 0
1829 -
1830 - function push (v) {
1831 - arr[L++] = v
1832 - }
1833 -
1834 - for (i = 0, j = 0; i < l; i += 4, j += 3) {
1835 - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
1836 - push((tmp & 0xFF0000) >> 16)
1837 - push((tmp & 0xFF00) >> 8)
1838 - push(tmp & 0xFF)
1839 - }
1840 -
1841 - if (placeHolders === 2) {
1842 - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
1843 - push(tmp & 0xFF)
1844 - } else if (placeHolders === 1) {
1845 - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
1846 - push((tmp >> 8) & 0xFF)
1847 - push(tmp & 0xFF)
1848 - }
1849 -
1850 - return arr
1851 - }
1852 -
1853 - function uint8ToBase64 (uint8) {
1854 - var i,
1855 - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
1856 - output = "",
1857 - temp, length
1858 -
1859 - function encode (num) {
1860 - return lookup.charAt(num)
1861 - }
1862 -
1863 - function tripletToBase64 (num) {
1864 - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
1865 - }
1866 -
1867 - // go through the array every three bytes, we'll deal with trailing stuff later
1868 - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
1869 - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
1870 - output += tripletToBase64(temp)
1871 - }
1872 -
1873 - // pad the end with zeros, but make sure to not forget the extra bytes
1874 - switch (extraBytes) {
1875 - case 1:
1876 - temp = uint8[uint8.length - 1]
1877 - output += encode(temp >> 2)
1878 - output += encode((temp << 4) & 0x3F)
1879 - output += '=='
1880 - break
1881 - case 2:
1882 - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
1883 - output += encode(temp >> 10)
1884 - output += encode((temp >> 4) & 0x3F)
1885 - output += encode((temp << 2) & 0x3F)
1886 - output += '='
1887 - break
1888 - }
1889 -
1890 - return output
1891 - }
1892 -
1893 - exports.toByteArray = b64ToByteArray
1894 - exports.fromByteArray = uint8ToBase64
1895 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
1896 -
1897 -},{}],5:[function(_dereq_,module,exports){
1898 -exports.read = function(buffer, offset, isLE, mLen, nBytes) {
1899 - var e, m,
1900 - eLen = nBytes * 8 - mLen - 1,
1901 - eMax = (1 << eLen) - 1,
1902 - eBias = eMax >> 1,
1903 - nBits = -7,
1904 - i = isLE ? (nBytes - 1) : 0,
1905 - d = isLE ? -1 : 1,
1906 - s = buffer[offset + i];
1907 -
1908 - i += d;
1909 -
1910 - e = s & ((1 << (-nBits)) - 1);
1911 - s >>= (-nBits);
1912 - nBits += eLen;
1913 - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
1914 -
1915 - m = e & ((1 << (-nBits)) - 1);
1916 - e >>= (-nBits);
1917 - nBits += mLen;
1918 - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
1919 -
1920 - if (e === 0) {
1921 - e = 1 - eBias;
1922 - } else if (e === eMax) {
1923 - return m ? NaN : ((s ? -1 : 1) * Infinity);
1924 - } else {
1925 - m = m + Math.pow(2, mLen);
1926 - e = e - eBias;
1927 - }
1928 - return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
1929 -};
1930 -
1931 -exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
1932 - var e, m, c,
1933 - eLen = nBytes * 8 - mLen - 1,
1934 - eMax = (1 << eLen) - 1,
1935 - eBias = eMax >> 1,
1936 - rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
1937 - i = isLE ? 0 : (nBytes - 1),
1938 - d = isLE ? 1 : -1,
1939 - s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
1940 -
1941 - value = Math.abs(value);
1942 -
1943 - if (isNaN(value) || value === Infinity) {
1944 - m = isNaN(value) ? 1 : 0;
1945 - e = eMax;
1946 - } else {
1947 - e = Math.floor(Math.log(value) / Math.LN2);
1948 - if (value * (c = Math.pow(2, -e)) < 1) {
1949 - e--;
1950 - c *= 2;
1951 - }
1952 - if (e + eBias >= 1) {
1953 - value += rt / c;
1954 - } else {
1955 - value += rt * Math.pow(2, 1 - eBias);
1956 - }
1957 - if (value * c >= 2) {
1958 - e++;
1959 - c /= 2;
1960 - }
1961 -
1962 - if (e + eBias >= eMax) {
1963 - m = 0;
1964 - e = eMax;
1965 - } else if (e + eBias >= 1) {
1966 - m = (value * c - 1) * Math.pow(2, mLen);
1967 - e = e + eBias;
1968 - } else {
1969 - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
1970 - e = 0;
1971 - }
1972 - }
1973 -
1974 - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
1975 -
1976 - e = (e << mLen) | m;
1977 - eLen += mLen;
1978 - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
1979 -
1980 - buffer[offset + i - d] |= s * 128;
1981 -};
1982 -
1983 -},{}],6:[function(_dereq_,module,exports){
1984 -
1985 -/**
1986 - * isArray
1987 - */
1988 -
1989 -var isArray = Array.isArray;
1990 -
1991 -/**
1992 - * toString
1993 - */
1994 -
1995 -var str = Object.prototype.toString;
1996 -
1997 -/**
1998 - * Whether or not the given `val`
1999 - * is an array.
2000 - *
2001 - * example:
2002 - *
2003 - * isArray([]);
2004 - * // > true
2005 - * isArray(arguments);
2006 - * // > false
2007 - * isArray('');
2008 - * // > false
2009 - *
2010 - * @param {mixed} val
2011 - * @return {bool}
2012 - */
2013 -
2014 -module.exports = isArray || function (val) {
2015 - return !! val && '[object Array]' == str.call(val);
2016 -};
2017 -
2018 -},{}],7:[function(_dereq_,module,exports){
2019 -(function (process){
2020 -// Copyright Joyent, Inc. and other Node contributors.
2021 -//
2022 -// Permission is hereby granted, free of charge, to any person obtaining a
2023 -// copy of this software and associated documentation files (the
2024 -// "Software"), to deal in the Software without restriction, including
2025 -// without limitation the rights to use, copy, modify, merge, publish,
2026 -// distribute, sublicense, and/or sell copies of the Software, and to permit
2027 -// persons to whom the Software is furnished to do so, subject to the
2028 -// following conditions:
2029 -//
2030 -// The above copyright notice and this permission notice shall be included
2031 -// in all copies or substantial portions of the Software.
2032 -//
2033 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2034 -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2035 -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2036 -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2037 -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2038 -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2039 -// USE OR OTHER DEALINGS IN THE SOFTWARE.
2040 -
2041 -// resolves . and .. elements in a path array with directory names there
2042 -// must be no slashes, empty elements, or device names (c:\) in the array
2043 -// (so also no leading and trailing slashes - it does not distinguish
2044 -// relative and absolute paths)
2045 -function normalizeArray(parts, allowAboveRoot) {
2046 - // if the path tries to go above the root, `up` ends up > 0
2047 - var up = 0;
2048 - for (var i = parts.length - 1; i >= 0; i--) {
2049 - var last = parts[i];
2050 - if (last === '.') {
2051 - parts.splice(i, 1);
2052 - } else if (last === '..') {
2053 - parts.splice(i, 1);
2054 - up++;
2055 - } else if (up) {
2056 - parts.splice(i, 1);
2057 - up--;
2058 - }
2059 - }
2060 -
2061 - // if the path is allowed to go above the root, restore leading ..s
2062 - if (allowAboveRoot) {
2063 - for (; up--; up) {
2064 - parts.unshift('..');
2065 - }
2066 - }
2067 -
2068 - return parts;
2069 -}
2070 -
2071 -// Split a filename into [root, dir, basename, ext], unix version
2072 -// 'root' is just a slash, or nothing.
2073 -var splitPathRe =
2074 - /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
2075 -var splitPath = function(filename) {
2076 - return splitPathRe.exec(filename).slice(1);
2077 -};
2078 -
2079 -// path.resolve([from ...], to)
2080 -// posix version
2081 -exports.resolve = function() {
2082 - var resolvedPath = '',
2083 - resolvedAbsolute = false;
2084 -
2085 - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
2086 - var path = (i >= 0) ? arguments[i] : process.cwd();
2087 -
2088 - // Skip empty and invalid entries
2089 - if (typeof path !== 'string') {
2090 - throw new TypeError('Arguments to path.resolve must be strings');
2091 - } else if (!path) {
2092 - continue;
2093 - }
2094 -
2095 - resolvedPath = path + '/' + resolvedPath;
2096 - resolvedAbsolute = path.charAt(0) === '/';
2097 - }
2098 -
2099 - // At this point the path should be resolved to a full absolute path, but
2100 - // handle relative paths to be safe (might happen when process.cwd() fails)
2101 -
2102 - // Normalize the path
2103 - resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
2104 - return !!p;
2105 - }), !resolvedAbsolute).join('/');
2106 -
2107 - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
2108 -};
2109 -
2110 -// path.normalize(path)
2111 -// posix version
2112 -exports.normalize = function(path) {
2113 - var isAbsolute = exports.isAbsolute(path),
2114 - trailingSlash = substr(path, -1) === '/';
2115 -
2116 - // Normalize the path
2117 - path = normalizeArray(filter(path.split('/'), function(p) {
2118 - return !!p;
2119 - }), !isAbsolute).join('/');
2120 -
2121 - if (!path && !isAbsolute) {
2122 - path = '.';
2123 - }
2124 - if (path && trailingSlash) {
2125 - path += '/';
2126 - }
2127 -
2128 - return (isAbsolute ? '/' : '') + path;
2129 -};
2130 -
2131 -// posix version
2132 -exports.isAbsolute = function(path) {
2133 - return path.charAt(0) === '/';
2134 -};
2135 -
2136 -// posix version
2137 -exports.join = function() {
2138 - var paths = Array.prototype.slice.call(arguments, 0);
2139 - return exports.normalize(filter(paths, function(p, index) {
2140 - if (typeof p !== 'string') {
2141 - throw new TypeError('Arguments to path.join must be strings');
2142 - }
2143 - return p;
2144 - }).join('/'));
2145 -};
2146 -
2147 -
2148 -// path.relative(from, to)
2149 -// posix version
2150 -exports.relative = function(from, to) {
2151 - from = exports.resolve(from).substr(1);
2152 - to = exports.resolve(to).substr(1);
2153 -
2154 - function trim(arr) {
2155 - var start = 0;
2156 - for (; start < arr.length; start++) {
2157 - if (arr[start] !== '') break;
2158 - }
2159 -
2160 - var end = arr.length - 1;
2161 - for (; end >= 0; end--) {
2162 - if (arr[end] !== '') break;
2163 - }
2164 -
2165 - if (start > end) return [];
2166 - return arr.slice(start, end - start + 1);
2167 - }
2168 -
2169 - var fromParts = trim(from.split('/'));
2170 - var toParts = trim(to.split('/'));
2171 -
2172 - var length = Math.min(fromParts.length, toParts.length);
2173 - var samePartsLength = length;
2174 - for (var i = 0; i < length; i++) {
2175 - if (fromParts[i] !== toParts[i]) {
2176 - samePartsLength = i;
2177 - break;
2178 - }
2179 - }
2180 -
2181 - var outputParts = [];
2182 - for (var i = samePartsLength; i < fromParts.length; i++) {
2183 - outputParts.push('..');
2184 - }
2185 -
2186 - outputParts = outputParts.concat(toParts.slice(samePartsLength));
2187 -
2188 - return outputParts.join('/');
2189 -};
2190 -
2191 -exports.sep = '/';
2192 -exports.delimiter = ':';
2193 -
2194 -exports.dirname = function(path) {
2195 - var result = splitPath(path),
2196 - root = result[0],
2197 - dir = result[1];
2198 -
2199 - if (!root && !dir) {
2200 - // No dirname whatsoever
2201 - return '.';
2202 - }
2203 -
2204 - if (dir) {
2205 - // It has a dirname, strip trailing slash
2206 - dir = dir.substr(0, dir.length - 1);
2207 - }
2208 -
2209 - return root + dir;
2210 -};
2211 -
2212 -
2213 -exports.basename = function(path, ext) {
2214 - var f = splitPath(path)[2];
2215 - // TODO: make this comparison case-insensitive on windows?
2216 - if (ext && f.substr(-1 * ext.length) === ext) {
2217 - f = f.substr(0, f.length - ext.length);
2218 - }
2219 - return f;
2220 -};
2221 -
2222 -
2223 -exports.extname = function(path) {
2224 - return splitPath(path)[3];
2225 -};
2226 -
2227 -function filter (xs, f) {
2228 - if (xs.filter) return xs.filter(f);
2229 - var res = [];
2230 - for (var i = 0; i < xs.length; i++) {
2231 - if (f(xs[i], i, xs)) res.push(xs[i]);
2232 - }
2233 - return res;
2234 -}
2235 -
2236 -// String.prototype.substr - negative index don't work in IE8
2237 -var substr = 'ab'.substr(-1) === 'b'
2238 - ? function (str, start, len) { return str.substr(start, len) }
2239 - : function (str, start, len) {
2240 - if (start < 0) start = str.length + start;
2241 - return str.substr(start, len);
2242 - }
2243 -;
2244 -
2245 -}).call(this,_dereq_('_process'))
2246 -},{"_process":8}],8:[function(_dereq_,module,exports){
2247 -// shim for using process in browser
2248 -
2249 -var process = module.exports = {};
2250 -var queue = [];
2251 -var draining = false;
2252 -
2253 -function drainQueue() {
2254 - if (draining) {
2255 - return;
2256 - }
2257 - draining = true;
2258 - var currentQueue;
2259 - var len = queue.length;
2260 - while(len) {
2261 - currentQueue = queue;
2262 - queue = [];
2263 - var i = -1;
2264 - while (++i < len) {
2265 - currentQueue[i]();
2266 - }
2267 - len = queue.length;
2268 - }
2269 - draining = false;
2270 -}
2271 -process.nextTick = function (fun) {
2272 - queue.push(fun);
2273 - if (!draining) {
2274 - setTimeout(drainQueue, 0);
2275 - }
2276 -};
2277 -
2278 -process.title = 'browser';
2279 -process.browser = true;
2280 -process.env = {};
2281 -process.argv = [];
2282 -process.version = ''; // empty string to avoid regexp issues
2283 -process.versions = {};
2284 -
2285 -function noop() {}
2286 -
2287 -process.on = noop;
2288 -process.addListener = noop;
2289 -process.once = noop;
2290 -process.off = noop;
2291 -process.removeListener = noop;
2292 -process.removeAllListeners = noop;
2293 -process.emit = noop;
2294 -
2295 -process.binding = function (name) {
2296 - throw new Error('process.binding is not supported');
2297 -};
2298 -
2299 -// TODO(shtylman)
2300 -process.cwd = function () { return '/' };
2301 -process.chdir = function (dir) {
2302 - throw new Error('process.chdir is not supported');
2303 -};
2304 -process.umask = function() { return 0; };
2305 -
2306 -},{}],9:[function(_dereq_,module,exports){
2307 -/*
2308 - Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
2309 - Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
2310 - Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
2311 - Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
2312 - Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
2313 - Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
2314 - Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
2315 - Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
2316 - Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
2317 -
2318 - Redistribution and use in source and binary forms, with or without
2319 - modification, are permitted provided that the following conditions are met:
2320 -
2321 - * Redistributions of source code must retain the above copyright
2322 - notice, this list of conditions and the following disclaimer.
2323 - * Redistributions in binary form must reproduce the above copyright
2324 - notice, this list of conditions and the following disclaimer in the
2325 - documentation and/or other materials provided with the distribution.
2326 -
2327 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2328 - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2329 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2330 - ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
2331 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2332 - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2333 - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2334 - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2335 - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2336 - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2337 -*/
2338 -
2339 -(function (root, factory) {
2340 - 'use strict';
2341 -
2342 - // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
2343 - // Rhino, and plain browser loading.
2344 -
2345 - /* istanbul ignore next */
2346 - if (typeof define === 'function' && define.amd) {
2347 - define(['exports'], factory);
2348 - } else if (typeof exports !== 'undefined') {
2349 - factory(exports);
2350 - } else {
2351 - factory((root.esprima = {}));
2352 - }
2353 -}(this, function (exports) {
2354 - 'use strict';
2355 -
2356 - var Token,
2357 - TokenName,
2358 - FnExprTokens,
2359 - Syntax,
2360 - PropertyKind,
2361 - Messages,
2362 - Regex,
2363 - SyntaxTreeDelegate,
2364 - XHTMLEntities,
2365 - ClassPropertyType,
2366 - source,
2367 - strict,
2368 - index,
2369 - lineNumber,
2370 - lineStart,
2371 - length,
2372 - delegate,
2373 - lookahead,
2374 - state,
2375 - extra;
2376 -
2377 - Token = {
2378 - BooleanLiteral: 1,
2379 - EOF: 2,
2380 - Identifier: 3,
2381 - Keyword: 4,
2382 - NullLiteral: 5,
2383 - NumericLiteral: 6,
2384 - Punctuator: 7,
2385 - StringLiteral: 8,
2386 - RegularExpression: 9,
2387 - Template: 10,
2388 - JSXIdentifier: 11,
2389 - JSXText: 12
2390 - };
2391 -
2392 - TokenName = {};
2393 - TokenName[Token.BooleanLiteral] = 'Boolean';
2394 - TokenName[Token.EOF] = '<end>';
2395 - TokenName[Token.Identifier] = 'Identifier';
2396 - TokenName[Token.Keyword] = 'Keyword';
2397 - TokenName[Token.NullLiteral] = 'Null';
2398 - TokenName[Token.NumericLiteral] = 'Numeric';
2399 - TokenName[Token.Punctuator] = 'Punctuator';
2400 - TokenName[Token.StringLiteral] = 'String';
2401 - TokenName[Token.JSXIdentifier] = 'JSXIdentifier';
2402 - TokenName[Token.JSXText] = 'JSXText';
2403 - TokenName[Token.RegularExpression] = 'RegularExpression';
2404 -
2405 - // A function following one of those tokens is an expression.
2406 - FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
2407 - 'return', 'case', 'delete', 'throw', 'void',
2408 - // assignment operators
2409 - '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=',
2410 - '&=', '|=', '^=', ',',
2411 - // binary/unary operators
2412 - '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
2413 - '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
2414 - '<=', '<', '>', '!=', '!=='];
2415 -
2416 - Syntax = {
2417 - AnyTypeAnnotation: 'AnyTypeAnnotation',
2418 - ArrayExpression: 'ArrayExpression',
2419 - ArrayPattern: 'ArrayPattern',
2420 - ArrayTypeAnnotation: 'ArrayTypeAnnotation',
2421 - ArrowFunctionExpression: 'ArrowFunctionExpression',
2422 - AssignmentExpression: 'AssignmentExpression',
2423 - BinaryExpression: 'BinaryExpression',
2424 - BlockStatement: 'BlockStatement',
2425 - BooleanTypeAnnotation: 'BooleanTypeAnnotation',
2426 - BreakStatement: 'BreakStatement',
2427 - CallExpression: 'CallExpression',
2428 - CatchClause: 'CatchClause',
2429 - ClassBody: 'ClassBody',
2430 - ClassDeclaration: 'ClassDeclaration',
2431 - ClassExpression: 'ClassExpression',
2432 - ClassImplements: 'ClassImplements',
2433 - ClassProperty: 'ClassProperty',
2434 - ComprehensionBlock: 'ComprehensionBlock',
2435 - ComprehensionExpression: 'ComprehensionExpression',
2436 - ConditionalExpression: 'ConditionalExpression',
2437 - ContinueStatement: 'ContinueStatement',
2438 - DebuggerStatement: 'DebuggerStatement',
2439 - DeclareClass: 'DeclareClass',
2440 - DeclareFunction: 'DeclareFunction',
2441 - DeclareModule: 'DeclareModule',
2442 - DeclareVariable: 'DeclareVariable',
2443 - DoWhileStatement: 'DoWhileStatement',
2444 - EmptyStatement: 'EmptyStatement',
2445 - ExportDeclaration: 'ExportDeclaration',
2446 - ExportBatchSpecifier: 'ExportBatchSpecifier',
2447 - ExportSpecifier: 'ExportSpecifier',
2448 - ExpressionStatement: 'ExpressionStatement',
2449 - ForInStatement: 'ForInStatement',
2450 - ForOfStatement: 'ForOfStatement',
2451 - ForStatement: 'ForStatement',
2452 - FunctionDeclaration: 'FunctionDeclaration',
2453 - FunctionExpression: 'FunctionExpression',
2454 - FunctionTypeAnnotation: 'FunctionTypeAnnotation',
2455 - FunctionTypeParam: 'FunctionTypeParam',
2456 - GenericTypeAnnotation: 'GenericTypeAnnotation',
2457 - Identifier: 'Identifier',
2458 - IfStatement: 'IfStatement',
2459 - ImportDeclaration: 'ImportDeclaration',
2460 - ImportDefaultSpecifier: 'ImportDefaultSpecifier',
2461 - ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
2462 - ImportSpecifier: 'ImportSpecifier',
2463 - InterfaceDeclaration: 'InterfaceDeclaration',
2464 - InterfaceExtends: 'InterfaceExtends',
2465 - IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
2466 - LabeledStatement: 'LabeledStatement',
2467 - Literal: 'Literal',
2468 - LogicalExpression: 'LogicalExpression',
2469 - MemberExpression: 'MemberExpression',
2470 - MethodDefinition: 'MethodDefinition',
2471 - ModuleSpecifier: 'ModuleSpecifier',
2472 - NewExpression: 'NewExpression',
2473 - NullableTypeAnnotation: 'NullableTypeAnnotation',
2474 - NumberTypeAnnotation: 'NumberTypeAnnotation',
2475 - ObjectExpression: 'ObjectExpression',
2476 - ObjectPattern: 'ObjectPattern',
2477 - ObjectTypeAnnotation: 'ObjectTypeAnnotation',
2478 - ObjectTypeCallProperty: 'ObjectTypeCallProperty',
2479 - ObjectTypeIndexer: 'ObjectTypeIndexer',
2480 - ObjectTypeProperty: 'ObjectTypeProperty',
2481 - Program: 'Program',
2482 - Property: 'Property',
2483 - QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
2484 - ReturnStatement: 'ReturnStatement',
2485 - SequenceExpression: 'SequenceExpression',
2486 - SpreadElement: 'SpreadElement',
2487 - SpreadProperty: 'SpreadProperty',
2488 - StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
2489 - StringTypeAnnotation: 'StringTypeAnnotation',
2490 - SwitchCase: 'SwitchCase',
2491 - SwitchStatement: 'SwitchStatement',
2492 - TaggedTemplateExpression: 'TaggedTemplateExpression',
2493 - TemplateElement: 'TemplateElement',
2494 - TemplateLiteral: 'TemplateLiteral',
2495 - ThisExpression: 'ThisExpression',
2496 - ThrowStatement: 'ThrowStatement',
2497 - TupleTypeAnnotation: 'TupleTypeAnnotation',
2498 - TryStatement: 'TryStatement',
2499 - TypeAlias: 'TypeAlias',
2500 - TypeAnnotation: 'TypeAnnotation',
2501 - TypeCastExpression: 'TypeCastExpression',
2502 - TypeofTypeAnnotation: 'TypeofTypeAnnotation',
2503 - TypeParameterDeclaration: 'TypeParameterDeclaration',
2504 - TypeParameterInstantiation: 'TypeParameterInstantiation',
2505 - UnaryExpression: 'UnaryExpression',
2506 - UnionTypeAnnotation: 'UnionTypeAnnotation',
2507 - UpdateExpression: 'UpdateExpression',
2508 - VariableDeclaration: 'VariableDeclaration',
2509 - VariableDeclarator: 'VariableDeclarator',
2510 - VoidTypeAnnotation: 'VoidTypeAnnotation',
2511 - WhileStatement: 'WhileStatement',
2512 - WithStatement: 'WithStatement',
2513 - JSXIdentifier: 'JSXIdentifier',
2514 - JSXNamespacedName: 'JSXNamespacedName',
2515 - JSXMemberExpression: 'JSXMemberExpression',
2516 - JSXEmptyExpression: 'JSXEmptyExpression',
2517 - JSXExpressionContainer: 'JSXExpressionContainer',
2518 - JSXElement: 'JSXElement',
2519 - JSXClosingElement: 'JSXClosingElement',
2520 - JSXOpeningElement: 'JSXOpeningElement',
2521 - JSXAttribute: 'JSXAttribute',
2522 - JSXSpreadAttribute: 'JSXSpreadAttribute',
2523 - JSXText: 'JSXText',
2524 - YieldExpression: 'YieldExpression',
2525 - AwaitExpression: 'AwaitExpression'
2526 - };
2527 -
2528 - PropertyKind = {
2529 - Data: 1,
2530 - Get: 2,
2531 - Set: 4
2532 - };
2533 -
2534 - ClassPropertyType = {
2535 - 'static': 'static',
2536 - prototype: 'prototype'
2537 - };
2538 -
2539 - // Error messages should be identical to V8.
2540 - Messages = {
2541 - UnexpectedToken: 'Unexpected token %0',
2542 - UnexpectedNumber: 'Unexpected number',
2543 - UnexpectedString: 'Unexpected string',
2544 - UnexpectedIdentifier: 'Unexpected identifier',
2545 - UnexpectedReserved: 'Unexpected reserved word',
2546 - UnexpectedTemplate: 'Unexpected quasi %0',
2547 - UnexpectedEOS: 'Unexpected end of input',
2548 - NewlineAfterThrow: 'Illegal newline after throw',
2549 - InvalidRegExp: 'Invalid regular expression',
2550 - UnterminatedRegExp: 'Invalid regular expression: missing /',
2551 - InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
2552 - InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
2553 - InvalidLHSInForIn: 'Invalid left-hand side in for-in',
2554 - MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
2555 - NoCatchOrFinally: 'Missing catch or finally after try',
2556 - UnknownLabel: 'Undefined label \'%0\'',
2557 - Redeclaration: '%0 \'%1\' has already been declared',
2558 - IllegalContinue: 'Illegal continue statement',
2559 - IllegalBreak: 'Illegal break statement',
2560 - IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
2561 - IllegalClassConstructorProperty: 'Illegal constructor property in class definition',
2562 - IllegalReturn: 'Illegal return statement',
2563 - IllegalSpread: 'Illegal spread element',
2564 - StrictModeWith: 'Strict mode code may not include a with statement',
2565 - StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
2566 - StrictVarName: 'Variable name may not be eval or arguments in strict mode',
2567 - StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
2568 - StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
2569 - ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
2570 - DefaultRestParameter: 'Rest parameter can not have a default value',
2571 - ElementAfterSpreadElement: 'Spread must be the final element of an element list',
2572 - PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
2573 - ObjectPatternAsRestParameter: 'Invalid rest parameter',
2574 - ObjectPatternAsSpread: 'Invalid spread argument',
2575 - StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
2576 - StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
2577 - StrictDelete: 'Delete of an unqualified identifier in strict mode.',
2578 - StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
2579 - AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
2580 - AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
2581 - StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
2582 - StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
2583 - StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
2584 - StrictReservedWord: 'Use of future reserved word in strict mode',
2585 - MissingFromClause: 'Missing from clause',
2586 - NoAsAfterImportNamespace: 'Missing as after import *',
2587 - InvalidModuleSpecifier: 'Invalid module specifier',
2588 - IllegalImportDeclaration: 'Illegal import declaration',
2589 - IllegalExportDeclaration: 'Illegal export declaration',
2590 - NoUninitializedConst: 'Const must be initialized',
2591 - ComprehensionRequiresBlock: 'Comprehension must have at least one block',
2592 - ComprehensionError: 'Comprehension Error',
2593 - EachNotAllowed: 'Each is not supported',
2594 - InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text',
2595 - ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0',
2596 - AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag',
2597 - ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
2598 - 'you are trying to write a function type, but you ended up ' +
2599 - 'writing a grouped type followed by an =>, which is a syntax ' +
2600 - 'error. Remember, function type parameters are named so function ' +
2601 - 'types look like (name1: type1, name2: type2) => returnType. You ' +
2602 - 'probably wrote (type1) => returnType'
2603 - };
2604 -
2605 - // See also tools/generate-unicode-regex.py.
2606 - Regex = {
2607 - NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
2608 - NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
2609 - LeadingZeros: new RegExp('^0+(?!$)')
2610 - };
2611 -
2612 - // Ensure the condition is true, otherwise throw an error.
2613 - // This is only to have a better contract semantic, i.e. another safety net
2614 - // to catch a logic error. The condition shall be fulfilled in normal case.
2615 - // Do NOT use this to enforce a certain condition on any user input.
2616 -
2617 - function assert(condition, message) {
2618 - /* istanbul ignore if */
2619 - if (!condition) {
2620 - throw new Error('ASSERT: ' + message);
2621 - }
2622 - }
2623 -
2624 - function StringMap() {
2625 - this.$data = {};
2626 - }
2627 -
2628 - StringMap.prototype.get = function (key) {
2629 - key = '$' + key;
2630 - return this.$data[key];
2631 - };
2632 -
2633 - StringMap.prototype.set = function (key, value) {
2634 - key = '$' + key;
2635 - this.$data[key] = value;
2636 - return this;
2637 - };
2638 -
2639 - StringMap.prototype.has = function (key) {
2640 - key = '$' + key;
2641 - return Object.prototype.hasOwnProperty.call(this.$data, key);
2642 - };
2643 -
2644 - StringMap.prototype["delete"] = function (key) {
2645 - key = '$' + key;
2646 - return delete this.$data[key];
2647 - };
2648 -
2649 - function isDecimalDigit(ch) {
2650 - return (ch >= 48 && ch <= 57); // 0..9
2651 - }
2652 -
2653 - function isHexDigit(ch) {
2654 - return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
2655 - }
2656 -
2657 - function isOctalDigit(ch) {
2658 - return '01234567'.indexOf(ch) >= 0;
2659 - }
2660 -
2661 -
2662 - // 7.2 White Space
2663 -
2664 - function isWhiteSpace(ch) {
2665 - return (ch === 32) || // space
2666 - (ch === 9) || // tab
2667 - (ch === 0xB) ||
2668 - (ch === 0xC) ||
2669 - (ch === 0xA0) ||
2670 - (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
2671 - }
2672 -
2673 - // 7.3 Line Terminators
2674 -
2675 - function isLineTerminator(ch) {
2676 - return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
2677 - }
2678 -
2679 - // 7.6 Identifier Names and Identifiers
2680 -
2681 - function isIdentifierStart(ch) {
2682 - return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
2683 - (ch >= 65 && ch <= 90) || // A..Z
2684 - (ch >= 97 && ch <= 122) || // a..z
2685 - (ch === 92) || // \ (backslash)
2686 - ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch)));
2687 - }
2688 -
2689 - function isIdentifierPart(ch) {
2690 - return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
2691 - (ch >= 65 && ch <= 90) || // A..Z
2692 - (ch >= 97 && ch <= 122) || // a..z
2693 - (ch >= 48 && ch <= 57) || // 0..9
2694 - (ch === 92) || // \ (backslash)
2695 - ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch)));
2696 - }
2697 -
2698 - // 7.6.1.2 Future Reserved Words
2699 -
2700 - function isFutureReservedWord(id) {
2701 - switch (id) {
2702 - case 'class':
2703 - case 'enum':
2704 - case 'export':
2705 - case 'extends':
2706 - case 'import':
2707 - case 'super':
2708 - return true;
2709 - default:
2710 - return false;
2711 - }
2712 - }
2713 -
2714 - function isStrictModeReservedWord(id) {
2715 - switch (id) {
2716 - case 'implements':
2717 - case 'interface':
2718 - case 'package':
2719 - case 'private':
2720 - case 'protected':
2721 - case 'public':
2722 - case 'static':
2723 - case 'yield':
2724 - case 'let':
2725 - return true;
2726 - default:
2727 - return false;
2728 - }
2729 - }
2730 -
2731 - function isRestrictedWord(id) {
2732 - return id === 'eval' || id === 'arguments';
2733 - }
2734 -
2735 - // 7.6.1.1 Keywords
2736 -
2737 - function isKeyword(id) {
2738 - if (strict && isStrictModeReservedWord(id)) {
2739 - return true;
2740 - }
2741 -
2742 - // 'const' is specialized as Keyword in V8.
2743 - // 'yield' is only treated as a keyword in strict mode.
2744 - // 'let' is for compatiblity with SpiderMonkey and ES.next.
2745 - // Some others are from future reserved words.
2746 -
2747 - switch (id.length) {
2748 - case 2:
2749 - return (id === 'if') || (id === 'in') || (id === 'do');
2750 - case 3:
2751 - return (id === 'var') || (id === 'for') || (id === 'new') ||
2752 - (id === 'try') || (id === 'let');
2753 - case 4:
2754 - return (id === 'this') || (id === 'else') || (id === 'case') ||
2755 - (id === 'void') || (id === 'with') || (id === 'enum');
2756 - case 5:
2757 - return (id === 'while') || (id === 'break') || (id === 'catch') ||
2758 - (id === 'throw') || (id === 'const') ||
2759 - (id === 'class') || (id === 'super');
2760 - case 6:
2761 - return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
2762 - (id === 'switch') || (id === 'export') || (id === 'import');
2763 - case 7:
2764 - return (id === 'default') || (id === 'finally') || (id === 'extends');
2765 - case 8:
2766 - return (id === 'function') || (id === 'continue') || (id === 'debugger');
2767 - case 10:
2768 - return (id === 'instanceof');
2769 - default:
2770 - return false;
2771 - }
2772 - }
2773 -
2774 - // 7.4 Comments
2775 -
2776 - function addComment(type, value, start, end, loc) {
2777 - var comment;
2778 - assert(typeof start === 'number', 'Comment must have valid position');
2779 -
2780 - // Because the way the actual token is scanned, often the comments
2781 - // (if any) are skipped twice during the lexical analysis.
2782 - // Thus, we need to skip adding a comment if the comment array already
2783 - // handled it.
2784 - if (state.lastCommentStart >= start) {
2785 - return;
2786 - }
2787 - state.lastCommentStart = start;
2788 -
2789 - comment = {
2790 - type: type,
2791 - value: value
2792 - };
2793 - if (extra.range) {
2794 - comment.range = [start, end];
2795 - }
2796 - if (extra.loc) {
2797 - comment.loc = loc;
2798 - }
2799 - extra.comments.push(comment);
2800 - if (extra.attachComment) {
2801 - extra.leadingComments.push(comment);
2802 - extra.trailingComments.push(comment);
2803 - }
2804 - }
2805 -
2806 - function skipSingleLineComment() {
2807 - var start, loc, ch, comment;
2808 -
2809 - start = index - 2;
2810 - loc = {
2811 - start: {
2812 - line: lineNumber,
2813 - column: index - lineStart - 2
2814 - }
2815 - };
2816 -
2817 - while (index < length) {
2818 - ch = source.charCodeAt(index);
2819 - ++index;
2820 - if (isLineTerminator(ch)) {
2821 - if (extra.comments) {
2822 - comment = source.slice(start + 2, index - 1);
2823 - loc.end = {
2824 - line: lineNumber,
2825 - column: index - lineStart - 1
2826 - };
2827 - addComment('Line', comment, start, index - 1, loc);
2828 - }
2829 - if (ch === 13 && source.charCodeAt(index) === 10) {
2830 - ++index;
2831 - }
2832 - ++lineNumber;
2833 - lineStart = index;
2834 - return;
2835 - }
2836 - }
2837 -
2838 - if (extra.comments) {
2839 - comment = source.slice(start + 2, index);
2840 - loc.end = {
2841 - line: lineNumber,
2842 - column: index - lineStart
2843 - };
2844 - addComment('Line', comment, start, index, loc);
2845 - }
2846 - }
2847 -
2848 - function skipMultiLineComment() {
2849 - var start, loc, ch, comment;
2850 -
2851 - if (extra.comments) {
2852 - start = index - 2;
2853 - loc = {
2854 - start: {
2855 - line: lineNumber,
2856 - column: index - lineStart - 2
2857 - }
2858 - };
2859 - }
2860 -
2861 - while (index < length) {
2862 - ch = source.charCodeAt(index);
2863 - if (isLineTerminator(ch)) {
2864 - if (ch === 13 && source.charCodeAt(index + 1) === 10) {
2865 - ++index;
2866 - }
2867 - ++lineNumber;
2868 - ++index;
2869 - lineStart = index;
2870 - if (index >= length) {
2871 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2872 - }
2873 - } else if (ch === 42) {
2874 - // Block comment ends with '*/' (char #42, char #47).
2875 - if (source.charCodeAt(index + 1) === 47) {
2876 - ++index;
2877 - ++index;
2878 - if (extra.comments) {
2879 - comment = source.slice(start + 2, index - 2);
2880 - loc.end = {
2881 - line: lineNumber,
2882 - column: index - lineStart
2883 - };
2884 - addComment('Block', comment, start, index, loc);
2885 - }
2886 - return;
2887 - }
2888 - ++index;
2889 - } else {
2890 - ++index;
2891 - }
2892 - }
2893 -
2894 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2895 - }
2896 -
2897 - function skipComment() {
2898 - var ch;
2899 -
2900 - while (index < length) {
2901 - ch = source.charCodeAt(index);
2902 -
2903 - if (isWhiteSpace(ch)) {
2904 - ++index;
2905 - } else if (isLineTerminator(ch)) {
2906 - ++index;
2907 - if (ch === 13 && source.charCodeAt(index) === 10) {
2908 - ++index;
2909 - }
2910 - ++lineNumber;
2911 - lineStart = index;
2912 - } else if (ch === 47) { // 47 is '/'
2913 - ch = source.charCodeAt(index + 1);
2914 - if (ch === 47) {
2915 - ++index;
2916 - ++index;
2917 - skipSingleLineComment();
2918 - } else if (ch === 42) { // 42 is '*'
2919 - ++index;
2920 - ++index;
2921 - skipMultiLineComment();
2922 - } else {
2923 - break;
2924 - }
2925 - } else {
2926 - break;
2927 - }
2928 - }
2929 - }
2930 -
2931 - function scanHexEscape(prefix) {
2932 - var i, len, ch, code = 0;
2933 -
2934 - len = (prefix === 'u') ? 4 : 2;
2935 - for (i = 0; i < len; ++i) {
2936 - if (index < length && isHexDigit(source[index])) {
2937 - ch = source[index++];
2938 - code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
2939 - } else {
2940 - return '';
2941 - }
2942 - }
2943 - return String.fromCharCode(code);
2944 - }
2945 -
2946 - function scanUnicodeCodePointEscape() {
2947 - var ch, code, cu1, cu2;
2948 -
2949 - ch = source[index];
2950 - code = 0;
2951 -
2952 - // At least, one hex digit is required.
2953 - if (ch === '}') {
2954 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2955 - }
2956 -
2957 - while (index < length) {
2958 - ch = source[index++];
2959 - if (!isHexDigit(ch)) {
2960 - break;
2961 - }
2962 - code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
2963 - }
2964 -
2965 - if (code > 0x10FFFF || ch !== '}') {
2966 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2967 - }
2968 -
2969 - // UTF-16 Encoding
2970 - if (code <= 0xFFFF) {
2971 - return String.fromCharCode(code);
2972 - }
2973 - cu1 = ((code - 0x10000) >> 10) + 0xD800;
2974 - cu2 = ((code - 0x10000) & 1023) + 0xDC00;
2975 - return String.fromCharCode(cu1, cu2);
2976 - }
2977 -
2978 - function getEscapedIdentifier() {
2979 - var ch, id;
2980 -
2981 - ch = source.charCodeAt(index++);
2982 - id = String.fromCharCode(ch);
2983 -
2984 - // '\u' (char #92, char #117) denotes an escaped character.
2985 - if (ch === 92) {
2986 - if (source.charCodeAt(index) !== 117) {
2987 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2988 - }
2989 - ++index;
2990 - ch = scanHexEscape('u');
2991 - if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
2992 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2993 - }
2994 - id = ch;
2995 - }
2996 -
2997 - while (index < length) {
2998 - ch = source.charCodeAt(index);
2999 - if (!isIdentifierPart(ch)) {
3000 - break;
3001 - }
3002 - ++index;
3003 - id += String.fromCharCode(ch);
3004 -
3005 - // '\u' (char #92, char #117) denotes an escaped character.
3006 - if (ch === 92) {
3007 - id = id.substr(0, id.length - 1);
3008 - if (source.charCodeAt(index) !== 117) {
3009 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3010 - }
3011 - ++index;
3012 - ch = scanHexEscape('u');
3013 - if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
3014 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3015 - }
3016 - id += ch;
3017 - }
3018 - }
3019 -
3020 - return id;
3021 - }
3022 -
3023 - function getIdentifier() {
3024 - var start, ch;
3025 -
3026 - start = index++;
3027 - while (index < length) {
3028 - ch = source.charCodeAt(index);
3029 - if (ch === 92) {
3030 - // Blackslash (char #92) marks Unicode escape sequence.
3031 - index = start;
3032 - return getEscapedIdentifier();
3033 - }
3034 - if (isIdentifierPart(ch)) {
3035 - ++index;
3036 - } else {
3037 - break;
3038 - }
3039 - }
3040 -
3041 - return source.slice(start, index);
3042 - }
3043 -
3044 - function scanIdentifier() {
3045 - var start, id, type;
3046 -
3047 - start = index;
3048 -
3049 - // Backslash (char #92) starts an escaped character.
3050 - id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier();
3051 -
3052 - // There is no keyword or literal with only one character.
3053 - // Thus, it must be an identifier.
3054 - if (id.length === 1) {
3055 - type = Token.Identifier;
3056 - } else if (isKeyword(id)) {
3057 - type = Token.Keyword;
3058 - } else if (id === 'null') {
3059 - type = Token.NullLiteral;
3060 - } else if (id === 'true' || id === 'false') {
3061 - type = Token.BooleanLiteral;
3062 - } else {
3063 - type = Token.Identifier;
3064 - }
3065 -
3066 - return {
3067 - type: type,
3068 - value: id,
3069 - lineNumber: lineNumber,
3070 - lineStart: lineStart,
3071 - range: [start, index]
3072 - };
3073 - }
3074 -
3075 -
3076 - // 7.7 Punctuators
3077 -
3078 - function scanPunctuator() {
3079 - var start = index,
3080 - code = source.charCodeAt(index),
3081 - code2,
3082 - ch1 = source[index],
3083 - ch2,
3084 - ch3,
3085 - ch4;
3086 -
3087 - if (state.inJSXTag || state.inJSXChild) {
3088 - // Don't need to check for '{' and '}' as it's already handled
3089 - // correctly by default.
3090 - switch (code) {
3091 - case 60: // <
3092 - case 62: // >
3093 - ++index;
3094 - return {
3095 - type: Token.Punctuator,
3096 - value: String.fromCharCode(code),
3097 - lineNumber: lineNumber,
3098 - lineStart: lineStart,
3099 - range: [start, index]
3100 - };
3101 - }
3102 - }
3103 -
3104 - switch (code) {
3105 - // Check for most common single-character punctuators.
3106 - case 40: // ( open bracket
3107 - case 41: // ) close bracket
3108 - case 59: // ; semicolon
3109 - case 44: // , comma
3110 - case 123: // { open curly brace
3111 - case 125: // } close curly brace
3112 - case 91: // [
3113 - case 93: // ]
3114 - case 58: // :
3115 - case 63: // ?
3116 - case 126: // ~
3117 - ++index;
3118 - if (extra.tokenize) {
3119 - if (code === 40) {
3120 - extra.openParenToken = extra.tokens.length;
3121 - } else if (code === 123) {
3122 - extra.openCurlyToken = extra.tokens.length;
3123 - }
3124 - }
3125 - return {
3126 - type: Token.Punctuator,
3127 - value: String.fromCharCode(code),
3128 - lineNumber: lineNumber,
3129 - lineStart: lineStart,
3130 - range: [start, index]
3131 - };
3132 -
3133 - default:
3134 - code2 = source.charCodeAt(index + 1);
3135 -
3136 - // '=' (char #61) marks an assignment or comparison operator.
3137 - if (code2 === 61) {
3138 - switch (code) {
3139 - case 37: // %
3140 - case 38: // &
3141 - case 42: // *:
3142 - case 43: // +
3143 - case 45: // -
3144 - case 47: // /
3145 - case 60: // <
3146 - case 62: // >
3147 - case 94: // ^
3148 - case 124: // |
3149 - index += 2;
3150 - return {
3151 - type: Token.Punctuator,
3152 - value: String.fromCharCode(code) + String.fromCharCode(code2),
3153 - lineNumber: lineNumber,
3154 - lineStart: lineStart,
3155 - range: [start, index]
3156 - };
3157 -
3158 - case 33: // !
3159 - case 61: // =
3160 - index += 2;
3161 -
3162 - // !== and ===
3163 - if (source.charCodeAt(index) === 61) {
3164 - ++index;
3165 - }
3166 - return {
3167 - type: Token.Punctuator,
3168 - value: source.slice(start, index),
3169 - lineNumber: lineNumber,
3170 - lineStart: lineStart,
3171 - range: [start, index]
3172 - };
3173 - default:
3174 - break;
3175 - }
3176 - }
3177 - break;
3178 - }
3179 -
3180 - // Peek more characters.
3181 -
3182 - ch2 = source[index + 1];
3183 - ch3 = source[index + 2];
3184 - ch4 = source[index + 3];
3185 -
3186 - // 4-character punctuator: >>>=
3187 -
3188 - if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
3189 - if (ch4 === '=') {
3190 - index += 4;
3191 - return {
3192 - type: Token.Punctuator,
3193 - value: '>>>=',
3194 - lineNumber: lineNumber,
3195 - lineStart: lineStart,
3196 - range: [start, index]
3197 - };
3198 - }
3199 - }
3200 -
3201 - // 3-character punctuators: === !== >>> <<= >>=
3202 -
3203 - if (ch1 === '>' && ch2 === '>' && ch3 === '>' && !state.inType) {
3204 - index += 3;
3205 - return {
3206 - type: Token.Punctuator,
3207 - value: '>>>',
3208 - lineNumber: lineNumber,
3209 - lineStart: lineStart,
3210 - range: [start, index]
3211 - };
3212 - }
3213 -
3214 - if (ch1 === '<' && ch2 === '<' && ch3 === '=') {
3215 - index += 3;
3216 - return {
3217 - type: Token.Punctuator,
3218 - value: '<<=',
3219 - lineNumber: lineNumber,
3220 - lineStart: lineStart,
3221 - range: [start, index]
3222 - };
3223 - }
3224 -
3225 - if (ch1 === '>' && ch2 === '>' && ch3 === '=') {
3226 - index += 3;
3227 - return {
3228 - type: Token.Punctuator,
3229 - value: '>>=',
3230 - lineNumber: lineNumber,
3231 - lineStart: lineStart,
3232 - range: [start, index]
3233 - };
3234 - }
3235 -
3236 - if (ch1 === '.' && ch2 === '.' && ch3 === '.') {
3237 - index += 3;
3238 - return {
3239 - type: Token.Punctuator,
3240 - value: '...',
3241 - lineNumber: lineNumber,
3242 - lineStart: lineStart,
3243 - range: [start, index]
3244 - };
3245 - }
3246 -
3247 - // Other 2-character punctuators: ++ -- << >> && ||
3248 -
3249 - // Don't match these tokens if we're in a type, since they never can
3250 - // occur and can mess up types like Map<string, Array<string>>
3251 - if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
3252 - index += 2;
3253 - return {
3254 - type: Token.Punctuator,
3255 - value: ch1 + ch2,
3256 - lineNumber: lineNumber,
3257 - lineStart: lineStart,
3258 - range: [start, index]
3259 - };
3260 - }
3261 -
3262 - if (ch1 === '=' && ch2 === '>') {
3263 - index += 2;
3264 - return {
3265 - type: Token.Punctuator,
3266 - value: '=>',
3267 - lineNumber: lineNumber,
3268 - lineStart: lineStart,
3269 - range: [start, index]
3270 - };
3271 - }
3272 -
3273 - if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
3274 - ++index;
3275 - return {
3276 - type: Token.Punctuator,
3277 - value: ch1,
3278 - lineNumber: lineNumber,
3279 - lineStart: lineStart,
3280 - range: [start, index]
3281 - };
3282 - }
3283 -
3284 - if (ch1 === '.') {
3285 - ++index;
3286 - return {
3287 - type: Token.Punctuator,
3288 - value: ch1,
3289 - lineNumber: lineNumber,
3290 - lineStart: lineStart,
3291 - range: [start, index]
3292 - };
3293 - }
3294 -
3295 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3296 - }
3297 -
3298 - // 7.8.3 Numeric Literals
3299 -
3300 - function scanHexLiteral(start) {
3301 - var number = '';
3302 -
3303 - while (index < length) {
3304 - if (!isHexDigit(source[index])) {
3305 - break;
3306 - }
3307 - number += source[index++];
3308 - }
3309 -
3310 - if (number.length === 0) {
3311 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3312 - }
3313 -
3314 - if (isIdentifierStart(source.charCodeAt(index))) {
3315 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3316 - }
3317 -
3318 - return {
3319 - type: Token.NumericLiteral,
3320 - value: parseInt('0x' + number, 16),
3321 - lineNumber: lineNumber,
3322 - lineStart: lineStart,
3323 - range: [start, index]
3324 - };
3325 - }
3326 -
3327 - function scanBinaryLiteral(start) {
3328 - var ch, number;
3329 -
3330 - number = '';
3331 -
3332 - while (index < length) {
3333 - ch = source[index];
3334 - if (ch !== '0' && ch !== '1') {
3335 - break;
3336 - }
3337 - number += source[index++];
3338 - }
3339 -
3340 - if (number.length === 0) {
3341 - // only 0b or 0B
3342 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3343 - }
3344 -
3345 - if (index < length) {
3346 - ch = source.charCodeAt(index);
3347 - /* istanbul ignore else */
3348 - if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
3349 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3350 - }
3351 - }
3352 -
3353 - return {
3354 - type: Token.NumericLiteral,
3355 - value: parseInt(number, 2),
3356 - lineNumber: lineNumber,
3357 - lineStart: lineStart,
3358 - range: [start, index]
3359 - };
3360 - }
3361 -
3362 - function scanOctalLiteral(prefix, start) {
3363 - var number, octal;
3364 -
3365 - if (isOctalDigit(prefix)) {
3366 - octal = true;
3367 - number = '0' + source[index++];
3368 - } else {
3369 - octal = false;
3370 - ++index;
3371 - number = '';
3372 - }
3373 -
3374 - while (index < length) {
3375 - if (!isOctalDigit(source[index])) {
3376 - break;
3377 - }
3378 - number += source[index++];
3379 - }
3380 -
3381 - if (!octal && number.length === 0) {
3382 - // only 0o or 0O
3383 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3384 - }
3385 -
3386 - if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
3387 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3388 - }
3389 -
3390 - return {
3391 - type: Token.NumericLiteral,
3392 - value: parseInt(number, 8),
3393 - octal: octal,
3394 - lineNumber: lineNumber,
3395 - lineStart: lineStart,
3396 - range: [start, index]
3397 - };
3398 - }
3399 -
3400 - function scanNumericLiteral() {
3401 - var number, start, ch;
3402 -
3403 - ch = source[index];
3404 - assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
3405 - 'Numeric literal must start with a decimal digit or a decimal point');
3406 -
3407 - start = index;
3408 - number = '';
3409 - if (ch !== '.') {
3410 - number = source[index++];
3411 - ch = source[index];
3412 -
3413 - // Hex number starts with '0x'.
3414 - // Octal number starts with '0'.
3415 - // Octal number in ES6 starts with '0o'.
3416 - // Binary number in ES6 starts with '0b'.
3417 - if (number === '0') {
3418 - if (ch === 'x' || ch === 'X') {
3419 - ++index;
3420 - return scanHexLiteral(start);
3421 - }
3422 - if (ch === 'b' || ch === 'B') {
3423 - ++index;
3424 - return scanBinaryLiteral(start);
3425 - }
3426 - if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
3427 - return scanOctalLiteral(ch, start);
3428 - }
3429 - // decimal number starts with '0' such as '09' is illegal.
3430 - if (ch && isDecimalDigit(ch.charCodeAt(0))) {
3431 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3432 - }
3433 - }
3434 -
3435 - while (isDecimalDigit(source.charCodeAt(index))) {
3436 - number += source[index++];
3437 - }
3438 - ch = source[index];
3439 - }
3440 -
3441 - if (ch === '.') {
3442 - number += source[index++];
3443 - while (isDecimalDigit(source.charCodeAt(index))) {
3444 - number += source[index++];
3445 - }
3446 - ch = source[index];
3447 - }
3448 -
3449 - if (ch === 'e' || ch === 'E') {
3450 - number += source[index++];
3451 -
3452 - ch = source[index];
3453 - if (ch === '+' || ch === '-') {
3454 - number += source[index++];
3455 - }
3456 - if (isDecimalDigit(source.charCodeAt(index))) {
3457 - while (isDecimalDigit(source.charCodeAt(index))) {
3458 - number += source[index++];
3459 - }
3460 - } else {
3461 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3462 - }
3463 - }
3464 -
3465 - if (isIdentifierStart(source.charCodeAt(index))) {
3466 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3467 - }
3468 -
3469 - return {
3470 - type: Token.NumericLiteral,
3471 - value: parseFloat(number),
3472 - lineNumber: lineNumber,
3473 - lineStart: lineStart,
3474 - range: [start, index]
3475 - };
3476 - }
3477 -
3478 - // 7.8.4 String Literals
3479 -
3480 - function scanStringLiteral() {
3481 - var str = '', quote, start, ch, code, unescaped, restore, octal = false;
3482 -
3483 - quote = source[index];
3484 - assert((quote === '\'' || quote === '"'),
3485 - 'String literal must starts with a quote');
3486 -
3487 - start = index;
3488 - ++index;
3489 -
3490 - while (index < length) {
3491 - ch = source[index++];
3492 -
3493 - if (ch === quote) {
3494 - quote = '';
3495 - break;
3496 - } else if (ch === '\\') {
3497 - ch = source[index++];
3498 - if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
3499 - switch (ch) {
3500 - case 'n':
3501 - str += '\n';
3502 - break;
3503 - case 'r':
3504 - str += '\r';
3505 - break;
3506 - case 't':
3507 - str += '\t';
3508 - break;
3509 - case 'u':
3510 - case 'x':
3511 - if (source[index] === '{') {
3512 - ++index;
3513 - str += scanUnicodeCodePointEscape();
3514 - } else {
3515 - restore = index;
3516 - unescaped = scanHexEscape(ch);
3517 - if (unescaped) {
3518 - str += unescaped;
3519 - } else {
3520 - index = restore;
3521 - str += ch;
3522 - }
3523 - }
3524 - break;
3525 - case 'b':
3526 - str += '\b';
3527 - break;
3528 - case 'f':
3529 - str += '\f';
3530 - break;
3531 - case 'v':
3532 - str += '\x0B';
3533 - break;
3534 -
3535 - default:
3536 - if (isOctalDigit(ch)) {
3537 - code = '01234567'.indexOf(ch);
3538 -
3539 - // \0 is not octal escape sequence
3540 - if (code !== 0) {
3541 - octal = true;
3542 - }
3543 -
3544 - /* istanbul ignore else */
3545 - if (index < length && isOctalDigit(source[index])) {
3546 - octal = true;
3547 - code = code * 8 + '01234567'.indexOf(source[index++]);
3548 -
3549 - // 3 digits are only allowed when string starts
3550 - // with 0, 1, 2, 3
3551 - if ('0123'.indexOf(ch) >= 0 &&
3552 - index < length &&
3553 - isOctalDigit(source[index])) {
3554 - code = code * 8 + '01234567'.indexOf(source[index++]);
3555 - }
3556 - }
3557 - str += String.fromCharCode(code);
3558 - } else {
3559 - str += ch;
3560 - }
3561 - break;
3562 - }
3563 - } else {
3564 - ++lineNumber;
3565 - if (ch === '\r' && source[index] === '\n') {
3566 - ++index;
3567 - }
3568 - lineStart = index;
3569 - }
3570 - } else if (isLineTerminator(ch.charCodeAt(0))) {
3571 - break;
3572 - } else {
3573 - str += ch;
3574 - }
3575 - }
3576 -
3577 - if (quote !== '') {
3578 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3579 - }
3580 -
3581 - return {
3582 - type: Token.StringLiteral,
3583 - value: str,
3584 - octal: octal,
3585 - lineNumber: lineNumber,
3586 - lineStart: lineStart,
3587 - range: [start, index]
3588 - };
3589 - }
3590 -
3591 - function scanTemplate() {
3592 - var cooked = '', ch, start, terminated, tail, restore, unescaped, code, octal;
3593 -
3594 - terminated = false;
3595 - tail = false;
3596 - start = index;
3597 -
3598 - ++index;
3599 -
3600 - while (index < length) {
3601 - ch = source[index++];
3602 - if (ch === '`') {
3603 - tail = true;
3604 - terminated = true;
3605 - break;
3606 - } else if (ch === '$') {
3607 - if (source[index] === '{') {
3608 - ++index;
3609 - terminated = true;
3610 - break;
3611 - }
3612 - cooked += ch;
3613 - } else if (ch === '\\') {
3614 - ch = source[index++];
3615 - if (!isLineTerminator(ch.charCodeAt(0))) {
3616 - switch (ch) {
3617 - case 'n':
3618 - cooked += '\n';
3619 - break;
3620 - case 'r':
3621 - cooked += '\r';
3622 - break;
3623 - case 't':
3624 - cooked += '\t';
3625 - break;
3626 - case 'u':
3627 - case 'x':
3628 - if (source[index] === '{') {
3629 - ++index;
3630 - cooked += scanUnicodeCodePointEscape();
3631 - } else {
3632 - restore = index;
3633 - unescaped = scanHexEscape(ch);
3634 - if (unescaped) {
3635 - cooked += unescaped;
3636 - } else {
3637 - index = restore;
3638 - cooked += ch;
3639 - }
3640 - }
3641 - break;
3642 - case 'b':
3643 - cooked += '\b';
3644 - break;
3645 - case 'f':
3646 - cooked += '\f';
3647 - break;
3648 - case 'v':
3649 - cooked += '\v';
3650 - break;
3651 -
3652 - default:
3653 - if (isOctalDigit(ch)) {
3654 - code = '01234567'.indexOf(ch);
3655 -
3656 - // \0 is not octal escape sequence
3657 - if (code !== 0) {
3658 - octal = true;
3659 - }
3660 -
3661 - /* istanbul ignore else */
3662 - if (index < length && isOctalDigit(source[index])) {
3663 - octal = true;
3664 - code = code * 8 + '01234567'.indexOf(source[index++]);
3665 -
3666 - // 3 digits are only allowed when string starts
3667 - // with 0, 1, 2, 3
3668 - if ('0123'.indexOf(ch) >= 0 &&
3669 - index < length &&
3670 - isOctalDigit(source[index])) {
3671 - code = code * 8 + '01234567'.indexOf(source[index++]);
3672 - }
3673 - }
3674 - cooked += String.fromCharCode(code);
3675 - } else {
3676 - cooked += ch;
3677 - }
3678 - break;
3679 - }
3680 - } else {
3681 - ++lineNumber;
3682 - if (ch === '\r' && source[index] === '\n') {
3683 - ++index;
3684 - }
3685 - lineStart = index;
3686 - }
3687 - } else if (isLineTerminator(ch.charCodeAt(0))) {
3688 - ++lineNumber;
3689 - if (ch === '\r' && source[index] === '\n') {
3690 - ++index;
3691 - }
3692 - lineStart = index;
3693 - cooked += '\n';
3694 - } else {
3695 - cooked += ch;
3696 - }
3697 - }
3698 -
3699 - if (!terminated) {
3700 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3701 - }
3702 -
3703 - return {
3704 - type: Token.Template,
3705 - value: {
3706 - cooked: cooked,
3707 - raw: source.slice(start + 1, index - ((tail) ? 1 : 2))
3708 - },
3709 - tail: tail,
3710 - octal: octal,
3711 - lineNumber: lineNumber,
3712 - lineStart: lineStart,
3713 - range: [start, index]
3714 - };
3715 - }
3716 -
3717 - function scanTemplateElement(option) {
3718 - var startsWith, template;
3719 -
3720 - lookahead = null;
3721 - skipComment();
3722 -
3723 - startsWith = (option.head) ? '`' : '}';
3724 -
3725 - if (source[index] !== startsWith) {
3726 - throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3727 - }
3728 -
3729 - template = scanTemplate();
3730 -
3731 - peek();
3732 -
3733 - return template;
3734 - }
3735 -
3736 - function testRegExp(pattern, flags) {
3737 - var tmp = pattern,
3738 - value;
3739 -
3740 - if (flags.indexOf('u') >= 0) {
3741 - // Replace each astral symbol and every Unicode code point
3742 - // escape sequence with a single ASCII symbol to avoid throwing on
3743 - // regular expressions that are only valid in combination with the
3744 - // `/u` flag.
3745 - // Note: replacing with the ASCII symbol `x` might cause false
3746 - // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
3747 - // perfectly valid pattern that is equivalent to `[a-b]`, but it
3748 - // would be replaced by `[x-b]` which throws an error.
3749 - tmp = tmp
3750 - .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
3751 - if (parseInt($1, 16) <= 0x10FFFF) {
3752 - return 'x';
3753 - }
3754 - throwError({}, Messages.InvalidRegExp);
3755 - })
3756 - .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
3757 - }
3758 -
3759 - // First, detect invalid regular expressions.
3760 - try {
3761 - value = new RegExp(tmp);
3762 - } catch (e) {
3763 - throwError({}, Messages.InvalidRegExp);
3764 - }
3765 -
3766 - // Return a regular expression object for this pattern-flag pair, or
3767 - // `null` in case the current environment doesn't support the flags it
3768 - // uses.
3769 - try {
3770 - return new RegExp(pattern, flags);
3771 - } catch (exception) {
3772 - return null;
3773 - }
3774 - }
3775 -
3776 - function scanRegExpBody() {
3777 - var ch, str, classMarker, terminated, body;
3778 -
3779 - ch = source[index];
3780 - assert(ch === '/', 'Regular expression literal must start with a slash');
3781 - str = source[index++];
3782 -
3783 - classMarker = false;
3784 - terminated = false;
3785 - while (index < length) {
3786 - ch = source[index++];
3787 - str += ch;
3788 - if (ch === '\\') {
3789 - ch = source[index++];
3790 - // ECMA-262 7.8.5
3791 - if (isLineTerminator(ch.charCodeAt(0))) {
3792 - throwError({}, Messages.UnterminatedRegExp);
3793 - }
3794 - str += ch;
3795 - } else if (isLineTerminator(ch.charCodeAt(0))) {
3796 - throwError({}, Messages.UnterminatedRegExp);
3797 - } else if (classMarker) {
3798 - if (ch === ']') {
3799 - classMarker = false;
3800 - }
3801 - } else {
3802 - if (ch === '/') {
3803 - terminated = true;
3804 - break;
3805 - } else if (ch === '[') {
3806 - classMarker = true;
3807 - }
3808 - }
3809 - }
3810 -
3811 - if (!terminated) {
3812 - throwError({}, Messages.UnterminatedRegExp);
3813 - }
3814 -
3815 - // Exclude leading and trailing slash.
3816 - body = str.substr(1, str.length - 2);
3817 - return {
3818 - value: body,
3819 - literal: str
3820 - };
3821 - }
3822 -
3823 - function scanRegExpFlags() {
3824 - var ch, str, flags, restore;
3825 -
3826 - str = '';
3827 - flags = '';
3828 - while (index < length) {
3829 - ch = source[index];
3830 - if (!isIdentifierPart(ch.charCodeAt(0))) {
3831 - break;
3832 - }
3833 -
3834 - ++index;
3835 - if (ch === '\\' && index < length) {
3836 - ch = source[index];
3837 - if (ch === 'u') {
3838 - ++index;
3839 - restore = index;
3840 - ch = scanHexEscape('u');
3841 - if (ch) {
3842 - flags += ch;
3843 - for (str += '\\u'; restore < index; ++restore) {
3844 - str += source[restore];
3845 - }
3846 - } else {
3847 - index = restore;
3848 - flags += 'u';
3849 - str += '\\u';
3850 - }
3851 - throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
3852 - } else {
3853 - str += '\\';
3854 - throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
3855 - }
3856 - } else {
3857 - flags += ch;
3858 - str += ch;
3859 - }
3860 - }
3861 -
3862 - return {
3863 - value: flags,
3864 - literal: str
3865 - };
3866 - }
3867 -
3868 - function scanRegExp() {
3869 - var start, body, flags, value;
3870 -
3871 - lookahead = null;
3872 - skipComment();
3873 - start = index;
3874 -
3875 - body = scanRegExpBody();
3876 - flags = scanRegExpFlags();
3877 - value = testRegExp(body.value, flags.value);
3878 -
3879 - if (extra.tokenize) {
3880 - return {
3881 - type: Token.RegularExpression,
3882 - value: value,
3883 - regex: {
3884 - pattern: body.value,
3885 - flags: flags.value
3886 - },
3887 - lineNumber: lineNumber,
3888 - lineStart: lineStart,
3889 - range: [start, index]
3890 - };
3891 - }
3892 -
3893 - return {
3894 - literal: body.literal + flags.literal,
3895 - value: value,
3896 - regex: {
3897 - pattern: body.value,
3898 - flags: flags.value
3899 - },
3900 - range: [start, index]
3901 - };
3902 - }
3903 -
3904 - function isIdentifierName(token) {
3905 - return token.type === Token.Identifier ||
3906 - token.type === Token.Keyword ||
3907 - token.type === Token.BooleanLiteral ||
3908 - token.type === Token.NullLiteral;
3909 - }
3910 -
3911 - function advanceSlash() {
3912 - var prevToken,
3913 - checkToken;
3914 - // Using the following algorithm:
3915 - // https://github.com/mozilla/sweet.js/wiki/design
3916 - prevToken = extra.tokens[extra.tokens.length - 1];
3917 - if (!prevToken) {
3918 - // Nothing before that: it cannot be a division.
3919 - return scanRegExp();
3920 - }
3921 - if (prevToken.type === 'Punctuator') {
3922 - if (prevToken.value === ')') {
3923 - checkToken = extra.tokens[extra.openParenToken - 1];
3924 - if (checkToken &&
3925 - checkToken.type === 'Keyword' &&
3926 - (checkToken.value === 'if' ||
3927 - checkToken.value === 'while' ||
3928 - checkToken.value === 'for' ||
3929 - checkToken.value === 'with')) {
3930 - return scanRegExp();
3931 - }
3932 - return scanPunctuator();
3933 - }
3934 - if (prevToken.value === '}') {
3935 - // Dividing a function by anything makes little sense,
3936 - // but we have to check for that.
3937 - if (extra.tokens[extra.openCurlyToken - 3] &&
3938 - extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') {
3939 - // Anonymous function.
3940 - checkToken = extra.tokens[extra.openCurlyToken - 4];
3941 - if (!checkToken) {
3942 - return scanPunctuator();
3943 - }
3944 - } else if (extra.tokens[extra.openCurlyToken - 4] &&
3945 - extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') {
3946 - // Named function.
3947 - checkToken = extra.tokens[extra.openCurlyToken - 5];
3948 - if (!checkToken) {
3949 - return scanRegExp();
3950 - }
3951 - } else {
3952 - return scanPunctuator();
3953 - }
3954 - // checkToken determines whether the function is
3955 - // a declaration or an expression.
3956 - if (FnExprTokens.indexOf(checkToken.value) >= 0) {
3957 - // It is an expression.
3958 - return scanPunctuator();
3959 - }
3960 - // It is a declaration.
3961 - return scanRegExp();
3962 - }
3963 - return scanRegExp();
3964 - }
3965 - if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
3966 - return scanRegExp();
3967 - }
3968 - return scanPunctuator();
3969 - }
3970 -
3971 - function advance() {
3972 - var ch;
3973 -
3974 - if (!state.inJSXChild) {
3975 - skipComment();
3976 - }
3977 -
3978 - if (index >= length) {
3979 - return {
3980 - type: Token.EOF,
3981 - lineNumber: lineNumber,
3982 - lineStart: lineStart,
3983 - range: [index, index]
3984 - };
3985 - }
3986 -
3987 - if (state.inJSXChild) {
3988 - return advanceJSXChild();
3989 - }
3990 -
3991 - ch = source.charCodeAt(index);
3992 -
3993 - // Very common: ( and ) and ;
3994 - if (ch === 40 || ch === 41 || ch === 58) {
3995 - return scanPunctuator();
3996 - }
3997 -
3998 - // String literal starts with single quote (#39) or double quote (#34).
3999 - if (ch === 39 || ch === 34) {
4000 - if (state.inJSXTag) {
4001 - return scanJSXStringLiteral();
4002 - }
4003 - return scanStringLiteral();
4004 - }
4005 -
4006 - if (state.inJSXTag && isJSXIdentifierStart(ch)) {
4007 - return scanJSXIdentifier();
4008 - }
4009 -
4010 - if (ch === 96) {
4011 - return scanTemplate();
4012 - }
4013 - if (isIdentifierStart(ch)) {
4014 - return scanIdentifier();
4015 - }
4016 -
4017 - // Dot (.) char #46 can also start a floating-point number, hence the need
4018 - // to check the next character.
4019 - if (ch === 46) {
4020 - if (isDecimalDigit(source.charCodeAt(index + 1))) {
4021 - return scanNumericLiteral();
4022 - }
4023 - return scanPunctuator();
4024 - }
4025 -
4026 - if (isDecimalDigit(ch)) {
4027 - return scanNumericLiteral();
4028 - }
4029 -
4030 - // Slash (/) char #47 can also start a regex.
4031 - if (extra.tokenize && ch === 47) {
4032 - return advanceSlash();
4033 - }
4034 -
4035 - return scanPunctuator();
4036 - }
4037 -
4038 - function lex() {
4039 - var token;
4040 -
4041 - token = lookahead;
4042 - index = token.range[1];
4043 - lineNumber = token.lineNumber;
4044 - lineStart = token.lineStart;
4045 -
4046 - lookahead = advance();
4047 -
4048 - index = token.range[1];
4049 - lineNumber = token.lineNumber;
4050 - lineStart = token.lineStart;
4051 -
4052 - return token;
4053 - }
4054 -
4055 - function peek() {
4056 - var pos, line, start;
4057 -
4058 - pos = index;
4059 - line = lineNumber;
4060 - start = lineStart;
4061 - lookahead = advance();
4062 - index = pos;
4063 - lineNumber = line;
4064 - lineStart = start;
4065 - }
4066 -
4067 - function lookahead2() {
4068 - var adv, pos, line, start, result;
4069 -
4070 - // If we are collecting the tokens, don't grab the next one yet.
4071 - /* istanbul ignore next */
4072 - adv = (typeof extra.advance === 'function') ? extra.advance : advance;
4073 -
4074 - pos = index;
4075 - line = lineNumber;
4076 - start = lineStart;
4077 -
4078 - // Scan for the next immediate token.
4079 - /* istanbul ignore if */
4080 - if (lookahead === null) {
4081 - lookahead = adv();
4082 - }
4083 - index = lookahead.range[1];
4084 - lineNumber = lookahead.lineNumber;
4085 - lineStart = lookahead.lineStart;
4086 -
4087 - // Grab the token right after.
4088 - result = adv();
4089 - index = pos;
4090 - lineNumber = line;
4091 - lineStart = start;
4092 -
4093 - return result;
4094 - }
4095 -
4096 - function rewind(token) {
4097 - index = token.range[0];
4098 - lineNumber = token.lineNumber;
4099 - lineStart = token.lineStart;
4100 - lookahead = token;
4101 - }
4102 -
4103 - function markerCreate() {
4104 - if (!extra.loc && !extra.range) {
4105 - return undefined;
4106 - }
4107 - skipComment();
4108 - return {offset: index, line: lineNumber, col: index - lineStart};
4109 - }
4110 -
4111 - function markerCreatePreserveWhitespace() {
4112 - if (!extra.loc && !extra.range) {
4113 - return undefined;
4114 - }
4115 - return {offset: index, line: lineNumber, col: index - lineStart};
4116 - }
4117 -
4118 - function processComment(node) {
4119 - var lastChild,
4120 - trailingComments,
4121 - bottomRight = extra.bottomRightStack,
4122 - last = bottomRight[bottomRight.length - 1];
4123 -
4124 - if (node.type === Syntax.Program) {
4125 - /* istanbul ignore else */
4126 - if (node.body.length > 0) {
4127 - return;
4128 - }
4129 - }
4130 -
4131 - if (extra.trailingComments.length > 0) {
4132 - if (extra.trailingComments[0].range[0] >= node.range[1]) {
4133 - trailingComments = extra.trailingComments;
4134 - extra.trailingComments = [];
4135 - } else {
4136 - extra.trailingComments.length = 0;
4137 - }
4138 - } else {
4139 - if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
4140 - trailingComments = last.trailingComments;
4141 - delete last.trailingComments;
4142 - }
4143 - }
4144 -
4145 - // Eating the stack.
4146 - if (last) {
4147 - while (last && last.range[0] >= node.range[0]) {
4148 - lastChild = last;
4149 - last = bottomRight.pop();
4150 - }
4151 - }
4152 -
4153 - if (lastChild) {
4154 - if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
4155 - node.leadingComments = lastChild.leadingComments;
4156 - delete lastChild.leadingComments;
4157 - }
4158 - } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
4159 - node.leadingComments = extra.leadingComments;
4160 - extra.leadingComments = [];
4161 - }
4162 -
4163 - if (trailingComments) {
4164 - node.trailingComments = trailingComments;
4165 - }
4166 -
4167 - bottomRight.push(node);
4168 - }
4169 -
4170 - function markerApply(marker, node) {
4171 - if (extra.range) {
4172 - node.range = [marker.offset, index];
4173 - }
4174 - if (extra.loc) {
4175 - node.loc = {
4176 - start: {
4177 - line: marker.line,
4178 - column: marker.col
4179 - },
4180 - end: {
4181 - line: lineNumber,
4182 - column: index - lineStart
4183 - }
4184 - };
4185 - node = delegate.postProcess(node);
4186 - }
4187 - if (extra.attachComment) {
4188 - processComment(node);
4189 - }
4190 - return node;
4191 - }
4192 -
4193 - SyntaxTreeDelegate = {
4194 -
4195 - name: 'SyntaxTree',
4196 -
4197 - postProcess: function (node) {
4198 - return node;
4199 - },
4200 -
4201 - createArrayExpression: function (elements) {
4202 - return {
4203 - type: Syntax.ArrayExpression,
4204 - elements: elements
4205 - };
4206 - },
4207 -
4208 - createAssignmentExpression: function (operator, left, right) {
4209 - return {
4210 - type: Syntax.AssignmentExpression,
4211 - operator: operator,
4212 - left: left,
4213 - right: right
4214 - };
4215 - },
4216 -
4217 - createBinaryExpression: function (operator, left, right) {
4218 - var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression :
4219 - Syntax.BinaryExpression;
4220 - return {
4221 - type: type,
4222 - operator: operator,
4223 - left: left,
4224 - right: right
4225 - };
4226 - },
4227 -
4228 - createBlockStatement: function (body) {
4229 - return {
4230 - type: Syntax.BlockStatement,
4231 - body: body
4232 - };
4233 - },
4234 -
4235 - createBreakStatement: function (label) {
4236 - return {
4237 - type: Syntax.BreakStatement,
4238 - label: label
4239 - };
4240 - },
4241 -
4242 - createCallExpression: function (callee, args) {
4243 - return {
4244 - type: Syntax.CallExpression,
4245 - callee: callee,
4246 - 'arguments': args
4247 - };
4248 - },
4249 -
4250 - createCatchClause: function (param, body) {
4251 - return {
4252 - type: Syntax.CatchClause,
4253 - param: param,
4254 - body: body
4255 - };
4256 - },
4257 -
4258 - createConditionalExpression: function (test, consequent, alternate) {
4259 - return {
4260 - type: Syntax.ConditionalExpression,
4261 - test: test,
4262 - consequent: consequent,
4263 - alternate: alternate
4264 - };
4265 - },
4266 -
4267 - createContinueStatement: function (label) {
4268 - return {
4269 - type: Syntax.ContinueStatement,
4270 - label: label
4271 - };
4272 - },
4273 -
4274 - createDebuggerStatement: function () {
4275 - return {
4276 - type: Syntax.DebuggerStatement
4277 - };
4278 - },
4279 -
4280 - createDoWhileStatement: function (body, test) {
4281 - return {
4282 - type: Syntax.DoWhileStatement,
4283 - body: body,
4284 - test: test
4285 - };
4286 - },
4287 -
4288 - createEmptyStatement: function () {
4289 - return {
4290 - type: Syntax.EmptyStatement
4291 - };
4292 - },
4293 -
4294 - createExpressionStatement: function (expression) {
4295 - return {
4296 - type: Syntax.ExpressionStatement,
4297 - expression: expression
4298 - };
4299 - },
4300 -
4301 - createForStatement: function (init, test, update, body) {
4302 - return {
4303 - type: Syntax.ForStatement,
4304 - init: init,
4305 - test: test,
4306 - update: update,
4307 - body: body
4308 - };
4309 - },
4310 -
4311 - createForInStatement: function (left, right, body) {
4312 - return {
4313 - type: Syntax.ForInStatement,
4314 - left: left,
4315 - right: right,
4316 - body: body,
4317 - each: false
4318 - };
4319 - },
4320 -
4321 - createForOfStatement: function (left, right, body) {
4322 - return {
4323 - type: Syntax.ForOfStatement,
4324 - left: left,
4325 - right: right,
4326 - body: body
4327 - };
4328 - },
4329 -
4330 - createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
4331 - isAsync, returnType, typeParameters) {
4332 - var funDecl = {
4333 - type: Syntax.FunctionDeclaration,
4334 - id: id,
4335 - params: params,
4336 - defaults: defaults,
4337 - body: body,
4338 - rest: rest,
4339 - generator: generator,
4340 - expression: expression,
4341 - returnType: returnType,
4342 - typeParameters: typeParameters
4343 - };
4344 -
4345 - if (isAsync) {
4346 - funDecl.async = true;
4347 - }
4348 -
4349 - return funDecl;
4350 - },
4351 -
4352 - createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
4353 - isAsync, returnType, typeParameters) {
4354 - var funExpr = {
4355 - type: Syntax.FunctionExpression,
4356 - id: id,
4357 - params: params,
4358 - defaults: defaults,
4359 - body: body,
4360 - rest: rest,
4361 - generator: generator,
4362 - expression: expression,
4363 - returnType: returnType,
4364 - typeParameters: typeParameters
4365 - };
4366 -
4367 - if (isAsync) {
4368 - funExpr.async = true;
4369 - }
4370 -
4371 - return funExpr;
4372 - },
4373 -
4374 - createIdentifier: function (name) {
4375 - return {
4376 - type: Syntax.Identifier,
4377 - name: name,
4378 - // Only here to initialize the shape of the object to ensure
4379 - // that the 'typeAnnotation' key is ordered before others that
4380 - // are added later (like 'loc' and 'range'). This just helps
4381 - // keep the shape of Identifier nodes consistent with everything
4382 - // else.
4383 - typeAnnotation: undefined,
4384 - optional: undefined
4385 - };
4386 - },
4387 -
4388 - createTypeAnnotation: function (typeAnnotation) {
4389 - return {
4390 - type: Syntax.TypeAnnotation,
4391 - typeAnnotation: typeAnnotation
4392 - };
4393 - },
4394 -
4395 - createTypeCast: function (expression, typeAnnotation) {
4396 - return {
4397 - type: Syntax.TypeCastExpression,
4398 - expression: expression,
4399 - typeAnnotation: typeAnnotation
4400 - };
4401 - },
4402 -
4403 - createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
4404 - return {
4405 - type: Syntax.FunctionTypeAnnotation,
4406 - params: params,
4407 - returnType: returnType,
4408 - rest: rest,
4409 - typeParameters: typeParameters
4410 - };
4411 - },
4412 -
4413 - createFunctionTypeParam: function (name, typeAnnotation, optional) {
4414 - return {
4415 - type: Syntax.FunctionTypeParam,
4416 - name: name,
4417 - typeAnnotation: typeAnnotation,
4418 - optional: optional
4419 - };
4420 - },
4421 -
4422 - createNullableTypeAnnotation: function (typeAnnotation) {
4423 - return {
4424 - type: Syntax.NullableTypeAnnotation,
4425 - typeAnnotation: typeAnnotation
4426 - };
4427 - },
4428 -
4429 - createArrayTypeAnnotation: function (elementType) {
4430 - return {
4431 - type: Syntax.ArrayTypeAnnotation,
4432 - elementType: elementType
4433 - };
4434 - },
4435 -
4436 - createGenericTypeAnnotation: function (id, typeParameters) {
4437 - return {
4438 - type: Syntax.GenericTypeAnnotation,
4439 - id: id,
4440 - typeParameters: typeParameters
4441 - };
4442 - },
4443 -
4444 - createQualifiedTypeIdentifier: function (qualification, id) {
4445 - return {
4446 - type: Syntax.QualifiedTypeIdentifier,
4447 - qualification: qualification,
4448 - id: id
4449 - };
4450 - },
4451 -
4452 - createTypeParameterDeclaration: function (params) {
4453 - return {
4454 - type: Syntax.TypeParameterDeclaration,
4455 - params: params
4456 - };
4457 - },
4458 -
4459 - createTypeParameterInstantiation: function (params) {
4460 - return {
4461 - type: Syntax.TypeParameterInstantiation,
4462 - params: params
4463 - };
4464 - },
4465 -
4466 - createAnyTypeAnnotation: function () {
4467 - return {
4468 - type: Syntax.AnyTypeAnnotation
4469 - };
4470 - },
4471 -
4472 - createBooleanTypeAnnotation: function () {
4473 - return {
4474 - type: Syntax.BooleanTypeAnnotation
4475 - };
4476 - },
4477 -
4478 - createNumberTypeAnnotation: function () {
4479 - return {
4480 - type: Syntax.NumberTypeAnnotation
4481 - };
4482 - },
4483 -
4484 - createStringTypeAnnotation: function () {
4485 - return {
4486 - type: Syntax.StringTypeAnnotation
4487 - };
4488 - },
4489 -
4490 - createStringLiteralTypeAnnotation: function (token) {
4491 - return {
4492 - type: Syntax.StringLiteralTypeAnnotation,
4493 - value: token.value,
4494 - raw: source.slice(token.range[0], token.range[1])
4495 - };
4496 - },
4497 -
4498 - createVoidTypeAnnotation: function () {
4499 - return {
4500 - type: Syntax.VoidTypeAnnotation
4501 - };
4502 - },
4503 -
4504 - createTypeofTypeAnnotation: function (argument) {
4505 - return {
4506 - type: Syntax.TypeofTypeAnnotation,
4507 - argument: argument
4508 - };
4509 - },
4510 -
4511 - createTupleTypeAnnotation: function (types) {
4512 - return {
4513 - type: Syntax.TupleTypeAnnotation,
4514 - types: types
4515 - };
4516 - },
4517 -
4518 - createObjectTypeAnnotation: function (properties, indexers, callProperties) {
4519 - return {
4520 - type: Syntax.ObjectTypeAnnotation,
4521 - properties: properties,
4522 - indexers: indexers,
4523 - callProperties: callProperties
4524 - };
4525 - },
4526 -
4527 - createObjectTypeIndexer: function (id, key, value, isStatic) {
4528 - return {
4529 - type: Syntax.ObjectTypeIndexer,
4530 - id: id,
4531 - key: key,
4532 - value: value,
4533 - "static": isStatic
4534 - };
4535 - },
4536 -
4537 - createObjectTypeCallProperty: function (value, isStatic) {
4538 - return {
4539 - type: Syntax.ObjectTypeCallProperty,
4540 - value: value,
4541 - "static": isStatic
4542 - };
4543 - },
4544 -
4545 - createObjectTypeProperty: function (key, value, optional, isStatic) {
4546 - return {
4547 - type: Syntax.ObjectTypeProperty,
4548 - key: key,
4549 - value: value,
4550 - optional: optional,
4551 - "static": isStatic
4552 - };
4553 - },
4554 -
4555 - createUnionTypeAnnotation: function (types) {
4556 - return {
4557 - type: Syntax.UnionTypeAnnotation,
4558 - types: types
4559 - };
4560 - },
4561 -
4562 - createIntersectionTypeAnnotation: function (types) {
4563 - return {
4564 - type: Syntax.IntersectionTypeAnnotation,
4565 - types: types
4566 - };
4567 - },
4568 -
4569 - createTypeAlias: function (id, typeParameters, right) {
4570 - return {
4571 - type: Syntax.TypeAlias,
4572 - id: id,
4573 - typeParameters: typeParameters,
4574 - right: right
4575 - };
4576 - },
4577 -
4578 - createInterface: function (id, typeParameters, body, extended) {
4579 - return {
4580 - type: Syntax.InterfaceDeclaration,
4581 - id: id,
4582 - typeParameters: typeParameters,
4583 - body: body,
4584 - "extends": extended
4585 - };
4586 - },
4587 -
4588 - createInterfaceExtends: function (id, typeParameters) {
4589 - return {
4590 - type: Syntax.InterfaceExtends,
4591 - id: id,
4592 - typeParameters: typeParameters
4593 - };
4594 - },
4595 -
4596 - createDeclareFunction: function (id) {
4597 - return {
4598 - type: Syntax.DeclareFunction,
4599 - id: id
4600 - };
4601 - },
4602 -
4603 - createDeclareVariable: function (id) {
4604 - return {
4605 - type: Syntax.DeclareVariable,
4606 - id: id
4607 - };
4608 - },
4609 -
4610 - createDeclareModule: function (id, body) {
4611 - return {
4612 - type: Syntax.DeclareModule,
4613 - id: id,
4614 - body: body
4615 - };
4616 - },
4617 -
4618 - createJSXAttribute: function (name, value) {
4619 - return {
4620 - type: Syntax.JSXAttribute,
4621 - name: name,
4622 - value: value || null
4623 - };
4624 - },
4625 -
4626 - createJSXSpreadAttribute: function (argument) {
4627 - return {
4628 - type: Syntax.JSXSpreadAttribute,
4629 - argument: argument
4630 - };
4631 - },
4632 -
4633 - createJSXIdentifier: function (name) {
4634 - return {
4635 - type: Syntax.JSXIdentifier,
4636 - name: name
4637 - };
4638 - },
4639 -
4640 - createJSXNamespacedName: function (namespace, name) {
4641 - return {
4642 - type: Syntax.JSXNamespacedName,
4643 - namespace: namespace,
4644 - name: name
4645 - };
4646 - },
4647 -
4648 - createJSXMemberExpression: function (object, property) {
4649 - return {
4650 - type: Syntax.JSXMemberExpression,
4651 - object: object,
4652 - property: property
4653 - };
4654 - },
4655 -
4656 - createJSXElement: function (openingElement, closingElement, children) {
4657 - return {
4658 - type: Syntax.JSXElement,
4659 - openingElement: openingElement,
4660 - closingElement: closingElement,
4661 - children: children
4662 - };
4663 - },
4664 -
4665 - createJSXEmptyExpression: function () {
4666 - return {
4667 - type: Syntax.JSXEmptyExpression
4668 - };
4669 - },
4670 -
4671 - createJSXExpressionContainer: function (expression) {
4672 - return {
4673 - type: Syntax.JSXExpressionContainer,
4674 - expression: expression
4675 - };
4676 - },
4677 -
4678 - createJSXOpeningElement: function (name, attributes, selfClosing) {
4679 - return {
4680 - type: Syntax.JSXOpeningElement,
4681 - name: name,
4682 - selfClosing: selfClosing,
4683 - attributes: attributes
4684 - };
4685 - },
4686 -
4687 - createJSXClosingElement: function (name) {
4688 - return {
4689 - type: Syntax.JSXClosingElement,
4690 - name: name
4691 - };
4692 - },
4693 -
4694 - createIfStatement: function (test, consequent, alternate) {
4695 - return {
4696 - type: Syntax.IfStatement,
4697 - test: test,
4698 - consequent: consequent,
4699 - alternate: alternate
4700 - };
4701 - },
4702 -
4703 - createLabeledStatement: function (label, body) {
4704 - return {
4705 - type: Syntax.LabeledStatement,
4706 - label: label,
4707 - body: body
4708 - };
4709 - },
4710 -
4711 - createLiteral: function (token) {
4712 - var object = {
4713 - type: Syntax.Literal,
4714 - value: token.value,
4715 - raw: source.slice(token.range[0], token.range[1])
4716 - };
4717 - if (token.regex) {
4718 - object.regex = token.regex;
4719 - }
4720 - return object;
4721 - },
4722 -
4723 - createMemberExpression: function (accessor, object, property) {
4724 - return {
4725 - type: Syntax.MemberExpression,
4726 - computed: accessor === '[',
4727 - object: object,
4728 - property: property
4729 - };
4730 - },
4731 -
4732 - createNewExpression: function (callee, args) {
4733 - return {
4734 - type: Syntax.NewExpression,
4735 - callee: callee,
4736 - 'arguments': args
4737 - };
4738 - },
4739 -
4740 - createObjectExpression: function (properties) {
4741 - return {
4742 - type: Syntax.ObjectExpression,
4743 - properties: properties
4744 - };
4745 - },
4746 -
4747 - createPostfixExpression: function (operator, argument) {
4748 - return {
4749 - type: Syntax.UpdateExpression,
4750 - operator: operator,
4751 - argument: argument,
4752 - prefix: false
4753 - };
4754 - },
4755 -
4756 - createProgram: function (body) {
4757 - return {
4758 - type: Syntax.Program,
4759 - body: body
4760 - };
4761 - },
4762 -
4763 - createProperty: function (kind, key, value, method, shorthand, computed) {
4764 - return {
4765 - type: Syntax.Property,
4766 - key: key,
4767 - value: value,
4768 - kind: kind,
4769 - method: method,
4770 - shorthand: shorthand,
4771 - computed: computed
4772 - };
4773 - },
4774 -
4775 - createReturnStatement: function (argument) {
4776 - return {
4777 - type: Syntax.ReturnStatement,
4778 - argument: argument
4779 - };
4780 - },
4781 -
4782 - createSequenceExpression: function (expressions) {
4783 - return {
4784 - type: Syntax.SequenceExpression,
4785 - expressions: expressions
4786 - };
4787 - },
4788 -
4789 - createSwitchCase: function (test, consequent) {
4790 - return {
4791 - type: Syntax.SwitchCase,
4792 - test: test,
4793 - consequent: consequent
4794 - };
4795 - },
4796 -
4797 - createSwitchStatement: function (discriminant, cases) {
4798 - return {
4799 - type: Syntax.SwitchStatement,
4800 - discriminant: discriminant,
4801 - cases: cases
4802 - };
4803 - },
4804 -
4805 - createThisExpression: function () {
4806 - return {
4807 - type: Syntax.ThisExpression
4808 - };
4809 - },
4810 -
4811 - createThrowStatement: function (argument) {
4812 - return {
4813 - type: Syntax.ThrowStatement,
4814 - argument: argument
4815 - };
4816 - },
4817 -
4818 - createTryStatement: function (block, guardedHandlers, handlers, finalizer) {
4819 - return {
4820 - type: Syntax.TryStatement,
4821 - block: block,
4822 - guardedHandlers: guardedHandlers,
4823 - handlers: handlers,
4824 - finalizer: finalizer
4825 - };
4826 - },
4827 -
4828 - createUnaryExpression: function (operator, argument) {
4829 - if (operator === '++' || operator === '--') {
4830 - return {
4831 - type: Syntax.UpdateExpression,
4832 - operator: operator,
4833 - argument: argument,
4834 - prefix: true
4835 - };
4836 - }
4837 - return {
4838 - type: Syntax.UnaryExpression,
4839 - operator: operator,
4840 - argument: argument,
4841 - prefix: true
4842 - };
4843 - },
4844 -
4845 - createVariableDeclaration: function (declarations, kind) {
4846 - return {
4847 - type: Syntax.VariableDeclaration,
4848 - declarations: declarations,
4849 - kind: kind
4850 - };
4851 - },
4852 -
4853 - createVariableDeclarator: function (id, init) {
4854 - return {
4855 - type: Syntax.VariableDeclarator,
4856 - id: id,
4857 - init: init
4858 - };
4859 - },
4860 -
4861 - createWhileStatement: function (test, body) {
4862 - return {
4863 - type: Syntax.WhileStatement,
4864 - test: test,
4865 - body: body
4866 - };
4867 - },
4868 -
4869 - createWithStatement: function (object, body) {
4870 - return {
4871 - type: Syntax.WithStatement,
4872 - object: object,
4873 - body: body
4874 - };
4875 - },
4876 -
4877 - createTemplateElement: function (value, tail) {
4878 - return {
4879 - type: Syntax.TemplateElement,
4880 - value: value,
4881 - tail: tail
4882 - };
4883 - },
4884 -
4885 - createTemplateLiteral: function (quasis, expressions) {
4886 - return {
4887 - type: Syntax.TemplateLiteral,
4888 - quasis: quasis,
4889 - expressions: expressions
4890 - };
4891 - },
4892 -
4893 - createSpreadElement: function (argument) {
4894 - return {
4895 - type: Syntax.SpreadElement,
4896 - argument: argument
4897 - };
4898 - },
4899 -
4900 - createSpreadProperty: function (argument) {
4901 - return {
4902 - type: Syntax.SpreadProperty,
4903 - argument: argument
4904 - };
4905 - },
4906 -
4907 - createTaggedTemplateExpression: function (tag, quasi) {
4908 - return {
4909 - type: Syntax.TaggedTemplateExpression,
4910 - tag: tag,
4911 - quasi: quasi
4912 - };
4913 - },
4914 -
4915 - createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
4916 - var arrowExpr = {
4917 - type: Syntax.ArrowFunctionExpression,
4918 - id: null,
4919 - params: params,
4920 - defaults: defaults,
4921 - body: body,
4922 - rest: rest,
4923 - generator: false,
4924 - expression: expression
4925 - };
4926 -
4927 - if (isAsync) {
4928 - arrowExpr.async = true;
4929 - }
4930 -
4931 - return arrowExpr;
4932 - },
4933 -
4934 - createMethodDefinition: function (propertyType, kind, key, value, computed) {
4935 - return {
4936 - type: Syntax.MethodDefinition,
4937 - key: key,
4938 - value: value,
4939 - kind: kind,
4940 - 'static': propertyType === ClassPropertyType["static"],
4941 - computed: computed
4942 - };
4943 - },
4944 -
4945 - createClassProperty: function (key, typeAnnotation, computed, isStatic) {
4946 - return {
4947 - type: Syntax.ClassProperty,
4948 - key: key,
4949 - typeAnnotation: typeAnnotation,
4950 - computed: computed,
4951 - "static": isStatic
4952 - };
4953 - },
4954 -
4955 - createClassBody: function (body) {
4956 - return {
4957 - type: Syntax.ClassBody,
4958 - body: body
4959 - };
4960 - },
4961 -
4962 - createClassImplements: function (id, typeParameters) {
4963 - return {
4964 - type: Syntax.ClassImplements,
4965 - id: id,
4966 - typeParameters: typeParameters
4967 - };
4968 - },
4969 -
4970 - createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
4971 - return {
4972 - type: Syntax.ClassExpression,
4973 - id: id,
4974 - superClass: superClass,
4975 - body: body,
4976 - typeParameters: typeParameters,
4977 - superTypeParameters: superTypeParameters,
4978 - "implements": implemented
4979 - };
4980 - },
4981 -
4982 - createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
4983 - return {
4984 - type: Syntax.ClassDeclaration,
4985 - id: id,
4986 - superClass: superClass,
4987 - body: body,
4988 - typeParameters: typeParameters,
4989 - superTypeParameters: superTypeParameters,
4990 - "implements": implemented
4991 - };
4992 - },
4993 -
4994 - createModuleSpecifier: function (token) {
4995 - return {
4996 - type: Syntax.ModuleSpecifier,
4997 - value: token.value,
4998 - raw: source.slice(token.range[0], token.range[1])
4999 - };

This file is too large to show in full.