From 2401fbd93f0d61cc01150c1071145e974dd6693f Mon Sep 17 00:00:00 2001 From: Azat Alimov <32402726+mkslanc@users.noreply.github.com> Date: Tue, 30 Aug 2022 18:41:30 +0400 Subject: [PATCH] fix: Updated Jshint to 2.13.5 (#4911) * update jshint.js to 2.13.5 * add instruction on how to update `jshint` lib --- lib/ace/mode/javascript/jshint.js | 5475 ++++++++++++++++------------- tool/Readme.md | 16 +- 2 files changed, 3026 insertions(+), 2465 deletions(-) diff --git a/lib/ace/mode/javascript/jshint.js b/lib/ace/mode/javascript/jshint.js index 3aa24224034..6b9535d9886 100644 --- a/lib/ace/mode/javascript/jshint.js +++ b/lib/ace/mode/javascript/jshint.js @@ -1,6 +1,5 @@ define(function(require, exports, module) { -module.exports = (function() { -function outer(modules, cache, entry) { +module.exports = (function outer (modules, cache, entry) { var previousRequire = typeof require == "function" && require; function newRequire(name, jumped){ if(!cache[name]) { @@ -22,10 +21,8 @@ function outer(modules, cache, entry) { } for(var i=0;i @@ -1920,7 +1917,7 @@ function stubFalse() { module.exports = clone; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],"/../../jshint/node_modules/lodash.slice/index.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/node_modules/lodash.slice/index.js":[function(_dereq_,module,exports){ /** * lodash (Custom Build) * Build: `lodash modularize exports="npm" -o ./` @@ -2384,32 +2381,30 @@ function toNumber(value) { module.exports = slice; -},{}],"/../../jshint/node_modules/underscore/underscore.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/node_modules/underscore/underscore-umd.js":[function(_dereq_,module,exports){ (function (global){ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define('underscore', factory) : - (function() { - var current = global._; - var exports = factory(); - global._ = exports; - exports.noConflict = function() { global._ = current; return exports; }; - })(); + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () { + var current = global._; + var exports = global._ = factory(); + exports.noConflict = function () { global._ = current; return exports; }; + }())); }(this, (function () { - - // Underscore.js 1.10.2 + // Underscore.js 1.13.4 // https://underscorejs.org - // (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + // (c) 2009-2022 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. - // Baseline setup - // -------------- + // Current version. + var VERSION = '1.13.4'; // Establish the root object, `window` (`self`) in the browser, `global` // on the server, or `this` in some virtual machines. We use `self` // instead of `window` for `WebWorker` support. - var root = typeof self == 'object' && self.self === self && self || - typeof global == 'object' && global.global === global && global || + var root = (typeof self == 'object' && self.self === self && self) || + (typeof global == 'object' && global.global === global && global) || Function('return this')() || {}; @@ -2423,76 +2418,28 @@ module.exports = slice; toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; - // All **ECMAScript 5** native function implementations that we hope to use + // Modern feature detection. + var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', + supportsDataView = typeof DataView !== 'undefined'; + + // All **ECMAScript 5+** native function implementations that we hope to use // are declared here. var nativeIsArray = Array.isArray, nativeKeys = Object.keys, - nativeCreate = Object.create; + nativeCreate = Object.create, + nativeIsView = supportsArrayBuffer && ArrayBuffer.isView; // Create references to these builtin functions because we override them. - var _isNaN = root.isNaN, - _isFinite = root.isFinite; - - // Naked function reference for surrogate-prototype-swapping. - var Ctor = function(){}; - - // The Underscore object. All exported functions below are added to it in the - // modules/index-all.js using the mixin function. - function _(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - } - - // Current version. - var VERSION = _.VERSION = '1.10.2'; - - // Internal function that returns an efficient (for current engines) version - // of the passed-in callback, to be repeatedly applied in other Underscore - // functions. - function optimizeCb(func, context, argCount) { - if (context === void 0) return func; - switch (argCount == null ? 3 : argCount) { - case 1: return function(value) { - return func.call(context, value); - }; - // The 2-argument case is omitted because we’re not using it. - case 3: return function(value, index, collection) { - return func.call(context, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(context, accumulator, value, index, collection); - }; - } - return function() { - return func.apply(context, arguments); - }; - } - - // An internal function to generate callbacks that can be applied to each - // element in a collection, returning the desired result — either `identity`, - // an arbitrary callback, a property matcher, or a property accessor. - function baseIteratee(value, context, argCount) { - if (value == null) return identity; - if (isFunction(value)) return optimizeCb(value, context, argCount); - if (isObject(value) && !isArray(value)) return matcher(value); - return property(value); - } + var _isNaN = isNaN, + _isFinite = isFinite; - // External wrapper for our callback generator. Users may customize - // `_.iteratee` if they want additional predicate/iteratee shorthand styles. - // This abstraction hides the internal-only argCount argument. - _.iteratee = iteratee; - function iteratee(value, context) { - return baseIteratee(value, context, Infinity); - } + // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. + var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - // The function we actually call internally. It invokes _.iteratee if - // overridden, otherwise baseIteratee. - function cb(value, context, argCount) { - if (_.iteratee !== iteratee) return _.iteratee(value, context); - return baseIteratee(value, context, argCount); - } + // The largest integer that can be represented exactly. + var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; // Some functions take a variable number of arguments, or a few expected // arguments at the beginning and then a variable number of values to operate @@ -2522,893 +2469,680 @@ module.exports = slice; }; } - // An internal function for creating a new object that inherits from another. - function baseCreate(prototype) { - if (!isObject(prototype)) return {}; - if (nativeCreate) return nativeCreate(prototype); - Ctor.prototype = prototype; - var result = new Ctor; - Ctor.prototype = null; - return result; + // Is a given variable an object? + function isObject(obj) { + var type = typeof obj; + return type === 'function' || (type === 'object' && !!obj); } - function shallowProperty(key) { - return function(obj) { - return obj == null ? void 0 : obj[key]; - }; + // Is a given value equal to null? + function isNull(obj) { + return obj === null; } - function _has(obj, path) { - return obj != null && hasOwnProperty.call(obj, path); + // Is a given variable undefined? + function isUndefined(obj) { + return obj === void 0; } - function deepGet(obj, path) { - var length = path.length; - for (var i = 0; i < length; i++) { - if (obj == null) return void 0; - obj = obj[path[i]]; - } - return length ? obj : void 0; + // Is a given value a boolean? + function isBoolean(obj) { + return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; } - // Helper for collection methods to determine whether a collection - // should be iterated as an array or as an object. - // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength - // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 - var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; - var getLength = shallowProperty('length'); - function isArrayLike(collection) { - var length = getLength(collection); - return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX; + // Is a given value a DOM element? + function isElement(obj) { + return !!(obj && obj.nodeType === 1); } - // Collection Functions - // -------------------- - - // The cornerstone, an `each` implementation, aka `forEach`. - // Handles raw objects in addition to array-likes. Treats all - // sparse array-likes as if they were dense. - function each(obj, iteratee, context) { - iteratee = optimizeCb(iteratee, context); - var i, length; - if (isArrayLike(obj)) { - for (i = 0, length = obj.length; i < length; i++) { - iteratee(obj[i], i, obj); - } - } else { - var _keys = keys(obj); - for (i = 0, length = _keys.length; i < length; i++) { - iteratee(obj[_keys[i]], _keys[i], obj); - } - } - return obj; + // Internal function for creating a `toString`-based type tester. + function tagTester(name) { + var tag = '[object ' + name + ']'; + return function(obj) { + return toString.call(obj) === tag; + }; } - // Return the results of applying the iteratee to each element. - function map(obj, iteratee, context) { - iteratee = cb(iteratee, context); - var _keys = !isArrayLike(obj) && keys(obj), - length = (_keys || obj).length, - results = Array(length); - for (var index = 0; index < length; index++) { - var currentKey = _keys ? _keys[index] : index; - results[index] = iteratee(obj[currentKey], currentKey, obj); - } - return results; - } + var isString = tagTester('String'); - // Create a reducing function iterating left or right. - function createReduce(dir) { - // Wrap code that reassigns argument variables in a separate function than - // the one that accesses `arguments.length` to avoid a perf hit. (#1991) - var reducer = function(obj, iteratee, memo, initial) { - var _keys = !isArrayLike(obj) && keys(obj), - length = (_keys || obj).length, - index = dir > 0 ? 0 : length - 1; - if (!initial) { - memo = obj[_keys ? _keys[index] : index]; - index += dir; - } - for (; index >= 0 && index < length; index += dir) { - var currentKey = _keys ? _keys[index] : index; - memo = iteratee(memo, obj[currentKey], currentKey, obj); - } - return memo; - }; + var isNumber = tagTester('Number'); - return function(obj, iteratee, memo, context) { - var initial = arguments.length >= 3; - return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); + var isDate = tagTester('Date'); + + var isRegExp = tagTester('RegExp'); + + var isError = tagTester('Error'); + + var isSymbol = tagTester('Symbol'); + + var isArrayBuffer = tagTester('ArrayBuffer'); + + var isFunction = tagTester('Function'); + + // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old + // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). + var nodelist = root.document && root.document.childNodes; + if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { + isFunction = function(obj) { + return typeof obj == 'function' || false; }; } - // **Reduce** builds up a single result from a list of values, aka `inject`, - // or `foldl`. - var reduce = createReduce(1); + var isFunction$1 = isFunction; - // The right-associative version of reduce, also known as `foldr`. - var reduceRight = createReduce(-1); + var hasObjectTag = tagTester('Object'); - // Return the first value which passes a truth test. - function find(obj, predicate, context) { - var keyFinder = isArrayLike(obj) ? findIndex : findKey; - var key = keyFinder(obj, predicate, context); - if (key !== void 0 && key !== -1) return obj[key]; - } + // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`. + // In IE 11, the most common among them, this problem also applies to + // `Map`, `WeakMap` and `Set`. + var hasStringTagBug = ( + supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8))) + ), + isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map)); - // Return all the elements that pass a truth test. - function filter(obj, predicate, context) { - var results = []; - predicate = cb(predicate, context); - each(obj, function(value, index, list) { - if (predicate(value, index, list)) results.push(value); - }); - return results; + var isDataView = tagTester('DataView'); + + // In IE 10 - Edge 13, we need a different heuristic + // to determine whether an object is a `DataView`. + function ie10IsDataView(obj) { + return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer); } - // Return all the elements for which a truth test fails. - function reject(obj, predicate, context) { - return filter(obj, negate(cb(predicate)), context); + var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView); + + // Is a given value an array? + // Delegates to ECMA5's native `Array.isArray`. + var isArray = nativeIsArray || tagTester('Array'); + + // Internal function to check whether `key` is an own property name of `obj`. + function has$1(obj, key) { + return obj != null && hasOwnProperty.call(obj, key); } - // Determine whether all of the elements match a truth test. - function every(obj, predicate, context) { - predicate = cb(predicate, context); - var _keys = !isArrayLike(obj) && keys(obj), - length = (_keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = _keys ? _keys[index] : index; - if (!predicate(obj[currentKey], currentKey, obj)) return false; + var isArguments = tagTester('Arguments'); + + // Define a fallback version of the method in browsers (ahem, IE < 9), where + // there isn't any inspectable "Arguments" type. + (function() { + if (!isArguments(arguments)) { + isArguments = function(obj) { + return has$1(obj, 'callee'); + }; } - return true; + }()); + + var isArguments$1 = isArguments; + + // Is a given object a finite number? + function isFinite$1(obj) { + return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj)); } - // Determine if at least one element in the object matches a truth test. - function some(obj, predicate, context) { - predicate = cb(predicate, context); - var _keys = !isArrayLike(obj) && keys(obj), - length = (_keys || obj).length; - for (var index = 0; index < length; index++) { - var currentKey = _keys ? _keys[index] : index; - if (predicate(obj[currentKey], currentKey, obj)) return true; - } - return false; + // Is the given value `NaN`? + function isNaN$1(obj) { + return isNumber(obj) && _isNaN(obj); } - // Determine if the array or object contains a given item (using `===`). - function contains(obj, item, fromIndex, guard) { - if (!isArrayLike(obj)) obj = values(obj); - if (typeof fromIndex != 'number' || guard) fromIndex = 0; - return indexOf(obj, item, fromIndex) >= 0; + // Predicate-generating function. Often useful outside of Underscore. + function constant(value) { + return function() { + return value; + }; } - // Invoke a method (with arguments) on every item in a collection. - var invoke = restArguments(function(obj, path, args) { - var contextPath, func; - if (isFunction(path)) { - func = path; - } else if (isArray(path)) { - contextPath = path.slice(0, -1); - path = path[path.length - 1]; + // Common internal logic for `isArrayLike` and `isBufferLike`. + function createSizePropertyCheck(getSizeProperty) { + return function(collection) { + var sizeProperty = getSizeProperty(collection); + return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX; } - return map(obj, function(context) { - var method = func; - if (!method) { - if (contextPath && contextPath.length) { - context = deepGet(context, contextPath); - } - if (context == null) return void 0; - method = context[path]; - } - return method == null ? method : method.apply(context, args); - }); - }); - - // Convenience version of a common use case of `map`: fetching a property. - function pluck(obj, key) { - return map(obj, property(key)); } - // Convenience version of a common use case of `filter`: selecting only objects - // containing specific `key:value` pairs. - function where(obj, attrs) { - return filter(obj, matcher(attrs)); + // Internal helper to generate a function to obtain property `key` from `obj`. + function shallowProperty(key) { + return function(obj) { + return obj == null ? void 0 : obj[key]; + }; } - // Convenience version of a common use case of `find`: getting the first object - // containing specific `key:value` pairs. - function findWhere(obj, attrs) { - return find(obj, matcher(attrs)); - } + // Internal helper to obtain the `byteLength` property of an object. + var getByteLength = shallowProperty('byteLength'); - // Return the maximum element (or element-based computation). - function max(obj, iteratee, context) { - var result = -Infinity, lastComputed = -Infinity, - value, computed; - if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { - obj = isArrayLike(obj) ? obj : values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value != null && value > result) { - result = value; - } - } - } else { - iteratee = cb(iteratee, context); - each(obj, function(v, index, list) { - computed = iteratee(v, index, list); - if (computed > lastComputed || computed === -Infinity && result === -Infinity) { - result = v; - lastComputed = computed; - } - }); - } - return result; - } + // Internal helper to determine whether we should spend extensive checks against + // `ArrayBuffer` et al. + var isBufferLike = createSizePropertyCheck(getByteLength); - // Return the minimum element (or element-based computation). - function min(obj, iteratee, context) { - var result = Infinity, lastComputed = Infinity, - value, computed; - if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { - obj = isArrayLike(obj) ? obj : values(obj); - for (var i = 0, length = obj.length; i < length; i++) { - value = obj[i]; - if (value != null && value < result) { - result = value; - } - } - } else { - iteratee = cb(iteratee, context); - each(obj, function(v, index, list) { - computed = iteratee(v, index, list); - if (computed < lastComputed || computed === Infinity && result === Infinity) { - result = v; - lastComputed = computed; - } - }); - } - return result; + // Is a given value a typed array? + var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/; + function isTypedArray(obj) { + // `ArrayBuffer.isView` is the most future-proof, so use it when available. + // Otherwise, fall back on the above regular expression. + return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) : + isBufferLike(obj) && typedArrayPattern.test(toString.call(obj)); } - // Shuffle a collection. - function shuffle(obj) { - return sample(obj, Infinity); - } + var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false); - // Sample **n** random values from a collection using the modern version of the - // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle). - // If **n** is not specified, returns a single random element. - // The internal `guard` argument allows it to work with `map`. - function sample(obj, n, guard) { - if (n == null || guard) { - if (!isArrayLike(obj)) obj = values(obj); - return obj[random(obj.length - 1)]; - } - var sample = isArrayLike(obj) ? clone(obj) : values(obj); - var length = getLength(sample); - n = Math.max(Math.min(n, length), 0); - var last = length - 1; - for (var index = 0; index < n; index++) { - var rand = random(index, last); - var temp = sample[index]; - sample[index] = sample[rand]; - sample[rand] = temp; - } - return sample.slice(0, n); - } + // Internal helper to obtain the `length` property of an object. + var getLength = shallowProperty('length'); - // Sort the object's values by a criterion produced by an iteratee. - function sortBy(obj, iteratee, context) { - var index = 0; - iteratee = cb(iteratee, context); - return pluck(map(obj, function(value, key, list) { - return { - value: value, - index: index++, - criteria: iteratee(value, key, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; + // Internal helper to create a simple lookup structure. + // `collectNonEnumProps` used to depend on `_.contains`, but this led to + // circular imports. `emulatedSet` is a one-off solution that only works for + // arrays of strings. + function emulatedSet(keys) { + var hash = {}; + for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true; + return { + contains: function(key) { return hash[key] === true; }, + push: function(key) { + hash[key] = true; + return keys.push(key); } - return left.index - right.index; - }), 'value'); - } - - // An internal function used for aggregate "group by" operations. - function group(behavior, partition) { - return function(obj, iteratee, context) { - var result = partition ? [[], []] : {}; - iteratee = cb(iteratee, context); - each(obj, function(value, index) { - var key = iteratee(value, index, obj); - behavior(result, value, key); - }); - return result; }; } - // Groups the object's values by a criterion. Pass either a string attribute - // to group by, or a function that returns the criterion. - var groupBy = group(function(result, value, key) { - if (_has(result, key)) result[key].push(value); else result[key] = [value]; - }); - - // Indexes the object's values by a criterion, similar to `groupBy`, but for - // when you know that your index values will be unique. - var indexBy = group(function(result, value, key) { - result[key] = value; - }); + // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't + // be iterated by `for key in ...` and thus missed. Extends `keys` in place if + // needed. + function collectNonEnumProps(obj, keys) { + keys = emulatedSet(keys); + var nonEnumIdx = nonEnumerableProps.length; + var constructor = obj.constructor; + var proto = (isFunction$1(constructor) && constructor.prototype) || ObjProto; - // Counts instances of an object that group by a certain criterion. Pass - // either a string attribute to count by, or a function that returns the - // criterion. - var countBy = group(function(result, value, key) { - if (_has(result, key)) result[key]++; else result[key] = 1; - }); + // Constructor is a special case. + var prop = 'constructor'; + if (has$1(obj, prop) && !keys.contains(prop)) keys.push(prop); - var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; - // Safely create a real, live array from anything iterable. - function toArray(obj) { - if (!obj) return []; - if (isArray(obj)) return slice.call(obj); - if (isString(obj)) { - // Keep surrogate pair characters together - return obj.match(reStrSymbol); + while (nonEnumIdx--) { + prop = nonEnumerableProps[nonEnumIdx]; + if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) { + keys.push(prop); + } } - if (isArrayLike(obj)) return map(obj, identity); - return values(obj); } - // Return the number of elements in an object. - function size(obj) { - if (obj == null) return 0; - return isArrayLike(obj) ? obj.length : keys(obj).length; + // Retrieve the names of an object's own properties. + // Delegates to **ECMAScript 5**'s native `Object.keys`. + function keys(obj) { + if (!isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) if (has$1(obj, key)) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; } - // Split a collection into two arrays: one whose elements all satisfy the given - // predicate, and one whose elements all do not satisfy the predicate. - var partition = group(function(result, value, pass) { - result[pass ? 0 : 1].push(value); - }, true); - - // Array Functions - // --------------- - - // Get the first element of an array. Passing **n** will return the first N - // values in the array. The **guard** check allows it to work with `map`. - function first(array, n, guard) { - if (array == null || array.length < 1) return n == null ? void 0 : []; - if (n == null || guard) return array[0]; - return initial(array, array.length - n); + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + function isEmpty(obj) { + if (obj == null) return true; + // Skip the more expensive `toString`-based type checks if `obj` has no + // `.length`. + var length = getLength(obj); + if (typeof length == 'number' && ( + isArray(obj) || isString(obj) || isArguments$1(obj) + )) return length === 0; + return getLength(keys(obj)) === 0; } - // Returns everything but the last entry of the array. Especially useful on - // the arguments object. Passing **n** will return all the values in - // the array, excluding the last N. - function initial(array, n, guard) { - return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); + // Returns whether an object has a given set of `key:value` pairs. + function isMatch(object, attrs) { + var _keys = keys(attrs), length = _keys.length; + if (object == null) return !length; + var obj = Object(object); + for (var i = 0; i < length; i++) { + var key = _keys[i]; + if (attrs[key] !== obj[key] || !(key in obj)) return false; + } + return true; } - // Get the last element of an array. Passing **n** will return the last N - // values in the array. - function last(array, n, guard) { - if (array == null || array.length < 1) return n == null ? void 0 : []; - if (n == null || guard) return array[array.length - 1]; - return rest(array, Math.max(0, array.length - n)); + // If Underscore is called as a function, it returns a wrapped object that can + // be used OO-style. This wrapper holds altered versions of all functions added + // through `_.mixin`. Wrapped objects may be chained. + function _$1(obj) { + if (obj instanceof _$1) return obj; + if (!(this instanceof _$1)) return new _$1(obj); + this._wrapped = obj; } - // Returns everything but the first entry of the array. Especially useful on - // the arguments object. Passing an **n** will return the rest N values in the - // array. - function rest(array, n, guard) { - return slice.call(array, n == null || guard ? 1 : n); - } + _$1.VERSION = VERSION; - // Trim out all falsy values from an array. - function compact(array) { - return filter(array, Boolean); - } + // Extracts the result from a wrapped and chained object. + _$1.prototype.value = function() { + return this._wrapped; + }; - // Internal implementation of a recursive `flatten` function. - function _flatten(input, shallow, strict, output) { - output = output || []; - var idx = output.length; - for (var i = 0, length = getLength(input); i < length; i++) { - var value = input[i]; - if (isArrayLike(value) && (isArray(value) || isArguments(value))) { - // Flatten current level of array or arguments object. - if (shallow) { - var j = 0, len = value.length; - while (j < len) output[idx++] = value[j++]; - } else { - _flatten(value, shallow, strict, output); - idx = output.length; - } - } else if (!strict) { - output[idx++] = value; - } - } - return output; - } + // Provide unwrapping proxies for some methods used in engine operations + // such as arithmetic and JSON stringification. + _$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value; + + _$1.prototype.toString = function() { + return String(this._wrapped); + }; - // Flatten out an array, either recursively (by default), or just one level. - function flatten(array, shallow) { - return _flatten(array, shallow, false); + // Internal function to wrap or shallow-copy an ArrayBuffer, + // typed array or DataView to a new view, reusing the buffer. + function toBufferView(bufferSource) { + return new Uint8Array( + bufferSource.buffer || bufferSource, + bufferSource.byteOffset || 0, + getByteLength(bufferSource) + ); } - // Return a version of the array that does not contain the specified value(s). - var without = restArguments(function(array, otherArrays) { - return difference(array, otherArrays); - }); + // We use this string twice, so give it a name for minification. + var tagDataView = '[object DataView]'; - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - // The faster algorithm will not work with an iteratee if the iteratee - // is not a one-to-one function, so providing an iteratee will disable - // the faster algorithm. - function uniq(array, isSorted, iteratee, context) { - if (!isBoolean(isSorted)) { - context = iteratee; - iteratee = isSorted; - isSorted = false; - } - if (iteratee != null) iteratee = cb(iteratee, context); - var result = []; - var seen = []; - for (var i = 0, length = getLength(array); i < length; i++) { - var value = array[i], - computed = iteratee ? iteratee(value, i, array) : value; - if (isSorted && !iteratee) { - if (!i || seen !== computed) result.push(value); - seen = computed; - } else if (iteratee) { - if (!contains(seen, computed)) { - seen.push(computed); - result.push(value); - } - } else if (!contains(result, value)) { - result.push(value); - } - } - return result; + // Internal recursive comparison function for `_.isEqual`. + function eq(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a === 1 / b; + // `null` or `undefined` only equal to itself (strict comparison). + if (a == null || b == null) return false; + // `NaN`s are equivalent, but non-reflexive. + if (a !== a) return b !== b; + // Exhaust primitive checks + var type = typeof a; + if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; + return deepEq(a, b, aStack, bStack); } - // Produce an array that contains the union: each distinct element from all of - // the passed-in arrays. - var union = restArguments(function(arrays) { - return uniq(_flatten(arrays, true, true)); - }); - - // Produce an array that contains every item shared between all the - // passed-in arrays. - function intersection(array) { - var result = []; - var argsLength = arguments.length; - for (var i = 0, length = getLength(array); i < length; i++) { - var item = array[i]; - if (contains(result, item)) continue; - var j; - for (j = 1; j < argsLength; j++) { - if (!contains(arguments[j], item)) break; - } - if (j === argsLength) result.push(item); + // Internal recursive comparison function for `_.isEqual`. + function deepEq(a, b, aStack, bStack) { + // Unwrap any wrapped objects. + if (a instanceof _$1) a = a._wrapped; + if (b instanceof _$1) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className !== toString.call(b)) return false; + // Work around a bug in IE 10 - Edge 13. + if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) { + if (!isDataView$1(b)) return false; + className = tagDataView; + } + switch (className) { + // These types are compared by value. + case '[object RegExp]': + // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return '' + a === '' + b; + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. + // Object(NaN) is equivalent to NaN. + if (+a !== +a) return +b !== +b; + // An `egal` comparison is performed for other numeric values. + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a === +b; + case '[object Symbol]': + return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); + case '[object ArrayBuffer]': + case tagDataView: + // Coerce to typed array so we can fall through. + return deepEq(toBufferView(a), toBufferView(b), aStack, bStack); } - return result; - } - // Take the difference between one array and a number of other arrays. - // Only the elements present in just the first array will remain. - var difference = restArguments(function(array, rest) { - rest = _flatten(rest, true, true); - return filter(array, function(value){ - return !contains(rest, value); - }); - }); + var areArrays = className === '[object Array]'; + if (!areArrays && isTypedArray$1(a)) { + var byteLength = getByteLength(a); + if (byteLength !== getByteLength(b)) return false; + if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true; + areArrays = true; + } + if (!areArrays) { + if (typeof a != 'object' || typeof b != 'object') return false; - // Complement of zip. Unzip accepts an array of arrays and groups - // each array's elements on shared indices. - function unzip(array) { - var length = array && max(array, getLength).length || 0; - var result = Array(length); + // Objects with different constructors are not equivalent, but `Object`s or `Array`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor && + isFunction$1(bCtor) && bCtor instanceof bCtor) + && ('constructor' in a && 'constructor' in b)) { + return false; + } + } + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - for (var index = 0; index < length; index++) { - result[index] = pluck(array, index); + // Initializing stack of traversed objects. + // It's done here since we only need them for objects and arrays comparison. + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] === a) return bStack[length] === b; } - return result; - } - // Zip together multiple lists into a single array -- elements that share - // an index go together. - var zip = restArguments(unzip); + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); - // Converts lists into objects. Pass either a single array of `[key, value]` - // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. Passing by pairs is the reverse of pairs. - function object(list, values) { - var result = {}; - for (var i = 0, length = getLength(list); i < length; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; + // Recursively compare objects and arrays. + if (areArrays) { + // Compare array lengths to determine if a deep comparison is necessary. + length = a.length; + if (length !== b.length) return false; + // Deep compare the contents, ignoring non-numeric properties. + while (length--) { + if (!eq(a[length], b[length], aStack, bStack)) return false; + } + } else { + // Deep compare objects. + var _keys = keys(a), key; + length = _keys.length; + // Ensure that both objects contain the same number of properties before comparing deep equality. + if (keys(b).length !== length) return false; + while (length--) { + // Deep compare each member + key = _keys[length]; + if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false; } } - return result; + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return true; } - // Generator function to create the findIndex and findLastIndex functions. - function createPredicateIndexFinder(dir) { - return function(array, predicate, context) { - predicate = cb(predicate, context); - var length = getLength(array); - var index = dir > 0 ? 0 : length - 1; - for (; index >= 0 && index < length; index += dir) { - if (predicate(array[index], index, array)) return index; - } - return -1; - }; + // Perform a deep comparison to check if two objects are equal. + function isEqual(a, b) { + return eq(a, b); } - // Returns the first index on an array-like that passes a predicate test. - var findIndex = createPredicateIndexFinder(1); - var findLastIndex = createPredicateIndexFinder(-1); - - // Use a comparator function to figure out the smallest index at which - // an object should be inserted so as to maintain order. Uses binary search. - function sortedIndex(array, obj, iteratee, context) { - iteratee = cb(iteratee, context, 1); - var value = iteratee(obj); - var low = 0, high = getLength(array); - while (low < high) { - var mid = Math.floor((low + high) / 2); - if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; - } - return low; + // Retrieve all the enumerable property names of an object. + function allKeys(obj) { + if (!isObject(obj)) return []; + var keys = []; + for (var key in obj) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; } - // Generator function to create the indexOf and lastIndexOf functions. - function createIndexFinder(dir, predicateFind, sortedIndex) { - return function(array, item, idx) { - var i = 0, length = getLength(array); - if (typeof idx == 'number') { - if (dir > 0) { - i = idx >= 0 ? idx : Math.max(idx + length, i); - } else { - length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; - } - } else if (sortedIndex && idx && length) { - idx = sortedIndex(array, item); - return array[idx] === item ? idx : -1; - } - if (item !== item) { - idx = predicateFind(slice.call(array, i, length), isNaN); - return idx >= 0 ? idx + i : -1; - } - for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { - if (array[idx] === item) return idx; + // Since the regular `Object.prototype.toString` type tests don't work for + // some types in IE 11, we use a fingerprinting heuristic instead, based + // on the methods. It's not great, but it's the best we got. + // The fingerprint method lists are defined below. + function ie11fingerprint(methods) { + var length = getLength(methods); + return function(obj) { + if (obj == null) return false; + // `Map`, `WeakMap` and `Set` have no enumerable keys. + var keys = allKeys(obj); + if (getLength(keys)) return false; + for (var i = 0; i < length; i++) { + if (!isFunction$1(obj[methods[i]])) return false; } - return -1; + // If we are testing against `WeakMap`, we need to ensure that + // `obj` doesn't have a `forEach` method in order to distinguish + // it from a regular `Map`. + return methods !== weakMapMethods || !isFunction$1(obj[forEachName]); }; } - // Return the position of the first occurrence of an item in an array, - // or -1 if the item is not included in the array. - // If the array is large and already in sort order, pass `true` - // for **isSorted** to use binary search. - var indexOf = createIndexFinder(1, findIndex, sortedIndex); - var lastIndexOf = createIndexFinder(-1, findLastIndex); + // In the interest of compact minification, we write + // each string in the fingerprints only once. + var forEachName = 'forEach', + hasName = 'has', + commonInit = ['clear', 'delete'], + mapTail = ['get', hasName, 'set']; - // Generate an integer Array containing an arithmetic progression. A port of - // the native Python `range()` function. See - // [the Python documentation](https://docs.python.org/library/functions.html#range). - function range(start, stop, step) { - if (stop == null) { - stop = start || 0; - start = 0; - } - if (!step) { - step = stop < start ? -1 : 1; - } + // `Map`, `WeakMap` and `Set` each have slightly different + // combinations of the above sublists. + var mapMethods = commonInit.concat(forEachName, mapTail), + weakMapMethods = commonInit.concat(mapTail), + setMethods = ['add'].concat(commonInit, forEachName, hasName); - var length = Math.max(Math.ceil((stop - start) / step), 0); - var range = Array(length); + var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map'); - for (var idx = 0; idx < length; idx++, start += step) { - range[idx] = start; + var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap'); + + var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set'); + + var isWeakSet = tagTester('WeakSet'); + + // Retrieve the values of an object's properties. + function values(obj) { + var _keys = keys(obj); + var length = _keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[_keys[i]]; } + return values; + } - return range; + // Convert an object into a list of `[key, value]` pairs. + // The opposite of `_.object` with one argument. + function pairs(obj) { + var _keys = keys(obj); + var length = _keys.length; + var pairs = Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [_keys[i], obj[_keys[i]]]; + } + return pairs; } - // Chunk a single array into multiple arrays, each containing `count` or fewer - // items. - function chunk(array, count) { - if (count == null || count < 1) return []; - var result = []; - var i = 0, length = array.length; - while (i < length) { - result.push(slice.call(array, i, i += count)); + // Invert the keys and values of an object. The values must be serializable. + function invert(obj) { + var result = {}; + var _keys = keys(obj); + for (var i = 0, length = _keys.length; i < length; i++) { + result[obj[_keys[i]]] = _keys[i]; } return result; } - // Function (ahem) Functions - // ------------------ + // Return a sorted list of the function names available on the object. + function functions(obj) { + var names = []; + for (var key in obj) { + if (isFunction$1(obj[key])) names.push(key); + } + return names.sort(); + } - // Determines whether to execute a function as a constructor - // or a normal function with the provided arguments. - function executeBound(sourceFunc, boundFunc, context, callingContext, args) { - if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); - var self = baseCreate(sourceFunc.prototype); - var result = sourceFunc.apply(self, args); - if (isObject(result)) return result; - return self; + // An internal function for creating assigner functions. + function createAssigner(keysFunc, defaults) { + return function(obj) { + var length = arguments.length; + if (defaults) obj = Object(obj); + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], + keys = keysFunc(source), + l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!defaults || obj[key] === void 0) obj[key] = source[key]; + } + } + return obj; + }; } - // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if - // available. - var bind = restArguments(function(func, context, args) { - if (!isFunction(func)) throw new TypeError('Bind must be called on a function'); - var bound = restArguments(function(callArgs) { - return executeBound(func, bound, context, this, args.concat(callArgs)); - }); - return bound; - }); - - // Partially apply a function by creating a version that has had some of its - // arguments pre-filled, without changing its dynamic `this` context. _ acts - // as a placeholder by default, allowing any combination of arguments to be - // pre-filled. Set `partial.placeholder` for a custom placeholder argument. - var partial = restArguments(function(func, boundArgs) { - var placeholder = partial.placeholder; - var bound = function() { - var position = 0, length = boundArgs.length; - var args = Array(length); - for (var i = 0; i < length; i++) { - args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; - } - while (position < arguments.length) args.push(arguments[position++]); - return executeBound(func, bound, this, this, args); - }; - return bound; - }); + // Extend a given object with all the properties in passed-in object(s). + var extend = createAssigner(allKeys); - partial.placeholder = _; + // Assigns a given object with all the own properties in the passed-in + // object(s). + // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) + var extendOwn = createAssigner(keys); - // Bind a number of an object's methods to that object. Remaining arguments - // are the method names to be bound. Useful for ensuring that all callbacks - // defined on an object belong to it. - var bindAll = restArguments(function(obj, _keys) { - _keys = _flatten(_keys, false, false); - var index = _keys.length; - if (index < 1) throw new Error('bindAll must be passed function names'); - while (index--) { - var key = _keys[index]; - obj[key] = bind(obj[key], obj); - } - }); + // Fill in a given object with default properties. + var defaults = createAssigner(allKeys, true); - // Memoize an expensive function by storing its results. - function memoize(func, hasher) { - var memoize = function(key) { - var cache = memoize.cache; - var address = '' + (hasher ? hasher.apply(this, arguments) : key); - if (!_has(cache, address)) cache[address] = func.apply(this, arguments); - return cache[address]; - }; - memoize.cache = {}; - return memoize; + // Create a naked function reference for surrogate-prototype-swapping. + function ctor() { + return function(){}; } - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - var delay = restArguments(function(func, wait, args) { - return setTimeout(function() { - return func.apply(null, args); - }, wait); - }); - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - var defer = partial(delay, _, 1); - - // Returns a function, that, when invoked, will only be triggered at most once - // during a given window of time. Normally, the throttled function will run - // as much as it can, without ever going more than once per `wait` duration; - // but if you'd like to disable the execution on the leading edge, pass - // `{leading: false}`. To disable execution on the trailing edge, ditto. - function throttle(func, wait, options) { - var timeout, context, args, result; - var previous = 0; - if (!options) options = {}; - - var later = function() { - previous = options.leading === false ? 0 : now(); - timeout = null; - result = func.apply(context, args); - if (!timeout) context = args = null; - }; - - var throttled = function() { - var _now = now(); - if (!previous && options.leading === false) previous = _now; - var remaining = wait - (_now - previous); - context = this; - args = arguments; - if (remaining <= 0 || remaining > wait) { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - previous = _now; - result = func.apply(context, args); - if (!timeout) context = args = null; - } else if (!timeout && options.trailing !== false) { - timeout = setTimeout(later, remaining); - } - return result; - }; - - throttled.cancel = function() { - clearTimeout(timeout); - previous = 0; - timeout = context = args = null; - }; + // An internal function for creating a new object that inherits from another. + function baseCreate(prototype) { + if (!isObject(prototype)) return {}; + if (nativeCreate) return nativeCreate(prototype); + var Ctor = ctor(); + Ctor.prototype = prototype; + var result = new Ctor; + Ctor.prototype = null; + return result; + } - return throttled; + // Creates an object that inherits from the given prototype object. + // If additional properties are provided then they will be added to the + // created object. + function create(prototype, props) { + var result = baseCreate(prototype); + if (props) extendOwn(result, props); + return result; } - // Returns a function, that, as long as it continues to be invoked, will not - // be triggered. The function will be called after it stops being called for - // N milliseconds. If `immediate` is passed, trigger the function on the - // leading edge, instead of the trailing. - function debounce(func, wait, immediate) { - var timeout, result; + // Create a (shallow-cloned) duplicate of an object. + function clone(obj) { + if (!isObject(obj)) return obj; + return isArray(obj) ? obj.slice() : extend({}, obj); + } - var later = function(context, args) { - timeout = null; - if (args) result = func.apply(context, args); - }; + // Invokes `interceptor` with the `obj` and then returns `obj`. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + function tap(obj, interceptor) { + interceptor(obj); + return obj; + } - var debounced = restArguments(function(args) { - if (timeout) clearTimeout(timeout); - if (immediate) { - var callNow = !timeout; - timeout = setTimeout(later, wait); - if (callNow) result = func.apply(this, args); - } else { - timeout = delay(later, wait, this, args); - } + // Normalize a (deep) property `path` to array. + // Like `_.iteratee`, this function can be customized. + function toPath$1(path) { + return isArray(path) ? path : [path]; + } + _$1.toPath = toPath$1; - return result; - }); + // Internal wrapper for `_.toPath` to enable minification. + // Similar to `cb` for `_.iteratee`. + function toPath(path) { + return _$1.toPath(path); + } - debounced.cancel = function() { - clearTimeout(timeout); - timeout = null; - }; + // Internal function to obtain a nested property in `obj` along `path`. + function deepGet(obj, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + if (obj == null) return void 0; + obj = obj[path[i]]; + } + return length ? obj : void 0; + } - return debounced; + // Get the value of the (deep) property on `path` from `object`. + // If any property in `path` does not exist or if the value is + // `undefined`, return `defaultValue` instead. + // The `path` is normalized through `_.toPath`. + function get(object, path, defaultValue) { + var value = deepGet(object, toPath(path)); + return isUndefined(value) ? defaultValue : value; } - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - function wrap(func, wrapper) { - return partial(wrapper, func); + // Shortcut function for checking if an object has a given property directly on + // itself (in other words, not on a prototype). Unlike the internal `has` + // function, this public version can also traverse nested properties. + function has(obj, path) { + path = toPath(path); + var length = path.length; + for (var i = 0; i < length; i++) { + var key = path[i]; + if (!has$1(obj, key)) return false; + obj = obj[key]; + } + return !!length; } - // Returns a negated version of the passed-in predicate. - function negate(predicate) { - return function() { - return !predicate.apply(this, arguments); - }; + // Keep the identity function around for default iteratees. + function identity(value) { + return value; } - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - function compose() { - var args = arguments; - var start = args.length - 1; - return function() { - var i = start; - var result = args[start].apply(this, arguments); - while (i--) result = args[i].call(this, result); - return result; + // Returns a predicate for checking whether an object has a given set of + // `key:value` pairs. + function matcher(attrs) { + attrs = extendOwn({}, attrs); + return function(obj) { + return isMatch(obj, attrs); }; } - // Returns a function that will only be executed on and after the Nth call. - function after(times, func) { - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } + // Creates a function that, when passed an object, will traverse that object’s + // properties down the given `path`, specified as an array of keys or indices. + function property(path) { + path = toPath(path); + return function(obj) { + return deepGet(obj, path); }; } - // Returns a function that will only be executed up to (but not including) the Nth call. - function before(times, func) { - var memo; + // Internal function that returns an efficient (for current engines) version + // of the passed-in callback, to be repeatedly applied in other Underscore + // functions. + function optimizeCb(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: return function(value) { + return func.call(context, value); + }; + // The 2-argument case is omitted because we’re not using it. + case 3: return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } return function() { - if (--times > 0) { - memo = func.apply(this, arguments); - } - if (times <= 1) func = null; - return memo; + return func.apply(context, arguments); }; } - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - var once = partial(before, 2); - - // Object Functions - // ---------------- - - // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. - var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); - var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', - 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - - function collectNonEnumProps(obj, _keys) { - var nonEnumIdx = nonEnumerableProps.length; - var constructor = obj.constructor; - var proto = isFunction(constructor) && constructor.prototype || ObjProto; - - // Constructor is a special case. - var prop = 'constructor'; - if (_has(obj, prop) && !contains(_keys, prop)) _keys.push(prop); + // An internal function to generate callbacks that can be applied to each + // element in a collection, returning the desired result — either `_.identity`, + // an arbitrary callback, a property matcher, or a property accessor. + function baseIteratee(value, context, argCount) { + if (value == null) return identity; + if (isFunction$1(value)) return optimizeCb(value, context, argCount); + if (isObject(value) && !isArray(value)) return matcher(value); + return property(value); + } - while (nonEnumIdx--) { - prop = nonEnumerableProps[nonEnumIdx]; - if (prop in obj && obj[prop] !== proto[prop] && !contains(_keys, prop)) { - _keys.push(prop); - } - } + // External wrapper for our callback generator. Users may customize + // `_.iteratee` if they want additional predicate/iteratee shorthand styles. + // This abstraction hides the internal-only `argCount` argument. + function iteratee(value, context) { + return baseIteratee(value, context, Infinity); } + _$1.iteratee = iteratee; - // Retrieve the names of an object's own properties. - // Delegates to **ECMAScript 5**'s native `Object.keys`. - function keys(obj) { - if (!isObject(obj)) return []; - if (nativeKeys) return nativeKeys(obj); - var _keys = []; - for (var key in obj) if (_has(obj, key)) _keys.push(key); - // Ahem, IE < 9. - if (hasEnumBug) collectNonEnumProps(obj, _keys); - return _keys; + // The function we call internally to generate a callback. It invokes + // `_.iteratee` if overridden, otherwise `baseIteratee`. + function cb(value, context, argCount) { + if (_$1.iteratee !== iteratee) return _$1.iteratee(value, context); + return baseIteratee(value, context, argCount); } - // Retrieve all the property names of an object. - function allKeys(obj) { - if (!isObject(obj)) return []; - var _keys = []; - for (var key in obj) _keys.push(key); - // Ahem, IE < 9. - if (hasEnumBug) collectNonEnumProps(obj, _keys); - return _keys; - } - - // Retrieve the values of an object's properties. - function values(obj) { - var _keys = keys(obj); - var length = _keys.length; - var values = Array(length); - for (var i = 0; i < length; i++) { - values[i] = obj[_keys[i]]; - } - return values; - } - - // Returns the results of applying the iteratee to each element of the object. - // In contrast to map it returns an object. + // Returns the results of applying the `iteratee` to each element of `obj`. + // In contrast to `_.map` it returns an object. function mapObject(obj, iteratee, context) { iteratee = cb(iteratee, context); var _keys = keys(obj), @@ -3421,651 +3155,1204 @@ module.exports = slice; return results; } - // Convert an object into a list of `[key, value]` pairs. - // The opposite of object. - function pairs(obj) { - var _keys = keys(obj); - var length = _keys.length; - var pairs = Array(length); - for (var i = 0; i < length; i++) { - pairs[i] = [_keys[i], obj[_keys[i]]]; - } - return pairs; + // Predicate-generating function. Often useful outside of Underscore. + function noop(){} + + // Generates a function for a given object that returns a given property. + function propertyOf(obj) { + if (obj == null) return noop; + return function(path) { + return get(obj, path); + }; } - // Invert the keys and values of an object. The values must be serializable. - function invert(obj) { - var result = {}; - var _keys = keys(obj); - for (var i = 0, length = _keys.length; i < length; i++) { - result[obj[_keys[i]]] = _keys[i]; - } - return result; + // Run a function **n** times. + function times(n, iteratee, context) { + var accum = Array(Math.max(0, n)); + iteratee = optimizeCb(iteratee, context, 1); + for (var i = 0; i < n; i++) accum[i] = iteratee(i); + return accum; } - // Return a sorted list of the function names available on the object. - function functions(obj) { - var names = []; - for (var key in obj) { - if (isFunction(obj[key])) names.push(key); + // Return a random integer between `min` and `max` (inclusive). + function random(min, max) { + if (max == null) { + max = min; + min = 0; } - return names.sort(); + return min + Math.floor(Math.random() * (max - min + 1)); } - // An internal function for creating assigner functions. - function createAssigner(keysFunc, defaults) { - return function(obj) { - var length = arguments.length; - if (defaults) obj = Object(obj); - if (length < 2 || obj == null) return obj; - for (var index = 1; index < length; index++) { - var source = arguments[index], - _keys = keysFunc(source), - l = _keys.length; - for (var i = 0; i < l; i++) { - var key = _keys[i]; - if (!defaults || obj[key] === void 0) obj[key] = source[key]; - } - } - return obj; + // A (possibly faster) way to get the current timestamp as an integer. + var now = Date.now || function() { + return new Date().getTime(); + }; + + // Internal helper to generate functions for escaping and unescaping strings + // to/from HTML interpolation. + function createEscaper(map) { + var escaper = function(match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped. + var source = '(?:' + keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function(string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; }; } - // Extend a given object with all the properties in passed-in object(s). - var extend = createAssigner(allKeys); + // Internal list of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; - // Assigns a given object with all the own properties in the passed-in object(s). - // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) - var extendOwn = createAssigner(keys); + // Function for escaping strings to HTML interpolation. + var _escape = createEscaper(escapeMap); - // Returns the first key on an object that passes a predicate test. - function findKey(obj, predicate, context) { - predicate = cb(predicate, context); - var _keys = keys(obj), key; - for (var i = 0, length = _keys.length; i < length; i++) { - key = _keys[i]; - if (predicate(obj[key], key, obj)) return key; - } - } + // Internal list of HTML entities for unescaping. + var unescapeMap = invert(escapeMap); - // Internal pick helper function to determine if `obj` has key `key`. - function keyInObj(value, key, obj) { - return key in obj; + // Function for unescaping strings from HTML interpolation. + var _unescape = createEscaper(unescapeMap); + + // By default, Underscore uses ERB-style template delimiters. Change the + // following template settings to use alternative delimiters. + var templateSettings = _$1.templateSettings = { + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g + }; + + // When customizing `_.templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; + + function escapeChar(match) { + return '\\' + escapes[match]; } - // Return a copy of the object only containing the whitelisted properties. - var pick = restArguments(function(obj, _keys) { - var result = {}, iteratee = _keys[0]; - if (obj == null) return result; - if (isFunction(iteratee)) { - if (_keys.length > 1) iteratee = optimizeCb(iteratee, _keys[1]); - _keys = allKeys(obj); + // In order to prevent third-party code injection through + // `_.templateSettings.variable`, we test it against the following regular + // expression. It is intentionally a bit more liberal than just matching valid + // identifiers, but still prevents possible loopholes through defaults or + // destructuring assignment. + var bareIdentifier = /^\s*(\w|\$)+\s*$/; + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + // NB: `oldSettings` only exists for backwards compatibility. + function template(text, settings, oldSettings) { + if (!settings && oldSettings) settings = oldSettings; + settings = defaults({}, settings, _$1.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset).replace(escapeRegExp, escapeChar); + index = offset + match.length; + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } else if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } else if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + + // Adobe VMs need the match returned to produce the correct offset. + return match; + }); + source += "';\n"; + + var argument = settings.variable; + if (argument) { + // Insure against third-party code injection. (CVE-2021-23358) + if (!bareIdentifier.test(argument)) throw new Error( + 'variable is not a bare identifier: ' + argument + ); } else { - iteratee = keyInObj; - _keys = _flatten(_keys, false, false); - obj = Object(obj); - } - for (var i = 0, length = _keys.length; i < length; i++) { - var key = _keys[i]; - var value = obj[key]; - if (iteratee(value, key, obj)) result[key] = value; + // If a variable is not specified, place data values in local scope. + source = 'with(obj||{}){\n' + source + '}\n'; + argument = 'obj'; } - return result; - }); - // Return a copy of the object without the blacklisted properties. - var omit = restArguments(function(obj, _keys) { - var iteratee = _keys[0], context; - if (isFunction(iteratee)) { - iteratee = negate(iteratee); - if (_keys.length > 1) context = _keys[1]; - } else { - _keys = map(_flatten(_keys, false, false), String); - iteratee = function(value, key) { - return !contains(_keys, key); - }; + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + 'return __p;\n'; + + var render; + try { + render = new Function(argument, '_', source); + } catch (e) { + e.source = source; + throw e; } - return pick(obj, iteratee, context); - }); - // Fill in a given object with default properties. - var defaults = createAssigner(allKeys, true); + var template = function(data) { + return render.call(this, data, _$1); + }; - // Creates an object that inherits from the given prototype object. - // If additional properties are provided then they will be added to the - // created object. - function create(prototype, props) { - var result = baseCreate(prototype); - if (props) extendOwn(result, props); - return result; - } + // Provide the compiled source as a convenience for precompilation. + template.source = 'function(' + argument + '){\n' + source + '}'; - // Create a (shallow-cloned) duplicate of an object. - function clone(obj) { - if (!isObject(obj)) return obj; - return isArray(obj) ? obj.slice() : extend({}, obj); + return template; } - // Invokes interceptor with the obj, and then returns obj. - // The primary purpose of this method is to "tap into" a method chain, in - // order to perform operations on intermediate results within the chain. - function tap(obj, interceptor) { - interceptor(obj); + // Traverses the children of `obj` along `path`. If a child is a function, it + // is invoked with its parent as context. Returns the value of the final + // child, or `fallback` if any child is undefined. + function result(obj, path, fallback) { + path = toPath(path); + var length = path.length; + if (!length) { + return isFunction$1(fallback) ? fallback.call(obj) : fallback; + } + for (var i = 0; i < length; i++) { + var prop = obj == null ? void 0 : obj[path[i]]; + if (prop === void 0) { + prop = fallback; + i = length; // Ensure we don't continue iterating. + } + obj = isFunction$1(prop) ? prop.call(obj) : prop; + } return obj; } - // Returns whether an object has a given set of `key:value` pairs. - function isMatch(object, attrs) { - var _keys = keys(attrs), length = _keys.length; - if (object == null) return !length; - var obj = Object(object); - for (var i = 0; i < length; i++) { - var key = _keys[i]; - if (attrs[key] !== obj[key] || !(key in obj)) return false; - } - return true; + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + function uniqueId(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; } + // Start chaining a wrapped Underscore object. + function chain(obj) { + var instance = _$1(obj); + instance._chain = true; + return instance; + } - // Internal recursive comparison function for `isEqual`. - function eq(a, b, aStack, bStack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal). - if (a === b) return a !== 0 || 1 / a === 1 / b; - // `null` or `undefined` only equal to itself (strict comparison). - if (a == null || b == null) return false; - // `NaN`s are equivalent, but non-reflexive. - if (a !== a) return b !== b; - // Exhaust primitive checks - var type = typeof a; - if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; - return deepEq(a, b, aStack, bStack); + // Internal function to execute `sourceFunc` bound to `context` with optional + // `args`. Determines whether to execute a function as a constructor or as a + // normal function. + function executeBound(sourceFunc, boundFunc, context, callingContext, args) { + if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); + var self = baseCreate(sourceFunc.prototype); + var result = sourceFunc.apply(self, args); + if (isObject(result)) return result; + return self; } - // Internal recursive comparison function for `isEqual`. - function deepEq(a, b, aStack, bStack) { - // Unwrap any wrapped objects. - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className !== toString.call(b)) return false; - switch (className) { - // Strings, numbers, regular expressions, dates, and booleans are compared by value. - case '[object RegExp]': - // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return '' + a === '' + b; - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. - // Object(NaN) is equivalent to NaN. - if (+a !== +a) return +b !== +b; - // An `egal` comparison is performed for other numeric values. - return +a === 0 ? 1 / +a === 1 / b : +a === +b; - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a === +b; - case '[object Symbol]': - return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. `_` acts + // as a placeholder by default, allowing any combination of arguments to be + // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. + var partial = restArguments(function(func, boundArgs) { + var placeholder = partial.placeholder; + var bound = function() { + var position = 0, length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; + } + while (position < arguments.length) args.push(arguments[position++]); + return executeBound(func, bound, this, this, args); + }; + return bound; + }); + + partial.placeholder = _$1; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). + var bind = restArguments(function(func, context, args) { + if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function'); + var bound = restArguments(function(callArgs) { + return executeBound(func, bound, context, this, args.concat(callArgs)); + }); + return bound; + }); + + // Internal helper for collection methods to determine whether a collection + // should be iterated as an array or as an object. + // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength + // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 + var isArrayLike = createSizePropertyCheck(getLength); + + // Internal implementation of a recursive `flatten` function. + function flatten$1(input, depth, strict, output) { + output = output || []; + if (!depth && depth !== 0) { + depth = Infinity; + } else if (depth <= 0) { + return output.concat(input); } + var idx = output.length; + for (var i = 0, length = getLength(input); i < length; i++) { + var value = input[i]; + if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) { + // Flatten current level of array or arguments object. + if (depth > 1) { + flatten$1(value, depth - 1, strict, output); + idx = output.length; + } else { + var j = 0, len = value.length; + while (j < len) output[idx++] = value[j++]; + } + } else if (!strict) { + output[idx++] = value; + } + } + return output; + } - var areArrays = className === '[object Array]'; - if (!areArrays) { - if (typeof a != 'object' || typeof b != 'object') return false; + // Bind a number of an object's methods to that object. Remaining arguments + // are the method names to be bound. Useful for ensuring that all callbacks + // defined on an object belong to it. + var bindAll = restArguments(function(obj, keys) { + keys = flatten$1(keys, false, false); + var index = keys.length; + if (index < 1) throw new Error('bindAll must be passed function names'); + while (index--) { + var key = keys[index]; + obj[key] = bind(obj[key], obj); + } + return obj; + }); - // Objects with different constructors are not equivalent, but `Object`s or `Array`s - // from different frames are. - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor && - isFunction(bCtor) && bCtor instanceof bCtor) - && ('constructor' in a && 'constructor' in b)) { - return false; + // Memoize an expensive function by storing its results. + function memoize(func, hasher) { + var memoize = function(key) { + var cache = memoize.cache; + var address = '' + (hasher ? hasher.apply(this, arguments) : key); + if (!has$1(cache, address)) cache[address] = func.apply(this, arguments); + return cache[address]; + }; + memoize.cache = {}; + return memoize; + } + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + var delay = restArguments(function(func, wait, args) { + return setTimeout(function() { + return func.apply(null, args); + }, wait); + }); + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + var defer = partial(delay, _$1, 1); + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + function throttle(func, wait, options) { + var timeout, context, args, result; + var previous = 0; + if (!options) options = {}; + + var later = function() { + previous = options.leading === false ? 0 : now(); + timeout = null; + result = func.apply(context, args); + if (!timeout) context = args = null; + }; + + var throttled = function() { + var _now = now(); + if (!previous && options.leading === false) previous = _now; + var remaining = wait - (_now - previous); + context = this; + args = arguments; + if (remaining <= 0 || remaining > wait) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + previous = _now; + result = func.apply(context, args); + if (!timeout) context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); } + return result; + }; + + throttled.cancel = function() { + clearTimeout(timeout); + previous = 0; + timeout = context = args = null; + }; + + return throttled; + } + + // When a sequence of calls of the returned function ends, the argument + // function is triggered. The end of a sequence is defined by the `wait` + // parameter. If `immediate` is passed, the argument function will be + // triggered at the beginning of the sequence instead of at the end. + function debounce(func, wait, immediate) { + var timeout, previous, args, result, context; + + var later = function() { + var passed = now() - previous; + if (wait > passed) { + timeout = setTimeout(later, wait - passed); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + // This check is needed because `func` can recursively invoke `debounced`. + if (!timeout) args = context = null; + } + }; + + var debounced = restArguments(function(_args) { + context = this; + args = _args; + previous = now(); + if (!timeout) { + timeout = setTimeout(later, wait); + if (immediate) result = func.apply(context, args); + } + return result; + }); + + debounced.cancel = function() { + clearTimeout(timeout); + timeout = args = context = null; + }; + + return debounced; + } + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + function wrap(func, wrapper) { + return partial(wrapper, func); + } + + // Returns a negated version of the passed-in predicate. + function negate(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + } + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + function compose() { + var args = arguments; + var start = args.length - 1; + return function() { + var i = start; + var result = args[start].apply(this, arguments); + while (i--) result = args[i].call(this, result); + return result; + }; + } + + // Returns a function that will only be executed on and after the Nth call. + function after(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + } + + // Returns a function that will only be executed up to (but not including) the + // Nth call. + function before(times, func) { + var memo; + return function() { + if (--times > 0) { + memo = func.apply(this, arguments); + } + if (times <= 1) func = null; + return memo; + }; + } + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + var once = partial(before, 2); + + // Returns the first key on an object that passes a truth test. + function findKey(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = keys(obj), key; + for (var i = 0, length = _keys.length; i < length; i++) { + key = _keys[i]; + if (predicate(obj[key], key, obj)) return key; } - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + } - // Initializing stack of traversed objects. - // It's done here since we only need them for objects and arrays comparison. - aStack = aStack || []; - bStack = bStack || []; - var length = aStack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (aStack[length] === a) return bStack[length] === b; + // Internal function to generate `_.findIndex` and `_.findLastIndex`. + function createPredicateIndexFinder(dir) { + return function(array, predicate, context) { + predicate = cb(predicate, context); + var length = getLength(array); + var index = dir > 0 ? 0 : length - 1; + for (; index >= 0 && index < length; index += dir) { + if (predicate(array[index], index, array)) return index; + } + return -1; + }; + } + + // Returns the first index on an array-like that passes a truth test. + var findIndex = createPredicateIndexFinder(1); + + // Returns the last index on an array-like that passes a truth test. + var findLastIndex = createPredicateIndexFinder(-1); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + function sortedIndex(array, obj, iteratee, context) { + iteratee = cb(iteratee, context, 1); + var value = iteratee(obj); + var low = 0, high = getLength(array); + while (low < high) { + var mid = Math.floor((low + high) / 2); + if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; } + return low; + } - // Add the first object to the stack of traversed objects. - aStack.push(a); - bStack.push(b); + // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions. + function createIndexFinder(dir, predicateFind, sortedIndex) { + return function(array, item, idx) { + var i = 0, length = getLength(array); + if (typeof idx == 'number') { + if (dir > 0) { + i = idx >= 0 ? idx : Math.max(idx + length, i); + } else { + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + } + } else if (sortedIndex && idx && length) { + idx = sortedIndex(array, item); + return array[idx] === item ? idx : -1; + } + if (item !== item) { + idx = predicateFind(slice.call(array, i, length), isNaN$1); + return idx >= 0 ? idx + i : -1; + } + for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { + if (array[idx] === item) return idx; + } + return -1; + }; + } - // Recursively compare objects and arrays. - if (areArrays) { - // Compare array lengths to determine if a deep comparison is necessary. - length = a.length; - if (length !== b.length) return false; - // Deep compare the contents, ignoring non-numeric properties. - while (length--) { - if (!eq(a[length], b[length], aStack, bStack)) return false; + // Return the position of the first occurrence of an item in an array, + // or -1 if the item is not included in the array. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + var indexOf = createIndexFinder(1, findIndex, sortedIndex); + + // Return the position of the last occurrence of an item in an array, + // or -1 if the item is not included in the array. + var lastIndexOf = createIndexFinder(-1, findLastIndex); + + // Return the first value which passes a truth test. + function find(obj, predicate, context) { + var keyFinder = isArrayLike(obj) ? findIndex : findKey; + var key = keyFinder(obj, predicate, context); + if (key !== void 0 && key !== -1) return obj[key]; + } + + // Convenience version of a common use case of `_.find`: getting the first + // object containing specific `key:value` pairs. + function findWhere(obj, attrs) { + return find(obj, matcher(attrs)); + } + + // The cornerstone for collection functions, an `each` + // implementation, aka `forEach`. + // Handles raw objects in addition to array-likes. Treats all + // sparse array-likes as if they were dense. + function each(obj, iteratee, context) { + iteratee = optimizeCb(iteratee, context); + var i, length; + if (isArrayLike(obj)) { + for (i = 0, length = obj.length; i < length; i++) { + iteratee(obj[i], i, obj); } } else { - // Deep compare objects. - var _keys = keys(a), key; - length = _keys.length; - // Ensure that both objects contain the same number of properties before comparing deep equality. - if (keys(b).length !== length) return false; - while (length--) { - // Deep compare each member - key = _keys[length]; - if (!(_has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + var _keys = keys(obj); + for (i = 0, length = _keys.length; i < length; i++) { + iteratee(obj[_keys[i]], _keys[i], obj); + } + } + return obj; + } + + // Return the results of applying the iteratee to each element. + function map(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Internal helper to create a reducing function, iterating left or right. + function createReduce(dir) { + // Wrap code that reassigns argument variables in a separate function than + // the one that accesses `arguments.length` to avoid a perf hit. (#1991) + var reducer = function(obj, iteratee, memo, initial) { + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + index = dir > 0 ? 0 : length - 1; + if (!initial) { + memo = obj[_keys ? _keys[index] : index]; + index += dir; } + for (; index >= 0 && index < length; index += dir) { + var currentKey = _keys ? _keys[index] : index; + memo = iteratee(memo, obj[currentKey], currentKey, obj); + } + return memo; + }; + + return function(obj, iteratee, memo, context) { + var initial = arguments.length >= 3; + return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); + }; + } + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. + var reduce = createReduce(1); + + // The right-associative version of reduce, also known as `foldr`. + var reduceRight = createReduce(-1); + + // Return all the elements that pass a truth test. + function filter(obj, predicate, context) { + var results = []; + predicate = cb(predicate, context); + each(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; + } + + // Return all the elements for which a truth test fails. + function reject(obj, predicate, context) { + return filter(obj, negate(cb(predicate)), context); + } + + // Determine whether all of the elements pass a truth test. + function every(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; + } + + // Determine if at least one element in the object passes a truth test. + function some(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; } - // Remove the first object from the stack of traversed objects. - aStack.pop(); - bStack.pop(); - return true; + return false; } - // Perform a deep comparison to check if two objects are equal. - function isEqual(a, b) { - return eq(a, b); + // Determine if the array or object contains a given item (using `===`). + function contains(obj, item, fromIndex, guard) { + if (!isArrayLike(obj)) obj = values(obj); + if (typeof fromIndex != 'number' || guard) fromIndex = 0; + return indexOf(obj, item, fromIndex) >= 0; } - // Is a given array, string, or object empty? - // An "empty" object has no enumerable own-properties. - function isEmpty(obj) { - if (obj == null) return true; - if (isArrayLike(obj) && (isArray(obj) || isString(obj) || isArguments(obj))) return obj.length === 0; - return keys(obj).length === 0; - } + // Invoke a method (with arguments) on every item in a collection. + var invoke = restArguments(function(obj, path, args) { + var contextPath, func; + if (isFunction$1(path)) { + func = path; + } else { + path = toPath(path); + contextPath = path.slice(0, -1); + path = path[path.length - 1]; + } + return map(obj, function(context) { + var method = func; + if (!method) { + if (contextPath && contextPath.length) { + context = deepGet(context, contextPath); + } + if (context == null) return void 0; + method = context[path]; + } + return method == null ? method : method.apply(context, args); + }); + }); - // Is a given value a DOM element? - function isElement(obj) { - return !!(obj && obj.nodeType === 1); + // Convenience version of a common use case of `_.map`: fetching a property. + function pluck(obj, key) { + return map(obj, property(key)); } - // Internal function for creating a toString-based type tester. - function tagTester(name) { - return function(obj) { - return toString.call(obj) === '[object ' + name + ']'; - }; + // Convenience version of a common use case of `_.filter`: selecting only + // objects containing specific `key:value` pairs. + function where(obj, attrs) { + return filter(obj, matcher(attrs)); } - // Is a given value an array? - // Delegates to ECMA5's native Array.isArray - var isArray = nativeIsArray || tagTester('Array'); - - // Is a given variable an object? - function isObject(obj) { - var type = typeof obj; - return type === 'function' || type === 'object' && !!obj; + // Return the maximum element (or element-based computation). + function max(obj, iteratee, context) { + var result = -Infinity, lastComputed = -Infinity, + value, computed; + if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value > result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed > lastComputed || (computed === -Infinity && result === -Infinity)) { + result = v; + lastComputed = computed; + } + }); + } + return result; } - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError, isMap, isWeakMap, isSet, isWeakSet. - var isArguments = tagTester('Arguments'); - var isFunction = tagTester('Function'); - var isString = tagTester('String'); - var isNumber = tagTester('Number'); - var isDate = tagTester('Date'); - var isRegExp = tagTester('RegExp'); - var isError = tagTester('Error'); - var isSymbol = tagTester('Symbol'); - var isMap = tagTester('Map'); - var isWeakMap = tagTester('WeakMap'); - var isSet = tagTester('Set'); - var isWeakSet = tagTester('WeakSet'); - - // Define a fallback version of the method in browsers (ahem, IE < 9), where - // there isn't any inspectable "Arguments" type. - (function() { - if (!isArguments(arguments)) { - isArguments = function(obj) { - return _has(obj, 'callee'); - }; + // Return the minimum element (or element-based computation). + function min(obj, iteratee, context) { + var result = Infinity, lastComputed = Infinity, + value, computed; + if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value < result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed < lastComputed || (computed === Infinity && result === Infinity)) { + result = v; + lastComputed = computed; + } + }); } - }()); - - // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, - // IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). - var nodelist = root.document && root.document.childNodes; - if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { - isFunction = function(obj) { - return typeof obj == 'function' || false; - }; + return result; } - // Is a given object a finite number? - function isFinite(obj) { - return !isSymbol(obj) && _isFinite(obj) && !_isNaN(parseFloat(obj)); + // Safely create a real, live array from anything iterable. + var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; + function toArray(obj) { + if (!obj) return []; + if (isArray(obj)) return slice.call(obj); + if (isString(obj)) { + // Keep surrogate pair characters together. + return obj.match(reStrSymbol); + } + if (isArrayLike(obj)) return map(obj, identity); + return values(obj); } - // Is the given value `NaN`? - function isNaN(obj) { - return isNumber(obj) && _isNaN(obj); + // Sample **n** random values from a collection using the modern version of the + // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + // If **n** is not specified, returns a single random element. + // The internal `guard` argument allows it to work with `_.map`. + function sample(obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = values(obj); + return obj[random(obj.length - 1)]; + } + var sample = toArray(obj); + var length = getLength(sample); + n = Math.max(Math.min(n, length), 0); + var last = length - 1; + for (var index = 0; index < n; index++) { + var rand = random(index, last); + var temp = sample[index]; + sample[index] = sample[rand]; + sample[rand] = temp; + } + return sample.slice(0, n); } - // Is a given value a boolean? - function isBoolean(obj) { - return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; + // Shuffle a collection. + function shuffle(obj) { + return sample(obj, Infinity); } - // Is a given value equal to null? - function isNull(obj) { - return obj === null; + // Sort the object's values by a criterion produced by an iteratee. + function sortBy(obj, iteratee, context) { + var index = 0; + iteratee = cb(iteratee, context); + return pluck(map(obj, function(value, key, list) { + return { + value: value, + index: index++, + criteria: iteratee(value, key, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); } - // Is a given variable undefined? - function isUndefined(obj) { - return obj === void 0; + // An internal function used for aggregate "group by" operations. + function group(behavior, partition) { + return function(obj, iteratee, context) { + var result = partition ? [[], []] : {}; + iteratee = cb(iteratee, context); + each(obj, function(value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; } - // Shortcut function for checking if an object has a given property directly - // on itself (in other words, not on a prototype). - function has(obj, path) { - if (!isArray(path)) { - return _has(obj, path); - } - var length = path.length; - for (var i = 0; i < length; i++) { - var key = path[i]; - if (obj == null || !hasOwnProperty.call(obj, key)) { - return false; - } - obj = obj[key]; - } - return !!length; - } + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + var groupBy = group(function(result, value, key) { + if (has$1(result, key)) result[key].push(value); else result[key] = [value]; + }); + + // Indexes the object's values by a criterion, similar to `_.groupBy`, but for + // when you know that your index values will be unique. + var indexBy = group(function(result, value, key) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + var countBy = group(function(result, value, key) { + if (has$1(result, key)) result[key]++; else result[key] = 1; + }); - // Utility Functions - // ----------------- + // Split a collection into two arrays: one whose elements all pass the given + // truth test, and one whose elements all do not pass the truth test. + var partition = group(function(result, value, pass) { + result[pass ? 0 : 1].push(value); + }, true); - // Keep the identity function around for default iteratees. - function identity(value) { - return value; + // Return the number of elements in a collection. + function size(obj) { + if (obj == null) return 0; + return isArrayLike(obj) ? obj.length : keys(obj).length; } - // Predicate-generating functions. Often useful outside of Underscore. - function constant(value) { - return function() { - return value; - }; + // Internal `_.pick` helper function to determine whether `key` is an enumerable + // property name of `obj`. + function keyInObj(value, key, obj) { + return key in obj; } - function noop(){} + // Return a copy of the object only containing the allowed properties. + var pick = restArguments(function(obj, keys) { + var result = {}, iteratee = keys[0]; + if (obj == null) return result; + if (isFunction$1(iteratee)) { + if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); + keys = allKeys(obj); + } else { + iteratee = keyInObj; + keys = flatten$1(keys, false, false); + obj = Object(obj); + } + for (var i = 0, length = keys.length; i < length; i++) { + var key = keys[i]; + var value = obj[key]; + if (iteratee(value, key, obj)) result[key] = value; + } + return result; + }); - // Creates a function that, when passed an object, will traverse that object’s - // properties down the given `path`, specified as an array of keys or indexes. - function property(path) { - if (!isArray(path)) { - return shallowProperty(path); + // Return a copy of the object without the disallowed properties. + var omit = restArguments(function(obj, keys) { + var iteratee = keys[0], context; + if (isFunction$1(iteratee)) { + iteratee = negate(iteratee); + if (keys.length > 1) context = keys[1]; + } else { + keys = map(flatten$1(keys, false, false), String); + iteratee = function(value, key) { + return !contains(keys, key); + }; } - return function(obj) { - return deepGet(obj, path); - }; + return pick(obj, iteratee, context); + }); + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. + function initial(array, n, guard) { + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); } - // Generates a function for a given object that returns a given property. - function propertyOf(obj) { - if (obj == null) { - return function(){}; - } - return function(path) { - return !isArray(path) ? obj[path] : deepGet(obj, path); - }; + // Get the first element of an array. Passing **n** will return the first N + // values in the array. The **guard** check allows it to work with `_.map`. + function first(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[0]; + return initial(array, array.length - n); } - // Returns a predicate for checking whether an object has a given set of - // `key:value` pairs. - function matcher(attrs) { - attrs = extendOwn({}, attrs); - return function(obj) { - return isMatch(obj, attrs); - }; + // Returns everything but the first entry of the `array`. Especially useful on + // the `arguments` object. Passing an **n** will return the rest N values in the + // `array`. + function rest(array, n, guard) { + return slice.call(array, n == null || guard ? 1 : n); } - // Run a function **n** times. - function times(n, iteratee, context) { - var accum = Array(Math.max(0, n)); - iteratee = optimizeCb(iteratee, context, 1); - for (var i = 0; i < n; i++) accum[i] = iteratee(i); - return accum; + // Get the last element of an array. Passing **n** will return the last N + // values in the array. + function last(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[array.length - 1]; + return rest(array, Math.max(0, array.length - n)); } - // Return a random integer between min and max (inclusive). - function random(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + Math.floor(Math.random() * (max - min + 1)); + // Trim out all falsy values from an array. + function compact(array) { + return filter(array, Boolean); } - // A (possibly faster) way to get the current timestamp as an integer. - var now = Date.now || function() { - return new Date().getTime(); - }; + // Flatten out an array, either recursively (by default), or up to `depth`. + // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively. + function flatten(array, depth) { + return flatten$1(array, depth, false); + } - // List of HTML entities for escaping. - var escapeMap = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '`': '`' - }; - var unescapeMap = invert(escapeMap); + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + var difference = restArguments(function(array, rest) { + rest = flatten$1(rest, true, true); + return filter(array, function(value){ + return !contains(rest, value); + }); + }); - // Functions for escaping and unescaping strings to/from HTML interpolation. - function createEscaper(map) { - var escaper = function(match) { - return map[match]; - }; - // Regexes for identifying a key that needs to be escaped. - var source = '(?:' + keys(map).join('|') + ')'; - var testRegexp = RegExp(source); - var replaceRegexp = RegExp(source, 'g'); - return function(string) { - string = string == null ? '' : '' + string; - return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; - }; - } - var escape = createEscaper(escapeMap); - var unescape = createEscaper(unescapeMap); + // Return a version of the array that does not contain the specified value(s). + var without = restArguments(function(array, otherArrays) { + return difference(array, otherArrays); + }); - // Traverses the children of `obj` along `path`. If a child is a function, it - // is invoked with its parent as context. Returns the value of the final - // child, or `fallback` if any child is undefined. - function result(obj, path, fallback) { - if (!isArray(path)) path = [path]; - var length = path.length; - if (!length) { - return isFunction(fallback) ? fallback.call(obj) : fallback; + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // The faster algorithm will not work with an iteratee if the iteratee + // is not a one-to-one function, so providing an iteratee will disable + // the faster algorithm. + function uniq(array, isSorted, iteratee, context) { + if (!isBoolean(isSorted)) { + context = iteratee; + iteratee = isSorted; + isSorted = false; } - for (var i = 0; i < length; i++) { - var prop = obj == null ? void 0 : obj[path[i]]; - if (prop === void 0) { - prop = fallback; - i = length; // Ensure we don't continue iterating. + if (iteratee != null) iteratee = cb(iteratee, context); + var result = []; + var seen = []; + for (var i = 0, length = getLength(array); i < length; i++) { + var value = array[i], + computed = iteratee ? iteratee(value, i, array) : value; + if (isSorted && !iteratee) { + if (!i || seen !== computed) result.push(value); + seen = computed; + } else if (iteratee) { + if (!contains(seen, computed)) { + seen.push(computed); + result.push(value); + } + } else if (!contains(result, value)) { + result.push(value); } - obj = isFunction(prop) ? prop.call(obj) : prop; } - return obj; - } - - // Generate a unique integer id (unique within the entire client session). - // Useful for temporary DOM ids. - var idCounter = 0; - function uniqueId(prefix) { - var id = ++idCounter + ''; - return prefix ? prefix + id : id; + return result; } - // By default, Underscore uses ERB-style template delimiters, change the - // following template settings to use alternative delimiters. - var templateSettings = _.templateSettings = { - evaluate: /<%([\s\S]+?)%>/g, - interpolate: /<%=([\s\S]+?)%>/g, - escape: /<%-([\s\S]+?)%>/g - }; - - // When customizing `templateSettings`, if you don't want to define an - // interpolation, evaluation or escaping regex, we need one that is - // guaranteed not to match. - var noMatch = /(.)^/; - - // Certain characters need to be escaped so that they can be put into a - // string literal. - var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; - - var escapeChar = function(match) { - return '\\' + escapes[match]; - }; - - // JavaScript micro-templating, similar to John Resig's implementation. - // Underscore templating handles arbitrary delimiters, preserves whitespace, - // and correctly escapes quotes within interpolated code. - // NB: `oldSettings` only exists for backwards compatibility. - function template(text, settings, oldSettings) { - if (!settings && oldSettings) settings = oldSettings; - settings = defaults({}, settings, _.templateSettings); - - // Combine delimiters into one regular expression via alternation. - var matcher = RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - - // Compile the template source, escaping string literals appropriately. - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset).replace(escapeRegExp, escapeChar); - index = offset + match.length; + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + var union = restArguments(function(arrays) { + return uniq(flatten$1(arrays, true, true)); + }); - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } else if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } else if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; + // Produce an array that contains every item shared between all the + // passed-in arrays. + function intersection(array) { + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = getLength(array); i < length; i++) { + var item = array[i]; + if (contains(result, item)) continue; + var j; + for (j = 1; j < argsLength; j++) { + if (!contains(arguments[j], item)) break; } + if (j === argsLength) result.push(item); + } + return result; + } - // Adobe VMs need the match returned to produce the correct offset. - return match; - }); - source += "';\n"; + // Complement of zip. Unzip accepts an array of arrays and groups + // each array's elements on shared indices. + function unzip(array) { + var length = (array && max(array, getLength).length) || 0; + var result = Array(length); - // If a variable is not specified, place data values in local scope. - if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + for (var index = 0; index < length; index++) { + result[index] = pluck(array, index); + } + return result; + } - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + 'return __p;\n'; + // Zip together multiple lists into a single array -- elements that share + // an index go together. + var zip = restArguments(unzip); - var render; - try { - render = new Function(settings.variable || 'obj', '_', source); - } catch (e) { - e.source = source; - throw e; + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. Passing by pairs is the reverse of `_.pairs`. + function object(list, values) { + var result = {}; + for (var i = 0, length = getLength(list); i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } } + return result; + } - var template = function(data) { - return render.call(this, data, _); - }; + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](https://docs.python.org/library/functions.html#range). + function range(start, stop, step) { + if (stop == null) { + stop = start || 0; + start = 0; + } + if (!step) { + step = stop < start ? -1 : 1; + } - // Provide the compiled source as a convenience for precompilation. - var argument = settings.variable || 'obj'; - template.source = 'function(' + argument + '){\n' + source + '}'; + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); - return template; - } + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } - // Add a "chain" function. Start chaining a wrapped Underscore object. - function chain(obj) { - var instance = _(obj); - instance._chain = true; - return instance; + return range; } - // OOP - // --------------- - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. + // Chunk a single array into multiple arrays, each containing `count` or fewer + // items. + function chunk(array, count) { + if (count == null || count < 1) return []; + var result = []; + var i = 0, length = array.length; + while (i < length) { + result.push(slice.call(array, i, i += count)); + } + return result; + } // Helper function to continue chaining intermediate results. function chainResult(instance, obj) { - return instance._chain ? _(obj).chain() : obj; + return instance._chain ? _$1(obj).chain() : obj; } // Add your own custom functions to the Underscore object. function mixin(obj) { each(functions(obj), function(name) { - var func = _[name] = obj[name]; - _.prototype[name] = function() { + var func = _$1[name] = obj[name]; + _$1.prototype[name] = function() { var args = [this._wrapped]; push.apply(args, arguments); - return chainResult(this, func.apply(_, args)); + return chainResult(this, func.apply(_$1, args)); }; }); - return _; + return _$1; } - // Add all mutator Array functions to the wrapper. + // Add all mutator `Array` functions to the wrapper. each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { var method = ArrayProto[name]; - _.prototype[name] = function() { + _$1.prototype[name] = function() { var obj = this._wrapped; - method.apply(obj, arguments); - if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; + if (obj != null) { + method.apply(obj, arguments); + if ((name === 'shift' || name === 'splice') && obj.length === 0) { + delete obj[0]; + } + } return chainResult(this, obj); }; }); - // Add all accessor Array functions to the wrapper. + // Add all accessor `Array` functions to the wrapper. each(['concat', 'join', 'slice'], function(name) { var method = ArrayProto[name]; - _.prototype[name] = function() { - return chainResult(this, method.apply(this._wrapped, arguments)); + _$1.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) obj = method.apply(obj, arguments); + return chainResult(this, obj); }; }); - // Extracts the result from a wrapped and chained object. - _.prototype.value = function() { - return this._wrapped; - }; - - // Provide unwrapping proxy for some methods used in engine operations - // such as arithmetic and JSON stringification. - _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; - - _.prototype.toString = function() { - return String(this._wrapped); - }; + // Named Exports - var allExports = ({ - 'default': _, + var allExports = { + __proto__: null, VERSION: VERSION, - iteratee: iteratee, restArguments: restArguments, + isObject: isObject, + isNull: isNull, + isUndefined: isUndefined, + isBoolean: isBoolean, + isElement: isElement, + isString: isString, + isNumber: isNumber, + isDate: isDate, + isRegExp: isRegExp, + isError: isError, + isSymbol: isSymbol, + isArrayBuffer: isArrayBuffer, + isDataView: isDataView$1, + isArray: isArray, + isFunction: isFunction$1, + isArguments: isArguments$1, + isFinite: isFinite$1, + isNaN: isNaN$1, + isTypedArray: isTypedArray$1, + isEmpty: isEmpty, + isMatch: isMatch, + isEqual: isEqual, + isMap: isMap, + isWeakMap: isWeakMap, + isSet: isSet, + isWeakSet: isWeakSet, + keys: keys, + allKeys: allKeys, + values: values, + pairs: pairs, + invert: invert, + functions: functions, + methods: functions, + extend: extend, + extendOwn: extendOwn, + assign: extendOwn, + defaults: defaults, + create: create, + clone: clone, + tap: tap, + get: get, + has: has, + mapObject: mapObject, + identity: identity, + constant: constant, + noop: noop, + toPath: toPath$1, + property: property, + propertyOf: propertyOf, + matcher: matcher, + matches: matcher, + times: times, + random: random, + now: now, + escape: _escape, + unescape: _unescape, + templateSettings: templateSettings, + template: template, + result: result, + uniqueId: uniqueId, + chain: chain, + iteratee: iteratee, + partial: partial, + bind: bind, + bindAll: bindAll, + memoize: memoize, + delay: delay, + defer: defer, + throttle: throttle, + debounce: debounce, + wrap: wrap, + negate: negate, + compose: compose, + after: after, + before: before, + once: once, + findKey: findKey, + findIndex: findIndex, + findLastIndex: findLastIndex, + sortedIndex: sortedIndex, + indexOf: indexOf, + lastIndexOf: lastIndexOf, + find: find, + detect: find, + findWhere: findWhere, each: each, forEach: each, map: map, @@ -4075,8 +4362,6 @@ module.exports = slice; inject: reduce, reduceRight: reduceRight, foldr: reduceRight, - find: find, - detect: find, filter: filter, select: filter, reject: reject, @@ -4090,7 +4375,6 @@ module.exports = slice; invoke: invoke, pluck: pluck, where: where, - findWhere: findWhere, max: max, min: min, shuffle: shuffle, @@ -4099,9 +4383,11 @@ module.exports = slice; groupBy: groupBy, indexBy: indexBy, countBy: countBy, + partition: partition, toArray: toArray, size: size, - partition: partition, + pick: pick, + omit: omit, first: first, head: first, take: first, @@ -4119,108 +4405,35 @@ module.exports = slice; intersection: intersection, difference: difference, unzip: unzip, + transpose: unzip, zip: zip, object: object, - findIndex: findIndex, - findLastIndex: findLastIndex, - sortedIndex: sortedIndex, - indexOf: indexOf, - lastIndexOf: lastIndexOf, range: range, chunk: chunk, - bind: bind, - partial: partial, - bindAll: bindAll, - memoize: memoize, - delay: delay, - defer: defer, - throttle: throttle, - debounce: debounce, - wrap: wrap, - negate: negate, - compose: compose, - after: after, - before: before, - once: once, - keys: keys, - allKeys: allKeys, - values: values, - mapObject: mapObject, - pairs: pairs, - invert: invert, - functions: functions, - methods: functions, - extend: extend, - extendOwn: extendOwn, - assign: extendOwn, - findKey: findKey, - pick: pick, - omit: omit, - defaults: defaults, - create: create, - clone: clone, - tap: tap, - isMatch: isMatch, - isEqual: isEqual, - isEmpty: isEmpty, - isElement: isElement, - isArray: isArray, - isObject: isObject, - isArguments: isArguments, - isFunction: isFunction, - isString: isString, - isNumber: isNumber, - isDate: isDate, - isRegExp: isRegExp, - isError: isError, - isSymbol: isSymbol, - isMap: isMap, - isWeakMap: isWeakMap, - isSet: isSet, - isWeakSet: isWeakSet, - isFinite: isFinite, - isNaN: isNaN, - isBoolean: isBoolean, - isNull: isNull, - isUndefined: isUndefined, - has: has, - identity: identity, - constant: constant, - noop: noop, - property: property, - propertyOf: propertyOf, - matcher: matcher, - matches: matcher, - times: times, - random: random, - now: now, - escape: escape, - unescape: unescape, - result: result, - uniqueId: uniqueId, - templateSettings: templateSettings, - template: template, - chain: chain, - mixin: mixin - }); + mixin: mixin, + 'default': _$1 + }; + + // Default Export // Add all of the Underscore functions to the wrapper object. - var _$1 = mixin(allExports); - // Legacy Node.js API - _$1._ = _$1; + var _ = mixin(allExports); + // Legacy Node.js API. + _._ = _; - return _$1; + return _; }))); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],"/../../jshint/src/jshint.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/src/jshint.js":[function(_dereq_,module,exports){ /*! * JSHint, by JSHint Community. * - * This file (and this file only) is licensed under the same slightly modified - * MIT license that JSLint is. It stops evil-doers everywhere: + * Licensed under the MIT license. + * + * JSHint is a derivative work of JSLint: * * Copyright (c) 2002 Douglas Crockford (www.JSLint.com) * @@ -4234,8 +4447,6 @@ module.exports = slice; * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * - * The Software shall be used for Good, not Evil. - * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -4249,15 +4460,6 @@ module.exports = slice; /*jshint quotmark:double */ /*exported console */ -/* -_.clone -_.includes -_.isEmpty -_.isNumber -_.reject -_.zip -*/ - var _ = _dereq_("underscore"); _.clone = _dereq_("lodash.clone"); var events = _dereq_("events"); @@ -4471,6 +4673,10 @@ var JSHINT = (function() { combine(predefined, vars.ecmaIdentifiers[8]); } + if (state.inES11()) { + combine(predefined, vars.ecmaIdentifiers[11]); + } + /** * Use `in` to check for the presence of any explicitly-specified value for * `globalstrict` because both `true` and `false` should trigger an error. @@ -4652,9 +4858,10 @@ var JSHINT = (function() { removeIgnoredMessages(); - if (JSHINT.errors.length >= state.option.maxerr) + var errors = JSHINT.errors.filter(function(e) { return /E\d{3}/.test(e.code); }); + if (errors.length >= state.option.maxerr) { quit("E043", t); - + } return w; } @@ -4938,6 +5145,7 @@ var JSHINT = (function() { case "8": case "9": case "10": + case "11": state.option.moz = false; state.option.esversion = +val; break; @@ -4946,6 +5154,7 @@ var JSHINT = (function() { case "2017": case "2018": case "2019": + case "2020": state.option.moz = false; // Translate specification publication year to version number. state.option.esversion = +val - 2009; @@ -4976,6 +5185,7 @@ var JSHINT = (function() { state.option[tn] = !state.option[tn]; } } else if (directiveToken.type === "jshint.unstable") { + /* istanbul ignore next */ state.option.unstable[key] = (val === "true"); } else { state.option[key] = (val === "true"); @@ -5256,7 +5466,6 @@ var JSHINT = (function() { } function nolinebreak(t) { - t = t; if (!sameLine(t, state.tokens.next)) { warning("E022", t, t.value); } @@ -5700,8 +5909,8 @@ var JSHINT = (function() { if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)") { if (left.value === "bigint") { - if (!state.option.unstable.bigint) { - warning("W144", left, "BigInt", "bigint"); + if (!state.inES11()) { + warning("W119", left, "BigInt", "11"); } return false; @@ -5965,18 +6174,18 @@ var JSHINT = (function() { } /** - * Retrieve the value of the current token if it is an identifier and - * optionally advance the parser. + * Retrieve the value of the next token if it is an identifier and optionally + * advance the parser. * * @param {number} context - the parsing context; see `prod-params.js` for * more information - * @param {boolean} [prop] -`true` if this identifier is that of an object - * property + * @param {boolean} [isName] - `true` if an IdentifierName should be consumed + * (e.g. object properties) * @param {boolean} [preserve] - `true` if the token should not be consumed * * @returns {string|undefined} - the value of the identifier, if present */ - function optionalidentifier(context, prop, preserve) { + function optionalidentifier(context, isName, preserve) { if (!state.tokens.next.identifier) { return; } @@ -5986,20 +6195,12 @@ var JSHINT = (function() { } var curr = state.tokens.curr; - var val = state.tokens.curr.value; - - if (!isReserved(context, curr)) { - return val; - } - if (prop) { - if (state.inES5()) { - return val; - } + if (isReserved(context, curr) && !(isName && state.inES5())) { + warning("W024", state.tokens.curr, state.tokens.curr.id); } - warning("W024", state.tokens.curr, state.tokens.curr.id); - return val; + return curr.value; } /** @@ -6037,13 +6238,13 @@ var JSHINT = (function() { * * @param {number} context - the parsing context; see `prod-params.js` for * more information - * @param {boolean} [prop] -`true` if this identifier is that of an object - * property + * @param {boolean} [isName] - `true` if an IdentifierName should be consumed + * (e.g. object properties) * * @returns {string|undefined} - the value of the identifier, if present */ - function identifier(context, prop) { - var i = optionalidentifier(context, prop, false); + function identifier(context, isName) { + var i = optionalidentifier(context, isName, false); if (i) { return i; } @@ -6080,8 +6281,9 @@ var JSHINT = (function() { if (t.reach) { return; } + if (t.id !== "(endline)") { - if (t.id === "function") { + if (isFunction(t, i)) { if (state.option.latedef === true) { warning("W026", t); } @@ -6092,6 +6294,16 @@ var JSHINT = (function() { break; } } + + function isFunction(t, i) { + if (t.id === "function") { + return true; + } + if (t.id === "async") { + t = peek(i); + return t.id === "function"; + } + } } /** @@ -6284,8 +6496,7 @@ var JSHINT = (function() { error("E065", state.tokens.curr); } - // there's no directive negation, so always set to true - state.directive[directive] = true; + state.directive[directive] = state.tokens.curr; parseFinalSemicolon(current); } @@ -6595,11 +6806,14 @@ var JSHINT = (function() { return this; }); - reserve("super", function() { + + (function(superSymbol) { + superSymbol.rbp = 161; + })(reserve("super", function() { superNud.call(state.tokens.curr, this); return this; - }); + })); assignop("=", "assign"); assignop("+=", "assignadd"); @@ -6655,14 +6869,43 @@ var JSHINT = (function() { return that; }, 30); - var orPrecendence = 40; infix("||", function(context, left, that) { increaseComplexityCount(); that.left = left; - that.right = expression(context, orPrecendence); + that.right = expression(context, 40); + return that; + }, 40); + + var andPrecedence = 50; + infix("&&", function(context, left, that) { + increaseComplexityCount(); + that.left = left; + that.right = expression(context, andPrecedence); + return that; + }, andPrecedence); + + infix("??", function(context, left, that) { + if (!left.paren && (left.id === "||" || left.id === "&&")) { + error("E024", that, "??"); + } + + if (!state.inES11()) { + warning("W119", that, "nullish coalescing", "11"); + } + + increaseComplexityCount(); + that.left = left; + var right = that.right = expression(context, 39); + + if (!right) { + error("E024", state.tokens.next, state.tokens.next.id); + } else if (!right.paren && (right.id === "||" || right.id === "&&")) { + error("E024", that.right, that.right.id); + } + return that; - }, orPrecendence); - infix("&&", "and", 50); + }, 39); + // The Exponentiation operator, introduced in ECMAScript 2016 // // ExponentiationExpression[Yield] : @@ -6921,8 +7164,18 @@ var JSHINT = (function() { }); if (mp) { return mp; } + var opening = state.tokens.next; var c = expression(context, 155), i; - if (c && c.id !== "function") { + + if (!c) { + return this; + } + + if (!c.paren && c.rbp > 160) { + error("E024", opening, opening.value); + } + + if (c.id !== "function") { if (c.identifier) { switch (c.value) { case "Number": @@ -6954,7 +7207,9 @@ var JSHINT = (function() { } } } else { - if (c.id !== "." && c.id !== "[" && c.id !== "(") { + if (c.id === "?." && !c.paren) { + error("E024", c, "?."); + } else if (c.id !== "." && c.id !== "[" && c.id !== "(") { /* istanbul ignore next */ warning("W056", state.tokens.curr); } @@ -6972,10 +7227,8 @@ var JSHINT = (function() { state.syntax["new"].exps = true; - // Class statement - blockstmt("class", function(context) { + var classDeclaration = blockstmt("class", function(context) { var className, classNameToken; - var inexport = context & prodParams.export; if (!state.inES6()) { warning("W104", state.tokens.curr, "class", "6"); @@ -7002,16 +7255,18 @@ var JSHINT = (function() { } if (classNameToken) { - this.name = className; + this.name = classNameToken; state.funct["(scope)"].initialize(className); - if (inexport) { - state.funct["(scope)"].setExported(className, classNameToken); - } + } else { + this.name = null; } + state.funct["(scope)"].stack(); classBody(this, context); return this; - }).exps = true; + }); + classDeclaration.exps = true; + classDeclaration.declaration = true; /* Class expression @@ -7042,13 +7297,15 @@ var JSHINT = (function() { state.funct["(scope)"].stack(); if (classNameToken) { - this.name = className; + this.name = classNameToken; state.funct["(scope)"].addbinding(className, { type: "class", initialized: true, token: classNameToken }); state.funct["(scope)"].block.use(className, classNameToken); + } else { + this.name = null; } classBody(this, context); @@ -7253,6 +7510,47 @@ var JSHINT = (function() { return that; }, 160, true); + infix("?.", function(context, left, that) { + if (!state.inES11()) { + warning("W119", state.tokens.curr, "Optional chaining", "11"); + } + + + if (checkPunctuator(state.tokens.next, "[")) { + that.left = left; + advance(); + that.right = state.tokens.curr.led(context, left); + } else if (checkPunctuator(state.tokens.next, "(")) { + that.left = left; + advance(); + that.right = state.tokens.curr.led(context, left); + that.exps = true; + } else { + state.syntax["."].led.call(that, context, left); + } + + if (state.tokens.next.type === "(template)") { + error("E024", state.tokens.next, "`"); + } + + return that; + }, 160, true); + + + /** + * Determine if a CallExpression's "base" is a type of expression commonly + * used in this position. + * + * @param {token} token - token describing the "base" of the CallExpression + * @returns {boolean} + */ + function isTypicalCallExpression(token) { + return token.identifier || token.id === "." || token.id === "[" || + token.id === "=>" || token.id === "(" || token.id === "&&" || + token.id === "||" || token.id === "?" || token.id === "async" || + token.id === "?." || (state.inES6() && token["(name)"]); + } + infix("(", function(context, left, that) { if (state.option.immed && left && !left.immed && left.id === "function") { warning("W062"); @@ -7268,14 +7566,17 @@ var JSHINT = (function() { if (left) { if (left.type === "(identifier)") { - if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) { - if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) { - if (left.value === "Math") { - /* istanbul ignore next */ - warning("W063", left); - } else if (state.option.newcap) { - warning("W064", left); - } + var newcapRe = /^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/; + var newcapIgnore = [ + "Array", "Boolean", "Date", "Error", "Function", "Number", + "Object", "RegExp", "String", "Symbol" + ]; + if (newcapRe.test(left.value) && newcapIgnore.indexOf(left.value) === -1) { + if (left.value === "Math") { + /* istanbul ignore next */ + warning("W063", left); + } else if (state.option.newcap) { + warning("W064", left); } } } @@ -7340,9 +7641,7 @@ var JSHINT = (function() { addEvalCode(left, p[0]); } } - if (!left.identifier && left.id !== "." && left.id !== "[" && left.id !== "=>" && - left.id !== "(" && left.id !== "&&" && left.id !== "||" && left.id !== "?" && - left.id !== "async" && !(state.inES6() && left["(name)"])) { + if (!isTypicalCallExpression(left)) { warning("W067", that); } } @@ -7462,12 +7761,19 @@ var JSHINT = (function() { // Used to cover a unary expression as the left-hand side of the // exponentiation operator (beginsUnaryExpression(ret) && state.tokens.next.id === "**") || + // Used to cover a logical operator as the right-hand side of the + // nullish coalescing operator + (preceeding.id === "??" && (ret.id === "&&" || ret.id === "||")) || // Used to delineate an integer number literal from a dereferencing // punctuator (otherwise interpreted as a decimal point) (ret.type === "(number)" && checkPunctuator(pn, ".") && /^\d+$/.test(ret.value)) || // Used to wrap object destructuring assignment - (opening.beginsStmt && ret.id === "=" && ret.left.id === "{"); + (opening.beginsStmt && ret.id === "=" && ret.left.id === "{") || + // Used to allow optional chaining with other language features which + // are otherwise restricted. + (ret.id === "?." && + (preceeding.id === "new" || state.tokens.next.type === "(template)")); } } @@ -7488,7 +7794,7 @@ var JSHINT = (function() { return ret; }); - application("=>"); + application("=>").rbp = 161; infix("[", function(context, left, that) { var e, s, canUseDot; @@ -7498,7 +7804,7 @@ var JSHINT = (function() { warning("W014", state.tokens.curr, state.tokens.curr.id); } - e = expression(context & ~prodParams.noin, 10); + e = expression(context & ~prodParams.noin, 0); if (e && e.type === "(string)") { if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) { @@ -7667,33 +7973,26 @@ var JSHINT = (function() { return !!state.funct["(method)"]; } - function propertyName(context, preserveOrToken) { - var id; - var preserve = true; - if (typeof preserveOrToken === "object") { - /* istanbul ignore next */ - id = preserveOrToken; - } else { - preserve = preserveOrToken; - id = optionalidentifier(context, true, preserve); - } + /** + * Retrieve the value of the next token if it is a valid LiteralPropertyName + * and optionally advance the parser. + * + * @param {number} context - the parsing context; see `prod-params.js` for + * more information + * + * @returns {string|undefined} - the value of the identifier, if present + */ + function propertyName(context) { + var id = optionalidentifier(context, true); if (!id) { if (state.tokens.next.id === "(string)") { id = state.tokens.next.value; - if (!preserve) { - advance(); - } + advance(); } else if (state.tokens.next.id === "(number)") { id = state.tokens.next.value.toString(); - if (!preserve) { - advance(); - } + advance(); } - /* istanbul ignore next */ - } else if (typeof id === "object") { - if (id.id === "(string)" || id.id === "(identifier)") id = id.value; - else if (id.id === "(number)") id = id.value.toString(); } if (id === "hasOwnProperty") { @@ -7751,6 +8050,8 @@ var JSHINT = (function() { // are added to the param scope var currentParams = []; + pastRest = spreadrest("rest"); + if (_.includes(["{", "["], state.tokens.next.id)) { hasDestructuring = true; tokens = destructuringPattern(context); @@ -7762,7 +8063,6 @@ var JSHINT = (function() { } } } else { - pastRest = spreadrest("rest"); ident = identifier(context); if (ident) { @@ -8220,10 +8520,11 @@ var JSHINT = (function() { if (!state.inES6()) { warning("W104", state.tokens.next, "object short notation", "6"); } - i = propertyName(context, true); - saveProperty(props, i, state.tokens.next); - - expression(context, 10); + t = expression(context, 10); + i = t && t.value; + if (t) { + saveProperty(props, i, t); + } } else if (peek().id !== ":" && (nextVal === "get" || nextVal === "set")) { advance(nextVal); @@ -8557,7 +8858,6 @@ var JSHINT = (function() { // used for both let and const statements var noin = context & prodParams.noin; - var inexport = context & prodParams.export; var isLet = type === "let"; var isConst = type === "const"; var tokens, lone, value, letblock; @@ -8647,10 +8947,6 @@ var JSHINT = (function() { if (tokens.hasOwnProperty(t)) { t = tokens[t]; state.funct["(scope)"].initialize(t.id); - - if (lone && inexport) { - state.funct["(scope)"].setExported(t.token.value, t.token); - } } } } @@ -8752,7 +9048,6 @@ var JSHINT = (function() { var varstatement = stmt("var", function(context) { var noin = context & prodParams.noin; - var inexport = context & prodParams.export; var tokens, lone, value, id; this.first = []; @@ -8795,9 +9090,6 @@ var JSHINT = (function() { type: "var", token: t.token }); - if (lone && inexport) { - state.funct["(scope)"].setExported(t.id, t.token); - } names.push(t.token); } } @@ -8870,25 +9162,21 @@ var JSHINT = (function() { if (inblock) { warning("W082", state.tokens.curr); } - var nameToken = optionalidentifier(context) ? state.tokens.curr : null; + this.name = optionalidentifier(context) ? state.tokens.curr : null; - if (!nameToken) { + if (!this.name) { if (!inexport) { warning("W025"); } } else { - state.funct["(scope)"].addbinding(nameToken.value, { + state.funct["(scope)"].addbinding(this.name.value, { type: labelType, token: state.tokens.curr, initialized: true }); - - if (inexport) { - state.funct["(scope)"].setExported(nameToken.value, state.tokens.prev); - } } var f = doFunction(context, { - name: nameToken && nameToken.value, + name: this.name && this.name.value, statement: this, type: generator ? "generator" : null, ignoreLoopFunc: inblock // a declaration may already have warned @@ -8901,13 +9189,16 @@ var JSHINT = (function() { // mode (the scope manager will not report an error because a declaration // does not introduce a binding into the function's environment record). var enablesStrictMode = f["(isStrict)"] && !state.isStrict(); - if (nameToken && (f["(name)"] === "arguments" || f["(name)"] === "eval") && + if (this.name && (f["(name)"] === "arguments" || f["(name)"] === "eval") && enablesStrictMode) { - error("E008", nameToken); + error("E008", this.name); } - if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) { - /* istanbul ignore next */ + // Although the parser correctly recognizes the statement boundary in this + // condition, it's support for the invalid "empty grouping" expression + // makes it tolerant of productions such as `function f() {}();`. + if (state.tokens.next.id === "(" && peek().id === ")" && peek(1).id !== "=>" && + state.tokens.next.line === state.tokens.curr.line) { error("E039"); } return this; @@ -8930,21 +9221,21 @@ var JSHINT = (function() { // This context modification restricts the use of `await` as the optional // BindingIdentifier in async function expressions. - var nameToken = optionalidentifier(isAsync ? context | prodParams.async : context) ? + this.name = optionalidentifier(isAsync ? context | prodParams.async : context) ? state.tokens.curr : null; var f = doFunction(context, { - name: nameToken && nameToken.value, + name: this.name && this.name.value, type: generator ? "generator" : null }); - if (generator && nameToken && nameToken.value === "yield") { - error("E024", nameToken, "yield"); + if (generator && this.name && this.name.value === "yield") { + error("E024", this.name, "yield"); } - if (nameToken && (f["(name)"] === "arguments" || f["(name)"] === "eval") && + if (this.name && (f["(name)"] === "arguments" || f["(name)"] === "eval") && f["(isStrict)"]) { - error("E008", nameToken); + error("E008", this.name); } return this; @@ -9008,7 +9299,7 @@ var JSHINT = (function() { var tokens = destructuringPattern(context); _.each(tokens, function(token) { if (token.id) { - state.funct["(scope)"].addParam(token.id, token, "exception"); + state.funct["(scope)"].addParam(token.id, token.token, "exception"); } }); } else if (state.tokens.next.type !== "(identifier)") { @@ -9445,9 +9736,9 @@ var JSHINT = (function() { if (foreachtok) { error("E045", foreachtok); } - nolinebreak(state.tokens.curr); + advance(";"); - if (decl) { + if (decl && decl.first && decl.first[0]) { if (decl.value === "const" && !decl.hasInitializer) { warning("E012", decl, decl.first[0].value); } @@ -9463,7 +9754,7 @@ var JSHINT = (function() { if (state.tokens.next.id !== ";") { checkCondAssignment(expression(context, 0)); } - nolinebreak(state.tokens.curr); + advance(";"); if (state.tokens.next.id === ";") { error("E021", state.tokens.next, ")", ";"); @@ -9496,9 +9787,6 @@ var JSHINT = (function() { stmt("break", function() { var v = state.tokens.next.value; - if (!state.option.asi) - nolinebreak(this); - if (state.tokens.next.identifier && sameLine(state.tokens.curr, state.tokens.next)) { if (!state.funct["(scope)"].funct.hasLabel(v)) { @@ -9524,9 +9812,6 @@ var JSHINT = (function() { warning("W052", state.tokens.next, this.value); } - if (!state.option.asi) - nolinebreak(this); - if (state.tokens.next.identifier) { if (sameLine(state.tokens.curr, state.tokens.next)) { if (!state.funct["(scope)"].funct.hasLabel(v)) { @@ -9751,7 +10036,35 @@ var JSHINT = (function() { return this; }).exps = true; - stmt("import", function(context) { + prefix("import", function(context) { + var mp = metaProperty(context, "meta", function() { + if (!state.inES11(true)) { + warning("W119", state.tokens.prev, "import.meta", "11"); + } + if (!state.option.module) { + error("E070", state.tokens.prev); + } + }); + + if (mp) { + return mp; + } + + if (!checkPunctuator(state.tokens.next, "(")) { + return state.syntax["(identifier)"].nud.call(this, context); + } + + if (!state.inES11()) { + warning("W119", state.tokens.curr, "dynamic import", "11"); + } + + advance("("); + expression(context, 10); + advance(")"); + return this; + }); + + var importSymbol = stmt("import", function(context) { if (!state.funct["(scope)"].block.isGlobal()) { error("E053", state.tokens.curr, "Import"); } @@ -9811,15 +10124,12 @@ var JSHINT = (function() { break; } var importName; - if (state.tokens.next.type === "default") { - importName = "default"; - advance("default"); - } else { - importName = identifier(context); - } - if (state.tokens.next.value === "as") { + if (peek().value === "as") { + identifier(context, true); advance("as"); importName = identifier(context); + } else { + importName = identifier(context); } // Import bindings are immutable (see ES6 8.1.1.5.5) @@ -9853,12 +10163,18 @@ var JSHINT = (function() { // } return this; - }).exps = true; + }); + importSymbol.exps = true; + importSymbol.reserved = true; + importSymbol.meta = { isFutureReservedWord: true, es5: true }; + importSymbol.useFud = function() { + return !(checkPunctuators(state.tokens.next, [".", "("])); + }; + importSymbol.rbp = 161; stmt("export", function(context) { var ok = true; var token; - var identifier; var moduleSpecifier; context = context | prodParams.export; @@ -9874,7 +10190,18 @@ var JSHINT = (function() { if (state.tokens.next.value === "*") { // ExportDeclaration :: export * FromClause + // ExportDeclaration :: export * as IdentifierName FromClause advance("*"); + + if (state.tokens.next.value === "as") { + if (!state.inES11()) { + warning("W119", state.tokens.curr, "export * as ns from", "11"); + } + advance("as"); + identifier(context, true); + state.funct["(scope)"].setExported(null, state.tokens.curr); + } + advance("from"); advance("(string)"); return this; @@ -9891,26 +10218,27 @@ var JSHINT = (function() { state.nameStack.set(state.tokens.next); advance("default"); + var def = state.tokens.curr; var exportType = state.tokens.next.id; if (exportType === "function") { this.block = true; advance("function"); - state.syntax["function"].fud(context); + token = state.syntax["function"].fud(context); + state.funct["(scope)"].setExported(token.name, def); } else if (exportType === "async" && peek().id === "function") { this.block = true; advance("async"); advance("function"); - state.syntax["function"].fud(context | prodParams.preAsync); + token = state.syntax["function"].fud(context | prodParams.preAsync); + state.funct["(scope)"].setExported(token.name, def); } else if (exportType === "class") { this.block = true; advance("class"); - state.syntax["class"].fud(context); + token = state.syntax["class"].fud(context); + state.funct["(scope)"].setExported(token.name, def); } else { - token = expression(context, 10); - if (token.identifier) { - identifier = token.value; - state.funct["(scope)"].setExported(identifier, token); - } + expression(context, 10); + state.funct["(scope)"].setExported(null, def); } return this; } @@ -9925,15 +10253,22 @@ var JSHINT = (function() { } advance(); - exportedTokens.push(state.tokens.curr); - if (state.tokens.next.value === "as") { advance("as"); if (!state.tokens.next.identifier) { /* istanbul ignore next */ error("E030", state.tokens.next, state.tokens.next.value); } + exportedTokens.push({ + local: state.tokens.prev, + export: state.tokens.next + }); advance(); + } else { + exportedTokens.push({ + local: state.tokens.curr, + export: state.tokens.curr + }); } if (!checkPunctuator(state.tokens.next, "}")) { @@ -9947,8 +10282,8 @@ var JSHINT = (function() { moduleSpecifier = state.tokens.next; advance("(string)"); } else if (ok) { - exportedTokens.forEach(function(token) { - state.funct["(scope)"].setExported(token.value, token); + exportedTokens.forEach(function(x) { + state.funct["(scope)"].setExported(x.local, x.export); }); } @@ -9964,31 +10299,43 @@ var JSHINT = (function() { } else if (state.tokens.next.id === "var") { // ExportDeclaration :: export VariableStatement advance("var"); - state.tokens.curr.fud(context); + token = state.tokens.curr.fud(context); + token.first.forEach(function(binding) { + state.funct["(scope)"].setExported(binding, binding); + }); } else if (state.tokens.next.id === "let") { // ExportDeclaration :: export VariableStatement advance("let"); - state.tokens.curr.fud(context); + token = state.tokens.curr.fud(context); + token.first.forEach(function(binding) { + state.funct["(scope)"].setExported(binding, binding); + }); } else if (state.tokens.next.id === "const") { // ExportDeclaration :: export VariableStatement advance("const"); - state.tokens.curr.fud(context); + token = state.tokens.curr.fud(context); + token.first.forEach(function(binding) { + state.funct["(scope)"].setExported(binding, binding); + }); } else if (state.tokens.next.id === "function") { // ExportDeclaration :: export Declaration this.block = true; advance("function"); - state.syntax["function"].fud(context); + token = state.syntax["function"].fud(context); + state.funct["(scope)"].setExported(token.name, token.name); } else if (state.tokens.next.id === "async" && peek().id === "function") { // ExportDeclaration :: export Declaration this.block = true; advance("async"); advance("function"); - state.syntax["function"].fud(context | prodParams.preAsync); + token = state.syntax["function"].fud(context | prodParams.preAsync); + state.funct["(scope)"].setExported(token.name, token.name); } else if (state.tokens.next.id === "class") { // ExportDeclaration :: export Declaration this.block = true; advance("class"); - state.syntax["class"].fud(context); + token = state.syntax["class"].fud(context); + state.funct["(scope)"].setExported(token.name, token.name); } else { /* istanbul ignore next */ error("E024", state.tokens.next, state.tokens.next.value); @@ -10060,7 +10407,6 @@ var JSHINT = (function() { FutureReservedWord("float"); FutureReservedWord("goto"); FutureReservedWord("implements", { es5: true, strictOnly: true }); - FutureReservedWord("import", { es5: true }); FutureReservedWord("int"); FutureReservedWord("interface", { es5: true, strictOnly: true }); FutureReservedWord("long"); @@ -10733,7 +11079,7 @@ var JSHINT = (function() { if (state.directive["use strict"]) { if (!state.allowsGlobalUsd()) { - warning("W097", state.tokens.prev); + warning("W097", state.directive["use strict"]); } } @@ -10851,7 +11197,7 @@ if (typeof exports === "object" && exports) { exports.JSHINT = JSHINT; } -},{"./lex.js":"/../../jshint/src/lex.js","./messages.js":"/../../jshint/src/messages.js","./options.js":"/../../jshint/src/options.js","./prod-params.js":"/../../jshint/src/prod-params.js","./reg.js":"/../../jshint/src/reg.js","./scope-manager.js":"/../../jshint/src/scope-manager.js","./state.js":"/../../jshint/src/state.js","./style.js":"/../../jshint/src/style.js","./vars.js":"/../../jshint/src/vars.js","console-browserify":"/../../jshint/node_modules/console-browserify/index.js","events":"/../node_modules/events/events.js","lodash.clone":"/../../jshint/node_modules/lodash.clone/index.js","underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/lex.js":[function(_dereq_,module,exports){ +},{"./lex.js":"/../../../jshint/src/lex.js","./messages.js":"/../../../jshint/src/messages.js","./options.js":"/../../../jshint/src/options.js","./prod-params.js":"/../../../jshint/src/prod-params.js","./reg.js":"/../../../jshint/src/reg.js","./scope-manager.js":"/../../../jshint/src/scope-manager.js","./state.js":"/../../../jshint/src/state.js","./style.js":"/../../../jshint/src/style.js","./vars.js":"/../../../jshint/src/vars.js","console-browserify":"/../../../jshint/node_modules/console-browserify/index.js","events":"/node_modules/events/events.js","lodash.clone":"/../../../jshint/node_modules/lodash.clone/index.js","underscore":"/../../../jshint/node_modules/underscore/underscore-umd.js"}],"/../../../jshint/src/lex.js":[function(_dereq_,module,exports){ /* * Lexical analysis and token construction. */ @@ -11103,7 +11449,6 @@ Lexer.prototype = { case "]": case ":": case "~": - case "?": return { type: Token.Punctuator, value: ch1 @@ -11143,6 +11488,22 @@ Lexer.prototype = { ch2 = this.peek(1); ch3 = this.peek(2); + + if (ch1 === "?") { + // Optional chaining + if (ch2 === "." && !reg.decimalDigit.test(ch3)) { + return { + type: Token.Punctuator, + value: "?." + }; + } + + return { + type: Token.Punctuator, + value: ch2 === "?" ? "??" : "?" + }; + } + ch4 = this.peek(3); // 4-character punctuator: >>>= @@ -11606,6 +11967,7 @@ Lexer.prototype = { var isAllowedDigit = isDecimalDigit; var base = 10; var isLegacy = false; + var isNonOctal = false; function isDecimalDigit(str) { return (/^[0-9]$/).test(str); @@ -11615,6 +11977,10 @@ Lexer.prototype = { return (/^[0-7]$/).test(str); } + function isNonOctalDigit(str) { + return str === "8" || str === "9"; + } + function isBinaryDigit(str) { return (/^[01]$/).test(str); } @@ -11697,25 +12063,22 @@ Lexer.prototype = { base = 8; isLegacy = true; - index += 1; - value += char; - } - - // Decimal numbers that start with '0' such as '09' are illegal - // but we still parse them and return as malformed. - - if (!isOctalDigit(char) && isDecimalDigit(char)) { - index += 1; - value += char; + } else if (isDecimalDigit(char)) { + isNonOctal = true; } } while (index < length) { char = this.peek(index); - // Numbers like '019' (note the 9) are not valid octals - // but we still parse them and mark as malformed. - if (!(isLegacy && isDecimalDigit(char)) && !isAllowedDigit(char)) { + if (isLegacy && isNonOctalDigit(char)) { + base = 10; + isLegacy = false; + isNonOctal = true; + isAllowedDigit = isDecimalDigit; + } + + if (!isAllowedDigit(char)) { break; } value += char; @@ -11726,14 +12089,26 @@ Lexer.prototype = { if (isAllowedDigit !== isDecimalDigit || isBigInt) { if (isBigInt) { - if (!state.option.unstable.bigint) { + this.triggerAsync( + "warning", + { + code: "W119", + line: this.line, + character: this.char, + data: [ "BigInt", "11" ] + }, + checks, + function() { return !state.inES11(); } + ); + + if (isLegacy || isNonOctal) { this.triggerAsync( - "warning", + "error", { - code: "W144", + code: "E067", line: this.line, character: this.char, - data: [ "BigInt", "bigint" ] + data: [value + char] }, checks, function() { return true; } @@ -11820,11 +12195,20 @@ Lexer.prototype = { } } + // TODO: Extend this check to other numeric literals + this.triggerAsync("warning", { + code: "W045", + line: this.line, + character: this.char + value.length, + data: [ value ] + }, checks, function() { return !isFinite(value); }); + return { type: Token.NumericLiteral, value: value, base: base, - isMalformed: !isFinite(value) + isNonOctal: isNonOctal, + isMalformed: false }; }, @@ -11930,9 +12314,6 @@ Lexer.prototype = { case "\\": char = "\\\\"; break; - case "\"": - char = "\\\""; - break; case "/": break; case "": @@ -12269,6 +12650,60 @@ Lexer.prototype = { } } + if (char === "p" || char === "P") { + var y = index + 2; + sequence = ""; + next = ""; + + if (this.peek(index + 1) === "{") { + next = this.peek(y); + while (next && next !== "}") { + sequence += next; + y += 1; + next = this.peek(y); + } + } + + // Module loading is intentionally deferred as an optimization for + // Node.js users who do not use Unicode escape sequences. + if (!sequence || !_dereq_("./validate-unicode-escape-sequence")(sequence)) { + this.triggerAsync( + "error", + { + code: "E016", + line: this.line, + character: this.char, + data: [ "Invalid Unicode property escape sequence" ] + }, + checks, + hasUFlag + ); + } + + if (sequence) { + sequence = char + "{" + sequence + "}"; + body += sequence; + value += sequence; + index = y + 1; + + if (!state.inES9()) { + this.triggerAsync( + "warning", + { + code: "W119", + line: this.line, + character: this.char, + data: [ "Unicode property escape", "9" ] + }, + checks, + hasUFlag + ); + } + + return sequence; + } + } + // Unexpected control character if (char < " ") { malformed = true; @@ -12841,7 +13276,8 @@ Lexer.prototype = { if (type === "(identifier)") { if (value === "return" || value === "case" || value === "yield" || value === "typeof" || value === "instanceof" || value === "void" || - value === "await") { + value === "await" || value === "new" || value === "delete" || + value === "default" || value === "extends") { this.prereg = true; } @@ -12996,10 +13432,8 @@ Lexer.prototype = { case Token.NumericLiteral: if (token.isMalformed) { - // This condition unequivocally describes a syntax error. - // TODO: Re-factor as an "error" (not a "warning"). - this.trigger("warning", { - code: "W045", + this.trigger("error", { + code: "E067", line: this.line, character: this.char, data: [ token.value ] @@ -13021,6 +13455,14 @@ Lexer.prototype = { return state.isStrict() && token.base === 8 && token.isLegacy; }); + this.triggerAsync("error", { + code: "E068", + line: this.line, + character: this.char + }, checks, function() { + return state.isStrict() && token.isNonOctal; + }); + this.trigger("Number", { line: this.line, char: this.char, @@ -13061,7 +13503,7 @@ Lexer.prototype = { exports.Lexer = Lexer; exports.Context = Context; -},{"../data/ascii-identifier-data.js":"/../../jshint/data/ascii-identifier-data.js","../data/es5-identifier-names.js":"/../../jshint/data/es5-identifier-names.js","../data/non-ascii-identifier-part-only.js":"/../../jshint/data/non-ascii-identifier-part-only.js","../data/non-ascii-identifier-start.js":"/../../jshint/data/non-ascii-identifier-start.js","./reg.js":"/../../jshint/src/reg.js","./state.js":"/../../jshint/src/state.js","events":"/../node_modules/events/events.js","underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/messages.js":[function(_dereq_,module,exports){ +},{"../data/ascii-identifier-data.js":"/../../../jshint/data/ascii-identifier-data.js","../data/es5-identifier-names.js":"/../../../jshint/data/es5-identifier-names.js","../data/non-ascii-identifier-part-only.js":"/../../../jshint/data/non-ascii-identifier-part-only.js","../data/non-ascii-identifier-start.js":"/../../../jshint/data/non-ascii-identifier-start.js","./reg.js":"/../../../jshint/src/reg.js","./state.js":"/../../../jshint/src/state.js","./validate-unicode-escape-sequence":"/../../../jshint/src/validate-unicode-escape-sequence.js","events":"/node_modules/events/events.js","underscore":"/../../../jshint/node_modules/underscore/underscore-umd.js"}],"/../../../jshint/src/messages.js":[function(_dereq_,module,exports){ "use strict"; var _ = _dereq_("underscore"); @@ -13146,7 +13588,11 @@ var errors = { E064: "Super call may only be used within class method bodies.", E065: "Functions defined outside of strict mode with non-simple parameter lists may not " + "enable strict mode.", - E066: "Asynchronous iteration is only available with for-of loops." + E066: "Asynchronous iteration is only available with for-of loops.", + E067: "Malformed numeric literal: '{a}'.", + E068: "Decimals with leading zeros are not allowed in strict mode.", + E069: "Duplicate exported binding: '{a}'.", + E070: "import.meta may only be used in module code." }; var warnings = { @@ -13195,7 +13641,8 @@ var warnings = { W042: "Avoid EOL escaping.", W043: "Bad escaping of EOL. Use option multistr if needed.", W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */ - W045: "Bad number '{a}'.", + W045: "Value described by numeric literal cannot be accurately " + + "represented with a number value: '{a}'.", W046: "Don't use extra leading zeros '{a}'.", W047: "A trailing decimal point can be confused with a dot: '{a}'.", W048: "Unexpected control character in regular expression.", @@ -13219,7 +13666,7 @@ var warnings = { W064: "Missing 'new' prefix when invoking a constructor.", W065: "Missing radix parameter.", W066: "Implied eval. Consider passing a function instead of a string.", - W067: "Bad invocation.", + W067: "Unorthodox function invocation.", W068: "Wrapping non-IIFE function literals in parens is unnecessary.", W069: "['{a}'] is better written in dot notation.", W070: "Extra comma. (it breaks older versions of IE)", @@ -13329,7 +13776,7 @@ _.each(info, function(desc, code) { exports.info[code] = { code: code, desc: desc }; }); -},{"underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/name-stack.js":[function(_dereq_,module,exports){ +},{"underscore":"/../../../jshint/node_modules/underscore/underscore-umd.js"}],"/../../../jshint/src/name-stack.js":[function(_dereq_,module,exports){ /** * The NameStack class is used to approximate function name inference as * introduced by ECMAScript 2015. In that edition, the `name` property of @@ -13425,7 +13872,7 @@ NameStack.prototype.infer = function() { module.exports = NameStack; -},{}],"/../../jshint/src/options.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/src/options.js":[function(_dereq_,module,exports){ "use strict"; // These are the JSHint boolean options. @@ -14248,7 +14695,7 @@ exports.val = { indent : false, /** - * This options allows you to set the maximum amount of warnings JSHint will + * This options allows you to set the maximum amount of errors JSHint will * produce before giving up. Default is 50. */ maxerr : false, @@ -14476,9 +14923,13 @@ exports.val = { * 9](https://www.ecma-international.org/ecma-262/9.0/index.html). Notable * additions: asynchronous iteration, rest/spread properties, and various * RegExp extensions - * - `10` - To enable language features introduced by ECMAScript + * - `10` - To enable language features introduced by [ECMAScript * 10](https://www.ecma-international.org/ecma-262/10.0/index.html). * Notable additions: optional catch bindings. + * - `11` - To enable language features introduced by ECMAScript 11. Notable + * additions: "export * as ns from 'module'", `import.meta`, the nullish + * coalescing operator, the BigInt type, the `globalThis` binding, + * optional chaining, and dynamic import. */ esversion: 5 }; @@ -14490,17 +14941,6 @@ exports.val = { * right to remove or modify them between major version releases. */ exports.unstable = { - /** - * [The BigInt proposal](https://github.com/tc39/proposal-bigint) extends the - * language's grammer for numeric literals to support integer values of - * arbitrary precision. It also introduces a new value of the `typeof` - * operator, "bigint". - * - * Mathematical operations which use both BigInt and traditional ECMAScript - * Number values may not have the intended effect. Due to the weakly-typed - * nature of the language, JSHint is unable to identify such cases. - */ - bigint: true }; // These are JSHint boolean options which are shared with JSLint @@ -14553,7 +14993,7 @@ exports.noenforceall = { regexpu: true }; -},{}],"/../../jshint/src/prod-params.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/src/prod-params.js":[function(_dereq_,module,exports){ /** * This module defines a set of enum-like values intended for use as bit * "flags" during parsing. The ECMAScript grammar defines a number of such @@ -14603,7 +15043,7 @@ module.exports = { yield: 64 }; -},{}],"/../../jshint/src/reg.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/src/reg.js":[function(_dereq_,module,exports){ /* * Regular expressions. Some of these are stupidly long. */ @@ -14657,17 +15097,33 @@ exports.regexpQuantifiers = /[*+?{]/; exports.regexpControlEscapes = /[fnrtv]/; -exports.regexpCharClasses = /[dDsSwW]/; +exports.regexpCharClasses = /[dDsSwWpP]/; // Identifies the "dot" atom in regular expressions exports.regexpDot = /(^|[^\\])(\\\\)*\./; -},{}],"/../../jshint/src/scope-manager.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/src/scope-manager.js":[function(_dereq_,module,exports){ "use strict"; +/** + * A note on `__proto__`: + * + * This file uses ordinary objects to track identifiers that are observed in + * the input source code. It creates these objects using `Object.create` so + * that the tracking objects have no prototype, allowing the `__proto__` + * property to be used to store a value *without* triggering the invocation of + * the built-in `Object.prototype.__proto__` accessor method. Some environments + * (e.g. PhantomJS) do not implement the correct semantics for property + * enumeration. In those environments, methods like `Object.keys` and Lodash's + * `values` do not include the property name. This file includes a number of + * branches which ensure that JSHint behaves consistently in those + * environments. The branches must be ignored by the test coverage verification + * system because the workaround is not necessary in the environment where + * coverage is verified (i.e. Node.js). + */ -var _ = _dereq_("underscore"); -_.slice = _dereq_("lodash.slice"); -var events = _dereq_("events"); +var _ = _dereq_("underscore"); +_.slice = _dereq_("lodash.slice"); +var events = _dereq_("events"); // Used to denote membership in lookup tables (a primitive value such as `true` // would be silently rejected for the property name "__proto__" in some @@ -14714,6 +15170,7 @@ var scopeManager = function(state, predefined, exported, declared) { var usedPredefinedAndGlobals = Object.create(null); var impliedGlobals = Object.create(null); var unuseds = []; + var esModuleExports = []; var emitter = new events.EventEmitter(); function warning(code, token) { @@ -14787,34 +15244,21 @@ var scopeManager = function(state, predefined, exported, declared) { * Check the current scope for unused identifiers */ function _checkForUnused() { - // function parameters are validated by a dedicated function - // assume that parameters are the only thing declared in the param scope - if (_current["(type)"] === "functionparams") { - _checkParams(); - return; - } - var currentBindings = _current["(bindings)"]; - for (var bindingName in currentBindings) { - if (currentBindings[bindingName]["(type)"] !== "exception" && - currentBindings[bindingName]["(unused)"]) { - _warnUnused(bindingName, currentBindings[bindingName]["(token)"], "var"); + if (_current["(type)"] !== "functionparams") { + var currentBindings = _current["(bindings)"]; + for (var bindingName in currentBindings) { + if (currentBindings[bindingName]["(type)"] !== "exception" && + currentBindings[bindingName]["(unused)"]) { + _warnUnused(bindingName, currentBindings[bindingName]["(token)"], "var"); + } } + return; } - } - /** - * Check the current scope for unused parameters and issue warnings as - * necessary. This function may only be invoked when the current scope is a - * "function parameter" scope. - */ - function _checkParams() { + // Check the current scope for unused parameters and issue warnings as + // necessary. var params = _current["(params)"]; - if (!params) { - /* istanbul ignore next */ - return; - } - var param = params.pop(); var unused_opt; @@ -14970,6 +15414,7 @@ var scopeManager = function(state, predefined, exported, declared) { var currentBindings = _current["(bindings)"]; var usedBindingNameList = Object.keys(currentUsages); + // See comment, "A note on `__proto__`" /* istanbul ignore if */ if (currentUsages.__proto__ && usedBindingNameList.indexOf("__proto__") === -1) { usedBindingNameList.push("__proto__"); @@ -15199,8 +15644,9 @@ var scopeManager = function(state, predefined, exported, declared) { if (usage["(onlyUsedSubFunction)"]) { _latedefWarning(type, bindingName, token); } else { - // this is a clear illegal usage for block scoped variables - warning("E056", token, bindingName, type); + // this is a clear illegal usage, but not a syntax error, so emit a + // warning and not an error + warning("W003", token, bindingName); } } }, @@ -15248,9 +15694,7 @@ var scopeManager = function(state, predefined, exported, declared) { // jshint proto: true var list = Object.keys(usedPredefinedAndGlobals); - // If `__proto__` is used as a global variable name, its entry in the - // lookup table may not be enumerated by `Object.keys` (depending on the - // environment). + // See comment, "A note on `__proto__`" /* istanbul ignore if */ if (usedPredefinedAndGlobals.__proto__ === marker && list.indexOf("__proto__") === -1) { @@ -15270,9 +15714,7 @@ var scopeManager = function(state, predefined, exported, declared) { var values = _.values(impliedGlobals); var hasProto = false; - // If `__proto__` is an implied global variable, its entry in the lookup - // table may not be enumerated by `_.values` (depending on the - // environment). + // See comment, "A note on `__proto__`" if (impliedGlobals.__proto__) { hasProto = values.some(function(value) { return value.name === "__proto__"; @@ -15347,7 +15789,6 @@ var scopeManager = function(state, predefined, exported, declared) { return; } } else { - /* istanbul ignore next */ break; } } @@ -15361,8 +15802,18 @@ var scopeManager = function(state, predefined, exported, declared) { * @param {string} bindingName - the value of the identifier * @param {object} token */ - setExported: function(bindingName, token) { - this.block.use(bindingName, token); + setExported: function(localName, exportName) { + if (exportName) { + if (esModuleExports.indexOf(exportName.value) > -1) { + error("E069", exportName, exportName.value); + } + + esModuleExports.push(exportName.value); + } + + if (localName) { + this.block.use(localName.value, localName); + } }, /** @@ -15703,7 +16154,7 @@ var scopeManager = function(state, predefined, exported, declared) { module.exports = scopeManager; -},{"events":"/../node_modules/events/events.js","lodash.slice":"/../../jshint/node_modules/lodash.slice/index.js","underscore":"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/state.js":[function(_dereq_,module,exports){ +},{"events":"/node_modules/events/events.js","lodash.slice":"/../../../jshint/node_modules/lodash.slice/index.js","underscore":"/../../../jshint/node_modules/underscore/underscore-umd.js"}],"/../../../jshint/src/state.js":[function(_dereq_,module,exports){ "use strict"; var NameStack = _dereq_("./name-stack.js"); @@ -15716,7 +16167,7 @@ var state = { * @returns {boolean} */ isStrict: function() { - return this.directive["use strict"] || this.inClassBody || + return !!this.directive["use strict"] || this.inClassBody || this.option.module || this.option.strict === "implied"; }, @@ -15771,6 +16222,15 @@ var state = { return this.option.moz; }, + /** + * Determine if constructs introduced in ECMAScript 11 should be accepted. + * + * @returns {boolean} + */ + inES11: function() { + return this.esVersion >= 11; + }, + /** * Determine if constructs introduced in ECMAScript 10 should be accepted. * @@ -15883,6 +16343,10 @@ var state = { this.esVersion = 5; this.funct = null; this.ignored = {}; + /** + * A lookup table for active directives whose keys are the value of the + * directives and whose values are the tokens which enabled the directives. + */ this.directive = Object.create(null); this.jsonMode = false; this.lines = []; @@ -15897,7 +16361,7 @@ var state = { exports.state = state; -},{"./name-stack.js":"/../../jshint/src/name-stack.js"}],"/../../jshint/src/style.js":[function(_dereq_,module,exports){ +},{"./name-stack.js":"/../../../jshint/src/name-stack.js"}],"/../../../jshint/src/style.js":[function(_dereq_,module,exports){ "use strict"; exports.register = function(linter) { @@ -16043,7 +16507,543 @@ exports.register = function(linter) { }); }; -},{}],"/../../jshint/src/vars.js":[function(_dereq_,module,exports){ +},{}],"/../../../jshint/src/validate-unicode-escape-sequence.js":[function(_dereq_,module,exports){ +/* + * Determine whether a given string is a valid UnicodePropertyValueExpression. + */ + +"use strict"; + +module.exports = function validate(sequence) { + var equalSignIndex = sequence.indexOf("="); + + if (equalSignIndex === -1) { + return sequence in names.binary || sequence in values.general; + } + + var name = sequence.substr(0, equalSignIndex); + var value = sequence.substr(equalSignIndex + 1); + + if (name === "General_Category" || name === "gc") { + return value in values.general; + } if (name === "Script" || name === "sc" || name === "Script_Extensions" || name === "scx") { + return value in values.script; + } + + return false; +}; + + +var names = { + nonBinary: Object.create(null), + binary: Object.create(null) +}; +var values = { + general: Object.create(null), + script: Object.create(null) +}; + +var nb = names.nonBinary; +nb.General_Category = true; +nb.gc = true; +nb.Script = true; +nb.sc = true; +nb.Script_Extensions = true; +nb.scx = true; + +var b = names.binary; +b.ASCII = true; +b.ASCII_Hex_Digit = true; +b.AHex = true; +b.Alphabetic = true; +b.Alpha = true; +b.Any = true; +b.Assigned = true; +b.Bidi_Control = true; +b.Bidi_C = true; +b.Bidi_Mirrored = true; +b.Bidi_M = true; +b.Case_Ignorable = true; +b.CI = true; +b.Cased = true; +b.Changes_When_Casefolded = true; +b.CWCF = true; +b.Changes_When_Casemapped = true; +b.CWCM = true; +b.Changes_When_Lowercased = true; +b.CWL = true; +b.Changes_When_NFKC_Casefolded = true; +b.CWKCF = true; +b.Changes_When_Titlecased = true; +b.CWT = true; +b.Changes_When_Uppercased = true; +b.CWU = true; +b.Dash = true; +b.Default_Ignorable_Code_Point = true; +b.DI = true; +b.Deprecated = true; +b.Dep = true; +b.Diacritic = true; +b.Dia = true; +b.Emoji = true; +b.Emoji_Component = true; +b.EComp = true; +b.Emoji_Modifier = true; +b.EMod = true; +b.Emoji_Modifier_Base = true; +b.EBase = true; +b.Emoji_Presentation = true; +b.EPres = true; +b.Extended_Pictographic = true; +b.ExtPict = true; +b.Extender = true; +b.Ext = true; +b.Grapheme_Base = true; +b.Gr_Base = true; +b.Grapheme_Extend = true; +b.Gr_Ext = true; +b.Hex_Digit = true; +b.Hex = true; +b.IDS_Binary_Operator = true; +b.IDSB = true; +b.IDS_Trinary_Operator = true; +b.IDST = true; +b.ID_Continue = true; +b.IDC = true; +b.ID_Start = true; +b.IDS = true; +b.Ideographic = true; +b.Ideo = true; +b.Join_Control = true; +b.Join_C = true; +b.Logical_Order_Exception = true; +b.LOE = true; +b.Lowercase = true; +b.Lower = true; +b.Math = true; +b.Noncharacter_Code_Point = true; +b.NChar = true; +b.Pattern_Syntax = true; +b.Pat_Syn = true; +b.Pattern_White_Space = true; +b.Pat_WS = true; +b.Quotation_Mark = true; +b.QMark = true; +b.Radical = true; +b.Regional_Indicator = true; +b.RI = true; +b.Sentence_Terminal = true; +b.STerm = true; +b.Soft_Dotted = true; +b.SD = true; +b.Terminal_Punctuation = true; +b.Term = true; +b.Unified_Ideograph = true; +b.UIdeo = true; +b.Uppercase = true; +b.Upper = true; +b.Variation_Selector = true; +b.VS = true; +b.White_Space = true; +b.space = true; +b.XID_Continue = true; +b.XIDC = true; +b.XID_Start = true; +b.XIDS = true; + +var g = values.general; +g.Cased_Letter = true; +g.LC = true; +g.Close_Punctuation = true; +g.Pe = true; +g.Connector_Punctuation = true; +g.Pc = true; +g.Control = true; +g.Cc = true; +g.cntrl = true; +g.Currency_Symbol = true; +g.Sc = true; +g.Dash_Punctuation = true; +g.Pd = true; +g.Decimal_Number = true; +g.Nd = true; +g.digit = true; +g.Enclosing_Mark = true; +g.Me = true; +g.Final_Punctuation = true; +g.Pf = true; +g.Format = true; +g.Cf = true; +g.Initial_Punctuation = true; +g.Pi = true; +g.Letter = true; +g.L = true; +g.Letter_Number = true; +g.Nl = true; +g.Line_Separator = true; +g.Zl = true; +g.Lowercase_Letter = true; +g.Ll = true; +g.Mark = true; +g.M = true; +g.Combining_Mark = true; +g.Math_Symbol = true; +g.Sm = true; +g.Modifier_Letter = true; +g.Lm = true; +g.Modifier_Symbol = true; +g.Sk = true; +g.Nonspacing_Mark = true; +g.Mn = true; +g.Number = true; +g.N = true; +g.Open_Punctuation = true; +g.Ps = true; +g.Other = true; +g.C = true; +g.Other_Letter = true; +g.Lo = true; +g.Other_Number = true; +g.No = true; +g.Other_Punctuation = true; +g.Po = true; +g.Other_Symbol = true; +g.So = true; +g.Paragraph_Separator = true; +g.Zp = true; +g.Private_Use = true; +g.Co = true; +g.Punctuation = true; +g.P = true; +g.punct = true; +g.Separator = true; +g.Z = true; +g.Space_Separator = true; +g.Zs = true; +g.Spacing_Mark = true; +g.Mc = true; +g.Surrogate = true; +g.Cs = true; +g.Symbol = true; +g.S = true; +g.Titlecase_Letter = true; +g.Lt = true; +g.Unassigned = true; +g.Cn = true; +g.Uppercase_Letter = true; +g.Lu = true; + +var s = values.script; +s.Adlam = true; +s.Adlm = true; +s.Ahom = true; +s.Anatolian_Hieroglyphs = true; +s.Hluw = true; +s.Arabic = true; +s.Arab = true; +s.Armenian = true; +s.Armn = true; +s.Avestan = true; +s.Avst = true; +s.Balinese = true; +s.Bali = true; +s.Bamum = true; +s.Bamu = true; +s.Bassa_Vah = true; +s.Bass = true; +s.Batak = true; +s.Batk = true; +s.Bengali = true; +s.Beng = true; +s.Bhaiksuki = true; +s.Bhks = true; +s.Bopomofo = true; +s.Bopo = true; +s.Brahmi = true; +s.Brah = true; +s.Braille = true; +s.Brai = true; +s.Buginese = true; +s.Bugi = true; +s.Buhid = true; +s.Buhd = true; +s.Canadian_Aboriginal = true; +s.Cans = true; +s.Carian = true; +s.Cari = true; +s.Caucasian_Albanian = true; +s.Aghb = true; +s.Chakma = true; +s.Cakm = true; +s.Cham = true; +s.Chorasmian = true; +s.Chrs = true; +s.Cherokee = true; +s.Cher = true; +s.Common = true; +s.Zyyy = true; +s.Coptic = true; +s.Copt = true; +s.Qaac = true; +s.Cuneiform = true; +s.Xsux = true; +s.Cypriot = true; +s.Cprt = true; +s.Cyrillic = true; +s.Cyrl = true; +s.Deseret = true; +s.Dsrt = true; +s.Devanagari = true; +s.Deva = true; +s.Dives_Akuru = true; +s.Diak = true; +s.Dogra = true; +s.Dogr = true; +s.Duployan = true; +s.Dupl = true; +s.Egyptian_Hieroglyphs = true; +s.Egyp = true; +s.Elbasan = true; +s.Elba = true; +s.Elymaic = true; +s.Elym = true; +s.Ethiopic = true; +s.Ethi = true; +s.Georgian = true; +s.Geor = true; +s.Glagolitic = true; +s.Glag = true; +s.Gothic = true; +s.Goth = true; +s.Grantha = true; +s.Gran = true; +s.Greek = true; +s.Grek = true; +s.Gujarati = true; +s.Gujr = true; +s.Gunjala_Gondi = true; +s.Gong = true; +s.Gurmukhi = true; +s.Guru = true; +s.Han = true; +s.Hani = true; +s.Hangul = true; +s.Hang = true; +s.Hanifi_Rohingya = true; +s.Rohg = true; +s.Hanunoo = true; +s.Hano = true; +s.Hatran = true; +s.Hatr = true; +s.Hebrew = true; +s.Hebr = true; +s.Hiragana = true; +s.Hira = true; +s.Imperial_Aramaic = true; +s.Armi = true; +s.Inherited = true; +s.Zinh = true; +s.Qaai = true; +s.Inscriptional_Pahlavi = true; +s.Phli = true; +s.Inscriptional_Parthian = true; +s.Prti = true; +s.Javanese = true; +s.Java = true; +s.Kaithi = true; +s.Kthi = true; +s.Kannada = true; +s.Knda = true; +s.Katakana = true; +s.Kana = true; +s.Kayah_Li = true; +s.Kali = true; +s.Kharoshthi = true; +s.Khar = true; +s.Khitan_Small_Script = true; +s.Kits = true; +s.Khmer = true; +s.Khmr = true; +s.Khojki = true; +s.Khoj = true; +s.Khudawadi = true; +s.Sind = true; +s.Lao = true; +s.Laoo = true; +s.Latin = true; +s.Latn = true; +s.Lepcha = true; +s.Lepc = true; +s.Limbu = true; +s.Limb = true; +s.Linear_A = true; +s.Lina = true; +s.Linear_B = true; +s.Linb = true; +s.Lisu = true; +s.Lycian = true; +s.Lyci = true; +s.Lydian = true; +s.Lydi = true; +s.Mahajani = true; +s.Mahj = true; +s.Makasar = true; +s.Maka = true; +s.Malayalam = true; +s.Mlym = true; +s.Mandaic = true; +s.Mand = true; +s.Manichaean = true; +s.Mani = true; +s.Marchen = true; +s.Marc = true; +s.Medefaidrin = true; +s.Medf = true; +s.Masaram_Gondi = true; +s.Gonm = true; +s.Meetei_Mayek = true; +s.Mtei = true; +s.Mende_Kikakui = true; +s.Mend = true; +s.Meroitic_Cursive = true; +s.Merc = true; +s.Meroitic_Hieroglyphs = true; +s.Mero = true; +s.Miao = true; +s.Plrd = true; +s.Modi = true; +s.Mongolian = true; +s.Mong = true; +s.Mro = true; +s.Mroo = true; +s.Multani = true; +s.Mult = true; +s.Myanmar = true; +s.Mymr = true; +s.Nabataean = true; +s.Nbat = true; +s.Nandinagari = true; +s.Nand = true; +s.New_Tai_Lue = true; +s.Talu = true; +s.Newa = true; +s.Nko = true; +s.Nkoo = true; +s.Nushu = true; +s.Nshu = true; +s.Nyiakeng_Puachue_Hmong = true; +s.Hmnp = true; +s.Ogham = true; +s.Ogam = true; +s.Ol_Chiki = true; +s.Olck = true; +s.Old_Hungarian = true; +s.Hung = true; +s.Old_Italic = true; +s.Ital = true; +s.Old_North_Arabian = true; +s.Narb = true; +s.Old_Permic = true; +s.Perm = true; +s.Old_Persian = true; +s.Xpeo = true; +s.Old_Sogdian = true; +s.Sogo = true; +s.Old_South_Arabian = true; +s.Sarb = true; +s.Old_Turkic = true; +s.Orkh = true; +s.Oriya = true; +s.Orya = true; +s.Osage = true; +s.Osge = true; +s.Osmanya = true; +s.Osma = true; +s.Pahawh_Hmong = true; +s.Hmng = true; +s.Palmyrene = true; +s.Palm = true; +s.Pau_Cin_Hau = true; +s.Pauc = true; +s.Phags_Pa = true; +s.Phag = true; +s.Phoenician = true; +s.Phnx = true; +s.Psalter_Pahlavi = true; +s.Phlp = true; +s.Rejang = true; +s.Rjng = true; +s.Runic = true; +s.Runr = true; +s.Samaritan = true; +s.Samr = true; +s.Saurashtra = true; +s.Saur = true; +s.Sharada = true; +s.Shrd = true; +s.Shavian = true; +s.Shaw = true; +s.Siddham = true; +s.Sidd = true; +s.SignWriting = true; +s.Sgnw = true; +s.Sinhala = true; +s.Sinh = true; +s.Sogdian = true; +s.Sogd = true; +s.Sora_Sompeng = true; +s.Sora = true; +s.Soyombo = true; +s.Soyo = true; +s.Sundanese = true; +s.Sund = true; +s.Syloti_Nagri = true; +s.Sylo = true; +s.Syriac = true; +s.Syrc = true; +s.Tagalog = true; +s.Tglg = true; +s.Tagbanwa = true; +s.Tagb = true; +s.Tai_Le = true; +s.Tale = true; +s.Tai_Tham = true; +s.Lana = true; +s.Tai_Viet = true; +s.Tavt = true; +s.Takri = true; +s.Takr = true; +s.Tamil = true; +s.Taml = true; +s.Tangut = true; +s.Tang = true; +s.Telugu = true; +s.Telu = true; +s.Thaana = true; +s.Thaa = true; +s.Thai = true; +s.Tibetan = true; +s.Tibt = true; +s.Tifinagh = true; +s.Tfng = true; +s.Tirhuta = true; +s.Tirh = true; +s.Ugaritic = true; +s.Ugar = true; +s.Vai = true; +s.Vaii = true; +s.Wancho = true; +s.Wcho = true; +s.Warang_Citi = true; +s.Wara = true; +s.Yezidi = true; +s.Yezi = true; +s.Yi = true; +s.Yiii = true; +s.Zanabazar_Square = true; +s.Zanb = true; + +},{}],"/../../../jshint/src/vars.js":[function(_dereq_,module,exports){ // jshint -W001 "use strict"; @@ -16112,6 +17112,10 @@ exports.ecmaIdentifiers = { 8: { Atomics : false, SharedArrayBuffer : false + }, + 11: { + BigInt : false, + globalThis : false } }; @@ -16465,6 +17469,7 @@ exports.browser = { TimeEvent : false, top : false, URL : false, + URLSearchParams : false, WebGLActiveInfo : false, WebGLBuffer : false, WebGLContextEvent : false, @@ -16551,20 +17556,23 @@ exports.node = { global : false, module : false, require : false, + Intl : false, // These globals are writeable because Node allows the following // usage pattern: var Buffer = require("buffer").Buffer; - Buffer : true, - console : true, - exports : true, - process : true, - setTimeout : true, - clearTimeout : true, - setInterval : true, - clearInterval : true, - setImmediate : true, // v0.9.1+ - clearImmediate: true // v0.9.1+ + Buffer : true, + console : true, + exports : true, + process : true, + setTimeout : true, + clearTimeout : true, + setInterval : true, + clearInterval : true, + setImmediate : true, // v0.9.1+ + clearImmediate : true, // v0.9.1+ + URL : true, // v10.0.0+ + URLSearchParams: true // v10.0.0+ }; exports.browserify = { @@ -16806,10 +17814,12 @@ exports.mocha = { // BDD describe : false, xdescribe : false, - it : false, - xit : false, context : false, xcontext : false, + it : false, + xit : false, + specify : false, + xspecify : false, before : false, after : false, beforeEach : false, @@ -16832,74 +17842,25 @@ exports.jasmine = { beforeEach : false, afterEach : false, setFixtures : false, - loadFixtures: false, - spyOn : false, - expect : false, - // Jasmine 1.3 - runs : false, - waitsFor : false, - waits : false, - // Jasmine 2.1 - beforeAll : false, - afterAll : false, - fail : false, - fdescribe : false, - fit : false, - pending : false, - // Jasmine 2.6 - spyOnProperty: false -}; - -},{}],"/../node_modules/assert/assert.js":[function(_dereq_,module,exports){ -(function (global){ -'use strict'; - -var objectAssign = _dereq_('object-assign'); - -// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js -// original notice: - -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -function compare(a, b) { - if (a === b) { - return 0; - } - - var x = a.length; - var y = b.length; - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i]; - y = b[i]; - break; - } - } - - if (x < y) { - return -1; - } - if (y < x) { - return 1; - } - return 0; -} -function isBuffer(b) { - if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { - return global.Buffer.isBuffer(b); - } - return !!(b != null && b._isBuffer); -} - -// based on node assert, original notice: -// NB: The URL to the CommonJS spec is kept just for tradition. -// node-assert has evolved a lot since then, both in API and behavior. + loadFixtures: false, + spyOn : false, + expect : false, + // Jasmine 1.3 + runs : false, + waitsFor : false, + waits : false, + // Jasmine 2.1 + beforeAll : false, + afterAll : false, + fail : false, + fdescribe : false, + fit : false, + pending : false, + // Jasmine 2.6 + spyOnProperty: false +}; +},{}],"/node_modules/assert/assert.js":[function(_dereq_,module,exports){ // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 // // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! @@ -16924,36 +17885,14 @@ function isBuffer(b) { // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// when used in node, this will actually load the util module we depend on +// versus loading the builtin util module as happens otherwise +// this is a bug in node module loading as far as I am concerned var util = _dereq_('util/'); -var hasOwn = Object.prototype.hasOwnProperty; + var pSlice = Array.prototype.slice; -var functionsHaveNames = (function () { - return function foo() {}.name === 'foo'; -}()); -function pToString (obj) { - return Object.prototype.toString.call(obj); -} -function isView(arrbuf) { - if (isBuffer(arrbuf)) { - return false; - } - if (typeof global.ArrayBuffer !== 'function') { - return false; - } - if (typeof ArrayBuffer.isView === 'function') { - return ArrayBuffer.isView(arrbuf); - } - if (!arrbuf) { - return false; - } - if (arrbuf instanceof DataView) { - return true; - } - if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { - return true; - } - return false; -} +var hasOwn = Object.prototype.hasOwnProperty; + // 1. The assert module provides functions that throw // AssertionError's when particular conditions are not met. The // assert module must conform to the following interface. @@ -16965,19 +17904,6 @@ var assert = module.exports = ok; // actual: actual, // expected: expected }) -var regex = /\s*function\s+([^\(\s]*)\s*/; -// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js -function getName(func) { - if (!util.isFunction(func)) { - return; - } - if (functionsHaveNames) { - return func.name; - } - var str = func.toString(); - var match = str.match(regex); - return match && match[1]; -} assert.AssertionError = function AssertionError(options) { this.name = 'AssertionError'; this.actual = options.actual; @@ -16991,16 +17917,18 @@ assert.AssertionError = function AssertionError(options) { this.generatedMessage = true; } var stackStartFunction = options.stackStartFunction || fail; + if (Error.captureStackTrace) { Error.captureStackTrace(this, stackStartFunction); - } else { + } + else { // non v8 browsers so we can have a stacktrace var err = new Error(); if (err.stack) { var out = err.stack; // try to strip useless frames - var fn_name = getName(stackStartFunction); + var fn_name = stackStartFunction.name; var idx = out.indexOf('\n' + fn_name); if (idx >= 0) { // once we have located the function frame @@ -17017,25 +17945,31 @@ assert.AssertionError = function AssertionError(options) { // assert.AssertionError instanceof Error util.inherits(assert.AssertionError, Error); +function replacer(key, value) { + if (util.isUndefined(value)) { + return '' + value; + } + if (util.isNumber(value) && !isFinite(value)) { + return value.toString(); + } + if (util.isFunction(value) || util.isRegExp(value)) { + return value.toString(); + } + return value; +} + function truncate(s, n) { - if (typeof s === 'string') { + if (util.isString(s)) { return s.length < n ? s : s.slice(0, n); } else { return s; } } -function inspect(something) { - if (functionsHaveNames || !util.isFunction(something)) { - return util.inspect(something); - } - var rawname = getName(something); - var name = rawname ? ': ' + rawname : ''; - return '[Function' + name + ']'; -} + function getMessage(self) { - return truncate(inspect(self.actual), 128) + ' ' + + return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' + self.operator + ' ' + - truncate(inspect(self.expected), 128); + truncate(JSON.stringify(self.expected, replacer), 128); } // At present only the three keys mentioned above are used and @@ -17095,23 +18029,24 @@ assert.notEqual = function notEqual(actual, expected, message) { // assert.deepEqual(actual, expected, message_opt); assert.deepEqual = function deepEqual(actual, expected, message) { - if (!_deepEqual(actual, expected, false)) { + if (!_deepEqual(actual, expected)) { fail(actual, expected, message, 'deepEqual', assert.deepEqual); } }; -assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { - if (!_deepEqual(actual, expected, true)) { - fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); - } -}; - -function _deepEqual(actual, expected, strict, memos) { +function _deepEqual(actual, expected) { // 7.1. All identical values are equivalent, as determined by ===. if (actual === expected) { return true; - } else if (isBuffer(actual) && isBuffer(expected)) { - return compare(actual, expected) === 0; + + } else if (util.isBuffer(actual) && util.isBuffer(expected)) { + if (actual.length != expected.length) return false; + + for (var i = 0; i < actual.length; i++) { + if (actual[i] !== expected[i]) return false; + } + + return true; // 7.2. If the expected value is a Date object, the actual value is // equivalent if it is also a Date object that refers to the same time. @@ -17130,22 +18065,8 @@ function _deepEqual(actual, expected, strict, memos) { // 7.4. Other pairs that do not both pass typeof value == 'object', // equivalence is determined by ==. - } else if ((actual === null || typeof actual !== 'object') && - (expected === null || typeof expected !== 'object')) { - return strict ? actual === expected : actual == expected; - - // If both values are instances of typed arrays, wrap their underlying - // ArrayBuffers in a Buffer each to increase performance - // This optimization requires the arrays to have the same type as checked by - // Object.prototype.toString (aka pToString). Never perform binary - // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their - // bit patterns are not identical. - } else if (isView(actual) && isView(expected) && - pToString(actual) === pToString(expected) && - !(actual instanceof Float32Array || - actual instanceof Float64Array)) { - return compare(new Uint8Array(actual.buffer), - new Uint8Array(expected.buffer)) === 0; + } else if (!util.isObject(actual) && !util.isObject(expected)) { + return actual == expected; // 7.5 For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified @@ -17153,22 +18074,8 @@ function _deepEqual(actual, expected, strict, memos) { // (although not necessarily the same order), equivalent values for every // corresponding key, and an identical 'prototype' property. Note: this // accounts for both named and indexed properties on Arrays. - } else if (isBuffer(actual) !== isBuffer(expected)) { - return false; } else { - memos = memos || {actual: [], expected: []}; - - var actualIndex = memos.actual.indexOf(actual); - if (actualIndex !== -1) { - if (actualIndex === memos.expected.indexOf(expected)) { - return true; - } - } - - memos.actual.push(actual); - memos.expected.push(expected); - - return objEquiv(actual, expected, strict, memos); + return objEquiv(actual, expected); } } @@ -17176,44 +18083,44 @@ function isArguments(object) { return Object.prototype.toString.call(object) == '[object Arguments]'; } -function objEquiv(a, b, strict, actualVisitedObjects) { - if (a === null || a === undefined || b === null || b === undefined) +function objEquiv(a, b) { + if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b)) return false; + // an identical 'prototype' property. + if (a.prototype !== b.prototype) return false; // if one is a primitive, the other must be same - if (util.isPrimitive(a) || util.isPrimitive(b)) + if (util.isPrimitive(a) || util.isPrimitive(b)) { return a === b; - if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) - return false; - var aIsArgs = isArguments(a); - var bIsArgs = isArguments(b); + } + var aIsArgs = isArguments(a), + bIsArgs = isArguments(b); if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) return false; if (aIsArgs) { a = pSlice.call(a); b = pSlice.call(b); - return _deepEqual(a, b, strict); + return _deepEqual(a, b); } - var ka = objectKeys(a); - var kb = objectKeys(b); - var key, i; + var ka = objectKeys(a), + kb = objectKeys(b), + key, i; // having the same number of owned properties (keys incorporates // hasOwnProperty) - if (ka.length !== kb.length) + if (ka.length != kb.length) return false; //the same set of keys (although not necessarily the same order), ka.sort(); kb.sort(); //~~~cheap key test for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] !== kb[i]) + if (ka[i] != kb[i]) return false; } //equivalent values for every corresponding key, and //~~~possibly expensive deep test for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; - if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) - return false; + if (!_deepEqual(a[key], b[key])) return false; } return true; } @@ -17222,19 +18129,11 @@ function objEquiv(a, b, strict, actualVisitedObjects) { // assert.notDeepEqual(actual, expected, message_opt); assert.notDeepEqual = function notDeepEqual(actual, expected, message) { - if (_deepEqual(actual, expected, false)) { + if (_deepEqual(actual, expected)) { fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); } }; -assert.notDeepStrictEqual = notDeepStrictEqual; -function notDeepStrictEqual(actual, expected, message) { - if (_deepEqual(actual, expected, true)) { - fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); - } -} - - // 9. The strict equality assertion tests strict equality, as determined by ===. // assert.strictEqual(actual, expected, message_opt); @@ -17260,46 +18159,28 @@ function expectedException(actual, expected) { if (Object.prototype.toString.call(expected) == '[object RegExp]') { return expected.test(actual); + } else if (actual instanceof expected) { + return true; + } else if (expected.call({}, actual) === true) { + return true; } - try { - if (actual instanceof expected) { - return true; - } - } catch (e) { - // Ignore. The instanceof check doesn't work for arrow functions. - } - - if (Error.isPrototypeOf(expected)) { - return false; - } - - return expected.call({}, actual) === true; -} - -function _tryBlock(block) { - var error; - try { - block(); - } catch (e) { - error = e; - } - return error; + return false; } function _throws(shouldThrow, block, expected, message) { var actual; - if (typeof block !== 'function') { - throw new TypeError('"block" argument must be a function'); - } - - if (typeof expected === 'string') { + if (util.isString(expected)) { message = expected; expected = null; } - actual = _tryBlock(block); + try { + block(); + } catch (e) { + actual = e; + } message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.'); @@ -17308,14 +18189,7 @@ function _throws(shouldThrow, block, expected, message) { fail(actual, expected, 'Missing expected exception' + message); } - var userProvidedMessage = typeof message === 'string'; - var isUnwantedException = !shouldThrow && util.isError(actual); - var isUnexpectedException = !shouldThrow && actual && !expected; - - if ((isUnwantedException && - userProvidedMessage && - expectedException(actual, expected)) || - isUnexpectedException) { + if (!shouldThrow && expectedException(actual, expected)) { fail(actual, expected, 'Got unwanted exception' + message); } @@ -17329,27 +18203,15 @@ function _throws(shouldThrow, block, expected, message) { // assert.throws(block, Error_opt, message_opt); assert.throws = function(block, /*optional*/error, /*optional*/message) { - _throws(true, block, error, message); + _throws.apply(this, [true].concat(pSlice.call(arguments))); }; // EXTENSION! This is annoying to write outside this module. -assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { - _throws(false, block, error, message); +assert.doesNotThrow = function(block, /*optional*/message) { + _throws.apply(this, [false].concat(pSlice.call(arguments))); }; -assert.ifError = function(err) { if (err) throw err; }; - -// Expose a strict only variant of assert -function strict(value, message) { - if (!value) fail(value, true, message, '==', strict); -} -assert.strict = objectAssign(strict, assert, { - equal: assert.strictEqual, - deepEqual: assert.deepStrictEqual, - notEqual: assert.notStrictEqual, - notDeepEqual: assert.notDeepStrictEqual -}); -assert.strict.strict = assert.strict; +assert.ifError = function(err) { if (err) {throw err;}}; var objectKeys = Object.keys || function (obj) { var keys = []; @@ -17359,8 +18221,7 @@ var objectKeys = Object.keys || function (obj) { return keys; }; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"object-assign":"/../node_modules/object-assign/index.js","util/":"/../node_modules/assert/node_modules/util/util.js"}],"/../node_modules/assert/node_modules/inherits/inherits_browser.js":[function(_dereq_,module,exports){ +},{"util/":"/node_modules/assert/node_modules/util/util.js"}],"/node_modules/assert/node_modules/inherits/inherits_browser.js":[function(_dereq_,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -17385,14 +18246,14 @@ if (typeof Object.create === 'function') { } } -},{}],"/../node_modules/assert/node_modules/util/support/isBufferBrowser.js":[function(_dereq_,module,exports){ +},{}],"/node_modules/assert/node_modules/util/support/isBufferBrowser.js":[function(_dereq_,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],"/../node_modules/assert/node_modules/util/util.js":[function(_dereq_,module,exports){ +},{}],"/node_modules/assert/node_modules/util/util.js":[function(_dereq_,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -17982,7 +18843,7 @@ function hasOwnProperty(obj, prop) { } }).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":"/../node_modules/assert/node_modules/util/support/isBufferBrowser.js","_process":"/../node_modules/process/browser.js","inherits":"/../node_modules/assert/node_modules/inherits/inherits_browser.js"}],"/../node_modules/events/events.js":[function(_dereq_,module,exports){ +},{"./support/isBuffer":"/node_modules/assert/node_modules/util/support/isBufferBrowser.js","_process":"/node_modules/process/browser.js","inherits":"/node_modules/assert/node_modules/inherits/inherits_browser.js"}],"/node_modules/events/events.js":[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -18004,16 +18865,8 @@ function hasOwnProperty(obj, prop) { // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var objectCreate = Object.create || objectCreatePolyfill -var objectKeys = Object.keys || objectKeysPolyfill -var bind = Function.prototype.bind || functionBindPolyfill - function EventEmitter() { - if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) { - this._events = objectCreate(null); - this._eventsCount = 0; - } - + this._events = this._events || {}; this._maxListeners = this._maxListeners || undefined; } module.exports = EventEmitter; @@ -18026,580 +18879,274 @@ EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are // added to it. This is a useful default which helps finding memory leaks. -var defaultMaxListeners = 200; - -var hasDefineProperty; -try { - var o = {}; - if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 }); - hasDefineProperty = o.x === 0; -} catch (err) { hasDefineProperty = false } -if (hasDefineProperty) { - Object.defineProperty(EventEmitter, 'defaultMaxListeners', { - enumerable: true, - get: function() { - return defaultMaxListeners; - }, - set: function(arg) { - // check whether the input is a positive number (whose value is zero or - // greater and not a NaN). - if (typeof arg !== 'number' || arg < 0 || arg !== arg) - throw new TypeError('"defaultMaxListeners" must be a positive number'); - defaultMaxListeners = arg; - } - }); -} else { - EventEmitter.defaultMaxListeners = defaultMaxListeners; -} +EventEmitter.defaultMaxListeners = 10; // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { - if (typeof n !== 'number' || n < 0 || isNaN(n)) - throw new TypeError('"n" argument must be a positive number'); +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); this._maxListeners = n; return this; }; -function $getMaxListeners(that) { - if (that._maxListeners === undefined) - return EventEmitter.defaultMaxListeners; - return that._maxListeners; -} - -EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return $getMaxListeners(this); -}; - -// These standalone emit* functions are used to optimize calling of event -// handlers for fast cases because emit() itself often has a variable number of -// arguments and can be deoptimized because of that. These functions always have -// the same number of arguments and thus do not get deoptimized, so the code -// inside them can execute faster. -function emitNone(handler, isFn, self) { - if (isFn) - handler.call(self); - else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - listeners[i].call(self); - } -} -function emitOne(handler, isFn, self, arg1) { - if (isFn) - handler.call(self, arg1); - else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - listeners[i].call(self, arg1); - } -} -function emitTwo(handler, isFn, self, arg1, arg2) { - if (isFn) - handler.call(self, arg1, arg2); - else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - listeners[i].call(self, arg1, arg2); - } -} -function emitThree(handler, isFn, self, arg1, arg2, arg3) { - if (isFn) - handler.call(self, arg1, arg2, arg3); - else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - listeners[i].call(self, arg1, arg2, arg3); - } -} - -function emitMany(handler, isFn, self, args) { - if (isFn) - handler.apply(self, args); - else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - listeners[i].apply(self, args); - } -} - -EventEmitter.prototype.emit = function emit(type) { - var er, handler, len, args, i, events; - var doError = (type === 'error'); +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; - events = this._events; - if (events) - doError = (doError && events.error == null); - else if (!doError) - return false; + if (!this._events) + this._events = {}; // If there is no 'error' event listener then throw. - if (doError) { - if (arguments.length > 1) + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Unhandled "error" event. (' + er + ')'); - err.context = er; - throw err; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } + throw TypeError('Uncaught, unspecified "error" event.'); } - return false; } - handler = events[type]; + handler = this._events[type]; - if (!handler) + if (isUndefined(handler)) return false; - var isFn = typeof handler === 'function'; - len = arguments.length; - switch (len) { + if (isFunction(handler)) { + switch (arguments.length) { // fast cases - case 1: - emitNone(handler, isFn, this); - break; - case 2: - emitOne(handler, isFn, this, arguments[1]); - break; - case 3: - emitTwo(handler, isFn, this, arguments[1], arguments[2]); - break; - case 4: - emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]); - break; + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; // slower - default: - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; - emitMany(handler, isFn, this, args); + default: + len = arguments.length; + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + handler.apply(this, args); + } + } else if (isObject(handler)) { + len = arguments.length; + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); } return true; }; -function _addListener(target, type, listener, prepend) { +EventEmitter.prototype.addListener = function(type, listener) { var m; - var events; - var existing; - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - events = target._events; - if (!events) { - events = target._events = objectCreate(null); - target._eventsCount = 0; - } else { - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (events.newListener) { - target.emit('newListener', type, - listener.listener ? listener.listener : listener); + if (!this._events) + this._events = {}; - // Re-assign `events` because a newListener handler could have caused the - // this._events to be assigned to a new object - events = target._events; - } - existing = events[type]; - } + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); - if (!existing) { + if (!this._events[type]) // Optimize the case of one listener. Don't need the extra array object. - existing = events[type] = listener; - ++target._eventsCount; - } else { - if (typeof existing === 'function') { - // Adding the second element, need to change to array. - existing = events[type] = - prepend ? [listener, existing] : [existing, listener]; + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + var m; + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; } else { - // If we've already got an array, just append. - if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - } - - // Check for listener leak - if (!existing.warned) { - m = $getMaxListeners(target); - if (m && m > 0 && existing.length > m) { - existing.warned = true; - var w = new Error('Possible EventEmitter memory leak detected. ' + - existing.length + ' "' + String(type) + '" listeners ' + - 'added. Use emitter.setMaxListeners() to ' + - 'increase limit.'); - w.name = 'MaxListenersExceededWarning'; - w.emitter = target; - w.type = type; - w.count = existing.length; - if (typeof console === 'object' && console.warn) { - console.warn('%s: %s', w.name, w.message); - } + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); } } } - return target; -} - -EventEmitter.prototype.addListener = function addListener(type, listener) { - return _addListener(this, type, listener, false); + return this; }; EventEmitter.prototype.on = EventEmitter.prototype.addListener; -EventEmitter.prototype.prependListener = - function prependListener(type, listener) { - return _addListener(this, type, listener, true); - }; +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - switch (arguments.length) { - case 0: - return this.listener.call(this.target); - case 1: - return this.listener.call(this.target, arguments[0]); - case 2: - return this.listener.call(this.target, arguments[0], arguments[1]); - case 3: - return this.listener.call(this.target, arguments[0], arguments[1], - arguments[2]); - default: - var args = new Array(arguments.length); - for (var i = 0; i < args.length; ++i) - args[i] = arguments[i]; - this.listener.apply(this.target, args); + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); } } -} -function _onceWrap(target, type, listener) { - var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; - var wrapped = bind.call(onceWrapper, state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} + g.listener = listener; + this.on(type, g); -EventEmitter.prototype.once = function once(type, listener) { - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); - this.on(type, _onceWrap(this, type, listener)); return this; }; -EventEmitter.prototype.prependOnceListener = - function prependOnceListener(type, listener) { - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); - this.prependListener(type, _onceWrap(this, type, listener)); - return this; - }; - -// Emits a 'removeListener' event if and only if the listener was removed. -EventEmitter.prototype.removeListener = - function removeListener(type, listener) { - var list, events, position, i, originalListener; - - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); - - events = this._events; - if (!events) - return this; - - list = events[type]; - if (!list) - return this; - - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = objectCreate(null); - else { - delete events[type]; - if (events.removeListener) - this.emit('removeListener', type, list.listener || listener); - } - } else if (typeof list !== 'function') { - position = -1; - - for (i = list.length - 1; i >= 0; i--) { - if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; - position = i; - break; - } - } - - if (position < 0) - return this; +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; - if (position === 0) - list.shift(); - else - spliceOne(list, position); + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - if (list.length === 1) - events[type] = list[0]; + if (!this._events || !this._events[type]) + return this; - if (events.removeListener) - this.emit('removeListener', type, originalListener || listener); + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; } + } + if (position < 0) return this; - }; - -EventEmitter.prototype.removeAllListeners = - function removeAllListeners(type) { - var listeners, events, i; - - events = this._events; - if (!events) - return this; - - // not listening for removeListener, no need to emit - if (!events.removeListener) { - if (arguments.length === 0) { - this._events = objectCreate(null); - this._eventsCount = 0; - } else if (events[type]) { - if (--this._eventsCount === 0) - this._events = objectCreate(null); - else - delete events[type]; - } - return this; - } - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - var keys = objectKeys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = objectCreate(null); - this._eventsCount = 0; - return this; - } + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } - listeners = events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } - if (typeof listeners === 'function') { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - for (i = listeners.length - 1; i >= 0; i--) { - this.removeListener(type, listeners[i]); - } - } + return this; +}; - return this; - }; +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; -function _listeners(target, type, unwrap) { - var events = target._events; + if (!this._events) + return this; - if (!events) - return []; + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } - var evlistener = events[type]; - if (!evlistener) - return []; + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } - if (typeof evlistener === 'function') - return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + listeners = this._events[type]; - return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); -} + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; -EventEmitter.prototype.listeners = function listeners(type) { - return _listeners(this, type, true); + return this; }; -EventEmitter.prototype.rawListeners = function rawListeners(type) { - return _listeners(this, type, false); +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; }; EventEmitter.listenerCount = function(emitter, type) { - if (typeof emitter.listenerCount === 'function') { - return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); - } -}; - -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type) { - var events = this._events; - - if (events) { - var evlistener = events[type]; - - if (typeof evlistener === 'function') { - return 1; - } else if (evlistener) { - return evlistener.length; - } - } - - return 0; -} - -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; + var ret; + if (!emitter._events || !emitter._events[type]) + ret = 0; + else if (isFunction(emitter._events[type])) + ret = 1; + else + ret = emitter._events[type].length; + return ret; }; -// About 1.5x faster than the two-arg version of Array#splice(). -function spliceOne(list, index) { - for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) - list[i] = list[k]; - list.pop(); -} - -function arrayClone(arr, n) { - var copy = new Array(n); - for (var i = 0; i < n; ++i) - copy[i] = arr[i]; - return copy; -} - -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i = 0; i < ret.length; ++i) { - ret[i] = arr[i].listener || arr[i]; - } - return ret; +function isFunction(arg) { + return typeof arg === 'function'; } -function objectCreatePolyfill(proto) { - var F = function() {}; - F.prototype = proto; - return new F; -} -function objectKeysPolyfill(obj) { - var keys = []; - for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) { - keys.push(k); - } - return k; -} -function functionBindPolyfill(context) { - var fn = this; - return function () { - return fn.apply(context, arguments); - }; +function isNumber(arg) { + return typeof arg === 'number'; } -},{}],"/../node_modules/object-assign/index.js":[function(_dereq_,module,exports){ -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ - -'use strict'; -/* eslint-disable no-unused-vars */ -var getOwnPropertySymbols = Object.getOwnPropertySymbols; -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); +function isObject(arg) { + return typeof arg === 'object' && arg !== null; } -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } +function isUndefined(arg) { + return arg === void 0; } -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; -}; - -},{}],"/../node_modules/process/browser.js":[function(_dereq_,module,exports){ +},{}],"/node_modules/process/browser.js":[function(_dereq_,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -18785,12 +19332,12 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],"/../node_modules/util/node_modules/inherits/inherits_browser.js":[function(_dereq_,module,exports){ -arguments[4]["/../node_modules/assert/node_modules/inherits/inherits_browser.js"][0].apply(exports,arguments) -},{}],"/../node_modules/util/support/isBufferBrowser.js":[function(_dereq_,module,exports){ -arguments[4]["/../node_modules/assert/node_modules/util/support/isBufferBrowser.js"][0].apply(exports,arguments) -},{}],"/../node_modules/util/util.js":[function(_dereq_,module,exports){ -arguments[4]["/../node_modules/assert/node_modules/util/util.js"][0].apply(exports,arguments) -},{"./support/isBuffer":"/../node_modules/util/support/isBufferBrowser.js","_process":"/../node_modules/process/browser.js","inherits":"/../node_modules/util/node_modules/inherits/inherits_browser.js"}]},{},["/../../jshint/src/jshint.js"]); +},{}],"/node_modules/util/node_modules/inherits/inherits_browser.js":[function(_dereq_,module,exports){ +arguments[4]["/node_modules/assert/node_modules/inherits/inherits_browser.js"][0].apply(exports,arguments) +},{}],"/node_modules/util/support/isBufferBrowser.js":[function(_dereq_,module,exports){ +arguments[4]["/node_modules/assert/node_modules/util/support/isBufferBrowser.js"][0].apply(exports,arguments) +},{}],"/node_modules/util/util.js":[function(_dereq_,module,exports){ +arguments[4]["/node_modules/assert/node_modules/util/util.js"][0].apply(exports,arguments) +},{"./support/isBuffer":"/node_modules/util/support/isBufferBrowser.js","_process":"/node_modules/process/browser.js","inherits":"/node_modules/util/node_modules/inherits/inherits_browser.js"}]},{},["/../../../jshint/src/jshint.js"]); }); \ No newline at end of file diff --git a/tool/Readme.md b/tool/Readme.md index 28dd5166226..34255f7389c 100644 --- a/tool/Readme.md +++ b/tool/Readme.md @@ -23,4 +23,18 @@ node add_mode.js ModeName "extension1|extension2|^FullName" ``` node tmlanguage.js ./templates/dummy.JSON-tmLanguage -``` \ No newline at end of file +``` + +# update_deps.js +To update `jshint` to new version: +1. Clone last version from https://github.com/jshint/jshint +2. Replace all `lodash` with `underscore` in requires in `jshint/src/*.js` +3. Add `_.slice = require("lodash.slice");` to `src/scope-manager.js` after `var _ = ...` +4. Add `_.clone = require("lodash.clone");` to `src/jshint.js` after `var _ = ...` +5. Add ``` + "underscore": latest + "lodash.clone": "^4.5.0", + "lodash.slice": "^4.2.0" + ``` to `package.json`, remove `lodash` and run `npm i` +6. Change in `ace/tool/update_deps.js` jshint path `deps.jshint.browserify.path` with your path to changed jshint +7. Run `node update_deps.js jshint` \ No newline at end of file