text stringlengths 9 39.2M | dir stringlengths 26 295 | lang stringclasses 185
values | created_date timestamp[us] | updated_date timestamp[us] | repo_name stringlengths 1 97 | repo_full_name stringlengths 7 106 | star int64 1k 183k | len_tokens int64 1 13.8M |
|---|---|---|---|---|---|---|---|---|
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (opts, task) {
if (!task) {
task = opts;
opts = null;
}
var _task = (0, _wrapAsync2.default)(task);
return (0, _initialParams2.default)(function (args, callback) {
function taskFn(cb) {
_task.apply(null, args.concat(cb));
}
if (opts) (0, _retry2.default)(opts, taskFn, callback);else (0, _retry2.default)(taskFn, callback);
});
};
var _retry = require('./retry');
var _retry2 = _interopRequireDefault(_retry);
var _initialParams = require('./internal/initialParams');
var _initialParams2 = _interopRequireDefault(_initialParams);
var _wrapAsync = require('./internal/wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = exports['default'];
/**
* A close relative of [`retry`]{@link module:ControlFlow.retry}. This method
* wraps a task and makes it retryable, rather than immediately calling it
* with retries.
*
* @name retryable
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.retry]{@link module:ControlFlow.retry}
* @category Control Flow
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
* options, exactly the same as from `retry`
* @param {AsyncFunction} task - the asynchronous function to wrap.
* This function will be passed any arguments passed to the returned wrapper.
* Invoked with (...args, callback).
* @returns {AsyncFunction} The wrapped function, which when invoked, will
* retry on an error, based on the parameters specified in `opts`.
* This function will accept the same parameters as `task`.
* @example
*
* async.auto({
* dep1: async.retryable(3, getFromFlakyService),
* process: ["dep1", async.retryable(3, function (results, cb) {
* maybeProcessData(results.dep1, cb);
* })]
* }, callback);
*/
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/retryable.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 504 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = retry;
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _constant = require('lodash/constant');
var _constant2 = _interopRequireDefault(_constant);
var _wrapAsync = require('./internal/wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Attempts to get a successful response from `task` no more than `times` times
* before returning an error. If the task is successful, the `callback` will be
* passed the result of the successful task. If all attempts fail, the callback
* will be passed the error and result (if any) of the final attempt.
*
* @name retry
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @see [async.retryable]{@link module:ControlFlow.retryable}
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
* object with `times` and `interval` or a number.
* * `times` - The number of attempts to make before giving up. The default
* is `5`.
* * `interval` - The time to wait between retries, in milliseconds. The
* default is `0`. The interval may also be specified as a function of the
* retry count (see example).
* * `errorFilter` - An optional synchronous function that is invoked on
* erroneous result. If it returns `true` the retry attempts will continue;
* if the function returns `false` the retry flow is aborted with the current
* attempt's error and result being returned to the final callback.
* Invoked with (err).
* * If `opts` is a number, the number specifies the number of times to retry,
* with the default interval of `0`.
* @param {AsyncFunction} task - An async function to retry.
* Invoked with (callback).
* @param {Function} [callback] - An optional callback which is called when the
* task has succeeded, or after the final failed attempt. It receives the `err`
* and `result` arguments of the last attempt at completing the `task`. Invoked
* with (err, results).
*
* @example
*
* // The `retry` function can be used as a stand-alone control flow by passing
* // a callback, as shown below:
*
* // try calling apiMethod 3 times
* async.retry(3, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod 3 times, waiting 200 ms between each retry
* async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod 10 times with exponential backoff
* // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
* async.retry({
* times: 10,
* interval: function(retryCount) {
* return 50 * Math.pow(2, retryCount);
* }
* }, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod the default 5 times no delay between each retry
* async.retry(apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod only when error condition satisfies, all other
* // errors will abort the retry control flow and return to final callback
* async.retry({
* errorFilter: function(err) {
* return err.message === 'Temporary error'; // only retry on a specific error
* }
* }, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // to retry individual methods that are not as reliable within other
* // control flow functions, use the `retryable` wrapper:
* async.auto({
* users: api.getUsers.bind(api),
* payments: async.retryable(3, api.getPayments.bind(api))
* }, function(err, results) {
* // do something with the results
* });
*
*/
function retry(opts, task, callback) {
var DEFAULT_TIMES = 5;
var DEFAULT_INTERVAL = 0;
var options = {
times: DEFAULT_TIMES,
intervalFunc: (0, _constant2.default)(DEFAULT_INTERVAL)
};
function parseTimes(acc, t) {
if (typeof t === 'object') {
acc.times = +t.times || DEFAULT_TIMES;
acc.intervalFunc = typeof t.interval === 'function' ? t.interval : (0, _constant2.default)(+t.interval || DEFAULT_INTERVAL);
acc.errorFilter = t.errorFilter;
} else if (typeof t === 'number' || typeof t === 'string') {
acc.times = +t || DEFAULT_TIMES;
} else {
throw new Error("Invalid arguments for async.retry");
}
}
if (arguments.length < 3 && typeof opts === 'function') {
callback = task || _noop2.default;
task = opts;
} else {
parseTimes(options, opts);
callback = callback || _noop2.default;
}
if (typeof task !== 'function') {
throw new Error("Invalid arguments for async.retry");
}
var _task = (0, _wrapAsync2.default)(task);
var attempt = 1;
function retryAttempt() {
_task(function (err) {
if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) {
setTimeout(retryAttempt, options.intervalFunc(attempt));
} else {
callback.apply(null, arguments);
}
});
}
retryAttempt();
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/retry.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,318 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = race;
var _isArray = require('lodash/isArray');
var _isArray2 = _interopRequireDefault(_isArray);
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _once = require('./internal/once');
var _once2 = _interopRequireDefault(_once);
var _wrapAsync = require('./internal/wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Runs the `tasks` array of functions in parallel, without waiting until the
* previous function has completed. Once any of the `tasks` complete or pass an
* error to its callback, the main `callback` is immediately called. It's
* equivalent to `Promise.race()`.
*
* @name race
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Array} tasks - An array containing [async functions]{@link AsyncFunction}
* to run. Each function can complete with an optional `result` value.
* @param {Function} callback - A callback to run once any of the functions have
* completed. This function gets an error or result from the first function that
* completed. Invoked with (err, result).
* @returns undefined
* @example
*
* async.race([
* function(callback) {
* setTimeout(function() {
* callback(null, 'one');
* }, 200);
* },
* function(callback) {
* setTimeout(function() {
* callback(null, 'two');
* }, 100);
* }
* ],
* // main callback
* function(err, result) {
* // the result will be equal to 'two' as it finishes earlier
* });
*/
function race(tasks, callback) {
callback = (0, _once2.default)(callback || _noop2.default);
if (!(0, _isArray2.default)(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
if (!tasks.length) return callback();
for (var i = 0, l = tasks.length; i < l; i++) {
(0, _wrapAsync2.default)(tasks[i])(callback);
}
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/race.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 516 |
```javascript
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var testFixtureOptions = {},
testFixture = {
'Primary Expression': {
'this\n': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'ThisExpression',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
}],
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
},
tokens: [{
type: 'Keyword',
value: 'this',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
}]
},
'null\n': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: null,
raw: 'null',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
}],
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
},
tokens: [{
type: 'Null',
value: 'null',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
}]
},
'\n 42\n\n': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
}
},
range: [5, 7],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
}
}],
range: [5, 7],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
tokens: [{
type: 'Numeric',
value: '42',
range: [5, 7],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
}
}]
},
'(1 + 2 ) * 3': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Literal',
value: 1,
raw: '1',
range: [1, 2],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 2 }
}
},
right: {
type: 'Literal',
value: 2,
raw: '2',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [1, 6],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 6 }
}
},
right: {
type: 'Literal',
value: 3,
raw: '3',
range: [11, 12],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 12 }
}
},
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
}
},
'Grouping Operator': {
'(1) + (2 ) + 3': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Literal',
value: 1,
raw: '1',
range: [1, 2],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 2 }
}
},
right: {
type: 'Literal',
value: 2,
raw: '2',
range: [7, 8],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 8 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
right: {
type: 'Literal',
value: 3,
raw: '3',
range: [14, 15],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
'4 + 5 << (6)': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '<<',
left: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Literal',
value: 4,
raw: '4',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 5,
raw: '5',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Literal',
value: 6,
raw: '6',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
}
},
'Array Initializer': {
'x = []': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
}],
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
},
tokens: [{
type: 'Identifier',
value: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
}, {
type: 'Punctuator',
value: '=',
range: [2, 3],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 3 }
}
}, {
type: 'Punctuator',
value: '[',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: ']',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
}]
},
'x = [ ]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x = [ 42 ]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: 42,
raw: '42',
range: [6, 8],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 8 }
}
}],
range: [4, 10],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 10 }
}
},
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
},
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
},
'x = [ 42, ]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: 42,
raw: '42',
range: [6, 8],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 8 }
}
}],
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'x = [ ,, 42 ]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [
null,
null,
{
type: 'Literal',
value: 42,
raw: '42',
range: [9, 11],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 11 }
}
}],
range: [4, 13],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'x = [ 1, 2, 3, ]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: 1,
raw: '1',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'Literal',
value: 2,
raw: '2',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
}, {
type: 'Literal',
value: 3,
raw: '3',
range: [12, 13],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 13 }
}
}],
range: [4, 16],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'x = [ 1, 2,, 3, ]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: 1,
raw: '1',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'Literal',
value: 2,
raw: '2',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
}, null, {
type: 'Literal',
value: 3,
raw: '3',
range: [13, 14],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 14 }
}
}],
range: [4, 17],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
'x = [ "finally", "for" ]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: 'finally',
raw: '"finally"',
range: [6, 15],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 15 }
}
}, {
type: 'Literal',
value: 'for',
raw: '"for"',
range: [17, 22],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 22 }
}
}],
range: [4, 24],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 24 }
}
},
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
' = []': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: '',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [6, 8],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'T\u203F = []': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'T\u203F',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'T\u200C = []': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'T\u200C',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'T\u200D = []': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'T\u200D',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'\u2163\u2161 = []': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: '\u2163\u2161',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'\u2163\u2161\u200A=\u2009[]': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: '\u2163\u2161',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'[",", "second"]': {
type: 'ExpressionStatement',
expression: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: ',',
raw: '","',
range: [1, 4],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 4 }
}
}, {
type: 'Literal',
value: 'second',
raw: '"second"',
range: [6, 14],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 14 }
}
}],
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
'["notAToken", "if"]': {
type: 'ExpressionStatement',
expression: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: 'notAToken',
raw: '"notAToken"',
range: [1, 12],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 12 }
}
}, {
type: 'Literal',
value: 'if',
raw: '"if"',
range: [14, 18],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 18 }
}
}],
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
},
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
}
},
'Object Initializer': {
'x = {}': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [],
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x = { }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [],
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x = { answer: 42 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'answer',
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [14, 16],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 16 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 16],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 16 }
}
}],
range: [4, 18],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 18 }
}
},
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
},
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
},
'x = { if: 42 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'if',
range: [6, 8],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 8 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
}],
range: [4, 14],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'x = { true: 42 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'true',
range: [6, 10],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 10 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [12, 14],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 14 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 14],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 14 }
}
}],
range: [4, 16],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'x = { false: 42 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'false',
range: [6, 11],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 11 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [13, 15],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 15 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 15],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 15 }
}
}],
range: [4, 17],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
'x = { null: 42 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'null',
range: [6, 10],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 10 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [12, 14],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 14 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 14],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 14 }
}
}],
range: [4, 16],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'x = { "answer": 42 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Literal',
value: 'answer',
raw: '"answer"',
range: [6, 14],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 14 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [16, 18],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 18 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 18],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 18 }
}
}],
range: [4, 20],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 20 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
'x = { x: 1, x: 2 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [
{
type: 'Property',
key: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
value: {
type: 'Literal',
value: 1,
raw: '1',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 10],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 10 }
}
},
{
type: 'Property',
key: {
type: 'Identifier',
name: 'x',
range: [12, 13],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 13 }
}
},
value: {
type: 'Literal',
value: 2,
raw: '2',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [12, 16],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 16 }
}
}
],
range: [4, 18],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 18 }
}
},
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
},
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
},
'x = { get width() { return m_width } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'width',
range: [10, 15],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ReturnStatement',
argument: {
type: 'Identifier',
name: 'm_width',
range: [27, 34],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 34 }
}
},
range: [20, 35],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 35 }
}
}],
range: [18, 36],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 36 }
}
},
rest: null,
generator: false,
expression: false,
range: [18, 36],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 36 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 36],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 36 }
}
}],
range: [4, 38],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 38 }
}
},
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
},
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
},
'x = { get undef() {} }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'undef',
range: [10, 15],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [18, 20],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 20 }
}
},
rest: null,
generator: false,
expression: false,
range: [18, 20],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 20 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 20],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 20 }
}
}],
range: [4, 22],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 22 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
'x = { get if() {} }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'if',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 17],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 17 }
}
}],
range: [4, 19],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 19 }
}
},
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
},
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
},
'x = { get true() {} }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'true',
range: [10, 14],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 14 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [17, 19],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 19 }
}
},
rest: null,
generator: false,
expression: false,
range: [17, 19],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 19 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 19],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 19 }
}
}],
range: [4, 21],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'x = { get false() {} }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'false',
range: [10, 15],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [18, 20],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 20 }
}
},
rest: null,
generator: false,
expression: false,
range: [18, 20],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 20 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 20],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 20 }
}
}],
range: [4, 22],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 22 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
'x = { get null() {} }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'null',
range: [10, 14],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 14 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [17, 19],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 19 }
}
},
rest: null,
generator: false,
expression: false,
range: [17, 19],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 19 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 19],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 19 }
}
}],
range: [4, 21],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'x = { get "undef"() {} }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Literal',
value: 'undef',
raw: '"undef"',
range: [10, 17],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 17 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [20, 22],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 22 }
}
},
rest: null,
generator: false,
expression: false,
range: [20, 22],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 22 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 22],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 22 }
}
}],
range: [4, 24],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 24 }
}
},
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
'x = { get 10() {} }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Literal',
value: 10,
raw: '10',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 17],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 17 }
}
}],
range: [4, 19],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 19 }
}
},
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
},
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
},
'x = { set width(w) { m_width = w } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'width',
range: [10, 15],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'w',
range: [16, 17],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 17 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_width',
range: [21, 28],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 28 }
}
},
right: {
type: 'Identifier',
name: 'w',
range: [31, 32],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 32 }
}
},
range: [21, 32],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 32 }
}
},
range: [21, 33],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 33 }
}
}],
range: [19, 34],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 34 }
}
},
rest: null,
generator: false,
expression: false,
range: [19, 34],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 34 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [6, 34],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 34 }
}
}],
range: [4, 36],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 36 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
}
},
'x = { set if(w) { m_if = w } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'if',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'w',
range: [13, 14],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 14 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_if',
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
},
right: {
type: 'Identifier',
name: 'w',
range: [25, 26],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 26 }
}
},
range: [18, 26],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 26 }
}
},
range: [18, 27],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 27 }
}
}],
range: [16, 28],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 28 }
}
},
rest: null,
generator: false,
expression: false,
range: [16, 28],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 28 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [6, 28],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 28 }
}
}],
range: [4, 30],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 30 }
}
},
range: [0, 30],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 30 }
}
},
range: [0, 30],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 30 }
}
},
'x = { set true(w) { m_true = w } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'true',
range: [10, 14],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 14 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'w',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_true',
range: [20, 26],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 26 }
}
},
right: {
type: 'Identifier',
name: 'w',
range: [29, 30],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 30 }
}
},
range: [20, 30],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 30 }
}
},
range: [20, 31],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 31 }
}
}],
range: [18, 32],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 32 }
}
},
rest: null,
generator: false,
expression: false,
range: [18, 32],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 32 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [6, 32],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 32 }
}
}],
range: [4, 34],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 34 }
}
},
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
'x = { set false(w) { m_false = w } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'false',
range: [10, 15],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'w',
range: [16, 17],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 17 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_false',
range: [21, 28],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 28 }
}
},
right: {
type: 'Identifier',
name: 'w',
range: [31, 32],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 32 }
}
},
range: [21, 32],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 32 }
}
},
range: [21, 33],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 33 }
}
}],
range: [19, 34],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 34 }
}
},
rest: null,
generator: false,
expression: false,
range: [19, 34],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 34 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [6, 34],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 34 }
}
}],
range: [4, 36],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 36 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
}
},
'x = { set null(w) { m_null = w } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'null',
range: [10, 14],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 14 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'w',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_null',
range: [20, 26],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 26 }
}
},
right: {
type: 'Identifier',
name: 'w',
range: [29, 30],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 30 }
}
},
range: [20, 30],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 30 }
}
},
range: [20, 31],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 31 }
}
}],
range: [18, 32],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 32 }
}
},
rest: null,
generator: false,
expression: false,
range: [18, 32],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 32 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [6, 32],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 32 }
}
}],
range: [4, 34],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 34 }
}
},
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
'x = { set "null"(w) { m_null = w } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Literal',
value: 'null',
raw: '"null"',
range: [10, 16],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 16 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'w',
range: [17, 18],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 18 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_null',
range: [22, 28],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 28 }
}
},
right: {
type: 'Identifier',
name: 'w',
range: [31, 32],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 32 }
}
},
range: [22, 32],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 32 }
}
},
range: [22, 33],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 33 }
}
}],
range: [20, 34],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 34 }
}
},
rest: null,
generator: false,
expression: false,
range: [20, 34],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 34 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [6, 34],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 34 }
}
}],
range: [4, 36],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 36 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
}
},
'x = { set 10(w) { m_null = w } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Literal',
value: 10,
raw: '10',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'w',
range: [13, 14],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 14 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_null',
range: [18, 24],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 24 }
}
},
right: {
type: 'Identifier',
name: 'w',
range: [27, 28],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 28 }
}
},
range: [18, 28],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 28 }
}
},
range: [18, 29],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 29 }
}
}],
range: [16, 30],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 30 }
}
},
rest: null,
generator: false,
expression: false,
range: [16, 30],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 30 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [6, 30],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 30 }
}
}],
range: [4, 32],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 32 }
}
},
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 32 }
}
},
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 32 }
}
},
'x = { get: 42 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'get',
range: [6, 9],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 9 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [11, 13],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 13 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 13],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 13 }
}
}],
range: [4, 15],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
'x = { set: 43 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'set',
range: [6, 9],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 9 }
}
},
value: {
type: 'Literal',
value: 43,
raw: '43',
range: [11, 13],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 13 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 13],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 13 }
}
}],
range: [4, 15],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
'x = { __proto__: 2 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: '__proto__',
range: [6, 15],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'Literal',
value: 2,
raw: '2',
range: [17, 18],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 18 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [6, 18],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 18 }
}
}],
range: [4, 20],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 20 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
'x = {"__proto__": 2 }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Literal',
value: '__proto__',
raw: '"__proto__"',
range: [5, 16],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 16 }
}
},
value: {
type: 'Literal',
value: 2,
raw: '2',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [5, 19],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 19 }
}
}],
range: [4, 21],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'x = { get width() { return m_width }, set width(width) { m_width = width; } }': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'width',
range: [10, 15],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ReturnStatement',
argument: {
type: 'Identifier',
name: 'm_width',
range: [27, 34],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 34 }
}
},
range: [20, 35],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 35 }
}
}],
range: [18, 36],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 36 }
}
},
rest: null,
generator: false,
expression: false,
range: [18, 36],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 36 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [6, 36],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 36 }
}
}, {
type: 'Property',
key: {
type: 'Identifier',
name: 'width',
range: [42, 47],
loc: {
start: { line: 1, column: 42 },
end: { line: 1, column: 47 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'width',
range: [48, 53],
loc: {
start: { line: 1, column: 48 },
end: { line: 1, column: 53 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'm_width',
range: [57, 64],
loc: {
start: { line: 1, column: 57 },
end: { line: 1, column: 64 }
}
},
right: {
type: 'Identifier',
name: 'width',
range: [67, 72],
loc: {
start: { line: 1, column: 67 },
end: { line: 1, column: 72 }
}
},
range: [57, 72],
loc: {
start: { line: 1, column: 57 },
end: { line: 1, column: 72 }
}
},
range: [57, 73],
loc: {
start: { line: 1, column: 57 },
end: { line: 1, column: 73 }
}
}],
range: [55, 75],
loc: {
start: { line: 1, column: 55 },
end: { line: 1, column: 75 }
}
},
rest: null,
generator: false,
expression: false,
range: [55, 75],
loc: {
start: { line: 1, column: 55 },
end: { line: 1, column: 75 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [38, 75],
loc: {
start: { line: 1, column: 38 },
end: { line: 1, column: 75 }
}
}],
range: [4, 77],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 77 }
}
},
range: [0, 77],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 77 }
}
},
range: [0, 77],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 77 }
}
}
},
'Comments': {
'/* block comment */ 42': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [20, 22],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 22 }
}
},
range: [20, 22],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 22 }
}
},
'42 /*The*/ /*Answer*/': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
},
trailingComments: [{
type: 'Block',
value: 'The',
range: [3, 10],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 10 }
}
}, {
type: 'Block',
value: 'Answer',
range: [11, 21],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 21 }
}
}]
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
}],
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
},
comments: [{
type: 'Block',
value: 'The',
range: [3, 10],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 10 }
}
}, {
type: 'Block',
value: 'Answer',
range: [11, 21],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 21 }
}
}]
},
'42 /*the*/ /*answer*/': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [0, 2],
trailingComments: [{
type: 'Block',
value: 'the',
range: [3, 10]
}, {
type: 'Block',
value: 'answer',
range: [11, 21]
}]
},
range: [0, 21]
}],
range: [0, 21],
comments: [{
type: 'Block',
value: 'the',
range: [3, 10]
}, {
type: 'Block',
value: 'answer',
range: [11, 21]
}]
},
'42 /* the * answer */': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'42 /* The * answer */': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
},
trailingComments: [{
type: 'Block',
value: ' The * answer ',
range: [3, 21],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 21 }
}
}]
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
}],
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
},
comments: [{
type: 'Block',
value: ' The * answer ',
range: [3, 21],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 21 }
}
}]
},
'/* multiline\ncomment\nshould\nbe\nignored */ 42': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [42, 44],
loc: {
start: { line: 5, column: 11 },
end: { line: 5, column: 13 }
}
},
range: [42, 44],
loc: {
start: { line: 5, column: 11 },
end: { line: 5, column: 13 }
}
},
'function foo(){}\n//comment\nfunction bar(){}': {
type: "Program",
body: [{
type: "FunctionDeclaration",
id: {
type: "Identifier",
name: "foo",
range: [9, 12]
},
params: [],
defaults: [],
body: {
type: "BlockStatement",
body: [],
range: [14, 16]
},
rest: null,
generator: false,
expression: false,
range: [0, 16],
trailingComments: [{
type: "Line",
value: "comment",
range: [17, 26]
}]
}, {
type: "FunctionDeclaration",
id: {
type: "Identifier",
name: "bar",
range: [36, 39]
},
params: [],
defaults: [],
body: {
type: "BlockStatement",
body: [],
range: [41, 43]
},
rest: null,
generator: false,
expression: false,
range: [27, 43],
leadingComments: [{
type: "Line",
value: "comment",
range: [17, 26]
}]
}],
range: [0, 43],
comments: [{
type: "Line",
value: "comment",
range: [17, 26]
}]
},
'/*a\r\nb*/ 42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [9, 11],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
}
},
range: [9, 11],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
leadingComments: [{
type: 'Block',
value: 'a\r\nb',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
}],
range: [9, 11],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
comments: [{
type: 'Block',
value: 'a\r\nb',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
},
'/*a\rb*/ 42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
}
},
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
leadingComments: [{
type: 'Block',
value: 'a\rb',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
}],
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
comments: [{
type: 'Block',
value: 'a\rb',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
},
'/*a\nb*/ 42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
}
},
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
leadingComments: [{
type: 'Block',
value: 'a\nb',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
}],
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
comments: [{
type: 'Block',
value: 'a\nb',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
},
'/*a\nc*/ 42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
}
},
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
leadingComments: [{
type: 'Block',
value: 'a\nc',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
}],
range: [8, 10],
loc: {
start: { line: 2, column: 4 },
end: { line: 2, column: 6 }
},
comments: [{
type: 'Block',
value: 'a\nc',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 3 }
}
}]
},
'// line comment\n42': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [16, 18],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
},
range: [16, 18],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
},
'42 // line comment': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
},
trailingComments: [{
type: 'Line',
value: ' line comment',
range: [3, 18],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 18 }
}
}]
},
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
}],
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
},
comments: [{
type: 'Line',
value: ' line comment',
range: [3, 18],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 18 }
}
}]
},
'// Hello, world!\n42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [17, 19],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
},
range: [17, 19],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
}],
range: [17, 19],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
},
comments: [{
type: 'Line',
value: ' Hello, world!',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}]
},
'// Hello, world!\n': {
type: 'Program',
body: [],
range: [17, 17],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 0 }
},
comments: [{
type: 'Line',
value: ' Hello, world!',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}]
},
'// Hallo, world!\n': {
type: 'Program',
body: [],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 0 }
},
comments: [{
type: 'Line',
value: ' Hallo, world!',
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}]
},
'//\n42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [3, 5],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
},
range: [3, 5],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
}],
range: [3, 5],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
},
comments: [{
type: 'Line',
value: '',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
}]
},
'//': {
type: 'Program',
body: [],
range: [2, 2],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 2 }
},
comments: [{
type: 'Line',
value: '',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
}]
},
'// ': {
type: 'Program',
body: [],
range: [3, 3],
comments: [{
type: 'Line',
value: ' ',
range: [0, 3]
}]
},
'/**/42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
},
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
}],
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
},
comments: [{
type: 'Block',
value: '',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
}]
},
'// Hello, world!\n\n// Another hello\n42': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [37, 39],
loc: {
start: { line: 4, column: 0 },
end: { line: 4, column: 2 }
}
},
range: [37, 39],
loc: {
start: { line: 4, column: 0 },
end: { line: 4, column: 2 }
}
}],
range: [37, 39],
loc: {
start: { line: 4, column: 0 },
end: { line: 4, column: 2 }
},
comments: [{
type: 'Line',
value: ' Hello, world!',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}, {
type: 'Line',
value: ' Another hello',
range: [18, 36],
loc: {
start: { line: 3, column: 0 },
end: { line: 3, column: 18 }
}
}]
},
'if (x) { // Some comment\ndoThat(); }': {
type: 'Program',
body: [{
type: 'IfStatement',
test: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
consequent: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'doThat',
range: [25, 31],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 6 }
}
},
'arguments': [],
range: [25, 33],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 8 }
}
},
range: [25, 34],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 9 }
}
}],
range: [7, 36],
loc: {
start: { line: 1, column: 7 },
end: { line: 2, column: 11 }
}
},
alternate: null,
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 11 }
}
}],
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 11 }
},
comments: [{
type: 'Line',
value: ' Some comment',
range: [9, 24],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 24 }
}
}]
},
'switch (answer) { case 42: /* perfect */ bingo() }': {
type: 'Program',
body: [{
type: 'SwitchStatement',
discriminant: {
type: 'Identifier',
name: 'answer',
range: [8, 14],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 14 }
}
},
cases: [{
type: 'SwitchCase',
test: {
type: 'Literal',
value: 42,
raw: '42',
range: [23, 25],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 25 }
}
},
consequent: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'bingo',
range: [41, 46],
loc: {
start: { line: 1, column: 41 },
end: { line: 1, column: 46 }
}
},
'arguments': [],
range: [41, 48],
loc: {
start: { line: 1, column: 41 },
end: { line: 1, column: 48 }
}
},
range: [41, 49],
loc: {
start: { line: 1, column: 41 },
end: { line: 1, column: 49 }
},
leadingComments: [{
type: 'Block',
value: ' perfect ',
range: [27, 40],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 40 }
}
}]
}],
range: [18, 49],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 49 }
}
}],
range: [0, 50],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 50 }
}
}],
range: [0, 50],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 50 }
},
comments: [{
type: 'Block',
value: ' perfect ',
range: [27, 40],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 40 }
}
}]
}
},
'Numeric Literals': {
'0': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0,
raw: '0',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
'42': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
'3': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 3,
raw: '3',
range: [0, 1]
},
range: [0, 1]
}],
range: [0, 1],
tokens: [{
type: 'Numeric',
value: '3',
range: [0, 1]
}]
},
'5': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 5,
raw: '5',
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
}],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
},
tokens: [{
type: 'Numeric',
value: '5',
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
}]
},
'.14': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0.14,
raw: '.14',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'3.14159': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 3.14159,
raw: '3.14159',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'6.02214179e+23': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 6.02214179e+23,
raw: '6.02214179e+23',
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'1.492417830e-10': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 1.49241783e-10,
raw: '1.492417830e-10',
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
'0x0': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0,
raw: '0x0',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'0x0;': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0,
raw: '0x0',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
'0e+100 ': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0,
raw: '0e+100',
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'0e+100': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0,
raw: '0e+100',
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'0xabc': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0xabc,
raw: '0xabc',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'0xdef': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0xdef,
raw: '0xdef',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'0X1A': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0x1A,
raw: '0X1A',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
'0x10': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0x10,
raw: '0x10',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
'0x100': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0x100,
raw: '0x100',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'0X04': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 0X04,
raw: '0X04',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
'02': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 2,
raw: '02',
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
'012': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 10,
raw: '012',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'0012': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 10,
raw: '0012',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
}
},
'String Literals': {
'"Hello"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello',
raw: '"Hello"',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'"\\n\\r\\t\\v\\b\\f\\\\\\\'\\"\\0"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: '\n\r\t\x0B\b\f\\\'"\x00',
raw: '"\\n\\r\\t\\v\\b\\f\\\\\\\'\\"\\0"',
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
'"\\u0061"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'a',
raw: '"\\u0061"',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'"\\x61"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'a',
raw: '"\\x61"',
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'"\\u00"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'u00',
raw: '"\\u00"',
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'"\\xt"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'xt',
raw: '"\\xt"',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'"Hello\\nworld"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\nworld',
raw: '"Hello\\nworld"',
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'"Hello\\\nworld"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Helloworld',
raw: '"Hello\\\nworld"',
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 6 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 6 }
}
},
'"Hello\\02World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\u0002World',
raw: '"Hello\\02World"',
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
'"Hello\\012World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\u000AWorld',
raw: '"Hello\\012World"',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'"Hello\\122World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\122World',
raw: '"Hello\\122World"',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'"Hello\\0122World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\u000A2World',
raw: '"Hello\\0122World"',
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
'"Hello\\312World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\u00CAWorld',
raw: '"Hello\\312World"',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'"Hello\\412World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\412World',
raw: '"Hello\\412World"',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'"Hello\\812World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello812World',
raw: '"Hello\\812World"',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'"Hello\\712World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\712World',
raw: '"Hello\\712World"',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'"Hello\\0World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\u0000World',
raw: '"Hello\\0World"',
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'"Hello\\\r\nworld"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Helloworld',
raw: '"Hello\\\r\nworld"',
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 6 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 6 }
}
},
'"Hello\\1World"': {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'Hello\u0001World',
raw: '"Hello\\1World"',
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
}
},
'Regular Expression Literals': {
'/p/;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: '/p/',
raw: '/p/',
regex: {
pattern: 'p',
flags: ''
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
}],
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
},
tokens: [{
type: 'RegularExpression',
value: '/p/',
regex: {
pattern: 'p',
flags: ''
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Punctuator',
value: ';',
range: [3, 4],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 4 }
}
}]
},
'[/q/]': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'ArrayExpression',
elements: [{
type: 'Literal',
value: '/q/',
raw: '/q/',
regex: {
pattern: 'q',
flags: ''
},
range: [1, 4],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 4 }
}
}],
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
}],
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
},
tokens: [{
type: 'Punctuator',
value: '[',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
}, {
type: 'RegularExpression',
value: '/q/',
regex: {
pattern: 'q',
flags: ''
},
range: [1, 4],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 4 }
}
}, {
type: 'Punctuator',
value: ']',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}]
},
'var x = /[a-z]/i': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: '/[a-z]/i',
raw: '/[a-z]/i',
regex: {
pattern: '[a-z]',
flags: 'i'
},
range: [8, 16],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
},
range: [4, 16],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 16 }
}
}],
kind: 'var',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}],
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
},
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/[a-z]/i',
regex: {
pattern: '[a-z]',
flags: 'i'
},
range: [8, 16],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
}]
},
'var x = /[a-z]/y': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: null,
raw: '/[a-z]/y',
regex: {
pattern: '[a-z]',
flags: 'y'
},
range: [8, 16],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
},
range: [4, 16],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 16 }
}
}],
kind: 'var',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}],
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
},
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/[a-z]/y',
regex: {
pattern: '[a-z]',
flags: 'y'
},
range: [8, 16],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
}]
},
'var x = /[a-z]/u': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: null,
raw: '/[a-z]/u',
regex: {
pattern: '[a-z]',
flags: 'u'
},
range: [8, 16],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
},
range: [4, 16],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 16 }
}
}],
kind: 'var',
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}],
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
},
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/[a-z]/u',
regex: {
pattern: '[a-z]',
flags: 'u'
},
range: [8, 16],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
}]
},
'var x = /[\\u{0000000000000061}-\\u{7A}]/u': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: null,
raw: '/[\\u{0000000000000061}-\\u{7A}]/u',
regex: {
pattern: '[\\u{0000000000000061}-\\u{7A}]',
flags: 'u'
},
range: [8, 40],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 40 }
}
},
range: [4, 40],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 40 }
}
}],
kind: 'var',
range: [0, 40],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 40 }
}
}],
range: [0, 40],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 40 }
},
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/[\\u{0000000000000061}-\\u{7A}]/u',
regex: {
pattern: '[\\u{0000000000000061}-\\u{7A}]',
flags: 'u'
},
range: [8, 40],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 40 }
}
}]
},
'var x = /\\u{110000}/u': {
index: 21,
lineNumber: 1,
column: 22,
message: 'Error: Line 1: Invalid regular expression'
},
'var x = /[x-z]/i': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5]
},
init: {
type: 'Literal',
value: '/[x-z]/i',
raw: '/[x-z]/i',
regex: {
pattern: '[x-z]',
flags: 'i'
},
range: [8, 16]
},
range: [4, 16]
}],
kind: 'var',
range: [0, 16]
}],
range: [0, 16],
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3]
}, {
type: 'Identifier',
value: 'x',
range: [4, 5]
}, {
type: 'Punctuator',
value: '=',
range: [6, 7]
}, {
type: 'RegularExpression',
value: '/[x-z]/i',
regex: {
pattern: '[x-z]',
flags: 'i'
},
range: [8, 16]
}]
},
'var x = /[a-c]/i': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: '/[a-c]/i',
raw: '/[a-c]/i',
regex: {
pattern: '[a-c]',
flags: 'i'
},
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
},
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 16 }
}
}],
kind: 'var',
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
}],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
},
tokens: [{
type: 'Keyword',
value: 'var',
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/[a-c]/i',
regex: {
pattern: '[a-c]',
flags: 'i'
},
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 16 }
}
}]
},
'var x = /[P QR]/i': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: '/[P QR]/i',
raw: '/[P QR]/i',
regex: {
pattern: '[P QR]',
flags: 'i'
},
range: [8, 17],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 17 }
}
},
range: [4, 17],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 17 }
}
}],
kind: 'var',
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
}],
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
},
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/[P QR]/i',
regex: {
pattern: '[P QR]',
flags: 'i'
},
range: [8, 17],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 17 }
}
}]
},
'var x = /foo\\/bar/': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: '/foo\\/bar/',
raw: '/foo\\/bar/',
regex: {
pattern: 'foo\\/bar',
flags: ''
},
range: [8, 18],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 18 }
}
},
range: [4, 18],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 18 }
}
}],
kind: 'var',
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
}],
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
},
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/foo\\/bar/',
regex: {
pattern: 'foo\\/bar',
flags: ''
},
range: [8, 18],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 18 }
}
}]
},
'var x = /=([^=\\s])+/g': {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: '/=([^=\\s])+/g',
raw: '/=([^=\\s])+/g',
regex: {
pattern: '=([^=\\s])+',
flags: 'g'
},
range: [8, 21],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 21 }
}
},
range: [4, 21],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 21 }
}
}],
kind: 'var',
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
}],
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
},
tokens: [{
type: 'Keyword',
value: 'var',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
}, {
type: 'Identifier',
value: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'Punctuator',
value: '=',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}, {
type: 'RegularExpression',
value: '/=([^=\\s])+/g',
regex: {
pattern: '=([^=\\s])+',
flags: 'g'
},
range: [8, 21],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 21 }
}
}]
},
'var x = /42/g.test': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Literal',
value: '/42/g',
raw: '/42/g',
regex: {
pattern: '42',
flags: 'g'
},
range: [8, 13],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 13 }
}
},
property: {
type: 'Identifier',
name: 'test',
range: [14, 18],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 18 }
}
},
range: [8, 18],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 18 }
}
},
range: [4, 18],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 18 }
}
}],
kind: 'var',
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
}
},
'Left-Hand-Side Expression': {
'new Button': {
type: 'ExpressionStatement',
expression: {
type: 'NewExpression',
callee: {
type: 'Identifier',
name: 'Button',
range: [4, 10],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 10 }
}
},
'arguments': [],
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
},
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
},
'new Button()': {
type: 'ExpressionStatement',
expression: {
type: 'NewExpression',
callee: {
type: 'Identifier',
name: 'Button',
range: [4, 10],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 10 }
}
},
'arguments': [],
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
'new new foo': {
type: 'ExpressionStatement',
expression: {
type: 'NewExpression',
callee: {
type: 'NewExpression',
callee: {
type: 'Identifier',
name: 'foo',
range: [8, 11],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 11 }
}
},
'arguments': [],
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
'arguments': [],
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'new new foo()': {
type: 'ExpressionStatement',
expression: {
type: 'NewExpression',
callee: {
type: 'NewExpression',
callee: {
type: 'Identifier',
name: 'foo',
range: [8, 11],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 11 }
}
},
'arguments': [],
range: [4, 13],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 13 }
}
},
'arguments': [],
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'new foo().bar()': {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
type: 'NewExpression',
callee: {
type: 'Identifier',
name: 'foo',
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
'arguments': [],
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
property: {
type: 'Identifier',
name: 'bar',
range: [10, 13],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'arguments': [],
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
},
'new foo[bar]': {
type: 'ExpressionStatement',
expression: {
type: 'NewExpression',
callee: {
type: 'MemberExpression',
computed: true,
object: {
type: 'Identifier',
name: 'foo',
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
property: {
type: 'Identifier',
name: 'bar',
range: [8, 11],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 11 }
}
},
range: [4, 12],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 12 }
}
},
'arguments': [],
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
'new foo.bar()': {
type: 'ExpressionStatement',
expression: {
type: 'NewExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'foo',
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
property: {
type: 'Identifier',
name: 'bar',
range: [8, 11],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 11 }
}
},
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
'arguments': [],
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'( new foo).bar()': {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
type: 'NewExpression',
callee: {
type: 'Identifier',
name: 'foo',
range: [6, 9],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 9 }
}
},
'arguments': [],
range: [2, 9],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 9 }
}
},
property: {
type: 'Identifier',
name: 'bar',
range: [11, 14],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'arguments': [],
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'foo(bar, baz)': {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'foo',
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'arguments': [{
type: 'Identifier',
name: 'bar',
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
}, {
type: 'Identifier',
name: 'baz',
range: [9, 12],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 12 }
}
}],
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'( foo )()': {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'foo',
range: [5, 8],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 8 }
}
},
'arguments': [],
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'universe.milkyway': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'milkyway',
range: [9, 17],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
'universe.milkyway.solarsystem': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'milkyway',
range: [9, 17],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
property: {
type: 'Identifier',
name: 'solarsystem',
range: [18, 29],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 29 }
}
},
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
'universe.milkyway.solarsystem.Earth': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'MemberExpression',
computed: false,
object: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'milkyway',
range: [9, 17],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
property: {
type: 'Identifier',
name: 'solarsystem',
range: [18, 29],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 29 }
}
},
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
property: {
type: 'Identifier',
name: 'Earth',
range: [30, 35],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 35 }
}
},
range: [0, 35],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 35 }
}
},
range: [0, 35],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 35 }
}
},
'universe[galaxyName, otherUselessName]': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: true,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'SequenceExpression',
expressions: [{
type: 'Identifier',
name: 'galaxyName',
range: [9, 19],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 19 }
}
}, {
type: 'Identifier',
name: 'otherUselessName',
range: [21, 37],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 37 }
}
}],
range: [9, 37],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 37 }
}
},
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
},
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
},
'universe[galaxyName]': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: true,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'galaxyName',
range: [9, 19],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 19 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
'universe[42].galaxies': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'MemberExpression',
computed: true,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Literal',
value: 42,
raw: '42',
range: [9, 11],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 11 }
}
},
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
property: {
type: 'Identifier',
name: 'galaxies',
range: [13, 21],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'universe(42).galaxies': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'arguments': [{
type: 'Literal',
value: 42,
raw: '42',
range: [9, 11],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 11 }
}
}],
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
property: {
type: 'Identifier',
name: 'galaxies',
range: [13, 21],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'universe(42).galaxies(14, 3, 77).milkyway': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'arguments': [{
type: 'Literal',
value: 42,
raw: '42',
range: [9, 11],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 11 }
}
}],
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
property: {
type: 'Identifier',
name: 'galaxies',
range: [13, 21],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 21 }
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'arguments': [{
type: 'Literal',
value: 14,
raw: '14',
range: [22, 24],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 24 }
}
}, {
type: 'Literal',
value: 3,
raw: '3',
range: [26, 27],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 27 }
}
}, {
type: 'Literal',
value: 77,
raw: '77',
range: [29, 31],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 31 }
}
}],
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 32 }
}
},
property: {
type: 'Identifier',
name: 'milkyway',
range: [33, 41],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 41 }
}
},
range: [0, 41],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 41 }
}
},
range: [0, 41],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 41 }
}
},
'earth.asia.Indonesia.prepareForElection(2014)': {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
type: 'MemberExpression',
computed: false,
object: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'earth',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
property: {
type: 'Identifier',
name: 'asia',
range: [6, 10],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 10 }
}
},
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
},
property: {
type: 'Identifier',
name: 'Indonesia',
range: [11, 20],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 20 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
property: {
type: 'Identifier',
name: 'prepareForElection',
range: [21, 39],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 39 }
}
},
range: [0, 39],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 39 }
}
},
'arguments': [{
type: 'Literal',
value: 2014,
raw: '2014',
range: [40, 44],
loc: {
start: { line: 1, column: 40 },
end: { line: 1, column: 44 }
}
}],
range: [0, 45],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 45 }
}
},
range: [0, 45],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 45 }
}
},
'universe.if': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'if',
range: [9, 11],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'universe.true': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'true',
range: [9, 13],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'universe.false': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'false',
range: [9, 14],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'universe.null': {
type: 'ExpressionStatement',
expression: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'universe',
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
property: {
type: 'Identifier',
name: 'null',
range: [9, 13],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}
},
'Postfix Expressions': {
'x++': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
prefix: false,
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'x--': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
prefix: false,
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'eval++': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'eval',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
prefix: false,
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'eval--': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'eval',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
prefix: false,
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'arguments++': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'arguments',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
prefix: false,
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'arguments--': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'arguments',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
prefix: false,
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
}
},
'Unary Operators': {
'++x': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'x',
range: [2, 3],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 3 }
}
},
prefix: true,
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'--x': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'x',
range: [2, 3],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 3 }
}
},
prefix: true,
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
range: [0, 3],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 3 }
}
},
'++eval': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'eval',
range: [2, 6],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 6 }
}
},
prefix: true,
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'--eval': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'eval',
range: [2, 6],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 6 }
}
},
prefix: true,
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'++arguments': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'arguments',
range: [2, 11],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 11 }
}
},
prefix: true,
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'--arguments': {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'arguments',
range: [2, 11],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 11 }
}
},
prefix: true,
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'+x': {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: '+',
argument: {
type: 'Identifier',
name: 'x',
range: [1, 2],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 2 }
}
},
prefix: true,
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
'-x': {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: '-',
argument: {
type: 'Identifier',
name: 'x',
range: [1, 2],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 2 }
}
},
prefix: true,
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
'~x': {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: '~',
argument: {
type: 'Identifier',
name: 'x',
range: [1, 2],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 2 }
}
},
prefix: true,
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
'!x': {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: '!',
argument: {
type: 'Identifier',
name: 'x',
range: [1, 2],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 2 }
}
},
prefix: true,
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
},
'void x': {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: 'void',
argument: {
type: 'Identifier',
name: 'x',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
prefix: true,
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'delete x': {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: 'delete',
argument: {
type: 'Identifier',
name: 'x',
range: [7, 8],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 8 }
}
},
prefix: true,
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'typeof x': {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: 'typeof',
argument: {
type: 'Identifier',
name: 'x',
range: [7, 8],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 8 }
}
},
prefix: true,
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
}
},
'Multiplicative Operators': {
'x * y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'x / y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '/',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'x % y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '%',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
}
},
'Additive Operators': {
'x + y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'x - y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '-',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'"use strict" + 42': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
}
},
'Bitwise Shift Operator': {
'x << y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '<<',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x >> y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '>>',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x >>> y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '>>>',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
}
},
'Relational Operators': {
'x < y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'x > y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '>',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'x <= y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '<=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x >= y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '>=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x in y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: 'in',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x instanceof y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: 'instanceof',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [13, 14],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'x < y < z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
}
},
'Equality Operators': {
'x == y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '==',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x != y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '!=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x === y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '===',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x !== y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '!==',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
}
},
'Binary Bitwise Operators': {
'x & y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '&',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'x ^ y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '^',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'x | y': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '|',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
}
},
'Binary Expressions': {
'x + y + z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x - y + z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'BinaryExpression',
operator: '-',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x + y - z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '-',
left: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x - y - z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '-',
left: {
type: 'BinaryExpression',
operator: '-',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x + y * z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x + y / z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'BinaryExpression',
operator: '/',
left: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x - y % z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '-',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'BinaryExpression',
operator: '%',
left: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x * y * z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x * y / z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '/',
left: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x * y % z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '%',
left: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x % y * z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'BinaryExpression',
operator: '%',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x << y << z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '<<',
left: {
type: 'BinaryExpression',
operator: '<<',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'x | y | z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '|',
left: {
type: 'BinaryExpression',
operator: '|',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x & y & z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '&',
left: {
type: 'BinaryExpression',
operator: '&',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x ^ y ^ z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '^',
left: {
type: 'BinaryExpression',
operator: '^',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x & y | z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '|',
left: {
type: 'BinaryExpression',
operator: '&',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x | y ^ z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '|',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'BinaryExpression',
operator: '^',
left: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x | y & z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '|',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'BinaryExpression',
operator: '&',
left: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
}
},
'Binary Logical Operators': {
'x || y': {
type: 'ExpressionStatement',
expression: {
type: 'LogicalExpression',
operator: '||',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x && y': {
type: 'ExpressionStatement',
expression: {
type: 'LogicalExpression',
operator: '&&',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'x || y || z': {
type: 'ExpressionStatement',
expression: {
type: 'LogicalExpression',
operator: '||',
left: {
type: 'LogicalExpression',
operator: '||',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'x && y && z': {
type: 'ExpressionStatement',
expression: {
type: 'LogicalExpression',
operator: '&&',
left: {
type: 'LogicalExpression',
operator: '&&',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'x || y && z': {
type: 'ExpressionStatement',
expression: {
type: 'LogicalExpression',
operator: '||',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'LogicalExpression',
operator: '&&',
left: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
range: [5, 11],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'x || y ^ z': {
type: 'ExpressionStatement',
expression: {
type: 'LogicalExpression',
operator: '||',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'BinaryExpression',
operator: '^',
left: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
right: {
type: 'Identifier',
name: 'z',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
},
range: [5, 10],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 10 }
}
},
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
},
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
}
},
'Conditional Operator': {
'y ? 1 : 2': {
type: 'ExpressionStatement',
expression: {
type: 'ConditionalExpression',
test: {
type: 'Identifier',
name: 'y',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
consequent: {
type: 'Literal',
value: 1,
raw: '1',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
alternate: {
type: 'Literal',
value: 2,
raw: '2',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x && y ? 1 : 2': {
type: 'ExpressionStatement',
expression: {
type: 'ConditionalExpression',
test: {
type: 'LogicalExpression',
operator: '&&',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
consequent: {
type: 'Literal',
value: 1,
raw: '1',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
},
alternate: {
type: 'Literal',
value: 2,
raw: '2',
range: [13, 14],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
}
},
'Assignment Operators': {
'x = 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'eval = 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'eval',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [7, 9],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'arguments = 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'arguments',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [12, 14],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'type = 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'type',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [7, 9],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x *= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '*=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x /= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '/=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x %= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '%=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x += 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '+=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x -= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '-=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x <<= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '<<=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [6, 8],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'x >>= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '>>=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [6, 8],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'x >>>= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '>>>=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [7, 9],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'x &= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '&=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x ^= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '^=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'x |= 42': {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '|=',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [5, 7],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
}
},
'Complex Expression': {
'a || b && c | d ^ e & f == g < h >>> i + j * k': {
type: 'ExpressionStatement',
expression: {
type: 'LogicalExpression',
operator: '||',
left: {
type: 'Identifier',
name: 'a',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
right: {
type: 'LogicalExpression',
operator: '&&',
left: {
type: 'Identifier',
name: 'b',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
right: {
type: 'BinaryExpression',
operator: '|',
left: {
type: 'Identifier',
name: 'c',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
right: {
type: 'BinaryExpression',
operator: '^',
left: {
type: 'Identifier',
name: 'd',
range: [14, 15],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 15 }
}
},
right: {
type: 'BinaryExpression',
operator: '&',
left: {
type: 'Identifier',
name: 'e',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
right: {
type: 'BinaryExpression',
operator: '==',
left: {
type: 'Identifier',
name: 'f',
range: [22, 23],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 23 }
}
},
right: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'g',
range: [27, 28],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 28 }
}
},
right: {
type: 'BinaryExpression',
operator: '>>>',
left: {
type: 'Identifier',
name: 'h',
range: [31, 32],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 32 }
}
},
right: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'i',
range: [37, 38],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 38 }
}
},
right: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'j',
range: [41, 42],
loc: {
start: { line: 1, column: 41 },
end: { line: 1, column: 42 }
}
},
right: {
type: 'Identifier',
name: 'k',
range: [45, 46],
loc: {
start: { line: 1, column: 45 },
end: { line: 1, column: 46 }
}
},
range: [41, 46],
loc: {
start: { line: 1, column: 41 },
end: { line: 1, column: 46 }
}
},
range: [37, 46],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 46 }
}
},
range: [31, 46],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 46 }
}
},
range: [27, 46],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 46 }
}
},
range: [22, 46],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 46 }
}
},
range: [18, 46],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 46 }
}
},
range: [14, 46],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 46 }
}
},
range: [10, 46],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 46 }
}
},
range: [5, 46],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 46 }
}
},
range: [0, 46],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 46 }
}
},
range: [0, 46],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 46 }
}
}
},
'Block': {
'{ foo }': {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'foo',
range: [2, 5],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 5 }
}
},
range: [2, 6],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 6 }
}
}],
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'{ doThis(); doThat(); }': {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'doThis',
range: [2, 8],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 8 }
}
},
'arguments': [],
range: [2, 10],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 10 }
}
},
range: [2, 11],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 11 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'doThat',
range: [12, 18],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 18 }
}
},
'arguments': [],
range: [12, 20],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 20 }
}
},
range: [12, 21],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 21 }
}
}],
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
}
},
'{}': {
type: 'BlockStatement',
body: [],
range: [0, 2],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 2 }
}
}
},
'Variable Statement': {
'var x': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: null,
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}],
kind: 'var',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'var x, y;': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: null,
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'y',
range: [7, 8],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 8 }
}
},
init: null,
range: [7, 8],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 8 }
}
}],
kind: 'var',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'var x = 42': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: 42,
raw: '42',
range: [8, 10],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 10 }
}
},
range: [4, 10],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 10 }
}
}],
kind: 'var',
range: [0, 10],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 10 }
}
},
'var eval = 42, arguments = 42': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'eval',
range: [4, 8],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 8 }
}
},
init: {
type: 'Literal',
value: 42,
raw: '42',
range: [11, 13],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 13 }
}
},
range: [4, 13],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'arguments',
range: [15, 24],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 24 }
}
},
init: {
type: 'Literal',
value: 42,
raw: '42',
range: [27, 29],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 29 }
}
},
range: [15, 29],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 29 }
}
}],
kind: 'var',
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
'var x = 14, y = 3, z = 1977': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: 'Literal',
value: 14,
raw: '14',
range: [8, 10],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 10 }
}
},
range: [4, 10],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 10 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'y',
range: [12, 13],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 13 }
}
},
init: {
type: 'Literal',
value: 3,
raw: '3',
range: [16, 17],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 17 }
}
},
range: [12, 17],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 17 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'z',
range: [19, 20],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 20 }
}
},
init: {
type: 'Literal',
value: 1977,
raw: '1977',
range: [23, 27],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 27 }
}
},
range: [19, 27],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 27 }
}
}],
kind: 'var',
range: [0, 27],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 27 }
}
},
'var implements, interface, package': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'implements',
range: [4, 14],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 14 }
}
},
init: null,
range: [4, 14],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 14 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'interface',
range: [16, 25],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 25 }
}
},
init: null,
range: [16, 25],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 25 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'package',
range: [27, 34],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 34 }
}
},
init: null,
range: [27, 34],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 34 }
}
}],
kind: 'var',
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
'var private, protected, public, static': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'private',
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
init: null,
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'protected',
range: [13, 22],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 22 }
}
},
init: null,
range: [13, 22],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 22 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'public',
range: [24, 30],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 30 }
}
},
init: null,
range: [24, 30],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 30 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'static',
range: [32, 38],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 38 }
}
},
init: null,
range: [32, 38],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 38 }
}
}],
kind: 'var',
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
}
},
'Let Statement': {
'let x': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: null,
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}],
kind: 'let',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
'{ let x }': {
type: 'BlockStatement',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
init: null,
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
}],
kind: 'let',
range: [2, 8],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 8 }
}
}],
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'{ let x = 42 }': {
type: 'BlockStatement',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
init: {
type: 'Literal',
value: 42,
raw: '42',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
}],
kind: 'let',
range: [2, 13],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 13 }
}
}],
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'{ let x = 14, y = 3, z = 1977 }': {
type: 'BlockStatement',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
init: {
type: 'Literal',
value: 14,
raw: '14',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'y',
range: [14, 15],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 15 }
}
},
init: {
type: 'Literal',
value: 3,
raw: '3',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
range: [14, 19],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 19 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'z',
range: [21, 22],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 22 }
}
},
init: {
type: 'Literal',
value: 1977,
raw: '1977',
range: [25, 29],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 29 }
}
},
range: [21, 29],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 29 }
}
}],
kind: 'let',
range: [2, 30],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 30 }
}
}],
range: [0, 31],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 31 }
}
}
},
'Const Statement': {
'const x = 42': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
init: {
type: 'Literal',
value: 42,
raw: '42',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
}],
kind: 'const',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
'{ const x = 42 }': {
type: 'BlockStatement',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
init: {
type: 'Literal',
value: 42,
raw: '42',
range: [12, 14],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 14 }
}
},
range: [8, 14],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 14 }
}
}],
kind: 'const',
range: [2, 15],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 15 }
}
}],
range: [0, 16],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 16 }
}
},
'{ const x = 14, y = 3, z = 1977 }': {
type: 'BlockStatement',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
init: {
type: 'Literal',
value: 14,
raw: '14',
range: [12, 14],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 14 }
}
},
range: [8, 14],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 14 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'y',
range: [16, 17],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 17 }
}
},
init: {
type: 'Literal',
value: 3,
raw: '3',
range: [20, 21],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 21 }
}
},
range: [16, 21],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 21 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'z',
range: [23, 24],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 24 }
}
},
init: {
type: 'Literal',
value: 1977,
raw: '1977',
range: [27, 31],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 31 }
}
},
range: [23, 31],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 31 }
}
}],
kind: 'const',
range: [2, 32],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 32 }
}
}],
range: [0, 33],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 33 }
}
}
},
'Empty Statement': {
';': {
type: 'EmptyStatement',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
}
},
'Expression Statement': {
'x': {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
},
'x, y': {
type: 'ExpressionStatement',
expression: {
type: 'SequenceExpression',
expressions: [{
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 }
}
}, {
type: 'Identifier',
name: 'y',
range: [3, 4],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 4 }
}
}],
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
'\\u0061': {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'a',
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
},
'a\\u0061': {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'aa',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'\\u0061a': {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'aa',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
'\\u0061a ': {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'aa',
range: [0, 7],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 7 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
}
},
'If Statement': {
'if (morning) goodMorning()': {
type: 'IfStatement',
test: {
type: 'Identifier',
name: 'morning',
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
consequent: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'goodMorning',
range: [13, 24],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 24 }
}
},
'arguments': [],
range: [13, 26],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 26 }
}
},
range: [13, 26],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 26 }
}
},
alternate: null,
range: [0, 26],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 26 }
}
},
'if (morning) (function(){})': {
type: 'IfStatement',
test: {
type: 'Identifier',
name: 'morning',
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
consequent: {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [24, 26],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 26 }
}
},
rest: null,
generator: false,
expression: false,
range: [14, 26],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 26 }
}
},
range: [13, 27],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 27 }
}
},
alternate: null,
range: [0, 27],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 27 }
}
},
'if (morning) var x = 0;': {
type: 'IfStatement',
test: {
type: 'Identifier',
name: 'morning',
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
consequent: {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [17, 18],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 18 }
}
},
init: {
type: 'Literal',
value: 0,
raw: '0',
range: [21, 22],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 22 }
}
},
range: [17, 22],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 22 }
}
}],
kind: 'var',
range: [13, 23],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 23 }
}
},
alternate: null,
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
}
},
'if (morning) function a(){}': {
type: 'IfStatement',
test: {
type: 'Identifier',
name: 'morning',
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
consequent: {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'a',
range: [22, 23],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 23 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [25, 27],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 27 }
}
},
rest: null,
generator: false,
expression: false,
range: [13, 27],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 27 }
}
},
alternate: null,
range: [0, 27],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 27 }
}
},
'if (morning) goodMorning(); else goodDay()': {
type: 'IfStatement',
test: {
type: 'Identifier',
name: 'morning',
range: [4, 11],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 11 }
}
},
consequent: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'goodMorning',
range: [13, 24],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 24 }
}
},
'arguments': [],
range: [13, 26],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 26 }
}
},
range: [13, 27],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 27 }
}
},
alternate: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'goodDay',
range: [33, 40],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 40 }
}
},
'arguments': [],
range: [33, 42],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 42 }
}
},
range: [33, 42],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 42 }
}
},
range: [0, 42],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 42 }
}
}
},
'Iteration Statements': {
'do keep(); while (true)': {
type: 'DoWhileStatement',
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'keep',
range: [3, 7],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 7 }
}
},
'arguments': [],
range: [3, 9],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 9 }
}
},
range: [3, 10],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 10 }
}
},
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
},
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
}
},
'do keep(); while (true);': {
type: 'DoWhileStatement',
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'keep',
range: [3, 7],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 7 }
}
},
'arguments': [],
range: [3, 9],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 9 }
}
},
range: [3, 10],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 10 }
}
},
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
},
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
'do { x++; y--; } while (x < 10)': {
type: 'DoWhileStatement',
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'x',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 }
}
},
prefix: false,
range: [5, 8],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 8 }
}
},
range: [5, 9],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 9 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'y',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
prefix: false,
range: [10, 13],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 13 }
}
},
range: [10, 14],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 14 }
}
}],
range: [3, 16],
loc: {
start: { line: 1, column: 3 },
end: { line: 1, column: 16 }
}
},
test: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'x',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
},
right: {
type: 'Literal',
value: 10,
raw: '10',
range: [28, 30],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 30 }
}
},
range: [24, 30],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 30 }
}
},
range: [0, 31],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 31 }
}
},
'{ do { } while (false) false }': {
type: 'BlockStatement',
body: [{
type: 'DoWhileStatement',
body: {
type: 'BlockStatement',
body: [],
range: [5, 8],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 8 }
}
},
test: {
type: 'Literal',
value: false,
raw: 'false',
range: [16, 21],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 21 }
}
},
range: [2, 22],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 22 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: false,
raw: 'false',
range: [23, 28],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 28 }
}
},
range: [23, 29],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 29 }
}
}],
range: [0, 30],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 30 }
}
},
'while (true) doSomething()': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'doSomething',
range: [13, 24],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 24 }
}
},
'arguments': [],
range: [13, 26],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 26 }
}
},
range: [13, 26],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 26 }
}
},
range: [0, 26],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 26 }
}
},
'while (x < 10) { x++; y--; }': {
type: 'WhileStatement',
test: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'x',
range: [7, 8],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 8 }
}
},
right: {
type: 'Literal',
value: 10,
raw: '10',
range: [11, 13],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 13 }
}
},
range: [7, 13],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 13 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'x',
range: [17, 18],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 18 }
}
},
prefix: false,
range: [17, 20],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 20 }
}
},
range: [17, 21],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 21 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'y',
range: [22, 23],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 23 }
}
},
prefix: false,
range: [22, 25],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 25 }
}
},
range: [22, 26],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 26 }
}
}],
range: [15, 28],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 28 }
}
},
range: [0, 28],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 28 }
}
},
'for(;;);': {
type: 'ForStatement',
init: null,
test: null,
update: null,
body: {
type: 'EmptyStatement',
range: [7, 8],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 8 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'for(;;){}': {
type: 'ForStatement',
init: null,
test: null,
update: null,
body: {
type: 'BlockStatement',
body: [],
range: [7, 9],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 9 }
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
'for(x = 0;;);': {
type: 'ForStatement',
init: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Literal',
value: 0,
raw: '0',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
test: null,
update: null,
body: {
type: 'EmptyStatement',
range: [12, 13],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 13 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'for(var x = 0;;);': {
type: 'ForStatement',
init: {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
init: {
type: 'Literal',
value: 0,
raw: '0',
range: [12, 13],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 13 }
}
},
range: [8, 13],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 13 }
}
}],
kind: 'var',
range: [4, 13],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 13 }
}
},
test: null,
update: null,
body: {
type: 'EmptyStatement',
range: [16, 17],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
'for(let x = 0;;);': {
type: 'ForStatement',
init: {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
init: {
type: 'Literal',
value: 0,
raw: '0',
range: [12, 13],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 13 }
}
},
range: [8, 13],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 13 }
}
}],
kind: 'let',
range: [4, 13],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 13 }
}
},
test: null,
update: null,
body: {
type: 'EmptyStatement',
range: [16, 17],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 17 }
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 }
}
},
'for(var x = 0, y = 1;;);': {
type: 'ForStatement',
init: {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
init: {
type: 'Literal',
value: 0,
raw: '0',
range: [12, 13],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 13 }
}
},
range: [8, 13],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'y',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
},
init: {
type: 'Literal',
value: 1,
raw: '1',
range: [19, 20],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 20 }
}
},
range: [15, 20],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 20 }
}
}],
kind: 'var',
range: [4, 20],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 20 }
}
},
test: null,
update: null,
body: {
type: 'EmptyStatement',
range: [23, 24],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 24 }
}
},
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
'for(x = 0; x < 42;);': {
type: 'ForStatement',
init: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Literal',
value: 0,
raw: '0',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
test: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'x',
range: [11, 12],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 12 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
range: [11, 17],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 17 }
}
},
update: null,
body: {
type: 'EmptyStatement',
range: [19, 20],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 20 }
}
},
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
'for(x = 0; x < 42; x++);': {
type: 'ForStatement',
init: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Literal',
value: 0,
raw: '0',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
test: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'x',
range: [11, 12],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 12 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
range: [11, 17],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 17 }
}
},
update: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'x',
range: [19, 20],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 20 }
}
},
prefix: false,
range: [19, 22],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 22 }
}
},
body: {
type: 'EmptyStatement',
range: [23, 24],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 24 }
}
},
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
'for(x = 0; x < 42; x++) process(x);': {
type: 'ForStatement',
init: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Literal',
value: 0,
raw: '0',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
test: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'x',
range: [11, 12],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 12 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [15, 17],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 17 }
}
},
range: [11, 17],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 17 }
}
},
update: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'x',
range: [19, 20],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 20 }
}
},
prefix: false,
range: [19, 22],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 22 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'process',
range: [24, 31],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 31 }
}
},
'arguments': [{
type: 'Identifier',
name: 'x',
range: [32, 33],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 33 }
}
}],
range: [24, 34],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 34 }
}
},
range: [24, 35],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 35 }
}
},
range: [0, 35],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 35 }
}
},
'for(x in list) process(x);': {
type: 'ForInStatement',
left: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
right: {
type: 'Identifier',
name: 'list',
range: [9, 13],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 13 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'process',
range: [15, 22],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 22 }
}
},
'arguments': [{
type: 'Identifier',
name: 'x',
range: [23, 24],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 24 }
}
}],
range: [15, 25],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 25 }
}
},
range: [15, 26],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 26 }
}
},
each: false,
range: [0, 26],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 26 }
}
},
'for (var x in list) process(x);': {
type: 'ForInStatement',
left: {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
},
init: null,
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
}],
kind: 'var',
range: [5, 10],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 10 }
}
},
right: {
type: 'Identifier',
name: 'list',
range: [14, 18],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 18 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'process',
range: [20, 27],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 27 }
}
},
'arguments': [{
type: 'Identifier',
name: 'x',
range: [28, 29],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 29 }
}
}],
range: [20, 30],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 30 }
}
},
range: [20, 31],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 31 }
}
},
each: false,
range: [0, 31],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 31 }
}
},
'for (let x in list) process(x);': {
type: 'ForInStatement',
left: {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
},
init: null,
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
}],
kind: 'let',
range: [5, 10],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 10 }
}
},
right: {
type: 'Identifier',
name: 'list',
range: [14, 18],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 18 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'process',
range: [20, 27],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 27 }
}
},
'arguments': [{
type: 'Identifier',
name: 'x',
range: [28, 29],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 29 }
}
}],
range: [20, 30],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 30 }
}
},
range: [20, 31],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 31 }
}
},
each: false,
range: [0, 31],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 31 }
}
},
'for (var i = function() { return 10 in [] } of list) process(x);': {
type: 'ForOfStatement',
left: {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'i',
range: [9, 10],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 10 }
}
},
init: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ReturnStatement',
argument: {
type: 'BinaryExpression',
operator: 'in',
left: {
type: 'Literal',
value: 10,
raw: '10',
range: [33, 35],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 35 }
}
},
right: {
type: 'ArrayExpression',
elements: [],
range: [39, 41],
loc: {
start: { line: 1, column: 39 },
end: { line: 1, column: 41 }
}
},
range: [33, 41],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 41 }
}
},
range: [26, 42],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 42 }
}
}],
range: [24, 43],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 43 }
}
},
rest: null,
generator: false,
expression: false,
range: [13, 43],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 43 }
}
},
range: [9, 43],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 43 }
}
}],
kind: 'var',
range: [5, 43],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 43 }
}
},
right: {
type: 'Identifier',
name: 'list',
range: [47, 51],
loc: {
start: { line: 1, column: 47 },
end: { line: 1, column: 51 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'process',
range: [53, 60],
loc: {
start: { line: 1, column: 53 },
end: { line: 1, column: 60 }
}
},
'arguments': [{
type: 'Identifier',
name: 'x',
range: [61, 62],
loc: {
start: { line: 1, column: 61 },
end: { line: 1, column: 62 }
}
}],
range: [53, 63],
loc: {
start: { line: 1, column: 53 },
end: { line: 1, column: 63 }
}
},
range: [53, 64],
loc: {
start: { line: 1, column: 53 },
end: { line: 1, column: 64 }
}
},
range: [0, 64],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 64 }
}
}
},
'continue statement': {
'while (true) { continue; }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [
{
type: 'ContinueStatement',
label: null,
range: [15, 24],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 24 }
}
}
],
range: [13, 26],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 26 }
}
},
range: [0, 26],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 26 }
}
},
'while (true) { continue }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [
{
type: 'ContinueStatement',
label: null,
range: [15, 24],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 24 }
}
}
],
range: [13, 25],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 25 }
}
},
range: [0, 25],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 25 }
}
},
'done: while (true) { continue done }': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: 'done',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
body: {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [13, 17],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 17 }
}
},
body: {
type: 'BlockStatement',
body: [
{
type: 'ContinueStatement',
label: {
type: 'Identifier',
name: 'done',
range: [30, 34],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 34 }
}
},
range: [21, 35],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 35 }
}
}
],
range: [19, 36],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 36 }
}
},
range: [6, 36],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 36 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
}
},
'done: while (true) { continue done; }': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: 'done',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
body: {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [13, 17],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 17 }
}
},
body: {
type: 'BlockStatement',
body: [
{
type: 'ContinueStatement',
label: {
type: 'Identifier',
name: 'done',
range: [30, 34],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 34 }
}
},
range: [21, 35],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 35 }
}
}
],
range: [19, 37],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 37 }
}
},
range: [6, 37],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 37 }
}
},
range: [0, 37],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 37 }
}
},
'__proto__: while (true) { continue __proto__; }': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: '__proto__',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
body: {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ContinueStatement',
label: {
type: 'Identifier',
name: '__proto__',
range: [35, 44],
loc: {
start: { line: 1, column: 35 },
end: { line: 1, column: 44 }
}
},
range: [26, 45],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 45 }
}
}],
range: [24, 47],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 47 }
}
},
range: [11, 47],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 47 }
}
},
range: [0, 47],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 47 }
}
}
},
'break statement': {
'while (true) { break }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [
{
type: 'BreakStatement',
label: null,
range: [15, 21],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 21 }
}
}
],
range: [13, 22],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 22 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
'done: while (true) { break done }': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: 'done',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
body: {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [13, 17],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 17 }
}
},
body: {
type: 'BlockStatement',
body: [
{
type: 'BreakStatement',
label: {
type: 'Identifier',
name: 'done',
range: [27, 31],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 31 }
}
},
range: [21, 32],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 32 }
}
}
],
range: [19, 33],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 33 }
}
},
range: [6, 33],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 33 }
}
},
range: [0, 33],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 33 }
}
},
'done: while (true) { break done; }': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: 'done',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
body: {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [13, 17],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 17 }
}
},
body: {
type: 'BlockStatement',
body: [
{
type: 'BreakStatement',
label: {
type: 'Identifier',
name: 'done',
range: [27, 31],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 31 }
}
},
range: [21, 32],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 32 }
}
}
],
range: [19, 34],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 34 }
}
},
range: [6, 34],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 34 }
}
},
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
'__proto__: while (true) { break __proto__; }': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: '__proto__',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
body: {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'BreakStatement',
label: {
type: 'Identifier',
name: '__proto__',
range: [32, 41],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 41 }
}
},
range: [26, 42],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 42 }
}
}],
range: [24, 44],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 44 }
}
},
range: [11, 44],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 44 }
}
},
range: [0, 44],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 44 }
}
}
},
'return statement': {
'(function(){ return })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [
{
type: 'ReturnStatement',
argument: null,
range: [13, 20],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 20 }
}
}
],
range: [11, 21],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 21 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 21],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 21 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
},
'(function(){ return; })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [
{
type: 'ReturnStatement',
argument: null,
range: [13, 20],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 20 }
}
}
],
range: [11, 22],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 22 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 22],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 22 }
}
},
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
}
},
'(function(){ return x; })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [
{
type: 'ReturnStatement',
argument: {
type: 'Identifier',
name: 'x',
range: [20, 21],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 21 }
}
},
range: [13, 22],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 22 }
}
}
],
range: [11, 24],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 24 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 24],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 24 }
}
},
range: [0, 25],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 25 }
}
},
'(function(){ return x * y })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [
{
type: 'ReturnStatement',
argument: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'x',
range: [20, 21],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 21 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
},
range: [20, 25],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 25 }
}
},
range: [13, 26],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 26 }
}
}
],
range: [11, 27],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 27 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 27],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 27 }
}
},
range: [0, 28],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 28 }
}
}
},
'with statement': {
'with (x) foo = bar': {
type: 'WithStatement',
object: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'foo',
range: [9, 12],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 12 }
}
},
right: {
type: 'Identifier',
name: 'bar',
range: [15, 18],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 18 }
}
},
range: [9, 18],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 18 }
}
},
range: [9, 18],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 18 }
}
},
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
},
'with (x) foo = bar;': {
type: 'WithStatement',
object: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'foo',
range: [9, 12],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 12 }
}
},
right: {
type: 'Identifier',
name: 'bar',
range: [15, 18],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 18 }
}
},
range: [9, 18],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 18 }
}
},
range: [9, 19],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 19 }
}
},
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
},
'with (x) { foo = bar }': {
type: 'WithStatement',
object: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'foo',
range: [11, 14],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 14 }
}
},
right: {
type: 'Identifier',
name: 'bar',
range: [17, 20],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 20 }
}
},
range: [11, 20],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 20 }
}
},
range: [11, 21],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 21 }
}
}],
range: [9, 22],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 22 }
}
},
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
}
}
},
'switch statement': {
'switch (x) {}': {
type: 'SwitchStatement',
discriminant: {
type: 'Identifier',
name: 'x',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 }
}
},
cases:[],
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
},
'switch (answer) { case 42: hi(); break; }': {
type: 'SwitchStatement',
discriminant: {
type: 'Identifier',
name: 'answer',
range: [8, 14],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 14 }
}
},
cases: [{
type: 'SwitchCase',
test: {
type: 'Literal',
value: 42,
raw: '42',
range: [23, 25],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 25 }
}
},
consequent: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'hi',
range: [27, 29],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 29 }
}
},
'arguments': [],
range: [27, 31],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 31 }
}
},
range: [27, 32],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 32 }
}
}, {
type: 'BreakStatement',
label: null,
range: [33, 39],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 39 }
}
}],
range: [18, 39],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 39 }
}
}],
range: [0, 41],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 41 }
}
},
'switch (answer) { case 42: hi(); break; default: break }': {
type: 'SwitchStatement',
discriminant: {
type: 'Identifier',
name: 'answer',
range: [8, 14],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 14 }
}
},
cases: [{
type: 'SwitchCase',
test: {
type: 'Literal',
value: 42,
raw: '42',
range: [23, 25],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 25 }
}
},
consequent: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'hi',
range: [27, 29],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 29 }
}
},
'arguments': [],
range: [27, 31],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 31 }
}
},
range: [27, 32],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 32 }
}
}, {
type: 'BreakStatement',
label: null,
range: [33, 39],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 39 }
}
}],
range: [18, 39],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 39 }
}
}, {
type: 'SwitchCase',
test: null,
consequent: [{
type: 'BreakStatement',
label: null,
range: [49, 55],
loc: {
start: { line: 1, column: 49 },
end: { line: 1, column: 55 }
}
}],
range: [40, 55],
loc: {
start: { line: 1, column: 40 },
end: { line: 1, column: 55 }
}
}],
range: [0, 56],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 56 }
}
}
},
'Labelled Statements': {
'start: for (;;) break start': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: 'start',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
body: {
type: 'ForStatement',
init: null,
test: null,
update: null,
body: {
type: 'BreakStatement',
label: {
type: 'Identifier',
name: 'start',
range: [22, 27],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 27 }
}
},
range: [16, 27],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 27 }
}
},
range: [7, 27],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 27 }
}
},
range: [0, 27],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 27 }
}
},
'start: while (true) break start': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: 'start',
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
},
body: {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [14, 18],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 18 }
}
},
body: {
type: 'BreakStatement',
label: {
type: 'Identifier',
name: 'start',
range: [26, 31],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 31 }
}
},
range: [20, 31],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 31 }
}
},
range: [7, 31],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 31 }
}
},
range: [0, 31],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 31 }
}
},
'__proto__: test': {
type: 'LabeledStatement',
label: {
type: 'Identifier',
name: '__proto__',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
},
body: {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'test',
range: [11, 15],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 15 }
}
},
range: [11, 15],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 15 }
}
},
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 15 }
}
}
},
'throw statement': {
'throw x;': {
type: 'ThrowStatement',
argument: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
range: [0, 8],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 8 }
}
},
'throw x * y': {
type: 'ThrowStatement',
argument: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
right: {
type: 'Identifier',
name: 'y',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 }
}
},
range: [6, 11],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 11 }
}
},
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 11 }
}
},
'throw { message: "Error" }': {
type: 'ThrowStatement',
argument: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'message',
range: [8, 15],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 15 }
}
},
value: {
type: 'Literal',
value: 'Error',
raw: '"Error"',
range: [17, 24],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 24 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [8, 24],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 24 }
}
}],
range: [6, 26],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 26 }
}
},
range: [0, 26],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 26 }
}
}
},
'try statement': {
'try { } catch (e) { }': {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [],
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'e',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
},
body: {
type: 'BlockStatement',
body: [],
range: [18, 21],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 21 }
}
},
range: [8, 21],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 21 }
}
}],
finalizer: null,
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
}
},
'try { } catch (eval) { }': {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [],
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'eval',
range: [15, 19],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 19 }
}
},
body: {
type: 'BlockStatement',
body: [],
range: [21, 24],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 24 }
}
},
range: [8, 24],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 24 }
}
}],
finalizer: null,
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
'try { } catch (arguments) { }': {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [],
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'arguments',
range: [15, 24],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 24 }
}
},
body: {
type: 'BlockStatement',
body: [],
range: [26, 29],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 29 }
}
},
range: [8, 29],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 29 }
}
}],
finalizer: null,
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
'try { } catch (e) { say(e) }': {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [],
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'e',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'say',
range: [20, 23],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 23 }
}
},
'arguments': [{
type: 'Identifier',
name: 'e',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
}],
range: [20, 26],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 26 }
}
},
range: [20, 27],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 27 }
}
}],
range: [18, 28],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 28 }
}
},
range: [8, 28],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 28 }
}
}],
finalizer: null,
range: [0, 28],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 28 }
}
},
'try { } finally { cleanup(stuff) }': {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [],
range: [4, 7],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 7 }
}
},
guardedHandlers: [],
handlers: [],
finalizer: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'cleanup',
range: [18, 25],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 25 }
}
},
'arguments': [{
type: 'Identifier',
name: 'stuff',
range: [26, 31],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 31 }
}
}],
range: [18, 32],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 32 }
}
},
range: [18, 33],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 33 }
}
}],
range: [16, 34],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 34 }
}
},
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
'try { doThat(); } catch (e) { say(e) }': {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'doThat',
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
},
'arguments': [],
range: [6, 14],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 14 }
}
},
range: [6, 15],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 15 }
}
}],
range: [4, 17],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 17 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'e',
range: [25, 26],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 26 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'say',
range: [30, 33],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 33 }
}
},
'arguments': [{
type: 'Identifier',
name: 'e',
range: [34, 35],
loc: {
start: { line: 1, column: 34 },
end: { line: 1, column: 35 }
}
}],
range: [30, 36],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 36 }
}
},
range: [30, 37],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 37 }
}
}],
range: [28, 38],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 38 }
}
},
range: [18, 38],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 38 }
}
}],
finalizer: null,
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
},
'try { doThat(); } catch (e) { say(e) } finally { cleanup(stuff) }': {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'doThat',
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
},
'arguments': [],
range: [6, 14],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 14 }
}
},
range: [6, 15],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 15 }
}
}],
range: [4, 17],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 17 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'e',
range: [25, 26],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 26 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'say',
range: [30, 33],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 33 }
}
},
'arguments': [{
type: 'Identifier',
name: 'e',
range: [34, 35],
loc: {
start: { line: 1, column: 34 },
end: { line: 1, column: 35 }
}
}],
range: [30, 36],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 36 }
}
},
range: [30, 37],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 37 }
}
}],
range: [28, 38],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 38 }
}
},
range: [18, 38],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 38 }
}
}],
finalizer: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'cleanup',
range: [49, 56],
loc: {
start: { line: 1, column: 49 },
end: { line: 1, column: 56 }
}
},
'arguments': [{
type: 'Identifier',
name: 'stuff',
range: [57, 62],
loc: {
start: { line: 1, column: 57 },
end: { line: 1, column: 62 }
}
}],
range: [49, 63],
loc: {
start: { line: 1, column: 49 },
end: { line: 1, column: 63 }
}
},
range: [49, 64],
loc: {
start: { line: 1, column: 49 },
end: { line: 1, column: 64 }
}
}],
range: [47, 65],
loc: {
start: { line: 1, column: 47 },
end: { line: 1, column: 65 }
}
},
range: [0, 65],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 65 }
}
}
},
'debugger statement': {
'debugger;': {
type: 'DebuggerStatement',
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 }
}
}
},
'Function Definition': {
'function hello() { sayHi(); }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'hello',
range: [9, 14],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 14 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'sayHi',
range: [19, 24],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 24 }
}
},
'arguments': [],
range: [19, 26],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 26 }
}
},
range: [19, 27],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 27 }
}
}],
range: [17, 29],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 29 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
'function eval() { }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'eval',
range: [9, 13],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 13 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [16, 19],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 19 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
}
},
'function arguments() { }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'arguments',
range: [9, 18],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 18 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [21, 24],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 24 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
}
},
'function test(t, t) { }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'test',
range: [9, 13],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 13 }
}
},
params: [{
type: 'Identifier',
name: 't',
range: [14, 15],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 15 }
}
}, {
type: 'Identifier',
name: 't',
range: [17, 18],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 18 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [20, 23],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 23 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
}
},
'(function test(t, t) { })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'test',
range: [10, 14],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 14 }
}
},
params: [{
type: 'Identifier',
name: 't',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
}, {
type: 'Identifier',
name: 't',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [21, 24],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 24 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 24],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 24 }
}
},
range: [0, 25],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 25 }
}
},
'function eval() { function inner() { "use strict" } }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'eval',
range: [9, 13],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 13 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'inner',
range: [27, 32],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 32 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '\"use strict\"',
range: [37, 49],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 49 }
}
},
range: [37, 50],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 50 }
}
}],
range: [35, 51],
loc: {
start: { line: 1, column: 35 },
end: { line: 1, column: 51 }
}
},
rest: null,
generator: false,
expression: false,
range: [18, 51],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 51 }
}
}],
range: [16, 53],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 53 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 53],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 53 }
}
},
'function hello(a) { sayHi(); }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'hello',
range: [9, 14],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 14 }
}
},
params: [{
type: 'Identifier',
name: 'a',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'sayHi',
range: [20, 25],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 25 }
}
},
'arguments': [],
range: [20, 27],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 27 }
}
},
range: [20, 28],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 28 }
}
}],
range: [18, 30],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 30 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 30],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 30 }
}
},
'function hello(a, b) { sayHi(); }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'hello',
range: [9, 14],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 14 }
}
},
params: [{
type: 'Identifier',
name: 'a',
range: [15, 16],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 16 }
}
}, {
type: 'Identifier',
name: 'b',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'sayHi',
range: [23, 28],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 28 }
}
},
'arguments': [],
range: [23, 30],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 30 }
}
},
range: [23, 31],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 31 }
}
}],
range: [21, 33],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 33 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 33],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 33 }
}
},
'var hi = function() { sayHi() };': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'hi',
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
},
init: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'sayHi',
range: [22, 27],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 27 }
}
},
'arguments': [],
range: [22, 29],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 29 }
}
},
range: [22, 30],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 30 }
}
}],
range: [20, 31],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 31 }
}
},
rest: null,
generator: false,
expression: false,
range: [9, 31],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 31 }
}
},
range: [4, 31],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 31 }
}
}],
kind: 'var',
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 32 }
}
},
'var hi = function eval() { };': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'hi',
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
},
init: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'eval',
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [25, 28],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 28 }
}
},
rest: null,
generator: false,
expression: false,
range: [9, 28],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 28 }
}
},
range: [4, 28],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 28 }
}
}],
kind: 'var',
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 29 }
}
},
'var hi = function arguments() { };': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'hi',
range: [4, 6],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 6 }
}
},
init: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'arguments',
range: [18, 27],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 27 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [30, 33],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 33 }
}
},
rest: null,
generator: false,
expression: false,
range: [9, 33],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 33 }
}
},
range: [4, 33],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 33 }
}
}],
kind: 'var',
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
}
},
'var hello = function hi() { sayHi() };': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'hello',
range: [4, 9],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 9 }
}
},
init: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'hi',
range: [21, 23],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 23 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'sayHi',
range: [28, 33],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 33 }
}
},
'arguments': [],
range: [28, 35],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 35 }
}
},
range: [28, 36],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 36 }
}
}],
range: [26, 37],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 37 }
}
},
rest: null,
generator: false,
expression: false,
range: [12, 37],
loc: {
start: { line: 1, column: 12 },
end: { line: 1, column: 37 }
}
},
range: [4, 37],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 37 }
}
}],
kind: 'var',
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
},
'(function(){})': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [11, 13],
loc: {
start: { line: 1, column: 11 },
end: { line: 1, column: 13 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 13],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 13 }
}
},
range: [0, 14],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 14 }
}
},
'function universe(__proto__) { }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'universe',
range: [9, 17],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 17 }
}
},
params: [{
type: 'Identifier',
name: '__proto__',
range: [18, 27],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 27 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [29, 32],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 32 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 32 }
}
},
'function test() { "use strict" + 42; }': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'test',
range: [9, 13],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 13 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [18, 30],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 30 }
}
},
right: {
type: 'Literal',
value: 42,
raw: '42',
range: [33, 35],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 35 }
}
},
range: [18, 35],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 35 }
}
},
range: [18, 36],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 36 }
}
}],
range: [16, 38],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 38 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
}
}
},
'Automatic semicolon insertion': {
'{ x\n++y }': {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'x',
range: [2, 3],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 3 }
}
},
range: [2, 3],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 3 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'y',
range: [6, 7],
loc: {
start: { line: 2, column: 2 },
end: { line: 2, column: 3 }
}
},
prefix: true,
range: [4, 7],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 3 }
}
},
range: [4, 8],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 4 }
}
}],
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 5 }
}
},
'{ x\n--y }': {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'x',
range: [2, 3],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 3 }
}
},
range: [2, 3],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 3 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'y',
range: [6, 7],
loc: {
start: { line: 2, column: 2 },
end: { line: 2, column: 3 }
}
},
prefix: true,
range: [4, 7],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 3 }
}
},
range: [4, 8],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 4 }
}
}],
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 5 }
}
},
'var x /* comment */;': {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: null,
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
}],
kind: 'var',
range: [0, 20],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 20 }
}
},
'{ var x = 14, y = 3\nz; }': {
type: 'BlockStatement',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [6, 7],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 7 }
}
},
init: {
type: 'Literal',
value: 14,
raw: '14',
range: [10, 12],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 12 }
}
},
range: [6, 12],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 12 }
}
}, {
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'y',
range: [14, 15],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 15 }
}
},
init: {
type: 'Literal',
value: 3,
raw: '3',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
range: [14, 19],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 19 }
}
}],
kind: 'var',
range: [2, 19],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 19 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'z',
range: [20, 21],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 1 }
}
},
range: [20, 22],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
}],
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 4 }
}
},
'while (true) { continue\nthere; }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ContinueStatement',
label: null,
range: [15, 23],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 23 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'there',
range: [24, 29],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 5 }
}
},
range: [24, 30],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 6 }
}
}],
range: [13, 32],
loc: {
start: { line: 1, column: 13 },
end: { line: 2, column: 8 }
}
},
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 8 }
}
},
'while (true) { continue // Comment\nthere; }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ContinueStatement',
label: null,
range: [15, 23],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 23 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'there',
range: [35, 40],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 5 }
}
},
range: [35, 41],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 6 }
}
}],
range: [13, 43],
loc: {
start: { line: 1, column: 13 },
end: { line: 2, column: 8 }
}
},
range: [0, 43],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 8 }
}
},
'while (true) { continue /* Multiline\nComment */there; }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'ContinueStatement',
label: null,
range: [15, 23],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 23 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'there',
range: [47, 52],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 15 }
}
},
range: [47, 53],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 16 }
}
}],
range: [13, 55],
loc: {
start: { line: 1, column: 13 },
end: { line: 2, column: 18 }
}
},
range: [0, 55],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 18 }
}
},
'while (true) { break\nthere; }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'BreakStatement',
label: null,
range: [15, 20],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 20 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'there',
range: [21, 26],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 5 }
}
},
range: [21, 27],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 6 }
}
}],
range: [13, 29],
loc: {
start: { line: 1, column: 13 },
end: { line: 2, column: 8 }
}
},
range: [0, 29],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 8 }
}
},
'while (true) { break // Comment\nthere; }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'BreakStatement',
label: null,
range: [15, 20],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 20 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'there',
range: [32, 37],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 5 }
}
},
range: [32, 38],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 6 }
}
}],
range: [13, 40],
loc: {
start: { line: 1, column: 13 },
end: { line: 2, column: 8 }
}
},
range: [0, 40],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 8 }
}
},
'while (true) { break /* Multiline\nComment */there; }': {
type: 'WhileStatement',
test: {
type: 'Literal',
value: true,
raw: 'true',
range: [7, 11],
loc: {
start: { line: 1, column: 7 },
end: { line: 1, column: 11 }
}
},
body: {
type: 'BlockStatement',
body: [{
type: 'BreakStatement',
label: null,
range: [15, 20],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 20 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'there',
range: [44, 49],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 15 }
}
},
range: [44, 50],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 16 }
}
}],
range: [13, 52],
loc: {
start: { line: 1, column: 13 },
end: { line: 2, column: 18 }
}
},
range: [0, 52],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 18 }
}
},
'(function(){ return\nx; })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [
{
type: 'ReturnStatement',
argument: null,
range: [13, 19],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 19 }
}
},
{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'x',
range: [20, 21],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 1 }
}
},
range: [20, 22],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
}
],
range: [11, 24],
loc: {
start: { line: 1, column: 11 },
end: { line: 2, column: 4 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 24],
loc: {
start: { line: 1, column: 1 },
end: { line: 2, column: 4 }
}
},
range: [0, 25],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 5 }
}
},
'(function(){ return // Comment\nx; })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [
{
type: 'ReturnStatement',
argument: null,
range: [13, 19],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 19 }
}
},
{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'x',
range: [31, 32],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 1 }
}
},
range: [31, 33],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 2 }
}
}
],
range: [11, 35],
loc: {
start: { line: 1, column: 11 },
end: { line: 2, column: 4 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 35],
loc: {
start: { line: 1, column: 1 },
end: { line: 2, column: 4 }
}
},
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 5 }
}
},
'(function(){ return/* Multiline\nComment */x; })': {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [
{
type: 'ReturnStatement',
argument: null,
range: [13, 19],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 19 }
}
},
{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'x',
range: [42, 43],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 11 }
}
},
range: [42, 44],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 12 }
}
}
],
range: [11, 46],
loc: {
start: { line: 1, column: 11 },
end: { line: 2, column: 14 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 46],
loc: {
start: { line: 1, column: 1 },
end: { line: 2, column: 14 }
}
},
range: [0, 47],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 15 }
}
},
'{ throw error\nerror; }': {
type: 'BlockStatement',
body: [{
type: 'ThrowStatement',
argument: {
type: 'Identifier',
name: 'error',
range: [8, 13],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 13 }
}
},
range: [2, 13],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'error',
range: [14, 19],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 5 }
}
},
range: [14, 20],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 6 }
}
}],
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 8 }
}
},
'{ throw error// Comment\nerror; }': {
type: 'BlockStatement',
body: [{
type: 'ThrowStatement',
argument: {
type: 'Identifier',
name: 'error',
range: [8, 13],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 13 }
}
},
range: [2, 13],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'error',
range: [24, 29],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 5 }
}
},
range: [24, 30],
loc: {
start: { line: 2, column: 0 },
end: { line: 2, column: 6 }
}
}],
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 8 }
}
},
'{ throw error/* Multiline\nComment */error; }': {
type: 'BlockStatement',
body: [{
type: 'ThrowStatement',
argument: {
type: 'Identifier',
name: 'error',
range: [8, 13],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 13 }
}
},
range: [2, 13],
loc: {
start: { line: 1, column: 2 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'error',
range: [36, 41],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 15 }
}
},
range: [36, 42],
loc: {
start: { line: 2, column: 10 },
end: { line: 2, column: 16 }
}
}],
range: [0, 44],
loc: {
start: { line: 1, column: 0 },
end: { line: 2, column: 18 }
}
}
},
'Source elements': {
'': {
type: 'Program',
body: [],
range: [0, 0],
loc: {
start: { line: 0, column: 0 },
end: { line: 0, column: 0 }
},
tokens: []
}
},
'Source option': {
'x + y - z': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '-',
left: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'x',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 },
source: '42.js'
}
},
right: {
type: 'Identifier',
name: 'y',
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 },
source: '42.js'
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 },
source: '42.js'
}
},
right: {
type: 'Identifier',
name: 'z',
range: [8, 9],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 9 },
source: '42.js'
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 },
source: '42.js'
}
},
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 9 },
source: '42.js'
}
},
'a + (b < (c * d)) + e': {
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'a',
range: [0, 1],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 1 },
source: '42.js'
}
},
right: {
type: 'BinaryExpression',
operator: '<',
left: {
type: 'Identifier',
name: 'b',
range: [5, 6],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 6 },
source: '42.js'
}
},
right: {
type: 'BinaryExpression',
operator: '*',
left: {
type: 'Identifier',
name: 'c',
range: [10, 11],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 11 },
source: '42.js'
}
},
right: {
type: 'Identifier',
name: 'd',
range: [14, 15],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 15 },
source: '42.js'
}
},
range: [10, 15],
loc: {
start: { line: 1, column: 10 },
end: { line: 1, column: 15 },
source: '42.js'
}
},
range: [5, 16],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 16 },
source: '42.js'
}
},
range: [0, 17],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 17 },
source: '42.js'
}
},
right: {
type: 'Identifier',
name: 'e',
range: [20, 21],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 21 },
source: '42.js'
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 },
source: '42.js'
}
},
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 },
source: '42.js'
}
}
},
'Invalid syntax': {
'{': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected end of input'
},
'}': {
index: 0,
lineNumber: 1,
column: 1,
message: 'Error: Line 1: Unexpected token }'
},
'3ea': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3in []': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3e': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3e+': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3e-': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3x': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3x0': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'0x': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'09': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'018': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'01a': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3in[]': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'0x3in[]': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'"Hello\nWorld"': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'x\\': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'x\\u005c': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'x\\u002a': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'var x = /(s/g': {
index: 13,
lineNumber: 1,
column: 14,
message: 'Error: Line 1: Invalid regular expression'
},
'a\\u': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'\\ua': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'/': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'/test': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'var x = /[z-a]/': {
index: 15,
lineNumber: 1,
column: 16,
message: 'Error: Line 1: Invalid regular expression'
},
'/test\n/': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'var x = /[a-z]/\\ux': {
index: 17,
lineNumber: 1,
column: 18,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'var x = /[a-z\n]/\\ux': {
index: 14,
lineNumber: 1,
column: 15,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'var x = /[a-z]/\\\\ux': {
index: 16,
lineNumber: 1,
column: 17,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'var x = /[P QR]/\\\\u0067': {
index: 17,
lineNumber: 1,
column: 18,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'3 = 4': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'func() = 4': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'(1 + 1) = 10': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'1++': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'1--': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'++1': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'--1': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'for((1 + 1) in list) process(x);': {
index: 11,
lineNumber: 1,
column: 12,
message: 'Error: Line 1: Invalid left-hand side in for-in'
},
'[': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected end of input'
},
'[,': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected end of input'
},
'1 + {': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Unexpected end of input'
},
'1 + { t:t ': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Unexpected end of input'
},
'1 + { t:t,': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Unexpected end of input'
},
'var x = /\n/': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'var x = "\n': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'var if = 42': {
index: 4,
lineNumber: 1,
column: 5,
message: 'Error: Line 1: Unexpected token if'
},
'i #= 42': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'i + 2 = 42': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'+i = 42': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Invalid left-hand side in assignment'
},
'1 + (': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Unexpected end of input'
},
'\n\n\n{': {
index: 4,
lineNumber: 4,
column: 2,
message: 'Error: Line 4: Unexpected end of input'
},
'\n/* Some multiline\ncomment */\n)': {
index: 30,
lineNumber: 4,
column: 1,
message: 'Error: Line 4: Unexpected token )'
},
'{ set 1 }': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Unexpected number'
},
'{ get 2 }': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Unexpected number'
},
'({ set: s(if) { } })': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Unexpected token if'
},
'({ set s(.) { } })': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token .'
},
'({ set: s() { } })': {
index: 12,
lineNumber: 1,
column: 13,
message: 'Error: Line 1: Unexpected token {'
},
'({ set: s(a, b) { } })': {
index: 16,
lineNumber: 1,
column: 17,
message: 'Error: Line 1: Unexpected token {'
},
'({ get: g(d) { } })': {
index: 13,
lineNumber: 1,
column: 14,
message: 'Error: Line 1: Unexpected token {'
},
'({ get i() { }, i: 42 })': {
index: 21,
lineNumber: 1,
column: 22,
message: 'Error: Line 1: Object literal may not have data and accessor property with the same name'
},
'({ i: 42, get i() { } })': {
index: 21,
lineNumber: 1,
column: 22,
message: 'Error: Line 1: Object literal may not have data and accessor property with the same name'
},
'({ set i(x) { }, i: 42 })': {
index: 22,
lineNumber: 1,
column: 23,
message: 'Error: Line 1: Object literal may not have data and accessor property with the same name'
},
'({ i: 42, set i(x) { } })': {
index: 22,
lineNumber: 1,
column: 23,
message: 'Error: Line 1: Object literal may not have data and accessor property with the same name'
},
'({ get i() { }, get i() { } })': {
index: 27,
lineNumber: 1,
column: 28,
message: 'Error: Line 1: Object literal may not have multiple get/set accessors with the same name'
},
'({ set i(x) { }, set i(x) { } })': {
index: 29,
lineNumber: 1,
column: 30,
message: 'Error: Line 1: Object literal may not have multiple get/set accessors with the same name'
},
'function t(if) { }': {
index: 11,
lineNumber: 1,
column: 12,
message: 'Error: Line 1: Unexpected token if'
},
'function t(true) { }': {
index: 11,
lineNumber: 1,
column: 12,
message: 'Error: Line 1: Unexpected token true'
},
'function t(false) { }': {
index: 11,
lineNumber: 1,
column: 12,
message: 'Error: Line 1: Unexpected token false'
},
'function t(null) { }': {
index: 11,
lineNumber: 1,
column: 12,
message: 'Error: Line 1: Unexpected token null'
},
'function null() { }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token null'
},
'function true() { }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token true'
},
'function false() { }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token false'
},
'function if() { }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token if'
},
'a b;': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected identifier'
},
'if.a;': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token .'
},
'a if;': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token if'
},
'a class;': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected reserved word'
},
'break\n': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Illegal break statement'
},
'break 1;': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Unexpected number'
},
'continue\n': {
index: 8,
lineNumber: 1,
column: 9,
message: 'Error: Line 1: Illegal continue statement'
},
'continue 2;': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected number'
},
'throw': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Unexpected end of input'
},
'throw;': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Unexpected token ;'
},
'throw\n': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Illegal newline after throw'
},
'for (var i, i2 in {});': {
index: 15,
lineNumber: 1,
column: 16,
message: 'Error: Line 1: Unexpected token in'
},
'for ((i in {}));': {
index: 14,
lineNumber: 1,
column: 15,
message: 'Error: Line 1: Unexpected token )'
},
'for (i + 1 in {});': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Invalid left-hand side in for-in'
},
'for (+i in {});': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Invalid left-hand side in for-in'
},
'if(false)': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected end of input'
},
'if(false) doThis(); else': {
index: 24,
lineNumber: 1,
column: 25,
message: 'Error: Line 1: Unexpected end of input'
},
'do': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected end of input'
},
'while(false)': {
index: 12,
lineNumber: 1,
column: 13,
message: 'Error: Line 1: Unexpected end of input'
},
'for(;;)': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Unexpected end of input'
},
'with(x)': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Unexpected end of input'
},
'try { }': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Missing catch or finally after try'
},
'\u203F = 10': {
index: 0,
lineNumber: 1,
column: 1,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'const x = 12, y;': {
index: 15,
lineNumber: 1,
column: 16,
message: 'Error: Line 1: Const must be initialized'
},
'const x, y = 12;': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Const must be initialized'
},
'const x;': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Const must be initialized'
},
'if(true) let a = 1;': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token let'
},
'if(true) const a = 1;': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token const'
},
'switch (c) { default: default: }': {
index: 30,
lineNumber: 1,
column: 31,
message: 'Error: Line 1: More than one default clause in switch statement'
},
'new X()."s"': {
index: 8,
lineNumber: 1,
column: 9,
message: 'Error: Line 1: Unexpected string'
},
'/*': {
index: 2,
lineNumber: 1,
column: 3,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'/*\n\n\n': {
index: 5,
lineNumber: 4,
column: 1,
message: 'Error: Line 4: Unexpected token ILLEGAL'
},
'/**': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'/*\n\n*': {
index: 5,
lineNumber: 3,
column: 2,
message: 'Error: Line 3: Unexpected token ILLEGAL'
},
'/*hello': {
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'/*hello *': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'\n]': {
index: 1,
lineNumber: 2,
column: 1,
message: 'Error: Line 2: Unexpected token ]'
},
'\r]': {
index: 1,
lineNumber: 2,
column: 1,
message: 'Error: Line 2: Unexpected token ]'
},
'\r\n]': {
index: 2,
lineNumber: 2,
column: 1,
message: 'Error: Line 2: Unexpected token ]'
},
'\n\r]': {
index: 2,
lineNumber: 3,
column: 1,
message: 'Error: Line 3: Unexpected token ]'
},
'//\r\n]': {
index: 4,
lineNumber: 2,
column: 1,
message: 'Error: Line 2: Unexpected token ]'
},
'//\n\r]': {
index: 4,
lineNumber: 3,
column: 1,
message: 'Error: Line 3: Unexpected token ]'
},
'/a\\\n/': {
index: 4,
lineNumber: 1,
column: 5,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'//\r \n]': {
index: 5,
lineNumber: 3,
column: 1,
message: 'Error: Line 3: Unexpected token ]'
},
'/*\r\n*/]': {
index: 6,
lineNumber: 2,
column: 3,
message: 'Error: Line 2: Unexpected token ]'
},
'/*\n\r*/]': {
index: 6,
lineNumber: 3,
column: 3,
message: 'Error: Line 3: Unexpected token ]'
},
'/*\r \n*/]': {
index: 7,
lineNumber: 3,
column: 3,
message: 'Error: Line 3: Unexpected token ]'
},
'\\\\': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'\\u005c': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'\\x': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'\\u0000': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'\u200C = []': {
index: 0,
lineNumber: 1,
column: 1,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'\u200D = []': {
index: 0,
lineNumber: 1,
column: 1,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'"\\': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'"\\u': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected token ILLEGAL'
},
'try { } catch() {}': {
index: 14,
lineNumber: 1,
column: 15,
message: 'Error: Line 1: Unexpected token )'
},
'return': {
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Illegal return statement'
},
'break': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Illegal break statement'
},
'continue': {
index: 8,
lineNumber: 1,
column: 9,
message: 'Error: Line 1: Illegal continue statement'
},
'switch (x) { default: continue; }': {
index: 31,
lineNumber: 1,
column: 32,
message: 'Error: Line 1: Illegal continue statement'
},
'do { x } *': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Unexpected token *'
},
'while (true) { break x; }': {
index: 22,
lineNumber: 1,
column: 23,
message: 'Error: Line 1: Undefined label \'x\''
},
'while (true) { continue x; }': {
index: 25,
lineNumber: 1,
column: 26,
message: 'Error: Line 1: Undefined label \'x\''
},
'x: while (true) { (function () { break x; }); }': {
index: 40,
lineNumber: 1,
column: 41,
message: 'Error: Line 1: Undefined label \'x\''
},
'x: while (true) { (function () { continue x; }); }': {
index: 43,
lineNumber: 1,
column: 44,
message: 'Error: Line 1: Undefined label \'x\''
},
'x: while (true) { (function () { break; }); }': {
index: 39,
lineNumber: 1,
column: 40,
message: 'Error: Line 1: Illegal break statement'
},
'x: while (true) { (function () { continue; }); }': {
index: 42,
lineNumber: 1,
column: 43,
message: 'Error: Line 1: Illegal continue statement'
},
'x: while (true) { x: while (true) { } }': {
index: 20,
lineNumber: 1,
column: 21,
message: 'Error: Line 1: Label \'x\' has already been declared'
},
'(function () { \'use strict\'; delete i; }())': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Delete of an unqualified identifier in strict mode.'
},
'(function () { \'use strict\'; with (i); }())': {
index: 28,
lineNumber: 1,
column: 29,
message: 'Error: Line 1: Strict mode code may not include a with statement'
},
'function hello() {\'use strict\'; ({ i: 42, i: 42 }) }': {
index: 47,
lineNumber: 1,
column: 48,
message: 'Error: Line 1: Duplicate data property in object literal not allowed in strict mode'
},
'function hello() {\'use strict\'; ({ hasOwnProperty: 42, hasOwnProperty: 42 }) }': {
index: 73,
lineNumber: 1,
column: 74,
message: 'Error: Line 1: Duplicate data property in object literal not allowed in strict mode'
},
'function hello() {\'use strict\'; var eval = 10; }': {
index: 40,
lineNumber: 1,
column: 41,
message: 'Error: Line 1: Variable name may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; var arguments = 10; }': {
index: 45,
lineNumber: 1,
column: 46,
message: 'Error: Line 1: Variable name may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; try { } catch (eval) { } }': {
index: 51,
lineNumber: 1,
column: 52,
message: 'Error: Line 1: Catch variable may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; try { } catch (arguments) { } }': {
index: 56,
lineNumber: 1,
column: 57,
message: 'Error: Line 1: Catch variable may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; eval = 10; }': {
index: 32,
lineNumber: 1,
column: 33,
message: 'Error: Line 1: Assignment to eval or arguments is not allowed in strict mode'
},
'function hello() {\'use strict\'; arguments = 10; }': {
index: 32,
lineNumber: 1,
column: 33,
message: 'Error: Line 1: Assignment to eval or arguments is not allowed in strict mode'
},
'function hello() {\'use strict\'; ++eval; }': {
index: 38,
lineNumber: 1,
column: 39,
message: 'Error: Line 1: Prefix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; --eval; }': {
index: 38,
lineNumber: 1,
column: 39,
message: 'Error: Line 1: Prefix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; ++arguments; }': {
index: 43,
lineNumber: 1,
column: 44,
message: 'Error: Line 1: Prefix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; --arguments; }': {
index: 43,
lineNumber: 1,
column: 44,
message: 'Error: Line 1: Prefix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; eval++; }': {
index: 36,
lineNumber: 1,
column: 37,
message: 'Error: Line 1: Postfix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; eval--; }': {
index: 36,
lineNumber: 1,
column: 37,
message: 'Error: Line 1: Postfix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; arguments++; }': {
index: 41,
lineNumber: 1,
column: 42,
message: 'Error: Line 1: Postfix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; arguments--; }': {
index: 41,
lineNumber: 1,
column: 42,
message: 'Error: Line 1: Postfix increment/decrement may not have eval or arguments operand in strict mode'
},
'function hello() {\'use strict\'; function eval() { } }': {
index: 41,
lineNumber: 1,
column: 42,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; function arguments() { } }': {
index: 41,
lineNumber: 1,
column: 42,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'function eval() {\'use strict\'; }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'function arguments() {\'use strict\'; }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; (function eval() { }()) }': {
index: 42,
lineNumber: 1,
column: 43,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; (function arguments() { }()) }': {
index: 42,
lineNumber: 1,
column: 43,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'(function eval() {\'use strict\'; })()': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'(function arguments() {\'use strict\'; })()': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'function hello() {\'use strict\'; ({ s: function eval() { } }); }': {
index: 47,
lineNumber: 1,
column: 48,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'(function package() {\'use strict\'; })()': {
index: 10,
lineNumber: 1,
column: 11,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() {\'use strict\'; ({ i: 10, set s(eval) { } }); }': {
index: 48,
lineNumber: 1,
column: 49,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'function hello() {\'use strict\'; ({ set s(eval) { } }); }': {
index: 41,
lineNumber: 1,
column: 42,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'function hello() {\'use strict\'; ({ s: function s(eval) { } }); }': {
index: 49,
lineNumber: 1,
column: 50,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'function hello(eval) {\'use strict\';}': {
index: 15,
lineNumber: 1,
column: 16,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'function hello(arguments) {\'use strict\';}': {
index: 15,
lineNumber: 1,
column: 16,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'function hello() { \'use strict\'; function inner(eval) {} }': {
index: 48,
lineNumber: 1,
column: 49,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'function hello() { \'use strict\'; function inner(arguments) {} }': {
index: 48,
lineNumber: 1,
column: 49,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
' "\\1"; \'use strict\';': {
index: 1,
lineNumber: 1,
column: 2,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { \'use strict\'; "\\1"; }': {
index: 33,
lineNumber: 1,
column: 34,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { \'use strict\'; 021; }': {
index: 33,
lineNumber: 1,
column: 34,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { \'use strict\'; ({ "\\1": 42 }); }': {
index: 36,
lineNumber: 1,
column: 37,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { \'use strict\'; ({ 021: 42 }); }': {
index: 36,
lineNumber: 1,
column: 37,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { "octal directive\\1"; "use strict"; }': {
index: 19,
lineNumber: 1,
column: 20,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { "octal directive\\1"; "octal directive\\2"; "use strict"; }': {
index: 19,
lineNumber: 1,
column: 20,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { "use strict"; function inner() { "octal directive\\1"; } }': {
index: 52,
lineNumber: 1,
column: 53,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
},
'function hello() { "use strict"; var implements; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var interface; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var package; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var private; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var protected; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var public; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var static; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var yield; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello() { "use strict"; var let; }': {
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function hello(static) { "use strict"; }': {
index: 15,
lineNumber: 1,
column: 16,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function static() { "use strict"; }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function eval(a) { "use strict"; }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'function arguments(a) { "use strict"; }': {
index: 9,
lineNumber: 1,
column: 10,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
},
'var yield': {
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "yield",
"range": [
4,
9
],
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 9
}
}
},
"init": null,
"range": [
4,
9
],
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 9
}
}
}
],
"kind": "var",
"range": [
0,
9
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
}
},
'var let': {
index: 4,
lineNumber: 1,
column: 5,
message: 'Error: Line 1: Unexpected token let'
},
'"use strict"; function static() { }': {
index: 23,
lineNumber: 1,
column: 24,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function a(t, t) { "use strict"; }': {
index: 14,
lineNumber: 1,
column: 15,
message: 'Error: Line 1: Strict mode function may not have duplicate parameter names'
},
'function a(eval) { "use strict"; }': {
index: 11,
lineNumber: 1,
column: 12,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'function a(package) { "use strict"; }': {
index: 11,
lineNumber: 1,
column: 12,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'function a() { "use strict"; function b(t, t) { }; }': {
index: 43,
lineNumber: 1,
column: 44,
message: 'Error: Line 1: Strict mode function may not have duplicate parameter names'
},
'(function a(t, t) { "use strict"; })': {
index: 15,
lineNumber: 1,
column: 16,
message: 'Error: Line 1: Strict mode function may not have duplicate parameter names'
},
'function a() { "use strict"; (function b(t, t) { }); }': {
index: 44,
lineNumber: 1,
column: 45,
message: 'Error: Line 1: Strict mode function may not have duplicate parameter names'
},
'(function a(eval) { "use strict"; })': {
index: 12,
lineNumber: 1,
column: 13,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
},
'(function a(package) { "use strict"; })': {
index: 12,
lineNumber: 1,
column: 13,
message: 'Error: Line 1: Use of future reserved word in strict mode'
},
'__proto__: __proto__: 42;': {
index: 21,
lineNumber: 1,
column: 22,
message: 'Error: Line 1: Label \'__proto__\' has already been declared'
},
'"use strict"; function t(__proto__, __proto__) { }': {
index: 36,
lineNumber: 1,
column: 37,
message: 'Error: Line 1: Strict mode function may not have duplicate parameter names'
},
'"use strict"; x = { __proto__: 42, __proto__: 43 }': {
index: 48,
lineNumber: 1,
column: 49,
message: 'Error: Line 1: Duplicate data property in object literal not allowed in strict mode'
},
'"use strict"; x = { get __proto__() { }, __proto__: 43 }': {
index: 54,
lineNumber: 1,
column: 55,
message: 'Error: Line 1: Object literal may not have data and accessor property with the same name'
},
'var': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected end of input'
},
'let': {
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Unexpected end of input'
},
'const': {
index: 5,
lineNumber: 1,
column: 6,
message: 'Error: Line 1: Unexpected end of input'
},
'{ ; ; ': {
index: 8,
lineNumber: 1,
column: 9,
message: 'Error: Line 1: Unexpected end of input'
},
'function t() { ; ; ': {
index: 21,
lineNumber: 1,
column: 22,
message: 'Error: Line 1: Unexpected end of input'
}
},
'Tokenize': {
'tokenize(/42/)': [
{
"type": "Identifier",
"value": "tokenize",
"range": [
0,
8
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
8,
9
],
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "RegularExpression",
"value": "/42/",
"regex": {
"pattern": "42",
"flags": ""
},
"range": [
9,
13
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 13
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
13,
14
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
}
}
}
],
'if (false) { /42/ }': [
{
"type": "Keyword",
"value": "if",
"range": [
0,
2
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 2
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
3,
4
],
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "Boolean",
"value": "false",
"range": [
4,
9
],
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
9,
10
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
}
},
{
"type": "Punctuator",
"value": "{",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
},
{
"type": "RegularExpression",
"value": "/42/",
"regex": {
"pattern": "42",
"flags": ""
},
"range": [
13,
17
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 17
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
18,
19
],
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
}
}
}
],
'with (false) /42/': [
{
"type": "Keyword",
"value": "with",
"range": [
0,
4
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
5,
6
],
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
}
}
},
{
"type": "Boolean",
"value": "false",
"range": [
6,
11
],
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 11
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
},
{
"type": "RegularExpression",
"value": "/42/",
"regex": {
"pattern": "42",
"flags": ""
},
"range": [
13,
17
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 17
}
}
}
],
'(false) /42/': [
{
"type": "Punctuator",
"value": "(",
"range": [
0,
1
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
}
},
{
"type": "Boolean",
"value": "false",
"range": [
1,
6
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
6,
7
],
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
}
},
{
"type": "Punctuator",
"value": "/",
"range": [
8,
9
],
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "Numeric",
"value": "42",
"range": [
9,
11
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 11
}
}
},
{
"type": "Punctuator",
"value": "/",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
}
],
'function f(){} /42/': [
{
"type": "Keyword",
"value": "function",
"range": [
0,
8
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
},
{
"type": "Identifier",
"value": "f",
"range": [
9,
10
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
},
{
"type": "Punctuator",
"value": "{",
"range": [
12,
13
],
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 13
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
13,
14
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
}
}
},
{
"type": "RegularExpression",
"value": "/42/",
"regex": {
"pattern": "42",
"flags": ""
},
"range": [
15,
19
],
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 19
}
}
}
],
'function(){} /42': [
{
"type": "Keyword",
"value": "function",
"range": [
0,
8
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
8,
9
],
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
9,
10
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
}
},
{
"type": "Punctuator",
"value": "{",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
},
{
"type": "Punctuator",
"value": "/",
"range": [
13,
14
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
}
}
},
{
"type": "Numeric",
"value": "42",
"range": [
14,
16
],
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 16
}
}
}
],
'{} /42': [
{
"type": "Punctuator",
"value": "{",
"range": [
0,
1
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
1,
2
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
}
}
},
{
"type": "Punctuator",
"value": "/",
"range": [
3,
4
],
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "Numeric",
"value": "42",
"range": [
4,
6
],
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 6
}
}
}
],
'[function(){} /42]': [
{
"type": "Punctuator",
"value": "[",
"range": [
0,
1
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
}
},
{
"type": "Keyword",
"value": "function",
"range": [
1,
9
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
9,
10
],
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
},
{
"type": "Punctuator",
"value": "{",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
12,
13
],
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 13
}
}
},
{
"type": "Punctuator",
"value": "/",
"range": [
14,
15
],
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
}
}
},
{
"type": "Numeric",
"value": "42",
"range": [
15,
17
],
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 17
}
}
},
{
"type": "Punctuator",
"value": "]",
"range": [
17,
18
],
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 18
}
}
}
],
';function f(){} /42/': [
{
"type": "Punctuator",
"value": ";",
"range": [
0,
1
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
}
},
{
"type": "Keyword",
"value": "function",
"range": [
1,
9
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "Identifier",
"value": "f",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
11,
12
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
12,
13
],
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 13
}
}
},
{
"type": "Punctuator",
"value": "{",
"range": [
13,
14
],
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
14,
15
],
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
}
}
},
{
"type": "RegularExpression",
"value": "/42/",
"regex": {
"pattern": "42",
"flags": ""
},
"range": [
16,
20
],
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
}
}
}
],
'void /42/': [
{
"type": "Keyword",
"value": "void",
"range": [
0,
4
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "RegularExpression",
"value": "/42/",
"regex": {
"pattern": "42",
"flags": ""
},
"range": [
5,
9
],
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 9
}
}
}
],
'/42/': [
{
"type": "RegularExpression",
"value": "/42/",
"regex": {
"pattern": "42",
"flags": ""
},
"range": [
0,
4
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
}
}
],
'foo[/42]': [
{
"type": "Identifier",
"value": "foo",
"range": [
0,
3
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
}
},
{
"type": "Punctuator",
"value": "[",
"range": [
3,
4
],
"loc": {
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 4
}
}
}
],
'': [],
'/42': {
tokenize: true,
index: 3,
lineNumber: 1,
column: 4,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'foo[/42': {
tokenize: true,
index: 7,
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Invalid regular expression: missing /'
},
'this / 100;': [
{
"type": "Keyword",
"value": "this",
"range": [
0,
4
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "Punctuator",
"value": "/",
"range": [
5,
6
],
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
}
}
},
{
"type": "Numeric",
"value": "100",
"range": [
7,
10
],
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 10
}
}
},
{
"type": "Punctuator",
"value": ";",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
}
]
},
'API': {
'parse()': {
call: 'parse',
args: [],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'undefined'
}
}]
}
},
'parse(null)': {
call: 'parse',
args: [null],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: null,
raw: 'null'
}
}]
}
},
'parse(42)': {
call: 'parse',
args: [42],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42'
}
}]
}
},
'parse(true)': {
call: 'parse',
args: [true],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: true,
raw: 'true'
}
}]
}
},
'parse(undefined)': {
call: 'parse',
args: [void 0],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'undefined'
}
}]
}
},
'parse(new String("test"))': {
call: 'parse',
args: [new String('test')],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Identifier',
name: 'test'
}
}]
}
},
'parse(new Number(42))': {
call: 'parse',
args: [new Number(42)],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 42,
raw: '42'
}
}]
}
},
'parse(new Boolean(true))': {
call: 'parse',
args: [new Boolean(true)],
result: {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: true,
raw: 'true'
}
}]
}
},
'Syntax': {
property: 'Syntax',
result: {
AnyTypeAnnotation: 'AnyTypeAnnotation',
ArrayExpression: 'ArrayExpression',
ArrayPattern: 'ArrayPattern',
ArrayTypeAnnotation: 'ArrayTypeAnnotation',
ArrowFunctionExpression: 'ArrowFunctionExpression',
AssignmentExpression: 'AssignmentExpression',
BinaryExpression: 'BinaryExpression',
BlockStatement: 'BlockStatement',
BooleanTypeAnnotation: 'BooleanTypeAnnotation',
BreakStatement: 'BreakStatement',
CallExpression: 'CallExpression',
CatchClause: 'CatchClause',
ClassBody: 'ClassBody',
ClassDeclaration: 'ClassDeclaration',
ClassExpression: 'ClassExpression',
ClassImplements: 'ClassImplements',
ClassProperty: 'ClassProperty',
ComprehensionBlock: 'ComprehensionBlock',
ComprehensionExpression: 'ComprehensionExpression',
ConditionalExpression: 'ConditionalExpression',
ContinueStatement: 'ContinueStatement',
DebuggerStatement: 'DebuggerStatement',
DeclareClass: 'DeclareClass',
DeclareFunction: 'DeclareFunction',
DeclareModule: 'DeclareModule',
DeclareVariable: 'DeclareVariable',
DoWhileStatement: 'DoWhileStatement',
EmptyStatement: 'EmptyStatement',
ExportDeclaration: 'ExportDeclaration',
ExportBatchSpecifier: 'ExportBatchSpecifier',
ExportSpecifier: 'ExportSpecifier',
ExpressionStatement: 'ExpressionStatement',
ForInStatement: 'ForInStatement',
ForOfStatement: 'ForOfStatement',
ForStatement: 'ForStatement',
FunctionDeclaration: 'FunctionDeclaration',
FunctionExpression: 'FunctionExpression',
FunctionTypeAnnotation: 'FunctionTypeAnnotation',
FunctionTypeParam: 'FunctionTypeParam',
GenericTypeAnnotation: 'GenericTypeAnnotation',
Identifier: 'Identifier',
IfStatement: 'IfStatement',
ImportDeclaration: 'ImportDeclaration',
ImportDefaultSpecifier: "ImportDefaultSpecifier",
ImportNamespaceSpecifier: "ImportNamespaceSpecifier",
ImportSpecifier: 'ImportSpecifier',
InterfaceDeclaration: 'InterfaceDeclaration',
InterfaceExtends: 'InterfaceExtends',
IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
LabeledStatement: 'LabeledStatement',
Literal: 'Literal',
LogicalExpression: 'LogicalExpression',
MemberExpression: 'MemberExpression',
MethodDefinition: 'MethodDefinition',
NewExpression: 'NewExpression',
NullableTypeAnnotation: 'NullableTypeAnnotation',
NumberTypeAnnotation: 'NumberTypeAnnotation',
ObjectExpression: 'ObjectExpression',
ObjectPattern: 'ObjectPattern',
ObjectTypeAnnotation: 'ObjectTypeAnnotation',
ObjectTypeCallProperty: 'ObjectTypeCallProperty',
ObjectTypeIndexer: 'ObjectTypeIndexer',
ObjectTypeProperty: 'ObjectTypeProperty',
Program: 'Program',
Property: 'Property',
QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
ReturnStatement: 'ReturnStatement',
SequenceExpression: 'SequenceExpression',
SpreadElement: 'SpreadElement',
SpreadProperty: 'SpreadProperty',
StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
StringTypeAnnotation: 'StringTypeAnnotation',
SwitchCase: 'SwitchCase',
SwitchStatement: 'SwitchStatement',
TaggedTemplateExpression: 'TaggedTemplateExpression',
TemplateElement: 'TemplateElement',
TemplateLiteral: 'TemplateLiteral',
ThisExpression: 'ThisExpression',
ThrowStatement: 'ThrowStatement',
TupleTypeAnnotation: 'TupleTypeAnnotation',
TryStatement: 'TryStatement',
TypeAlias: 'TypeAlias',
TypeAnnotation: 'TypeAnnotation',
TypeCastExpression: 'TypeCastExpression',
TypeofTypeAnnotation: 'TypeofTypeAnnotation',
TypeParameterDeclaration: 'TypeParameterDeclaration',
TypeParameterInstantiation: 'TypeParameterInstantiation',
UnaryExpression: 'UnaryExpression',
UnionTypeAnnotation: 'UnionTypeAnnotation',
UpdateExpression: 'UpdateExpression',
VariableDeclaration: 'VariableDeclaration',
VariableDeclarator: 'VariableDeclarator',
VoidTypeAnnotation: 'VoidTypeAnnotation',
WhileStatement: 'WhileStatement',
WithStatement: 'WithStatement',
JSXIdentifier: 'JSXIdentifier',
JSXNamespacedName: 'JSXNamespacedName',
JSXMemberExpression: "JSXMemberExpression",
JSXEmptyExpression: "JSXEmptyExpression",
JSXExpressionContainer: "JSXExpressionContainer",
JSXElement: 'JSXElement',
JSXClosingElement: 'JSXClosingElement',
JSXOpeningElement: 'JSXOpeningElement',
JSXAttribute: "JSXAttribute",
JSXSpreadAttribute: 'JSXSpreadAttribute',
JSXText: 'JSXText',
YieldExpression: 'YieldExpression',
AwaitExpression: 'AwaitExpression'
}
},
'tokenize()': {
call: 'tokenize',
args: [],
result: [{
type: 'Identifier',
value: 'undefined'
}]
},
'tokenize(null)': {
call: 'tokenize',
args: [null],
result: [{
type: 'Null',
value: 'null'
}]
},
'tokenize(42)': {
call: 'tokenize',
args: [42],
result: [{
type: 'Numeric',
value: '42'
}]
},
'tokenize(true)': {
call: 'tokenize',
args: [true],
result: [{
type: 'Boolean',
value: 'true'
}]
},
'tokenize(undefined)': {
call: 'tokenize',
args: [void 0],
result: [{
type: 'Identifier',
value: 'undefined'
}]
},
'tokenize(new String("test"))': {
call: 'tokenize',
args: [new String('test')],
result: [{
type: 'Identifier',
value: 'test'
}]
},
'tokenize(new Number(42))': {
call: 'tokenize',
args: [new Number(42)],
result: [{
type: 'Numeric',
value: '42'
}]
},
'tokenize(new Boolean(true))': {
call: 'tokenize',
args: [new Boolean(true)],
result: [{
type: 'Boolean',
value: 'true'
}]
}
},
'Tolerant parse': {
'return': {
type: 'Program',
body: [{
type: 'ReturnStatement',
'argument': null,
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
}
}],
range: [0, 6],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 6 }
},
errors: [{
index: 6,
lineNumber: 1,
column: 7,
message: 'Error: Line 1: Illegal return statement'
}]
},
'(function () { \'use strict\'; with (i); }())': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '\'use strict\'',
range: [15, 27],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 27 }
}
},
range: [15, 28],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 28 }
}
}, {
type: 'WithStatement',
object: {
type: 'Identifier',
name: 'i',
range: [35, 36],
loc: {
start: { line: 1, column: 35 },
end: { line: 1, column: 36 }
}
},
body: {
type: 'EmptyStatement',
range: [37, 38],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 38 }
}
},
range: [29, 38],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 38 }
}
}],
range: [13, 40],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 40 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 40],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 40 }
}
},
'arguments': [],
range: [1, 42],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 42 }
}
},
range: [0, 43],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 43 }
}
}],
range: [0, 43],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 43 }
},
errors: [{
index: 29,
lineNumber: 1,
column: 30,
message: 'Error: Line 1: Strict mode code may not include a with statement'
}]
},
'(function () { \'use strict\'; 021 }())': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '\'use strict\'',
range: [15, 27],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 27 }
}
},
range: [15, 28],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 28 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 17,
raw: "021",
range: [29, 32],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 32 }
}
},
range: [29, 33],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 33 }
}
}],
range: [13, 34],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 34 }
}
},
rest: null,
generator: false,
expression: false,
range: [1, 34],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 34 }
}
},
'arguments': [],
range: [1, 36],
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 36 }
}
},
range: [0, 37],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 37 }
}
}],
range: [0, 37],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 37 }
},
errors: [{
index: 29,
lineNumber: 1,
column: 30,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
}]
},
'"use strict"; delete x': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UnaryExpression',
operator: 'delete',
argument: {
type: 'Identifier',
name: 'x',
range: [21, 22],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 22 }
}
},
prefix: true,
range: [14, 22],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 22 }
}
},
range: [14, 22],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 22 }
}
}],
range: [0, 22],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 22 }
},
errors: [{
index: 22,
lineNumber: 1,
column: 23,
message: 'Error: Line 1: Delete of an unqualified identifier in strict mode.'
}]
},
'"use strict"; try {} catch (eval) {}': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [],
range: [18, 20],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 20 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'eval',
range: [28, 32],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 32 }
}
},
body: {
type: 'BlockStatement',
body: [],
range: [34, 36],
loc: {
start: { line: 1, column: 34 },
end: { line: 1, column: 36 }
}
},
range: [21, 36],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 36 }
}
}],
finalizer: null,
range: [14, 36],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 36 }
}
}],
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
},
errors: [{
index: 32,
lineNumber: 1,
column: 33,
message: 'Error: Line 1: Catch variable may not be eval or arguments in strict mode'
}]
},
'"use strict"; try {} catch (arguments) {}': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'TryStatement',
block: {
type: 'BlockStatement',
body: [],
range: [18, 20],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 20 }
}
},
guardedHandlers: [],
handlers: [{
type: 'CatchClause',
param: {
type: 'Identifier',
name: 'arguments',
range: [28, 37],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 37 }
}
},
body: {
type: 'BlockStatement',
body: [],
range: [39, 41],
loc: {
start: { line: 1, column: 39 },
end: { line: 1, column: 41 }
}
},
range: [21, 41],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 41 }
}
}],
finalizer: null,
range: [14, 41],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 41 }
}
}],
range: [0, 41],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 41 }
},
errors: [{
index: 37,
lineNumber: 1,
column: 38,
message: 'Error: Line 1: Catch variable may not be eval or arguments in strict mode'
}]
},
'"use strict"; var eval;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'eval',
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
},
init: null,
range: [18, 22],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 22 }
}
}],
kind: 'var',
range: [14, 23],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 23 }
}
}],
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
},
errors: [{
index: 22,
lineNumber: 1,
column: 23,
message: 'Error: Line 1: Variable name may not be eval or arguments in strict mode'
}]
},
'"use strict"; var arguments;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'arguments',
range: [18, 27],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 27 }
}
},
init: null,
range: [18, 27],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 27 }
}
}],
kind: 'var',
range: [14, 28],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 28 }
}
}],
range: [0, 28],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 28 }
},
errors: [{
index: 27,
lineNumber: 1,
column: 28,
message: 'Error: Line 1: Variable name may not be eval or arguments in strict mode'
}]
},
'"use strict"; eval = 0;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'eval',
range: [14, 18],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 18 }
}
},
right: {
type: 'Literal',
value: 0,
raw: '0',
range: [21, 22],
loc: {
start: { line: 1, column: 21 },
end: { line: 1, column: 22 }
}
},
range: [14, 22],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 22 }
}
},
range: [14, 23],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 23 }
}
}],
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
},
errors: [{
index: 14,
lineNumber: 1,
column: 15,
message: 'Error: Line 1: Assignment to eval or arguments is not allowed in strict mode'
}]
},
'"use strict"; eval++;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'eval',
range: [14, 18],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 18 }
}
},
prefix: false,
range: [14, 20],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 20 }
}
},
range: [14, 21],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 21 }
}
}],
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
},
errors: [{
index: 18,
lineNumber: 1,
column: 19,
message: 'Error: Line 1: Postfix increment/decrement may not have eval or arguments operand in strict mode'
}]
},
'"use strict"; --eval;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'eval',
range: [16, 20],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 20 }
}
},
prefix: true,
range: [14, 20],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 20 }
}
},
range: [14, 21],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 21 }
}
}],
range: [0, 21],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 21 }
},
errors: [{
index: 20,
lineNumber: 1,
column: 21,
message: 'Error: Line 1: Prefix increment/decrement may not have eval or arguments operand in strict mode'
}]
},
'"use strict"; arguments = 0;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'arguments',
range: [14, 23],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 23 }
}
},
right: {
type: 'Literal',
value: 0,
raw: '0',
range: [26, 27],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 27 }
}
},
range: [14, 27],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 27 }
}
},
range: [14, 28],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 28 }
}
}],
range: [0, 28],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 28 }
},
errors: [{
index: 14,
lineNumber: 1,
column: 15,
message: 'Error: Line 1: Assignment to eval or arguments is not allowed in strict mode'
}]
},
'"use strict"; arguments--;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '--',
argument: {
type: 'Identifier',
name: 'arguments',
range: [14, 23],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 23 }
}
},
prefix: false,
range: [14, 25],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 25 }
}
},
range: [14, 26],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 26 }
}
}],
range: [0, 26],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 26 }
},
errors: [{
index: 23,
lineNumber: 1,
column: 24,
message: 'Error: Line 1: Postfix increment/decrement may not have eval or arguments operand in strict mode'
}]
},
'"use strict"; ++arguments;': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'UpdateExpression',
operator: '++',
argument: {
type: 'Identifier',
name: 'arguments',
range: [16, 25],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 25 }
}
},
prefix: true,
range: [14, 25],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 25 }
}
},
range: [14, 26],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 26 }
}
}],
range: [0, 26],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 26 }
},
errors: [{
index: 25,
lineNumber: 1,
column: 26,
message: 'Error: Line 1: Prefix increment/decrement may not have eval or arguments operand in strict mode'
}]
},
'"use strict";x={y:1,y:1}': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [13, 14],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 14 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'y',
range: [16, 17],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 17 }
}
},
value: {
type: 'Literal',
value: 1,
raw: '1',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [16, 19],
loc: {
start: { line: 1, column: 16 },
end: { line: 1, column: 19 }
}
}, {
type: 'Property',
key: {
type: 'Identifier',
name: 'y',
range: [20, 21],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 21 }
}
},
value: {
type: 'Literal',
value: 1,
raw: '1',
range: [22, 23],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 23 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [20, 23],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 23 }
}
}],
range: [15, 24],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 24 }
}
},
range: [13, 24],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 24 }
}
},
range: [13, 24],
loc: {
start: { line: 1, column: 13 },
end: { line: 1, column: 24 }
}
}],
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 24 }
},
errors: [{
index: 23,
lineNumber: 1,
column: 24,
message: 'Error: Line 1: Duplicate data property in object literal not allowed in strict mode'
}]
},
'"use strict"; function eval() {};': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'eval',
range: [23, 27],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 27 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [30, 32],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 32 }
}
},
rest: null,
generator: false,
expression: false,
range: [14, 32],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 32 }
}
}, {
type: 'EmptyStatement',
range: [32, 33],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 33 }
}
}],
range: [0, 33],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 33 }
},
errors: [{
index: 23,
lineNumber: 1,
column: 24,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
}]
},
'"use strict"; function arguments() {};': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'arguments',
range: [23, 32],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 32 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [35, 37],
loc: {
start: { line: 1, column: 35 },
end: { line: 1, column: 37 }
}
},
rest: null,
generator: false,
expression: false,
range: [14, 37],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 37 }
}
}, {
type: 'EmptyStatement',
range: [37, 38],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 38 }
}
}],
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
},
errors: [{
index: 23,
lineNumber: 1,
column: 24,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
}]
},
'"use strict"; function interface() {};': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'interface',
range: [23, 32],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 32 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [35, 37],
loc: {
start: { line: 1, column: 35 },
end: { line: 1, column: 37 }
}
},
rest: null,
generator: false,
expression: false,
range: [14, 37],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 37 }
}
}, {
type: 'EmptyStatement',
range: [37, 38],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 38 }
}
}],
range: [0, 38],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 38 }
},
errors: [{
index: 23,
lineNumber: 1,
column: 24,
message: 'Error: Line 1: Use of future reserved word in strict mode'
}]
},
'"use strict"; (function eval() {});': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'eval',
range: [24, 28],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 28 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [31, 33],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 33 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 33],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 33 }
}
},
range: [14, 35],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 35 }
}
}],
range: [0, 35],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 35 }
},
errors: [{
index: 24,
lineNumber: 1,
column: 25,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
}]
},
'"use strict"; (function arguments() {});': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'arguments',
range: [24, 33],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 33 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [36, 38],
loc: {
start: { line: 1, column: 36 },
end: { line: 1, column: 38 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 38],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 38 }
}
},
range: [14, 40],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 40 }
}
}],
range: [0, 40],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 40 }
},
errors: [{
index: 24,
lineNumber: 1,
column: 25,
message: 'Error: Line 1: Function name may not be eval or arguments in strict mode'
}]
},
'"use strict"; (function interface() {});': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'interface',
range: [24, 33],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 33 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [36, 38],
loc: {
start: { line: 1, column: 36 },
end: { line: 1, column: 38 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 38],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 38 }
}
},
range: [14, 40],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 40 }
}
}],
range: [0, 40],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 40 }
},
errors: [{
index: 24,
lineNumber: 1,
column: 25,
message: 'Error: Line 1: Use of future reserved word in strict mode'
}]
},
'"use strict"; function f(eval) {};': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'f',
range: [23, 24],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 24 }
}
},
params: [{
type: 'Identifier',
name: 'eval',
range: [25, 29],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 29 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [31, 33],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 33 }
}
},
rest: null,
generator: false,
expression: false,
range: [14, 33],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 33 }
}
}, {
type: 'EmptyStatement',
range: [33, 34],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 34 }
}
}],
range: [0, 34],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 34 }
},
errors: [{
index: 25,
lineNumber: 1,
column: 26,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
}]
},
'"use strict"; function f(arguments) {};': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'f',
range: [23, 24],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 24 }
}
},
params: [{
type: 'Identifier',
name: 'arguments',
range: [25, 34],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 34 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [36, 38],
loc: {
start: { line: 1, column: 36 },
end: { line: 1, column: 38 }
}
},
rest: null,
generator: false,
expression: false,
range: [14, 38],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 38 }
}
}, {
type: 'EmptyStatement',
range: [38, 39],
loc: {
start: { line: 1, column: 38 },
end: { line: 1, column: 39 }
}
}],
range: [0, 39],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 39 }
},
errors: [{
index: 25,
lineNumber: 1,
column: 26,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
}]
},
'"use strict"; function f(foo, foo) {};': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'f',
range: [23, 24],
loc: {
start: { line: 1, column: 23 },
end: { line: 1, column: 24 }
}
},
params: [{
type: 'Identifier',
name: 'foo',
range: [25, 28],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 28 }
}
}, {
type: 'Identifier',
name: 'foo',
range: [31, 34],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 34 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [36, 38],
loc: {
start: { line: 1, column: 36 },
end: { line: 1, column: 38 }
}
},
rest: null,
generator: false,
expression: false,
range: [14, 38],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 38 }
}
}, {
type: 'EmptyStatement',
range: [38, 39],
loc: {
start: { line: 1, column: 38 },
end: { line: 1, column: 39 }
}
}],
range: [0, 39],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 39 }
},
errors: [{
index: 31,
lineNumber: 1,
column: 32,
message: 'Error: Line 1: Strict mode function may not have duplicate parameter names'
}]
},
'"use strict"; (function f(eval) {});': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'f',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
},
params: [{
type: 'Identifier',
name: 'eval',
range: [26, 30],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 30 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [32, 34],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 34 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 34],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 34 }
}
},
range: [14, 36],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 36 }
}
}],
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
},
errors: [{
index: 26,
lineNumber: 1,
column: 27,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
}]
},
'"use strict"; (function f(arguments) {});': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'f',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
},
params: [{
type: 'Identifier',
name: 'arguments',
range: [26, 35],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 35 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [37, 39],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 39 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 39],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 39 }
}
},
range: [14, 41],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 41 }
}
}],
range: [0, 41],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 41 }
},
errors: [{
index: 26,
lineNumber: 1,
column: 27,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
}]
},
'"use strict"; (function f(foo, foo) {});': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'FunctionExpression',
id: {
type: 'Identifier',
name: 'f',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
},
params: [{
type: 'Identifier',
name: 'foo',
range: [26, 29],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 29 }
}
}, {
type: 'Identifier',
name: 'foo',
range: [32, 35],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 35 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [37, 39],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 39 }
}
},
rest: null,
generator: false,
expression: false,
range: [15, 39],
loc: {
start: { line: 1, column: 15 },
end: { line: 1, column: 39 }
}
},
range: [14, 41],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 41 }
}
}],
range: [0, 41],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 41 }
},
errors: [{
index: 32,
lineNumber: 1,
column: 33,
message: 'Error: Line 1: Strict mode function may not have duplicate parameter names'
}]
},
'"use strict"; x = { set f(eval) {} }' : {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: {
type: 'Identifier',
name: 'x',
range: [14, 15],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 15 }
}
},
right: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'f',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
},
value : {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'eval',
range: [26, 30],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 30 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [32, 34],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 34 }
}
},
rest: null,
generator: false,
expression: false,
range: [32, 34],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 34 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [20, 34],
loc: {
start: { line: 1, column: 20 },
end: { line: 1, column: 34 }
}
}],
range: [18, 36],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 36 }
}
},
range: [14, 36],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 36 }
}
},
range: [14, 36],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 36 }
}
}],
range: [0, 36],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 36 }
},
errors: [{
index: 26,
lineNumber: 1,
column: 27,
message: 'Error: Line 1: Parameter name eval or arguments is not allowed in strict mode'
}]
},
'function hello() { "octal directive\\1"; "use strict"; }': {
type: 'Program',
body: [{
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
name: 'hello',
range: [9, 14],
loc: {
start: { line: 1, column: 9 },
end: { line: 1, column: 14 }
}
},
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'octal directive\u0001',
raw: '"octal directive\\1"',
range: [19, 38],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 38 }
}
},
range: [19, 39],
loc: {
start: { line: 1, column: 19 },
end: { line: 1, column: 39 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [40, 52],
loc: {
start: { line: 1, column: 40 },
end: { line: 1, column: 52 }
}
},
range: [40, 53],
loc: {
start: { line: 1, column: 40 },
end: { line: 1, column: 53 }
}
}],
range: [17, 55],
loc: {
start: { line: 1, column: 17 },
end: { line: 1, column: 55 }
}
},
rest: null,
generator: false,
expression: false,
range: [0, 55],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 55 }
}
}],
range: [0, 55],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 55 }
},
errors: [{
index: 19,
lineNumber: 1,
column: 20,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
}]
},
'"\\1"; \'use strict\';': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: '\u0001',
raw: '"\\1"',
range: [0, 4],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 4 }
}
},
range: [0, 5],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 5 }
}
}, {
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '\'use strict\'',
range: [6, 18],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 18 }
}
},
range: [6, 19],
loc: {
start: { line: 1, column: 6 },
end: { line: 1, column: 19 }
}
}],
range: [0, 19],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 19 }
},
errors: [{
index: 0,
lineNumber: 1,
column: 1,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
}]
},
'"use strict"; var x = { 014: 3}': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
init: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Literal',
value: 12,
raw: '014',
range: [24, 27],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 27 }
}
},
value: {
type: 'Literal',
value: 3,
raw: '3',
range: [29, 30],
loc: {
start: { line: 1, column: 29 },
end: { line: 1, column: 30 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [24, 30],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 30 }
}
}],
range: [22, 31],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 31 }
}
},
range: [18, 31],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 31 }
}
}],
kind: 'var',
range: [14, 31],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 31 }
}
}],
range: [0, 31],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 31 }
},
errors: [{
index: 24,
lineNumber: 1,
column: 25,
message: 'Error: Line 1: Octal literals are not allowed in strict mode.'
}]
},
'"use strict"; var x = { get i() {}, get i() {} }': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
init: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'i',
range: [28, 29],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 29 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [32, 34],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 34 }
}
},
rest: null,
generator: false,
expression: false,
range: [32, 34],
loc: {
start: { line: 1, column: 32 },
end: { line: 1, column: 34 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [24, 34],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 34 }
}
}, {
type: 'Property',
key: {
type: 'Identifier',
name: 'i',
range: [40, 41],
loc: {
start: { line: 1, column: 40 },
end: { line: 1, column: 41 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [44, 46],
loc: {
start: { line: 1, column: 44 },
end: { line: 1, column: 46 }
}
},
rest: null,
generator: false,
expression: false,
range: [44, 46],
loc: {
start: { line: 1, column: 44 },
end: { line: 1, column: 46 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [36, 46],
loc: {
start: { line: 1, column: 36 },
end: { line: 1, column: 46 }
}
}],
range: [22, 48],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 48 }
}
},
range: [18, 48],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 48 }
}
}],
kind: 'var',
range: [14, 48],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 48 }
}
}],
range: [0, 48],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 48 }
},
errors: [{
index: 46,
lineNumber: 1,
column: 47,
message: 'Error: Line 1: Object literal may not have multiple get/set accessors with the same name'
}]
},
'"use strict"; var x = { i: 42, get i() {} }': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
init: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'i',
range: [24, 25],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 25 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [27, 29],
loc: {
start: { line: 1, column: 27 },
end: { line: 1, column: 29 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [24, 29],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 29 }
}
}, {
type: 'Property',
key: {
type: 'Identifier',
name: 'i',
range: [35, 36],
loc: {
start: { line: 1, column: 35 },
end: { line: 1, column: 36 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [39, 41],
loc: {
start: { line: 1, column: 39 },
end: { line: 1, column: 41 }
}
},
rest: null,
generator: false,
expression: false,
range: [39, 41],
loc: {
start: { line: 1, column: 39 },
end: { line: 1, column: 41 }
}
},
kind: 'get',
method: false,
shorthand: false,
computed: false,
range: [31, 41],
loc: {
start: { line: 1, column: 31 },
end: { line: 1, column: 41 }
}
}],
range: [22, 43],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 43 }
}
},
range: [18, 43],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 43 }
}
}],
kind: 'var',
range: [14, 43],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 43 }
}
}],
range: [0, 43],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 43 }
},
errors: [{
index: 41,
lineNumber: 1,
column: 42,
message: 'Error: Line 1: Object literal may not have data and accessor property with the same name'
}]
},
'"use strict"; var x = { set i(x) {}, i: 42 }': {
type: 'Program',
body: [{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: 'use strict',
raw: '"use strict"',
range: [0, 12],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 12 }
}
},
range: [0, 13],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 13 }
}
}, {
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x',
range: [18, 19],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 19 }
}
},
init: {
type: 'ObjectExpression',
properties: [{
type: 'Property',
key: {
type: 'Identifier',
name: 'i',
range: [28, 29],
loc: {
start: { line: 1, column: 28 },
end: { line: 1, column: 29 }
}
},
value: {
type: 'FunctionExpression',
id: null,
params: [{
type: 'Identifier',
name: 'x',
range: [30, 31],
loc: {
start: { line: 1, column: 30 },
end: { line: 1, column: 31 }
}
}],
defaults: [],
body: {
type: 'BlockStatement',
body: [],
range: [33, 35],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 35 }
}
},
rest: null,
generator: false,
expression: false,
range: [33, 35],
loc: {
start: { line: 1, column: 33 },
end: { line: 1, column: 35 }
}
},
kind: 'set',
method: false,
shorthand: false,
computed: false,
range: [24, 35],
loc: {
start: { line: 1, column: 24 },
end: { line: 1, column: 35 }
}
}, {
type: 'Property',
key: {
type: 'Identifier',
name: 'i',
range: [37, 38],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 38 }
}
},
value: {
type: 'Literal',
value: 42,
raw: '42',
range: [40, 42],
loc: {
start: { line: 1, column: 40 },
end: { line: 1, column: 42 }
}
},
kind: 'init',
method: false,
shorthand: false,
computed: false,
range: [37, 42],
loc: {
start: { line: 1, column: 37 },
end: { line: 1, column: 42 }
}
}],
range: [22, 44],
loc: {
start: { line: 1, column: 22 },
end: { line: 1, column: 44 }
}
},
range: [18, 44],
loc: {
start: { line: 1, column: 18 },
end: { line: 1, column: 44 }
}
}],
kind: 'var',
range: [14, 44],
loc: {
start: { line: 1, column: 14 },
end: { line: 1, column: 44 }
}
}],
range: [0, 44],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 44 }
},
errors: [{
index: 42,
lineNumber: 1,
column: 43,
message: 'Error: Line 1: Object literal may not have data and accessor property with the same name'
}]
},
'var x = /[P QR]/\\g': {
type: "Program",
body: [{
type: "VariableDeclaration",
declarations: [{
type: "VariableDeclarator",
id: {
type: "Identifier",
name: "x",
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: "Literal",
value: "/[P QR]/g",
raw: "/[P QR]/\\g",
regex: {
pattern: '[P QR]',
flags: 'g'
},
range: [8, 18],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 18 }
}
},
range: [4, 18],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 18 }
}
}],
kind: "var",
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
}
}],
range: [0, 18],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 18 }
},
errors: [{
index: 17,
lineNumber: 1,
column: 18,
message: "Error: Line 1: Unexpected token ILLEGAL"
}]
},
'var x = /[P QR]/\\\\u0067': {
type: "Program",
body: [{
type: "VariableDeclaration",
declarations: [{
type: "VariableDeclarator",
id: {
type: "Identifier",
name: "x",
range: [4, 5],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 5 }
}
},
init: {
type: "Literal",
value: "/[P QR]/g",
raw: "/[P QR]/\\\\u0067",
regex: {
pattern: '[P QR]',
flags: 'g'
},
range: [8, 23],
loc: {
start: { line: 1, column: 8 },
end: { line: 1, column: 23 }
}
},
range: [4, 23],
loc: {
start: { line: 1, column: 4 },
end: { line: 1, column: 23 }
}
}],
kind: "var",
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
}
}],
range: [0, 23],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 23 }
},
errors: [{
index: 17,
lineNumber: 1,
column: 18,
message: "Error: Line 1: Unexpected token ILLEGAL"
}, {
index: 23,
lineNumber: 1,
column: 24,
message: "Error: Line 1: Unexpected token ILLEGAL"
}]
}
}
};
``` | /content/code_sandbox/node_modules/recast/node_modules/esprima-fb/test/test.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 154,254 |
```javascript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.async = global.async || {})));
}(this, (function (exports) { 'use strict';
function slice(arrayLike, start) {
start = start|0;
var newLen = Math.max(arrayLike.length - start, 0);
var newArr = Array(newLen);
for(var idx = 0; idx < newLen; idx++) {
newArr[idx] = arrayLike[start + idx];
}
return newArr;
}
/**
* Creates a continuation function with some arguments already applied.
*
* Useful as a shorthand when combined with other control flow functions. Any
* arguments passed to the returned function are added to the arguments
* originally passed to apply.
*
* @name apply
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {Function} fn - The function you want to eventually apply all
* arguments to. Invokes with (arguments...).
* @param {...*} arguments... - Any number of arguments to automatically apply
* when the continuation is called.
* @returns {Function} the partially-applied function
* @example
*
* // using apply
* async.parallel([
* async.apply(fs.writeFile, 'testfile1', 'test1'),
* async.apply(fs.writeFile, 'testfile2', 'test2')
* ]);
*
*
* // the same process without using apply
* async.parallel([
* function(callback) {
* fs.writeFile('testfile1', 'test1', callback);
* },
* function(callback) {
* fs.writeFile('testfile2', 'test2', callback);
* }
* ]);
*
* // It's possible to pass any number of additional arguments when calling the
* // continuation:
*
* node> var fn = async.apply(sys.puts, 'one');
* node> fn('two', 'three');
* one
* two
* three
*/
var apply = function(fn/*, ...args*/) {
var args = slice(arguments, 1);
return function(/*callArgs*/) {
var callArgs = slice(arguments);
return fn.apply(null, args.concat(callArgs));
};
};
var initialParams = function (fn) {
return function (/*...args, callback*/) {
var args = slice(arguments);
var callback = args.pop();
fn.call(this, args, callback);
};
};
/**
* Checks if `value` is the
* [language type](path_to_url#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
}
var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
function fallback(fn) {
setTimeout(fn, 0);
}
function wrap(defer) {
return function (fn/*, ...args*/) {
var args = slice(arguments, 1);
defer(function () {
fn.apply(null, args);
});
};
}
var _defer;
if (hasSetImmediate) {
_defer = setImmediate;
} else if (hasNextTick) {
_defer = process.nextTick;
} else {
_defer = fallback;
}
var setImmediate$1 = wrap(_defer);
/**
* Take a sync function and make it async, passing its return value to a
* callback. This is useful for plugging sync functions into a waterfall,
* series, or other async functions. Any arguments passed to the generated
* function will be passed to the wrapped function (except for the final
* callback argument). Errors thrown will be passed to the callback.
*
* If the function passed to `asyncify` returns a Promise, that promises's
* resolved/rejected state will be used to call the callback, rather than simply
* the synchronous return value.
*
* This also means you can asyncify ES2017 `async` functions.
*
* @name asyncify
* @static
* @memberOf module:Utils
* @method
* @alias wrapSync
* @category Util
* @param {Function} func - The synchronous function, or Promise-returning
* function to convert to an {@link AsyncFunction}.
* @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
* invoked with `(args..., callback)`.
* @example
*
* // passing a regular synchronous function
* async.waterfall([
* async.apply(fs.readFile, filename, "utf8"),
* async.asyncify(JSON.parse),
* function (data, next) {
* // data is the result of parsing the text.
* // If there was a parsing error, it would have been caught.
* }
* ], callback);
*
* // passing a function returning a promise
* async.waterfall([
* async.apply(fs.readFile, filename, "utf8"),
* async.asyncify(function (contents) {
* return db.model.create(contents);
* }),
* function (model, next) {
* // `model` is the instantiated model object.
* // If there was an error, this function would be skipped.
* }
* ], callback);
*
* // es2017 example, though `asyncify` is not needed if your JS environment
* // supports async functions out of the box
* var q = async.queue(async.asyncify(async function(file) {
* var intermediateStep = await processFile(file);
* return await somePromise(intermediateStep)
* }));
*
* q.push(files);
*/
function asyncify(func) {
return initialParams(function (args, callback) {
var result;
try {
result = func.apply(this, args);
} catch (e) {
return callback(e);
}
// if result is Promise object
if (isObject(result) && typeof result.then === 'function') {
result.then(function(value) {
invokeCallback(callback, null, value);
}, function(err) {
invokeCallback(callback, err.message ? err : new Error(err));
});
} else {
callback(null, result);
}
});
}
function invokeCallback(callback, error, value) {
try {
callback(error, value);
} catch (e) {
setImmediate$1(rethrow, e);
}
}
function rethrow(error) {
throw error;
}
var supportsSymbol = typeof Symbol === 'function';
function isAsync(fn) {
return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction';
}
function wrapAsync(asyncFn) {
return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn;
}
function applyEach$1(eachfn) {
return function(fns/*, ...args*/) {
var args = slice(arguments, 1);
var go = initialParams(function(args, callback) {
var that = this;
return eachfn(fns, function (fn, cb) {
wrapAsync(fn).apply(that, args.concat(cb));
}, callback);
});
if (args.length) {
return go.apply(this, args);
}
else {
return go;
}
};
}
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Built-in value references. */
var Symbol$1 = root.Symbol;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](path_to_url#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/** Built-in value references. */
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag$1),
tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$1 = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](path_to_url#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString$1 = objectProto$1.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString$1.call(value);
}
/** `Object#toString` result references. */
var nullTag = '[object Null]';
var undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
/** `Object#toString` result references. */
var asyncTag = '[object AsyncFunction]';
var funcTag = '[object Function]';
var genTag = '[object GeneratorFunction]';
var proxyTag = '[object Proxy]';
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var tag = baseGetTag(value);
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This method is loosely based on
* [`ToLength`](path_to_url#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
* // => true
*
* _.isLength(Number.MIN_VALUE);
* // => false
*
* _.isLength(Infinity);
* // => false
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
return typeof value == 'number' &&
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
/**
* Checks if `value` is array-like. A value is considered array-like if it's
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
* _.isArrayLike([1, 2, 3]);
* // => true
*
* _.isArrayLike(document.body.children);
* // => true
*
* _.isArrayLike('abc');
* // => true
*
* _.isArrayLike(_.noop);
* // => false
*/
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
// A temporary value used to identify if the loop should be broken.
// See #1064, #1293
var breakLoop = {};
/**
* This method returns `undefined`.
*
* @static
* @memberOf _
* @since 2.3.0
* @category Util
* @example
*
* _.times(2, _.noop);
* // => [undefined, undefined]
*/
function noop() {
// No operation performed.
}
function once(fn) {
return function () {
if (fn === null) return;
var callFn = fn;
fn = null;
callFn.apply(this, arguments);
};
}
var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
var getIterator = function (coll) {
return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
};
/**
* The base implementation of `_.times` without support for iteratee shorthands
* or max array length checks.
*
* @private
* @param {number} n The number of times to invoke `iteratee`.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the array of results.
*/
function baseTimes(n, iteratee) {
var index = -1,
result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/** `Object#toString` result references. */
var argsTag = '[object Arguments]';
/**
* The base implementation of `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && baseGetTag(value) == argsTag;
}
/** Used for built-in method references. */
var objectProto$3 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
/** Built-in value references. */
var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
*
* _.isArguments([1, 2, 3]);
* // => false
*/
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
/**
* This method returns `false`.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {boolean} Returns `false`.
* @example
*
* _.times(2, _.stubFalse);
* // => [false, false]
*/
function stubFalse() {
return false;
}
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = nativeIsBuffer || stubFalse;
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER$1 = 9007199254740991;
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
var type = typeof value;
length = length == null ? MAX_SAFE_INTEGER$1 : length;
return !!length &&
(type == 'number' ||
(type != 'symbol' && reIsUint.test(value))) &&
(value > -1 && value % 1 == 0 && value < length);
}
/** `Object#toString` result references. */
var argsTag$1 = '[object Arguments]';
var arrayTag = '[object Array]';
var boolTag = '[object Boolean]';
var dateTag = '[object Date]';
var errorTag = '[object Error]';
var funcTag$1 = '[object Function]';
var mapTag = '[object Map]';
var numberTag = '[object Number]';
var objectTag = '[object Object]';
var regexpTag = '[object RegExp]';
var setTag = '[object Set]';
var stringTag = '[object String]';
var weakMapTag = '[object WeakMap]';
var arrayBufferTag = '[object ArrayBuffer]';
var dataViewTag = '[object DataView]';
var float32Tag = '[object Float32Array]';
var float64Tag = '[object Float64Array]';
var int8Tag = '[object Int8Array]';
var int16Tag = '[object Int16Array]';
var int32Tag = '[object Int32Array]';
var uint8Tag = '[object Uint8Array]';
var uint8ClampedTag = '[object Uint8ClampedArray]';
var uint16Tag = '[object Uint16Array]';
var uint32Tag = '[object Uint32Array]';
/** Used to identify `toStringTag` values of typed arrays. */
var typedArrayTags = {};
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
typedArrayTags[uint32Tag] = true;
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
typedArrayTags[setTag] = typedArrayTags[stringTag] =
typedArrayTags[weakMapTag] = false;
/**
* The base implementation of `_.isTypedArray` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
*/
function baseIsTypedArray(value) {
return isObjectLike(value) &&
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
}
/**
* The base implementation of `_.unary` without support for storing metadata.
*
* @private
* @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new capped function.
*/
function baseUnary(func) {
return function(value) {
return func(value);
};
}
/** Detect free variable `exports`. */
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
/** Detect free variable `process` from Node.js. */
var freeProcess = moduleExports$1 && freeGlobal.process;
/** Used to access faster Node.js helpers. */
var nodeUtil = (function() {
try {
// Use `util.types` for Node.js 10+.
var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
if (types) {
return types;
}
// Legacy `process.binding('util')` for Node.js < 10.
return freeProcess && freeProcess.binding && freeProcess.binding('util');
} catch (e) {}
}());
/* Node.js helper references. */
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
/**
* Checks if `value` is classified as a typed array.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* _.isTypedArray(new Uint8Array);
* // => true
*
* _.isTypedArray([]);
* // => false
*/
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
/** Used for built-in method references. */
var objectProto$2 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
/**
* Creates an array of the enumerable property names of the array-like `value`.
*
* @private
* @param {*} value The value to query.
* @param {boolean} inherited Specify returning inherited property names.
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
var isArr = isArray(value),
isArg = !isArr && isArguments(value),
isBuff = !isArr && !isArg && isBuffer(value),
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
skipIndexes = isArr || isArg || isBuff || isType,
result = skipIndexes ? baseTimes(value.length, String) : [],
length = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty$1.call(value, key)) &&
!(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
// Node.js 0.10 has enumerable non-index properties on buffers.
(isBuff && (key == 'offset' || key == 'parent')) ||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
// Skip index properties.
isIndex(key, length)
))) {
result.push(key);
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$5 = Object.prototype;
/**
* Checks if `value` is likely a prototype object.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
return value === proto;
}
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeKeys = overArg(Object.keys, Object);
/** Used for built-in method references. */
var objectProto$4 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
/**
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
if (!isPrototype(object)) {
return nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty$3.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
}
/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
* [ES spec](path_to_url#sec-object.keys)
* for more details.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* _.keys('hi');
* // => ['0', '1']
*/
function keys(object) {
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
function createArrayIterator(coll) {
var i = -1;
var len = coll.length;
return function next() {
return ++i < len ? {value: coll[i], key: i} : null;
}
}
function createES2015Iterator(iterator) {
var i = -1;
return function next() {
var item = iterator.next();
if (item.done)
return null;
i++;
return {value: item.value, key: i};
}
}
function createObjectIterator(obj) {
var okeys = keys(obj);
var i = -1;
var len = okeys.length;
return function next() {
var key = okeys[++i];
if (key === '__proto__') {
return next();
}
return i < len ? {value: obj[key], key: key} : null;
};
}
function iterator(coll) {
if (isArrayLike(coll)) {
return createArrayIterator(coll);
}
var iterator = getIterator(coll);
return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
}
function onlyOnce(fn) {
return function() {
if (fn === null) throw new Error("Callback was already called.");
var callFn = fn;
fn = null;
callFn.apply(this, arguments);
};
}
function _eachOfLimit(limit) {
return function (obj, iteratee, callback) {
callback = once(callback || noop);
if (limit <= 0 || !obj) {
return callback(null);
}
var nextElem = iterator(obj);
var done = false;
var running = 0;
var looping = false;
function iterateeCallback(err, value) {
running -= 1;
if (err) {
done = true;
callback(err);
}
else if (value === breakLoop || (done && running <= 0)) {
done = true;
return callback(null);
}
else if (!looping) {
replenish();
}
}
function replenish () {
looping = true;
while (running < limit && !done) {
var elem = nextElem();
if (elem === null) {
done = true;
if (running <= 0) {
callback(null);
}
return;
}
running += 1;
iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
}
looping = false;
}
replenish();
};
}
/**
* The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
* time.
*
* @name eachOfLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.eachOf]{@link module:Collections.eachOf}
* @alias forEachOfLimit
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - An async function to apply to each
* item in `coll`. The `key` is the item's key, or index in the case of an
* array.
* Invoked with (item, key, callback).
* @param {Function} [callback] - A callback which is called when all
* `iteratee` functions have finished, or an error occurs. Invoked with (err).
*/
function eachOfLimit(coll, limit, iteratee, callback) {
_eachOfLimit(limit)(coll, wrapAsync(iteratee), callback);
}
function doLimit(fn, limit) {
return function (iterable, iteratee, callback) {
return fn(iterable, limit, iteratee, callback);
};
}
// eachOf implementation optimized for array-likes
function eachOfArrayLike(coll, iteratee, callback) {
callback = once(callback || noop);
var index = 0,
completed = 0,
length = coll.length;
if (length === 0) {
callback(null);
}
function iteratorCallback(err, value) {
if (err) {
callback(err);
} else if ((++completed === length) || value === breakLoop) {
callback(null);
}
}
for (; index < length; index++) {
iteratee(coll[index], index, onlyOnce(iteratorCallback));
}
}
// a generic version of eachOf which can handle array, object, and iterator cases.
var eachOfGeneric = doLimit(eachOfLimit, Infinity);
/**
* Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
* to the iteratee.
*
* @name eachOf
* @static
* @memberOf module:Collections
* @method
* @alias forEachOf
* @category Collection
* @see [async.each]{@link module:Collections.each}
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - A function to apply to each
* item in `coll`.
* The `key` is the item's key, or index in the case of an array.
* Invoked with (item, key, callback).
* @param {Function} [callback] - A callback which is called when all
* `iteratee` functions have finished, or an error occurs. Invoked with (err).
* @example
*
* var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
* var configs = {};
*
* async.forEachOf(obj, function (value, key, callback) {
* fs.readFile(__dirname + value, "utf8", function (err, data) {
* if (err) return callback(err);
* try {
* configs[key] = JSON.parse(data);
* } catch (e) {
* return callback(e);
* }
* callback();
* });
* }, function (err) {
* if (err) console.error(err.message);
* // configs is now a map of JSON data
* doSomethingWith(configs);
* });
*/
var eachOf = function(coll, iteratee, callback) {
var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
eachOfImplementation(coll, wrapAsync(iteratee), callback);
};
function doParallel(fn) {
return function (obj, iteratee, callback) {
return fn(eachOf, obj, wrapAsync(iteratee), callback);
};
}
function _asyncMap(eachfn, arr, iteratee, callback) {
callback = callback || noop;
arr = arr || [];
var results = [];
var counter = 0;
var _iteratee = wrapAsync(iteratee);
eachfn(arr, function (value, _, callback) {
var index = counter++;
_iteratee(value, function (err, v) {
results[index] = v;
callback(err);
});
}, function (err) {
callback(err, results);
});
}
/**
* Produces a new collection of values by mapping each value in `coll` through
* the `iteratee` function. The `iteratee` is called with an item from `coll`
* and a callback for when it has finished processing. Each of these callback
* takes 2 arguments: an `error`, and the transformed item from `coll`. If
* `iteratee` passes an error to its callback, the main `callback` (for the
* `map` function) is immediately called with the error.
*
* Note, that since this function applies the `iteratee` to each item in
* parallel, there is no guarantee that the `iteratee` functions will complete
* in order. However, the results array will be in the same order as the
* original `coll`.
*
* If `map` is passed an Object, the results will be an Array. The results
* will roughly be in the order of the original Objects' keys (but this can
* vary across JavaScript engines).
*
* @name map
* @static
* @memberOf module:Collections
* @method
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The iteratee should complete with the transformed item.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. Results is an Array of the
* transformed items from the `coll`. Invoked with (err, results).
* @example
*
* async.map(['file1','file2','file3'], fs.stat, function(err, results) {
* // results is now an array of stats for each file
* });
*/
var map = doParallel(_asyncMap);
/**
* Applies the provided arguments to each function in the array, calling
* `callback` after all functions have completed. If you only provide the first
* argument, `fns`, then it will return a function which lets you pass in the
* arguments as if it were a single function call. If more arguments are
* provided, `callback` is required while `args` is still optional.
*
* @name applyEach
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s
* to all call with the same arguments
* @param {...*} [args] - any number of separate arguments to pass to the
* function.
* @param {Function} [callback] - the final argument should be the callback,
* called when all functions have completed processing.
* @returns {Function} - If only the first argument, `fns`, is provided, it will
* return a function which lets you pass in the arguments as if it were a single
* function call. The signature is `(..args, callback)`. If invoked with any
* arguments, `callback` is required.
* @example
*
* async.applyEach([enableSearch, updateSchema], 'bucket', callback);
*
* // partial application example:
* async.each(
* buckets,
* async.applyEach([enableSearch, updateSchema]),
* callback
* );
*/
var applyEach = applyEach$1(map);
function doParallelLimit(fn) {
return function (obj, limit, iteratee, callback) {
return fn(_eachOfLimit(limit), obj, wrapAsync(iteratee), callback);
};
}
/**
* The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
*
* @name mapLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.map]{@link module:Collections.map}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The iteratee should complete with the transformed item.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. Results is an array of the
* transformed items from the `coll`. Invoked with (err, results).
*/
var mapLimit = doParallelLimit(_asyncMap);
/**
* The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
*
* @name mapSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.map]{@link module:Collections.map}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The iteratee should complete with the transformed item.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. Results is an array of the
* transformed items from the `coll`. Invoked with (err, results).
*/
var mapSeries = doLimit(mapLimit, 1);
/**
* The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
*
* @name applyEachSeries
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.applyEach]{@link module:ControlFlow.applyEach}
* @category Control Flow
* @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s to all
* call with the same arguments
* @param {...*} [args] - any number of separate arguments to pass to the
* function.
* @param {Function} [callback] - the final argument should be the callback,
* called when all functions have completed processing.
* @returns {Function} - If only the first argument is provided, it will return
* a function which lets you pass in the arguments as if it were a single
* function call.
*/
var applyEachSeries = applyEach$1(mapSeries);
/**
* A specialized version of `_.forEach` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEach(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
}
/**
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
*
* @private
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new base function.
*/
function createBaseFor(fromRight) {
return function(object, iteratee, keysFunc) {
var index = -1,
iterable = Object(object),
props = keysFunc(object),
length = props.length;
while (length--) {
var key = props[fromRight ? length : ++index];
if (iteratee(iterable[key], key, iterable) === false) {
break;
}
}
return object;
};
}
/**
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {Function} keysFunc The function to get the keys of `object`.
* @returns {Object} Returns `object`.
*/
var baseFor = createBaseFor();
/**
* The base implementation of `_.forOwn` without support for iteratee shorthands.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Object} Returns `object`.
*/
function baseForOwn(object, iteratee) {
return object && baseFor(object, iteratee, keys);
}
/**
* The base implementation of `_.findIndex` and `_.findLastIndex` without
* support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseFindIndex(array, predicate, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while ((fromRight ? index-- : ++index < length)) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
/**
* The base implementation of `_.isNaN` without support for number objects.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
*/
function baseIsNaN(value) {
return value !== value;
}
/**
* A specialized version of `_.indexOf` which performs strict equality
* comparisons of values, i.e. `===`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function strictIndexOf(array, value, fromIndex) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (array[index] === value) {
return index;
}
}
return -1;
}
/**
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOf(array, value, fromIndex) {
return value === value
? strictIndexOf(array, value, fromIndex)
: baseFindIndex(array, baseIsNaN, fromIndex);
}
/**
* Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
* their requirements. Each function can optionally depend on other functions
* being completed first, and each function is run as soon as its requirements
* are satisfied.
*
* If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
* will stop. Further tasks will not execute (so any other functions depending
* on it will not run), and the main `callback` is immediately called with the
* error.
*
* {@link AsyncFunction}s also receive an object containing the results of functions which
* have completed so far as the first argument, if they have dependencies. If a
* task function has no dependencies, it will only be passed a callback.
*
* @name auto
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Object} tasks - An object. Each of its properties is either a
* function or an array of requirements, with the {@link AsyncFunction} itself the last item
* in the array. The object's key of a property serves as the name of the task
* defined by that property, i.e. can be used when specifying requirements for
* other tasks. The function receives one or two arguments:
* * a `results` object, containing the results of the previously executed
* functions, only passed if the task has any dependencies,
* * a `callback(err, result)` function, which must be called when finished,
* passing an `error` (which can be `null`) and the result of the function's
* execution.
* @param {number} [concurrency=Infinity] - An optional `integer` for
* determining the maximum number of tasks that can be run in parallel. By
* default, as many as possible.
* @param {Function} [callback] - An optional callback which is called when all
* the tasks have been completed. It receives the `err` argument if any `tasks`
* pass an error to their callback. Results are always returned; however, if an
* error occurs, no further `tasks` will be performed, and the results object
* will only contain partial results. Invoked with (err, results).
* @returns undefined
* @example
*
* async.auto({
* // this function will just be passed a callback
* readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
* showData: ['readData', function(results, cb) {
* // results.readData is the file's contents
* // ...
* }]
* }, callback);
*
* async.auto({
* get_data: function(callback) {
* console.log('in get_data');
* // async code to get some data
* callback(null, 'data', 'converted to array');
* },
* make_folder: function(callback) {
* console.log('in make_folder');
* // async code to create a directory to store a file in
* // this is run at the same time as getting the data
* callback(null, 'folder');
* },
* write_file: ['get_data', 'make_folder', function(results, callback) {
* console.log('in write_file', JSON.stringify(results));
* // once there is some data and the directory exists,
* // write the data to a file in the directory
* callback(null, 'filename');
* }],
* email_link: ['write_file', function(results, callback) {
* console.log('in email_link', JSON.stringify(results));
* // once the file is written let's email a link to it...
* // results.write_file contains the filename returned by write_file.
* callback(null, {'file':results.write_file, 'email':'user@example.com'});
* }]
* }, function(err, results) {
* console.log('err = ', err);
* console.log('results = ', results);
* });
*/
var auto = function (tasks, concurrency, callback) {
if (typeof concurrency === 'function') {
// concurrency is optional, shift the args.
callback = concurrency;
concurrency = null;
}
callback = once(callback || noop);
var keys$$1 = keys(tasks);
var numTasks = keys$$1.length;
if (!numTasks) {
return callback(null);
}
if (!concurrency) {
concurrency = numTasks;
}
var results = {};
var runningTasks = 0;
var hasError = false;
var listeners = Object.create(null);
var readyTasks = [];
// for cycle detection:
var readyToCheck = []; // tasks that have been identified as reachable
// without the possibility of returning to an ancestor task
var uncheckedDependencies = {};
baseForOwn(tasks, function (task, key) {
if (!isArray(task)) {
// no dependencies
enqueueTask(key, [task]);
readyToCheck.push(key);
return;
}
var dependencies = task.slice(0, task.length - 1);
var remainingDependencies = dependencies.length;
if (remainingDependencies === 0) {
enqueueTask(key, task);
readyToCheck.push(key);
return;
}
uncheckedDependencies[key] = remainingDependencies;
arrayEach(dependencies, function (dependencyName) {
if (!tasks[dependencyName]) {
throw new Error('async.auto task `' + key +
'` has a non-existent dependency `' +
dependencyName + '` in ' +
dependencies.join(', '));
}
addListener(dependencyName, function () {
remainingDependencies--;
if (remainingDependencies === 0) {
enqueueTask(key, task);
}
});
});
});
checkForDeadlocks();
processQueue();
function enqueueTask(key, task) {
readyTasks.push(function () {
runTask(key, task);
});
}
function processQueue() {
if (readyTasks.length === 0 && runningTasks === 0) {
return callback(null, results);
}
while(readyTasks.length && runningTasks < concurrency) {
var run = readyTasks.shift();
run();
}
}
function addListener(taskName, fn) {
var taskListeners = listeners[taskName];
if (!taskListeners) {
taskListeners = listeners[taskName] = [];
}
taskListeners.push(fn);
}
function taskComplete(taskName) {
var taskListeners = listeners[taskName] || [];
arrayEach(taskListeners, function (fn) {
fn();
});
processQueue();
}
function runTask(key, task) {
if (hasError) return;
var taskCallback = onlyOnce(function(err, result) {
runningTasks--;
if (arguments.length > 2) {
result = slice(arguments, 1);
}
if (err) {
var safeResults = {};
baseForOwn(results, function(val, rkey) {
safeResults[rkey] = val;
});
safeResults[key] = result;
hasError = true;
listeners = Object.create(null);
callback(err, safeResults);
} else {
results[key] = result;
taskComplete(key);
}
});
runningTasks++;
var taskFn = wrapAsync(task[task.length - 1]);
if (task.length > 1) {
taskFn(results, taskCallback);
} else {
taskFn(taskCallback);
}
}
function checkForDeadlocks() {
// Kahn's algorithm
// path_to_url#Kahn.27s_algorithm
// path_to_url
var currentTask;
var counter = 0;
while (readyToCheck.length) {
currentTask = readyToCheck.pop();
counter++;
arrayEach(getDependents(currentTask), function (dependent) {
if (--uncheckedDependencies[dependent] === 0) {
readyToCheck.push(dependent);
}
});
}
if (counter !== numTasks) {
throw new Error(
'async.auto cannot execute tasks due to a recursive dependency'
);
}
}
function getDependents(taskName) {
var result = [];
baseForOwn(tasks, function (task, key) {
if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) {
result.push(key);
}
});
return result;
}
};
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && baseGetTag(value) == symbolTag);
}
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
var symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + '';
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
/**
* The base implementation of `_.slice` without an iteratee call guard.
*
* @private
* @param {Array} array The array to slice.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the slice of `array`.
*/
function baseSlice(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : ((end - start) >>> 0);
start >>>= 0;
var result = Array(length);
while (++index < length) {
result[index] = array[index + start];
}
return result;
}
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
/**
* Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
* that is not found in the character symbols.
*
* @private
* @param {Array} strSymbols The string symbols to inspect.
* @param {Array} chrSymbols The character symbols to find.
* @returns {number} Returns the index of the last unmatched string symbol.
*/
function charsEndIndex(strSymbols, chrSymbols) {
var index = strSymbols.length;
while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
}
/**
* Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
* that is not found in the character symbols.
*
* @private
* @param {Array} strSymbols The string symbols to inspect.
* @param {Array} chrSymbols The character symbols to find.
* @returns {number} Returns the index of the first unmatched string symbol.
*/
function charsStartIndex(strSymbols, chrSymbols) {
var index = -1,
length = strSymbols.length;
while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
}
/**
* Converts an ASCII `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function asciiToArray(string) {
return string.split('');
}
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff';
var rsComboMarksRange = '\\u0300-\\u036f';
var reComboHalfMarksRange = '\\ufe20-\\ufe2f';
var rsComboSymbolsRange = '\\u20d0-\\u20ff';
var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
var rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](path_to_url */
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
/**
* Checks if `string` contains Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
*/
function hasUnicode(string) {
return reHasUnicode.test(string);
}
/** Used to compose unicode character classes. */
var rsAstralRange$1 = '\\ud800-\\udfff';
var rsComboMarksRange$1 = '\\u0300-\\u036f';
var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f';
var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff';
var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;
var rsVarRange$1 = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange$1 + ']';
var rsCombo = '[' + rsComboRange$1 + ']';
var rsFitz = '\\ud83c[\\udffb-\\udfff]';
var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
var rsNonAstral = '[^' + rsAstralRange$1 + ']';
var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
var rsZWJ$1 = '\\u200d';
/** Used to compose unicode regexes. */
var reOptMod = rsModifier + '?';
var rsOptVar = '[' + rsVarRange$1 + ']?';
var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
var rsSeq = rsOptVar + reOptMod + rsOptJoin;
var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
/** Used to match [string symbols](path_to_url */
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/**
* Converts a Unicode `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function unicodeToArray(string) {
return string.match(reUnicode) || [];
}
/**
* Converts `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function stringToArray(string) {
return hasUnicode(string)
? unicodeToArray(string)
: asciiToArray(string);
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
/**
* Removes leading and trailing whitespace or specified characters from `string`.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to trim.
* @param {string} [chars=whitespace] The characters to trim.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {string} Returns the trimmed string.
* @example
*
* _.trim(' abc ');
* // => 'abc'
*
* _.trim('-_-abc-_-', '_-');
* // => 'abc'
*
* _.map([' foo ', ' bar '], _.trim);
* // => ['foo', 'bar']
*/
function trim(string, chars, guard) {
string = toString(string);
if (string && (guard || chars === undefined)) {
return string.replace(reTrim, '');
}
if (!string || !(chars = baseToString(chars))) {
return string;
}
var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars),
start = charsStartIndex(strSymbols, chrSymbols),
end = charsEndIndex(strSymbols, chrSymbols) + 1;
return castSlice(strSymbols, start, end).join('');
}
var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /(=.+)?(\s*)$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
function parseParams(func) {
func = func.toString().replace(STRIP_COMMENTS, '');
func = func.match(FN_ARGS)[2].replace(' ', '');
func = func ? func.split(FN_ARG_SPLIT) : [];
func = func.map(function (arg){
return trim(arg.replace(FN_ARG, ''));
});
return func;
}
/**
* A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
* tasks are specified as parameters to the function, after the usual callback
* parameter, with the parameter names matching the names of the tasks it
* depends on. This can provide even more readable task graphs which can be
* easier to maintain.
*
* If a final callback is specified, the task results are similarly injected,
* specified as named parameters after the initial error parameter.
*
* The autoInject function is purely syntactic sugar and its semantics are
* otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
*
* @name autoInject
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.auto]{@link module:ControlFlow.auto}
* @category Control Flow
* @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
* the form 'func([dependencies...], callback). The object's key of a property
* serves as the name of the task defined by that property, i.e. can be used
* when specifying requirements for other tasks.
* * The `callback` parameter is a `callback(err, result)` which must be called
* when finished, passing an `error` (which can be `null`) and the result of
* the function's execution. The remaining parameters name other tasks on
* which the task is dependent, and the results from those tasks are the
* arguments of those parameters.
* @param {Function} [callback] - An optional callback which is called when all
* the tasks have been completed. It receives the `err` argument if any `tasks`
* pass an error to their callback, and a `results` object with any completed
* task results, similar to `auto`.
* @example
*
* // The example from `auto` can be rewritten as follows:
* async.autoInject({
* get_data: function(callback) {
* // async code to get some data
* callback(null, 'data', 'converted to array');
* },
* make_folder: function(callback) {
* // async code to create a directory to store a file in
* // this is run at the same time as getting the data
* callback(null, 'folder');
* },
* write_file: function(get_data, make_folder, callback) {
* // once there is some data and the directory exists,
* // write the data to a file in the directory
* callback(null, 'filename');
* },
* email_link: function(write_file, callback) {
* // once the file is written let's email a link to it...
* // write_file contains the filename returned by write_file.
* callback(null, {'file':write_file, 'email':'user@example.com'});
* }
* }, function(err, results) {
* console.log('err = ', err);
* console.log('email_link = ', results.email_link);
* });
*
* // If you are using a JS minifier that mangles parameter names, `autoInject`
* // will not work with plain functions, since the parameter names will be
* // collapsed to a single letter identifier. To work around this, you can
* // explicitly specify the names of the parameters your task function needs
* // in an array, similar to Angular.js dependency injection.
*
* // This still has an advantage over plain `auto`, since the results a task
* // depends on are still spread into arguments.
* async.autoInject({
* //...
* write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
* callback(null, 'filename');
* }],
* email_link: ['write_file', function(write_file, callback) {
* callback(null, {'file':write_file, 'email':'user@example.com'});
* }]
* //...
* }, function(err, results) {
* console.log('err = ', err);
* console.log('email_link = ', results.email_link);
* });
*/
function autoInject(tasks, callback) {
var newTasks = {};
baseForOwn(tasks, function (taskFn, key) {
var params;
var fnIsAsync = isAsync(taskFn);
var hasNoDeps =
(!fnIsAsync && taskFn.length === 1) ||
(fnIsAsync && taskFn.length === 0);
if (isArray(taskFn)) {
params = taskFn.slice(0, -1);
taskFn = taskFn[taskFn.length - 1];
newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
} else if (hasNoDeps) {
// no dependencies, use the function as-is
newTasks[key] = taskFn;
} else {
params = parseParams(taskFn);
if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
throw new Error("autoInject task functions require explicit parameters.");
}
// remove callback param
if (!fnIsAsync) params.pop();
newTasks[key] = params.concat(newTask);
}
function newTask(results, taskCb) {
var newArgs = arrayMap(params, function (name) {
return results[name];
});
newArgs.push(taskCb);
wrapAsync(taskFn).apply(null, newArgs);
}
});
auto(newTasks, callback);
}
// Simple doubly linked list (path_to_url implementation
// used for queues. This implementation assumes that the node provided by the user can be modified
// to adjust the next and last properties. We implement only the minimal functionality
// for queue support.
function DLL() {
this.head = this.tail = null;
this.length = 0;
}
function setInitial(dll, node) {
dll.length = 1;
dll.head = dll.tail = node;
}
DLL.prototype.removeLink = function(node) {
if (node.prev) node.prev.next = node.next;
else this.head = node.next;
if (node.next) node.next.prev = node.prev;
else this.tail = node.prev;
node.prev = node.next = null;
this.length -= 1;
return node;
};
DLL.prototype.empty = function () {
while(this.head) this.shift();
return this;
};
DLL.prototype.insertAfter = function(node, newNode) {
newNode.prev = node;
newNode.next = node.next;
if (node.next) node.next.prev = newNode;
else this.tail = newNode;
node.next = newNode;
this.length += 1;
};
DLL.prototype.insertBefore = function(node, newNode) {
newNode.prev = node.prev;
newNode.next = node;
if (node.prev) node.prev.next = newNode;
else this.head = newNode;
node.prev = newNode;
this.length += 1;
};
DLL.prototype.unshift = function(node) {
if (this.head) this.insertBefore(this.head, node);
else setInitial(this, node);
};
DLL.prototype.push = function(node) {
if (this.tail) this.insertAfter(this.tail, node);
else setInitial(this, node);
};
DLL.prototype.shift = function() {
return this.head && this.removeLink(this.head);
};
DLL.prototype.pop = function() {
return this.tail && this.removeLink(this.tail);
};
DLL.prototype.toArray = function () {
var arr = Array(this.length);
var curr = this.head;
for(var idx = 0; idx < this.length; idx++) {
arr[idx] = curr.data;
curr = curr.next;
}
return arr;
};
DLL.prototype.remove = function (testFn) {
var curr = this.head;
while(!!curr) {
var next = curr.next;
if (testFn(curr)) {
this.removeLink(curr);
}
curr = next;
}
return this;
};
function queue(worker, concurrency, payload) {
if (concurrency == null) {
concurrency = 1;
}
else if(concurrency === 0) {
throw new Error('Concurrency must not be zero');
}
var _worker = wrapAsync(worker);
var numRunning = 0;
var workersList = [];
var processingScheduled = false;
function _insert(data, insertAtFront, callback) {
if (callback != null && typeof callback !== 'function') {
throw new Error('task callback must be a function');
}
q.started = true;
if (!isArray(data)) {
data = [data];
}
if (data.length === 0 && q.idle()) {
// call drain immediately if there are no tasks
return setImmediate$1(function() {
q.drain();
});
}
for (var i = 0, l = data.length; i < l; i++) {
var item = {
data: data[i],
callback: callback || noop
};
if (insertAtFront) {
q._tasks.unshift(item);
} else {
q._tasks.push(item);
}
}
if (!processingScheduled) {
processingScheduled = true;
setImmediate$1(function() {
processingScheduled = false;
q.process();
});
}
}
function _next(tasks) {
return function(err){
numRunning -= 1;
for (var i = 0, l = tasks.length; i < l; i++) {
var task = tasks[i];
var index = baseIndexOf(workersList, task, 0);
if (index === 0) {
workersList.shift();
} else if (index > 0) {
workersList.splice(index, 1);
}
task.callback.apply(task, arguments);
if (err != null) {
q.error(err, task.data);
}
}
if (numRunning <= (q.concurrency - q.buffer) ) {
q.unsaturated();
}
if (q.idle()) {
q.drain();
}
q.process();
};
}
var isProcessing = false;
var q = {
_tasks: new DLL(),
concurrency: concurrency,
payload: payload,
saturated: noop,
unsaturated:noop,
buffer: concurrency / 4,
empty: noop,
drain: noop,
error: noop,
started: false,
paused: false,
push: function (data, callback) {
_insert(data, false, callback);
},
kill: function () {
q.drain = noop;
q._tasks.empty();
},
unshift: function (data, callback) {
_insert(data, true, callback);
},
remove: function (testFn) {
q._tasks.remove(testFn);
},
process: function () {
// Avoid trying to start too many processing operations. This can occur
// when callbacks resolve synchronously (#1267).
if (isProcessing) {
return;
}
isProcessing = true;
while(!q.paused && numRunning < q.concurrency && q._tasks.length){
var tasks = [], data = [];
var l = q._tasks.length;
if (q.payload) l = Math.min(l, q.payload);
for (var i = 0; i < l; i++) {
var node = q._tasks.shift();
tasks.push(node);
workersList.push(node);
data.push(node.data);
}
numRunning += 1;
if (q._tasks.length === 0) {
q.empty();
}
if (numRunning === q.concurrency) {
q.saturated();
}
var cb = onlyOnce(_next(tasks));
_worker(data, cb);
}
isProcessing = false;
},
length: function () {
return q._tasks.length;
},
running: function () {
return numRunning;
},
workersList: function () {
return workersList;
},
idle: function() {
return q._tasks.length + numRunning === 0;
},
pause: function () {
q.paused = true;
},
resume: function () {
if (q.paused === false) { return; }
q.paused = false;
setImmediate$1(q.process);
}
};
return q;
}
/**
* A cargo of tasks for the worker function to complete. Cargo inherits all of
* the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
* @typedef {Object} CargoObject
* @memberOf module:ControlFlow
* @property {Function} length - A function returning the number of items
* waiting to be processed. Invoke like `cargo.length()`.
* @property {number} payload - An `integer` for determining how many tasks
* should be process per round. This property can be changed after a `cargo` is
* created to alter the payload on-the-fly.
* @property {Function} push - Adds `task` to the `queue`. The callback is
* called once the `worker` has finished processing the task. Instead of a
* single task, an array of `tasks` can be submitted. The respective callback is
* used for every task in the list. Invoke like `cargo.push(task, [callback])`.
* @property {Function} saturated - A callback that is called when the
* `queue.length()` hits the concurrency and further tasks will be queued.
* @property {Function} empty - A callback that is called when the last item
* from the `queue` is given to a `worker`.
* @property {Function} drain - A callback that is called when the last item
* from the `queue` has returned from the `worker`.
* @property {Function} idle - a function returning false if there are items
* waiting or being processed, or true if not. Invoke like `cargo.idle()`.
* @property {Function} pause - a function that pauses the processing of tasks
* until `resume()` is called. Invoke like `cargo.pause()`.
* @property {Function} resume - a function that resumes the processing of
* queued tasks when the queue is paused. Invoke like `cargo.resume()`.
* @property {Function} kill - a function that removes the `drain` callback and
* empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
*/
/**
* Creates a `cargo` object with the specified payload. Tasks added to the
* cargo will be processed altogether (up to the `payload` limit). If the
* `worker` is in progress, the task is queued until it becomes available. Once
* the `worker` has completed some tasks, each callback of those tasks is
* called. Check out [these](path_to_url [animations](path_to_url
* for how `cargo` and `queue` work.
*
* While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
* at a time, cargo passes an array of tasks to a single worker, repeating
* when the worker is finished.
*
* @name cargo
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.queue]{@link module:ControlFlow.queue}
* @category Control Flow
* @param {AsyncFunction} worker - An asynchronous function for processing an array
* of queued tasks. Invoked with `(tasks, callback)`.
* @param {number} [payload=Infinity] - An optional `integer` for determining
* how many tasks should be processed per round; if omitted, the default is
* unlimited.
* @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
* attached as certain properties to listen for specific events during the
* lifecycle of the cargo and inner queue.
* @example
*
* // create a cargo object with payload 2
* var cargo = async.cargo(function(tasks, callback) {
* for (var i=0; i<tasks.length; i++) {
* console.log('hello ' + tasks[i].name);
* }
* callback();
* }, 2);
*
* // add some items
* cargo.push({name: 'foo'}, function(err) {
* console.log('finished processing foo');
* });
* cargo.push({name: 'bar'}, function(err) {
* console.log('finished processing bar');
* });
* cargo.push({name: 'baz'}, function(err) {
* console.log('finished processing baz');
* });
*/
function cargo(worker, payload) {
return queue(worker, 1, payload);
}
/**
* The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
*
* @name eachOfSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.eachOf]{@link module:Collections.eachOf}
* @alias forEachOfSeries
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* Invoked with (item, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. Invoked with (err).
*/
var eachOfSeries = doLimit(eachOfLimit, 1);
/**
* Reduces `coll` into a single value using an async `iteratee` to return each
* successive step. `memo` is the initial state of the reduction. This function
* only operates in series.
*
* For performance reasons, it may make sense to split a call to this function
* into a parallel map, and then use the normal `Array.prototype.reduce` on the
* results. This function is for situations where each step in the reduction
* needs to be async; if you can get the data before reducing it, then it's
* probably a good idea to do so.
*
* @name reduce
* @static
* @memberOf module:Collections
* @method
* @alias inject
* @alias foldl
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {*} memo - The initial state of the reduction.
* @param {AsyncFunction} iteratee - A function applied to each item in the
* array to produce the next step in the reduction.
* The `iteratee` should complete with the next state of the reduction.
* If the iteratee complete with an error, the reduction is stopped and the
* main `callback` is immediately called with the error.
* Invoked with (memo, item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Result is the reduced value. Invoked with
* (err, result).
* @example
*
* async.reduce([1,2,3], 0, function(memo, item, callback) {
* // pointless async:
* process.nextTick(function() {
* callback(null, memo + item)
* });
* }, function(err, result) {
* // result is now equal to the last value of memo, which is 6
* });
*/
function reduce(coll, memo, iteratee, callback) {
callback = once(callback || noop);
var _iteratee = wrapAsync(iteratee);
eachOfSeries(coll, function(x, i, callback) {
_iteratee(memo, x, function(err, v) {
memo = v;
callback(err);
});
}, function(err) {
callback(err, memo);
});
}
/**
* Version of the compose function that is more natural to read. Each function
* consumes the return value of the previous function. It is the equivalent of
* [compose]{@link module:ControlFlow.compose} with the arguments reversed.
*
* Each function is executed with the `this` binding of the composed function.
*
* @name seq
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.compose]{@link module:ControlFlow.compose}
* @category Control Flow
* @param {...AsyncFunction} functions - the asynchronous functions to compose
* @returns {Function} a function that composes the `functions` in order
* @example
*
* // Requires lodash (or underscore), express3 and dresende's orm2.
* // Part of an app, that fetches cats of the logged user.
* // This example uses `seq` function to avoid overnesting and error
* // handling clutter.
* app.get('/cats', function(request, response) {
* var User = request.models.User;
* async.seq(
* _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
* function(user, fn) {
* user.getCats(fn); // 'getCats' has signature (callback(err, data))
* }
* )(req.session.user_id, function (err, cats) {
* if (err) {
* console.error(err);
* response.json({ status: 'error', message: err.message });
* } else {
* response.json({ status: 'ok', message: 'Cats found', data: cats });
* }
* });
* });
*/
function seq(/*...functions*/) {
var _functions = arrayMap(arguments, wrapAsync);
return function(/*...args*/) {
var args = slice(arguments);
var that = this;
var cb = args[args.length - 1];
if (typeof cb == 'function') {
args.pop();
} else {
cb = noop;
}
reduce(_functions, args, function(newargs, fn, cb) {
fn.apply(that, newargs.concat(function(err/*, ...nextargs*/) {
var nextargs = slice(arguments, 1);
cb(err, nextargs);
}));
},
function(err, results) {
cb.apply(that, [err].concat(results));
});
};
}
/**
* Creates a function which is a composition of the passed asynchronous
* functions. Each function consumes the return value of the function that
* follows. Composing functions `f()`, `g()`, and `h()` would produce the result
* of `f(g(h()))`, only this version uses callbacks to obtain the return values.
*
* Each function is executed with the `this` binding of the composed function.
*
* @name compose
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {...AsyncFunction} functions - the asynchronous functions to compose
* @returns {Function} an asynchronous function that is the composed
* asynchronous `functions`
* @example
*
* function add1(n, callback) {
* setTimeout(function () {
* callback(null, n + 1);
* }, 10);
* }
*
* function mul3(n, callback) {
* setTimeout(function () {
* callback(null, n * 3);
* }, 10);
* }
*
* var add1mul3 = async.compose(mul3, add1);
* add1mul3(4, function (err, result) {
* // result now equals 15
* });
*/
var compose = function(/*...args*/) {
return seq.apply(null, slice(arguments).reverse());
};
var _concat = Array.prototype.concat;
/**
* The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
*
* @name concatLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.concat]{@link module:Collections.concat}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
* which should use an array as its result. Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished, or an error occurs. Results is an array
* containing the concatenated results of the `iteratee` function. Invoked with
* (err, results).
*/
var concatLimit = function(coll, limit, iteratee, callback) {
callback = callback || noop;
var _iteratee = wrapAsync(iteratee);
mapLimit(coll, limit, function(val, callback) {
_iteratee(val, function(err /*, ...args*/) {
if (err) return callback(err);
return callback(null, slice(arguments, 1));
});
}, function(err, mapResults) {
var result = [];
for (var i = 0; i < mapResults.length; i++) {
if (mapResults[i]) {
result = _concat.apply(result, mapResults[i]);
}
}
return callback(err, result);
});
};
/**
* Applies `iteratee` to each item in `coll`, concatenating the results. Returns
* the concatenated list. The `iteratee`s are called in parallel, and the
* results are concatenated as they return. There is no guarantee that the
* results array will be returned in the original order of `coll` passed to the
* `iteratee` function.
*
* @name concat
* @static
* @memberOf module:Collections
* @method
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
* which should use an array as its result. Invoked with (item, callback).
* @param {Function} [callback(err)] - A callback which is called after all the
* `iteratee` functions have finished, or an error occurs. Results is an array
* containing the concatenated results of the `iteratee` function. Invoked with
* (err, results).
* @example
*
* async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
* // files is now a list of filenames that exist in the 3 directories
* });
*/
var concat = doLimit(concatLimit, Infinity);
/**
* The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
*
* @name concatSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.concat]{@link module:Collections.concat}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
* The iteratee should complete with an array an array of results.
* Invoked with (item, callback).
* @param {Function} [callback(err)] - A callback which is called after all the
* `iteratee` functions have finished, or an error occurs. Results is an array
* containing the concatenated results of the `iteratee` function. Invoked with
* (err, results).
*/
var concatSeries = doLimit(concatLimit, 1);
/**
* Returns a function that when called, calls-back with the values provided.
* Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
* [`auto`]{@link module:ControlFlow.auto}.
*
* @name constant
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {...*} arguments... - Any number of arguments to automatically invoke
* callback with.
* @returns {AsyncFunction} Returns a function that when invoked, automatically
* invokes the callback with the previous given arguments.
* @example
*
* async.waterfall([
* async.constant(42),
* function (value, next) {
* // value === 42
* },
* //...
* ], callback);
*
* async.waterfall([
* async.constant(filename, "utf8"),
* fs.readFile,
* function (fileData, next) {
* //...
* }
* //...
* ], callback);
*
* async.auto({
* hostname: async.constant("path_to_url"),
* port: findFreePort,
* launchServer: ["hostname", "port", function (options, cb) {
* startServer(options, cb);
* }],
* //...
* }, callback);
*/
var constant = function(/*...values*/) {
var values = slice(arguments);
var args = [null].concat(values);
return function (/*...ignoredArgs, callback*/) {
var callback = arguments[arguments.length - 1];
return callback.apply(this, args);
};
};
/**
* This method returns the first argument it receives.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {*} value Any value.
* @returns {*} Returns `value`.
* @example
*
* var object = { 'a': 1 };
*
* console.log(_.identity(object) === object);
* // => true
*/
function identity(value) {
return value;
}
function _createTester(check, getResult) {
return function(eachfn, arr, iteratee, cb) {
cb = cb || noop;
var testPassed = false;
var testResult;
eachfn(arr, function(value, _, callback) {
iteratee(value, function(err, result) {
if (err) {
callback(err);
} else if (check(result) && !testResult) {
testPassed = true;
testResult = getResult(true, value);
callback(null, breakLoop);
} else {
callback();
}
});
}, function(err) {
if (err) {
cb(err);
} else {
cb(null, testPassed ? testResult : getResult(false));
}
});
};
}
function _findGetResult(v, x) {
return x;
}
/**
* Returns the first value in `coll` that passes an async truth test. The
* `iteratee` is applied in parallel, meaning the first iteratee to return
* `true` will fire the detect `callback` with that result. That means the
* result might not be the first item in the original `coll` (in terms of order)
* that passes the test.
* If order within the original `coll` is important, then look at
* [`detectSeries`]{@link module:Collections.detectSeries}.
*
* @name detect
* @static
* @memberOf module:Collections
* @method
* @alias find
* @category Collections
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
* The iteratee must complete with a boolean value as its result.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called as soon as any
* iteratee returns `true`, or after all the `iteratee` functions have finished.
* Result will be the first item in the array that passes the truth test
* (iteratee) or the value `undefined` if none passed. Invoked with
* (err, result).
* @example
*
* async.detect(['file1','file2','file3'], function(filePath, callback) {
* fs.access(filePath, function(err) {
* callback(null, !err)
* });
* }, function(err, result) {
* // result now equals the first file in the list that exists
* });
*/
var detect = doParallel(_createTester(identity, _findGetResult));
/**
* The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
* time.
*
* @name detectLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.detect]{@link module:Collections.detect}
* @alias findLimit
* @category Collections
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
* The iteratee must complete with a boolean value as its result.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called as soon as any
* iteratee returns `true`, or after all the `iteratee` functions have finished.
* Result will be the first item in the array that passes the truth test
* (iteratee) or the value `undefined` if none passed. Invoked with
* (err, result).
*/
var detectLimit = doParallelLimit(_createTester(identity, _findGetResult));
/**
* The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
*
* @name detectSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.detect]{@link module:Collections.detect}
* @alias findSeries
* @category Collections
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
* The iteratee must complete with a boolean value as its result.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called as soon as any
* iteratee returns `true`, or after all the `iteratee` functions have finished.
* Result will be the first item in the array that passes the truth test
* (iteratee) or the value `undefined` if none passed. Invoked with
* (err, result).
*/
var detectSeries = doLimit(detectLimit, 1);
function consoleFunc(name) {
return function (fn/*, ...args*/) {
var args = slice(arguments, 1);
args.push(function (err/*, ...args*/) {
var args = slice(arguments, 1);
if (typeof console === 'object') {
if (err) {
if (console.error) {
console.error(err);
}
} else if (console[name]) {
arrayEach(args, function (x) {
console[name](x);
});
}
}
});
wrapAsync(fn).apply(null, args);
};
}
/**
* Logs the result of an [`async` function]{@link AsyncFunction} to the
* `console` using `console.dir` to display the properties of the resulting object.
* Only works in Node.js or in browsers that support `console.dir` and
* `console.error` (such as FF and Chrome).
* If multiple arguments are returned from the async function,
* `console.dir` is called on each argument in order.
*
* @name dir
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {AsyncFunction} function - The function you want to eventually apply
* all arguments to.
* @param {...*} arguments... - Any number of arguments to apply to the function.
* @example
*
* // in a module
* var hello = function(name, callback) {
* setTimeout(function() {
* callback(null, {hello: name});
* }, 1000);
* };
*
* // in the node repl
* node> async.dir(hello, 'world');
* {hello: 'world'}
*/
var dir = consoleFunc('dir');
/**
* The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
* the order of operations, the arguments `test` and `fn` are switched.
*
* Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
* @name doDuring
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.during]{@link module:ControlFlow.during}
* @category Control Flow
* @param {AsyncFunction} fn - An async function which is called each time
* `test` passes. Invoked with (callback).
* @param {AsyncFunction} test - asynchronous truth test to perform before each
* execution of `fn`. Invoked with (...args, callback), where `...args` are the
* non-error args from the previous callback of `fn`.
* @param {Function} [callback] - A callback which is called after the test
* function has failed and repeated execution of `fn` has stopped. `callback`
* will be passed an error if one occurred, otherwise `null`.
*/
function doDuring(fn, test, callback) {
callback = onlyOnce(callback || noop);
var _fn = wrapAsync(fn);
var _test = wrapAsync(test);
function next(err/*, ...args*/) {
if (err) return callback(err);
var args = slice(arguments, 1);
args.push(check);
_test.apply(this, args);
}
function check(err, truth) {
if (err) return callback(err);
if (!truth) return callback(null);
_fn(next);
}
check(null, true);
}
/**
* The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
* the order of operations, the arguments `test` and `iteratee` are switched.
*
* `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
*
* @name doWhilst
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.whilst]{@link module:ControlFlow.whilst}
* @category Control Flow
* @param {AsyncFunction} iteratee - A function which is called each time `test`
* passes. Invoked with (callback).
* @param {Function} test - synchronous truth test to perform after each
* execution of `iteratee`. Invoked with any non-error callback results of
* `iteratee`.
* @param {Function} [callback] - A callback which is called after the test
* function has failed and repeated execution of `iteratee` has stopped.
* `callback` will be passed an error and any arguments passed to the final
* `iteratee`'s callback. Invoked with (err, [results]);
*/
function doWhilst(iteratee, test, callback) {
callback = onlyOnce(callback || noop);
var _iteratee = wrapAsync(iteratee);
var next = function(err/*, ...args*/) {
if (err) return callback(err);
var args = slice(arguments, 1);
if (test.apply(this, args)) return _iteratee(next);
callback.apply(null, [null].concat(args));
};
_iteratee(next);
}
/**
* Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
* argument ordering differs from `until`.
*
* @name doUntil
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
* @category Control Flow
* @param {AsyncFunction} iteratee - An async function which is called each time
* `test` fails. Invoked with (callback).
* @param {Function} test - synchronous truth test to perform after each
* execution of `iteratee`. Invoked with any non-error callback results of
* `iteratee`.
* @param {Function} [callback] - A callback which is called after the test
* function has passed and repeated execution of `iteratee` has stopped. `callback`
* will be passed an error and any arguments passed to the final `iteratee`'s
* callback. Invoked with (err, [results]);
*/
function doUntil(iteratee, test, callback) {
doWhilst(iteratee, function() {
return !test.apply(this, arguments);
}, callback);
}
/**
* Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
* is passed a callback in the form of `function (err, truth)`. If error is
* passed to `test` or `fn`, the main callback is immediately called with the
* value of the error.
*
* @name during
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.whilst]{@link module:ControlFlow.whilst}
* @category Control Flow
* @param {AsyncFunction} test - asynchronous truth test to perform before each
* execution of `fn`. Invoked with (callback).
* @param {AsyncFunction} fn - An async function which is called each time
* `test` passes. Invoked with (callback).
* @param {Function} [callback] - A callback which is called after the test
* function has failed and repeated execution of `fn` has stopped. `callback`
* will be passed an error, if one occurred, otherwise `null`.
* @example
*
* var count = 0;
*
* async.during(
* function (callback) {
* return callback(null, count < 5);
* },
* function (callback) {
* count++;
* setTimeout(callback, 1000);
* },
* function (err) {
* // 5 seconds have passed
* }
* );
*/
function during(test, fn, callback) {
callback = onlyOnce(callback || noop);
var _fn = wrapAsync(fn);
var _test = wrapAsync(test);
function next(err) {
if (err) return callback(err);
_test(check);
}
function check(err, truth) {
if (err) return callback(err);
if (!truth) return callback(null);
_fn(next);
}
_test(check);
}
function _withoutIndex(iteratee) {
return function (value, index, callback) {
return iteratee(value, callback);
};
}
/**
* Applies the function `iteratee` to each item in `coll`, in parallel.
* The `iteratee` is called with an item from the list, and a callback for when
* it has finished. If the `iteratee` passes an error to its `callback`, the
* main `callback` (for the `each` function) is immediately called with the
* error.
*
* Note, that since this function applies `iteratee` to each item in parallel,
* there is no guarantee that the iteratee functions will complete in order.
*
* @name each
* @static
* @memberOf module:Collections
* @method
* @alias forEach
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async function to apply to
* each item in `coll`. Invoked with (item, callback).
* The array index is not passed to the iteratee.
* If you need the index, use `eachOf`.
* @param {Function} [callback] - A callback which is called when all
* `iteratee` functions have finished, or an error occurs. Invoked with (err).
* @example
*
* // assuming openFiles is an array of file names and saveFile is a function
* // to save the modified contents of that file:
*
* async.each(openFiles, saveFile, function(err){
* // if any of the saves produced an error, err would equal that error
* });
*
* // assuming openFiles is an array of file names
* async.each(openFiles, function(file, callback) {
*
* // Perform operation on file here.
* console.log('Processing file ' + file);
*
* if( file.length > 32 ) {
* console.log('This file name is too long');
* callback('File name too long');
* } else {
* // Do work to process file here
* console.log('File processed');
* callback();
* }
* }, function(err) {
* // if any of the file processing produced an error, err would equal that error
* if( err ) {
* // One of the iterations produced an error.
* // All processing will now stop.
* console.log('A file failed to process');
* } else {
* console.log('All files have been processed successfully');
* }
* });
*/
function eachLimit(coll, iteratee, callback) {
eachOf(coll, _withoutIndex(wrapAsync(iteratee)), callback);
}
/**
* The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
*
* @name eachLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.each]{@link module:Collections.each}
* @alias forEachLimit
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The array index is not passed to the iteratee.
* If you need the index, use `eachOfLimit`.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called when all
* `iteratee` functions have finished, or an error occurs. Invoked with (err).
*/
function eachLimit$1(coll, limit, iteratee, callback) {
_eachOfLimit(limit)(coll, _withoutIndex(wrapAsync(iteratee)), callback);
}
/**
* The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
*
* @name eachSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.each]{@link module:Collections.each}
* @alias forEachSeries
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async function to apply to each
* item in `coll`.
* The array index is not passed to the iteratee.
* If you need the index, use `eachOfSeries`.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called when all
* `iteratee` functions have finished, or an error occurs. Invoked with (err).
*/
var eachSeries = doLimit(eachLimit$1, 1);
/**
* Wrap an async function and ensure it calls its callback on a later tick of
* the event loop. If the function already calls its callback on a next tick,
* no extra deferral is added. This is useful for preventing stack overflows
* (`RangeError: Maximum call stack size exceeded`) and generally keeping
* [Zalgo](path_to_url
* contained. ES2017 `async` functions are returned as-is -- they are immune
* to Zalgo's corrupting influences, as they always resolve on a later tick.
*
* @name ensureAsync
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {AsyncFunction} fn - an async function, one that expects a node-style
* callback as its last argument.
* @returns {AsyncFunction} Returns a wrapped function with the exact same call
* signature as the function passed in.
* @example
*
* function sometimesAsync(arg, callback) {
* if (cache[arg]) {
* return callback(null, cache[arg]); // this would be synchronous!!
* } else {
* doSomeIO(arg, callback); // this IO would be asynchronous
* }
* }
*
* // this has a risk of stack overflows if many results are cached in a row
* async.mapSeries(args, sometimesAsync, done);
*
* // this will defer sometimesAsync's callback if necessary,
* // preventing stack overflows
* async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
*/
function ensureAsync(fn) {
if (isAsync(fn)) return fn;
return initialParams(function (args, callback) {
var sync = true;
args.push(function () {
var innerArgs = arguments;
if (sync) {
setImmediate$1(function () {
callback.apply(null, innerArgs);
});
} else {
callback.apply(null, innerArgs);
}
});
fn.apply(this, args);
sync = false;
});
}
function notId(v) {
return !v;
}
/**
* Returns `true` if every element in `coll` satisfies an async test. If any
* iteratee call returns `false`, the main `callback` is immediately called.
*
* @name every
* @static
* @memberOf module:Collections
* @method
* @alias all
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
* in the collection in parallel.
* The iteratee must complete with a boolean result value.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Result will be either `true` or `false`
* depending on the values of the async tests. Invoked with (err, result).
* @example
*
* async.every(['file1','file2','file3'], function(filePath, callback) {
* fs.access(filePath, function(err) {
* callback(null, !err)
* });
* }, function(err, result) {
* // if result is true then every file exists
* });
*/
var every = doParallel(_createTester(notId, notId));
/**
* The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
*
* @name everyLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.every]{@link module:Collections.every}
* @alias allLimit
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
* in the collection in parallel.
* The iteratee must complete with a boolean result value.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Result will be either `true` or `false`
* depending on the values of the async tests. Invoked with (err, result).
*/
var everyLimit = doParallelLimit(_createTester(notId, notId));
/**
* The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
*
* @name everySeries
* @static
* @memberOf module:Collections
* @method
* @see [async.every]{@link module:Collections.every}
* @alias allSeries
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
* in the collection in series.
* The iteratee must complete with a boolean result value.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Result will be either `true` or `false`
* depending on the values of the async tests. Invoked with (err, result).
*/
var everySeries = doLimit(everyLimit, 1);
/**
* The base implementation of `_.property` without support for deep paths.
*
* @private
* @param {string} key The key of the property to get.
* @returns {Function} Returns the new accessor function.
*/
function baseProperty(key) {
return function(object) {
return object == null ? undefined : object[key];
};
}
function filterArray(eachfn, arr, iteratee, callback) {
var truthValues = new Array(arr.length);
eachfn(arr, function (x, index, callback) {
iteratee(x, function (err, v) {
truthValues[index] = !!v;
callback(err);
});
}, function (err) {
if (err) return callback(err);
var results = [];
for (var i = 0; i < arr.length; i++) {
if (truthValues[i]) results.push(arr[i]);
}
callback(null, results);
});
}
function filterGeneric(eachfn, coll, iteratee, callback) {
var results = [];
eachfn(coll, function (x, index, callback) {
iteratee(x, function (err, v) {
if (err) {
callback(err);
} else {
if (v) {
results.push({index: index, value: x});
}
callback();
}
});
}, function (err) {
if (err) {
callback(err);
} else {
callback(null, arrayMap(results.sort(function (a, b) {
return a.index - b.index;
}), baseProperty('value')));
}
});
}
function _filter(eachfn, coll, iteratee, callback) {
var filter = isArrayLike(coll) ? filterArray : filterGeneric;
filter(eachfn, coll, wrapAsync(iteratee), callback || noop);
}
/**
* Returns a new array of all the values in `coll` which pass an async truth
* test. This operation is performed in parallel, but the results array will be
* in the same order as the original.
*
* @name filter
* @static
* @memberOf module:Collections
* @method
* @alias select
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
* The `iteratee` is passed a `callback(err, truthValue)`, which must be called
* with a boolean argument once it has completed. Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Invoked with (err, results).
* @example
*
* async.filter(['file1','file2','file3'], function(filePath, callback) {
* fs.access(filePath, function(err) {
* callback(null, !err)
* });
* }, function(err, results) {
* // results now equals an array of the existing files
* });
*/
var filter = doParallel(_filter);
/**
* The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
* time.
*
* @name filterLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.filter]{@link module:Collections.filter}
* @alias selectLimit
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
* The `iteratee` is passed a `callback(err, truthValue)`, which must be called
* with a boolean argument once it has completed. Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Invoked with (err, results).
*/
var filterLimit = doParallelLimit(_filter);
/**
* The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
*
* @name filterSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.filter]{@link module:Collections.filter}
* @alias selectSeries
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
* The `iteratee` is passed a `callback(err, truthValue)`, which must be called
* with a boolean argument once it has completed. Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Invoked with (err, results)
*/
var filterSeries = doLimit(filterLimit, 1);
/**
* Calls the asynchronous function `fn` with a callback parameter that allows it
* to call itself again, in series, indefinitely.
* If an error is passed to the callback then `errback` is called with the
* error, and execution stops, otherwise it will never be called.
*
* @name forever
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {AsyncFunction} fn - an async function to call repeatedly.
* Invoked with (next).
* @param {Function} [errback] - when `fn` passes an error to it's callback,
* this function will be called, and execution stops. Invoked with (err).
* @example
*
* async.forever(
* function(next) {
* // next is suitable for passing to things that need a callback(err [, whatever]);
* // it will result in this function being called again.
* },
* function(err) {
* // if next is called with a value in its first parameter, it will appear
* // in here as 'err', and execution will stop.
* }
* );
*/
function forever(fn, errback) {
var done = onlyOnce(errback || noop);
var task = wrapAsync(ensureAsync(fn));
function next(err) {
if (err) return done(err);
task(next);
}
next();
}
/**
* The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time.
*
* @name groupByLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.groupBy]{@link module:Collections.groupBy}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The iteratee should complete with a `key` to group the value under.
* Invoked with (value, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. Result is an `Object` whoses
* properties are arrays of values which returned the corresponding key.
*/
var groupByLimit = function(coll, limit, iteratee, callback) {
callback = callback || noop;
var _iteratee = wrapAsync(iteratee);
mapLimit(coll, limit, function(val, callback) {
_iteratee(val, function(err, key) {
if (err) return callback(err);
return callback(null, {key: key, val: val});
});
}, function(err, mapResults) {
var result = {};
// from MDN, handle object having an `hasOwnProperty` prop
var hasOwnProperty = Object.prototype.hasOwnProperty;
for (var i = 0; i < mapResults.length; i++) {
if (mapResults[i]) {
var key = mapResults[i].key;
var val = mapResults[i].val;
if (hasOwnProperty.call(result, key)) {
result[key].push(val);
} else {
result[key] = [val];
}
}
}
return callback(err, result);
});
};
/**
* Returns a new object, where each value corresponds to an array of items, from
* `coll`, that returned the corresponding key. That is, the keys of the object
* correspond to the values passed to the `iteratee` callback.
*
* Note: Since this function applies the `iteratee` to each item in parallel,
* there is no guarantee that the `iteratee` functions will complete in order.
* However, the values for each key in the `result` will be in the same order as
* the original `coll`. For Objects, the values will roughly be in the order of
* the original Objects' keys (but this can vary across JavaScript engines).
*
* @name groupBy
* @static
* @memberOf module:Collections
* @method
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The iteratee should complete with a `key` to group the value under.
* Invoked with (value, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. Result is an `Object` whoses
* properties are arrays of values which returned the corresponding key.
* @example
*
* async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
* db.findById(userId, function(err, user) {
* if (err) return callback(err);
* return callback(null, user.age);
* });
* }, function(err, result) {
* // result is object containing the userIds grouped by age
* // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
* });
*/
var groupBy = doLimit(groupByLimit, Infinity);
/**
* The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time.
*
* @name groupBySeries
* @static
* @memberOf module:Collections
* @method
* @see [async.groupBy]{@link module:Collections.groupBy}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The iteratee should complete with a `key` to group the value under.
* Invoked with (value, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. Result is an `Object` whoses
* properties are arrays of values which returned the corresponding key.
*/
var groupBySeries = doLimit(groupByLimit, 1);
/**
* Logs the result of an `async` function to the `console`. Only works in
* Node.js or in browsers that support `console.log` and `console.error` (such
* as FF and Chrome). If multiple arguments are returned from the async
* function, `console.log` is called on each argument in order.
*
* @name log
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {AsyncFunction} function - The function you want to eventually apply
* all arguments to.
* @param {...*} arguments... - Any number of arguments to apply to the function.
* @example
*
* // in a module
* var hello = function(name, callback) {
* setTimeout(function() {
* callback(null, 'hello ' + name);
* }, 1000);
* };
*
* // in the node repl
* node> async.log(hello, 'world');
* 'hello world'
*/
var log = consoleFunc('log');
/**
* The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
* time.
*
* @name mapValuesLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.mapValues]{@link module:Collections.mapValues}
* @category Collection
* @param {Object} obj - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - A function to apply to each value and key
* in `coll`.
* The iteratee should complete with the transformed value as its result.
* Invoked with (value, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. `result` is a new object consisting
* of each key from `obj`, with each transformed value on the right-hand side.
* Invoked with (err, result).
*/
function mapValuesLimit(obj, limit, iteratee, callback) {
callback = once(callback || noop);
var newObj = {};
var _iteratee = wrapAsync(iteratee);
eachOfLimit(obj, limit, function(val, key, next) {
_iteratee(val, key, function (err, result) {
if (err) return next(err);
newObj[key] = result;
next();
});
}, function (err) {
callback(err, newObj);
});
}
/**
* A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
*
* Produces a new Object by mapping each value of `obj` through the `iteratee`
* function. The `iteratee` is called each `value` and `key` from `obj` and a
* callback for when it has finished processing. Each of these callbacks takes
* two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
* passes an error to its callback, the main `callback` (for the `mapValues`
* function) is immediately called with the error.
*
* Note, the order of the keys in the result is not guaranteed. The keys will
* be roughly in the order they complete, (but this is very engine-specific)
*
* @name mapValues
* @static
* @memberOf module:Collections
* @method
* @category Collection
* @param {Object} obj - A collection to iterate over.
* @param {AsyncFunction} iteratee - A function to apply to each value and key
* in `coll`.
* The iteratee should complete with the transformed value as its result.
* Invoked with (value, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. `result` is a new object consisting
* of each key from `obj`, with each transformed value on the right-hand side.
* Invoked with (err, result).
* @example
*
* async.mapValues({
* f1: 'file1',
* f2: 'file2',
* f3: 'file3'
* }, function (file, key, callback) {
* fs.stat(file, callback);
* }, function(err, result) {
* // result is now a map of stats for each file, e.g.
* // {
* // f1: [stats for file1],
* // f2: [stats for file2],
* // f3: [stats for file3]
* // }
* });
*/
var mapValues = doLimit(mapValuesLimit, Infinity);
/**
* The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
*
* @name mapValuesSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.mapValues]{@link module:Collections.mapValues}
* @category Collection
* @param {Object} obj - A collection to iterate over.
* @param {AsyncFunction} iteratee - A function to apply to each value and key
* in `coll`.
* The iteratee should complete with the transformed value as its result.
* Invoked with (value, key, callback).
* @param {Function} [callback] - A callback which is called when all `iteratee`
* functions have finished, or an error occurs. `result` is a new object consisting
* of each key from `obj`, with each transformed value on the right-hand side.
* Invoked with (err, result).
*/
var mapValuesSeries = doLimit(mapValuesLimit, 1);
function has(obj, key) {
return key in obj;
}
/**
* Caches the results of an async function. When creating a hash to store
* function results against, the callback is omitted from the hash and an
* optional hash function can be used.
*
* If no hash function is specified, the first argument is used as a hash key,
* which may work reasonably if it is a string or a data type that converts to a
* distinct string. Note that objects and arrays will not behave reasonably.
* Neither will cases where the other arguments are significant. In such cases,
* specify your own hash function.
*
* The cache of results is exposed as the `memo` property of the function
* returned by `memoize`.
*
* @name memoize
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {AsyncFunction} fn - The async function to proxy and cache results from.
* @param {Function} hasher - An optional function for generating a custom hash
* for storing results. It has all the arguments applied to it apart from the
* callback, and must be synchronous.
* @returns {AsyncFunction} a memoized version of `fn`
* @example
*
* var slow_fn = function(name, callback) {
* // do something
* callback(null, result);
* };
* var fn = async.memoize(slow_fn);
*
* // fn can now be used as if it were slow_fn
* fn('some name', function() {
* // callback
* });
*/
function memoize(fn, hasher) {
var memo = Object.create(null);
var queues = Object.create(null);
hasher = hasher || identity;
var _fn = wrapAsync(fn);
var memoized = initialParams(function memoized(args, callback) {
var key = hasher.apply(null, args);
if (has(memo, key)) {
setImmediate$1(function() {
callback.apply(null, memo[key]);
});
} else if (has(queues, key)) {
queues[key].push(callback);
} else {
queues[key] = [callback];
_fn.apply(null, args.concat(function(/*args*/) {
var args = slice(arguments);
memo[key] = args;
var q = queues[key];
delete queues[key];
for (var i = 0, l = q.length; i < l; i++) {
q[i].apply(null, args);
}
}));
}
});
memoized.memo = memo;
memoized.unmemoized = fn;
return memoized;
}
/**
* Calls `callback` on a later loop around the event loop. In Node.js this just
* calls `process.nextTick`. In the browser it will use `setImmediate` if
* available, otherwise `setTimeout(callback, 0)`, which means other higher
* priority events may precede the execution of `callback`.
*
* This is used internally for browser-compatibility purposes.
*
* @name nextTick
* @static
* @memberOf module:Utils
* @method
* @see [async.setImmediate]{@link module:Utils.setImmediate}
* @category Util
* @param {Function} callback - The function to call on a later loop around
* the event loop. Invoked with (args...).
* @param {...*} args... - any number of additional arguments to pass to the
* callback on the next tick.
* @example
*
* var call_order = [];
* async.nextTick(function() {
* call_order.push('two');
* // call_order now equals ['one','two']
* });
* call_order.push('one');
*
* async.setImmediate(function (a, b, c) {
* // a, b, and c equal 1, 2, and 3
* }, 1, 2, 3);
*/
var _defer$1;
if (hasNextTick) {
_defer$1 = process.nextTick;
} else if (hasSetImmediate) {
_defer$1 = setImmediate;
} else {
_defer$1 = fallback;
}
var nextTick = wrap(_defer$1);
function _parallel(eachfn, tasks, callback) {
callback = callback || noop;
var results = isArrayLike(tasks) ? [] : {};
eachfn(tasks, function (task, key, callback) {
wrapAsync(task)(function (err, result) {
if (arguments.length > 2) {
result = slice(arguments, 1);
}
results[key] = result;
callback(err);
});
}, function (err) {
callback(err, results);
});
}
/**
* Run the `tasks` collection of functions in parallel, without waiting until
* the previous function has completed. If any of the functions pass an error to
* its callback, the main `callback` is immediately called with the value of the
* error. Once the `tasks` have completed, the results are passed to the final
* `callback` as an array.
*
* **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
* parallel execution of code. If your tasks do not use any timers or perform
* any I/O, they will actually be executed in series. Any synchronous setup
* sections for each task will happen one after the other. JavaScript remains
* single-threaded.
*
* **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the
* execution of other tasks when a task fails.
*
* It is also possible to use an object instead of an array. Each property will
* be run as a function and the results will be passed to the final `callback`
* as an object instead of an array. This can be a more readable way of handling
* results from {@link async.parallel}.
*
* @name parallel
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Array|Iterable|Object} tasks - A collection of
* [async functions]{@link AsyncFunction} to run.
* Each async function can complete with any number of optional `result` values.
* @param {Function} [callback] - An optional callback to run once all the
* functions have completed successfully. This function gets a results array
* (or object) containing all the result arguments passed to the task callbacks.
* Invoked with (err, results).
*
* @example
* async.parallel([
* function(callback) {
* setTimeout(function() {
* callback(null, 'one');
* }, 200);
* },
* function(callback) {
* setTimeout(function() {
* callback(null, 'two');
* }, 100);
* }
* ],
* // optional callback
* function(err, results) {
* // the results array will equal ['one','two'] even though
* // the second function had a shorter timeout.
* });
*
* // an example using an object instead of an array
* async.parallel({
* one: function(callback) {
* setTimeout(function() {
* callback(null, 1);
* }, 200);
* },
* two: function(callback) {
* setTimeout(function() {
* callback(null, 2);
* }, 100);
* }
* }, function(err, results) {
* // results is now equals to: {one: 1, two: 2}
* });
*/
function parallelLimit(tasks, callback) {
_parallel(eachOf, tasks, callback);
}
/**
* The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
* time.
*
* @name parallelLimit
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.parallel]{@link module:ControlFlow.parallel}
* @category Control Flow
* @param {Array|Iterable|Object} tasks - A collection of
* [async functions]{@link AsyncFunction} to run.
* Each async function can complete with any number of optional `result` values.
* @param {number} limit - The maximum number of async operations at a time.
* @param {Function} [callback] - An optional callback to run once all the
* functions have completed successfully. This function gets a results array
* (or object) containing all the result arguments passed to the task callbacks.
* Invoked with (err, results).
*/
function parallelLimit$1(tasks, limit, callback) {
_parallel(_eachOfLimit(limit), tasks, callback);
}
/**
* A queue of tasks for the worker function to complete.
* @typedef {Object} QueueObject
* @memberOf module:ControlFlow
* @property {Function} length - a function returning the number of items
* waiting to be processed. Invoke with `queue.length()`.
* @property {boolean} started - a boolean indicating whether or not any
* items have been pushed and processed by the queue.
* @property {Function} running - a function returning the number of items
* currently being processed. Invoke with `queue.running()`.
* @property {Function} workersList - a function returning the array of items
* currently being processed. Invoke with `queue.workersList()`.
* @property {Function} idle - a function returning false if there are items
* waiting or being processed, or true if not. Invoke with `queue.idle()`.
* @property {number} concurrency - an integer for determining how many `worker`
* functions should be run in parallel. This property can be changed after a
* `queue` is created to alter the concurrency on-the-fly.
* @property {Function} push - add a new task to the `queue`. Calls `callback`
* once the `worker` has finished processing the task. Instead of a single task,
* a `tasks` array can be submitted. The respective callback is used for every
* task in the list. Invoke with `queue.push(task, [callback])`,
* @property {Function} unshift - add a new task to the front of the `queue`.
* Invoke with `queue.unshift(task, [callback])`.
* @property {Function} remove - remove items from the queue that match a test
* function. The test function will be passed an object with a `data` property,
* and a `priority` property, if this is a
* [priorityQueue]{@link module:ControlFlow.priorityQueue} object.
* Invoked with `queue.remove(testFn)`, where `testFn` is of the form
* `function ({data, priority}) {}` and returns a Boolean.
* @property {Function} saturated - a callback that is called when the number of
* running workers hits the `concurrency` limit, and further tasks will be
* queued.
* @property {Function} unsaturated - a callback that is called when the number
* of running workers is less than the `concurrency` & `buffer` limits, and
* further tasks will not be queued.
* @property {number} buffer - A minimum threshold buffer in order to say that
* the `queue` is `unsaturated`.
* @property {Function} empty - a callback that is called when the last item
* from the `queue` is given to a `worker`.
* @property {Function} drain - a callback that is called when the last item
* from the `queue` has returned from the `worker`.
* @property {Function} error - a callback that is called when a task errors.
* Has the signature `function(error, task)`.
* @property {boolean} paused - a boolean for determining whether the queue is
* in a paused state.
* @property {Function} pause - a function that pauses the processing of tasks
* until `resume()` is called. Invoke with `queue.pause()`.
* @property {Function} resume - a function that resumes the processing of
* queued tasks when the queue is paused. Invoke with `queue.resume()`.
* @property {Function} kill - a function that removes the `drain` callback and
* empties remaining tasks from the queue forcing it to go idle. No more tasks
* should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
*/
/**
* Creates a `queue` object with the specified `concurrency`. Tasks added to the
* `queue` are processed in parallel (up to the `concurrency` limit). If all
* `worker`s are in progress, the task is queued until one becomes available.
* Once a `worker` completes a `task`, that `task`'s callback is called.
*
* @name queue
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {AsyncFunction} worker - An async function for processing a queued task.
* If you want to handle errors from an individual task, pass a callback to
* `q.push()`. Invoked with (task, callback).
* @param {number} [concurrency=1] - An `integer` for determining how many
* `worker` functions should be run in parallel. If omitted, the concurrency
* defaults to `1`. If the concurrency is `0`, an error is thrown.
* @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
* attached as certain properties to listen for specific events during the
* lifecycle of the queue.
* @example
*
* // create a queue object with concurrency 2
* var q = async.queue(function(task, callback) {
* console.log('hello ' + task.name);
* callback();
* }, 2);
*
* // assign a callback
* q.drain = function() {
* console.log('all items have been processed');
* };
*
* // add some items to the queue
* q.push({name: 'foo'}, function(err) {
* console.log('finished processing foo');
* });
* q.push({name: 'bar'}, function (err) {
* console.log('finished processing bar');
* });
*
* // add some items to the queue (batch-wise)
* q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
* console.log('finished processing item');
* });
*
* // add some items to the front of the queue
* q.unshift({name: 'bar'}, function (err) {
* console.log('finished processing bar');
* });
*/
var queue$1 = function (worker, concurrency) {
var _worker = wrapAsync(worker);
return queue(function (items, cb) {
_worker(items[0], cb);
}, concurrency, 1);
};
/**
* The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
* completed in ascending priority order.
*
* @name priorityQueue
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.queue]{@link module:ControlFlow.queue}
* @category Control Flow
* @param {AsyncFunction} worker - An async function for processing a queued task.
* If you want to handle errors from an individual task, pass a callback to
* `q.push()`.
* Invoked with (task, callback).
* @param {number} concurrency - An `integer` for determining how many `worker`
* functions should be run in parallel. If omitted, the concurrency defaults to
* `1`. If the concurrency is `0`, an error is thrown.
* @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
* differences between `queue` and `priorityQueue` objects:
* * `push(task, priority, [callback])` - `priority` should be a number. If an
* array of `tasks` is given, all tasks will be assigned the same priority.
* * The `unshift` method was removed.
*/
var priorityQueue = function(worker, concurrency) {
// Start with a normal queue
var q = queue$1(worker, concurrency);
// Override push to accept second parameter representing priority
q.push = function(data, priority, callback) {
if (callback == null) callback = noop;
if (typeof callback !== 'function') {
throw new Error('task callback must be a function');
}
q.started = true;
if (!isArray(data)) {
data = [data];
}
if (data.length === 0) {
// call drain immediately if there are no tasks
return setImmediate$1(function() {
q.drain();
});
}
priority = priority || 0;
var nextNode = q._tasks.head;
while (nextNode && priority >= nextNode.priority) {
nextNode = nextNode.next;
}
for (var i = 0, l = data.length; i < l; i++) {
var item = {
data: data[i],
priority: priority,
callback: callback
};
if (nextNode) {
q._tasks.insertBefore(nextNode, item);
} else {
q._tasks.push(item);
}
}
setImmediate$1(q.process);
};
// Remove unshift function
delete q.unshift;
return q;
};
/**
* Runs the `tasks` array of functions in parallel, without waiting until the
* previous function has completed. Once any of the `tasks` complete or pass an
* error to its callback, the main `callback` is immediately called. It's
* equivalent to `Promise.race()`.
*
* @name race
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Array} tasks - An array containing [async functions]{@link AsyncFunction}
* to run. Each function can complete with an optional `result` value.
* @param {Function} callback - A callback to run once any of the functions have
* completed. This function gets an error or result from the first function that
* completed. Invoked with (err, result).
* @returns undefined
* @example
*
* async.race([
* function(callback) {
* setTimeout(function() {
* callback(null, 'one');
* }, 200);
* },
* function(callback) {
* setTimeout(function() {
* callback(null, 'two');
* }, 100);
* }
* ],
* // main callback
* function(err, result) {
* // the result will be equal to 'two' as it finishes earlier
* });
*/
function race(tasks, callback) {
callback = once(callback || noop);
if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
if (!tasks.length) return callback();
for (var i = 0, l = tasks.length; i < l; i++) {
wrapAsync(tasks[i])(callback);
}
}
/**
* Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
*
* @name reduceRight
* @static
* @memberOf module:Collections
* @method
* @see [async.reduce]{@link module:Collections.reduce}
* @alias foldr
* @category Collection
* @param {Array} array - A collection to iterate over.
* @param {*} memo - The initial state of the reduction.
* @param {AsyncFunction} iteratee - A function applied to each item in the
* array to produce the next step in the reduction.
* The `iteratee` should complete with the next state of the reduction.
* If the iteratee complete with an error, the reduction is stopped and the
* main `callback` is immediately called with the error.
* Invoked with (memo, item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Result is the reduced value. Invoked with
* (err, result).
*/
function reduceRight (array, memo, iteratee, callback) {
var reversed = slice(array).reverse();
reduce(reversed, memo, iteratee, callback);
}
/**
* Wraps the async function in another function that always completes with a
* result object, even when it errors.
*
* The result object has either the property `error` or `value`.
*
* @name reflect
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {AsyncFunction} fn - The async function you want to wrap
* @returns {Function} - A function that always passes null to it's callback as
* the error. The second argument to the callback will be an `object` with
* either an `error` or a `value` property.
* @example
*
* async.parallel([
* async.reflect(function(callback) {
* // do some stuff ...
* callback(null, 'one');
* }),
* async.reflect(function(callback) {
* // do some more stuff but error ...
* callback('bad stuff happened');
* }),
* async.reflect(function(callback) {
* // do some more stuff ...
* callback(null, 'two');
* })
* ],
* // optional callback
* function(err, results) {
* // values
* // results[0].value = 'one'
* // results[1].error = 'bad stuff happened'
* // results[2].value = 'two'
* });
*/
function reflect(fn) {
var _fn = wrapAsync(fn);
return initialParams(function reflectOn(args, reflectCallback) {
args.push(function callback(error, cbArg) {
if (error) {
reflectCallback(null, { error: error });
} else {
var value;
if (arguments.length <= 2) {
value = cbArg;
} else {
value = slice(arguments, 1);
}
reflectCallback(null, { value: value });
}
});
return _fn.apply(this, args);
});
}
/**
* A helper function that wraps an array or an object of functions with `reflect`.
*
* @name reflectAll
* @static
* @memberOf module:Utils
* @method
* @see [async.reflect]{@link module:Utils.reflect}
* @category Util
* @param {Array|Object|Iterable} tasks - The collection of
* [async functions]{@link AsyncFunction} to wrap in `async.reflect`.
* @returns {Array} Returns an array of async functions, each wrapped in
* `async.reflect`
* @example
*
* let tasks = [
* function(callback) {
* setTimeout(function() {
* callback(null, 'one');
* }, 200);
* },
* function(callback) {
* // do some more stuff but error ...
* callback(new Error('bad stuff happened'));
* },
* function(callback) {
* setTimeout(function() {
* callback(null, 'two');
* }, 100);
* }
* ];
*
* async.parallel(async.reflectAll(tasks),
* // optional callback
* function(err, results) {
* // values
* // results[0].value = 'one'
* // results[1].error = Error('bad stuff happened')
* // results[2].value = 'two'
* });
*
* // an example using an object instead of an array
* let tasks = {
* one: function(callback) {
* setTimeout(function() {
* callback(null, 'one');
* }, 200);
* },
* two: function(callback) {
* callback('two');
* },
* three: function(callback) {
* setTimeout(function() {
* callback(null, 'three');
* }, 100);
* }
* };
*
* async.parallel(async.reflectAll(tasks),
* // optional callback
* function(err, results) {
* // values
* // results.one.value = 'one'
* // results.two.error = 'two'
* // results.three.value = 'three'
* });
*/
function reflectAll(tasks) {
var results;
if (isArray(tasks)) {
results = arrayMap(tasks, reflect);
} else {
results = {};
baseForOwn(tasks, function(task, key) {
results[key] = reflect.call(this, task);
});
}
return results;
}
function reject$1(eachfn, arr, iteratee, callback) {
_filter(eachfn, arr, function(value, cb) {
iteratee(value, function(err, v) {
cb(err, !v);
});
}, callback);
}
/**
* The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
*
* @name reject
* @static
* @memberOf module:Collections
* @method
* @see [async.filter]{@link module:Collections.filter}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {Function} iteratee - An async truth test to apply to each item in
* `coll`.
* The should complete with a boolean value as its `result`.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Invoked with (err, results).
* @example
*
* async.reject(['file1','file2','file3'], function(filePath, callback) {
* fs.access(filePath, function(err) {
* callback(null, !err)
* });
* }, function(err, results) {
* // results now equals an array of missing files
* createFiles(results);
* });
*/
var reject = doParallel(reject$1);
/**
* The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
* time.
*
* @name rejectLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.reject]{@link module:Collections.reject}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {Function} iteratee - An async truth test to apply to each item in
* `coll`.
* The should complete with a boolean value as its `result`.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Invoked with (err, results).
*/
var rejectLimit = doParallelLimit(reject$1);
/**
* The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
*
* @name rejectSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.reject]{@link module:Collections.reject}
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {Function} iteratee - An async truth test to apply to each item in
* `coll`.
* The should complete with a boolean value as its `result`.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Invoked with (err, results).
*/
var rejectSeries = doLimit(rejectLimit, 1);
/**
* Creates a function that returns `value`.
*
* @static
* @memberOf _
* @since 2.4.0
* @category Util
* @param {*} value The value to return from the new function.
* @returns {Function} Returns the new constant function.
* @example
*
* var objects = _.times(2, _.constant({ 'a': 1 }));
*
* console.log(objects);
* // => [{ 'a': 1 }, { 'a': 1 }]
*
* console.log(objects[0] === objects[1]);
* // => true
*/
function constant$1(value) {
return function() {
return value;
};
}
/**
* Attempts to get a successful response from `task` no more than `times` times
* before returning an error. If the task is successful, the `callback` will be
* passed the result of the successful task. If all attempts fail, the callback
* will be passed the error and result (if any) of the final attempt.
*
* @name retry
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @see [async.retryable]{@link module:ControlFlow.retryable}
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
* object with `times` and `interval` or a number.
* * `times` - The number of attempts to make before giving up. The default
* is `5`.
* * `interval` - The time to wait between retries, in milliseconds. The
* default is `0`. The interval may also be specified as a function of the
* retry count (see example).
* * `errorFilter` - An optional synchronous function that is invoked on
* erroneous result. If it returns `true` the retry attempts will continue;
* if the function returns `false` the retry flow is aborted with the current
* attempt's error and result being returned to the final callback.
* Invoked with (err).
* * If `opts` is a number, the number specifies the number of times to retry,
* with the default interval of `0`.
* @param {AsyncFunction} task - An async function to retry.
* Invoked with (callback).
* @param {Function} [callback] - An optional callback which is called when the
* task has succeeded, or after the final failed attempt. It receives the `err`
* and `result` arguments of the last attempt at completing the `task`. Invoked
* with (err, results).
*
* @example
*
* // The `retry` function can be used as a stand-alone control flow by passing
* // a callback, as shown below:
*
* // try calling apiMethod 3 times
* async.retry(3, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod 3 times, waiting 200 ms between each retry
* async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod 10 times with exponential backoff
* // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
* async.retry({
* times: 10,
* interval: function(retryCount) {
* return 50 * Math.pow(2, retryCount);
* }
* }, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod the default 5 times no delay between each retry
* async.retry(apiMethod, function(err, result) {
* // do something with the result
* });
*
* // try calling apiMethod only when error condition satisfies, all other
* // errors will abort the retry control flow and return to final callback
* async.retry({
* errorFilter: function(err) {
* return err.message === 'Temporary error'; // only retry on a specific error
* }
* }, apiMethod, function(err, result) {
* // do something with the result
* });
*
* // to retry individual methods that are not as reliable within other
* // control flow functions, use the `retryable` wrapper:
* async.auto({
* users: api.getUsers.bind(api),
* payments: async.retryable(3, api.getPayments.bind(api))
* }, function(err, results) {
* // do something with the results
* });
*
*/
function retry(opts, task, callback) {
var DEFAULT_TIMES = 5;
var DEFAULT_INTERVAL = 0;
var options = {
times: DEFAULT_TIMES,
intervalFunc: constant$1(DEFAULT_INTERVAL)
};
function parseTimes(acc, t) {
if (typeof t === 'object') {
acc.times = +t.times || DEFAULT_TIMES;
acc.intervalFunc = typeof t.interval === 'function' ?
t.interval :
constant$1(+t.interval || DEFAULT_INTERVAL);
acc.errorFilter = t.errorFilter;
} else if (typeof t === 'number' || typeof t === 'string') {
acc.times = +t || DEFAULT_TIMES;
} else {
throw new Error("Invalid arguments for async.retry");
}
}
if (arguments.length < 3 && typeof opts === 'function') {
callback = task || noop;
task = opts;
} else {
parseTimes(options, opts);
callback = callback || noop;
}
if (typeof task !== 'function') {
throw new Error("Invalid arguments for async.retry");
}
var _task = wrapAsync(task);
var attempt = 1;
function retryAttempt() {
_task(function(err) {
if (err && attempt++ < options.times &&
(typeof options.errorFilter != 'function' ||
options.errorFilter(err))) {
setTimeout(retryAttempt, options.intervalFunc(attempt));
} else {
callback.apply(null, arguments);
}
});
}
retryAttempt();
}
/**
* A close relative of [`retry`]{@link module:ControlFlow.retry}. This method
* wraps a task and makes it retryable, rather than immediately calling it
* with retries.
*
* @name retryable
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.retry]{@link module:ControlFlow.retry}
* @category Control Flow
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
* options, exactly the same as from `retry`
* @param {AsyncFunction} task - the asynchronous function to wrap.
* This function will be passed any arguments passed to the returned wrapper.
* Invoked with (...args, callback).
* @returns {AsyncFunction} The wrapped function, which when invoked, will
* retry on an error, based on the parameters specified in `opts`.
* This function will accept the same parameters as `task`.
* @example
*
* async.auto({
* dep1: async.retryable(3, getFromFlakyService),
* process: ["dep1", async.retryable(3, function (results, cb) {
* maybeProcessData(results.dep1, cb);
* })]
* }, callback);
*/
var retryable = function (opts, task) {
if (!task) {
task = opts;
opts = null;
}
var _task = wrapAsync(task);
return initialParams(function (args, callback) {
function taskFn(cb) {
_task.apply(null, args.concat(cb));
}
if (opts) retry(opts, taskFn, callback);
else retry(taskFn, callback);
});
};
/**
* Run the functions in the `tasks` collection in series, each one running once
* the previous function has completed. If any functions in the series pass an
* error to its callback, no more functions are run, and `callback` is
* immediately called with the value of the error. Otherwise, `callback`
* receives an array of results when `tasks` have completed.
*
* It is also possible to use an object instead of an array. Each property will
* be run as a function, and the results will be passed to the final `callback`
* as an object instead of an array. This can be a more readable way of handling
* results from {@link async.series}.
*
* **Note** that while many implementations preserve the order of object
* properties, the [ECMAScript Language Specification](path_to_url#sec-8.6)
* explicitly states that
*
* > The mechanics and order of enumerating the properties is not specified.
*
* So if you rely on the order in which your series of functions are executed,
* and want this to work on all platforms, consider using an array.
*
* @name series
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Array|Iterable|Object} tasks - A collection containing
* [async functions]{@link AsyncFunction} to run in series.
* Each function can complete with any number of optional `result` values.
* @param {Function} [callback] - An optional callback to run once all the
* functions have completed. This function gets a results array (or object)
* containing all the result arguments passed to the `task` callbacks. Invoked
* with (err, result).
* @example
* async.series([
* function(callback) {
* // do some stuff ...
* callback(null, 'one');
* },
* function(callback) {
* // do some more stuff ...
* callback(null, 'two');
* }
* ],
* // optional callback
* function(err, results) {
* // results is now equal to ['one', 'two']
* });
*
* async.series({
* one: function(callback) {
* setTimeout(function() {
* callback(null, 1);
* }, 200);
* },
* two: function(callback){
* setTimeout(function() {
* callback(null, 2);
* }, 100);
* }
* }, function(err, results) {
* // results is now equal to: {one: 1, two: 2}
* });
*/
function series(tasks, callback) {
_parallel(eachOfSeries, tasks, callback);
}
/**
* Returns `true` if at least one element in the `coll` satisfies an async test.
* If any iteratee call returns `true`, the main `callback` is immediately
* called.
*
* @name some
* @static
* @memberOf module:Collections
* @method
* @alias any
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
* in the collections in parallel.
* The iteratee should complete with a boolean `result` value.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called as soon as any
* iteratee returns `true`, or after all the iteratee functions have finished.
* Result will be either `true` or `false` depending on the values of the async
* tests. Invoked with (err, result).
* @example
*
* async.some(['file1','file2','file3'], function(filePath, callback) {
* fs.access(filePath, function(err) {
* callback(null, !err)
* });
* }, function(err, result) {
* // if result is true then at least one of the files exists
* });
*/
var some = doParallel(_createTester(Boolean, identity));
/**
* The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
*
* @name someLimit
* @static
* @memberOf module:Collections
* @method
* @see [async.some]{@link module:Collections.some}
* @alias anyLimit
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
* in the collections in parallel.
* The iteratee should complete with a boolean `result` value.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called as soon as any
* iteratee returns `true`, or after all the iteratee functions have finished.
* Result will be either `true` or `false` depending on the values of the async
* tests. Invoked with (err, result).
*/
var someLimit = doParallelLimit(_createTester(Boolean, identity));
/**
* The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
*
* @name someSeries
* @static
* @memberOf module:Collections
* @method
* @see [async.some]{@link module:Collections.some}
* @alias anySeries
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
* in the collections in series.
* The iteratee should complete with a boolean `result` value.
* Invoked with (item, callback).
* @param {Function} [callback] - A callback which is called as soon as any
* iteratee returns `true`, or after all the iteratee functions have finished.
* Result will be either `true` or `false` depending on the values of the async
* tests. Invoked with (err, result).
*/
var someSeries = doLimit(someLimit, 1);
/**
* Sorts a list by the results of running each `coll` value through an async
* `iteratee`.
*
* @name sortBy
* @static
* @memberOf module:Collections
* @method
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {AsyncFunction} iteratee - An async function to apply to each item in
* `coll`.
* The iteratee should complete with a value to use as the sort criteria as
* its `result`.
* Invoked with (item, callback).
* @param {Function} callback - A callback which is called after all the
* `iteratee` functions have finished, or an error occurs. Results is the items
* from the original `coll` sorted by the values returned by the `iteratee`
* calls. Invoked with (err, results).
* @example
*
* async.sortBy(['file1','file2','file3'], function(file, callback) {
* fs.stat(file, function(err, stats) {
* callback(err, stats.mtime);
* });
* }, function(err, results) {
* // results is now the original array of files sorted by
* // modified date
* });
*
* // By modifying the callback parameter the
* // sorting order can be influenced:
*
* // ascending order
* async.sortBy([1,9,3,5], function(x, callback) {
* callback(null, x);
* }, function(err,result) {
* // result callback
* });
*
* // descending order
* async.sortBy([1,9,3,5], function(x, callback) {
* callback(null, x*-1); //<- x*-1 instead of x, turns the order around
* }, function(err,result) {
* // result callback
* });
*/
function sortBy (coll, iteratee, callback) {
var _iteratee = wrapAsync(iteratee);
map(coll, function (x, callback) {
_iteratee(x, function (err, criteria) {
if (err) return callback(err);
callback(null, {value: x, criteria: criteria});
});
}, function (err, results) {
if (err) return callback(err);
callback(null, arrayMap(results.sort(comparator), baseProperty('value')));
});
function comparator(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}
}
/**
* Sets a time limit on an asynchronous function. If the function does not call
* its callback within the specified milliseconds, it will be called with a
* timeout error. The code property for the error object will be `'ETIMEDOUT'`.
*
* @name timeout
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {AsyncFunction} asyncFn - The async function to limit in time.
* @param {number} milliseconds - The specified time limit.
* @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
* to timeout Error for more information..
* @returns {AsyncFunction} Returns a wrapped function that can be used with any
* of the control flow functions.
* Invoke this function with the same parameters as you would `asyncFunc`.
* @example
*
* function myFunction(foo, callback) {
* doAsyncTask(foo, function(err, data) {
* // handle errors
* if (err) return callback(err);
*
* // do some stuff ...
*
* // return processed data
* return callback(null, data);
* });
* }
*
* var wrapped = async.timeout(myFunction, 1000);
*
* // call `wrapped` as you would `myFunction`
* wrapped({ bar: 'bar' }, function(err, data) {
* // if `myFunction` takes < 1000 ms to execute, `err`
* // and `data` will have their expected values
*
* // else `err` will be an Error with the code 'ETIMEDOUT'
* });
*/
function timeout(asyncFn, milliseconds, info) {
var fn = wrapAsync(asyncFn);
return initialParams(function (args, callback) {
var timedOut = false;
var timer;
function timeoutCallback() {
var name = asyncFn.name || 'anonymous';
var error = new Error('Callback function "' + name + '" timed out.');
error.code = 'ETIMEDOUT';
if (info) {
error.info = info;
}
timedOut = true;
callback(error);
}
args.push(function () {
if (!timedOut) {
callback.apply(null, arguments);
clearTimeout(timer);
}
});
// setup timer and call original function
timer = setTimeout(timeoutCallback, milliseconds);
fn.apply(null, args);
});
}
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;
var nativeMax = Math.max;
/**
* The base implementation of `_.range` and `_.rangeRight` which doesn't
* coerce arguments.
*
* @private
* @param {number} start The start of the range.
* @param {number} end The end of the range.
* @param {number} step The value to increment or decrement by.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Array} Returns the range of numbers.
*/
function baseRange(start, end, step, fromRight) {
var index = -1,
length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
result = Array(length);
while (length--) {
result[fromRight ? length : ++index] = start;
start += step;
}
return result;
}
/**
* The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
* time.
*
* @name timesLimit
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.times]{@link module:ControlFlow.times}
* @category Control Flow
* @param {number} count - The number of times to run the function.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - The async function to call `n` times.
* Invoked with the iteration index and a callback: (n, next).
* @param {Function} callback - see [async.map]{@link module:Collections.map}.
*/
function timeLimit(count, limit, iteratee, callback) {
var _iteratee = wrapAsync(iteratee);
mapLimit(baseRange(0, count, 1), limit, _iteratee, callback);
}
/**
* Calls the `iteratee` function `n` times, and accumulates results in the same
* manner you would use with [map]{@link module:Collections.map}.
*
* @name times
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.map]{@link module:Collections.map}
* @category Control Flow
* @param {number} n - The number of times to run the function.
* @param {AsyncFunction} iteratee - The async function to call `n` times.
* Invoked with the iteration index and a callback: (n, next).
* @param {Function} callback - see {@link module:Collections.map}.
* @example
*
* // Pretend this is some complicated async factory
* var createUser = function(id, callback) {
* callback(null, {
* id: 'user' + id
* });
* };
*
* // generate 5 users
* async.times(5, function(n, next) {
* createUser(n, function(err, user) {
* next(err, user);
* });
* }, function(err, users) {
* // we should now have 5 users
* });
*/
var times = doLimit(timeLimit, Infinity);
/**
* The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
*
* @name timesSeries
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.times]{@link module:ControlFlow.times}
* @category Control Flow
* @param {number} n - The number of times to run the function.
* @param {AsyncFunction} iteratee - The async function to call `n` times.
* Invoked with the iteration index and a callback: (n, next).
* @param {Function} callback - see {@link module:Collections.map}.
*/
var timesSeries = doLimit(timeLimit, 1);
/**
* A relative of `reduce`. Takes an Object or Array, and iterates over each
* element in series, each step potentially mutating an `accumulator` value.
* The type of the accumulator defaults to the type of collection passed in.
*
* @name transform
* @static
* @memberOf module:Collections
* @method
* @category Collection
* @param {Array|Iterable|Object} coll - A collection to iterate over.
* @param {*} [accumulator] - The initial state of the transform. If omitted,
* it will default to an empty Object or Array, depending on the type of `coll`
* @param {AsyncFunction} iteratee - A function applied to each item in the
* collection that potentially modifies the accumulator.
* Invoked with (accumulator, item, key, callback).
* @param {Function} [callback] - A callback which is called after all the
* `iteratee` functions have finished. Result is the transformed accumulator.
* Invoked with (err, result).
* @example
*
* async.transform([1,2,3], function(acc, item, index, callback) {
* // pointless async:
* process.nextTick(function() {
* acc.push(item * 2)
* callback(null)
* });
* }, function(err, result) {
* // result is now equal to [2, 4, 6]
* });
*
* @example
*
* async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
* setImmediate(function () {
* obj[key] = val * 2;
* callback();
* })
* }, function (err, result) {
* // result is equal to {a: 2, b: 4, c: 6}
* })
*/
function transform (coll, accumulator, iteratee, callback) {
if (arguments.length <= 3) {
callback = iteratee;
iteratee = accumulator;
accumulator = isArray(coll) ? [] : {};
}
callback = once(callback || noop);
var _iteratee = wrapAsync(iteratee);
eachOf(coll, function(v, k, cb) {
_iteratee(accumulator, v, k, cb);
}, function(err) {
callback(err, accumulator);
});
}
/**
* It runs each task in series but stops whenever any of the functions were
* successful. If one of the tasks were successful, the `callback` will be
* passed the result of the successful task. If all tasks fail, the callback
* will be passed the error and result (if any) of the final attempt.
*
* @name tryEach
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Array|Iterable|Object} tasks - A collection containing functions to
* run, each function is passed a `callback(err, result)` it must call on
* completion with an error `err` (which can be `null`) and an optional `result`
* value.
* @param {Function} [callback] - An optional callback which is called when one
* of the tasks has succeeded, or all have failed. It receives the `err` and
* `result` arguments of the last attempt at completing the `task`. Invoked with
* (err, results).
* @example
* async.tryEach([
* function getDataFromFirstWebsite(callback) {
* // Try getting the data from the first website
* callback(err, data);
* },
* function getDataFromSecondWebsite(callback) {
* // First website failed,
* // Try getting the data from the backup website
* callback(err, data);
* }
* ],
* // optional callback
* function(err, results) {
* Now do something with the data.
* });
*
*/
function tryEach(tasks, callback) {
var error = null;
var result;
callback = callback || noop;
eachSeries(tasks, function(task, callback) {
wrapAsync(task)(function (err, res/*, ...args*/) {
if (arguments.length > 2) {
result = slice(arguments, 1);
} else {
result = res;
}
error = err;
callback(!err);
});
}, function () {
callback(error, result);
});
}
/**
* Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
* unmemoized form. Handy for testing.
*
* @name unmemoize
* @static
* @memberOf module:Utils
* @method
* @see [async.memoize]{@link module:Utils.memoize}
* @category Util
* @param {AsyncFunction} fn - the memoized function
* @returns {AsyncFunction} a function that calls the original unmemoized function
*/
function unmemoize(fn) {
return function () {
return (fn.unmemoized || fn).apply(null, arguments);
};
}
/**
* Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
* stopped, or an error occurs.
*
* @name whilst
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Function} test - synchronous truth test to perform before each
* execution of `iteratee`. Invoked with ().
* @param {AsyncFunction} iteratee - An async function which is called each time
* `test` passes. Invoked with (callback).
* @param {Function} [callback] - A callback which is called after the test
* function has failed and repeated execution of `iteratee` has stopped. `callback`
* will be passed an error and any arguments passed to the final `iteratee`'s
* callback. Invoked with (err, [results]);
* @returns undefined
* @example
*
* var count = 0;
* async.whilst(
* function() { return count < 5; },
* function(callback) {
* count++;
* setTimeout(function() {
* callback(null, count);
* }, 1000);
* },
* function (err, n) {
* // 5 seconds have passed, n = 5
* }
* );
*/
function whilst(test, iteratee, callback) {
callback = onlyOnce(callback || noop);
var _iteratee = wrapAsync(iteratee);
if (!test()) return callback(null);
var next = function(err/*, ...args*/) {
if (err) return callback(err);
if (test()) return _iteratee(next);
var args = slice(arguments, 1);
callback.apply(null, [null].concat(args));
};
_iteratee(next);
}
/**
* Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when
* stopped, or an error occurs. `callback` will be passed an error and any
* arguments passed to the final `iteratee`'s callback.
*
* The inverse of [whilst]{@link module:ControlFlow.whilst}.
*
* @name until
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.whilst]{@link module:ControlFlow.whilst}
* @category Control Flow
* @param {Function} test - synchronous truth test to perform before each
* execution of `iteratee`. Invoked with ().
* @param {AsyncFunction} iteratee - An async function which is called each time
* `test` fails. Invoked with (callback).
* @param {Function} [callback] - A callback which is called after the test
* function has passed and repeated execution of `iteratee` has stopped. `callback`
* will be passed an error and any arguments passed to the final `iteratee`'s
* callback. Invoked with (err, [results]);
*/
function until(test, iteratee, callback) {
whilst(function() {
return !test.apply(this, arguments);
}, iteratee, callback);
}
/**
* Runs the `tasks` array of functions in series, each passing their results to
* the next in the array. However, if any of the `tasks` pass an error to their
* own callback, the next function is not executed, and the main `callback` is
* immediately called with the error.
*
* @name waterfall
* @static
* @memberOf module:ControlFlow
* @method
* @category Control Flow
* @param {Array} tasks - An array of [async functions]{@link AsyncFunction}
* to run.
* Each function should complete with any number of `result` values.
* The `result` values will be passed as arguments, in order, to the next task.
* @param {Function} [callback] - An optional callback to run once all the
* functions have completed. This will be passed the results of the last task's
* callback. Invoked with (err, [results]).
* @returns undefined
* @example
*
* async.waterfall([
* function(callback) {
* callback(null, 'one', 'two');
* },
* function(arg1, arg2, callback) {
* // arg1 now equals 'one' and arg2 now equals 'two'
* callback(null, 'three');
* },
* function(arg1, callback) {
* // arg1 now equals 'three'
* callback(null, 'done');
* }
* ], function (err, result) {
* // result now equals 'done'
* });
*
* // Or, with named functions:
* async.waterfall([
* myFirstFunction,
* mySecondFunction,
* myLastFunction,
* ], function (err, result) {
* // result now equals 'done'
* });
* function myFirstFunction(callback) {
* callback(null, 'one', 'two');
* }
* function mySecondFunction(arg1, arg2, callback) {
* // arg1 now equals 'one' and arg2 now equals 'two'
* callback(null, 'three');
* }
* function myLastFunction(arg1, callback) {
* // arg1 now equals 'three'
* callback(null, 'done');
* }
*/
var waterfall = function(tasks, callback) {
callback = once(callback || noop);
if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
if (!tasks.length) return callback();
var taskIndex = 0;
function nextTask(args) {
var task = wrapAsync(tasks[taskIndex++]);
args.push(onlyOnce(next));
task.apply(null, args);
}
function next(err/*, ...args*/) {
if (err || taskIndex === tasks.length) {
return callback.apply(null, arguments);
}
nextTask(slice(arguments, 1));
}
nextTask([]);
};
/**
* An "async function" in the context of Async is an asynchronous function with
* a variable number of parameters, with the final parameter being a callback.
* (`function (arg1, arg2, ..., callback) {}`)
* The final callback is of the form `callback(err, results...)`, which must be
* called once the function is completed. The callback should be called with a
* Error as its first argument to signal that an error occurred.
* Otherwise, if no error occurred, it should be called with `null` as the first
* argument, and any additional `result` arguments that may apply, to signal
* successful completion.
* The callback must be called exactly once, ideally on a later tick of the
* JavaScript event loop.
*
* This type of function is also referred to as a "Node-style async function",
* or a "continuation passing-style function" (CPS). Most of the methods of this
* library are themselves CPS/Node-style async functions, or functions that
* return CPS/Node-style async functions.
*
* Wherever we accept a Node-style async function, we also directly accept an
* [ES2017 `async` function]{@link path_to_url}.
* In this case, the `async` function will not be passed a final callback
* argument, and any thrown error will be used as the `err` argument of the
* implicit callback, and the return value will be used as the `result` value.
* (i.e. a `rejected` of the returned Promise becomes the `err` callback
* argument, and a `resolved` value becomes the `result`.)
*
* Note, due to JavaScript limitations, we can only detect native `async`
* functions and not transpilied implementations.
* Your environment must have `async`/`await` support for this to work.
* (e.g. Node > v7.6, or a recent version of a modern browser).
* If you are using `async` functions through a transpiler (e.g. Babel), you
* must still wrap the function with [asyncify]{@link module:Utils.asyncify},
* because the `async function` will be compiled to an ordinary function that
* returns a promise.
*
* @typedef {Function} AsyncFunction
* @static
*/
/**
* Async is a utility module which provides straight-forward, powerful functions
* for working with asynchronous JavaScript. Although originally designed for
* use with [Node.js](path_to_url and installable via
* `npm install --save async`, it can also be used directly in the browser.
* @module async
* @see AsyncFunction
*/
/**
* A collection of `async` functions for manipulating collections, such as
* arrays and objects.
* @module Collections
*/
/**
* A collection of `async` functions for controlling the flow through a script.
* @module ControlFlow
*/
/**
* A collection of `async` utility functions.
* @module Utils
*/
var index = {
apply: apply,
applyEach: applyEach,
applyEachSeries: applyEachSeries,
asyncify: asyncify,
auto: auto,
autoInject: autoInject,
cargo: cargo,
compose: compose,
concat: concat,
concatLimit: concatLimit,
concatSeries: concatSeries,
constant: constant,
detect: detect,
detectLimit: detectLimit,
detectSeries: detectSeries,
dir: dir,
doDuring: doDuring,
doUntil: doUntil,
doWhilst: doWhilst,
during: during,
each: eachLimit,
eachLimit: eachLimit$1,
eachOf: eachOf,
eachOfLimit: eachOfLimit,
eachOfSeries: eachOfSeries,
eachSeries: eachSeries,
ensureAsync: ensureAsync,
every: every,
everyLimit: everyLimit,
everySeries: everySeries,
filter: filter,
filterLimit: filterLimit,
filterSeries: filterSeries,
forever: forever,
groupBy: groupBy,
groupByLimit: groupByLimit,
groupBySeries: groupBySeries,
log: log,
map: map,
mapLimit: mapLimit,
mapSeries: mapSeries,
mapValues: mapValues,
mapValuesLimit: mapValuesLimit,
mapValuesSeries: mapValuesSeries,
memoize: memoize,
nextTick: nextTick,
parallel: parallelLimit,
parallelLimit: parallelLimit$1,
priorityQueue: priorityQueue,
queue: queue$1,
race: race,
reduce: reduce,
reduceRight: reduceRight,
reflect: reflect,
reflectAll: reflectAll,
reject: reject,
rejectLimit: rejectLimit,
rejectSeries: rejectSeries,
retry: retry,
retryable: retryable,
seq: seq,
series: series,
setImmediate: setImmediate$1,
some: some,
someLimit: someLimit,
someSeries: someSeries,
sortBy: sortBy,
timeout: timeout,
times: times,
timesLimit: timeLimit,
timesSeries: timesSeries,
transform: transform,
tryEach: tryEach,
unmemoize: unmemoize,
until: until,
waterfall: waterfall,
whilst: whilst,
// aliases
all: every,
allLimit: everyLimit,
allSeries: everySeries,
any: some,
anyLimit: someLimit,
anySeries: someSeries,
find: detect,
findLimit: detectLimit,
findSeries: detectSeries,
forEach: eachLimit,
forEachSeries: eachSeries,
forEachLimit: eachLimit$1,
forEachOf: eachOf,
forEachOfSeries: eachOfSeries,
forEachOfLimit: eachOfLimit,
inject: reduce,
foldl: reduce,
foldr: reduceRight,
select: filter,
selectLimit: filterLimit,
selectSeries: filterSeries,
wrapSync: asyncify
};
exports['default'] = index;
exports.apply = apply;
exports.applyEach = applyEach;
exports.applyEachSeries = applyEachSeries;
exports.asyncify = asyncify;
exports.auto = auto;
exports.autoInject = autoInject;
exports.cargo = cargo;
exports.compose = compose;
exports.concat = concat;
exports.concatLimit = concatLimit;
exports.concatSeries = concatSeries;
exports.constant = constant;
exports.detect = detect;
exports.detectLimit = detectLimit;
exports.detectSeries = detectSeries;
exports.dir = dir;
exports.doDuring = doDuring;
exports.doUntil = doUntil;
exports.doWhilst = doWhilst;
exports.during = during;
exports.each = eachLimit;
exports.eachLimit = eachLimit$1;
exports.eachOf = eachOf;
exports.eachOfLimit = eachOfLimit;
exports.eachOfSeries = eachOfSeries;
exports.eachSeries = eachSeries;
exports.ensureAsync = ensureAsync;
exports.every = every;
exports.everyLimit = everyLimit;
exports.everySeries = everySeries;
exports.filter = filter;
exports.filterLimit = filterLimit;
exports.filterSeries = filterSeries;
exports.forever = forever;
exports.groupBy = groupBy;
exports.groupByLimit = groupByLimit;
exports.groupBySeries = groupBySeries;
exports.log = log;
exports.map = map;
exports.mapLimit = mapLimit;
exports.mapSeries = mapSeries;
exports.mapValues = mapValues;
exports.mapValuesLimit = mapValuesLimit;
exports.mapValuesSeries = mapValuesSeries;
exports.memoize = memoize;
exports.nextTick = nextTick;
exports.parallel = parallelLimit;
exports.parallelLimit = parallelLimit$1;
exports.priorityQueue = priorityQueue;
exports.queue = queue$1;
exports.race = race;
exports.reduce = reduce;
exports.reduceRight = reduceRight;
exports.reflect = reflect;
exports.reflectAll = reflectAll;
exports.reject = reject;
exports.rejectLimit = rejectLimit;
exports.rejectSeries = rejectSeries;
exports.retry = retry;
exports.retryable = retryable;
exports.seq = seq;
exports.series = series;
exports.setImmediate = setImmediate$1;
exports.some = some;
exports.someLimit = someLimit;
exports.someSeries = someSeries;
exports.sortBy = sortBy;
exports.timeout = timeout;
exports.times = times;
exports.timesLimit = timeLimit;
exports.timesSeries = timesSeries;
exports.transform = transform;
exports.tryEach = tryEach;
exports.unmemoize = unmemoize;
exports.until = until;
exports.waterfall = waterfall;
exports.whilst = whilst;
exports.all = every;
exports.allLimit = everyLimit;
exports.allSeries = everySeries;
exports.any = some;
exports.anyLimit = someLimit;
exports.anySeries = someSeries;
exports.find = detect;
exports.findLimit = detectLimit;
exports.findSeries = detectSeries;
exports.forEach = eachLimit;
exports.forEachSeries = eachSeries;
exports.forEachLimit = eachLimit$1;
exports.forEachOf = eachOf;
exports.forEachOfSeries = eachOfSeries;
exports.forEachOfLimit = eachOfLimit;
exports.inject = reduce;
exports.foldl = reduce;
exports.foldr = reduceRight;
exports.select = filter;
exports.selectLimit = filterLimit;
exports.selectSeries = filterSeries;
exports.wrapSync = asyncify;
Object.defineProperty(exports, '__esModule', { value: true });
})));
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/dist/async.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 45,050 |
```javascript
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async=n.async||{})}(this,function(n){"use strict";function t(n,t){t|=0;for(var e=Math.max(n.length-t,0),r=Array(e),u=0;u<e;u++)r[u]=n[t+u];return r}function e(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function r(n){setTimeout(n,0)}function u(n){return function(e){var r=t(arguments,1);n(function(){e.apply(null,r)})}}function i(n){return ct(function(t,r){var u;try{u=n.apply(this,t)}catch(n){return r(n)}e(u)&&"function"==typeof u.then?u.then(function(n){o(r,null,n)},function(n){o(r,n.message?n:new Error(n))}):r(null,u)})}function o(n,t,e){try{n(t,e)}catch(n){lt(c,n)}}function c(n){throw n}function f(n){return st&&"AsyncFunction"===n[Symbol.toStringTag]}function a(n){return f(n)?i(n):n}function l(n){return function(e){var r=t(arguments,1),u=ct(function(t,r){var u=this;return n(e,function(n,e){a(n).apply(u,t.concat(e))},r)});return r.length?u.apply(this,r):u}}function s(n){var t=mt.call(n,bt),e=n[bt];try{n[bt]=void 0;var r=!0}catch(n){}var u=gt.call(n);return r&&(t?n[bt]=e:delete n[bt]),u}function p(n){return St.call(n)}function h(n){return null==n?void 0===n?Lt:kt:Ot&&Ot in Object(n)?s(n):p(n)}function y(n){if(!e(n))return!1;var t=h(n);return t==xt||t==Et||t==wt||t==At}function v(n){return"number"==typeof n&&n>-1&&n%1==0&&n<=Tt}function d(n){return null!=n&&v(n.length)&&!y(n)}function m(){}function g(n){return function(){if(null!==n){var t=n;n=null,t.apply(this,arguments)}}}function b(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}function j(n){return null!=n&&"object"==typeof n}function S(n){return j(n)&&h(n)==It}function k(){return!1}function L(n,t){var e=typeof n;return t=null==t?Nt:t,!!t&&("number"==e||"symbol"!=e&&Qt.test(n))&&n>-1&&n%1==0&&n<t}function O(n){return j(n)&&v(n.length)&&!!me[h(n)]}function w(n){return function(t){return n(t)}}function x(n,t){var e=Pt(n),r=!e&&zt(n),u=!e&&!r&&Wt(n),i=!e&&!r&&!u&&Oe(n),o=e||r||u||i,c=o?b(n.length,String):[],f=c.length;for(var a in n)!t&&!xe.call(n,a)||o&&("length"==a||u&&("offset"==a||"parent"==a)||i&&("buffer"==a||"byteLength"==a||"byteOffset"==a)||L(a,f))||c.push(a);return c}function E(n){var t=n&&n.constructor,e="function"==typeof t&&t.prototype||Ee;return n===e}function A(n,t){return function(e){return n(t(e))}}function T(n){if(!E(n))return Ae(n);var t=[];for(var e in Object(n))_e.call(n,e)&&"constructor"!=e&&t.push(e);return t}function _(n){return d(n)?x(n):T(n)}function B(n){var t=-1,e=n.length;return function(){return++t<e?{value:n[t],key:t}:null}}function F(n){var t=-1;return function(){var e=n.next();return e.done?null:(t++,{value:e.value,key:t})}}function I(n){var t=_(n),e=-1,r=t.length;return function u(){var i=t[++e];return"__proto__"===i?u():e<r?{value:n[i],key:i}:null}}function M(n){if(d(n))return B(n);var t=Ft(n);return t?F(t):I(n)}function U(n){return function(){if(null===n)throw new Error("Callback was already called.");var t=n;n=null,t.apply(this,arguments)}}function q(n){return function(t,e,r){function u(n,t){if(f-=1,n)c=!0,r(n);else{if(t===_t||c&&f<=0)return c=!0,r(null);a||i()}}function i(){for(a=!0;f<n&&!c;){var t=o();if(null===t)return c=!0,void(f<=0&&r(null));f+=1,e(t.value,t.key,U(u))}a=!1}if(r=g(r||m),n<=0||!t)return r(null);var o=M(t),c=!1,f=0,a=!1;i()}}function z(n,t,e,r){q(t)(n,a(e),r)}function P(n,t){return function(e,r,u){return n(e,t,r,u)}}function V(n,t,e){function r(n,t){n?e(n):++i!==o&&t!==_t||e(null)}e=g(e||m);var u=0,i=0,o=n.length;for(0===o&&e(null);u<o;u++)t(n[u],u,U(r))}function D(n){return function(t,e,r){return n(Fe,t,a(e),r)}}function R(n,t,e,r){r=r||m,t=t||[];var u=[],i=0,o=a(e);n(t,function(n,t,e){var r=i++;o(n,function(n,t){u[r]=t,e(n)})},function(n){r(n,u)})}function C(n){return function(t,e,r,u){return n(q(e),t,a(r),u)}}function $(n,t){for(var e=-1,r=null==n?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}function W(n){return function(t,e,r){for(var u=-1,i=Object(t),o=r(t),c=o.length;c--;){var f=o[n?c:++u];if(e(i[f],f,i)===!1)break}return t}}function N(n,t){return n&&Pe(n,t,_)}function Q(n,t,e,r){for(var u=n.length,i=e+(r?1:-1);r?i--:++i<u;)if(t(n[i],i,n))return i;return-1}function G(n){return n!==n}function H(n,t,e){for(var r=e-1,u=n.length;++r<u;)if(n[r]===t)return r;return-1}function J(n,t,e){return t===t?H(n,t,e):Q(n,G,e)}function K(n,t){for(var e=-1,r=null==n?0:n.length,u=Array(r);++e<r;)u[e]=t(n[e],e,n);return u}function X(n){return"symbol"==typeof n||j(n)&&h(n)==De}function Y(n){if("string"==typeof n)return n;if(Pt(n))return K(n,Y)+"";if(X(n))return $e?$e.call(n):"";var t=n+"";return"0"==t&&1/n==-Re?"-0":t}function Z(n,t,e){var r=-1,u=n.length;t<0&&(t=-t>u?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(u);++r<u;)i[r]=n[r+t];return i}function nn(n,t,e){var r=n.length;return e=void 0===e?r:e,!t&&e>=r?n:Z(n,t,e)}function tn(n,t){for(var e=n.length;e--&&J(t,n[e],0)>-1;);return e}function en(n,t){for(var e=-1,r=n.length;++e<r&&J(t,n[e],0)>-1;);return e}function rn(n){return n.split("")}function un(n){return Xe.test(n)}function on(n){return n.match(mr)||[]}function cn(n){return un(n)?on(n):rn(n)}function fn(n){return null==n?"":Y(n)}function an(n,t,e){if(n=fn(n),n&&(e||void 0===t))return n.replace(gr,"");if(!n||!(t=Y(t)))return n;var r=cn(n),u=cn(t),i=en(r,u),o=tn(r,u)+1;return nn(r,i,o).join("")}function ln(n){return n=n.toString().replace(kr,""),n=n.match(br)[2].replace(" ",""),n=n?n.split(jr):[],n=n.map(function(n){return an(n.replace(Sr,""))})}function sn(n,t){var e={};N(n,function(n,t){function r(t,e){var r=K(u,function(n){return t[n]});r.push(e),a(n).apply(null,r)}var u,i=f(n),o=!i&&1===n.length||i&&0===n.length;if(Pt(n))u=n.slice(0,-1),n=n[n.length-1],e[t]=u.concat(u.length>0?r:n);else if(o)e[t]=n;else{if(u=ln(n),0===n.length&&!i&&0===u.length)throw new Error("autoInject task functions require explicit parameters.");i||u.pop(),e[t]=u.concat(r)}}),Ve(e,t)}function pn(){this.head=this.tail=null,this.length=0}function hn(n,t){n.length=1,n.head=n.tail=t}function yn(n,t,e){function r(n,t,e){if(null!=e&&"function"!=typeof e)throw new Error("task callback must be a function");if(s.started=!0,Pt(n)||(n=[n]),0===n.length&&s.idle())return lt(function(){s.drain()});for(var r=0,u=n.length;r<u;r++){var i={data:n[r],callback:e||m};t?s._tasks.unshift(i):s._tasks.push(i)}f||(f=!0,lt(function(){f=!1,s.process()}))}function u(n){return function(t){o-=1;for(var e=0,r=n.length;e<r;e++){var u=n[e],i=J(c,u,0);0===i?c.shift():i>0&&c.splice(i,1),u.callback.apply(u,arguments),null!=t&&s.error(t,u.data)}o<=s.concurrency-s.buffer&&s.unsaturated(),s.idle()&&s.drain(),s.process()}}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var i=a(n),o=0,c=[],f=!1,l=!1,s={_tasks:new pn,concurrency:t,payload:e,saturated:m,unsaturated:m,buffer:t/4,empty:m,drain:m,error:m,started:!1,paused:!1,push:function(n,t){r(n,!1,t)},kill:function(){s.drain=m,s._tasks.empty()},unshift:function(n,t){r(n,!0,t)},remove:function(n){s._tasks.remove(n)},process:function(){if(!l){for(l=!0;!s.paused&&o<s.concurrency&&s._tasks.length;){var n=[],t=[],e=s._tasks.length;s.payload&&(e=Math.min(e,s.payload));for(var r=0;r<e;r++){var f=s._tasks.shift();n.push(f),c.push(f),t.push(f.data)}o+=1,0===s._tasks.length&&s.empty(),o===s.concurrency&&s.saturated();var a=U(u(n));i(t,a)}l=!1}},length:function(){return s._tasks.length},running:function(){return o},workersList:function(){return c},idle:function(){return s._tasks.length+o===0},pause:function(){s.paused=!0},resume:function(){s.paused!==!1&&(s.paused=!1,lt(s.process))}};return s}function vn(n,t){return yn(n,1,t)}function dn(n,t,e,r){r=g(r||m);var u=a(e);Or(n,function(n,e,r){u(t,n,function(n,e){t=e,r(n)})},function(n){r(n,t)})}function mn(){var n=K(arguments,a);return function(){var e=t(arguments),r=this,u=e[e.length-1];"function"==typeof u?e.pop():u=m,dn(n,e,function(n,e,u){e.apply(r,n.concat(function(n){var e=t(arguments,1);u(n,e)}))},function(n,t){u.apply(r,[n].concat(t))})}}function gn(n){return n}function bn(n,t){return function(e,r,u,i){i=i||m;var o,c=!1;e(r,function(e,r,i){u(e,function(r,u){r?i(r):n(u)&&!o?(c=!0,o=t(!0,e),i(null,_t)):i()})},function(n){n?i(n):i(null,c?o:t(!1))})}}function jn(n,t){return t}function Sn(n){return function(e){var r=t(arguments,1);r.push(function(e){var r=t(arguments,1);"object"==typeof console&&(e?console.error&&console.error(e):console[n]&&$(r,function(t){console[n](t)}))}),a(e).apply(null,r)}}function kn(n,e,r){function u(n){if(n)return r(n);var e=t(arguments,1);e.push(i),c.apply(this,e)}function i(n,t){return n?r(n):t?void o(u):r(null)}r=U(r||m);var o=a(n),c=a(e);i(null,!0)}function Ln(n,e,r){r=U(r||m);var u=a(n),i=function(n){if(n)return r(n);var o=t(arguments,1);return e.apply(this,o)?u(i):void r.apply(null,[null].concat(o))};u(i)}function On(n,t,e){Ln(n,function(){return!t.apply(this,arguments)},e)}function wn(n,t,e){function r(n){return n?e(n):void o(u)}function u(n,t){return n?e(n):t?void i(r):e(null)}e=U(e||m);var i=a(t),o=a(n);o(u)}function xn(n){return function(t,e,r){return n(t,r)}}function En(n,t,e){Fe(n,xn(a(t)),e)}function An(n,t,e,r){q(t)(n,xn(a(e)),r)}function Tn(n){return f(n)?n:ct(function(t,e){var r=!0;t.push(function(){var n=arguments;r?lt(function(){e.apply(null,n)}):e.apply(null,n)}),n.apply(this,t),r=!1})}function _n(n){return!n}function Bn(n){return function(t){return null==t?void 0:t[n]}}function Fn(n,t,e,r){var u=new Array(t.length);n(t,function(n,t,r){e(n,function(n,e){u[t]=!!e,r(n)})},function(n){if(n)return r(n);for(var e=[],i=0;i<t.length;i++)u[i]&&e.push(t[i]);r(null,e)})}function In(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(e,i){e?r(e):(i&&u.push({index:t,value:n}),r())})},function(n){n?r(n):r(null,K(u.sort(function(n,t){return n.index-t.index}),Bn("value")))})}function Mn(n,t,e,r){var u=d(t)?Fn:In;u(n,t,a(e),r||m)}function Un(n,t){function e(n){return n?r(n):void u(e)}var r=U(t||m),u=a(Tn(n));e()}function qn(n,t,e,r){r=g(r||m);var u={},i=a(e);z(n,t,function(n,t,e){i(n,t,function(n,r){return n?e(n):(u[t]=r,void e())})},function(n){r(n,u)})}function zn(n,t){return t in n}function Pn(n,e){var r=Object.create(null),u=Object.create(null);e=e||gn;var i=a(n),o=ct(function(n,o){var c=e.apply(null,n);zn(r,c)?lt(function(){o.apply(null,r[c])}):zn(u,c)?u[c].push(o):(u[c]=[o],i.apply(null,n.concat(function(){var n=t(arguments);r[c]=n;var e=u[c];delete u[c];for(var i=0,o=e.length;i<o;i++)e[i].apply(null,n)})))});return o.memo=r,o.unmemoized=n,o}function Vn(n,e,r){r=r||m;var u=d(e)?[]:{};n(e,function(n,e,r){a(n)(function(n,i){arguments.length>2&&(i=t(arguments,1)),u[e]=i,r(n)})},function(n){r(n,u)})}function Dn(n,t){Vn(Fe,n,t)}function Rn(n,t,e){Vn(q(t),n,e)}function Cn(n,t){if(t=g(t||m),!Pt(n))return t(new TypeError("First argument to race must be an array of functions"));if(!n.length)return t();for(var e=0,r=n.length;e<r;e++)a(n[e])(t)}function $n(n,e,r,u){var i=t(n).reverse();dn(i,e,r,u)}function Wn(n){var e=a(n);return ct(function(n,r){return n.push(function(n,e){if(n)r(null,{error:n});else{var u;u=arguments.length<=2?e:t(arguments,1),r(null,{value:u})}}),e.apply(this,n)})}function Nn(n){var t;return Pt(n)?t=K(n,Wn):(t={},N(n,function(n,e){t[e]=Wn.call(this,n)})),t}function Qn(n,t,e,r){Mn(n,t,function(n,t){e(n,function(n,e){t(n,!e)})},r)}function Gn(n){return function(){return n}}function Hn(n,t,e){function r(n,t){if("object"==typeof t)n.times=+t.times||i,n.intervalFunc="function"==typeof t.interval?t.interval:Gn(+t.interval||o),n.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");n.times=+t||i}}function u(){f(function(n){n&&l++<c.times&&("function"!=typeof c.errorFilter||c.errorFilter(n))?setTimeout(u,c.intervalFunc(l)):e.apply(null,arguments)})}var i=5,o=0,c={times:i,intervalFunc:Gn(o)};if(arguments.length<3&&"function"==typeof n?(e=t||m,t=n):(r(c,n),e=e||m),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var f=a(t),l=1;u()}function Jn(n,t){Vn(Or,n,t)}function Kn(n,t,e){function r(n,t){var e=n.criteria,r=t.criteria;return e<r?-1:e>r?1:0}var u=a(t);Ie(n,function(n,t){u(n,function(e,r){return e?t(e):void t(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,K(t.sort(r),Bn("value")))})}function Xn(n,t,e){var r=a(n);return ct(function(u,i){function o(){var t=n.name||"anonymous",r=new Error('Callback function "'+t+'" timed out.');r.code="ETIMEDOUT",e&&(r.info=e),f=!0,i(r)}var c,f=!1;u.push(function(){f||(i.apply(null,arguments),clearTimeout(c))}),c=setTimeout(o,t),r.apply(null,u)})}function Yn(n,t,e,r){for(var u=-1,i=iu(uu((t-n)/(e||1)),0),o=Array(i);i--;)o[r?i:++u]=n,n+=e;return o}function Zn(n,t,e,r){var u=a(e);Ue(Yn(0,n,1),t,u,r)}function nt(n,t,e,r){arguments.length<=3&&(r=e,e=t,t=Pt(n)?[]:{}),r=g(r||m);var u=a(e);Fe(n,function(n,e,r){u(t,n,e,r)},function(n){r(n,t)})}function tt(n,e){var r,u=null;e=e||m,Ur(n,function(n,e){a(n)(function(n,i){r=arguments.length>2?t(arguments,1):i,u=n,e(!n)})},function(){e(u,r)})}function et(n){return function(){return(n.unmemoized||n).apply(null,arguments)}}function rt(n,e,r){r=U(r||m);var u=a(e);if(!n())return r(null);var i=function(e){if(e)return r(e);if(n())return u(i);var o=t(arguments,1);r.apply(null,[null].concat(o))};u(i)}function ut(n,t,e){rt(function(){return!n.apply(this,arguments)},t,e)}var it,ot=function(n){var e=t(arguments,1);return function(){var r=t(arguments);return n.apply(null,e.concat(r))}},ct=function(n){return function(){var e=t(arguments),r=e.pop();n.call(this,e,r)}},ft="function"==typeof setImmediate&&setImmediate,at="object"==typeof process&&"function"==typeof process.nextTick;it=ft?setImmediate:at?process.nextTick:r;var lt=u(it),st="function"==typeof Symbol,pt="object"==typeof global&&global&&global.Object===Object&&global,ht="object"==typeof self&&self&&self.Object===Object&&self,yt=pt||ht||Function("return this")(),vt=yt.Symbol,dt=Object.prototype,mt=dt.hasOwnProperty,gt=dt.toString,bt=vt?vt.toStringTag:void 0,jt=Object.prototype,St=jt.toString,kt="[object Null]",Lt="[object Undefined]",Ot=vt?vt.toStringTag:void 0,wt="[object AsyncFunction]",xt="[object Function]",Et="[object GeneratorFunction]",At="[object Proxy]",Tt=9007199254740991,_t={},Bt="function"==typeof Symbol&&Symbol.iterator,Ft=function(n){return Bt&&n[Bt]&&n[Bt]()},It="[object Arguments]",Mt=Object.prototype,Ut=Mt.hasOwnProperty,qt=Mt.propertyIsEnumerable,zt=S(function(){return arguments}())?S:function(n){return j(n)&&Ut.call(n,"callee")&&!qt.call(n,"callee")},Pt=Array.isArray,Vt="object"==typeof n&&n&&!n.nodeType&&n,Dt=Vt&&"object"==typeof module&&module&&!module.nodeType&&module,Rt=Dt&&Dt.exports===Vt,Ct=Rt?yt.Buffer:void 0,$t=Ct?Ct.isBuffer:void 0,Wt=$t||k,Nt=9007199254740991,Qt=/^(?:0|[1-9]\d*)$/,Gt="[object Arguments]",Ht="[object Array]",Jt="[object Boolean]",Kt="[object Date]",Xt="[object Error]",Yt="[object Function]",Zt="[object Map]",ne="[object Number]",te="[object Object]",ee="[object RegExp]",re="[object Set]",ue="[object String]",ie="[object WeakMap]",oe="[object ArrayBuffer]",ce="[object DataView]",fe="[object Float32Array]",ae="[object Float64Array]",le="[object Int8Array]",se="[object Int16Array]",pe="[object Int32Array]",he="[object Uint8Array]",ye="[object Uint8ClampedArray]",ve="[object Uint16Array]",de="[object Uint32Array]",me={};me[fe]=me[ae]=me[le]=me[se]=me[pe]=me[he]=me[ye]=me[ve]=me[de]=!0,me[Gt]=me[Ht]=me[oe]=me[Jt]=me[ce]=me[Kt]=me[Xt]=me[Yt]=me[Zt]=me[ne]=me[te]=me[ee]=me[re]=me[ue]=me[ie]=!1;var ge="object"==typeof n&&n&&!n.nodeType&&n,be=ge&&"object"==typeof module&&module&&!module.nodeType&&module,je=be&&be.exports===ge,Se=je&&pt.process,ke=function(){try{var n=be&&be.require&&be.require("util").types;return n?n:Se&&Se.binding&&Se.binding("util")}catch(n){}}(),Le=ke&&ke.isTypedArray,Oe=Le?w(Le):O,we=Object.prototype,xe=we.hasOwnProperty,Ee=Object.prototype,Ae=A(Object.keys,Object),Te=Object.prototype,_e=Te.hasOwnProperty,Be=P(z,1/0),Fe=function(n,t,e){var r=d(n)?V:Be;r(n,a(t),e)},Ie=D(R),Me=l(Ie),Ue=C(R),qe=P(Ue,1),ze=l(qe),Pe=W(),Ve=function(n,e,r){function u(n,t){j.push(function(){f(n,t)})}function i(){if(0===j.length&&0===v)return r(null,y);for(;j.length&&v<e;){var n=j.shift();n()}}function o(n,t){var e=b[n];e||(e=b[n]=[]),e.push(t)}function c(n){var t=b[n]||[];$(t,function(n){n()}),i()}function f(n,e){if(!d){var u=U(function(e,u){if(v--,arguments.length>2&&(u=t(arguments,1)),e){var i={};N(y,function(n,t){i[t]=n}),i[n]=u,d=!0,b=Object.create(null),r(e,i)}else y[n]=u,c(n)});v++;var i=a(e[e.length-1]);e.length>1?i(y,u):i(u)}}function l(){for(var n,t=0;S.length;)n=S.pop(),t++,$(s(n),function(n){0===--k[n]&&S.push(n)});if(t!==h)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function s(t){var e=[];return N(n,function(n,r){Pt(n)&&J(n,t,0)>=0&&e.push(r)}),e}"function"==typeof e&&(r=e,e=null),r=g(r||m);var p=_(n),h=p.length;if(!h)return r(null);e||(e=h);var y={},v=0,d=!1,b=Object.create(null),j=[],S=[],k={};N(n,function(t,e){if(!Pt(t))return u(e,[t]),void S.push(e);var r=t.slice(0,t.length-1),i=r.length;return 0===i?(u(e,t),void S.push(e)):(k[e]=i,void $(r,function(c){if(!n[c])throw new Error("async.auto task `"+e+"` has a non-existent dependency `"+c+"` in "+r.join(", "));o(c,function(){i--,0===i&&u(e,t)})}))}),l(),i()},De="[object Symbol]",Re=1/0,Ce=vt?vt.prototype:void 0,$e=Ce?Ce.toString:void 0,We="\\ud800-\\udfff",Ne="\\u0300-\\u036f",Qe="\\ufe20-\\ufe2f",Ge="\\u20d0-\\u20ff",He=Ne+Qe+Ge,Je="\\ufe0e\\ufe0f",Ke="\\u200d",Xe=RegExp("["+Ke+We+He+Je+"]"),Ye="\\ud800-\\udfff",Ze="\\u0300-\\u036f",nr="\\ufe20-\\ufe2f",tr="\\u20d0-\\u20ff",er=Ze+nr+tr,rr="\\ufe0e\\ufe0f",ur="["+Ye+"]",ir="["+er+"]",or="\\ud83c[\\udffb-\\udfff]",cr="(?:"+ir+"|"+or+")",fr="[^"+Ye+"]",ar="(?:\\ud83c[\\udde6-\\uddff]){2}",lr="[\\ud800-\\udbff][\\udc00-\\udfff]",sr="\\u200d",pr=cr+"?",hr="["+rr+"]?",yr="(?:"+sr+"(?:"+[fr,ar,lr].join("|")+")"+hr+pr+")*",vr=hr+pr+yr,dr="(?:"+[fr+ir+"?",ir,ar,lr,ur].join("|")+")",mr=RegExp(or+"(?="+or+")|"+dr+vr,"g"),gr=/^\s+|\s+$/g,br=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,jr=/,/,Sr=/(=.+)?(\s*)$/,kr=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;pn.prototype.removeLink=function(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n},pn.prototype.empty=function(){for(;this.head;)this.shift();return this},pn.prototype.insertAfter=function(n,t){t.prev=n,t.next=n.next,n.next?n.next.prev=t:this.tail=t,n.next=t,this.length+=1},pn.prototype.insertBefore=function(n,t){t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:this.head=t,n.prev=t,this.length+=1},pn.prototype.unshift=function(n){this.head?this.insertBefore(this.head,n):hn(this,n)},pn.prototype.push=function(n){this.tail?this.insertAfter(this.tail,n):hn(this,n)},pn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},pn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},pn.prototype.toArray=function(){for(var n=Array(this.length),t=this.head,e=0;e<this.length;e++)n[e]=t.data,t=t.next;return n},pn.prototype.remove=function(n){for(var t=this.head;t;){var e=t.next;n(t)&&this.removeLink(t),t=e}return this};var Lr,Or=P(z,1),wr=function(){return mn.apply(null,t(arguments).reverse())},xr=Array.prototype.concat,Er=function(n,e,r,u){u=u||m;var i=a(r);Ue(n,e,function(n,e){i(n,function(n){return n?e(n):e(null,t(arguments,1))})},function(n,t){for(var e=[],r=0;r<t.length;r++)t[r]&&(e=xr.apply(e,t[r]));return u(n,e)})},Ar=P(Er,1/0),Tr=P(Er,1),_r=function(){var n=t(arguments),e=[null].concat(n);return function(){var n=arguments[arguments.length-1];return n.apply(this,e)}},Br=D(bn(gn,jn)),Fr=C(bn(gn,jn)),Ir=P(Fr,1),Mr=Sn("dir"),Ur=P(An,1),qr=D(bn(_n,_n)),zr=C(bn(_n,_n)),Pr=P(zr,1),Vr=D(Mn),Dr=C(Mn),Rr=P(Dr,1),Cr=function(n,t,e,r){r=r||m;var u=a(e);Ue(n,t,function(n,t){u(n,function(e,r){return e?t(e):t(null,{key:r,val:n})})},function(n,t){for(var e={},u=Object.prototype.hasOwnProperty,i=0;i<t.length;i++)if(t[i]){var o=t[i].key,c=t[i].val;u.call(e,o)?e[o].push(c):e[o]=[c]}return r(n,e)})},$r=P(Cr,1/0),Wr=P(Cr,1),Nr=Sn("log"),Qr=P(qn,1/0),Gr=P(qn,1);Lr=at?process.nextTick:ft?setImmediate:r;var Hr=u(Lr),Jr=function(n,t){var e=a(n);return yn(function(n,t){e(n[0],t)},t,1)},Kr=function(n,t){var e=Jr(n,t);return e.push=function(n,t,r){if(null==r&&(r=m),"function"!=typeof r)throw new Error("task callback must be a function");if(e.started=!0,Pt(n)||(n=[n]),0===n.length)return lt(function(){e.drain()});t=t||0;for(var u=e._tasks.head;u&&t>=u.priority;)u=u.next;for(var i=0,o=n.length;i<o;i++){var c={data:n[i],priority:t,callback:r};u?e._tasks.insertBefore(u,c):e._tasks.push(c)}lt(e.process)},delete e.unshift,e},Xr=D(Qn),Yr=C(Qn),Zr=P(Yr,1),nu=function(n,t){t||(t=n,n=null);var e=a(t);return ct(function(t,r){function u(n){e.apply(null,t.concat(n))}n?Hn(n,u,r):Hn(u,r)})},tu=D(bn(Boolean,gn)),eu=C(bn(Boolean,gn)),ru=P(eu,1),uu=Math.ceil,iu=Math.max,ou=P(Zn,1/0),cu=P(Zn,1),fu=function(n,e){function r(t){var e=a(n[i++]);t.push(U(u)),e.apply(null,t)}function u(u){return u||i===n.length?e.apply(null,arguments):void r(t(arguments,1))}if(e=g(e||m),!Pt(n))return e(new Error("First argument to waterfall must be an array of functions"));if(!n.length)return e();var i=0;r([])},au={apply:ot,applyEach:Me,applyEachSeries:ze,asyncify:i,auto:Ve,autoInject:sn,cargo:vn,compose:wr,concat:Ar,concatLimit:Er,concatSeries:Tr,constant:_r,detect:Br,detectLimit:Fr,detectSeries:Ir,dir:Mr,doDuring:kn,doUntil:On,doWhilst:Ln,during:wn,each:En,eachLimit:An,eachOf:Fe,eachOfLimit:z,eachOfSeries:Or,eachSeries:Ur,ensureAsync:Tn,every:qr,everyLimit:zr,everySeries:Pr,filter:Vr,filterLimit:Dr,filterSeries:Rr,forever:Un,groupBy:$r,groupByLimit:Cr,groupBySeries:Wr,log:Nr,map:Ie,mapLimit:Ue,mapSeries:qe,mapValues:Qr,mapValuesLimit:qn,mapValuesSeries:Gr,memoize:Pn,nextTick:Hr,parallel:Dn,parallelLimit:Rn,priorityQueue:Kr,queue:Jr,race:Cn,reduce:dn,reduceRight:$n,reflect:Wn,reflectAll:Nn,reject:Xr,rejectLimit:Yr,rejectSeries:Zr,retry:Hn,retryable:nu,seq:mn,series:Jn,setImmediate:lt,some:tu,someLimit:eu,someSeries:ru,sortBy:Kn,timeout:Xn,times:ou,timesLimit:Zn,timesSeries:cu,transform:nt,tryEach:tt,unmemoize:et,until:ut,waterfall:fu,whilst:rt,all:qr,allLimit:zr,allSeries:Pr,any:tu,anyLimit:eu,anySeries:ru,find:Br,findLimit:Fr,findSeries:Ir,forEach:En,forEachSeries:Ur,forEachLimit:An,forEachOf:Fe,forEachOfSeries:Or,forEachOfLimit:z,inject:dn,foldl:dn,foldr:$n,select:Vr,selectLimit:Dr,selectSeries:Rr,wrapSync:i};n.default=au,n.apply=ot,n.applyEach=Me,n.applyEachSeries=ze,n.asyncify=i,n.auto=Ve,n.autoInject=sn,n.cargo=vn,n.compose=wr,n.concat=Ar,n.concatLimit=Er,n.concatSeries=Tr,n.constant=_r,n.detect=Br,n.detectLimit=Fr,n.detectSeries=Ir,n.dir=Mr,n.doDuring=kn,n.doUntil=On,n.doWhilst=Ln,n.during=wn,n.each=En,n.eachLimit=An,n.eachOf=Fe,n.eachOfLimit=z,n.eachOfSeries=Or,n.eachSeries=Ur,n.ensureAsync=Tn,n.every=qr,n.everyLimit=zr,n.everySeries=Pr,n.filter=Vr,n.filterLimit=Dr,n.filterSeries=Rr,n.forever=Un,n.groupBy=$r,n.groupByLimit=Cr,n.groupBySeries=Wr,n.log=Nr,n.map=Ie,n.mapLimit=Ue,n.mapSeries=qe,n.mapValues=Qr,n.mapValuesLimit=qn,n.mapValuesSeries=Gr,n.memoize=Pn,n.nextTick=Hr,n.parallel=Dn,n.parallelLimit=Rn,n.priorityQueue=Kr,n.queue=Jr,n.race=Cn,n.reduce=dn,n.reduceRight=$n,n.reflect=Wn,n.reflectAll=Nn,n.reject=Xr,n.rejectLimit=Yr,n.rejectSeries=Zr,n.retry=Hn,n.retryable=nu,n.seq=mn,n.series=Jn,n.setImmediate=lt,n.some=tu,n.someLimit=eu,n.someSeries=ru,n.sortBy=Kn,n.timeout=Xn,n.times=ou,n.timesLimit=Zn,n.timesSeries=cu,n.transform=nt,n.tryEach=tt,n.unmemoize=et,n.until=ut,n.waterfall=fu,n.whilst=rt,n.all=qr,n.allLimit=zr,n.allSeries=Pr,n.any=tu,n.anyLimit=eu,n.anySeries=ru,n.find=Br,n.findLimit=Fr,n.findSeries=Ir,n.forEach=En,n.forEachSeries=Ur,n.forEachLimit=An,n.forEachOf=Fe,n.forEachOfSeries=Or,n.forEachOfLimit=z,n.inject=dn,n.foldl=dn,n.foldr=$n,n.select=Vr,n.selectLimit=Dr,n.selectSeries=Rr,n.wrapSync=i,Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=async.min.map
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/dist/async.min.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 8,731 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (coll) {
return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
};
var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/getIterator.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 65 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = queue;
var _baseIndexOf = require('lodash/_baseIndexOf');
var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
var _isArray = require('lodash/isArray');
var _isArray2 = _interopRequireDefault(_isArray);
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _onlyOnce = require('./onlyOnce');
var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
var _setImmediate = require('./setImmediate');
var _setImmediate2 = _interopRequireDefault(_setImmediate);
var _DoublyLinkedList = require('./DoublyLinkedList');
var _DoublyLinkedList2 = _interopRequireDefault(_DoublyLinkedList);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function queue(worker, concurrency, payload) {
if (concurrency == null) {
concurrency = 1;
} else if (concurrency === 0) {
throw new Error('Concurrency must not be zero');
}
var _worker = (0, _wrapAsync2.default)(worker);
var numRunning = 0;
var workersList = [];
var processingScheduled = false;
function _insert(data, insertAtFront, callback) {
if (callback != null && typeof callback !== 'function') {
throw new Error('task callback must be a function');
}
q.started = true;
if (!(0, _isArray2.default)(data)) {
data = [data];
}
if (data.length === 0 && q.idle()) {
// call drain immediately if there are no tasks
return (0, _setImmediate2.default)(function () {
q.drain();
});
}
for (var i = 0, l = data.length; i < l; i++) {
var item = {
data: data[i],
callback: callback || _noop2.default
};
if (insertAtFront) {
q._tasks.unshift(item);
} else {
q._tasks.push(item);
}
}
if (!processingScheduled) {
processingScheduled = true;
(0, _setImmediate2.default)(function () {
processingScheduled = false;
q.process();
});
}
}
function _next(tasks) {
return function (err) {
numRunning -= 1;
for (var i = 0, l = tasks.length; i < l; i++) {
var task = tasks[i];
var index = (0, _baseIndexOf2.default)(workersList, task, 0);
if (index === 0) {
workersList.shift();
} else if (index > 0) {
workersList.splice(index, 1);
}
task.callback.apply(task, arguments);
if (err != null) {
q.error(err, task.data);
}
}
if (numRunning <= q.concurrency - q.buffer) {
q.unsaturated();
}
if (q.idle()) {
q.drain();
}
q.process();
};
}
var isProcessing = false;
var q = {
_tasks: new _DoublyLinkedList2.default(),
concurrency: concurrency,
payload: payload,
saturated: _noop2.default,
unsaturated: _noop2.default,
buffer: concurrency / 4,
empty: _noop2.default,
drain: _noop2.default,
error: _noop2.default,
started: false,
paused: false,
push: function (data, callback) {
_insert(data, false, callback);
},
kill: function () {
q.drain = _noop2.default;
q._tasks.empty();
},
unshift: function (data, callback) {
_insert(data, true, callback);
},
remove: function (testFn) {
q._tasks.remove(testFn);
},
process: function () {
// Avoid trying to start too many processing operations. This can occur
// when callbacks resolve synchronously (#1267).
if (isProcessing) {
return;
}
isProcessing = true;
while (!q.paused && numRunning < q.concurrency && q._tasks.length) {
var tasks = [],
data = [];
var l = q._tasks.length;
if (q.payload) l = Math.min(l, q.payload);
for (var i = 0; i < l; i++) {
var node = q._tasks.shift();
tasks.push(node);
workersList.push(node);
data.push(node.data);
}
numRunning += 1;
if (q._tasks.length === 0) {
q.empty();
}
if (numRunning === q.concurrency) {
q.saturated();
}
var cb = (0, _onlyOnce2.default)(_next(tasks));
_worker(data, cb);
}
isProcessing = false;
},
length: function () {
return q._tasks.length;
},
running: function () {
return numRunning;
},
workersList: function () {
return workersList;
},
idle: function () {
return q._tasks.length + numRunning === 0;
},
pause: function () {
q.paused = true;
},
resume: function () {
if (q.paused === false) {
return;
}
q.paused = false;
(0, _setImmediate2.default)(q.process);
}
};
return q;
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/queue.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,235 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (fn) {
return function () /*...args, callback*/{
var args = (0, _slice2.default)(arguments);
var callback = args.pop();
fn.call(this, args, callback);
};
};
var _slice = require('./slice');
var _slice2 = _interopRequireDefault(_slice);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/initialParams.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 116 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isAsync = undefined;
var _asyncify = require('../asyncify');
var _asyncify2 = _interopRequireDefault(_asyncify);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var supportsSymbol = typeof Symbol === 'function';
function isAsync(fn) {
return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction';
}
function wrapAsync(asyncFn) {
return isAsync(asyncFn) ? (0, _asyncify2.default)(asyncFn) : asyncFn;
}
exports.default = wrapAsync;
exports.isAsync = isAsync;
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/wrapAsync.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 145 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = notId;
function notId(v) {
return !v;
}
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/notId.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 43 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _parallel;
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _isArrayLike = require('lodash/isArrayLike');
var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
var _slice = require('./slice');
var _slice2 = _interopRequireDefault(_slice);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _parallel(eachfn, tasks, callback) {
callback = callback || _noop2.default;
var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
eachfn(tasks, function (task, key, callback) {
(0, _wrapAsync2.default)(task)(function (err, result) {
if (arguments.length > 2) {
result = (0, _slice2.default)(arguments, 1);
}
results[key] = result;
callback(err);
});
}, function (err) {
callback(err, results);
});
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/parallel.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 266 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _asyncMap;
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _asyncMap(eachfn, arr, iteratee, callback) {
callback = callback || _noop2.default;
arr = arr || [];
var results = [];
var counter = 0;
var _iteratee = (0, _wrapAsync2.default)(iteratee);
eachfn(arr, function (value, _, callback) {
var index = counter++;
_iteratee(value, function (err, v) {
results[index] = v;
callback(err);
});
}, function (err) {
callback(err, results);
});
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/map.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 217 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = iterator;
var _isArrayLike = require('lodash/isArrayLike');
var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
var _getIterator = require('./getIterator');
var _getIterator2 = _interopRequireDefault(_getIterator);
var _keys = require('lodash/keys');
var _keys2 = _interopRequireDefault(_keys);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function createArrayIterator(coll) {
var i = -1;
var len = coll.length;
return function next() {
return ++i < len ? { value: coll[i], key: i } : null;
};
}
function createES2015Iterator(iterator) {
var i = -1;
return function next() {
var item = iterator.next();
if (item.done) return null;
i++;
return { value: item.value, key: i };
};
}
function createObjectIterator(obj) {
var okeys = (0, _keys2.default)(obj);
var i = -1;
var len = okeys.length;
return function next() {
var key = okeys[++i];
if (key === '__proto__') {
return next();
}
return i < len ? { value: obj[key], key: key } : null;
};
}
function iterator(coll) {
if ((0, _isArrayLike2.default)(coll)) {
return createArrayIterator(coll);
}
var iterator = (0, _getIterator2.default)(coll);
return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/iterator.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 374 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = slice;
function slice(arrayLike, start) {
start = start | 0;
var newLen = Math.max(arrayLike.length - start, 0);
var newArr = Array(newLen);
for (var idx = 0; idx < newLen; idx++) {
newArr[idx] = arrayLike[start + idx];
}
return newArr;
}
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/slice.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 105 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = onlyOnce;
function onlyOnce(fn) {
return function () {
if (fn === null) throw new Error("Callback was already called.");
var callFn = fn;
fn = null;
callFn.apply(this, arguments);
};
}
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/onlyOnce.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 81 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasNextTick = exports.hasSetImmediate = undefined;
exports.fallback = fallback;
exports.wrap = wrap;
var _slice = require('./slice');
var _slice2 = _interopRequireDefault(_slice);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
function fallback(fn) {
setTimeout(fn, 0);
}
function wrap(defer) {
return function (fn /*, ...args*/) {
var args = (0, _slice2.default)(arguments, 1);
defer(function () {
fn.apply(null, args);
});
};
}
var _defer;
if (hasSetImmediate) {
_defer = setImmediate;
} else if (hasNextTick) {
_defer = process.nextTick;
} else {
_defer = fallback;
}
exports.default = wrap(_defer);
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/setImmediate.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 239 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
// A temporary value used to identify if the loop should be broken.
// See #1064, #1293
exports.default = {};
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/breakLoop.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 53 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = reject;
var _filter = require('./filter');
var _filter2 = _interopRequireDefault(_filter);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function reject(eachfn, arr, iteratee, callback) {
(0, _filter2.default)(eachfn, arr, function (value, cb) {
iteratee(value, function (err, v) {
cb(err, !v);
});
}, callback);
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/reject.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 129 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = consoleFunc;
var _arrayEach = require('lodash/_arrayEach');
var _arrayEach2 = _interopRequireDefault(_arrayEach);
var _slice = require('./slice');
var _slice2 = _interopRequireDefault(_slice);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function consoleFunc(name) {
return function (fn /*, ...args*/) {
var args = (0, _slice2.default)(arguments, 1);
args.push(function (err /*, ...args*/) {
var args = (0, _slice2.default)(arguments, 1);
if (typeof console === 'object') {
if (err) {
if (console.error) {
console.error(err);
}
} else if (console[name]) {
(0, _arrayEach2.default)(args, function (x) {
console[name](x);
});
}
}
});
(0, _wrapAsync2.default)(fn).apply(null, args);
};
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/consoleFunc.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 269 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = applyEach;
var _slice = require('./slice');
var _slice2 = _interopRequireDefault(_slice);
var _initialParams = require('./initialParams');
var _initialParams2 = _interopRequireDefault(_initialParams);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function applyEach(eachfn) {
return function (fns /*, ...args*/) {
var args = (0, _slice2.default)(arguments, 1);
var go = (0, _initialParams2.default)(function (args, callback) {
var that = this;
return eachfn(fns, function (fn, cb) {
(0, _wrapAsync2.default)(fn).apply(that, args.concat(cb));
}, callback);
});
if (args.length) {
return go.apply(this, args);
} else {
return go;
}
};
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/applyEach.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 243 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _withoutIndex;
function _withoutIndex(iteratee) {
return function (value, index, callback) {
return iteratee(value, callback);
};
}
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/withoutIndex.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 62 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = doLimit;
function doLimit(fn, limit) {
return function (iterable, iteratee, callback) {
return fn(iterable, limit, iteratee, callback);
};
}
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/doLimit.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 68 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = doParallel;
var _eachOf = require('../eachOf');
var _eachOf2 = _interopRequireDefault(_eachOf);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function doParallel(fn) {
return function (obj, iteratee, callback) {
return fn(_eachOf2.default, obj, (0, _wrapAsync2.default)(iteratee), callback);
};
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/doParallel.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 142 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DLL;
// Simple doubly linked list (path_to_url implementation
// used for queues. This implementation assumes that the node provided by the user can be modified
// to adjust the next and last properties. We implement only the minimal functionality
// for queue support.
function DLL() {
this.head = this.tail = null;
this.length = 0;
}
function setInitial(dll, node) {
dll.length = 1;
dll.head = dll.tail = node;
}
DLL.prototype.removeLink = function (node) {
if (node.prev) node.prev.next = node.next;else this.head = node.next;
if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
node.prev = node.next = null;
this.length -= 1;
return node;
};
DLL.prototype.empty = function () {
while (this.head) this.shift();
return this;
};
DLL.prototype.insertAfter = function (node, newNode) {
newNode.prev = node;
newNode.next = node.next;
if (node.next) node.next.prev = newNode;else this.tail = newNode;
node.next = newNode;
this.length += 1;
};
DLL.prototype.insertBefore = function (node, newNode) {
newNode.prev = node.prev;
newNode.next = node;
if (node.prev) node.prev.next = newNode;else this.head = newNode;
node.prev = newNode;
this.length += 1;
};
DLL.prototype.unshift = function (node) {
if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);
};
DLL.prototype.push = function (node) {
if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
};
DLL.prototype.shift = function () {
return this.head && this.removeLink(this.head);
};
DLL.prototype.pop = function () {
return this.tail && this.removeLink(this.tail);
};
DLL.prototype.toArray = function () {
var arr = Array(this.length);
var curr = this.head;
for (var idx = 0; idx < this.length; idx++) {
arr[idx] = curr.data;
curr = curr.next;
}
return arr;
};
DLL.prototype.remove = function (testFn) {
var curr = this.head;
while (!!curr) {
var next = curr.next;
if (testFn(curr)) {
this.removeLink(curr);
}
curr = next;
}
return this;
};
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/DoublyLinkedList.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 550 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _findGetResult;
function _findGetResult(v, x) {
return x;
}
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/findGetResult.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 48 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _eachOfLimit;
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _once = require('./once');
var _once2 = _interopRequireDefault(_once);
var _iterator = require('./iterator');
var _iterator2 = _interopRequireDefault(_iterator);
var _onlyOnce = require('./onlyOnce');
var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
var _breakLoop = require('./breakLoop');
var _breakLoop2 = _interopRequireDefault(_breakLoop);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _eachOfLimit(limit) {
return function (obj, iteratee, callback) {
callback = (0, _once2.default)(callback || _noop2.default);
if (limit <= 0 || !obj) {
return callback(null);
}
var nextElem = (0, _iterator2.default)(obj);
var done = false;
var running = 0;
var looping = false;
function iterateeCallback(err, value) {
running -= 1;
if (err) {
done = true;
callback(err);
} else if (value === _breakLoop2.default || done && running <= 0) {
done = true;
return callback(null);
} else if (!looping) {
replenish();
}
}
function replenish() {
looping = true;
while (running < limit && !done) {
var elem = nextElem();
if (elem === null) {
done = true;
if (running <= 0) {
callback(null);
}
return;
}
running += 1;
iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
}
looping = false;
}
replenish();
};
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/eachOfLimit.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 430 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _filter;
var _arrayMap = require('lodash/_arrayMap');
var _arrayMap2 = _interopRequireDefault(_arrayMap);
var _isArrayLike = require('lodash/isArrayLike');
var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
var _baseProperty = require('lodash/_baseProperty');
var _baseProperty2 = _interopRequireDefault(_baseProperty);
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function filterArray(eachfn, arr, iteratee, callback) {
var truthValues = new Array(arr.length);
eachfn(arr, function (x, index, callback) {
iteratee(x, function (err, v) {
truthValues[index] = !!v;
callback(err);
});
}, function (err) {
if (err) return callback(err);
var results = [];
for (var i = 0; i < arr.length; i++) {
if (truthValues[i]) results.push(arr[i]);
}
callback(null, results);
});
}
function filterGeneric(eachfn, coll, iteratee, callback) {
var results = [];
eachfn(coll, function (x, index, callback) {
iteratee(x, function (err, v) {
if (err) {
callback(err);
} else {
if (v) {
results.push({ index: index, value: x });
}
callback();
}
});
}, function (err) {
if (err) {
callback(err);
} else {
callback(null, (0, _arrayMap2.default)(results.sort(function (a, b) {
return a.index - b.index;
}), (0, _baseProperty2.default)('value')));
}
});
}
function _filter(eachfn, coll, iteratee, callback) {
var filter = (0, _isArrayLike2.default)(coll) ? filterArray : filterGeneric;
filter(eachfn, coll, (0, _wrapAsync2.default)(iteratee), callback || _noop2.default);
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/filter.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 511 |
```javascript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = once;
function once(fn) {
return function () {
if (fn === null) return;
var callFn = fn;
fn = null;
callFn.apply(this, arguments);
};
}
module.exports = exports["default"];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/once.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 72 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = doParallelLimit;
var _eachOfLimit = require('./eachOfLimit');
var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
var _wrapAsync = require('./wrapAsync');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function doParallelLimit(fn) {
return function (obj, limit, iteratee, callback) {
return fn((0, _eachOfLimit2.default)(limit), obj, (0, _wrapAsync2.default)(iteratee), callback);
};
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/doParallelLimit.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 156 |
```javascript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _createTester;
var _noop = require('lodash/noop');
var _noop2 = _interopRequireDefault(_noop);
var _breakLoop = require('./breakLoop');
var _breakLoop2 = _interopRequireDefault(_breakLoop);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _createTester(check, getResult) {
return function (eachfn, arr, iteratee, cb) {
cb = cb || _noop2.default;
var testPassed = false;
var testResult;
eachfn(arr, function (value, _, callback) {
iteratee(value, function (err, result) {
if (err) {
callback(err);
} else if (check(result) && !testResult) {
testPassed = true;
testResult = getResult(true, value);
callback(null, _breakLoop2.default);
} else {
callback();
}
});
}, function (err) {
if (err) {
cb(err);
} else {
cb(null, testPassed ? testResult : getResult(false));
}
});
};
}
module.exports = exports['default'];
``` | /content/code_sandbox/node_modules/random-fake-useragent/node_modules/async/internal/createTester.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 267 |
```html
<script src="tslib.es6.js"></script>
``` | /content/code_sandbox/node_modules/tslib/tslib.es6.html | html | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 12 |
```html
<script src="tslib.js"></script>
``` | /content/code_sandbox/node_modules/tslib/tslib.html | html | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 10 |
```javascript
/******************************************************************************
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
export function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
export var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
}
return __assign.apply(this, arguments);
}
export function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
export function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
export function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
export function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
export function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
export function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
export var __createBinding = Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
export function __exportStar(m, o) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
}
export function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
export function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
/** @deprecated */
export function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/** @deprecated */
export function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
export function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
export function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
export function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
export function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
export function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
export function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var __setModuleDefault = Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
};
export function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
}
export function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
export function __classPrivateFieldGet(receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
}
export function __classPrivateFieldSet(receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
}
export function __classPrivateFieldIn(state, receiver) {
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
}
``` | /content/code_sandbox/node_modules/tslib/tslib.es6.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 3,304 |
```javascript
import tslib from '../tslib.js';
const {
__extends,
__assign,
__rest,
__decorate,
__param,
__metadata,
__awaiter,
__generator,
__exportStar,
__createBinding,
__values,
__read,
__spread,
__spreadArrays,
__spreadArray,
__await,
__asyncGenerator,
__asyncDelegator,
__asyncValues,
__makeTemplateObject,
__importStar,
__importDefault,
__classPrivateFieldGet,
__classPrivateFieldSet,
__classPrivateFieldIn,
} = tslib;
export {
__extends,
__assign,
__rest,
__decorate,
__param,
__metadata,
__awaiter,
__generator,
__exportStar,
__createBinding,
__values,
__read,
__spread,
__spreadArrays,
__spreadArray,
__await,
__asyncGenerator,
__asyncDelegator,
__asyncValues,
__makeTemplateObject,
__importStar,
__importDefault,
__classPrivateFieldGet,
__classPrivateFieldSet,
__classPrivateFieldIn,
};
``` | /content/code_sandbox/node_modules/tslib/modules/index.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 260 |
```javascript
// Generated by CoffeeScript 1.12.2
(function() {
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
module.exports = function() {
return performance.now();
};
} else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
module.exports = function() {
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function() {
var hr;
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
} else if (Date.now) {
module.exports = function() {
return Date.now() - loadTime;
};
loadTime = Date.now();
} else {
module.exports = function() {
return new Date().getTime() - loadTime;
};
loadTime = new Date().getTime();
}
}).call(this);
//# sourceMappingURL=performance-now.js.map
``` | /content/code_sandbox/node_modules/performance-now/lib/performance-now.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 281 |
```coffeescript
Bluebird = require "bluebird"
exec = require("child_process").execSync
{assert} = require "chai"
describe "scripts/initital-value.coffee (module.uptime(), expressed in milliseconds)", ->
result = exec("./test/scripts/initial-value.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 100", -> assert.isAbove result, 100
it "printed a value below 350", -> assert.isBelow result, 350
describe "scripts/delayed-require.coffee (sum of uptime and 250 ms delay`)", ->
result = exec("./test/scripts/delayed-require.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 350", -> assert.isAbove result, 350
it "printed a value below 600", -> assert.isBelow result, 600
describe "scripts/delayed-call.coffee (sum of uptime and 250 ms delay`)", ->
result = exec("./test/scripts/delayed-call.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 350", -> assert.isAbove result, 350
it "printed a value below 600", -> assert.isBelow result, 600
describe "scripts/difference.coffee", ->
result = exec("./test/scripts/difference.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 0.005", -> assert.isAbove result, 0.005
it "printed a value below 0.07", -> assert.isBelow result, 0.07
``` | /content/code_sandbox/node_modules/performance-now/test/scripts.coffee | coffeescript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 359 |
```coffeescript
chai = require "chai"
chai.use(require "chai-increasing")
{assert,expect} = chai
Bluebird = require "bluebird"
now = require "../"
getUptime = -> process.uptime() * 1e3
describe "now", ->
it "reported time differs at most 1ms from a freshly reported uptime", ->
assert.isAtMost Math.abs(now()-getUptime()), 1
it "two subsequent calls return an increasing number", ->
assert.isBelow now(), now()
it "has less than 10 microseconds overhead", ->
assert.isBelow Math.abs(now() - now()), 0.010
it "can be called 1 million times in under 1 second (averaging under 1 microsecond per call)", ->
@timeout 1000
now() for [0...1e6]
undefined
it "for 10,000 numbers, number n is never bigger than number n-1", ->
stamps = (now() for [1...10000])
expect(stamps).to.be.increasing
it "shows that at least 0.2 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isAbove (now()-earlier), 0.2
it "shows that at most 3 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isBelow (now()-earlier), 3
it "shows that at least 190ms ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isAbove (now()-earlier), 190
it "shows that at most 220 ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isBelow (now()-earlier), 220
``` | /content/code_sandbox/node_modules/performance-now/test/performance-now.coffee | coffeescript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 432 |
```coffeescript
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 100 and below 350.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
now = require '../../lib/performance-now'
console.log now().toFixed 3
``` | /content/code_sandbox/node_modules/performance-now/test/scripts/initial-value.coffee | coffeescript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 77 |
```coffeescript
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 350 and below 600.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
delay = require "call-delayed"
delay 250, ->
now = require "../../lib/performance-now"
console.log now().toFixed 3
``` | /content/code_sandbox/node_modules/performance-now/test/scripts/delayed-require.coffee | coffeescript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 92 |
```coffeescript
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 350 and below 600.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
delay = require "call-delayed"
now = require "../../lib/performance-now"
delay 250, -> console.log now().toFixed 3
``` | /content/code_sandbox/node_modules/performance-now/test/scripts/delayed-call.coffee | coffeescript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 90 |
```coffeescript
#!/usr/bin/env ./node_modules/.bin/coffee
# Expected output is above 0.005 and below 0.07.
now = require('../../lib/performance-now')
console.log -(now() - now()).toFixed 3
``` | /content/code_sandbox/node_modules/performance-now/test/scripts/difference.coffee | coffeescript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 50 |
```coffeescript
if performance? and performance.now
module.exports = -> performance.now()
else if process? and process.hrtime
module.exports = -> (getNanoSeconds() - nodeLoadTime) / 1e6
hrtime = process.hrtime
getNanoSeconds = ->
hr = hrtime()
hr[0] * 1e9 + hr[1]
moduleLoadTime = getNanoSeconds()
upTime = process.uptime() * 1e9
nodeLoadTime = moduleLoadTime - upTime
else if Date.now
module.exports = -> Date.now() - loadTime
loadTime = Date.now()
else
module.exports = -> new Date().getTime() - loadTime
loadTime = new Date().getTime()
``` | /content/code_sandbox/node_modules/performance-now/src/performance-now.coffee | coffeescript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 165 |
```javascript
/******************************************************************************
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global global, define, System, Reflect, Promise */
var __extends;
var __assign;
var __rest;
var __decorate;
var __param;
var __metadata;
var __awaiter;
var __generator;
var __exportStar;
var __values;
var __read;
var __spread;
var __spreadArrays;
var __spreadArray;
var __await;
var __asyncGenerator;
var __asyncDelegator;
var __asyncValues;
var __makeTemplateObject;
var __importStar;
var __importDefault;
var __classPrivateFieldGet;
var __classPrivateFieldSet;
var __classPrivateFieldIn;
var __createBinding;
(function (factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) {
define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); });
}
else if (typeof module === "object" && typeof module.exports === "object") {
factory(createExporter(root, createExporter(module.exports)));
}
else {
factory(createExporter(root));
}
function createExporter(exports, previous) {
if (exports !== root) {
if (typeof Object.create === "function") {
Object.defineProperty(exports, "__esModule", { value: true });
}
else {
exports.__esModule = true;
}
}
return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };
}
})
(function (exporter) {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
__extends = function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
__rest = function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
__decorate = function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__param = function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
__metadata = function (metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
};
__awaiter = function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
__generator = function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
__exportStar = function(m, o) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
};
__createBinding = Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
__values = function (o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
__read = function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
/** @deprecated */
__spread = function () {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
};
/** @deprecated */
__spreadArrays = function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
__spreadArray = function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
__await = function (v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
};
__asyncGenerator = function (thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
};
__asyncDelegator = function (o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
};
__asyncValues = function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
__makeTemplateObject = function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var __setModuleDefault = Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
};
__importStar = function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
__importDefault = function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
__classPrivateFieldGet = function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
__classPrivateFieldSet = function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
__classPrivateFieldIn = function (state, receiver) {
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
};
exporter("__extends", __extends);
exporter("__assign", __assign);
exporter("__rest", __rest);
exporter("__decorate", __decorate);
exporter("__param", __param);
exporter("__metadata", __metadata);
exporter("__awaiter", __awaiter);
exporter("__generator", __generator);
exporter("__exportStar", __exportStar);
exporter("__createBinding", __createBinding);
exporter("__values", __values);
exporter("__read", __read);
exporter("__spread", __spread);
exporter("__spreadArrays", __spreadArrays);
exporter("__spreadArray", __spreadArray);
exporter("__await", __await);
exporter("__asyncGenerator", __asyncGenerator);
exporter("__asyncDelegator", __asyncDelegator);
exporter("__asyncValues", __asyncValues);
exporter("__makeTemplateObject", __makeTemplateObject);
exporter("__importStar", __importStar);
exporter("__importDefault", __importDefault);
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
exporter("__classPrivateFieldIn", __classPrivateFieldIn);
});
``` | /content/code_sandbox/node_modules/tslib/tslib.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 3,920 |
```javascript
var assert = require('assert');
var Stream = require('stream').Stream;
var util = require('util');
///--- Globals
/* JSSTYLED */
var UUID_REGEXP = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
///--- Internal
function _capitalize(str) {
return (str.charAt(0).toUpperCase() + str.slice(1));
}
function _toss(name, expected, oper, arg, actual) {
throw new assert.AssertionError({
message: util.format('%s (%s) is required', name, expected),
actual: (actual === undefined) ? typeof (arg) : actual(arg),
expected: expected,
operator: oper || '===',
stackStartFunction: _toss.caller
});
}
function _getClass(arg) {
return (Object.prototype.toString.call(arg).slice(8, -1));
}
function noop() {
// Why even bother with asserts?
}
///--- Exports
var types = {
bool: {
check: function (arg) { return typeof (arg) === 'boolean'; }
},
func: {
check: function (arg) { return typeof (arg) === 'function'; }
},
string: {
check: function (arg) { return typeof (arg) === 'string'; }
},
object: {
check: function (arg) {
return typeof (arg) === 'object' && arg !== null;
}
},
number: {
check: function (arg) {
return typeof (arg) === 'number' && !isNaN(arg);
}
},
finite: {
check: function (arg) {
return typeof (arg) === 'number' && !isNaN(arg) && isFinite(arg);
}
},
buffer: {
check: function (arg) { return Buffer.isBuffer(arg); },
operator: 'Buffer.isBuffer'
},
array: {
check: function (arg) { return Array.isArray(arg); },
operator: 'Array.isArray'
},
stream: {
check: function (arg) { return arg instanceof Stream; },
operator: 'instanceof',
actual: _getClass
},
date: {
check: function (arg) { return arg instanceof Date; },
operator: 'instanceof',
actual: _getClass
},
regexp: {
check: function (arg) { return arg instanceof RegExp; },
operator: 'instanceof',
actual: _getClass
},
uuid: {
check: function (arg) {
return typeof (arg) === 'string' && UUID_REGEXP.test(arg);
},
operator: 'isUUID'
}
};
function _setExports(ndebug) {
var keys = Object.keys(types);
var out;
/* re-export standard assert */
if (process.env.NODE_NDEBUG) {
out = noop;
} else {
out = function (arg, msg) {
if (!arg) {
_toss(msg, 'true', arg);
}
};
}
/* standard checks */
keys.forEach(function (k) {
if (ndebug) {
out[k] = noop;
return;
}
var type = types[k];
out[k] = function (arg, msg) {
if (!type.check(arg)) {
_toss(msg, k, type.operator, arg, type.actual);
}
};
});
/* optional checks */
keys.forEach(function (k) {
var name = 'optional' + _capitalize(k);
if (ndebug) {
out[name] = noop;
return;
}
var type = types[k];
out[name] = function (arg, msg) {
if (arg === undefined || arg === null) {
return;
}
if (!type.check(arg)) {
_toss(msg, k, type.operator, arg, type.actual);
}
};
});
/* arrayOf checks */
keys.forEach(function (k) {
var name = 'arrayOf' + _capitalize(k);
if (ndebug) {
out[name] = noop;
return;
}
var type = types[k];
var expected = '[' + k + ']';
out[name] = function (arg, msg) {
if (!Array.isArray(arg)) {
_toss(msg, expected, type.operator, arg, type.actual);
}
var i;
for (i = 0; i < arg.length; i++) {
if (!type.check(arg[i])) {
_toss(msg, expected, type.operator, arg, type.actual);
}
}
};
});
/* optionalArrayOf checks */
keys.forEach(function (k) {
var name = 'optionalArrayOf' + _capitalize(k);
if (ndebug) {
out[name] = noop;
return;
}
var type = types[k];
var expected = '[' + k + ']';
out[name] = function (arg, msg) {
if (arg === undefined || arg === null) {
return;
}
if (!Array.isArray(arg)) {
_toss(msg, expected, type.operator, arg, type.actual);
}
var i;
for (i = 0; i < arg.length; i++) {
if (!type.check(arg[i])) {
_toss(msg, expected, type.operator, arg, type.actual);
}
}
};
});
/* re-export built-in assertions */
Object.keys(assert).forEach(function (k) {
if (k === 'AssertionError') {
out[k] = assert[k];
return;
}
if (ndebug) {
out[k] = noop;
return;
}
out[k] = assert[k];
});
/* export ourselves (for unit tests _only_) */
out._setExports = _setExports;
return out;
}
module.exports = _setExports(process.env.NODE_NDEBUG);
``` | /content/code_sandbox/node_modules/assert-plus/assert.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,323 |
```javascript
"use strict";
var Buffer = require("safer-buffer").Buffer;
// Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that
// correspond to encoded bytes (if 128 - then lower half is ASCII).
exports._sbcs = SBCSCodec;
function SBCSCodec(codecOptions, iconv) {
if (!codecOptions)
throw new Error("SBCS codec is called without the data.")
// Prepare char buffer for decoding.
if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256))
throw new Error("Encoding '"+codecOptions.type+"' has incorrect 'chars' (must be of len 128 or 256)");
if (codecOptions.chars.length === 128) {
var asciiString = "";
for (var i = 0; i < 128; i++)
asciiString += String.fromCharCode(i);
codecOptions.chars = asciiString + codecOptions.chars;
}
this.decodeBuf = new Buffer.from(codecOptions.chars, 'ucs2');
// Encoding buffer.
var encodeBuf = new Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));
for (var i = 0; i < codecOptions.chars.length; i++)
encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
this.encodeBuf = encodeBuf;
}
SBCSCodec.prototype.encoder = SBCSEncoder;
SBCSCodec.prototype.decoder = SBCSDecoder;
function SBCSEncoder(options, codec) {
this.encodeBuf = codec.encodeBuf;
}
SBCSEncoder.prototype.write = function(str) {
var buf = Buffer.alloc(str.length);
for (var i = 0; i < str.length; i++)
buf[i] = this.encodeBuf[str.charCodeAt(i)];
return buf;
}
SBCSEncoder.prototype.end = function() {
}
function SBCSDecoder(options, codec) {
this.decodeBuf = codec.decodeBuf;
}
SBCSDecoder.prototype.write = function(buf) {
// Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
var decodeBuf = this.decodeBuf;
var newBuf = Buffer.alloc(buf.length*2);
var idx1 = 0, idx2 = 0;
for (var i = 0; i < buf.length; i++) {
idx1 = buf[i]*2; idx2 = i*2;
newBuf[idx2] = decodeBuf[idx1];
newBuf[idx2+1] = decodeBuf[idx1+1];
}
return newBuf.toString('ucs2');
}
SBCSDecoder.prototype.end = function() {
}
``` | /content/code_sandbox/node_modules/iconv-lite/encodings/sbcs-codec.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 576 |
```javascript
"use strict";
// Manually added data to be used by sbcs codec in addition to generated one.
module.exports = {
// Not supported by iconv, not sure why.
"10029": "maccenteuro",
"maccenteuro": {
"type": "_sbcs",
"chars": ""
},
"808": "cp808",
"ibm808": "cp808",
"cp808": {
"type": "_sbcs",
"chars": ""
},
// Aliases of generated encodings.
"ascii8bit": "ascii",
"usascii": "ascii",
"ansix34": "ascii",
"ansix341968": "ascii",
"ansix341986": "ascii",
"csascii": "ascii",
"cp367": "ascii",
"ibm367": "ascii",
"isoir6": "ascii",
"iso646us": "ascii",
"iso646irv": "ascii",
"us": "ascii",
"latin1": "iso88591",
"latin2": "iso88592",
"latin3": "iso88593",
"latin4": "iso88594",
"latin5": "iso88599",
"latin6": "iso885910",
"latin7": "iso885913",
"latin8": "iso885914",
"latin9": "iso885915",
"latin10": "iso885916",
"csisolatin1": "iso88591",
"csisolatin2": "iso88592",
"csisolatin3": "iso88593",
"csisolatin4": "iso88594",
"csisolatincyrillic": "iso88595",
"csisolatinarabic": "iso88596",
"csisolatingreek" : "iso88597",
"csisolatinhebrew": "iso88598",
"csisolatin5": "iso88599",
"csisolatin6": "iso885910",
"l1": "iso88591",
"l2": "iso88592",
"l3": "iso88593",
"l4": "iso88594",
"l5": "iso88599",
"l6": "iso885910",
"l7": "iso885913",
"l8": "iso885914",
"l9": "iso885915",
"l10": "iso885916",
"isoir14": "iso646jp",
"isoir57": "iso646cn",
"isoir100": "iso88591",
"isoir101": "iso88592",
"isoir109": "iso88593",
"isoir110": "iso88594",
"isoir144": "iso88595",
"isoir127": "iso88596",
"isoir126": "iso88597",
"isoir138": "iso88598",
"isoir148": "iso88599",
"isoir157": "iso885910",
"isoir166": "tis620",
"isoir179": "iso885913",
"isoir199": "iso885914",
"isoir203": "iso885915",
"isoir226": "iso885916",
"cp819": "iso88591",
"ibm819": "iso88591",
"cyrillic": "iso88595",
"arabic": "iso88596",
"arabic8": "iso88596",
"ecma114": "iso88596",
"asmo708": "iso88596",
"greek" : "iso88597",
"greek8" : "iso88597",
"ecma118" : "iso88597",
"elot928" : "iso88597",
"hebrew": "iso88598",
"hebrew8": "iso88598",
"turkish": "iso88599",
"turkish8": "iso88599",
"thai": "iso885911",
"thai8": "iso885911",
"celtic": "iso885914",
"celtic8": "iso885914",
"isoceltic": "iso885914",
"tis6200": "tis620",
"tis62025291": "tis620",
"tis62025330": "tis620",
"10000": "macroman",
"10006": "macgreek",
"10007": "maccyrillic",
"10079": "maciceland",
"10081": "macturkish",
"cspc8codepage437": "cp437",
"cspc775baltic": "cp775",
"cspc850multilingual": "cp850",
"cspcp852": "cp852",
"cspc862latinhebrew": "cp862",
"cpgr": "cp869",
"msee": "cp1250",
"mscyrl": "cp1251",
"msansi": "cp1252",
"msgreek": "cp1253",
"msturk": "cp1254",
"mshebr": "cp1255",
"msarab": "cp1256",
"winbaltrim": "cp1257",
"cp20866": "koi8r",
"20866": "koi8r",
"ibm878": "koi8r",
"cskoi8r": "koi8r",
"cp21866": "koi8u",
"21866": "koi8u",
"ibm1168": "koi8u",
"strk10482002": "rk1048",
"tcvn5712": "tcvn",
"tcvn57121": "tcvn",
"gb198880": "iso646cn",
"cn": "iso646cn",
"csiso14jisc6220ro": "iso646jp",
"jisc62201969ro": "iso646jp",
"jp": "iso646jp",
"cshproman8": "hproman8",
"r8": "hproman8",
"roman8": "hproman8",
"xroman8": "hproman8",
"ibm1051": "hproman8",
"mac": "macintosh",
"csmacintosh": "macintosh",
};
``` | /content/code_sandbox/node_modules/iconv-lite/encodings/sbcs-data.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,462 |
```javascript
'use strict';
/**
* Module dependencies.
*/
var url = require('url');
var LRU = require('lru-cache');
var Agent = require('agent-base');
var inherits = require('util').inherits;
var debug = require('debug')('proxy-agent');
var getProxyForUrl = require('proxy-from-env').getProxyForUrl;
var http = require('http');
var https = require('https');
var PacProxyAgent = require('pac-proxy-agent');
var HttpProxyAgent = require('http-proxy-agent');
var HttpsProxyAgent = require('https-proxy-agent');
var SocksProxyAgent = require('socks-proxy-agent');
/**
* Module exports.
*/
exports = module.exports = ProxyAgent;
/**
* Number of `http.Agent` instances to cache.
*
* This value was arbitrarily chosen... a better
* value could be conceived with some benchmarks.
*/
var cacheSize = 20;
/**
* Cache for `http.Agent` instances.
*/
exports.cache = new LRU(cacheSize);
/**
* Built-in proxy types.
*/
exports.proxies = Object.create(null);
exports.proxies.http = httpOrHttpsProxy;
exports.proxies.https = httpOrHttpsProxy;
exports.proxies.socks = SocksProxyAgent;
exports.proxies.socks4 = SocksProxyAgent;
exports.proxies.socks4a = SocksProxyAgent;
exports.proxies.socks5 = SocksProxyAgent;
exports.proxies.socks5h = SocksProxyAgent;
PacProxyAgent.protocols.forEach(function (protocol) {
exports.proxies['pac+' + protocol] = PacProxyAgent;
});
function httpOrHttps(opts, secureEndpoint) {
if (secureEndpoint) {
// HTTPS
return https.globalAgent;
} else {
// HTTP
return http.globalAgent;
}
}
function httpOrHttpsProxy(opts, secureEndpoint) {
if (secureEndpoint) {
// HTTPS
return new HttpsProxyAgent(opts);
} else {
// HTTP
return new HttpProxyAgent(opts);
}
}
function mapOptsToProxy(opts) {
// NO_PROXY case
if (!opts) {
return {
uri: 'no proxy',
fn: httpOrHttps
};
}
if ('string' == typeof opts) opts = url.parse(opts);
var proxies;
if (opts.proxies) {
proxies = Object.assign({}, exports.proxies, opts.proxies);
} else {
proxies = exports.proxies;
}
// get the requested proxy "protocol"
var protocol = opts.protocol;
if (!protocol) {
throw new TypeError('You must specify a "protocol" for the ' +
'proxy type (' + Object.keys(proxies).join(', ') + ')');
}
// strip the trailing ":" if present
if (':' == protocol[protocol.length - 1]) {
protocol = protocol.substring(0, protocol.length - 1);
}
// get the proxy `http.Agent` creation function
var proxyFn = proxies[protocol];
if ('function' != typeof proxyFn) {
throw new TypeError('unsupported proxy protocol: "' + protocol + '"');
}
// format the proxy info back into a URI, since an opts object
// could have been passed in originally. This generated URI is used
// as part of the "key" for the LRU cache
return {
opts: opts,
uri: url.format({
protocol: protocol + ':',
slashes: true,
auth: opts.auth,
hostname: opts.hostname || opts.host,
port: opts.port
}),
fn: proxyFn,
}
}
/**
* Attempts to get an `http.Agent` instance based off of the given proxy URI
* information, and the `secure` flag.
*
* An LRU cache is used, to prevent unnecessary creation of proxy
* `http.Agent` instances.
*
* @param {String} uri proxy url
* @param {Boolean} secure true if this is for an HTTPS request, false for HTTP
* @return {http.Agent}
* @api public
*/
function ProxyAgent (opts) {
if (!(this instanceof ProxyAgent)) return new ProxyAgent(opts);
debug('creating new ProxyAgent instance: %o', opts);
Agent.call(this);
if (opts) {
var proxy = mapOptsToProxy(opts);
this.proxy = proxy.opts;
this.proxyUri = proxy.uri;
this.proxyFn = proxy.fn;
}
}
inherits(ProxyAgent, Agent);
/**
*
*/
ProxyAgent.prototype.callback = function(req, opts, fn) {
var proxyOpts = this.proxy;
var proxyUri = this.proxyUri;
var proxyFn = this.proxyFn;
// if we did not instantiate with a proxy, set one per request
if (!proxyOpts) {
var urlOpts = getProxyForUrl(opts);
var proxy = mapOptsToProxy(urlOpts, opts);
proxyOpts = proxy.opts;
proxyUri = proxy.uri;
proxyFn = proxy.fn;
}
// create the "key" for the LRU cache
var key = proxyUri;
if (opts.secureEndpoint) key += ' secure';
// attempt to get a cached `http.Agent` instance first
var agent = exports.cache.get(key);
if (!agent) {
// get an `http.Agent` instance from protocol-specific agent function
agent = proxyFn(proxyOpts, opts.secureEndpoint);
if (agent) {
exports.cache.set(key, agent);
}
} else {
debug('cache hit with key: %o', key);
}
if (!proxyOpts) {
agent.addRequest(req, opts);
} else {
// XXX: agent.callback() is an agent-base-ism
agent.callback(req, opts)
.then(function(socket) { fn(null, socket); })
.catch(function(error) { fn(error); });
}
}
``` | /content/code_sandbox/node_modules/proxy-agent/index.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,260 |
```javascript
/**
* Module dependencies.
*/
var fs = require('fs');
var url = require('url');
var http = require('http');
var https = require('https');
var assert = require('assert');
var toBuffer = require('stream-to-buffer');
var Proxy = require('proxy');
var socks = require('socksv5');
var ProxyAgent = require('../');
describe('ProxyAgent', function () {
// target servers
var httpServer, httpPort;
var httpsServer, httpsPort;
// proxy servers
var socksServer, socksPort;
var proxyServer, proxyPort;
var proxyHttpsServer, proxyHttpsPort;
before(function (done) {
// setup target HTTP server
httpServer = http.createServer();
httpServer.listen(function () {
httpPort = httpServer.address().port;
done();
});
});
before(function (done) {
// setup target SSL HTTPS server
var options = {
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
};
httpsServer = https.createServer(options);
httpsServer.listen(function () {
httpsPort = httpsServer.address().port;
done();
});
});
before(function (done) {
// setup SOCKS proxy server
socksServer = socks.createServer(function(info, accept, deny) {
accept();
});
socksServer.listen(function() {
socksPort = socksServer.address().port;
done();
});
socksServer.useAuth(socks.auth.None());
});
before(function (done) {
// setup HTTP proxy server
proxyServer = Proxy();
proxyServer.listen(function () {
proxyPort = proxyServer.address().port;
done();
});
});
before(function (done) {
// setup SSL HTTPS proxy server
var options = {
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
};
proxyHttpsServer = Proxy(https.createServer(options));
proxyHttpsServer.listen(function () {
proxyHttpsPort = proxyHttpsServer.address().port;
done();
});
});
after(function (done) {
//socksServer.once('close', function () { done(); });
socksServer.close();
done();
});
after(function (done) {
//httpServer.once('close', function () { done(); });
httpServer.close();
done();
});
after(function (done) {
//httpsServer.once('close', function () { done(); });
httpsServer.close();
done();
});
after(function (done) {
//proxyServer.once('close', function () { done(); });
proxyServer.close();
done();
});
after(function (done) {
//proxyHttpsServer.once('close', function () { done(); });
proxyHttpsServer.close();
done();
});
it('should export a "function"', function () {
assert.equal('function', typeof ProxyAgent);
});
describe('constructor', function () {
it('should throw a TypeError if no "protocol" is given', function () {
assert.throws(function () {
ProxyAgent({ host: 'foo.com', port: 3128 });
}, function (e) {
return 'TypeError' === e.name &&
/must specify a "protocol"/.test(e.message) &&
/\bhttp\b/.test(e.message) &&
/\bhttps\b/.test(e.message) &&
/\bsocks\b/.test(e.message);
});
});
it('should throw a TypeError for unsupported proxy protocols', function () {
assert.throws(function () {
ProxyAgent('bad://foo.com:8888');
}, function (e) {
return 'TypeError' === e.name &&
/unsupported proxy protocol/.test(e.message);
});
});
});
describe('"http" module', function () {
describe('over "http" proxy', function () {
it('should work', function (done) {
httpServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var uri = 'path_to_url + proxyPort;
var agent = new ProxyAgent(uri);
var opts = url.parse('path_to_url + httpPort + '/test');
opts.agent = agent;
var req = http.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpPort, data.host);
assert('via' in data);
done();
});
});
req.once('error', done);
});
});
describe('over "http" proxy from env', function () {
it('should work', function (done) {
httpServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
process.env.HTTP_PROXY = 'path_to_url + proxyPort;
var agent = new ProxyAgent();
var opts = url.parse('path_to_url + httpPort + '/test');
opts.agent = agent;
var req = http.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpPort, data.host);
assert('via' in data);
done();
});
});
req.once('error', done);
});
});
describe('with no proxy from env', function () {
it('should work', function (done) {
httpServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
process.env.NO_PROXY = '*';
var agent = new ProxyAgent();
var opts = url.parse('path_to_url + httpPort + '/test');
opts.agent = agent;
var req = http.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpPort, data.host);
assert(!('via' in data));
done();
});
});
req.once('error', done);
});
});
describe('over "https" proxy', function () {
it('should work', function (done) {
httpServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var uri = 'path_to_url + proxyHttpsPort;
var proxy = url.parse(uri);
proxy.rejectUnauthorized = false;
var agent = new ProxyAgent(proxy);
var opts = url.parse('path_to_url + httpPort + '/test');
opts.agent = agent;
var req = http.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpPort, data.host);
assert('via' in data);
done();
});
});
req.once('error', done);
});
});
describe('over "socks" proxy', function () {
it('should work', function (done) {
httpServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var uri = 'socks://localhost:' + socksPort;
var agent = new ProxyAgent(uri);
var opts = url.parse('path_to_url + httpPort + '/test');
opts.agent = agent;
var req = http.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpPort, data.host);
done();
});
});
req.once('error', done);
});
});
});
describe('"https" module', function () {
describe('over "http" proxy', function () {
it('should work', function (done) {
httpsServer.once('request', function (req, res) {
res.end(JSON.stringify(req.headers));
});
var uri = 'path_to_url + proxyPort;
var agent = new ProxyAgent(uri);
var opts = url.parse('path_to_url + httpsPort + '/test');
opts.agent = agent;
opts.rejectUnauthorized = false;
var req = https.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpsPort, data.host);
done();
});
});
req.once('error', done);
});
});
describe('over "https" proxy', function () {
it('should work', function (done) {
var gotReq = false;
httpsServer.once('request', function (req, res) {
gotReq = true;
res.end(JSON.stringify(req.headers));
});
var agent = new ProxyAgent({
protocol: 'https:',
host: 'localhost',
port: proxyHttpsPort,
rejectUnauthorized: false
});
var opts = url.parse('path_to_url + httpsPort + '/test');
opts.agent = agent;
opts.rejectUnauthorized = false;
var req = https.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpsPort, data.host);
assert(gotReq);
done();
});
});
req.once('error', done);
});
});
describe('over "socks" proxy', function () {
it('should work', function (done) {
var gotReq = false;
httpsServer.once('request', function (req, res) {
gotReq = true;
res.end(JSON.stringify(req.headers));
});
var uri = 'socks://localhost:' + socksPort;
var agent = new ProxyAgent(uri);
var opts = url.parse('path_to_url + httpsPort + '/test');
opts.agent = agent;
opts.rejectUnauthorized = false;
var req = https.get(opts, function (res) {
toBuffer(res, function (err, buf) {
if (err) return done(err);
var data = JSON.parse(buf.toString('utf8'));
assert.equal('localhost:' + httpsPort, data.host);
assert(gotReq);
done();
});
});
req.once('error', done);
});
});
});
});
``` | /content/code_sandbox/node_modules/proxy-agent/test/test.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 2,338 |
```javascript
// Generated by LiveScript 1.5.0
(function(){
var ref$, id, find, sort, min, max, map, unlines, nameToRaw, dasherize, naturalJoin, wordwrap, getPreText, setHelpStyleDefaults, generateHelpForOption, generateHelp;
ref$ = require('prelude-ls'), id = ref$.id, find = ref$.find, sort = ref$.sort, min = ref$.min, max = ref$.max, map = ref$.map, unlines = ref$.unlines;
ref$ = require('./util'), nameToRaw = ref$.nameToRaw, dasherize = ref$.dasherize, naturalJoin = ref$.naturalJoin;
wordwrap = require('wordwrap');
getPreText = function(option, arg$, maxWidth){
var mainName, shortNames, ref$, longNames, type, description, aliasSeparator, typeSeparator, initialIndent, names, namesString, namesStringLen, typeSeparatorString, typeSeparatorStringLen, wrap;
mainName = option.option, shortNames = (ref$ = option.shortNames) != null
? ref$
: [], longNames = (ref$ = option.longNames) != null
? ref$
: [], type = option.type, description = option.description;
aliasSeparator = arg$.aliasSeparator, typeSeparator = arg$.typeSeparator, initialIndent = arg$.initialIndent;
if (option.negateName) {
mainName = "no-" + mainName;
if (longNames) {
longNames = map(function(it){
return "no-" + it;
}, longNames);
}
}
names = mainName.length === 1
? [mainName].concat(shortNames, longNames)
: shortNames.concat([mainName], longNames);
namesString = map(nameToRaw, names).join(aliasSeparator);
namesStringLen = namesString.length;
typeSeparatorString = mainName === 'NUM' ? '::' : typeSeparator;
typeSeparatorStringLen = typeSeparatorString.length;
if (maxWidth != null && !option.boolean && initialIndent + namesStringLen + typeSeparatorStringLen + type.length > maxWidth) {
wrap = wordwrap(initialIndent + namesStringLen + typeSeparatorStringLen, maxWidth);
return namesString + "" + typeSeparatorString + wrap(type).replace(/^\s+/, '');
} else {
return namesString + "" + (option.boolean
? ''
: typeSeparatorString + "" + type);
}
};
setHelpStyleDefaults = function(helpStyle){
helpStyle.aliasSeparator == null && (helpStyle.aliasSeparator = ', ');
helpStyle.typeSeparator == null && (helpStyle.typeSeparator = ' ');
helpStyle.descriptionSeparator == null && (helpStyle.descriptionSeparator = ' ');
helpStyle.initialIndent == null && (helpStyle.initialIndent = 2);
helpStyle.secondaryIndent == null && (helpStyle.secondaryIndent = 4);
helpStyle.maxPadFactor == null && (helpStyle.maxPadFactor = 1.5);
};
generateHelpForOption = function(getOption, arg$){
var stdout, helpStyle, ref$;
stdout = arg$.stdout, helpStyle = (ref$ = arg$.helpStyle) != null
? ref$
: {};
setHelpStyleDefaults(helpStyle);
return function(optionName){
var maxWidth, wrap, option, e, pre, defaultString, restPositionalString, description, fullDescription, that, preDescription, descriptionString, exampleString, examples, seperator;
maxWidth = stdout != null && stdout.isTTY ? stdout.columns - 1 : null;
wrap = maxWidth ? wordwrap(maxWidth) : id;
try {
option = getOption(dasherize(optionName));
} catch (e$) {
e = e$;
return e.message;
}
pre = getPreText(option, helpStyle);
defaultString = option['default'] && !option.negateName ? "\ndefault: " + option['default'] : '';
restPositionalString = option.restPositional ? 'Everything after this option is considered a positional argument, even if it looks like an option.' : '';
description = option.longDescription || option.description && sentencize(option.description);
fullDescription = description && restPositionalString
? description + " " + restPositionalString
: (that = description || restPositionalString) ? that : '';
preDescription = 'description:';
descriptionString = !fullDescription
? ''
: maxWidth && fullDescription.length - 1 - preDescription.length > maxWidth
? "\n" + preDescription + "\n" + wrap(fullDescription)
: "\n" + preDescription + " " + fullDescription;
exampleString = (that = option.example) ? (examples = [].concat(that), examples.length > 1
? "\nexamples:\n" + unlines(examples)
: "\nexample: " + examples[0]) : '';
seperator = defaultString || descriptionString || exampleString ? "\n" + repeatString$('=', pre.length) : '';
return pre + "" + seperator + defaultString + descriptionString + exampleString;
};
};
generateHelp = function(arg$){
var options, prepend, append, helpStyle, ref$, stdout, aliasSeparator, typeSeparator, descriptionSeparator, maxPadFactor, initialIndent, secondaryIndent;
options = arg$.options, prepend = arg$.prepend, append = arg$.append, helpStyle = (ref$ = arg$.helpStyle) != null
? ref$
: {}, stdout = arg$.stdout;
setHelpStyleDefaults(helpStyle);
aliasSeparator = helpStyle.aliasSeparator, typeSeparator = helpStyle.typeSeparator, descriptionSeparator = helpStyle.descriptionSeparator, maxPadFactor = helpStyle.maxPadFactor, initialIndent = helpStyle.initialIndent, secondaryIndent = helpStyle.secondaryIndent;
return function(arg$){
var ref$, showHidden, interpolate, maxWidth, output, out, data, optionCount, totalPreLen, preLens, i$, len$, item, that, pre, descParts, desc, preLen, sortedPreLens, maxPreLen, preLenMean, x, padAmount, descSepLen, fullWrapCount, partialWrapCount, descLen, totalLen, initialSpace, wrapAllFull, i, wrap;
ref$ = arg$ != null
? arg$
: {}, showHidden = ref$.showHidden, interpolate = ref$.interpolate;
maxWidth = stdout != null && stdout.isTTY ? stdout.columns - 1 : null;
output = [];
out = function(it){
return output.push(it != null ? it : '');
};
if (prepend) {
out(interpolate ? interp(prepend, interpolate) : prepend);
out();
}
data = [];
optionCount = 0;
totalPreLen = 0;
preLens = [];
for (i$ = 0, len$ = (ref$ = options).length; i$ < len$; ++i$) {
item = ref$[i$];
if (showHidden || !item.hidden) {
if (that = item.heading) {
data.push({
type: 'heading',
value: that
});
} else {
pre = getPreText(item, helpStyle, maxWidth);
descParts = [];
if ((that = item.description) != null) {
descParts.push(that);
}
if (that = item['enum']) {
descParts.push("either: " + naturalJoin(that));
}
if (item['default'] && !item.negateName) {
descParts.push("default: " + item['default']);
}
desc = descParts.join(' - ');
data.push({
type: 'option',
pre: pre,
desc: desc,
descLen: desc.length
});
preLen = pre.length;
optionCount++;
totalPreLen += preLen;
preLens.push(preLen);
}
}
}
sortedPreLens = sort(preLens);
maxPreLen = sortedPreLens[sortedPreLens.length - 1];
preLenMean = initialIndent + totalPreLen / optionCount;
x = optionCount > 2 ? min(preLenMean * maxPadFactor, maxPreLen) : maxPreLen;
for (i$ = sortedPreLens.length - 1; i$ >= 0; --i$) {
preLen = sortedPreLens[i$];
if (preLen <= x) {
padAmount = preLen;
break;
}
}
descSepLen = descriptionSeparator.length;
if (maxWidth != null) {
fullWrapCount = 0;
partialWrapCount = 0;
for (i$ = 0, len$ = data.length; i$ < len$; ++i$) {
item = data[i$];
if (item.type === 'option') {
pre = item.pre, desc = item.desc, descLen = item.descLen;
if (descLen === 0) {
item.wrap = 'none';
} else {
preLen = max(padAmount, pre.length) + initialIndent + descSepLen;
totalLen = preLen + descLen;
if (totalLen > maxWidth) {
if (descLen / 2.5 > maxWidth - preLen) {
fullWrapCount++;
item.wrap = 'full';
} else {
partialWrapCount++;
item.wrap = 'partial';
}
} else {
item.wrap = 'none';
}
}
}
}
}
initialSpace = repeatString$(' ', initialIndent);
wrapAllFull = optionCount > 1 && fullWrapCount + partialWrapCount * 0.5 > optionCount * 0.5;
for (i$ = 0, len$ = data.length; i$ < len$; ++i$) {
i = i$;
item = data[i$];
if (item.type === 'heading') {
if (i !== 0) {
out();
}
out(item.value + ":");
} else {
pre = item.pre, desc = item.desc, descLen = item.descLen, wrap = item.wrap;
if (maxWidth != null) {
if (wrapAllFull || wrap === 'full') {
wrap = wordwrap(initialIndent + secondaryIndent, maxWidth);
out(initialSpace + "" + pre + "\n" + wrap(desc));
continue;
} else if (wrap === 'partial') {
wrap = wordwrap(initialIndent + descSepLen + max(padAmount, pre.length), maxWidth);
out(initialSpace + "" + pad(pre, padAmount) + descriptionSeparator + wrap(desc).replace(/^\s+/, ''));
continue;
}
}
if (descLen === 0) {
out(initialSpace + "" + pre);
} else {
out(initialSpace + "" + pad(pre, padAmount) + descriptionSeparator + desc);
}
}
}
if (append) {
out();
out(interpolate ? interp(append, interpolate) : append);
}
return unlines(output);
};
};
function pad(str, num){
var len, padAmount;
len = str.length;
padAmount = num - len;
return str + "" + repeatString$(' ', padAmount > 0 ? padAmount : 0);
}
function sentencize(str){
var first, rest, period;
first = str.charAt(0).toUpperCase();
rest = str.slice(1);
period = /[\.!\?]$/.test(str) ? '' : '.';
return first + "" + rest + period;
}
function interp(string, object){
return string.replace(/{{([a-zA-Z$_][a-zA-Z$_0-9]*)}}/g, function(arg$, key){
var ref$;
return (ref$ = object[key]) != null
? ref$
: "{{" + key + "}}";
});
}
module.exports = {
generateHelp: generateHelp,
generateHelpForOption: generateHelpForOption
};
function repeatString$(str, n){
for (var r = ''; n > 0; (n >>= 1) && (str += str)) if (n & 1) r += str;
return r;
}
}).call(this);
``` | /content/code_sandbox/node_modules/optionator/lib/help.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 2,695 |
```javascript
// Generated by LiveScript 1.5.0
(function(){
var prelude, map, sortBy, fl, closestString, nameToRaw, dasherize, naturalJoin;
prelude = require('prelude-ls'), map = prelude.map, sortBy = prelude.sortBy;
fl = require('fast-levenshtein');
closestString = function(possibilities, input){
var distances, ref$, string, distance, this$ = this;
if (!possibilities.length) {
return;
}
distances = map(function(it){
var ref$, longer, shorter;
ref$ = input.length > it.length
? [input, it]
: [it, input], longer = ref$[0], shorter = ref$[1];
return {
string: it,
distance: fl.get(longer, shorter)
};
})(
possibilities);
ref$ = sortBy(function(it){
return it.distance;
}, distances)[0], string = ref$.string, distance = ref$.distance;
return string;
};
nameToRaw = function(name){
if (name.length === 1 || name === 'NUM') {
return "-" + name;
} else {
return "--" + name;
}
};
dasherize = function(string){
if (/^[A-Z]/.test(string)) {
return string;
} else {
return prelude.dasherize(string);
}
};
naturalJoin = function(array){
if (array.length < 3) {
return array.join(' or ');
} else {
return array.slice(0, -1).join(', ') + ", or " + array[array.length - 1];
}
};
module.exports = {
closestString: closestString,
nameToRaw: nameToRaw,
dasherize: dasherize,
naturalJoin: naturalJoin
};
}).call(this);
``` | /content/code_sandbox/node_modules/optionator/lib/util.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 416 |
```yaml
repo_token: SIAeZjKYlHK74rbcFvNHMUzjRiMpflxve
``` | /content/code_sandbox/node_modules/debug/.coveralls.yml | yaml | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 28 |
```javascript
// Karma configuration
// Generated on Fri Dec 16 2016 13:09:51 GMT+0000 (UTC)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: path_to_url
frameworks: ['mocha', 'chai', 'sinon'],
// list of files / patterns to load in the browser
files: [
'dist/debug.js',
'test/*spec.js'
],
// list of files to exclude
exclude: [
'src/node.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: path_to_url
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: path_to_url
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: path_to_url
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
``` | /content/code_sandbox/node_modules/debug/karma.conf.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 381 |
```javascript
module.exports = require('./src/node');
``` | /content/code_sandbox/node_modules/debug/node.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 9 |
```javascript
/**
* Detect Electron renderer process, which is node, but we should
* treat as a browser.
*/
if (typeof process !== 'undefined' && process.type === 'renderer') {
module.exports = require('./browser.js');
} else {
module.exports = require('./node.js');
}
``` | /content/code_sandbox/node_modules/debug/src/index.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 61 |
```javascript
/**
* Module dependencies.
*/
var tty = require('tty');
var util = require('util');
/**
* This is the Node.js implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = require('./debug');
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
/**
* Colors.
*/
exports.colors = [6, 2, 3, 4, 5, 1];
/**
* Build up the default `inspectOpts` object from the environment variables.
*
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
*/
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
return /^debug_/i.test(key);
}).reduce(function (obj, key) {
// camel-case
var prop = key
.substring(6)
.toLowerCase()
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
// coerce string value into JS value
var val = process.env[key];
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
else if (val === 'null') val = null;
else val = Number(val);
obj[prop] = val;
return obj;
}, {});
/**
* The file descriptor to write the `debug()` calls to.
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
*
* $ DEBUG_FD=3 node script.js 3>debug.log
*/
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
if (1 !== fd && 2 !== fd) {
util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (path_to_url
}
var stream = 1 === fd ? process.stdout :
2 === fd ? process.stderr :
createWritableStdioStream(fd);
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
return 'colors' in exports.inspectOpts
? Boolean(exports.inspectOpts.colors)
: tty.isatty(fd);
}
/**
* Map %o to `util.inspect()`, all on a single line.
*/
exports.formatters.o = function(v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts)
.split('\n').map(function(str) {
return str.trim()
}).join(' ');
};
/**
* Map %o to `util.inspect()`, allowing multiple lines if needed.
*/
exports.formatters.O = function(v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts);
};
/**
* Adds ANSI color escape codes if enabled.
*
* @api public
*/
function formatArgs(args) {
var name = this.namespace;
var useColors = this.useColors;
if (useColors) {
var c = this.color;
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
} else {
args[0] = new Date().toUTCString()
+ ' ' + name + ' ' + args[0];
}
}
/**
* Invokes `util.format()` with the specified arguments and writes to `stream`.
*/
function log() {
return stream.write(util.format.apply(util, arguments) + '\n');
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
if (null == namespaces) {
// If you set a process.env field to null or undefined, it gets cast to the
// string 'null' or 'undefined'. Just delete instead.
delete process.env.DEBUG;
} else {
process.env.DEBUG = namespaces;
}
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
return process.env.DEBUG;
}
/**
* Copied from `node/src/node.js`.
*
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
*/
function createWritableStdioStream (fd) {
var stream;
var tty_wrap = process.binding('tty_wrap');
// Note stream._type is used for test-module-load-list.js
switch (tty_wrap.guessHandleType(fd)) {
case 'TTY':
stream = new tty.WriteStream(fd);
stream._type = 'tty';
// Hack to have stream not keep the event loop alive.
// See path_to_url
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
case 'FILE':
var fs = require('fs');
stream = new fs.SyncWriteStream(fd, { autoClose: false });
stream._type = 'fs';
break;
case 'PIPE':
case 'TCP':
var net = require('net');
stream = new net.Socket({
fd: fd,
readable: false,
writable: true
});
// FIXME Should probably have an option in net.Socket to create a
// stream from an existing fd which is writable only. But for now
// we'll just add this hack and set the `readable` member to false.
// Test: ./node test/fixtures/echo.js < /etc/passwd
stream.readable = false;
stream.read = null;
stream._type = 'pipe';
// FIXME Hack to have stream not keep the event loop alive.
// See path_to_url
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
default:
// Probably an error on in uv_guess_handle()
throw new Error('Implement me. Unknown stream file type!');
}
// For supporting legacy API we put the FD here.
stream.fd = fd;
stream._isStdio = true;
return stream;
}
/**
* Init logic for `debug` instances.
*
* Create a new `inspectOpts` object in case `useColors` is set
* differently for a particular `debug` instance.
*/
function init (debug) {
debug.inspectOpts = {};
var keys = Object.keys(exports.inspectOpts);
for (var i = 0; i < keys.length; i++) {
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
}
}
/**
* Enable namespaces listed in `process.env.DEBUG` initially.
*/
exports.enable(load());
``` | /content/code_sandbox/node_modules/debug/src/node.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,546 |
```javascript
module.exports = inspectorLog;
// black hole
const nullStream = new (require('stream').Writable)();
nullStream._write = () => {};
/**
* Outputs a `console.log()` to the Node.js Inspector console *only*.
*/
function inspectorLog() {
const stdout = console._stdout;
console._stdout = nullStream;
console.log.apply(console, arguments);
console._stdout = stdout;
}
``` | /content/code_sandbox/node_modules/debug/src/inspector-log.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 87 |
```javascript
// Generated by LiveScript 1.5.0
(function(){
var VERSION, ref$, id, map, compact, any, groupBy, partition, chars, isItNaN, keys, Obj, camelize, deepIs, closestString, nameToRaw, dasherize, naturalJoin, generateHelp, generateHelpForOption, parsedTypeCheck, parseType, parseLevn, camelizeKeys, parseString, main, toString$ = {}.toString, slice$ = [].slice;
VERSION = '0.8.2';
ref$ = require('prelude-ls'), id = ref$.id, map = ref$.map, compact = ref$.compact, any = ref$.any, groupBy = ref$.groupBy, partition = ref$.partition, chars = ref$.chars, isItNaN = ref$.isItNaN, keys = ref$.keys, Obj = ref$.Obj, camelize = ref$.camelize;
deepIs = require('deep-is');
ref$ = require('./util'), closestString = ref$.closestString, nameToRaw = ref$.nameToRaw, dasherize = ref$.dasherize, naturalJoin = ref$.naturalJoin;
ref$ = require('./help'), generateHelp = ref$.generateHelp, generateHelpForOption = ref$.generateHelpForOption;
ref$ = require('type-check'), parsedTypeCheck = ref$.parsedTypeCheck, parseType = ref$.parseType;
parseLevn = require('levn').parsedTypeParse;
camelizeKeys = function(obj){
var key, value, resultObj$ = {};
for (key in obj) {
value = obj[key];
resultObj$[camelize(key)] = value;
}
return resultObj$;
};
parseString = function(string){
var assignOpt, regex, replaceRegex, result, this$ = this;
assignOpt = '--?[a-zA-Z][-a-z-A-Z0-9]*=';
regex = RegExp('(?:' + assignOpt + ')?(?:\'(?:\\\\\'|[^\'])+\'|"(?:\\\\"|[^"])+")|[^\'"\\s]+', 'g');
replaceRegex = RegExp('^(' + assignOpt + ')?[\'"]([\\s\\S]*)[\'"]$');
result = map(function(it){
return it.replace(replaceRegex, '$1$2');
}, string.match(regex) || []);
return result;
};
main = function(libOptions){
var opts, defaults, required, traverse, getOption, parse;
opts = {};
defaults = {};
required = [];
if (toString$.call(libOptions.stdout).slice(8, -1) === 'Undefined') {
libOptions.stdout = process.stdout;
}
libOptions.positionalAnywhere == null && (libOptions.positionalAnywhere = true);
libOptions.typeAliases == null && (libOptions.typeAliases = {});
libOptions.defaults == null && (libOptions.defaults = {});
if (libOptions.concatRepeatedArrays != null) {
libOptions.defaults.concatRepeatedArrays = libOptions.concatRepeatedArrays;
}
if (libOptions.mergeRepeatedObjects != null) {
libOptions.defaults.mergeRepeatedObjects = libOptions.mergeRepeatedObjects;
}
traverse = function(options){
var i$, len$, option, name, k, ref$, v, type, that, e, parsedPossibilities, parsedType, j$, len1$, possibility, rawDependsType, dependsOpts, dependsType, cra, alias, shortNames, longNames, this$ = this;
if (toString$.call(options).slice(8, -1) !== 'Array') {
throw new Error('No options defined.');
}
for (i$ = 0, len$ = options.length; i$ < len$; ++i$) {
option = options[i$];
if (option.heading == null) {
name = option.option;
if (opts[name] != null) {
throw new Error("Option '" + name + "' already defined.");
}
for (k in ref$ = libOptions.defaults) {
v = ref$[k];
option[k] == null && (option[k] = v);
}
if (option.type === 'Boolean') {
option.boolean == null && (option.boolean = true);
}
if (option.parsedType == null) {
if (!option.type) {
throw new Error("No type defined for option '" + name + "'.");
}
try {
type = (that = libOptions.typeAliases[option.type]) != null
? that
: option.type;
option.parsedType = parseType(type);
} catch (e$) {
e = e$;
throw new Error("Option '" + name + "': Error parsing type '" + option.type + "': " + e.message);
}
}
if (option['default']) {
try {
defaults[name] = parseLevn(option.parsedType, option['default']);
} catch (e$) {
e = e$;
throw new Error("Option '" + name + "': Error parsing default value '" + option['default'] + "' for type '" + option.type + "': " + e.message);
}
}
if (option['enum'] && !option.parsedPossiblities) {
parsedPossibilities = [];
parsedType = option.parsedType;
for (j$ = 0, len1$ = (ref$ = option['enum']).length; j$ < len1$; ++j$) {
possibility = ref$[j$];
try {
parsedPossibilities.push(parseLevn(parsedType, possibility));
} catch (e$) {
e = e$;
throw new Error("Option '" + name + "': Error parsing enum value '" + possibility + "' for type '" + option.type + "': " + e.message);
}
}
option.parsedPossibilities = parsedPossibilities;
}
if (that = option.dependsOn) {
if (that.length) {
ref$ = [].concat(option.dependsOn), rawDependsType = ref$[0], dependsOpts = slice$.call(ref$, 1);
dependsType = rawDependsType.toLowerCase();
if (dependsOpts.length) {
if (dependsType === 'and' || dependsType === 'or') {
option.dependsOn = [dependsType].concat(slice$.call(dependsOpts));
} else {
throw new Error("Option '" + name + "': If you have more than one dependency, you must specify either 'and' or 'or'");
}
} else {
if ((ref$ = dependsType.toLowerCase()) === 'and' || ref$ === 'or') {
option.dependsOn = null;
} else {
option.dependsOn = ['and', rawDependsType];
}
}
} else {
option.dependsOn = null;
}
}
if (option.required) {
required.push(name);
}
opts[name] = option;
if (option.concatRepeatedArrays != null) {
cra = option.concatRepeatedArrays;
if ('Boolean' === toString$.call(cra).slice(8, -1)) {
option.concatRepeatedArrays = [cra, {}];
} else if (cra.length === 1) {
option.concatRepeatedArrays = [cra[0], {}];
} else if (cra.length !== 2) {
throw new Error("Invalid setting for concatRepeatedArrays");
}
}
if (option.alias || option.aliases) {
if (name === 'NUM') {
throw new Error("-NUM option can't have aliases.");
}
if (option.alias) {
option.aliases == null && (option.aliases = [].concat(option.alias));
}
for (j$ = 0, len1$ = (ref$ = option.aliases).length; j$ < len1$; ++j$) {
alias = ref$[j$];
if (opts[alias] != null) {
throw new Error("Option '" + alias + "' already defined.");
}
opts[alias] = option;
}
ref$ = partition(fn$, option.aliases), shortNames = ref$[0], longNames = ref$[1];
option.shortNames == null && (option.shortNames = shortNames);
option.longNames == null && (option.longNames = longNames);
}
if ((!option.aliases || option.shortNames.length === 0) && option.type === 'Boolean' && option['default'] === 'true') {
option.negateName = true;
}
}
}
function fn$(it){
return it.length === 1;
}
};
traverse(libOptions.options);
getOption = function(name){
var opt, possiblyMeant;
opt = opts[name];
if (opt == null) {
possiblyMeant = closestString(keys(opts), name);
throw new Error("Invalid option '" + nameToRaw(name) + "'" + (possiblyMeant ? " - perhaps you meant '" + nameToRaw(possiblyMeant) + "'?" : '.'));
}
return opt;
};
parse = function(input, arg$){
var slice, obj, positional, restPositional, overrideRequired, prop, setValue, setDefaults, checkRequired, mutuallyExclusiveError, checkMutuallyExclusive, checkDependency, checkDependencies, checkProp, args, key, value, option, ref$, i$, len$, arg, that, result, short, argName, usingAssign, val, flags, len, j$, len1$, i, flag, opt, name, valPrime, negated, noedName;
slice = (arg$ != null
? arg$
: {}).slice;
obj = {};
positional = [];
restPositional = false;
overrideRequired = false;
prop = null;
setValue = function(name, value){
var opt, val, cra, e, currentType;
opt = getOption(name);
if (opt.boolean) {
val = value;
} else {
try {
cra = opt.concatRepeatedArrays;
if (cra != null && cra[0] && cra[1].oneValuePerFlag && opt.parsedType.length === 1 && opt.parsedType[0].structure === 'array') {
val = [parseLevn(opt.parsedType[0].of, value)];
} else {
val = parseLevn(opt.parsedType, value);
}
} catch (e$) {
e = e$;
throw new Error("Invalid value for option '" + name + "' - expected type " + opt.type + ", received value: " + value + ".");
}
if (opt['enum'] && !any(function(it){
return deepIs(it, val);
}, opt.parsedPossibilities)) {
throw new Error("Option " + name + ": '" + val + "' not one of " + naturalJoin(opt['enum']) + ".");
}
}
currentType = toString$.call(obj[name]).slice(8, -1);
if (obj[name] != null) {
if (opt.concatRepeatedArrays != null && opt.concatRepeatedArrays[0] && currentType === 'Array') {
obj[name] = obj[name].concat(val);
} else if (opt.mergeRepeatedObjects && currentType === 'Object') {
import$(obj[name], val);
} else {
obj[name] = val;
}
} else {
obj[name] = val;
}
if (opt.restPositional) {
restPositional = true;
}
if (opt.overrideRequired) {
overrideRequired = true;
}
};
setDefaults = function(){
var name, ref$, value;
for (name in ref$ = defaults) {
value = ref$[name];
if (obj[name] == null) {
obj[name] = value;
}
}
};
checkRequired = function(){
var i$, ref$, len$, name;
if (overrideRequired) {
return;
}
for (i$ = 0, len$ = (ref$ = required).length; i$ < len$; ++i$) {
name = ref$[i$];
if (!obj[name]) {
throw new Error("Option " + nameToRaw(name) + " is required.");
}
}
};
mutuallyExclusiveError = function(first, second){
throw new Error("The options " + nameToRaw(first) + " and " + nameToRaw(second) + " are mutually exclusive - you cannot use them at the same time.");
};
checkMutuallyExclusive = function(){
var rules, i$, len$, rule, present, j$, len1$, element, k$, len2$, opt;
rules = libOptions.mutuallyExclusive;
if (!rules) {
return;
}
for (i$ = 0, len$ = rules.length; i$ < len$; ++i$) {
rule = rules[i$];
present = null;
for (j$ = 0, len1$ = rule.length; j$ < len1$; ++j$) {
element = rule[j$];
if (toString$.call(element).slice(8, -1) === 'Array') {
for (k$ = 0, len2$ = element.length; k$ < len2$; ++k$) {
opt = element[k$];
if (opt in obj) {
if (present != null) {
mutuallyExclusiveError(present, opt);
} else {
present = opt;
break;
}
}
}
} else {
if (element in obj) {
if (present != null) {
mutuallyExclusiveError(present, element);
} else {
present = element;
}
}
}
}
}
};
checkDependency = function(option){
var dependsOn, type, targetOptionNames, i$, len$, targetOptionName, targetOption;
dependsOn = option.dependsOn;
if (!dependsOn || option.dependenciesMet) {
return true;
}
type = dependsOn[0], targetOptionNames = slice$.call(dependsOn, 1);
for (i$ = 0, len$ = targetOptionNames.length; i$ < len$; ++i$) {
targetOptionName = targetOptionNames[i$];
targetOption = obj[targetOptionName];
if (targetOption && checkDependency(targetOption)) {
if (type === 'or') {
return true;
}
} else if (type === 'and') {
throw new Error("The option '" + option.option + "' did not have its dependencies met.");
}
}
if (type === 'and') {
return true;
} else {
throw new Error("The option '" + option.option + "' did not meet any of its dependencies.");
}
};
checkDependencies = function(){
var name;
for (name in obj) {
checkDependency(opts[name]);
}
};
checkProp = function(){
if (prop) {
throw new Error("Value for '" + prop + "' of type '" + getOption(prop).type + "' required.");
}
};
switch (toString$.call(input).slice(8, -1)) {
case 'String':
args = parseString(input.slice(slice != null ? slice : 0));
break;
case 'Array':
args = input.slice(slice != null ? slice : 2);
break;
case 'Object':
obj = {};
for (key in input) {
value = input[key];
if (key !== '_') {
option = getOption(dasherize(key));
if (parsedTypeCheck(option.parsedType, value)) {
obj[option.option] = value;
} else {
throw new Error("Option '" + option.option + "': Invalid type for '" + value + "' - expected type '" + option.type + "'.");
}
}
}
checkMutuallyExclusive();
checkDependencies();
setDefaults();
checkRequired();
return ref$ = camelizeKeys(obj), ref$._ = input._ || [], ref$;
default:
throw new Error("Invalid argument to 'parse': " + input + ".");
}
for (i$ = 0, len$ = args.length; i$ < len$; ++i$) {
arg = args[i$];
if (arg === '--') {
restPositional = true;
} else if (restPositional) {
positional.push(arg);
} else {
if (that = arg.match(/^(--?)([a-zA-Z][-a-zA-Z0-9]*)(=)?(.*)?$/)) {
result = that;
checkProp();
short = result[1].length === 1;
argName = result[2];
usingAssign = result[3] != null;
val = result[4];
if (usingAssign && val == null) {
throw new Error("No value for '" + argName + "' specified.");
}
if (short) {
flags = chars(argName);
len = flags.length;
for (j$ = 0, len1$ = flags.length; j$ < len1$; ++j$) {
i = j$;
flag = flags[j$];
opt = getOption(flag);
name = opt.option;
if (restPositional) {
positional.push(flag);
} else if (i === len - 1) {
if (usingAssign) {
valPrime = opt.boolean ? parseLevn([{
type: 'Boolean'
}], val) : val;
setValue(name, valPrime);
} else if (opt.boolean) {
setValue(name, true);
} else {
prop = name;
}
} else if (opt.boolean) {
setValue(name, true);
} else {
throw new Error("Can't set argument '" + flag + "' when not last flag in a group of short flags.");
}
}
} else {
negated = false;
if (that = argName.match(/^no-(.+)$/)) {
negated = true;
noedName = that[1];
opt = getOption(noedName);
} else {
opt = getOption(argName);
}
name = opt.option;
if (opt.boolean) {
valPrime = usingAssign ? parseLevn([{
type: 'Boolean'
}], val) : true;
if (negated) {
setValue(name, !valPrime);
} else {
setValue(name, valPrime);
}
} else {
if (negated) {
throw new Error("Only use 'no-' prefix for Boolean options, not with '" + noedName + "'.");
}
if (usingAssign) {
setValue(name, val);
} else {
prop = name;
}
}
}
} else if (that = arg.match(/^-([0-9]+(?:\.[0-9]+)?)$/)) {
opt = opts.NUM;
if (!opt) {
throw new Error('No -NUM option defined.');
}
setValue(opt.option, that[1]);
} else {
if (prop) {
setValue(prop, arg);
prop = null;
} else {
positional.push(arg);
if (!libOptions.positionalAnywhere) {
restPositional = true;
}
}
}
}
}
checkProp();
checkMutuallyExclusive();
checkDependencies();
setDefaults();
checkRequired();
return ref$ = camelizeKeys(obj), ref$._ = positional, ref$;
};
return {
parse: parse,
parseArgv: function(it){
return parse(it, {
slice: 2
});
},
generateHelp: generateHelp(libOptions),
generateHelpForOption: generateHelpForOption(getOption, libOptions)
};
};
main.VERSION = VERSION;
module.exports = main;
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
}).call(this);
``` | /content/code_sandbox/node_modules/optionator/lib/index.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 4,416 |
```javascript
/**
* This is the web browser implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = require('./debug');
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = 'undefined' != typeof chrome
&& 'undefined' != typeof chrome.storage
? chrome.storage.local
: localstorage();
/**
* Colors.
*/
exports.colors = [
'lightseagreen',
'forestgreen',
'goldenrod',
'dodgerblue',
'darkorchid',
'crimson'
];
/**
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
* and the Firebug extension (any Firefox version) are known
* to support "%c" CSS customizations.
*
* TODO: add a `localStorage` variable to explicitly enable/disable colors
*/
function useColors() {
// NB: In an Electron preload script, document will be defined but not fully
// initialized. Since we know we're in Chrome, we'll just detect this case
// explicitly
if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
return true;
}
// is webkit? path_to_url
// document is undefined in react-native: path_to_url
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
// is firebug? path_to_url
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
// is firefox >= v31?
// path_to_url#Styling_messages
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
// double check webkit in userAgent just in case we are in a worker
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
}
/**
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
*/
exports.formatters.j = function(v) {
try {
return JSON.stringify(v);
} catch (err) {
return '[UnexpectedJSONParseError]: ' + err.message;
}
};
/**
* Colorize log arguments if enabled.
*
* @api public
*/
function formatArgs(args) {
var useColors = this.useColors;
args[0] = (useColors ? '%c' : '')
+ this.namespace
+ (useColors ? ' %c' : ' ')
+ args[0]
+ (useColors ? '%c ' : ' ')
+ '+' + exports.humanize(this.diff);
if (!useColors) return;
var c = 'color: ' + this.color;
args.splice(1, 0, c, 'color: inherit')
// the final "%c" is somewhat tricky, because there could be other
// arguments passed either before or after the %c, so we need to
// figure out the correct index to insert the CSS into
var index = 0;
var lastC = 0;
args[0].replace(/%[a-zA-Z%]/g, function(match) {
if ('%%' === match) return;
index++;
if ('%c' === match) {
// we only are interested in the *last* %c
// (the user may have provided their own)
lastC = index;
}
});
args.splice(lastC, 0, c);
}
/**
* Invokes `console.log()` when available.
* No-op when `console.log` is not a "function".
*
* @api public
*/
function log() {
// this hackery is required for IE8/9, where
// the `console.log` function doesn't have 'apply'
return 'object' === typeof console
&& console.log
&& Function.prototype.apply.call(console.log, console, arguments);
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
try {
if (null == namespaces) {
exports.storage.removeItem('debug');
} else {
exports.storage.debug = namespaces;
}
} catch(e) {}
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
var r;
try {
r = exports.storage.debug;
} catch(e) {}
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
if (!r && typeof process !== 'undefined' && 'env' in process) {
r = process.env.DEBUG;
}
return r;
}
/**
* Enable namespaces listed in `localStorage.debug` initially.
*/
exports.enable(load());
/**
* Localstorage attempts to return the localstorage.
*
* This is necessary because safari throws
* when a user disables cookies/localstorage
* and you attempt to access it.
*
* @return {LocalStorage}
* @api private
*/
function localstorage() {
try {
return window.localStorage;
} catch (e) {}
}
``` | /content/code_sandbox/node_modules/debug/src/browser.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,155 |
```javascript
/**
* This is the common logic for both the Node.js and web browser
* implementations of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
exports.coerce = coerce;
exports.disable = disable;
exports.enable = enable;
exports.enabled = enabled;
exports.humanize = require('ms');
/**
* The currently active debug mode names, and names to skip.
*/
exports.names = [];
exports.skips = [];
/**
* Map of special "%n" handling functions, for the debug "format" argument.
*
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
*/
exports.formatters = {};
/**
* Previous log timestamp.
*/
var prevTime;
/**
* Select a color.
* @param {String} namespace
* @return {Number}
* @api private
*/
function selectColor(namespace) {
var hash = 0, i;
for (i in namespace) {
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
hash |= 0; // Convert to 32bit integer
}
return exports.colors[Math.abs(hash) % exports.colors.length];
}
/**
* Create a debugger with the given `namespace`.
*
* @param {String} namespace
* @return {Function}
* @api public
*/
function createDebug(namespace) {
function debug() {
// disabled?
if (!debug.enabled) return;
var self = debug;
// set `diff` timestamp
var curr = +new Date();
var ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
// turn the `arguments` into a proper Array
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
args[0] = exports.coerce(args[0]);
if ('string' !== typeof args[0]) {
// anything else let's inspect with %O
args.unshift('%O');
}
// apply any `formatters` transformations
var index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
// if we encounter an escaped % then don't increase the array index
if (match === '%%') return match;
index++;
var formatter = exports.formatters[format];
if ('function' === typeof formatter) {
var val = args[index];
match = formatter.call(self, val);
// now we need to remove `args[index]` since it's inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
// apply env-specific formatting (colors, etc.)
exports.formatArgs.call(self, args);
var logFn = debug.log || exports.log || console.log.bind(console);
logFn.apply(self, args);
}
debug.namespace = namespace;
debug.enabled = exports.enabled(namespace);
debug.useColors = exports.useColors();
debug.color = selectColor(namespace);
// env-specific initialization logic for debug instances
if ('function' === typeof exports.init) {
exports.init(debug);
}
return debug;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*
* @param {String} namespaces
* @api public
*/
function enable(namespaces) {
exports.save(namespaces);
exports.names = [];
exports.skips = [];
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
var len = split.length;
for (var i = 0; i < len; i++) {
if (!split[i]) continue; // ignore empty strings
namespaces = split[i].replace(/\*/g, '.*?');
if (namespaces[0] === '-') {
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
} else {
exports.names.push(new RegExp('^' + namespaces + '$'));
}
}
}
/**
* Disable debug output.
*
* @api public
*/
function disable() {
exports.enable('');
}
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
function enabled(name) {
var i, len;
for (i = 0, len = exports.skips.length; i < len; i++) {
if (exports.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = exports.names.length; i < len; i++) {
if (exports.names[i].test(name)) {
return true;
}
}
return false;
}
/**
* Coerce `val`.
*
* @param {Mixed} val
* @return {Mixed}
* @api private
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
``` | /content/code_sandbox/node_modules/debug/src/debug.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,128 |
```yaml
environment:
matrix:
- nodejs_version: "4"
- nodejs_version: "5"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"
- nodejs_version: "" # latest
install:
- ps: "Install-Product node $env:nodejs_version"
- "npm install"
test_script:
- "node --version"
- "npm --version"
- "npm test"
build: off
``` | /content/code_sandbox/node_modules/xmlbuilder/appveyor.yml | yaml | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 112 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = {
None: 0,
OpenTag: 1,
InsideTag: 2,
CloseTag: 3
};
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/WriterState.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 54 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDummy, XMLNode,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
module.exports = XMLDummy = (function(superClass) {
extend(XMLDummy, superClass);
function XMLDummy(parent) {
XMLDummy.__super__.constructor.call(this, parent);
this.type = NodeType.Dummy;
}
XMLDummy.prototype.clone = function() {
return Object.create(this);
};
XMLDummy.prototype.toString = function(options) {
return '';
};
return XMLDummy;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDummy.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 213 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = {
Element: 1,
Attribute: 2,
Text: 3,
CData: 4,
EntityReference: 5,
EntityDeclaration: 6,
ProcessingInstruction: 7,
Comment: 8,
Document: 9,
DocType: 10,
DocumentFragment: 11,
NotationDeclaration: 12,
Declaration: 201,
Raw: 202,
AttributeDeclaration: 203,
ElementDeclaration: 204,
Dummy: 205
};
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/NodeType.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 139 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = {
Disconnected: 1,
Preceding: 2,
Following: 4,
Contains: 8,
ContainedBy: 16,
ImplementationSpecific: 32
};
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/DocumentPosition.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 69 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLDOMImplementation;
module.exports = XMLDOMImplementation = (function() {
function XMLDOMImplementation() {}
XMLDOMImplementation.prototype.hasFeature = function(feature, version) {
return true;
};
XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) {
throw new Error("This DOM method is not implemented.");
};
XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) {
throw new Error("This DOM method is not implemented.");
};
XMLDOMImplementation.prototype.createHTMLDocument = function(title) {
throw new Error("This DOM method is not implemented.");
};
XMLDOMImplementation.prototype.getFeature = function(feature, version) {
throw new Error("This DOM method is not implemented.");
};
return XMLDOMImplementation;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDOMImplementation.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 197 |
```javascript
'use strict'
const EE = require('events')
const Yallist = require('yallist')
const SD = require('string_decoder').StringDecoder
const EOF = Symbol('EOF')
const MAYBE_EMIT_END = Symbol('maybeEmitEnd')
const EMITTED_END = Symbol('emittedEnd')
const EMITTING_END = Symbol('emittingEnd')
const CLOSED = Symbol('closed')
const READ = Symbol('read')
const FLUSH = Symbol('flush')
const FLUSHCHUNK = Symbol('flushChunk')
const ENCODING = Symbol('encoding')
const DECODER = Symbol('decoder')
const FLOWING = Symbol('flowing')
const PAUSED = Symbol('paused')
const RESUME = Symbol('resume')
const BUFFERLENGTH = Symbol('bufferLength')
const BUFFERPUSH = Symbol('bufferPush')
const BUFFERSHIFT = Symbol('bufferShift')
const OBJECTMODE = Symbol('objectMode')
const DESTROYED = Symbol('destroyed')
// TODO remove when Node v8 support drops
const doIter = global._MP_NO_ITERATOR_SYMBOLS_ !== '1'
const ASYNCITERATOR = doIter && Symbol.asyncIterator
|| Symbol('asyncIterator not implemented')
const ITERATOR = doIter && Symbol.iterator
|| Symbol('iterator not implemented')
// Buffer in node 4.x < 4.5.0 doesn't have working Buffer.from
// or Buffer.alloc, and Buffer in node 10 deprecated the ctor.
// .M, this is fine .\^/M..
const B = Buffer.alloc ? Buffer
: /* istanbul ignore next */ require('safe-buffer').Buffer
// events that mean 'the stream is over'
// these are treated specially, and re-emitted
// if they are listened for after emitting.
const isEndish = ev =>
ev === 'end' ||
ev === 'finish' ||
ev === 'prefinish'
const isArrayBuffer = b => b instanceof ArrayBuffer ||
typeof b === 'object' &&
b.constructor &&
b.constructor.name === 'ArrayBuffer' &&
b.byteLength >= 0
const isArrayBufferView = b => !B.isBuffer(b) && ArrayBuffer.isView(b)
module.exports = class Minipass extends EE {
constructor (options) {
super()
this[FLOWING] = false
// whether we're explicitly paused
this[PAUSED] = false
this.pipes = new Yallist()
this.buffer = new Yallist()
this[OBJECTMODE] = options && options.objectMode || false
if (this[OBJECTMODE])
this[ENCODING] = null
else
this[ENCODING] = options && options.encoding || null
if (this[ENCODING] === 'buffer')
this[ENCODING] = null
this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null
this[EOF] = false
this[EMITTED_END] = false
this[EMITTING_END] = false
this[CLOSED] = false
this.writable = true
this.readable = true
this[BUFFERLENGTH] = 0
this[DESTROYED] = false
}
get bufferLength () { return this[BUFFERLENGTH] }
get encoding () { return this[ENCODING] }
set encoding (enc) {
if (this[OBJECTMODE])
throw new Error('cannot set encoding in objectMode')
if (this[ENCODING] && enc !== this[ENCODING] &&
(this[DECODER] && this[DECODER].lastNeed || this[BUFFERLENGTH]))
throw new Error('cannot change encoding')
if (this[ENCODING] !== enc) {
this[DECODER] = enc ? new SD(enc) : null
if (this.buffer.length)
this.buffer = this.buffer.map(chunk => this[DECODER].write(chunk))
}
this[ENCODING] = enc
}
setEncoding (enc) {
this.encoding = enc
}
get objectMode () { return this[OBJECTMODE] }
set objectMode ( ) { this[OBJECTMODE] = this[OBJECTMODE] || !! }
write (chunk, encoding, cb) {
if (this[EOF])
throw new Error('write after end')
if (this[DESTROYED]) {
this.emit('error', Object.assign(
new Error('Cannot call write after a stream was destroyed'),
{ code: 'ERR_STREAM_DESTROYED' }
))
return true
}
if (typeof encoding === 'function')
cb = encoding, encoding = 'utf8'
if (!encoding)
encoding = 'utf8'
// convert array buffers and typed array views into buffers
// at some point in the future, we may want to do the opposite!
// leave strings and buffers as-is
// anything else switches us into object mode
if (!this[OBJECTMODE] && !B.isBuffer(chunk)) {
if (isArrayBufferView(chunk))
chunk = B.from(chunk.buffer, chunk.byteOffset, chunk.byteLength)
else if (isArrayBuffer(chunk))
chunk = B.from(chunk)
else if (typeof chunk !== 'string')
// use the setter so we throw if we have encoding set
this.objectMode = true
}
// this ensures at this point that the chunk is a buffer or string
// don't buffer it up or send it to the decoder
if (!this.objectMode && !chunk.length) {
const ret = this.flowing
if (this[BUFFERLENGTH] !== 0)
this.emit('readable')
if (cb)
cb()
return ret
}
// fast-path writing strings of same encoding to a stream with
// an empty buffer, skipping the buffer/decoder dance
if (typeof chunk === 'string' && !this[OBJECTMODE] &&
// unless it is a string already ready for us to use
!(encoding === this[ENCODING] && !this[DECODER].lastNeed)) {
chunk = B.from(chunk, encoding)
}
if (B.isBuffer(chunk) && this[ENCODING])
chunk = this[DECODER].write(chunk)
try {
return this.flowing
? (this.emit('data', chunk), this.flowing)
: (this[BUFFERPUSH](chunk), false)
} finally {
if (this[BUFFERLENGTH] !== 0)
this.emit('readable')
if (cb)
cb()
}
}
read (n) {
if (this[DESTROYED])
return null
try {
if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH])
return null
if (this[OBJECTMODE])
n = null
if (this.buffer.length > 1 && !this[OBJECTMODE]) {
if (this.encoding)
this.buffer = new Yallist([
Array.from(this.buffer).join('')
])
else
this.buffer = new Yallist([
B.concat(Array.from(this.buffer), this[BUFFERLENGTH])
])
}
return this[READ](n || null, this.buffer.head.value)
} finally {
this[MAYBE_EMIT_END]()
}
}
[READ] (n, chunk) {
if (n === chunk.length || n === null)
this[BUFFERSHIFT]()
else {
this.buffer.head.value = chunk.slice(n)
chunk = chunk.slice(0, n)
this[BUFFERLENGTH] -= n
}
this.emit('data', chunk)
if (!this.buffer.length && !this[EOF])
this.emit('drain')
return chunk
}
end (chunk, encoding, cb) {
if (typeof chunk === 'function')
cb = chunk, chunk = null
if (typeof encoding === 'function')
cb = encoding, encoding = 'utf8'
if (chunk)
this.write(chunk, encoding)
if (cb)
this.once('end', cb)
this[EOF] = true
this.writable = false
// if we haven't written anything, then go ahead and emit,
// even if we're not reading.
// we'll re-emit if a new 'end' listener is added anyway.
// This makes MP more suitable to write-only use cases.
if (this.flowing || !this[PAUSED])
this[MAYBE_EMIT_END]()
return this
}
// don't let the internal resume be overwritten
[RESUME] () {
if (this[DESTROYED])
return
this[PAUSED] = false
this[FLOWING] = true
this.emit('resume')
if (this.buffer.length)
this[FLUSH]()
else if (this[EOF])
this[MAYBE_EMIT_END]()
else
this.emit('drain')
}
resume () {
return this[RESUME]()
}
pause () {
this[FLOWING] = false
this[PAUSED] = true
}
get destroyed () {
return this[DESTROYED]
}
get flowing () {
return this[FLOWING]
}
get paused () {
return this[PAUSED]
}
[BUFFERPUSH] (chunk) {
if (this[OBJECTMODE])
this[BUFFERLENGTH] += 1
else
this[BUFFERLENGTH] += chunk.length
return this.buffer.push(chunk)
}
[BUFFERSHIFT] () {
if (this.buffer.length) {
if (this[OBJECTMODE])
this[BUFFERLENGTH] -= 1
else
this[BUFFERLENGTH] -= this.buffer.head.value.length
}
return this.buffer.shift()
}
[FLUSH] () {
do {} while (this[FLUSHCHUNK](this[BUFFERSHIFT]()))
if (!this.buffer.length && !this[EOF])
this.emit('drain')
}
[FLUSHCHUNK] (chunk) {
return chunk ? (this.emit('data', chunk), this.flowing) : false
}
pipe (dest, opts) {
if (this[DESTROYED])
return
const ended = this[EMITTED_END]
opts = opts || {}
if (dest === process.stdout || dest === process.stderr)
opts.end = false
else
opts.end = opts.end !== false
const p = { dest: dest, opts: opts, ondrain: _ => this[RESUME]() }
this.pipes.push(p)
dest.on('drain', p.ondrain)
this[RESUME]()
// piping an ended stream ends immediately
if (ended && p.opts.end)
p.dest.end()
return dest
}
addListener (ev, fn) {
return this.on(ev, fn)
}
on (ev, fn) {
try {
return super.on(ev, fn)
} finally {
if (ev === 'data' && !this.pipes.length && !this.flowing)
this[RESUME]()
else if (isEndish(ev) && this[EMITTED_END]) {
super.emit(ev)
this.removeAllListeners(ev)
}
}
}
get emittedEnd () {
return this[EMITTED_END]
}
[MAYBE_EMIT_END] () {
if (!this[EMITTING_END] &&
!this[EMITTED_END] &&
!this[DESTROYED] &&
this.buffer.length === 0 &&
this[EOF]) {
this[EMITTING_END] = true
this.emit('end')
this.emit('prefinish')
this.emit('finish')
if (this[CLOSED])
this.emit('close')
this[EMITTING_END] = false
}
}
emit (ev, data) {
// error and close are only events allowed after calling destroy()
if (ev !== 'error' && ev !== 'close' && ev !== DESTROYED && this[DESTROYED])
return
else if (ev === 'data') {
if (!data)
return
if (this.pipes.length)
this.pipes.forEach(p =>
p.dest.write(data) === false && this.pause())
} else if (ev === 'end') {
// only actual end gets this treatment
if (this[EMITTED_END] === true)
return
this[EMITTED_END] = true
this.readable = false
if (this[DECODER]) {
data = this[DECODER].end()
if (data) {
this.pipes.forEach(p => p.dest.write(data))
super.emit('data', data)
}
}
this.pipes.forEach(p => {
p.dest.removeListener('drain', p.ondrain)
if (p.opts.end)
p.dest.end()
})
} else if (ev === 'close') {
this[CLOSED] = true
// don't emit close before 'end' and 'finish'
if (!this[EMITTED_END] && !this[DESTROYED])
return
}
// TODO: replace with a spread operator when Node v4 support drops
const args = new Array(arguments.length)
args[0] = ev
args[1] = data
if (arguments.length > 2) {
for (let i = 2; i < arguments.length; i++) {
args[i] = arguments[i]
}
}
try {
return super.emit.apply(this, args)
} finally {
if (!isEndish(ev))
this[MAYBE_EMIT_END]()
else
this.removeAllListeners(ev)
}
}
// const all = await stream.collect()
collect () {
const buf = []
buf.dataLength = 0
this.on('data', c => {
buf.push(c)
buf.dataLength += c.length
})
return this.promise().then(() => buf)
}
// const data = await stream.concat()
concat () {
return this[OBJECTMODE]
? Promise.reject(new Error('cannot concat in objectMode'))
: this.collect().then(buf =>
this[OBJECTMODE]
? Promise.reject(new Error('cannot concat in objectMode'))
: this[ENCODING] ? buf.join('') : B.concat(buf, buf.dataLength))
}
// stream.promise().then(() => done, er => emitted error)
promise () {
return new Promise((resolve, reject) => {
this.on(DESTROYED, () => reject(new Error('stream destroyed')))
this.on('end', () => resolve())
this.on('error', er => reject(er))
})
}
// for await (let chunk of stream)
[ASYNCITERATOR] () {
const next = () => {
const res = this.read()
if (res !== null)
return Promise.resolve({ done: false, value: res })
if (this[EOF])
return Promise.resolve({ done: true })
let resolve = null
let reject = null
const onerr = er => {
this.removeListener('data', ondata)
this.removeListener('end', onend)
reject(er)
}
const ondata = value => {
this.removeListener('error', onerr)
this.removeListener('end', onend)
this.pause()
resolve({ value: value, done: !!this[EOF] })
}
const onend = () => {
this.removeListener('error', onerr)
this.removeListener('data', ondata)
resolve({ done: true })
}
const ondestroy = () => onerr(new Error('stream destroyed'))
return new Promise((res, rej) => {
reject = rej
resolve = res
this.once(DESTROYED, ondestroy)
this.once('error', onerr)
this.once('end', onend)
this.once('data', ondata)
})
}
return { next }
}
// for (let chunk of stream)
[ITERATOR] () {
const next = () => {
const value = this.read()
const done = value === null
return { value, done }
}
return { next }
}
destroy (er) {
if (this[DESTROYED]) {
if (er)
this.emit('error', er)
else
this.emit(DESTROYED)
return this
}
this[DESTROYED] = true
// throw away all buffered data, it's never coming out
this.buffer = new Yallist()
this[BUFFERLENGTH] = 0
if (typeof this.close === 'function' && !this[CLOSED])
this.close()
if (er)
this.emit('error', er)
else // if no error to emit, still reject pending promises
this.emit(DESTROYED)
return this
}
static isStream (s) {
return !!s && (s instanceof Minipass || s instanceof EE && (
typeof s.pipe === 'function' || // readable
(typeof s.write === 'function' && typeof s.end === 'function') // writable
))
}
}
``` | /content/code_sandbox/node_modules/minipass/index.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 3,801 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
XMLDOMImplementation = require('./XMLDOMImplementation');
XMLDocument = require('./XMLDocument');
XMLDocumentCB = require('./XMLDocumentCB');
XMLStringWriter = require('./XMLStringWriter');
XMLStreamWriter = require('./XMLStreamWriter');
NodeType = require('./NodeType');
WriterState = require('./WriterState');
module.exports.create = function(name, xmldec, doctype, options) {
var doc, root;
if (name == null) {
throw new Error("Root element needs a name.");
}
options = assign({}, xmldec, doctype, options);
doc = new XMLDocument(options);
root = doc.element(name);
if (!options.headless) {
doc.declaration(options);
if ((options.pubID != null) || (options.sysID != null)) {
doc.dtd(options);
}
}
return root;
};
module.exports.begin = function(options, onData, onEnd) {
var ref1;
if (isFunction(options)) {
ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
options = {};
}
if (onData) {
return new XMLDocumentCB(options, onData, onEnd);
} else {
return new XMLDocument(options);
}
};
module.exports.stringWriter = function(options) {
return new XMLStringWriter(options);
};
module.exports.streamWriter = function(stream, options) {
return new XMLStreamWriter(stream, options);
};
module.exports.implementation = new XMLDOMImplementation();
module.exports.nodeType = NodeType;
module.exports.writerState = WriterState;
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/index.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 418 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLNodeFilter;
module.exports = XMLNodeFilter = (function() {
function XMLNodeFilter() {}
XMLNodeFilter.prototype.FilterAccept = 1;
XMLNodeFilter.prototype.FilterReject = 2;
XMLNodeFilter.prototype.FilterSkip = 3;
XMLNodeFilter.prototype.ShowAll = 0xffffffff;
XMLNodeFilter.prototype.ShowElement = 0x1;
XMLNodeFilter.prototype.ShowAttribute = 0x2;
XMLNodeFilter.prototype.ShowText = 0x4;
XMLNodeFilter.prototype.ShowCDataSection = 0x8;
XMLNodeFilter.prototype.ShowEntityReference = 0x10;
XMLNodeFilter.prototype.ShowEntity = 0x20;
XMLNodeFilter.prototype.ShowProcessingInstruction = 0x40;
XMLNodeFilter.prototype.ShowComment = 0x80;
XMLNodeFilter.prototype.ShowDocument = 0x100;
XMLNodeFilter.prototype.ShowDocumentType = 0x200;
XMLNodeFilter.prototype.ShowDocumentFragment = 0x400;
XMLNodeFilter.prototype.ShowNotation = 0x800;
XMLNodeFilter.prototype.acceptNode = function(node) {
throw new Error("This DOM method is not implemented.");
};
return XMLNodeFilter;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLNodeFilter.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 288 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDTDEntity, XMLNode, isObject,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
isObject = require('./Utility').isObject;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
module.exports = XMLDTDEntity = (function(superClass) {
extend(XMLDTDEntity, superClass);
function XMLDTDEntity(parent, pe, name, value) {
XMLDTDEntity.__super__.constructor.call(this, parent);
if (name == null) {
throw new Error("Missing DTD entity name. " + this.debugInfo(name));
}
if (value == null) {
throw new Error("Missing DTD entity value. " + this.debugInfo(name));
}
this.pe = !!pe;
this.name = this.stringify.name(name);
this.type = NodeType.EntityDeclaration;
if (!isObject(value)) {
this.value = this.stringify.dtdEntityValue(value);
this.internal = true;
} else {
if (!value.pubID && !value.sysID) {
throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
}
if (value.pubID && !value.sysID) {
throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
}
this.internal = false;
if (value.pubID != null) {
this.pubID = this.stringify.dtdPubID(value.pubID);
}
if (value.sysID != null) {
this.sysID = this.stringify.dtdSysID(value.sysID);
}
if (value.nData != null) {
this.nData = this.stringify.dtdNData(value.nData);
}
if (this.pe && this.nData) {
throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
}
}
}
Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
get: function() {
return this.pubID;
}
});
Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
get: function() {
return this.sysID;
}
});
Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
get: function() {
return this.nData || null;
}
});
Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
get: function() {
return null;
}
});
Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
get: function() {
return null;
}
});
Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
get: function() {
return null;
}
});
XMLDTDEntity.prototype.toString = function(options) {
return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
};
return XMLDTDEntity;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDTDEntity.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 716 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign,
hasProp = {}.hasOwnProperty;
assign = require('./Utility').assign;
NodeType = require('./NodeType');
XMLDeclaration = require('./XMLDeclaration');
XMLDocType = require('./XMLDocType');
XMLCData = require('./XMLCData');
XMLComment = require('./XMLComment');
XMLElement = require('./XMLElement');
XMLRaw = require('./XMLRaw');
XMLText = require('./XMLText');
XMLProcessingInstruction = require('./XMLProcessingInstruction');
XMLDummy = require('./XMLDummy');
XMLDTDAttList = require('./XMLDTDAttList');
XMLDTDElement = require('./XMLDTDElement');
XMLDTDEntity = require('./XMLDTDEntity');
XMLDTDNotation = require('./XMLDTDNotation');
WriterState = require('./WriterState');
module.exports = XMLWriterBase = (function() {
function XMLWriterBase(options) {
var key, ref, value;
options || (options = {});
this.options = options;
ref = options.writer || {};
for (key in ref) {
if (!hasProp.call(ref, key)) continue;
value = ref[key];
this["_" + key] = this[key];
this[key] = value;
}
}
XMLWriterBase.prototype.filterOptions = function(options) {
var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
options || (options = {});
options = assign({}, this.options, options);
filteredOptions = {
writer: this
};
filteredOptions.pretty = options.pretty || false;
filteredOptions.allowEmpty = options.allowEmpty || false;
filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : '';
if (filteredOptions.spaceBeforeSlash === true) {
filteredOptions.spaceBeforeSlash = ' ';
}
filteredOptions.suppressPrettyCount = 0;
filteredOptions.user = {};
filteredOptions.state = WriterState.None;
return filteredOptions;
};
XMLWriterBase.prototype.indent = function(node, options, level) {
var indentLevel;
if (!options.pretty || options.suppressPrettyCount) {
return '';
} else if (options.pretty) {
indentLevel = (level || 0) + options.offset + 1;
if (indentLevel > 0) {
return new Array(indentLevel).join(options.indent);
}
}
return '';
};
XMLWriterBase.prototype.endline = function(node, options, level) {
if (!options.pretty || options.suppressPrettyCount) {
return '';
} else {
return options.newline;
}
};
XMLWriterBase.prototype.attribute = function(att, options, level) {
var r;
this.openAttribute(att, options, level);
r = ' ' + att.name + '="' + att.value + '"';
this.closeAttribute(att, options, level);
return r;
};
XMLWriterBase.prototype.cdata = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<![CDATA[';
options.state = WriterState.InsideTag;
r += node.value;
options.state = WriterState.CloseTag;
r += ']]>' + this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.comment = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<!-- ';
options.state = WriterState.InsideTag;
r += node.value;
options.state = WriterState.CloseTag;
r += ' -->' + this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.declaration = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<?xml';
options.state = WriterState.InsideTag;
r += ' version="' + node.version + '"';
if (node.encoding != null) {
r += ' encoding="' + node.encoding + '"';
}
if (node.standalone != null) {
r += ' standalone="' + node.standalone + '"';
}
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '?>';
r += this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.docType = function(node, options, level) {
var child, i, len, r, ref;
level || (level = 0);
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level);
r += '<!DOCTYPE ' + node.root().name;
if (node.pubID && node.sysID) {
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
} else if (node.sysID) {
r += ' SYSTEM "' + node.sysID + '"';
}
if (node.children.length > 0) {
r += ' [';
r += this.endline(node, options, level);
options.state = WriterState.InsideTag;
ref = node.children;
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
r += this.writeChildNode(child, options, level + 1);
}
options.state = WriterState.CloseTag;
r += ']';
}
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '>';
r += this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.element = function(node, options, level) {
var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
level || (level = 0);
prettySuppressed = false;
r = '';
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r += this.indent(node, options, level) + '<' + node.name;
ref = node.attribs;
for (name in ref) {
if (!hasProp.call(ref, name)) continue;
att = ref[name];
r += this.attribute(att, options, level);
}
childNodeCount = node.children.length;
firstChildNode = childNodeCount === 0 ? null : node.children[0];
if (childNodeCount === 0 || node.children.every(function(e) {
return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
})) {
if (options.allowEmpty) {
r += '>';
options.state = WriterState.CloseTag;
r += '</' + node.name + '>' + this.endline(node, options, level);
} else {
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
}
} else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
r += '>';
options.state = WriterState.InsideTag;
options.suppressPrettyCount++;
prettySuppressed = true;
r += this.writeChildNode(firstChildNode, options, level + 1);
options.suppressPrettyCount--;
prettySuppressed = false;
options.state = WriterState.CloseTag;
r += '</' + node.name + '>' + this.endline(node, options, level);
} else {
if (options.dontPrettyTextNodes) {
ref1 = node.children;
for (i = 0, len = ref1.length; i < len; i++) {
child = ref1[i];
if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) {
options.suppressPrettyCount++;
prettySuppressed = true;
break;
}
}
}
r += '>' + this.endline(node, options, level);
options.state = WriterState.InsideTag;
ref2 = node.children;
for (j = 0, len1 = ref2.length; j < len1; j++) {
child = ref2[j];
r += this.writeChildNode(child, options, level + 1);
}
options.state = WriterState.CloseTag;
r += this.indent(node, options, level) + '</' + node.name + '>';
if (prettySuppressed) {
options.suppressPrettyCount--;
}
r += this.endline(node, options, level);
options.state = WriterState.None;
}
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.writeChildNode = function(node, options, level) {
switch (node.type) {
case NodeType.CData:
return this.cdata(node, options, level);
case NodeType.Comment:
return this.comment(node, options, level);
case NodeType.Element:
return this.element(node, options, level);
case NodeType.Raw:
return this.raw(node, options, level);
case NodeType.Text:
return this.text(node, options, level);
case NodeType.ProcessingInstruction:
return this.processingInstruction(node, options, level);
case NodeType.Dummy:
return '';
case NodeType.Declaration:
return this.declaration(node, options, level);
case NodeType.DocType:
return this.docType(node, options, level);
case NodeType.AttributeDeclaration:
return this.dtdAttList(node, options, level);
case NodeType.ElementDeclaration:
return this.dtdElement(node, options, level);
case NodeType.EntityDeclaration:
return this.dtdEntity(node, options, level);
case NodeType.NotationDeclaration:
return this.dtdNotation(node, options, level);
default:
throw new Error("Unknown XML node type: " + node.constructor.name);
}
};
XMLWriterBase.prototype.processingInstruction = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<?';
options.state = WriterState.InsideTag;
r += node.target;
if (node.value) {
r += ' ' + node.value;
}
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '?>';
r += this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.raw = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level);
options.state = WriterState.InsideTag;
r += node.value;
options.state = WriterState.CloseTag;
r += this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.text = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level);
options.state = WriterState.InsideTag;
r += node.value;
options.state = WriterState.CloseTag;
r += this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.dtdAttList = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<!ATTLIST';
options.state = WriterState.InsideTag;
r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
if (node.defaultValueType !== '#DEFAULT') {
r += ' ' + node.defaultValueType;
}
if (node.defaultValue) {
r += ' "' + node.defaultValue + '"';
}
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.dtdElement = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<!ELEMENT';
options.state = WriterState.InsideTag;
r += ' ' + node.name + ' ' + node.value;
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.dtdEntity = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<!ENTITY';
options.state = WriterState.InsideTag;
if (node.pe) {
r += ' %';
}
r += ' ' + node.name;
if (node.value) {
r += ' "' + node.value + '"';
} else {
if (node.pubID && node.sysID) {
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
} else if (node.sysID) {
r += ' SYSTEM "' + node.sysID + '"';
}
if (node.nData) {
r += ' NDATA ' + node.nData;
}
}
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.dtdNotation = function(node, options, level) {
var r;
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
r = this.indent(node, options, level) + '<!NOTATION';
options.state = WriterState.InsideTag;
r += ' ' + node.name;
if (node.pubID && node.sysID) {
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
} else if (node.pubID) {
r += ' PUBLIC "' + node.pubID + '"';
} else if (node.sysID) {
r += ' SYSTEM "' + node.sysID + '"';
}
options.state = WriterState.CloseTag;
r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
options.state = WriterState.None;
this.closeNode(node, options, level);
return r;
};
XMLWriterBase.prototype.openNode = function(node, options, level) {};
XMLWriterBase.prototype.closeNode = function(node, options, level) {};
XMLWriterBase.prototype.openAttribute = function(att, options, level) {};
XMLWriterBase.prototype.closeAttribute = function(att, options, level) {};
return XMLWriterBase;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLWriterBase.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 3,703 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLNode, XMLRaw,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
NodeType = require('./NodeType');
XMLNode = require('./XMLNode');
module.exports = XMLRaw = (function(superClass) {
extend(XMLRaw, superClass);
function XMLRaw(parent, text) {
XMLRaw.__super__.constructor.call(this, parent);
if (text == null) {
throw new Error("Missing raw text. " + this.debugInfo());
}
this.type = NodeType.Raw;
this.value = this.stringify.raw(text);
}
XMLRaw.prototype.clone = function() {
return Object.create(this);
};
XMLRaw.prototype.toString = function(options) {
return this.options.writer.raw(this, this.options.writer.filterOptions(options));
};
return XMLRaw;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLRaw.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 260 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLDOMStringList;
module.exports = XMLDOMStringList = (function() {
function XMLDOMStringList(arr) {
this.arr = arr || [];
}
Object.defineProperty(XMLDOMStringList.prototype, 'length', {
get: function() {
return this.arr.length;
}
});
XMLDOMStringList.prototype.item = function(index) {
return this.arr[index] || null;
};
XMLDOMStringList.prototype.contains = function(str) {
return this.arr.indexOf(str) !== -1;
};
return XMLDOMStringList;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDOMStringList.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 145 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
NodeType = require('./NodeType');
XMLWriterBase = require('./XMLWriterBase');
WriterState = require('./WriterState');
module.exports = XMLStreamWriter = (function(superClass) {
extend(XMLStreamWriter, superClass);
function XMLStreamWriter(stream, options) {
this.stream = stream;
XMLStreamWriter.__super__.constructor.call(this, options);
}
XMLStreamWriter.prototype.endline = function(node, options, level) {
if (node.isLastRootNode && options.state === WriterState.CloseTag) {
return '';
} else {
return XMLStreamWriter.__super__.endline.call(this, node, options, level);
}
};
XMLStreamWriter.prototype.document = function(doc, options) {
var child, i, j, k, len, len1, ref, ref1, results;
ref = doc.children;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
child = ref[i];
child.isLastRootNode = i === doc.children.length - 1;
}
options = this.filterOptions(options);
ref1 = doc.children;
results = [];
for (k = 0, len1 = ref1.length; k < len1; k++) {
child = ref1[k];
results.push(this.writeChildNode(child, options, 0));
}
return results;
};
XMLStreamWriter.prototype.attribute = function(att, options, level) {
return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
};
XMLStreamWriter.prototype.cdata = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
};
XMLStreamWriter.prototype.comment = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
};
XMLStreamWriter.prototype.declaration = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
};
XMLStreamWriter.prototype.docType = function(node, options, level) {
var child, j, len, ref;
level || (level = 0);
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
this.stream.write(this.indent(node, options, level));
this.stream.write('<!DOCTYPE ' + node.root().name);
if (node.pubID && node.sysID) {
this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
} else if (node.sysID) {
this.stream.write(' SYSTEM "' + node.sysID + '"');
}
if (node.children.length > 0) {
this.stream.write(' [');
this.stream.write(this.endline(node, options, level));
options.state = WriterState.InsideTag;
ref = node.children;
for (j = 0, len = ref.length; j < len; j++) {
child = ref[j];
this.writeChildNode(child, options, level + 1);
}
options.state = WriterState.CloseTag;
this.stream.write(']');
}
options.state = WriterState.CloseTag;
this.stream.write(options.spaceBeforeSlash + '>');
this.stream.write(this.endline(node, options, level));
options.state = WriterState.None;
return this.closeNode(node, options, level);
};
XMLStreamWriter.prototype.element = function(node, options, level) {
var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
level || (level = 0);
this.openNode(node, options, level);
options.state = WriterState.OpenTag;
this.stream.write(this.indent(node, options, level) + '<' + node.name);
ref = node.attribs;
for (name in ref) {
if (!hasProp.call(ref, name)) continue;
att = ref[name];
this.attribute(att, options, level);
}
childNodeCount = node.children.length;
firstChildNode = childNodeCount === 0 ? null : node.children[0];
if (childNodeCount === 0 || node.children.every(function(e) {
return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
})) {
if (options.allowEmpty) {
this.stream.write('>');
options.state = WriterState.CloseTag;
this.stream.write('</' + node.name + '>');
} else {
options.state = WriterState.CloseTag;
this.stream.write(options.spaceBeforeSlash + '/>');
}
} else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
this.stream.write('>');
options.state = WriterState.InsideTag;
options.suppressPrettyCount++;
prettySuppressed = true;
this.writeChildNode(firstChildNode, options, level + 1);
options.suppressPrettyCount--;
prettySuppressed = false;
options.state = WriterState.CloseTag;
this.stream.write('</' + node.name + '>');
} else {
this.stream.write('>' + this.endline(node, options, level));
options.state = WriterState.InsideTag;
ref1 = node.children;
for (j = 0, len = ref1.length; j < len; j++) {
child = ref1[j];
this.writeChildNode(child, options, level + 1);
}
options.state = WriterState.CloseTag;
this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
}
this.stream.write(this.endline(node, options, level));
options.state = WriterState.None;
return this.closeNode(node, options, level);
};
XMLStreamWriter.prototype.processingInstruction = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
};
XMLStreamWriter.prototype.raw = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level));
};
XMLStreamWriter.prototype.text = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level));
};
XMLStreamWriter.prototype.dtdAttList = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level));
};
XMLStreamWriter.prototype.dtdElement = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
};
XMLStreamWriter.prototype.dtdEntity = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level));
};
XMLStreamWriter.prototype.dtdNotation = function(node, options, level) {
return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level));
};
return XMLStreamWriter;
})(XMLWriterBase);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLStreamWriter.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,668 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDTDElement, XMLNode,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
module.exports = XMLDTDElement = (function(superClass) {
extend(XMLDTDElement, superClass);
function XMLDTDElement(parent, name, value) {
XMLDTDElement.__super__.constructor.call(this, parent);
if (name == null) {
throw new Error("Missing DTD element name. " + this.debugInfo());
}
if (!value) {
value = '(#PCDATA)';
}
if (Array.isArray(value)) {
value = '(' + value.join(',') + ')';
}
this.name = this.stringify.name(name);
this.type = NodeType.ElementDeclaration;
this.value = this.stringify.dtdElementValue(value);
}
XMLDTDElement.prototype.toString = function(options) {
return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
};
return XMLDTDElement;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDTDElement.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 310 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
XMLAttribute = require('./XMLAttribute');
XMLNamedNodeMap = require('./XMLNamedNodeMap');
module.exports = XMLElement = (function(superClass) {
extend(XMLElement, superClass);
function XMLElement(parent, name, attributes) {
var child, j, len, ref1;
XMLElement.__super__.constructor.call(this, parent);
if (name == null) {
throw new Error("Missing element name. " + this.debugInfo());
}
this.name = this.stringify.name(name);
this.type = NodeType.Element;
this.attribs = {};
this.schemaTypeInfo = null;
if (attributes != null) {
this.attribute(attributes);
}
if (parent.type === NodeType.Document) {
this.isRoot = true;
this.documentObject = parent;
parent.rootObject = this;
if (parent.children) {
ref1 = parent.children;
for (j = 0, len = ref1.length; j < len; j++) {
child = ref1[j];
if (child.type === NodeType.DocType) {
child.name = this.name;
break;
}
}
}
}
}
Object.defineProperty(XMLElement.prototype, 'tagName', {
get: function() {
return this.name;
}
});
Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
get: function() {
return '';
}
});
Object.defineProperty(XMLElement.prototype, 'prefix', {
get: function() {
return '';
}
});
Object.defineProperty(XMLElement.prototype, 'localName', {
get: function() {
return this.name;
}
});
Object.defineProperty(XMLElement.prototype, 'id', {
get: function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
});
Object.defineProperty(XMLElement.prototype, 'className', {
get: function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
});
Object.defineProperty(XMLElement.prototype, 'classList', {
get: function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
});
Object.defineProperty(XMLElement.prototype, 'attributes', {
get: function() {
if (!this.attributeMap || !this.attributeMap.nodes) {
this.attributeMap = new XMLNamedNodeMap(this.attribs);
}
return this.attributeMap;
}
});
XMLElement.prototype.clone = function() {
var att, attName, clonedSelf, ref1;
clonedSelf = Object.create(this);
if (clonedSelf.isRoot) {
clonedSelf.documentObject = null;
}
clonedSelf.attribs = {};
ref1 = this.attribs;
for (attName in ref1) {
if (!hasProp.call(ref1, attName)) continue;
att = ref1[attName];
clonedSelf.attribs[attName] = att.clone();
}
clonedSelf.children = [];
this.children.forEach(function(child) {
var clonedChild;
clonedChild = child.clone();
clonedChild.parent = clonedSelf;
return clonedSelf.children.push(clonedChild);
});
return clonedSelf;
};
XMLElement.prototype.attribute = function(name, value) {
var attName, attValue;
if (name != null) {
name = getValue(name);
}
if (isObject(name)) {
for (attName in name) {
if (!hasProp.call(name, attName)) continue;
attValue = name[attName];
this.attribute(attName, attValue);
}
} else {
if (isFunction(value)) {
value = value.apply();
}
if (this.options.keepNullAttributes && (value == null)) {
this.attribs[name] = new XMLAttribute(this, name, "");
} else if (value != null) {
this.attribs[name] = new XMLAttribute(this, name, value);
}
}
return this;
};
XMLElement.prototype.removeAttribute = function(name) {
var attName, j, len;
if (name == null) {
throw new Error("Missing attribute name. " + this.debugInfo());
}
name = getValue(name);
if (Array.isArray(name)) {
for (j = 0, len = name.length; j < len; j++) {
attName = name[j];
delete this.attribs[attName];
}
} else {
delete this.attribs[name];
}
return this;
};
XMLElement.prototype.toString = function(options) {
return this.options.writer.element(this, this.options.writer.filterOptions(options));
};
XMLElement.prototype.att = function(name, value) {
return this.attribute(name, value);
};
XMLElement.prototype.a = function(name, value) {
return this.attribute(name, value);
};
XMLElement.prototype.getAttribute = function(name) {
if (this.attribs.hasOwnProperty(name)) {
return this.attribs[name].value;
} else {
return null;
}
};
XMLElement.prototype.setAttribute = function(name, value) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getAttributeNode = function(name) {
if (this.attribs.hasOwnProperty(name)) {
return this.attribs[name];
} else {
return null;
}
};
XMLElement.prototype.setAttributeNode = function(newAttr) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.removeAttributeNode = function(oldAttr) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getElementsByTagName = function(name) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.setAttributeNodeNS = function(newAttr) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.hasAttribute = function(name) {
return this.attribs.hasOwnProperty(name);
};
XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.setIdAttribute = function(name, isId) {
if (this.attribs.hasOwnProperty(name)) {
return this.attribs[name].isId;
} else {
return isId;
}
};
XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getElementsByTagName = function(tagname) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.getElementsByClassName = function(classNames) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLElement.prototype.isEqualNode = function(node) {
var i, j, ref1;
if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
return false;
}
if (node.namespaceURI !== this.namespaceURI) {
return false;
}
if (node.prefix !== this.prefix) {
return false;
}
if (node.localName !== this.localName) {
return false;
}
if (node.attribs.length !== this.attribs.length) {
return false;
}
for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
if (!this.attribs[i].isEqualNode(node.attribs[i])) {
return false;
}
}
return true;
};
return XMLElement;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLElement.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 2,098 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDeclaration, XMLNode, isObject,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
isObject = require('./Utility').isObject;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
module.exports = XMLDeclaration = (function(superClass) {
extend(XMLDeclaration, superClass);
function XMLDeclaration(parent, version, encoding, standalone) {
var ref;
XMLDeclaration.__super__.constructor.call(this, parent);
if (isObject(version)) {
ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
}
if (!version) {
version = '1.0';
}
this.type = NodeType.Declaration;
this.version = this.stringify.xmlVersion(version);
if (encoding != null) {
this.encoding = this.stringify.xmlEncoding(encoding);
}
if (standalone != null) {
this.standalone = this.stringify.xmlStandalone(standalone);
}
}
XMLDeclaration.prototype.toString = function(options) {
return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
};
return XMLDeclaration;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDeclaration.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 333 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLCharacterData, XMLProcessingInstruction,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
NodeType = require('./NodeType');
XMLCharacterData = require('./XMLCharacterData');
module.exports = XMLProcessingInstruction = (function(superClass) {
extend(XMLProcessingInstruction, superClass);
function XMLProcessingInstruction(parent, target, value) {
XMLProcessingInstruction.__super__.constructor.call(this, parent);
if (target == null) {
throw new Error("Missing instruction target. " + this.debugInfo());
}
this.type = NodeType.ProcessingInstruction;
this.target = this.stringify.insTarget(target);
this.name = this.target;
if (value) {
this.value = this.stringify.insValue(value);
}
}
XMLProcessingInstruction.prototype.clone = function() {
return Object.create(this);
};
XMLProcessingInstruction.prototype.toString = function(options) {
return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
};
XMLProcessingInstruction.prototype.isEqualNode = function(node) {
if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
return false;
}
if (node.target !== this.target) {
return false;
}
return true;
};
return XMLProcessingInstruction;
})(XMLCharacterData);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 366 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, ref,
hasProp = {}.hasOwnProperty;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
NodeType = require('./NodeType');
XMLDocument = require('./XMLDocument');
XMLElement = require('./XMLElement');
XMLCData = require('./XMLCData');
XMLComment = require('./XMLComment');
XMLRaw = require('./XMLRaw');
XMLText = require('./XMLText');
XMLProcessingInstruction = require('./XMLProcessingInstruction');
XMLDeclaration = require('./XMLDeclaration');
XMLDocType = require('./XMLDocType');
XMLDTDAttList = require('./XMLDTDAttList');
XMLDTDEntity = require('./XMLDTDEntity');
XMLDTDElement = require('./XMLDTDElement');
XMLDTDNotation = require('./XMLDTDNotation');
XMLAttribute = require('./XMLAttribute');
XMLStringifier = require('./XMLStringifier');
XMLStringWriter = require('./XMLStringWriter');
WriterState = require('./WriterState');
module.exports = XMLDocumentCB = (function() {
function XMLDocumentCB(options, onData, onEnd) {
var writerOptions;
this.name = "?xml";
this.type = NodeType.Document;
options || (options = {});
writerOptions = {};
if (!options.writer) {
options.writer = new XMLStringWriter();
} else if (isPlainObject(options.writer)) {
writerOptions = options.writer;
options.writer = new XMLStringWriter();
}
this.options = options;
this.writer = options.writer;
this.writerOptions = this.writer.filterOptions(writerOptions);
this.stringify = new XMLStringifier(options);
this.onDataCallback = onData || function() {};
this.onEndCallback = onEnd || function() {};
this.currentNode = null;
this.currentLevel = -1;
this.openTags = {};
this.documentStarted = false;
this.documentCompleted = false;
this.root = null;
}
XMLDocumentCB.prototype.createChildNode = function(node) {
var att, attName, attributes, child, i, len, ref1, ref2;
switch (node.type) {
case NodeType.CData:
this.cdata(node.value);
break;
case NodeType.Comment:
this.comment(node.value);
break;
case NodeType.Element:
attributes = {};
ref1 = node.attribs;
for (attName in ref1) {
if (!hasProp.call(ref1, attName)) continue;
att = ref1[attName];
attributes[attName] = att.value;
}
this.node(node.name, attributes);
break;
case NodeType.Dummy:
this.dummy();
break;
case NodeType.Raw:
this.raw(node.value);
break;
case NodeType.Text:
this.text(node.value);
break;
case NodeType.ProcessingInstruction:
this.instruction(node.target, node.value);
break;
default:
throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
}
ref2 = node.children;
for (i = 0, len = ref2.length; i < len; i++) {
child = ref2[i];
this.createChildNode(child);
if (child.type === NodeType.Element) {
this.up();
}
}
return this;
};
XMLDocumentCB.prototype.dummy = function() {
return this;
};
XMLDocumentCB.prototype.node = function(name, attributes, text) {
var ref1;
if (name == null) {
throw new Error("Missing node name.");
}
if (this.root && this.currentLevel === -1) {
throw new Error("Document can only have one root node. " + this.debugInfo(name));
}
this.openCurrent();
name = getValue(name);
if (attributes == null) {
attributes = {};
}
attributes = getValue(attributes);
if (!isObject(attributes)) {
ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
}
this.currentNode = new XMLElement(this, name, attributes);
this.currentNode.children = false;
this.currentLevel++;
this.openTags[this.currentLevel] = this.currentNode;
if (text != null) {
this.text(text);
}
return this;
};
XMLDocumentCB.prototype.element = function(name, attributes, text) {
var child, i, len, oldValidationFlag, ref1, root;
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
this.dtdElement.apply(this, arguments);
} else {
if (Array.isArray(name) || isObject(name) || isFunction(name)) {
oldValidationFlag = this.options.noValidation;
this.options.noValidation = true;
root = new XMLDocument(this.options).element('TEMP_ROOT');
root.element(name);
this.options.noValidation = oldValidationFlag;
ref1 = root.children;
for (i = 0, len = ref1.length; i < len; i++) {
child = ref1[i];
this.createChildNode(child);
if (child.type === NodeType.Element) {
this.up();
}
}
} else {
this.node(name, attributes, text);
}
}
return this;
};
XMLDocumentCB.prototype.attribute = function(name, value) {
var attName, attValue;
if (!this.currentNode || this.currentNode.children) {
throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
}
if (name != null) {
name = getValue(name);
}
if (isObject(name)) {
for (attName in name) {
if (!hasProp.call(name, attName)) continue;
attValue = name[attName];
this.attribute(attName, attValue);
}
} else {
if (isFunction(value)) {
value = value.apply();
}
if (this.options.keepNullAttributes && (value == null)) {
this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
} else if (value != null) {
this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
}
}
return this;
};
XMLDocumentCB.prototype.text = function(value) {
var node;
this.openCurrent();
node = new XMLText(this, value);
this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.cdata = function(value) {
var node;
this.openCurrent();
node = new XMLCData(this, value);
this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.comment = function(value) {
var node;
this.openCurrent();
node = new XMLComment(this, value);
this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.raw = function(value) {
var node;
this.openCurrent();
node = new XMLRaw(this, value);
this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.instruction = function(target, value) {
var i, insTarget, insValue, len, node;
this.openCurrent();
if (target != null) {
target = getValue(target);
}
if (value != null) {
value = getValue(value);
}
if (Array.isArray(target)) {
for (i = 0, len = target.length; i < len; i++) {
insTarget = target[i];
this.instruction(insTarget);
}
} else if (isObject(target)) {
for (insTarget in target) {
if (!hasProp.call(target, insTarget)) continue;
insValue = target[insTarget];
this.instruction(insTarget, insValue);
}
} else {
if (isFunction(value)) {
value = value.apply();
}
node = new XMLProcessingInstruction(this, target, value);
this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
}
return this;
};
XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
var node;
this.openCurrent();
if (this.documentStarted) {
throw new Error("declaration() must be the first node.");
}
node = new XMLDeclaration(this, version, encoding, standalone);
this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
this.openCurrent();
if (root == null) {
throw new Error("Missing root node name.");
}
if (this.root) {
throw new Error("dtd() must come before the root node.");
}
this.currentNode = new XMLDocType(this, pubID, sysID);
this.currentNode.rootNodeName = root;
this.currentNode.children = false;
this.currentLevel++;
this.openTags[this.currentLevel] = this.currentNode;
return this;
};
XMLDocumentCB.prototype.dtdElement = function(name, value) {
var node;
this.openCurrent();
node = new XMLDTDElement(this, name, value);
this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
var node;
this.openCurrent();
node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.entity = function(name, value) {
var node;
this.openCurrent();
node = new XMLDTDEntity(this, false, name, value);
this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.pEntity = function(name, value) {
var node;
this.openCurrent();
node = new XMLDTDEntity(this, true, name, value);
this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.notation = function(name, value) {
var node;
this.openCurrent();
node = new XMLDTDNotation(this, name, value);
this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
return this;
};
XMLDocumentCB.prototype.up = function() {
if (this.currentLevel < 0) {
throw new Error("The document node has no parent.");
}
if (this.currentNode) {
if (this.currentNode.children) {
this.closeNode(this.currentNode);
} else {
this.openNode(this.currentNode);
}
this.currentNode = null;
} else {
this.closeNode(this.openTags[this.currentLevel]);
}
delete this.openTags[this.currentLevel];
this.currentLevel--;
return this;
};
XMLDocumentCB.prototype.end = function() {
while (this.currentLevel >= 0) {
this.up();
}
return this.onEnd();
};
XMLDocumentCB.prototype.openCurrent = function() {
if (this.currentNode) {
this.currentNode.children = true;
return this.openNode(this.currentNode);
}
};
XMLDocumentCB.prototype.openNode = function(node) {
var att, chunk, name, ref1;
if (!node.isOpen) {
if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
this.root = node;
}
chunk = '';
if (node.type === NodeType.Element) {
this.writerOptions.state = WriterState.OpenTag;
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
ref1 = node.attribs;
for (name in ref1) {
if (!hasProp.call(ref1, name)) continue;
att = ref1[name];
chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
}
chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
this.writerOptions.state = WriterState.InsideTag;
} else {
this.writerOptions.state = WriterState.OpenTag;
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
if (node.pubID && node.sysID) {
chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
} else if (node.sysID) {
chunk += ' SYSTEM "' + node.sysID + '"';
}
if (node.children) {
chunk += ' [';
this.writerOptions.state = WriterState.InsideTag;
} else {
this.writerOptions.state = WriterState.CloseTag;
chunk += '>';
}
chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
}
this.onData(chunk, this.currentLevel);
return node.isOpen = true;
}
};
XMLDocumentCB.prototype.closeNode = function(node) {
var chunk;
if (!node.isClosed) {
chunk = '';
this.writerOptions.state = WriterState.CloseTag;
if (node.type === NodeType.Element) {
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
} else {
chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
}
this.writerOptions.state = WriterState.None;
this.onData(chunk, this.currentLevel);
return node.isClosed = true;
}
};
XMLDocumentCB.prototype.onData = function(chunk, level) {
this.documentStarted = true;
return this.onDataCallback(chunk, level + 1);
};
XMLDocumentCB.prototype.onEnd = function() {
this.documentCompleted = true;
return this.onEndCallback();
};
XMLDocumentCB.prototype.debugInfo = function(name) {
if (name == null) {
return "";
} else {
return "node: <" + name + ">";
}
};
XMLDocumentCB.prototype.ele = function() {
return this.element.apply(this, arguments);
};
XMLDocumentCB.prototype.nod = function(name, attributes, text) {
return this.node(name, attributes, text);
};
XMLDocumentCB.prototype.txt = function(value) {
return this.text(value);
};
XMLDocumentCB.prototype.dat = function(value) {
return this.cdata(value);
};
XMLDocumentCB.prototype.com = function(value) {
return this.comment(value);
};
XMLDocumentCB.prototype.ins = function(target, value) {
return this.instruction(target, value);
};
XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
return this.declaration(version, encoding, standalone);
};
XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
return this.doctype(root, pubID, sysID);
};
XMLDocumentCB.prototype.e = function(name, attributes, text) {
return this.element(name, attributes, text);
};
XMLDocumentCB.prototype.n = function(name, attributes, text) {
return this.node(name, attributes, text);
};
XMLDocumentCB.prototype.t = function(value) {
return this.text(value);
};
XMLDocumentCB.prototype.d = function(value) {
return this.cdata(value);
};
XMLDocumentCB.prototype.c = function(value) {
return this.comment(value);
};
XMLDocumentCB.prototype.r = function(value) {
return this.raw(value);
};
XMLDocumentCB.prototype.i = function(target, value) {
return this.instruction(target, value);
};
XMLDocumentCB.prototype.att = function() {
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
return this.attList.apply(this, arguments);
} else {
return this.attribute.apply(this, arguments);
}
};
XMLDocumentCB.prototype.a = function() {
if (this.currentNode && this.currentNode.type === NodeType.DocType) {
return this.attList.apply(this, arguments);
} else {
return this.attribute.apply(this, arguments);
}
};
XMLDocumentCB.prototype.ent = function(name, value) {
return this.entity(name, value);
};
XMLDocumentCB.prototype.pent = function(name, value) {
return this.pEntity(name, value);
};
XMLDocumentCB.prototype.not = function(name, value) {
return this.notation(name, value);
};
return XMLDocumentCB;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDocumentCB.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 3,944 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
XMLDOMStringList = require('./XMLDOMStringList');
module.exports = XMLDOMConfiguration = (function() {
function XMLDOMConfiguration() {
var clonedSelf;
this.defaultParams = {
"canonical-form": false,
"cdata-sections": false,
"comments": false,
"datatype-normalization": false,
"element-content-whitespace": true,
"entities": true,
"error-handler": new XMLDOMErrorHandler(),
"infoset": true,
"validate-if-schema": false,
"namespaces": true,
"namespace-declarations": true,
"normalize-characters": false,
"schema-location": '',
"schema-type": '',
"split-cdata-sections": true,
"validate": false,
"well-formed": true
};
this.params = clonedSelf = Object.create(this.defaultParams);
}
Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
get: function() {
return new XMLDOMStringList(Object.keys(this.defaultParams));
}
});
XMLDOMConfiguration.prototype.getParameter = function(name) {
if (this.params.hasOwnProperty(name)) {
return this.params[name];
} else {
return null;
}
};
XMLDOMConfiguration.prototype.canSetParameter = function(name, value) {
return true;
};
XMLDOMConfiguration.prototype.setParameter = function(name, value) {
if (value != null) {
return this.params[name] = value;
} else {
return delete this.params[name];
}
};
return XMLDOMConfiguration;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDOMConfiguration.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 383 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
isObject = require('./Utility').isObject;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
XMLDTDAttList = require('./XMLDTDAttList');
XMLDTDEntity = require('./XMLDTDEntity');
XMLDTDElement = require('./XMLDTDElement');
XMLDTDNotation = require('./XMLDTDNotation');
XMLNamedNodeMap = require('./XMLNamedNodeMap');
module.exports = XMLDocType = (function(superClass) {
extend(XMLDocType, superClass);
function XMLDocType(parent, pubID, sysID) {
var child, i, len, ref, ref1, ref2;
XMLDocType.__super__.constructor.call(this, parent);
this.type = NodeType.DocType;
if (parent.children) {
ref = parent.children;
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if (child.type === NodeType.Element) {
this.name = child.name;
break;
}
}
}
this.documentObject = parent;
if (isObject(pubID)) {
ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
}
if (sysID == null) {
ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
}
if (pubID != null) {
this.pubID = this.stringify.dtdPubID(pubID);
}
if (sysID != null) {
this.sysID = this.stringify.dtdSysID(sysID);
}
}
Object.defineProperty(XMLDocType.prototype, 'entities', {
get: function() {
var child, i, len, nodes, ref;
nodes = {};
ref = this.children;
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
nodes[child.name] = child;
}
}
return new XMLNamedNodeMap(nodes);
}
});
Object.defineProperty(XMLDocType.prototype, 'notations', {
get: function() {
var child, i, len, nodes, ref;
nodes = {};
ref = this.children;
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if (child.type === NodeType.NotationDeclaration) {
nodes[child.name] = child;
}
}
return new XMLNamedNodeMap(nodes);
}
});
Object.defineProperty(XMLDocType.prototype, 'publicId', {
get: function() {
return this.pubID;
}
});
Object.defineProperty(XMLDocType.prototype, 'systemId', {
get: function() {
return this.sysID;
}
});
Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
get: function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
});
XMLDocType.prototype.element = function(name, value) {
var child;
child = new XMLDTDElement(this, name, value);
this.children.push(child);
return this;
};
XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
var child;
child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
this.children.push(child);
return this;
};
XMLDocType.prototype.entity = function(name, value) {
var child;
child = new XMLDTDEntity(this, false, name, value);
this.children.push(child);
return this;
};
XMLDocType.prototype.pEntity = function(name, value) {
var child;
child = new XMLDTDEntity(this, true, name, value);
this.children.push(child);
return this;
};
XMLDocType.prototype.notation = function(name, value) {
var child;
child = new XMLDTDNotation(this, name, value);
this.children.push(child);
return this;
};
XMLDocType.prototype.toString = function(options) {
return this.options.writer.docType(this, this.options.writer.filterOptions(options));
};
XMLDocType.prototype.ele = function(name, value) {
return this.element(name, value);
};
XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
};
XMLDocType.prototype.ent = function(name, value) {
return this.entity(name, value);
};
XMLDocType.prototype.pent = function(name, value) {
return this.pEntity(name, value);
};
XMLDocType.prototype.not = function(name, value) {
return this.notation(name, value);
};
XMLDocType.prototype.up = function() {
return this.root() || this.documentObject;
};
XMLDocType.prototype.isEqualNode = function(node) {
if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
return false;
}
if (node.name !== this.name) {
return false;
}
if (node.publicId !== this.publicId) {
return false;
}
if (node.systemId !== this.systemId) {
return false;
}
return true;
};
return XMLDocType;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDocType.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,338 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLCharacterData, XMLNode,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
XMLNode = require('./XMLNode');
module.exports = XMLCharacterData = (function(superClass) {
extend(XMLCharacterData, superClass);
function XMLCharacterData(parent) {
XMLCharacterData.__super__.constructor.call(this, parent);
this.value = '';
}
Object.defineProperty(XMLCharacterData.prototype, 'data', {
get: function() {
return this.value;
},
set: function(value) {
return this.value = value || '';
}
});
Object.defineProperty(XMLCharacterData.prototype, 'length', {
get: function() {
return this.value.length;
}
});
Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
get: function() {
return this.value;
},
set: function(value) {
return this.value = value || '';
}
});
XMLCharacterData.prototype.clone = function() {
return Object.create(this);
};
XMLCharacterData.prototype.substringData = function(offset, count) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLCharacterData.prototype.appendData = function(arg) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLCharacterData.prototype.insertData = function(offset, arg) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLCharacterData.prototype.deleteData = function(offset, count) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLCharacterData.prototype.replaceData = function(offset, count, arg) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLCharacterData.prototype.isEqualNode = function(node) {
if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
return false;
}
if (node.data !== this.data) {
return false;
}
return true;
};
return XMLCharacterData;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLCharacterData.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 536 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var Derivation, XMLTypeInfo;
Derivation = require('./Derivation');
module.exports = XMLTypeInfo = (function() {
function XMLTypeInfo(typeName, typeNamespace) {
this.typeName = typeName;
this.typeNamespace = typeNamespace;
}
XMLTypeInfo.prototype.isDerivedFrom = function(typeNamespaceArg, typeNameArg, derivationMethod) {
throw new Error("This DOM method is not implemented.");
};
return XMLTypeInfo;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLTypeInfo.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 118 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLDOMErrorHandler;
module.exports = XMLDOMErrorHandler = (function() {
function XMLDOMErrorHandler() {}
XMLDOMErrorHandler.prototype.handleError = function(error) {
throw new Error(error);
};
return XMLDOMErrorHandler;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDOMErrorHandler.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 73 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLCharacterData, XMLComment,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
NodeType = require('./NodeType');
XMLCharacterData = require('./XMLCharacterData');
module.exports = XMLComment = (function(superClass) {
extend(XMLComment, superClass);
function XMLComment(parent, text) {
XMLComment.__super__.constructor.call(this, parent);
if (text == null) {
throw new Error("Missing comment text. " + this.debugInfo());
}
this.name = "#comment";
this.type = NodeType.Comment;
this.value = this.stringify.comment(text);
}
XMLComment.prototype.clone = function() {
return Object.create(this);
};
XMLComment.prototype.toString = function(options) {
return this.options.writer.comment(this, this.options.writer.filterOptions(options));
};
return XMLComment;
})(XMLCharacterData);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLComment.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 271 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
slice = [].slice,
hasProp = {}.hasOwnProperty;
assign = function() {
var i, key, len, source, sources, target;
target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
if (isFunction(Object.assign)) {
Object.assign.apply(null, arguments);
} else {
for (i = 0, len = sources.length; i < len; i++) {
source = sources[i];
if (source != null) {
for (key in source) {
if (!hasProp.call(source, key)) continue;
target[key] = source[key];
}
}
}
}
return target;
};
isFunction = function(val) {
return !!val && Object.prototype.toString.call(val) === '[object Function]';
};
isObject = function(val) {
var ref;
return !!val && ((ref = typeof val) === 'function' || ref === 'object');
};
isArray = function(val) {
if (isFunction(Array.isArray)) {
return Array.isArray(val);
} else {
return Object.prototype.toString.call(val) === '[object Array]';
}
};
isEmpty = function(val) {
var key;
if (isArray(val)) {
return !val.length;
} else {
for (key in val) {
if (!hasProp.call(val, key)) continue;
return false;
}
return true;
}
};
isPlainObject = function(val) {
var ctor, proto;
return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
};
getValue = function(obj) {
if (isFunction(obj.valueOf)) {
return obj.valueOf();
} else {
return obj;
}
};
module.exports.assign = assign;
module.exports.isFunction = isFunction;
module.exports.isObject = isObject;
module.exports.isArray = isArray;
module.exports.isEmpty = isEmpty;
module.exports.isPlainObject = isPlainObject;
module.exports.getValue = getValue;
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/Utility.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 517 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDTDNotation, XMLNode,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
module.exports = XMLDTDNotation = (function(superClass) {
extend(XMLDTDNotation, superClass);
function XMLDTDNotation(parent, name, value) {
XMLDTDNotation.__super__.constructor.call(this, parent);
if (name == null) {
throw new Error("Missing DTD notation name. " + this.debugInfo(name));
}
if (!value.pubID && !value.sysID) {
throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
}
this.name = this.stringify.name(name);
this.type = NodeType.NotationDeclaration;
if (value.pubID != null) {
this.pubID = this.stringify.dtdPubID(value.pubID);
}
if (value.sysID != null) {
this.sysID = this.stringify.dtdSysID(value.sysID);
}
}
Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
get: function() {
return this.pubID;
}
});
Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
get: function() {
return this.sysID;
}
});
XMLDTDNotation.prototype.toString = function(options) {
return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
};
return XMLDTDNotation;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDTDNotation.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 416 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var OperationType, XMLUserDataHandler;
OperationType = require('./OperationType');
module.exports = XMLUserDataHandler = (function() {
function XMLUserDataHandler() {}
XMLUserDataHandler.prototype.handle = function(operation, key, data, src, dst) {};
return XMLUserDataHandler;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLUserDataHandler.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 85 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = {
Clones: 1,
Imported: 2,
Deleted: 3,
Renamed: 4,
Adopted: 5
};
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/OperationType.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 60 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLAttribute, XMLNode;
NodeType = require('./NodeType');
XMLNode = require('./XMLNode');
module.exports = XMLAttribute = (function() {
function XMLAttribute(parent, name, value) {
this.parent = parent;
if (this.parent) {
this.options = this.parent.options;
this.stringify = this.parent.stringify;
}
if (name == null) {
throw new Error("Missing attribute name. " + this.debugInfo(name));
}
this.name = this.stringify.name(name);
this.value = this.stringify.attValue(value);
this.type = NodeType.Attribute;
this.isId = false;
this.schemaTypeInfo = null;
}
Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
get: function() {
return this.type;
}
});
Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
get: function() {
return this.parent;
}
});
Object.defineProperty(XMLAttribute.prototype, 'textContent', {
get: function() {
return this.value;
},
set: function(value) {
return this.value = value || '';
}
});
Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
get: function() {
return '';
}
});
Object.defineProperty(XMLAttribute.prototype, 'prefix', {
get: function() {
return '';
}
});
Object.defineProperty(XMLAttribute.prototype, 'localName', {
get: function() {
return this.name;
}
});
Object.defineProperty(XMLAttribute.prototype, 'specified', {
get: function() {
return true;
}
});
XMLAttribute.prototype.clone = function() {
return Object.create(this);
};
XMLAttribute.prototype.toString = function(options) {
return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
};
XMLAttribute.prototype.debugInfo = function(name) {
name = name || this.name;
if (name == null) {
return "parent: <" + this.parent.name + ">";
} else {
return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
}
};
XMLAttribute.prototype.isEqualNode = function(node) {
if (node.namespaceURI !== this.namespaceURI) {
return false;
}
if (node.prefix !== this.prefix) {
return false;
}
if (node.localName !== this.localName) {
return false;
}
if (node.value !== this.value) {
return false;
}
return true;
};
return XMLAttribute;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLAttribute.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 574 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLStringWriter, XMLWriterBase,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
XMLWriterBase = require('./XMLWriterBase');
module.exports = XMLStringWriter = (function(superClass) {
extend(XMLStringWriter, superClass);
function XMLStringWriter(options) {
XMLStringWriter.__super__.constructor.call(this, options);
}
XMLStringWriter.prototype.document = function(doc, options) {
var child, i, len, r, ref;
options = this.filterOptions(options);
r = '';
ref = doc.children;
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
r += this.writeChildNode(child, options, 0);
}
if (options.pretty && r.slice(-options.newline.length) === options.newline) {
r = r.slice(0, -options.newline.length);
}
return r;
};
return XMLStringWriter;
})(XMLWriterBase);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLStringWriter.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 301 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
isPlainObject = require('./Utility').isPlainObject;
XMLDOMImplementation = require('./XMLDOMImplementation');
XMLDOMConfiguration = require('./XMLDOMConfiguration');
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
XMLStringifier = require('./XMLStringifier');
XMLStringWriter = require('./XMLStringWriter');
module.exports = XMLDocument = (function(superClass) {
extend(XMLDocument, superClass);
function XMLDocument(options) {
XMLDocument.__super__.constructor.call(this, null);
this.name = "#document";
this.type = NodeType.Document;
this.documentURI = null;
this.domConfig = new XMLDOMConfiguration();
options || (options = {});
if (!options.writer) {
options.writer = new XMLStringWriter();
}
this.options = options;
this.stringify = new XMLStringifier(options);
}
Object.defineProperty(XMLDocument.prototype, 'implementation', {
value: new XMLDOMImplementation()
});
Object.defineProperty(XMLDocument.prototype, 'doctype', {
get: function() {
var child, i, len, ref;
ref = this.children;
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if (child.type === NodeType.DocType) {
return child;
}
}
return null;
}
});
Object.defineProperty(XMLDocument.prototype, 'documentElement', {
get: function() {
return this.rootObject || null;
}
});
Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
get: function() {
return null;
}
});
Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
get: function() {
return false;
}
});
Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
get: function() {
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
return this.children[0].encoding;
} else {
return null;
}
}
});
Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
get: function() {
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
return this.children[0].standalone === 'yes';
} else {
return false;
}
}
});
Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
get: function() {
if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
return this.children[0].version;
} else {
return "1.0";
}
}
});
Object.defineProperty(XMLDocument.prototype, 'URL', {
get: function() {
return this.documentURI;
}
});
Object.defineProperty(XMLDocument.prototype, 'origin', {
get: function() {
return null;
}
});
Object.defineProperty(XMLDocument.prototype, 'compatMode', {
get: function() {
return null;
}
});
Object.defineProperty(XMLDocument.prototype, 'characterSet', {
get: function() {
return null;
}
});
Object.defineProperty(XMLDocument.prototype, 'contentType', {
get: function() {
return null;
}
});
XMLDocument.prototype.end = function(writer) {
var writerOptions;
writerOptions = {};
if (!writer) {
writer = this.options.writer;
} else if (isPlainObject(writer)) {
writerOptions = writer;
writer = this.options.writer;
}
return writer.document(this, writer.filterOptions(writerOptions));
};
XMLDocument.prototype.toString = function(options) {
return this.options.writer.document(this, this.options.writer.filterOptions(options));
};
XMLDocument.prototype.createElement = function(tagName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createDocumentFragment = function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createTextNode = function(data) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createComment = function(data) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createCDATASection = function(data) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createProcessingInstruction = function(target, data) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createAttribute = function(name) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createEntityReference = function(name) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.getElementsByTagName = function(tagname) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.importNode = function(importedNode, deep) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.getElementById = function(elementId) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.adoptNode = function(source) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.normalizeDocument = function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.getElementsByClassName = function(classNames) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createEvent = function(eventInterface) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createRange = function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
return XMLDocument;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDocument.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 1,637 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLNamedNodeMap;
module.exports = XMLNamedNodeMap = (function() {
function XMLNamedNodeMap(nodes) {
this.nodes = nodes;
}
Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
get: function() {
return Object.keys(this.nodes).length || 0;
}
});
XMLNamedNodeMap.prototype.clone = function() {
return this.nodes = null;
};
XMLNamedNodeMap.prototype.getNamedItem = function(name) {
return this.nodes[name];
};
XMLNamedNodeMap.prototype.setNamedItem = function(node) {
var oldNode;
oldNode = this.nodes[node.nodeName];
this.nodes[node.nodeName] = node;
return oldNode || null;
};
XMLNamedNodeMap.prototype.removeNamedItem = function(name) {
var oldNode;
oldNode = this.nodes[name];
delete this.nodes[name];
return oldNode || null;
};
XMLNamedNodeMap.prototype.item = function(index) {
return this.nodes[Object.keys(this.nodes)[index]] || null;
};
XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented.");
};
XMLNamedNodeMap.prototype.setNamedItemNS = function(node) {
throw new Error("This DOM method is not implemented.");
};
XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) {
throw new Error("This DOM method is not implemented.");
};
return XMLNamedNodeMap;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLNamedNodeMap.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 356 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1,
hasProp = {}.hasOwnProperty;
ref1 = require('./Utility'), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
XMLElement = null;
XMLCData = null;
XMLComment = null;
XMLDeclaration = null;
XMLDocType = null;
XMLRaw = null;
XMLText = null;
XMLProcessingInstruction = null;
XMLDummy = null;
NodeType = null;
XMLNodeList = null;
XMLNamedNodeMap = null;
DocumentPosition = null;
module.exports = XMLNode = (function() {
function XMLNode(parent1) {
this.parent = parent1;
if (this.parent) {
this.options = this.parent.options;
this.stringify = this.parent.stringify;
}
this.value = null;
this.children = [];
this.baseURI = null;
if (!XMLElement) {
XMLElement = require('./XMLElement');
XMLCData = require('./XMLCData');
XMLComment = require('./XMLComment');
XMLDeclaration = require('./XMLDeclaration');
XMLDocType = require('./XMLDocType');
XMLRaw = require('./XMLRaw');
XMLText = require('./XMLText');
XMLProcessingInstruction = require('./XMLProcessingInstruction');
XMLDummy = require('./XMLDummy');
NodeType = require('./NodeType');
XMLNodeList = require('./XMLNodeList');
XMLNamedNodeMap = require('./XMLNamedNodeMap');
DocumentPosition = require('./DocumentPosition');
}
}
Object.defineProperty(XMLNode.prototype, 'nodeName', {
get: function() {
return this.name;
}
});
Object.defineProperty(XMLNode.prototype, 'nodeType', {
get: function() {
return this.type;
}
});
Object.defineProperty(XMLNode.prototype, 'nodeValue', {
get: function() {
return this.value;
}
});
Object.defineProperty(XMLNode.prototype, 'parentNode', {
get: function() {
return this.parent;
}
});
Object.defineProperty(XMLNode.prototype, 'childNodes', {
get: function() {
if (!this.childNodeList || !this.childNodeList.nodes) {
this.childNodeList = new XMLNodeList(this.children);
}
return this.childNodeList;
}
});
Object.defineProperty(XMLNode.prototype, 'firstChild', {
get: function() {
return this.children[0] || null;
}
});
Object.defineProperty(XMLNode.prototype, 'lastChild', {
get: function() {
return this.children[this.children.length - 1] || null;
}
});
Object.defineProperty(XMLNode.prototype, 'previousSibling', {
get: function() {
var i;
i = this.parent.children.indexOf(this);
return this.parent.children[i - 1] || null;
}
});
Object.defineProperty(XMLNode.prototype, 'nextSibling', {
get: function() {
var i;
i = this.parent.children.indexOf(this);
return this.parent.children[i + 1] || null;
}
});
Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
get: function() {
return this.document() || null;
}
});
Object.defineProperty(XMLNode.prototype, 'textContent', {
get: function() {
var child, j, len, ref2, str;
if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
str = '';
ref2 = this.children;
for (j = 0, len = ref2.length; j < len; j++) {
child = ref2[j];
if (child.textContent) {
str += child.textContent;
}
}
return str;
} else {
return null;
}
},
set: function(value) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
});
XMLNode.prototype.setParent = function(parent) {
var child, j, len, ref2, results;
this.parent = parent;
if (parent) {
this.options = parent.options;
this.stringify = parent.stringify;
}
ref2 = this.children;
results = [];
for (j = 0, len = ref2.length; j < len; j++) {
child = ref2[j];
results.push(child.setParent(this));
}
return results;
};
XMLNode.prototype.element = function(name, attributes, text) {
var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
lastChild = null;
if (attributes === null && (text == null)) {
ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
}
if (attributes == null) {
attributes = {};
}
attributes = getValue(attributes);
if (!isObject(attributes)) {
ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
}
if (name != null) {
name = getValue(name);
}
if (Array.isArray(name)) {
for (j = 0, len = name.length; j < len; j++) {
item = name[j];
lastChild = this.element(item);
}
} else if (isFunction(name)) {
lastChild = this.element(name.apply());
} else if (isObject(name)) {
for (key in name) {
if (!hasProp.call(name, key)) continue;
val = name[key];
if (isFunction(val)) {
val = val.apply();
}
if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
} else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
lastChild = this.dummy();
} else if (isObject(val) && isEmpty(val)) {
lastChild = this.element(key);
} else if (!this.options.keepNullNodes && (val == null)) {
lastChild = this.dummy();
} else if (!this.options.separateArrayItems && Array.isArray(val)) {
for (k = 0, len1 = val.length; k < len1; k++) {
item = val[k];
childNode = {};
childNode[key] = item;
lastChild = this.element(childNode);
}
} else if (isObject(val)) {
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
lastChild = this.element(val);
} else {
lastChild = this.element(key);
lastChild.element(val);
}
} else {
lastChild = this.element(key, val);
}
}
} else if (!this.options.keepNullNodes && text === null) {
lastChild = this.dummy();
} else {
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
lastChild = this.text(text);
} else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
lastChild = this.cdata(text);
} else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
lastChild = this.comment(text);
} else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
lastChild = this.raw(text);
} else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
} else {
lastChild = this.node(name, attributes, text);
}
}
if (lastChild == null) {
throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
}
return lastChild;
};
XMLNode.prototype.insertBefore = function(name, attributes, text) {
var child, i, newChild, refChild, removed;
if (name != null ? name.type : void 0) {
newChild = name;
refChild = attributes;
newChild.setParent(this);
if (refChild) {
i = children.indexOf(refChild);
removed = children.splice(i);
children.push(newChild);
Array.prototype.push.apply(children, removed);
} else {
children.push(newChild);
}
return newChild;
} else {
if (this.isRoot) {
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
}
i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i);
child = this.parent.element(name, attributes, text);
Array.prototype.push.apply(this.parent.children, removed);
return child;
}
};
XMLNode.prototype.insertAfter = function(name, attributes, text) {
var child, i, removed;
if (this.isRoot) {
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
}
i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i + 1);
child = this.parent.element(name, attributes, text);
Array.prototype.push.apply(this.parent.children, removed);
return child;
};
XMLNode.prototype.remove = function() {
var i, ref2;
if (this.isRoot) {
throw new Error("Cannot remove the root element. " + this.debugInfo());
}
i = this.parent.children.indexOf(this);
[].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
return this.parent;
};
XMLNode.prototype.node = function(name, attributes, text) {
var child, ref2;
if (name != null) {
name = getValue(name);
}
attributes || (attributes = {});
attributes = getValue(attributes);
if (!isObject(attributes)) {
ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
}
child = new XMLElement(this, name, attributes);
if (text != null) {
child.text(text);
}
this.children.push(child);
return child;
};
XMLNode.prototype.text = function(value) {
var child;
if (isObject(value)) {
this.element(value);
}
child = new XMLText(this, value);
this.children.push(child);
return this;
};
XMLNode.prototype.cdata = function(value) {
var child;
child = new XMLCData(this, value);
this.children.push(child);
return this;
};
XMLNode.prototype.comment = function(value) {
var child;
child = new XMLComment(this, value);
this.children.push(child);
return this;
};
XMLNode.prototype.commentBefore = function(value) {
var child, i, removed;
i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i);
child = this.parent.comment(value);
Array.prototype.push.apply(this.parent.children, removed);
return this;
};
XMLNode.prototype.commentAfter = function(value) {
var child, i, removed;
i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i + 1);
child = this.parent.comment(value);
Array.prototype.push.apply(this.parent.children, removed);
return this;
};
XMLNode.prototype.raw = function(value) {
var child;
child = new XMLRaw(this, value);
this.children.push(child);
return this;
};
XMLNode.prototype.dummy = function() {
var child;
child = new XMLDummy(this);
return child;
};
XMLNode.prototype.instruction = function(target, value) {
var insTarget, insValue, instruction, j, len;
if (target != null) {
target = getValue(target);
}
if (value != null) {
value = getValue(value);
}
if (Array.isArray(target)) {
for (j = 0, len = target.length; j < len; j++) {
insTarget = target[j];
this.instruction(insTarget);
}
} else if (isObject(target)) {
for (insTarget in target) {
if (!hasProp.call(target, insTarget)) continue;
insValue = target[insTarget];
this.instruction(insTarget, insValue);
}
} else {
if (isFunction(value)) {
value = value.apply();
}
instruction = new XMLProcessingInstruction(this, target, value);
this.children.push(instruction);
}
return this;
};
XMLNode.prototype.instructionBefore = function(target, value) {
var child, i, removed;
i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i);
child = this.parent.instruction(target, value);
Array.prototype.push.apply(this.parent.children, removed);
return this;
};
XMLNode.prototype.instructionAfter = function(target, value) {
var child, i, removed;
i = this.parent.children.indexOf(this);
removed = this.parent.children.splice(i + 1);
child = this.parent.instruction(target, value);
Array.prototype.push.apply(this.parent.children, removed);
return this;
};
XMLNode.prototype.declaration = function(version, encoding, standalone) {
var doc, xmldec;
doc = this.document();
xmldec = new XMLDeclaration(doc, version, encoding, standalone);
if (doc.children.length === 0) {
doc.children.unshift(xmldec);
} else if (doc.children[0].type === NodeType.Declaration) {
doc.children[0] = xmldec;
} else {
doc.children.unshift(xmldec);
}
return doc.root() || doc;
};
XMLNode.prototype.dtd = function(pubID, sysID) {
var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
doc = this.document();
doctype = new XMLDocType(doc, pubID, sysID);
ref2 = doc.children;
for (i = j = 0, len = ref2.length; j < len; i = ++j) {
child = ref2[i];
if (child.type === NodeType.DocType) {
doc.children[i] = doctype;
return doctype;
}
}
ref3 = doc.children;
for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
child = ref3[i];
if (child.isRoot) {
doc.children.splice(i, 0, doctype);
return doctype;
}
}
doc.children.push(doctype);
return doctype;
};
XMLNode.prototype.up = function() {
if (this.isRoot) {
throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
}
return this.parent;
};
XMLNode.prototype.root = function() {
var node;
node = this;
while (node) {
if (node.type === NodeType.Document) {
return node.rootObject;
} else if (node.isRoot) {
return node;
} else {
node = node.parent;
}
}
};
XMLNode.prototype.document = function() {
var node;
node = this;
while (node) {
if (node.type === NodeType.Document) {
return node;
} else {
node = node.parent;
}
}
};
XMLNode.prototype.end = function(options) {
return this.document().end(options);
};
XMLNode.prototype.prev = function() {
var i;
i = this.parent.children.indexOf(this);
if (i < 1) {
throw new Error("Already at the first node. " + this.debugInfo());
}
return this.parent.children[i - 1];
};
XMLNode.prototype.next = function() {
var i;
i = this.parent.children.indexOf(this);
if (i === -1 || i === this.parent.children.length - 1) {
throw new Error("Already at the last node. " + this.debugInfo());
}
return this.parent.children[i + 1];
};
XMLNode.prototype.importDocument = function(doc) {
var clonedRoot;
clonedRoot = doc.root().clone();
clonedRoot.parent = this;
clonedRoot.isRoot = false;
this.children.push(clonedRoot);
return this;
};
XMLNode.prototype.debugInfo = function(name) {
var ref2, ref3;
name = name || this.name;
if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
return "";
} else if (name == null) {
return "parent: <" + this.parent.name + ">";
} else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
return "node: <" + name + ">";
} else {
return "node: <" + name + ">, parent: <" + this.parent.name + ">";
}
};
XMLNode.prototype.ele = function(name, attributes, text) {
return this.element(name, attributes, text);
};
XMLNode.prototype.nod = function(name, attributes, text) {
return this.node(name, attributes, text);
};
XMLNode.prototype.txt = function(value) {
return this.text(value);
};
XMLNode.prototype.dat = function(value) {
return this.cdata(value);
};
XMLNode.prototype.com = function(value) {
return this.comment(value);
};
XMLNode.prototype.ins = function(target, value) {
return this.instruction(target, value);
};
XMLNode.prototype.doc = function() {
return this.document();
};
XMLNode.prototype.dec = function(version, encoding, standalone) {
return this.declaration(version, encoding, standalone);
};
XMLNode.prototype.e = function(name, attributes, text) {
return this.element(name, attributes, text);
};
XMLNode.prototype.n = function(name, attributes, text) {
return this.node(name, attributes, text);
};
XMLNode.prototype.t = function(value) {
return this.text(value);
};
XMLNode.prototype.d = function(value) {
return this.cdata(value);
};
XMLNode.prototype.c = function(value) {
return this.comment(value);
};
XMLNode.prototype.r = function(value) {
return this.raw(value);
};
XMLNode.prototype.i = function(target, value) {
return this.instruction(target, value);
};
XMLNode.prototype.u = function() {
return this.up();
};
XMLNode.prototype.importXMLBuilder = function(doc) {
return this.importDocument(doc);
};
XMLNode.prototype.replaceChild = function(newChild, oldChild) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.removeChild = function(oldChild) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.appendChild = function(newChild) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.hasChildNodes = function() {
return this.children.length !== 0;
};
XMLNode.prototype.cloneNode = function(deep) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.normalize = function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.isSupported = function(feature, version) {
return true;
};
XMLNode.prototype.hasAttributes = function() {
return this.attribs.length !== 0;
};
XMLNode.prototype.compareDocumentPosition = function(other) {
var ref, res;
ref = this;
if (ref === other) {
return 0;
} else if (this.document() !== other.document()) {
res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
if (Math.random() < 0.5) {
res |= DocumentPosition.Preceding;
} else {
res |= DocumentPosition.Following;
}
return res;
} else if (ref.isAncestor(other)) {
return DocumentPosition.Contains | DocumentPosition.Preceding;
} else if (ref.isDescendant(other)) {
return DocumentPosition.Contains | DocumentPosition.Following;
} else if (ref.isPreceding(other)) {
return DocumentPosition.Preceding;
} else {
return DocumentPosition.Following;
}
};
XMLNode.prototype.isSameNode = function(other) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.lookupPrefix = function(namespaceURI) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.isDefaultNamespace = function(namespaceURI) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.lookupNamespaceURI = function(prefix) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.isEqualNode = function(node) {
var i, j, ref2;
if (node.nodeType !== this.nodeType) {
return false;
}
if (node.children.length !== this.children.length) {
return false;
}
for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
if (!this.children[i].isEqualNode(node.children[i])) {
return false;
}
}
return true;
};
XMLNode.prototype.getFeature = function(feature, version) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.setUserData = function(key, data, handler) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.getUserData = function(key) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLNode.prototype.contains = function(other) {
if (!other) {
return false;
}
return other === this || this.isDescendant(other);
};
XMLNode.prototype.isDescendant = function(node) {
var child, isDescendantChild, j, len, ref2;
ref2 = this.children;
for (j = 0, len = ref2.length; j < len; j++) {
child = ref2[j];
if (node === child) {
return true;
}
isDescendantChild = child.isDescendant(node);
if (isDescendantChild) {
return true;
}
}
return false;
};
XMLNode.prototype.isAncestor = function(node) {
return node.isDescendant(this);
};
XMLNode.prototype.isPreceding = function(node) {
var nodePos, thisPos;
nodePos = this.treePosition(node);
thisPos = this.treePosition(this);
if (nodePos === -1 || thisPos === -1) {
return false;
} else {
return nodePos < thisPos;
}
};
XMLNode.prototype.isFollowing = function(node) {
var nodePos, thisPos;
nodePos = this.treePosition(node);
thisPos = this.treePosition(this);
if (nodePos === -1 || thisPos === -1) {
return false;
} else {
return nodePos > thisPos;
}
};
XMLNode.prototype.treePosition = function(node) {
var found, pos;
pos = 0;
found = false;
this.foreachTreeNode(this.document(), function(childNode) {
pos++;
if (!found && childNode === node) {
return found = true;
}
});
if (found) {
return pos;
} else {
return -1;
}
};
XMLNode.prototype.foreachTreeNode = function(node, func) {
var child, j, len, ref2, res;
node || (node = this.document());
ref2 = node.children;
for (j = 0, len = ref2.length; j < len; j++) {
child = ref2[j];
if (res = func(child)) {
return res;
} else {
res = this.foreachTreeNode(child, func);
if (res) {
return res;
}
}
}
};
return XMLNode;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLNode.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 5,518 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDTDAttList, XMLNode,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
module.exports = XMLDTDAttList = (function(superClass) {
extend(XMLDTDAttList, superClass);
function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
XMLDTDAttList.__super__.constructor.call(this, parent);
if (elementName == null) {
throw new Error("Missing DTD element name. " + this.debugInfo());
}
if (attributeName == null) {
throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
}
if (!attributeType) {
throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
}
if (!defaultValueType) {
throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
}
if (defaultValueType.indexOf('#') !== 0) {
defaultValueType = '#' + defaultValueType;
}
if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
}
if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
}
this.elementName = this.stringify.name(elementName);
this.type = NodeType.AttributeDeclaration;
this.attributeName = this.stringify.name(attributeName);
this.attributeType = this.stringify.dtdAttType(attributeType);
if (defaultValue) {
this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
}
this.defaultValueType = defaultValueType;
}
XMLDTDAttList.prototype.toString = function(options) {
return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
};
return XMLDTDAttList;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDTDAttList.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 539 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = {
Restriction: 1,
Extension: 2,
Union: 4,
List: 8
};
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/Derivation.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 52 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLCData, XMLCharacterData,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
NodeType = require('./NodeType');
XMLCharacterData = require('./XMLCharacterData');
module.exports = XMLCData = (function(superClass) {
extend(XMLCData, superClass);
function XMLCData(parent, text) {
XMLCData.__super__.constructor.call(this, parent);
if (text == null) {
throw new Error("Missing CDATA text. " + this.debugInfo());
}
this.name = "#cdata-section";
this.type = NodeType.CData;
this.value = this.stringify.cdata(text);
}
XMLCData.prototype.clone = function() {
return Object.create(this);
};
XMLCData.prototype.toString = function(options) {
return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
};
return XMLCData;
})(XMLCharacterData);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLCData.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 285 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLDocumentFragment, XMLNode,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
module.exports = XMLDocumentFragment = (function(superClass) {
extend(XMLDocumentFragment, superClass);
function XMLDocumentFragment() {
XMLDocumentFragment.__super__.constructor.call(this, null);
this.name = "#document-fragment";
this.type = NodeType.DocumentFragment;
}
return XMLDocumentFragment;
})(XMLNode);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLDocumentFragment.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 195 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var NodeType, XMLCharacterData, XMLText,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
NodeType = require('./NodeType');
XMLCharacterData = require('./XMLCharacterData');
module.exports = XMLText = (function(superClass) {
extend(XMLText, superClass);
function XMLText(parent, text) {
XMLText.__super__.constructor.call(this, parent);
if (text == null) {
throw new Error("Missing element text. " + this.debugInfo());
}
this.name = "#text";
this.type = NodeType.Text;
this.value = this.stringify.text(text);
}
Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
get: function() {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
});
Object.defineProperty(XMLText.prototype, 'wholeText', {
get: function() {
var next, prev, str;
str = '';
prev = this.previousSibling;
while (prev) {
str = prev.data + str;
prev = prev.previousSibling;
}
str += this.data;
next = this.nextSibling;
while (next) {
str = str + next.data;
next = next.nextSibling;
}
return str;
}
});
XMLText.prototype.clone = function() {
return Object.create(this);
};
XMLText.prototype.toString = function(options) {
return this.options.writer.text(this, this.options.writer.filterOptions(options));
};
XMLText.prototype.splitText = function(offset) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
XMLText.prototype.replaceWholeText = function(content) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
};
return XMLText;
})(XMLCharacterData);
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLText.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 475 |
```javascript
// Generated by CoffeeScript 1.12.7
(function() {
var XMLNodeList;
module.exports = XMLNodeList = (function() {
function XMLNodeList(nodes) {
this.nodes = nodes;
}
Object.defineProperty(XMLNodeList.prototype, 'length', {
get: function() {
return this.nodes.length || 0;
}
});
XMLNodeList.prototype.clone = function() {
return this.nodes = null;
};
XMLNodeList.prototype.item = function(index) {
return this.nodes[index] || null;
};
return XMLNodeList;
})();
}).call(this);
``` | /content/code_sandbox/node_modules/xmlbuilder/lib/XMLNodeList.js | javascript | 2016-03-11T09:28:00 | 2024-08-16T17:55:54 | antSword | AntSwordProject/antSword | 3,579 | 135 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.