You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2861 lines
98 KiB
JavaScript
2861 lines
98 KiB
JavaScript
5 years ago
|
/**
|
||
|
* Modules in this bundle
|
||
|
* @license
|
||
|
*
|
||
|
* call-matcher:
|
||
|
* license: MIT (http://opensource.org/licenses/MIT)
|
||
|
* author: Takuto Wada <takuto.wada@gmail.com>
|
||
|
* homepage: https://github.com/twada/call-matcher
|
||
|
* version: 1.1.0
|
||
|
*
|
||
|
* core-js:
|
||
|
* license: MIT (http://opensource.org/licenses/MIT)
|
||
|
* homepage: https://github.com/zloirock/core-js#readme
|
||
|
* version: 2.5.7
|
||
|
*
|
||
|
* deep-equal:
|
||
|
* license: MIT (http://opensource.org/licenses/MIT)
|
||
|
* author: James Halliday <mail@substack.net>
|
||
|
* homepage: https://github.com/substack/node-deep-equal#readme
|
||
|
* version: 1.0.1
|
||
|
*
|
||
|
* espurify:
|
||
|
* license: MIT (http://opensource.org/licenses/MIT)
|
||
|
* author: Takuto Wada <takuto.wada@gmail.com>
|
||
|
* homepage: https://github.com/estools/espurify
|
||
|
* version: 1.8.1
|
||
|
*
|
||
|
* estraverse:
|
||
|
* license: BSD-2-Clause (http://opensource.org/licenses/BSD-2-Clause)
|
||
|
* maintainers: Yusuke Suzuki <utatane.tea@gmail.com>
|
||
|
* homepage: https://github.com/estools/estraverse
|
||
|
* version: 4.2.0
|
||
|
*
|
||
|
* This header is generated by licensify (https://github.com/twada/licensify)
|
||
|
*/
|
||
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.CallMatcher = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw (a.code="MODULE_NOT_FOUND", a)}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
|
||
|
/**
|
||
|
* call-matcher:
|
||
|
* ECMAScript CallExpression matcher made from function/method signature
|
||
|
*
|
||
|
* https://github.com/twada/call-matcher
|
||
|
*
|
||
|
* Copyright (c) 2015-2018 Takuto Wada
|
||
|
* Licensed under the MIT license.
|
||
|
* https://github.com/twada/call-matcher/blob/master/MIT-LICENSE.txt
|
||
|
*/
|
||
|
'use strict';
|
||
|
/* jshint -W024 */
|
||
|
|
||
|
var estraverse = _dereq_('estraverse');
|
||
|
var espurify = _dereq_('espurify');
|
||
|
var syntax = estraverse.Syntax;
|
||
|
var hasOwn = Object.prototype.hasOwnProperty;
|
||
|
var forEach = _dereq_('core-js/library/fn/array/for-each');
|
||
|
var map = _dereq_('core-js/library/fn/array/map');
|
||
|
var filter = _dereq_('core-js/library/fn/array/filter');
|
||
|
var reduce = _dereq_('core-js/library/fn/array/reduce');
|
||
|
var indexOf = _dereq_('core-js/library/fn/array/index-of');
|
||
|
var deepEqual = _dereq_('deep-equal');
|
||
|
var notCallExprMessage = 'Argument should be in the form of CallExpression';
|
||
|
var duplicatedArgMessage = 'Duplicate argument name: ';
|
||
|
var invalidFormMessage = 'Argument should be in the form of `name` or `[name]`';
|
||
|
|
||
|
function CallMatcher (signatureAst, options) {
|
||
|
validateApiExpression(signatureAst);
|
||
|
options = options || {};
|
||
|
this.visitorKeys = options.visitorKeys || estraverse.VisitorKeys;
|
||
|
if (options.astWhiteList) {
|
||
|
this.purifyAst = espurify.cloneWithWhitelist(options.astWhiteList);
|
||
|
} else {
|
||
|
this.purifyAst = espurify;
|
||
|
}
|
||
|
this.signatureAst = signatureAst;
|
||
|
this.signatureCalleeDepth = astDepth(signatureAst.callee, this.visitorKeys);
|
||
|
this.numMaxArgs = this.signatureAst.arguments.length;
|
||
|
this.numMinArgs = filter(this.signatureAst.arguments, identifiers).length;
|
||
|
}
|
||
|
|
||
|
CallMatcher.prototype.test = function (currentNode) {
|
||
|
var calleeMatched = this.isCalleeMatched(currentNode);
|
||
|
var numArgs;
|
||
|
if (calleeMatched) {
|
||
|
numArgs = currentNode.arguments.length;
|
||
|
return this.numMinArgs <= numArgs && numArgs <= this.numMaxArgs;
|
||
|
}
|
||
|
return false;
|
||
|
};
|
||
|
|
||
|
CallMatcher.prototype.matchArgument = function (currentNode, parentNode) {
|
||
|
if (isCalleeOfParent(currentNode, parentNode)) {
|
||
|
return null;
|
||
|
}
|
||
|
if (this.test(parentNode)) {
|
||
|
var indexOfCurrentArg = indexOf(parentNode.arguments, currentNode);
|
||
|
var numOptional = parentNode.arguments.length - this.numMinArgs;
|
||
|
var matchedSignatures = reduce(this.argumentSignatures(), function (accum, argSig) {
|
||
|
if (argSig.kind === 'mandatory') {
|
||
|
accum.push(argSig);
|
||
|
}
|
||
|
if (argSig.kind === 'optional' && 0 < numOptional) {
|
||
|
numOptional -= 1;
|
||
|
accum.push(argSig);
|
||
|
}
|
||
|
return accum;
|
||
|
}, []);
|
||
|
return matchedSignatures[indexOfCurrentArg];
|
||
|
}
|
||
|
return null;
|
||
|
};
|
||
|
|
||
|
CallMatcher.prototype.calleeAst = function () {
|
||
|
return this.purifyAst(this.signatureAst.callee);
|
||
|
};
|
||
|
|
||
|
CallMatcher.prototype.argumentSignatures = function () {
|
||
|
return map(this.signatureAst.arguments, toArgumentSignature);
|
||
|
};
|
||
|
|
||
|
CallMatcher.prototype.isCalleeMatched = function (node) {
|
||
|
if (!isCallExpression(node)) {
|
||
|
return false;
|
||
|
}
|
||
|
if (!this.isSameDepthAsSignatureCallee(node.callee)) {
|
||
|
return false;
|
||
|
}
|
||
|
return deepEqual(this.purifyAst(this.signatureAst.callee), this.purifyAst(node.callee));
|
||
|
};
|
||
|
|
||
|
CallMatcher.prototype.isSameDepthAsSignatureCallee = function (ast) {
|
||
|
var depth = this.signatureCalleeDepth;
|
||
|
var currentDepth = 0;
|
||
|
estraverse.traverse(ast, {
|
||
|
keys: this.visitorKeys,
|
||
|
enter: function (currentNode, parentNode) {
|
||
|
var path = this.path();
|
||
|
var pathDepth = path ? path.length : 0;
|
||
|
if (currentDepth < pathDepth) {
|
||
|
currentDepth = pathDepth;
|
||
|
}
|
||
|
if (depth < currentDepth) {
|
||
|
this['break']();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
return (depth === currentDepth);
|
||
|
};
|
||
|
|
||
|
function toArgumentSignature (argSignatureNode, idx) {
|
||
|
switch(argSignatureNode.type) {
|
||
|
case syntax.Identifier:
|
||
|
return {
|
||
|
index: idx,
|
||
|
name: argSignatureNode.name,
|
||
|
kind: 'mandatory'
|
||
|
};
|
||
|
case syntax.ArrayExpression:
|
||
|
return {
|
||
|
index: idx,
|
||
|
name: argSignatureNode.elements[0].name,
|
||
|
kind: 'optional'
|
||
|
};
|
||
|
default:
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function astDepth (ast, visitorKeys) {
|
||
|
var maxDepth = 0;
|
||
|
estraverse.traverse(ast, {
|
||
|
keys: visitorKeys,
|
||
|
enter: function (currentNode, parentNode) {
|
||
|
var path = this.path();
|
||
|
var pathDepth = path ? path.length : 0;
|
||
|
if (maxDepth < pathDepth) {
|
||
|
maxDepth = pathDepth;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
return maxDepth;
|
||
|
}
|
||
|
|
||
|
function isCallExpression (node) {
|
||
|
return node && node.type === syntax.CallExpression;
|
||
|
}
|
||
|
|
||
|
function isCalleeOfParent(currentNode, parentNode) {
|
||
|
return parentNode && currentNode &&
|
||
|
parentNode.type === syntax.CallExpression &&
|
||
|
parentNode.callee === currentNode;
|
||
|
}
|
||
|
|
||
|
function identifiers (node) {
|
||
|
return node.type === syntax.Identifier;
|
||
|
}
|
||
|
|
||
|
function validateApiExpression (callExpression) {
|
||
|
if (!callExpression || !callExpression.type) {
|
||
|
throw new Error(notCallExprMessage);
|
||
|
}
|
||
|
if (callExpression.type !== syntax.CallExpression) {
|
||
|
throw new Error(notCallExprMessage);
|
||
|
}
|
||
|
var names = {};
|
||
|
forEach(callExpression.arguments, function (arg) {
|
||
|
var name = validateArg(arg);
|
||
|
if (hasOwn.call(names, name)) {
|
||
|
throw new Error(duplicatedArgMessage + name);
|
||
|
} else {
|
||
|
names[name] = name;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function validateArg (arg) {
|
||
|
var inner;
|
||
|
switch(arg.type) {
|
||
|
case syntax.Identifier:
|
||
|
return arg.name;
|
||
|
case syntax.ArrayExpression:
|
||
|
if (arg.elements.length !== 1) {
|
||
|
throw new Error(invalidFormMessage);
|
||
|
}
|
||
|
inner = arg.elements[0];
|
||
|
if (inner.type !== syntax.Identifier) {
|
||
|
throw new Error(invalidFormMessage);
|
||
|
}
|
||
|
return inner.name;
|
||
|
default:
|
||
|
throw new Error(invalidFormMessage);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = CallMatcher;
|
||
|
|
||
|
},{"core-js/library/fn/array/filter":2,"core-js/library/fn/array/for-each":3,"core-js/library/fn/array/index-of":4,"core-js/library/fn/array/map":6,"core-js/library/fn/array/reduce":7,"deep-equal":98,"espurify":101,"estraverse":105}],2:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.array.filter');
|
||
|
module.exports = _dereq_('../../modules/_core').Array.filter;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.array.filter":82}],3:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.array.for-each');
|
||
|
module.exports = _dereq_('../../modules/_core').Array.forEach;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.array.for-each":83}],4:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.array.index-of');
|
||
|
module.exports = _dereq_('../../modules/_core').Array.indexOf;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.array.index-of":84}],5:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.array.is-array');
|
||
|
module.exports = _dereq_('../../modules/_core').Array.isArray;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.array.is-array":85}],6:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.array.map');
|
||
|
module.exports = _dereq_('../../modules/_core').Array.map;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.array.map":87}],7:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.array.reduce');
|
||
|
module.exports = _dereq_('../../modules/_core').Array.reduce;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.array.reduce":88}],8:[function(_dereq_,module,exports){
|
||
|
_dereq_('../modules/es6.object.to-string');
|
||
|
_dereq_('../modules/es6.string.iterator');
|
||
|
_dereq_('../modules/web.dom.iterable');
|
||
|
_dereq_('../modules/es6.map');
|
||
|
_dereq_('../modules/es7.map.to-json');
|
||
|
_dereq_('../modules/es7.map.of');
|
||
|
_dereq_('../modules/es7.map.from');
|
||
|
module.exports = _dereq_('../modules/_core').Map;
|
||
|
|
||
|
},{"../modules/_core":26,"../modules/es6.map":89,"../modules/es6.object.to-string":92,"../modules/es6.string.iterator":93,"../modules/es7.map.from":94,"../modules/es7.map.of":95,"../modules/es7.map.to-json":96,"../modules/web.dom.iterable":97}],9:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.object.assign');
|
||
|
module.exports = _dereq_('../../modules/_core').Object.assign;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.object.assign":90}],10:[function(_dereq_,module,exports){
|
||
|
_dereq_('../../modules/es6.object.keys');
|
||
|
module.exports = _dereq_('../../modules/_core').Object.keys;
|
||
|
|
||
|
},{"../../modules/_core":26,"../../modules/es6.object.keys":91}],11:[function(_dereq_,module,exports){
|
||
|
module.exports = function (it) {
|
||
|
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
|
||
|
return it;
|
||
|
};
|
||
|
|
||
|
},{}],12:[function(_dereq_,module,exports){
|
||
|
module.exports = function () { /* empty */ };
|
||
|
|
||
|
},{}],13:[function(_dereq_,module,exports){
|
||
|
module.exports = function (it, Constructor, name, forbiddenField) {
|
||
|
if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
|
||
|
throw TypeError(name + ': incorrect invocation!');
|
||
|
} return it;
|
||
|
};
|
||
|
|
||
|
},{}],14:[function(_dereq_,module,exports){
|
||
|
var isObject = _dereq_('./_is-object');
|
||
|
module.exports = function (it) {
|
||
|
if (!isObject(it)) throw TypeError(it + ' is not an object!');
|
||
|
return it;
|
||
|
};
|
||
|
|
||
|
},{"./_is-object":43}],15:[function(_dereq_,module,exports){
|
||
|
var forOf = _dereq_('./_for-of');
|
||
|
|
||
|
module.exports = function (iter, ITERATOR) {
|
||
|
var result = [];
|
||
|
forOf(iter, false, result.push, result, ITERATOR);
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
},{"./_for-of":34}],16:[function(_dereq_,module,exports){
|
||
|
// false -> Array#indexOf
|
||
|
// true -> Array#includes
|
||
|
var toIObject = _dereq_('./_to-iobject');
|
||
|
var toLength = _dereq_('./_to-length');
|
||
|
var toAbsoluteIndex = _dereq_('./_to-absolute-index');
|
||
|
module.exports = function (IS_INCLUDES) {
|
||
|
return function ($this, el, fromIndex) {
|
||
|
var O = toIObject($this);
|
||
|
var length = toLength(O.length);
|
||
|
var index = toAbsoluteIndex(fromIndex, length);
|
||
|
var value;
|
||
|
// Array#includes uses SameValueZero equality algorithm
|
||
|
// eslint-disable-next-line no-self-compare
|
||
|
if (IS_INCLUDES && el != el) while (length > index) {
|
||
|
value = O[index++];
|
||
|
// eslint-disable-next-line no-self-compare
|
||
|
if (value != value) return true;
|
||
|
// Array#indexOf ignores holes, Array#includes - not
|
||
|
} else for (;length > index; index++) if (IS_INCLUDES || index in O) {
|
||
|
if (O[index] === el) return IS_INCLUDES || index || 0;
|
||
|
} return !IS_INCLUDES && -1;
|
||
|
};
|
||
|
};
|
||
|
|
||
|
},{"./_to-absolute-index":72,"./_to-iobject":74,"./_to-length":75}],17:[function(_dereq_,module,exports){
|
||
|
// 0 -> Array#forEach
|
||
|
// 1 -> Array#map
|
||
|
// 2 -> Array#filter
|
||
|
// 3 -> Array#some
|
||
|
// 4 -> Array#every
|
||
|
// 5 -> Array#find
|
||
|
// 6 -> Array#findIndex
|
||
|
var ctx = _dereq_('./_ctx');
|
||
|
var IObject = _dereq_('./_iobject');
|
||
|
var toObject = _dereq_('./_to-object');
|
||
|
var toLength = _dereq_('./_to-length');
|
||
|
var asc = _dereq_('./_array-species-create');
|
||
|
module.exports = function (TYPE, $create) {
|
||
|
var IS_MAP = TYPE == 1;
|
||
|
var IS_FILTER = TYPE == 2;
|
||
|
var IS_SOME = TYPE == 3;
|
||
|
var IS_EVERY = TYPE == 4;
|
||
|
var IS_FIND_INDEX = TYPE == 6;
|
||
|
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
||
|
var create = $create || asc;
|
||
|
return function ($this, callbackfn, that) {
|
||
|
var O = toObject($this);
|
||
|
var self = IObject(O);
|
||
|
var f = ctx(callbackfn, that, 3);
|
||
|
var length = toLength(self.length);
|
||
|
var index = 0;
|
||
|
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
|
||
|
var val, res;
|
||
|
for (;length > index; index++) if (NO_HOLES || index in self) {
|
||
|
val = self[index];
|
||
|
res = f(val, index, O);
|
||
|
if (TYPE) {
|
||
|
if (IS_MAP) result[index] = res; // map
|
||
|
else if (res) switch (TYPE) {
|
||
|
case 3: return true; // some
|
||
|
case 5: return val; // find
|
||
|
case 6: return index; // findIndex
|
||
|
case 2: result.push(val); // filter
|
||
|
} else if (IS_EVERY) return false; // every
|
||
|
}
|
||
|
}
|
||
|
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
|
||
|
};
|
||
|
};
|
||
|
|
||
|
},{"./_array-species-create":20,"./_ctx":27,"./_iobject":40,"./_to-length":75,"./_to-object":76}],18:[function(_dereq_,module,exports){
|
||
|
var aFunction = _dereq_('./_a-function');
|
||
|
var toObject = _dereq_('./_to-object');
|
||
|
var IObject = _dereq_('./_iobject');
|
||
|
var toLength = _dereq_('./_to-length');
|
||
|
|
||
|
module.exports = function (that, callbackfn, aLen, memo, isRight) {
|
||
|
aFunction(callbackfn);
|
||
|
var O = toObject(that);
|
||
|
var self = IObject(O);
|
||
|
var length = toLength(O.length);
|
||
|
var index = isRight ? length - 1 : 0;
|
||
|
var i = isRight ? -1 : 1;
|
||
|
if (aLen < 2) for (;;) {
|
||
|
if (index in self) {
|
||
|
memo = self[index];
|
||
|
index += i;
|
||
|
break;
|
||
|
}
|
||
|
index += i;
|
||
|
if (isRight ? index < 0 : length <= index) {
|
||
|
throw TypeError('Reduce of empty array with no initial value');
|
||
|
}
|
||
|
}
|
||
|
for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {
|
||
|
memo = callbackfn(memo, self[index], index, O);
|
||
|
}
|
||
|
return memo;
|
||
|
};
|
||
|
|
||
|
},{"./_a-function":11,"./_iobject":40,"./_to-length":75,"./_to-object":76}],19:[function(_dereq_,module,exports){
|
||
|
var isObject = _dereq_('./_is-object');
|
||
|
var isArray = _dereq_('./_is-array');
|
||
|
var SPECIES = _dereq_('./_wks')('species');
|
||
|
|
||
|
module.exports = function (original) {
|
||
|
var C;
|
||
|
if (isArray(original)) {
|
||
|
C = original.constructor;
|
||
|
// cross-realm fallback
|
||
|
if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
|
||
|
if (isObject(C)) {
|
||
|
C = C[SPECIES];
|
||
|
if (C === null) C = undefined;
|
||
|
}
|
||
|
} return C === undefined ? Array : C;
|
||
|
};
|
||
|
|
||
|
},{"./_is-array":42,"./_is-object":43,"./_wks":80}],20:[function(_dereq_,module,exports){
|
||
|
// 9.4.2.3 ArraySpeciesCreate(originalArray, length)
|
||
|
var speciesConstructor = _dereq_('./_array-species-constructor');
|
||
|
|
||
|
module.exports = function (original, length) {
|
||
|
return new (speciesConstructor(original))(length);
|
||
|
};
|
||
|
|
||
|
},{"./_array-species-constructor":19}],21:[function(_dereq_,module,exports){
|
||
|
// getting tag from 19.1.3.6 Object.prototype.toString()
|
||
|
var cof = _dereq_('./_cof');
|
||
|
var TAG = _dereq_('./_wks')('toStringTag');
|
||
|
// ES3 wrong here
|
||
|
var ARG = cof(function () { return arguments; }()) == 'Arguments';
|
||
|
|
||
|
// fallback for IE11 Script Access Denied error
|
||
|
var tryGet = function (it, key) {
|
||
|
try {
|
||
|
return it[key];
|
||
|
} catch (e) { /* empty */ }
|
||
|
};
|
||
|
|
||
|
module.exports = function (it) {
|
||
|
var O, T, B;
|
||
|
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
||
|
// @@toStringTag case
|
||
|
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
|
||
|
// builtinTag case
|
||
|
: ARG ? cof(O)
|
||
|
// ES3 arguments fallback
|
||
|
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
||
|
};
|
||
|
|
||
|
},{"./_cof":22,"./_wks":80}],22:[function(_dereq_,module,exports){
|
||
|
var toString = {}.toString;
|
||
|
|
||
|
module.exports = function (it) {
|
||
|
return toString.call(it).slice(8, -1);
|
||
|
};
|
||
|
|
||
|
},{}],23:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var dP = _dereq_('./_object-dp').f;
|
||
|
var create = _dereq_('./_object-create');
|
||
|
var redefineAll = _dereq_('./_redefine-all');
|
||
|
var ctx = _dereq_('./_ctx');
|
||
|
var anInstance = _dereq_('./_an-instance');
|
||
|
var forOf = _dereq_('./_for-of');
|
||
|
var $iterDefine = _dereq_('./_iter-define');
|
||
|
var step = _dereq_('./_iter-step');
|
||
|
var setSpecies = _dereq_('./_set-species');
|
||
|
var DESCRIPTORS = _dereq_('./_descriptors');
|
||
|
var fastKey = _dereq_('./_meta').fastKey;
|
||
|
var validate = _dereq_('./_validate-collection');
|
||
|
var SIZE = DESCRIPTORS ? '_s' : 'size';
|
||
|
|
||
|
var getEntry = function (that, key) {
|
||
|
// fast case
|
||
|
var index = fastKey(key);
|
||
|
var entry;
|
||
|
if (index !== 'F') return that._i[index];
|
||
|
// frozen object case
|
||
|
for (entry = that._f; entry; entry = entry.n) {
|
||
|
if (entry.k == key) return entry;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = {
|
||
|
getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
|
||
|
var C = wrapper(function (that, iterable) {
|
||
|
anInstance(that, C, NAME, '_i');
|
||
|
that._t = NAME; // collection type
|
||
|
that._i = create(null); // index
|
||
|
that._f = undefined; // first entry
|
||
|
that._l = undefined; // last entry
|
||
|
that[SIZE] = 0; // size
|
||
|
if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
|
||
|
});
|
||
|
redefineAll(C.prototype, {
|
||
|
// 23.1.3.1 Map.prototype.clear()
|
||
|
// 23.2.3.2 Set.prototype.clear()
|
||
|
clear: function clear() {
|
||
|
for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
|
||
|
entry.r = true;
|
||
|
if (entry.p) entry.p = entry.p.n = undefined;
|
||
|
delete data[entry.i];
|
||
|
}
|
||
|
that._f = that._l = undefined;
|
||
|
that[SIZE] = 0;
|
||
|
},
|
||
|
// 23.1.3.3 Map.prototype.delete(key)
|
||
|
// 23.2.3.4 Set.prototype.delete(value)
|
||
|
'delete': function (key) {
|
||
|
var that = validate(this, NAME);
|
||
|
var entry = getEntry(that, key);
|
||
|
if (entry) {
|
||
|
var next = entry.n;
|
||
|
var prev = entry.p;
|
||
|
delete that._i[entry.i];
|
||
|
entry.r = true;
|
||
|
if (prev) prev.n = next;
|
||
|
if (next) next.p = prev;
|
||
|
if (that._f == entry) that._f = next;
|
||
|
if (that._l == entry) that._l = prev;
|
||
|
that[SIZE]--;
|
||
|
} return !!entry;
|
||
|
},
|
||
|
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
|
||
|
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
|
||
|
forEach: function forEach(callbackfn /* , that = undefined */) {
|
||
|
validate(this, NAME);
|
||
|
var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
|
||
|
var entry;
|
||
|
while (entry = entry ? entry.n : this._f) {
|
||
|
f(entry.v, entry.k, this);
|
||
|
// revert to the last existing entry
|
||
|
while (entry && entry.r) entry = entry.p;
|
||
|
}
|
||
|
},
|
||
|
// 23.1.3.7 Map.prototype.has(key)
|
||
|
// 23.2.3.7 Set.prototype.has(value)
|
||
|
has: function has(key) {
|
||
|
return !!getEntry(validate(this, NAME), key);
|
||
|
}
|
||
|
});
|
||
|
if (DESCRIPTORS) dP(C.prototype, 'size', {
|
||
|
get: function () {
|
||
|
return validate(this, NAME)[SIZE];
|
||
|
}
|
||
|
});
|
||
|
return C;
|
||
|
},
|
||
|
def: function (that, key, value) {
|
||
|
var entry = getEntry(that, key);
|
||
|
var prev, index;
|
||
|
// change existing entry
|
||
|
if (entry) {
|
||
|
entry.v = value;
|
||
|
// create new entry
|
||
|
} else {
|
||
|
that._l = entry = {
|
||
|
i: index = fastKey(key, true), // <- index
|
||
|
k: key, // <- key
|
||
|
v: value, // <- value
|
||
|
p: prev = that._l, // <- previous entry
|
||
|
n: undefined, // <- next entry
|
||
|
r: false // <- removed
|
||
|
};
|
||
|
if (!that._f) that._f = entry;
|
||
|
if (prev) prev.n = entry;
|
||
|
that[SIZE]++;
|
||
|
// add to index
|
||
|
if (index !== 'F') that._i[index] = entry;
|
||
|
} return that;
|
||
|
},
|
||
|
getEntry: getEntry,
|
||
|
setStrong: function (C, NAME, IS_MAP) {
|
||
|
// add .keys, .values, .entries, [@@iterator]
|
||
|
// 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
|
||
|
$iterDefine(C, NAME, function (iterated, kind) {
|
||
|
this._t = validate(iterated, NAME); // target
|
||
|
this._k = kind; // kind
|
||
|
this._l = undefined; // previous
|
||
|
}, function () {
|
||
|
var that = this;
|
||
|
var kind = that._k;
|
||
|
var entry = that._l;
|
||
|
// revert to the last existing entry
|
||
|
while (entry && entry.r) entry = entry.p;
|
||
|
// get next entry
|
||
|
if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
|
||
|
// or finish the iteration
|
||
|
that._t = undefined;
|
||
|
return step(1);
|
||
|
}
|
||
|
// return step by kind
|
||
|
if (kind == 'keys') return step(0, entry.k);
|
||
|
if (kind == 'values') return step(0, entry.v);
|
||
|
return step(0, [entry.k, entry.v]);
|
||
|
}, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
|
||
|
|
||
|
// add [@@species], 23.1.2.2, 23.2.2.2
|
||
|
setSpecies(NAME);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
},{"./_an-instance":13,"./_ctx":27,"./_descriptors":29,"./_for-of":34,"./_iter-define":46,"./_iter-step":47,"./_meta":50,"./_object-create":52,"./_object-dp":53,"./_redefine-all":62,"./_set-species":66,"./_validate-collection":79}],24:[function(_dereq_,module,exports){
|
||
|
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
|
||
|
var classof = _dereq_('./_classof');
|
||
|
var from = _dereq_('./_array-from-iterable');
|
||
|
module.exports = function (NAME) {
|
||
|
return function toJSON() {
|
||
|
if (classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
|
||
|
return from(this);
|
||
|
};
|
||
|
};
|
||
|
|
||
|
},{"./_array-from-iterable":15,"./_classof":21}],25:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var global = _dereq_('./_global');
|
||
|
var $export = _dereq_('./_export');
|
||
|
var meta = _dereq_('./_meta');
|
||
|
var fails = _dereq_('./_fails');
|
||
|
var hide = _dereq_('./_hide');
|
||
|
var redefineAll = _dereq_('./_redefine-all');
|
||
|
var forOf = _dereq_('./_for-of');
|
||
|
var anInstance = _dereq_('./_an-instance');
|
||
|
var isObject = _dereq_('./_is-object');
|
||
|
var setToStringTag = _dereq_('./_set-to-string-tag');
|
||
|
var dP = _dereq_('./_object-dp').f;
|
||
|
var each = _dereq_('./_array-methods')(0);
|
||
|
var DESCRIPTORS = _dereq_('./_descriptors');
|
||
|
|
||
|
module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
|
||
|
var Base = global[NAME];
|
||
|
var C = Base;
|
||
|
var ADDER = IS_MAP ? 'set' : 'add';
|
||
|
var proto = C && C.prototype;
|
||
|
var O = {};
|
||
|
if (!DESCRIPTORS || typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
|
||
|
new C().entries().next();
|
||
|
}))) {
|
||
|
// create collection constructor
|
||
|
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
|
||
|
redefineAll(C.prototype, methods);
|
||
|
meta.NEED = true;
|
||
|
} else {
|
||
|
C = wrapper(function (target, iterable) {
|
||
|
anInstance(target, C, NAME, '_c');
|
||
|
target._c = new Base();
|
||
|
if (iterable != undefined) forOf(iterable, IS_MAP, target[ADDER], target);
|
||
|
});
|
||
|
each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
|
||
|
var IS_ADDER = KEY == 'add' || KEY == 'set';
|
||
|
if (KEY in proto && !(IS_WEAK && KEY == 'clear')) hide(C.prototype, KEY, function (a, b) {
|
||
|
anInstance(this, C, KEY);
|
||
|
if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
|
||
|
var result = this._c[KEY](a === 0 ? 0 : a, b);
|
||
|
return IS_ADDER ? this : result;
|
||
|
});
|
||
|
});
|
||
|
IS_WEAK || dP(C.prototype, 'size', {
|
||
|
get: function () {
|
||
|
return this._c.size;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
setToStringTag(C, NAME);
|
||
|
|
||
|
O[NAME] = C;
|
||
|
$export($export.G + $export.W + $export.F, O);
|
||
|
|
||
|
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
|
||
|
|
||
|
return C;
|
||
|
};
|
||
|
|
||
|
},{"./_an-instance":13,"./_array-methods":17,"./_descriptors":29,"./_export":32,"./_fails":33,"./_for-of":34,"./_global":35,"./_hide":37,"./_is-object":43,"./_meta":50,"./_object-dp":53,"./_redefine-all":62,"./_set-to-string-tag":67}],26:[function(_dereq_,module,exports){
|
||
|
var core = module.exports = { version: '2.5.7' };
|
||
|
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
|
||
|
|
||
|
},{}],27:[function(_dereq_,module,exports){
|
||
|
// optional / simple context binding
|
||
|
var aFunction = _dereq_('./_a-function');
|
||
|
module.exports = function (fn, that, length) {
|
||
|
aFunction(fn);
|
||
|
if (that === undefined) return fn;
|
||
|
switch (length) {
|
||
|
case 1: return function (a) {
|
||
|
return fn.call(that, a);
|
||
|
};
|
||
|
case 2: return function (a, b) {
|
||
|
return fn.call(that, a, b);
|
||
|
};
|
||
|
case 3: return function (a, b, c) {
|
||
|
return fn.call(that, a, b, c);
|
||
|
};
|
||
|
}
|
||
|
return function (/* ...args */) {
|
||
|
return fn.apply(that, arguments);
|
||
|
};
|
||
|
};
|
||
|
|
||
|
},{"./_a-function":11}],28:[function(_dereq_,module,exports){
|
||
|
// 7.2.1 RequireObjectCoercible(argument)
|
||
|
module.exports = function (it) {
|
||
|
if (it == undefined) throw TypeError("Can't call method on " + it);
|
||
|
return it;
|
||
|
};
|
||
|
|
||
|
},{}],29:[function(_dereq_,module,exports){
|
||
|
// Thank's IE8 for his funny defineProperty
|
||
|
module.exports = !_dereq_('./_fails')(function () {
|
||
|
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
|
||
|
});
|
||
|
|
||
|
},{"./_fails":33}],30:[function(_dereq_,module,exports){
|
||
|
var isObject = _dereq_('./_is-object');
|
||
|
var document = _dereq_('./_global').document;
|
||
|
// typeof document.createElement is 'object' in old IE
|
||
|
var is = isObject(document) && isObject(document.createElement);
|
||
|
module.exports = function (it) {
|
||
|
return is ? document.createElement(it) : {};
|
||
|
};
|
||
|
|
||
|
},{"./_global":35,"./_is-object":43}],31:[function(_dereq_,module,exports){
|
||
|
// IE 8- don't enum bug keys
|
||
|
module.exports = (
|
||
|
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
|
||
|
).split(',');
|
||
|
|
||
|
},{}],32:[function(_dereq_,module,exports){
|
||
|
var global = _dereq_('./_global');
|
||
|
var core = _dereq_('./_core');
|
||
|
var ctx = _dereq_('./_ctx');
|
||
|
var hide = _dereq_('./_hide');
|
||
|
var has = _dereq_('./_has');
|
||
|
var PROTOTYPE = 'prototype';
|
||
|
|
||
|
var $export = function (type, name, source) {
|
||
|
var IS_FORCED = type & $export.F;
|
||
|
var IS_GLOBAL = type & $export.G;
|
||
|
var IS_STATIC = type & $export.S;
|
||
|
var IS_PROTO = type & $export.P;
|
||
|
var IS_BIND = type & $export.B;
|
||
|
var IS_WRAP = type & $export.W;
|
||
|
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
|
||
|
var expProto = exports[PROTOTYPE];
|
||
|
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
|
||
|
var key, own, out;
|
||
|
if (IS_GLOBAL) source = name;
|
||
|
for (key in source) {
|
||
|
// contains in native
|
||
|
own = !IS_FORCED && target && target[key] !== undefined;
|
||
|
if (own && has(exports, key)) continue;
|
||
|
// export native or passed
|
||
|
out = own ? target[key] : source[key];
|
||
|
// prevent global pollution for namespaces
|
||
|
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
|
||
|
// bind timers to global for call from export context
|
||
|
: IS_BIND && own ? ctx(out, global)
|
||
|
// wrap global constructors for prevent change them in library
|
||
|
: IS_WRAP && target[key] == out ? (function (C) {
|
||
|
var F = function (a, b, c) {
|
||
|
if (this instanceof C) {
|
||
|
switch (arguments.length) {
|
||
|
case 0: return new C();
|
||
|
case 1: return new C(a);
|
||
|
case 2: return new C(a, b);
|
||
|
} return new C(a, b, c);
|
||
|
} return C.apply(this, arguments);
|
||
|
};
|
||
|
F[PROTOTYPE] = C[PROTOTYPE];
|
||
|
return F;
|
||
|
// make static versions for prototype methods
|
||
|
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
|
||
|
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
|
||
|
if (IS_PROTO) {
|
||
|
(exports.virtual || (exports.virtual = {}))[key] = out;
|
||
|
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
|
||
|
if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
// type bitmap
|
||
|
$export.F = 1; // forced
|
||
|
$export.G = 2; // global
|
||
|
$export.S = 4; // static
|
||
|
$export.P = 8; // proto
|
||
|
$export.B = 16; // bind
|
||
|
$export.W = 32; // wrap
|
||
|
$export.U = 64; // safe
|
||
|
$export.R = 128; // real proto method for `library`
|
||
|
module.exports = $export;
|
||
|
|
||
|
},{"./_core":26,"./_ctx":27,"./_global":35,"./_has":36,"./_hide":37}],33:[function(_dereq_,module,exports){
|
||
|
module.exports = function (exec) {
|
||
|
try {
|
||
|
return !!exec();
|
||
|
} catch (e) {
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
},{}],34:[function(_dereq_,module,exports){
|
||
|
var ctx = _dereq_('./_ctx');
|
||
|
var call = _dereq_('./_iter-call');
|
||
|
var isArrayIter = _dereq_('./_is-array-iter');
|
||
|
var anObject = _dereq_('./_an-object');
|
||
|
var toLength = _dereq_('./_to-length');
|
||
|
var getIterFn = _dereq_('./core.get-iterator-method');
|
||
|
var BREAK = {};
|
||
|
var RETURN = {};
|
||
|
var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
|
||
|
var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
|
||
|
var f = ctx(fn, that, entries ? 2 : 1);
|
||
|
var index = 0;
|
||
|
var length, step, iterator, result;
|
||
|
if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
|
||
|
// fast case for arrays with default iterator
|
||
|
if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
|
||
|
result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
||
|
if (result === BREAK || result === RETURN) return result;
|
||
|
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
|
||
|
result = call(iterator, f, step.value, entries);
|
||
|
if (result === BREAK || result === RETURN) return result;
|
||
|
}
|
||
|
};
|
||
|
exports.BREAK = BREAK;
|
||
|
exports.RETURN = RETURN;
|
||
|
|
||
|
},{"./_an-object":14,"./_ctx":27,"./_is-array-iter":41,"./_iter-call":44,"./_to-length":75,"./core.get-iterator-method":81}],35:[function(_dereq_,module,exports){
|
||
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
||
|
var global = module.exports = typeof window != 'undefined' && window.Math == Math
|
||
|
? window : typeof self != 'undefined' && self.Math == Math ? self
|
||
|
// eslint-disable-next-line no-new-func
|
||
|
: Function('return this')();
|
||
|
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
|
||
|
|
||
|
},{}],36:[function(_dereq_,module,exports){
|
||
|
var hasOwnProperty = {}.hasOwnProperty;
|
||
|
module.exports = function (it, key) {
|
||
|
return hasOwnProperty.call(it, key);
|
||
|
};
|
||
|
|
||
|
},{}],37:[function(_dereq_,module,exports){
|
||
|
var dP = _dereq_('./_object-dp');
|
||
|
var createDesc = _dereq_('./_property-desc');
|
||
|
module.exports = _dereq_('./_descriptors') ? function (object, key, value) {
|
||
|
return dP.f(object, key, createDesc(1, value));
|
||
|
} : function (object, key, value) {
|
||
|
object[key] = value;
|
||
|
return object;
|
||
|
};
|
||
|
|
||
|
},{"./_descriptors":29,"./_object-dp":53,"./_property-desc":61}],38:[function(_dereq_,module,exports){
|
||
|
var document = _dereq_('./_global').document;
|
||
|
module.exports = document && document.documentElement;
|
||
|
|
||
|
},{"./_global":35}],39:[function(_dereq_,module,exports){
|
||
|
module.exports = !_dereq_('./_descriptors') && !_dereq_('./_fails')(function () {
|
||
|
return Object.defineProperty(_dereq_('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
|
||
|
});
|
||
|
|
||
|
},{"./_descriptors":29,"./_dom-create":30,"./_fails":33}],40:[function(_dereq_,module,exports){
|
||
|
// fallback for non-array-like ES3 and non-enumerable old V8 strings
|
||
|
var cof = _dereq_('./_cof');
|
||
|
// eslint-disable-next-line no-prototype-builtins
|
||
|
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
|
||
|
return cof(it) == 'String' ? it.split('') : Object(it);
|
||
|
};
|
||
|
|
||
|
},{"./_cof":22}],41:[function(_dereq_,module,exports){
|
||
|
// check on default Array iterator
|
||
|
var Iterators = _dereq_('./_iterators');
|
||
|
var ITERATOR = _dereq_('./_wks')('iterator');
|
||
|
var ArrayProto = Array.prototype;
|
||
|
|
||
|
module.exports = function (it) {
|
||
|
return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
|
||
|
};
|
||
|
|
||
|
},{"./_iterators":48,"./_wks":80}],42:[function(_dereq_,module,exports){
|
||
|
// 7.2.2 IsArray(argument)
|
||
|
var cof = _dereq_('./_cof');
|
||
|
module.exports = Array.isArray || function isArray(arg) {
|
||
|
return cof(arg) == 'Array';
|
||
|
};
|
||
|
|
||
|
},{"./_cof":22}],43:[function(_dereq_,module,exports){
|
||
|
module.exports = function (it) {
|
||
|
return typeof it === 'object' ? it !== null : typeof it === 'function';
|
||
|
};
|
||
|
|
||
|
},{}],44:[function(_dereq_,module,exports){
|
||
|
// call something on iterator step with safe closing on error
|
||
|
var anObject = _dereq_('./_an-object');
|
||
|
module.exports = function (iterator, fn, value, entries) {
|
||
|
try {
|
||
|
return entries ? fn(anObject(value)[0], value[1]) : fn(value);
|
||
|
// 7.4.6 IteratorClose(iterator, completion)
|
||
|
} catch (e) {
|
||
|
var ret = iterator['return'];
|
||
|
if (ret !== undefined) anObject(ret.call(iterator));
|
||
|
throw e;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
},{"./_an-object":14}],45:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var create = _dereq_('./_object-create');
|
||
|
var descriptor = _dereq_('./_property-desc');
|
||
|
var setToStringTag = _dereq_('./_set-to-string-tag');
|
||
|
var IteratorPrototype = {};
|
||
|
|
||
|
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
|
||
|
_dereq_('./_hide')(IteratorPrototype, _dereq_('./_wks')('iterator'), function () { return this; });
|
||
|
|
||
|
module.exports = function (Constructor, NAME, next) {
|
||
|
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
|
||
|
setToStringTag(Constructor, NAME + ' Iterator');
|
||
|
};
|
||
|
|
||
|
},{"./_hide":37,"./_object-create":52,"./_property-desc":61,"./_set-to-string-tag":67,"./_wks":80}],46:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var LIBRARY = _dereq_('./_library');
|
||
|
var $export = _dereq_('./_export');
|
||
|
var redefine = _dereq_('./_redefine');
|
||
|
var hide = _dereq_('./_hide');
|
||
|
var Iterators = _dereq_('./_iterators');
|
||
|
var $iterCreate = _dereq_('./_iter-create');
|
||
|
var setToStringTag = _dereq_('./_set-to-string-tag');
|
||
|
var getPrototypeOf = _dereq_('./_object-gpo');
|
||
|
var ITERATOR = _dereq_('./_wks')('iterator');
|
||
|
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
|
||
|
var FF_ITERATOR = '@@iterator';
|
||
|
var KEYS = 'keys';
|
||
|
var VALUES = 'values';
|
||
|
|
||
|
var returnThis = function () { return this; };
|
||
|
|
||
|
module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
||
|
$iterCreate(Constructor, NAME, next);
|
||
|
var getMethod = function (kind) {
|
||
|
if (!BUGGY && kind in proto) return proto[kind];
|
||
|
switch (kind) {
|
||
|
case KEYS: return function keys() { return new Constructor(this, kind); };
|
||
|
case VALUES: return function values() { return new Constructor(this, kind); };
|
||
|
} return function entries() { return new Constructor(this, kind); };
|
||
|
};
|
||
|
var TAG = NAME + ' Iterator';
|
||
|
var DEF_VALUES = DEFAULT == VALUES;
|
||
|
var VALUES_BUG = false;
|
||
|
var proto = Base.prototype;
|
||
|
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
|
||
|
var $default = $native || getMethod(DEFAULT);
|
||
|
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
|
||
|
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
|
||
|
var methods, key, IteratorPrototype;
|
||
|
// Fix native
|
||
|
if ($anyNative) {
|
||
|
IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
|
||
|
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
|
||
|
// Set @@toStringTag to native iterators
|
||
|
setToStringTag(IteratorPrototype, TAG, true);
|
||
|
// fix for some old engines
|
||
|
if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
|
||
|
}
|
||
|
}
|
||
|
// fix Array#{values, @@iterator}.name in V8 / FF
|
||
|
if (DEF_VALUES && $native && $native.name !== VALUES) {
|
||
|
VALUES_BUG = true;
|
||
|
$default = function values() { return $native.call(this); };
|
||
|
}
|
||
|
// Define iterator
|
||
|
if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
|
||
|
hide(proto, ITERATOR, $default);
|
||
|
}
|
||
|
// Plug for library
|
||
|
Iterators[NAME] = $default;
|
||
|
Iterators[TAG] = returnThis;
|
||
|
if (DEFAULT) {
|
||
|
methods = {
|
||
|
values: DEF_VALUES ? $default : getMethod(VALUES),
|
||
|
keys: IS_SET ? $default : getMethod(KEYS),
|
||
|
entries: $entries
|
||
|
};
|
||
|
if (FORCED) for (key in methods) {
|
||
|
if (!(key in proto)) redefine(proto, key, methods[key]);
|
||
|
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
||
|
}
|
||
|
return methods;
|
||
|
};
|
||
|
|
||
|
},{"./_export":32,"./_hide":37,"./_iter-create":45,"./_iterators":48,"./_library":49,"./_object-gpo":56,"./_redefine":63,"./_set-to-string-tag":67,"./_wks":80}],47:[function(_dereq_,module,exports){
|
||
|
module.exports = function (done, value) {
|
||
|
return { value: value, done: !!done };
|
||
|
};
|
||
|
|
||
|
},{}],48:[function(_dereq_,module,exports){
|
||
|
module.exports = {};
|
||
|
|
||
|
},{}],49:[function(_dereq_,module,exports){
|
||
|
module.exports = true;
|
||
|
|
||
|
},{}],50:[function(_dereq_,module,exports){
|
||
|
var META = _dereq_('./_uid')('meta');
|
||
|
var isObject = _dereq_('./_is-object');
|
||
|
var has = _dereq_('./_has');
|
||
|
var setDesc = _dereq_('./_object-dp').f;
|
||
|
var id = 0;
|
||
|
var isExtensible = Object.isExtensible || function () {
|
||
|
return true;
|
||
|
};
|
||
|
var FREEZE = !_dereq_('./_fails')(function () {
|
||
|
return isExtensible(Object.preventExtensions({}));
|
||
|
});
|
||
|
var setMeta = function (it) {
|
||
|
setDesc(it, META, { value: {
|
||
|
i: 'O' + ++id, // object ID
|
||
|
w: {} // weak collections IDs
|
||
|
} });
|
||
|
};
|
||
|
var fastKey = function (it, create) {
|
||
|
// return primitive with prefix
|
||
|
if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
||
|
if (!has(it, META)) {
|
||
|
// can't set metadata to uncaught frozen object
|
||
|
if (!isExtensible(it)) return 'F';
|
||
|
// not necessary to add metadata
|
||
|
if (!create) return 'E';
|
||
|
// add missing metadata
|
||
|
setMeta(it);
|
||
|
// return object ID
|
||
|
} return it[META].i;
|
||
|
};
|
||
|
var getWeak = function (it, create) {
|
||
|
if (!has(it, META)) {
|
||
|
// can't set metadata to uncaught frozen object
|
||
|
if (!isExtensible(it)) return true;
|
||
|
// not necessary to add metadata
|
||
|
if (!create) return false;
|
||
|
// add missing metadata
|
||
|
setMeta(it);
|
||
|
// return hash weak collections IDs
|
||
|
} return it[META].w;
|
||
|
};
|
||
|
// add metadata on freeze-family methods calling
|
||
|
var onFreeze = function (it) {
|
||
|
if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
|
||
|
return it;
|
||
|
};
|
||
|
var meta = module.exports = {
|
||
|
KEY: META,
|
||
|
NEED: false,
|
||
|
fastKey: fastKey,
|
||
|
getWeak: getWeak,
|
||
|
onFreeze: onFreeze
|
||
|
};
|
||
|
|
||
|
},{"./_fails":33,"./_has":36,"./_is-object":43,"./_object-dp":53,"./_uid":78}],51:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
// 19.1.2.1 Object.assign(target, source, ...)
|
||
|
var getKeys = _dereq_('./_object-keys');
|
||
|
var gOPS = _dereq_('./_object-gops');
|
||
|
var pIE = _dereq_('./_object-pie');
|
||
|
var toObject = _dereq_('./_to-object');
|
||
|
var IObject = _dereq_('./_iobject');
|
||
|
var $assign = Object.assign;
|
||
|
|
||
|
// should work with symbols and should have deterministic property order (V8 bug)
|
||
|
module.exports = !$assign || _dereq_('./_fails')(function () {
|
||
|
var A = {};
|
||
|
var B = {};
|
||
|
// eslint-disable-next-line no-undef
|
||
|
var S = Symbol();
|
||
|
var K = 'abcdefghijklmnopqrst';
|
||
|
A[S] = 7;
|
||
|
K.split('').forEach(function (k) { B[k] = k; });
|
||
|
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
|
||
|
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
|
||
|
var T = toObject(target);
|
||
|
var aLen = arguments.length;
|
||
|
var index = 1;
|
||
|
var getSymbols = gOPS.f;
|
||
|
var isEnum = pIE.f;
|
||
|
while (aLen > index) {
|
||
|
var S = IObject(arguments[index++]);
|
||
|
var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
|
||
|
var length = keys.length;
|
||
|
var j = 0;
|
||
|
var key;
|
||
|
while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
|
||
|
} return T;
|
||
|
} : $assign;
|
||
|
|
||
|
},{"./_fails":33,"./_iobject":40,"./_object-gops":55,"./_object-keys":58,"./_object-pie":59,"./_to-object":76}],52:[function(_dereq_,module,exports){
|
||
|
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
|
||
|
var anObject = _dereq_('./_an-object');
|
||
|
var dPs = _dereq_('./_object-dps');
|
||
|
var enumBugKeys = _dereq_('./_enum-bug-keys');
|
||
|
var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
|
||
|
var Empty = function () { /* empty */ };
|
||
|
var PROTOTYPE = 'prototype';
|
||
|
|
||
|
// Create object with fake `null` prototype: use iframe Object with cleared prototype
|
||
|
var createDict = function () {
|
||
|
// Thrash, waste and sodomy: IE GC bug
|
||
|
var iframe = _dereq_('./_dom-create')('iframe');
|
||
|
var i = enumBugKeys.length;
|
||
|
var lt = '<';
|
||
|
var gt = '>';
|
||
|
var iframeDocument;
|
||
|
iframe.style.display = 'none';
|
||
|
_dereq_('./_html').appendChild(iframe);
|
||
|
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
|
||
|
// createDict = iframe.contentWindow.Object;
|
||
|
// html.removeChild(iframe);
|
||
|
iframeDocument = iframe.contentWindow.document;
|
||
|
iframeDocument.open();
|
||
|
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
|
||
|
iframeDocument.close();
|
||
|
createDict = iframeDocument.F;
|
||
|
while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
|
||
|
return createDict();
|
||
|
};
|
||
|
|
||
|
module.exports = Object.create || function create(O, Properties) {
|
||
|
var result;
|
||
|
if (O !== null) {
|
||
|
Empty[PROTOTYPE] = anObject(O);
|
||
|
result = new Empty();
|
||
|
Empty[PROTOTYPE] = null;
|
||
|
// add "__proto__" for Object.getPrototypeOf polyfill
|
||
|
result[IE_PROTO] = O;
|
||
|
} else result = createDict();
|
||
|
return Properties === undefined ? result : dPs(result, Properties);
|
||
|
};
|
||
|
|
||
|
},{"./_an-object":14,"./_dom-create":30,"./_enum-bug-keys":31,"./_html":38,"./_object-dps":54,"./_shared-key":68}],53:[function(_dereq_,module,exports){
|
||
|
var anObject = _dereq_('./_an-object');
|
||
|
var IE8_DOM_DEFINE = _dereq_('./_ie8-dom-define');
|
||
|
var toPrimitive = _dereq_('./_to-primitive');
|
||
|
var dP = Object.defineProperty;
|
||
|
|
||
|
exports.f = _dereq_('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
||
|
anObject(O);
|
||
|
P = toPrimitive(P, true);
|
||
|
anObject(Attributes);
|
||
|
if (IE8_DOM_DEFINE) try {
|
||
|
return dP(O, P, Attributes);
|
||
|
} catch (e) { /* empty */ }
|
||
|
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
|
||
|
if ('value' in Attributes) O[P] = Attributes.value;
|
||
|
return O;
|
||
|
};
|
||
|
|
||
|
},{"./_an-object":14,"./_descriptors":29,"./_ie8-dom-define":39,"./_to-primitive":77}],54:[function(_dereq_,module,exports){
|
||
|
var dP = _dereq_('./_object-dp');
|
||
|
var anObject = _dereq_('./_an-object');
|
||
|
var getKeys = _dereq_('./_object-keys');
|
||
|
|
||
|
module.exports = _dereq_('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
|
||
|
anObject(O);
|
||
|
var keys = getKeys(Properties);
|
||
|
var length = keys.length;
|
||
|
var i = 0;
|
||
|
var P;
|
||
|
while (length > i) dP.f(O, P = keys[i++], Properties[P]);
|
||
|
return O;
|
||
|
};
|
||
|
|
||
|
},{"./_an-object":14,"./_descriptors":29,"./_object-dp":53,"./_object-keys":58}],55:[function(_dereq_,module,exports){
|
||
|
exports.f = Object.getOwnPropertySymbols;
|
||
|
|
||
|
},{}],56:[function(_dereq_,module,exports){
|
||
|
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
|
||
|
var has = _dereq_('./_has');
|
||
|
var toObject = _dereq_('./_to-object');
|
||
|
var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
|
||
|
var ObjectProto = Object.prototype;
|
||
|
|
||
|
module.exports = Object.getPrototypeOf || function (O) {
|
||
|
O = toObject(O);
|
||
|
if (has(O, IE_PROTO)) return O[IE_PROTO];
|
||
|
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
|
||
|
return O.constructor.prototype;
|
||
|
} return O instanceof Object ? ObjectProto : null;
|
||
|
};
|
||
|
|
||
|
},{"./_has":36,"./_shared-key":68,"./_to-object":76}],57:[function(_dereq_,module,exports){
|
||
|
var has = _dereq_('./_has');
|
||
|
var toIObject = _dereq_('./_to-iobject');
|
||
|
var arrayIndexOf = _dereq_('./_array-includes')(false);
|
||
|
var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
|
||
|
|
||
|
module.exports = function (object, names) {
|
||
|
var O = toIObject(object);
|
||
|
var i = 0;
|
||
|
var result = [];
|
||
|
var key;
|
||
|
for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
|
||
|
// Don't enum bug & hidden keys
|
||
|
while (names.length > i) if (has(O, key = names[i++])) {
|
||
|
~arrayIndexOf(result, key) || result.push(key);
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
},{"./_array-includes":16,"./_has":36,"./_shared-key":68,"./_to-iobject":74}],58:[function(_dereq_,module,exports){
|
||
|
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
|
||
|
var $keys = _dereq_('./_object-keys-internal');
|
||
|
var enumBugKeys = _dereq_('./_enum-bug-keys');
|
||
|
|
||
|
module.exports = Object.keys || function keys(O) {
|
||
|
return $keys(O, enumBugKeys);
|
||
|
};
|
||
|
|
||
|
},{"./_enum-bug-keys":31,"./_object-keys-internal":57}],59:[function(_dereq_,module,exports){
|
||
|
exports.f = {}.propertyIsEnumerable;
|
||
|
|
||
|
},{}],60:[function(_dereq_,module,exports){
|
||
|
// most Object methods by ES6 should accept primitives
|
||
|
var $export = _dereq_('./_export');
|
||
|
var core = _dereq_('./_core');
|
||
|
var fails = _dereq_('./_fails');
|
||
|
module.exports = function (KEY, exec) {
|
||
|
var fn = (core.Object || {})[KEY] || Object[KEY];
|
||
|
var exp = {};
|
||
|
exp[KEY] = exec(fn);
|
||
|
$export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
|
||
|
};
|
||
|
|
||
|
},{"./_core":26,"./_export":32,"./_fails":33}],61:[function(_dereq_,module,exports){
|
||
|
module.exports = function (bitmap, value) {
|
||
|
return {
|
||
|
enumerable: !(bitmap & 1),
|
||
|
configurable: !(bitmap & 2),
|
||
|
writable: !(bitmap & 4),
|
||
|
value: value
|
||
|
};
|
||
|
};
|
||
|
|
||
|
},{}],62:[function(_dereq_,module,exports){
|
||
|
var hide = _dereq_('./_hide');
|
||
|
module.exports = function (target, src, safe) {
|
||
|
for (var key in src) {
|
||
|
if (safe && target[key]) target[key] = src[key];
|
||
|
else hide(target, key, src[key]);
|
||
|
} return target;
|
||
|
};
|
||
|
|
||
|
},{"./_hide":37}],63:[function(_dereq_,module,exports){
|
||
|
module.exports = _dereq_('./_hide');
|
||
|
|
||
|
},{"./_hide":37}],64:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
// https://tc39.github.io/proposal-setmap-offrom/
|
||
|
var $export = _dereq_('./_export');
|
||
|
var aFunction = _dereq_('./_a-function');
|
||
|
var ctx = _dereq_('./_ctx');
|
||
|
var forOf = _dereq_('./_for-of');
|
||
|
|
||
|
module.exports = function (COLLECTION) {
|
||
|
$export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
|
||
|
var mapFn = arguments[1];
|
||
|
var mapping, A, n, cb;
|
||
|
aFunction(this);
|
||
|
mapping = mapFn !== undefined;
|
||
|
if (mapping) aFunction(mapFn);
|
||
|
if (source == undefined) return new this();
|
||
|
A = [];
|
||
|
if (mapping) {
|
||
|
n = 0;
|
||
|
cb = ctx(mapFn, arguments[2], 2);
|
||
|
forOf(source, false, function (nextItem) {
|
||
|
A.push(cb(nextItem, n++));
|
||
|
});
|
||
|
} else {
|
||
|
forOf(source, false, A.push, A);
|
||
|
}
|
||
|
return new this(A);
|
||
|
} });
|
||
|
};
|
||
|
|
||
|
},{"./_a-function":11,"./_ctx":27,"./_export":32,"./_for-of":34}],65:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
// https://tc39.github.io/proposal-setmap-offrom/
|
||
|
var $export = _dereq_('./_export');
|
||
|
|
||
|
module.exports = function (COLLECTION) {
|
||
|
$export($export.S, COLLECTION, { of: function of() {
|
||
|
var length = arguments.length;
|
||
|
var A = new Array(length);
|
||
|
while (length--) A[length] = arguments[length];
|
||
|
return new this(A);
|
||
|
} });
|
||
|
};
|
||
|
|
||
|
},{"./_export":32}],66:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var global = _dereq_('./_global');
|
||
|
var core = _dereq_('./_core');
|
||
|
var dP = _dereq_('./_object-dp');
|
||
|
var DESCRIPTORS = _dereq_('./_descriptors');
|
||
|
var SPECIES = _dereq_('./_wks')('species');
|
||
|
|
||
|
module.exports = function (KEY) {
|
||
|
var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
|
||
|
if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
|
||
|
configurable: true,
|
||
|
get: function () { return this; }
|
||
|
});
|
||
|
};
|
||
|
|
||
|
},{"./_core":26,"./_descriptors":29,"./_global":35,"./_object-dp":53,"./_wks":80}],67:[function(_dereq_,module,exports){
|
||
|
var def = _dereq_('./_object-dp').f;
|
||
|
var has = _dereq_('./_has');
|
||
|
var TAG = _dereq_('./_wks')('toStringTag');
|
||
|
|
||
|
module.exports = function (it, tag, stat) {
|
||
|
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
|
||
|
};
|
||
|
|
||
|
},{"./_has":36,"./_object-dp":53,"./_wks":80}],68:[function(_dereq_,module,exports){
|
||
|
var shared = _dereq_('./_shared')('keys');
|
||
|
var uid = _dereq_('./_uid');
|
||
|
module.exports = function (key) {
|
||
|
return shared[key] || (shared[key] = uid(key));
|
||
|
};
|
||
|
|
||
|
},{"./_shared":69,"./_uid":78}],69:[function(_dereq_,module,exports){
|
||
|
var core = _dereq_('./_core');
|
||
|
var global = _dereq_('./_global');
|
||
|
var SHARED = '__core-js_shared__';
|
||
|
var store = global[SHARED] || (global[SHARED] = {});
|
||
|
|
||
|
(module.exports = function (key, value) {
|
||
|
return store[key] || (store[key] = value !== undefined ? value : {});
|
||
|
})('versions', []).push({
|
||
|
version: core.version,
|
||
|
mode: _dereq_('./_library') ? 'pure' : 'global',
|
||
|
copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
|
||
|
});
|
||
|
|
||
|
},{"./_core":26,"./_global":35,"./_library":49}],70:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var fails = _dereq_('./_fails');
|
||
|
|
||
|
module.exports = function (method, arg) {
|
||
|
return !!method && fails(function () {
|
||
|
// eslint-disable-next-line no-useless-call
|
||
|
arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
},{"./_fails":33}],71:[function(_dereq_,module,exports){
|
||
|
var toInteger = _dereq_('./_to-integer');
|
||
|
var defined = _dereq_('./_defined');
|
||
|
// true -> String#at
|
||
|
// false -> String#codePointAt
|
||
|
module.exports = function (TO_STRING) {
|
||
|
return function (that, pos) {
|
||
|
var s = String(defined(that));
|
||
|
var i = toInteger(pos);
|
||
|
var l = s.length;
|
||
|
var a, b;
|
||
|
if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
|
||
|
a = s.charCodeAt(i);
|
||
|
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
|
||
|
? TO_STRING ? s.charAt(i) : a
|
||
|
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
||
|
};
|
||
|
};
|
||
|
|
||
|
},{"./_defined":28,"./_to-integer":73}],72:[function(_dereq_,module,exports){
|
||
|
var toInteger = _dereq_('./_to-integer');
|
||
|
var max = Math.max;
|
||
|
var min = Math.min;
|
||
|
module.exports = function (index, length) {
|
||
|
index = toInteger(index);
|
||
|
return index < 0 ? max(index + length, 0) : min(index, length);
|
||
|
};
|
||
|
|
||
|
},{"./_to-integer":73}],73:[function(_dereq_,module,exports){
|
||
|
// 7.1.4 ToInteger
|
||
|
var ceil = Math.ceil;
|
||
|
var floor = Math.floor;
|
||
|
module.exports = function (it) {
|
||
|
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
||
|
};
|
||
|
|
||
|
},{}],74:[function(_dereq_,module,exports){
|
||
|
// to indexed object, toObject with fallback for non-array-like ES3 strings
|
||
|
var IObject = _dereq_('./_iobject');
|
||
|
var defined = _dereq_('./_defined');
|
||
|
module.exports = function (it) {
|
||
|
return IObject(defined(it));
|
||
|
};
|
||
|
|
||
|
},{"./_defined":28,"./_iobject":40}],75:[function(_dereq_,module,exports){
|
||
|
// 7.1.15 ToLength
|
||
|
var toInteger = _dereq_('./_to-integer');
|
||
|
var min = Math.min;
|
||
|
module.exports = function (it) {
|
||
|
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
|
||
|
};
|
||
|
|
||
|
},{"./_to-integer":73}],76:[function(_dereq_,module,exports){
|
||
|
// 7.1.13 ToObject(argument)
|
||
|
var defined = _dereq_('./_defined');
|
||
|
module.exports = function (it) {
|
||
|
return Object(defined(it));
|
||
|
};
|
||
|
|
||
|
},{"./_defined":28}],77:[function(_dereq_,module,exports){
|
||
|
// 7.1.1 ToPrimitive(input [, PreferredType])
|
||
|
var isObject = _dereq_('./_is-object');
|
||
|
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
|
||
|
// and the second argument - flag - preferred type is a string
|
||
|
module.exports = function (it, S) {
|
||
|
if (!isObject(it)) return it;
|
||
|
var fn, val;
|
||
|
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
|
||
|
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
|
||
|
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
|
||
|
throw TypeError("Can't convert object to primitive value");
|
||
|
};
|
||
|
|
||
|
},{"./_is-object":43}],78:[function(_dereq_,module,exports){
|
||
|
var id = 0;
|
||
|
var px = Math.random();
|
||
|
module.exports = function (key) {
|
||
|
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
||
|
};
|
||
|
|
||
|
},{}],79:[function(_dereq_,module,exports){
|
||
|
var isObject = _dereq_('./_is-object');
|
||
|
module.exports = function (it, TYPE) {
|
||
|
if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
|
||
|
return it;
|
||
|
};
|
||
|
|
||
|
},{"./_is-object":43}],80:[function(_dereq_,module,exports){
|
||
|
var store = _dereq_('./_shared')('wks');
|
||
|
var uid = _dereq_('./_uid');
|
||
|
var Symbol = _dereq_('./_global').Symbol;
|
||
|
var USE_SYMBOL = typeof Symbol == 'function';
|
||
|
|
||
|
var $exports = module.exports = function (name) {
|
||
|
return store[name] || (store[name] =
|
||
|
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
|
||
|
};
|
||
|
|
||
|
$exports.store = store;
|
||
|
|
||
|
},{"./_global":35,"./_shared":69,"./_uid":78}],81:[function(_dereq_,module,exports){
|
||
|
var classof = _dereq_('./_classof');
|
||
|
var ITERATOR = _dereq_('./_wks')('iterator');
|
||
|
var Iterators = _dereq_('./_iterators');
|
||
|
module.exports = _dereq_('./_core').getIteratorMethod = function (it) {
|
||
|
if (it != undefined) return it[ITERATOR]
|
||
|
|| it['@@iterator']
|
||
|
|| Iterators[classof(it)];
|
||
|
};
|
||
|
|
||
|
},{"./_classof":21,"./_core":26,"./_iterators":48,"./_wks":80}],82:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var $export = _dereq_('./_export');
|
||
|
var $filter = _dereq_('./_array-methods')(2);
|
||
|
|
||
|
$export($export.P + $export.F * !_dereq_('./_strict-method')([].filter, true), 'Array', {
|
||
|
// 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
|
||
|
filter: function filter(callbackfn /* , thisArg */) {
|
||
|
return $filter(this, callbackfn, arguments[1]);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
},{"./_array-methods":17,"./_export":32,"./_strict-method":70}],83:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var $export = _dereq_('./_export');
|
||
|
var $forEach = _dereq_('./_array-methods')(0);
|
||
|
var STRICT = _dereq_('./_strict-method')([].forEach, true);
|
||
|
|
||
|
$export($export.P + $export.F * !STRICT, 'Array', {
|
||
|
// 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
|
||
|
forEach: function forEach(callbackfn /* , thisArg */) {
|
||
|
return $forEach(this, callbackfn, arguments[1]);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
},{"./_array-methods":17,"./_export":32,"./_strict-method":70}],84:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var $export = _dereq_('./_export');
|
||
|
var $indexOf = _dereq_('./_array-includes')(false);
|
||
|
var $native = [].indexOf;
|
||
|
var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;
|
||
|
|
||
|
$export($export.P + $export.F * (NEGATIVE_ZERO || !_dereq_('./_strict-method')($native)), 'Array', {
|
||
|
// 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
|
||
|
indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
|
||
|
return NEGATIVE_ZERO
|
||
|
// convert -0 to +0
|
||
|
? $native.apply(this, arguments) || 0
|
||
|
: $indexOf(this, searchElement, arguments[1]);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
},{"./_array-includes":16,"./_export":32,"./_strict-method":70}],85:[function(_dereq_,module,exports){
|
||
|
// 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
|
||
|
var $export = _dereq_('./_export');
|
||
|
|
||
|
$export($export.S, 'Array', { isArray: _dereq_('./_is-array') });
|
||
|
|
||
|
},{"./_export":32,"./_is-array":42}],86:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var addToUnscopables = _dereq_('./_add-to-unscopables');
|
||
|
var step = _dereq_('./_iter-step');
|
||
|
var Iterators = _dereq_('./_iterators');
|
||
|
var toIObject = _dereq_('./_to-iobject');
|
||
|
|
||
|
// 22.1.3.4 Array.prototype.entries()
|
||
|
// 22.1.3.13 Array.prototype.keys()
|
||
|
// 22.1.3.29 Array.prototype.values()
|
||
|
// 22.1.3.30 Array.prototype[@@iterator]()
|
||
|
module.exports = _dereq_('./_iter-define')(Array, 'Array', function (iterated, kind) {
|
||
|
this._t = toIObject(iterated); // target
|
||
|
this._i = 0; // next index
|
||
|
this._k = kind; // kind
|
||
|
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
|
||
|
}, function () {
|
||
|
var O = this._t;
|
||
|
var kind = this._k;
|
||
|
var index = this._i++;
|
||
|
if (!O || index >= O.length) {
|
||
|
this._t = undefined;
|
||
|
return step(1);
|
||
|
}
|
||
|
if (kind == 'keys') return step(0, index);
|
||
|
if (kind == 'values') return step(0, O[index]);
|
||
|
return step(0, [index, O[index]]);
|
||
|
}, 'values');
|
||
|
|
||
|
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
|
||
|
Iterators.Arguments = Iterators.Array;
|
||
|
|
||
|
addToUnscopables('keys');
|
||
|
addToUnscopables('values');
|
||
|
addToUnscopables('entries');
|
||
|
|
||
|
},{"./_add-to-unscopables":12,"./_iter-define":46,"./_iter-step":47,"./_iterators":48,"./_to-iobject":74}],87:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var $export = _dereq_('./_export');
|
||
|
var $map = _dereq_('./_array-methods')(1);
|
||
|
|
||
|
$export($export.P + $export.F * !_dereq_('./_strict-method')([].map, true), 'Array', {
|
||
|
// 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
|
||
|
map: function map(callbackfn /* , thisArg */) {
|
||
|
return $map(this, callbackfn, arguments[1]);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
},{"./_array-methods":17,"./_export":32,"./_strict-method":70}],88:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var $export = _dereq_('./_export');
|
||
|
var $reduce = _dereq_('./_array-reduce');
|
||
|
|
||
|
$export($export.P + $export.F * !_dereq_('./_strict-method')([].reduce, true), 'Array', {
|
||
|
// 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
|
||
|
reduce: function reduce(callbackfn /* , initialValue */) {
|
||
|
return $reduce(this, callbackfn, arguments.length, arguments[1], false);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
},{"./_array-reduce":18,"./_export":32,"./_strict-method":70}],89:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var strong = _dereq_('./_collection-strong');
|
||
|
var validate = _dereq_('./_validate-collection');
|
||
|
var MAP = 'Map';
|
||
|
|
||
|
// 23.1 Map Objects
|
||
|
module.exports = _dereq_('./_collection')(MAP, function (get) {
|
||
|
return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
|
||
|
}, {
|
||
|
// 23.1.3.6 Map.prototype.get(key)
|
||
|
get: function get(key) {
|
||
|
var entry = strong.getEntry(validate(this, MAP), key);
|
||
|
return entry && entry.v;
|
||
|
},
|
||
|
// 23.1.3.9 Map.prototype.set(key, value)
|
||
|
set: function set(key, value) {
|
||
|
return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
|
||
|
}
|
||
|
}, strong, true);
|
||
|
|
||
|
},{"./_collection":25,"./_collection-strong":23,"./_validate-collection":79}],90:[function(_dereq_,module,exports){
|
||
|
// 19.1.3.1 Object.assign(target, source)
|
||
|
var $export = _dereq_('./_export');
|
||
|
|
||
|
$export($export.S + $export.F, 'Object', { assign: _dereq_('./_object-assign') });
|
||
|
|
||
|
},{"./_export":32,"./_object-assign":51}],91:[function(_dereq_,module,exports){
|
||
|
// 19.1.2.14 Object.keys(O)
|
||
|
var toObject = _dereq_('./_to-object');
|
||
|
var $keys = _dereq_('./_object-keys');
|
||
|
|
||
|
_dereq_('./_object-sap')('keys', function () {
|
||
|
return function keys(it) {
|
||
|
return $keys(toObject(it));
|
||
|
};
|
||
|
});
|
||
|
|
||
|
},{"./_object-keys":58,"./_object-sap":60,"./_to-object":76}],92:[function(_dereq_,module,exports){
|
||
|
|
||
|
},{}],93:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
var $at = _dereq_('./_string-at')(true);
|
||
|
|
||
|
// 21.1.3.27 String.prototype[@@iterator]()
|
||
|
_dereq_('./_iter-define')(String, 'String', function (iterated) {
|
||
|
this._t = String(iterated); // target
|
||
|
this._i = 0; // next index
|
||
|
// 21.1.5.2.1 %StringIteratorPrototype%.next()
|
||
|
}, function () {
|
||
|
var O = this._t;
|
||
|
var index = this._i;
|
||
|
var point;
|
||
|
if (index >= O.length) return { value: undefined, done: true };
|
||
|
point = $at(O, index);
|
||
|
this._i += point.length;
|
||
|
return { value: point, done: false };
|
||
|
});
|
||
|
|
||
|
},{"./_iter-define":46,"./_string-at":71}],94:[function(_dereq_,module,exports){
|
||
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
|
||
|
_dereq_('./_set-collection-from')('Map');
|
||
|
|
||
|
},{"./_set-collection-from":64}],95:[function(_dereq_,module,exports){
|
||
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
|
||
|
_dereq_('./_set-collection-of')('Map');
|
||
|
|
||
|
},{"./_set-collection-of":65}],96:[function(_dereq_,module,exports){
|
||
|
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
|
||
|
var $export = _dereq_('./_export');
|
||
|
|
||
|
$export($export.P + $export.R, 'Map', { toJSON: _dereq_('./_collection-to-json')('Map') });
|
||
|
|
||
|
},{"./_collection-to-json":24,"./_export":32}],97:[function(_dereq_,module,exports){
|
||
|
_dereq_('./es6.array.iterator');
|
||
|
var global = _dereq_('./_global');
|
||
|
var hide = _dereq_('./_hide');
|
||
|
var Iterators = _dereq_('./_iterators');
|
||
|
var TO_STRING_TAG = _dereq_('./_wks')('toStringTag');
|
||
|
|
||
|
var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
|
||
|
'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
|
||
|
'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
|
||
|
'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
|
||
|
'TextTrackList,TouchList').split(',');
|
||
|
|
||
|
for (var i = 0; i < DOMIterables.length; i++) {
|
||
|
var NAME = DOMIterables[i];
|
||
|
var Collection = global[NAME];
|
||
|
var proto = Collection && Collection.prototype;
|
||
|
if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
|
||
|
Iterators[NAME] = Iterators.Array;
|
||
|
}
|
||
|
|
||
|
},{"./_global":35,"./_hide":37,"./_iterators":48,"./_wks":80,"./es6.array.iterator":86}],98:[function(_dereq_,module,exports){
|
||
|
var pSlice = Array.prototype.slice;
|
||
|
var objectKeys = _dereq_('./lib/keys.js');
|
||
|
var isArguments = _dereq_('./lib/is_arguments.js');
|
||
|
|
||
|
var deepEqual = module.exports = function (actual, expected, opts) {
|
||
|
if (!opts) opts = {};
|
||
|
// 7.1. All identical values are equivalent, as determined by ===.
|
||
|
if (actual === expected) {
|
||
|
return true;
|
||
|
|
||
|
} else if (actual instanceof Date && expected instanceof Date) {
|
||
|
return actual.getTime() === expected.getTime();
|
||
|
|
||
|
// 7.3. Other pairs that do not both pass typeof value == 'object',
|
||
|
// equivalence is determined by ==.
|
||
|
} else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
|
||
|
return opts.strict ? actual === expected : actual == expected;
|
||
|
|
||
|
// 7.4. For all other Object pairs, including Array objects, equivalence is
|
||
|
// determined by having the same number of owned properties (as verified
|
||
|
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
||
|
// (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 {
|
||
|
return objEquiv(actual, expected, opts);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function isUndefinedOrNull(value) {
|
||
|
return value === null || value === undefined;
|
||
|
}
|
||
|
|
||
|
function isBuffer (x) {
|
||
|
if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
|
||
|
if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
|
||
|
return false;
|
||
|
}
|
||
|
if (x.length > 0 && typeof x[0] !== 'number') return false;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
function objEquiv(a, b, opts) {
|
||
|
var i, key;
|
||
|
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
|
||
|
return false;
|
||
|
// an identical 'prototype' property.
|
||
|
if (a.prototype !== b.prototype) return false;
|
||
|
//~~~I've managed to break Object.keys through screwy arguments passing.
|
||
|
// Converting to array solves the problem.
|
||
|
if (isArguments(a)) {
|
||
|
if (!isArguments(b)) {
|
||
|
return false;
|
||
|
}
|
||
|
a = pSlice.call(a);
|
||
|
b = pSlice.call(b);
|
||
|
return deepEqual(a, b, opts);
|
||
|
}
|
||
|
if (isBuffer(a)) {
|
||
|
if (!isBuffer(b)) {
|
||
|
return false;
|
||
|
}
|
||
|
if (a.length !== b.length) return false;
|
||
|
for (i = 0; i < a.length; i++) {
|
||
|
if (a[i] !== b[i]) return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
try {
|
||
|
var ka = objectKeys(a),
|
||
|
kb = objectKeys(b);
|
||
|
} catch (e) {//happens when one is a string literal and the other isn't
|
||
|
return false;
|
||
|
}
|
||
|
// having the same number of owned properties (keys incorporates
|
||
|
// hasOwnProperty)
|
||
|
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])
|
||
|
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], opts)) return false;
|
||
|
}
|
||
|
return typeof a === typeof b;
|
||
|
}
|
||
|
|
||
|
},{"./lib/is_arguments.js":99,"./lib/keys.js":100}],99:[function(_dereq_,module,exports){
|
||
|
var supportsArgumentsClass = (function(){
|
||
|
return Object.prototype.toString.call(arguments)
|
||
|
})() == '[object Arguments]';
|
||
|
|
||
|
exports = module.exports = supportsArgumentsClass ? supported : unsupported;
|
||
|
|
||
|
exports.supported = supported;
|
||
|
function supported(object) {
|
||
|
return Object.prototype.toString.call(object) == '[object Arguments]';
|
||
|
};
|
||
|
|
||
|
exports.unsupported = unsupported;
|
||
|
function unsupported(object){
|
||
|
return object &&
|
||
|
typeof object == 'object' &&
|
||
|
typeof object.length == 'number' &&
|
||
|
Object.prototype.hasOwnProperty.call(object, 'callee') &&
|
||
|
!Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
|
||
|
false;
|
||
|
};
|
||
|
|
||
|
},{}],100:[function(_dereq_,module,exports){
|
||
|
exports = module.exports = typeof Object.keys === 'function'
|
||
|
? Object.keys : shim;
|
||
|
|
||
|
exports.shim = shim;
|
||
|
function shim (obj) {
|
||
|
var keys = [];
|
||
|
for (var key in obj) keys.push(key);
|
||
|
return keys;
|
||
|
}
|
||
|
|
||
|
},{}],101:[function(_dereq_,module,exports){
|
||
|
/**
|
||
|
* espurify - Clone new AST without extra properties
|
||
|
*
|
||
|
* https://github.com/estools/espurify
|
||
|
*
|
||
|
* Copyright (c) 2014-2018 Takuto Wada
|
||
|
* Licensed under the MIT license.
|
||
|
* https://github.com/estools/espurify/blob/master/MIT-LICENSE.txt
|
||
|
*/
|
||
|
'use strict';
|
||
|
|
||
|
var createWhitelist = _dereq_('./lib/create-whitelist');
|
||
|
var cloneWithWhitelist = _dereq_('./lib/clone-ast');
|
||
|
|
||
|
function createCloneFunction (options) {
|
||
|
return cloneWithWhitelist(createWhitelist(options));
|
||
|
}
|
||
|
|
||
|
var espurify = createCloneFunction();
|
||
|
espurify.customize = createCloneFunction;
|
||
|
espurify.cloneWithWhitelist = cloneWithWhitelist;
|
||
|
module.exports = espurify;
|
||
|
|
||
|
},{"./lib/clone-ast":103,"./lib/create-whitelist":104}],102:[function(_dereq_,module,exports){
|
||
|
module.exports = {
|
||
|
ArrayExpression: ['type', 'elements'],
|
||
|
ArrayPattern: ['type', 'elements'],
|
||
|
ArrowFunctionExpression: ['type', 'id', 'params', 'body', 'generator', 'expression', 'async'],
|
||
|
AssignmentExpression: ['type', 'operator', 'left', 'right'],
|
||
|
AssignmentPattern: ['type', 'left', 'right'],
|
||
|
AwaitExpression: ['type', 'argument'],
|
||
|
BinaryExpression: ['type', 'operator', 'left', 'right'],
|
||
|
BlockStatement: ['type', 'body'],
|
||
|
BreakStatement: ['type', 'label'],
|
||
|
CallExpression: ['type', 'callee', 'arguments'],
|
||
|
CatchClause: ['type', 'param', 'guard', 'body'],
|
||
|
ClassBody: ['type', 'body'],
|
||
|
ClassDeclaration: ['type', 'id', 'superClass', 'body'],
|
||
|
ClassExpression: ['type', 'id', 'superClass', 'body'],
|
||
|
ConditionalExpression: ['type', 'test', 'consequent', 'alternate'],
|
||
|
ContinueStatement: ['type', 'label'],
|
||
|
DebuggerStatement: ['type'],
|
||
|
DoWhileStatement: ['type', 'body', 'test'],
|
||
|
EmptyStatement: ['type'],
|
||
|
ExportAllDeclaration: ['type', 'source'],
|
||
|
ExportDefaultDeclaration: ['type', 'declaration'],
|
||
|
ExportNamedDeclaration: ['type', 'declaration', 'specifiers', 'source'],
|
||
|
ExportSpecifier: ['type', 'exported', 'local'],
|
||
|
ExpressionStatement: ['type', 'expression'],
|
||
|
ForInStatement: ['type', 'left', 'right', 'body'],
|
||
|
ForOfStatement: ['type', 'left', 'right', 'body', 'await'],
|
||
|
ForStatement: ['type', 'init', 'test', 'update', 'body'],
|
||
|
FunctionDeclaration: ['type', 'id', 'params', 'body', 'generator', 'async'],
|
||
|
FunctionExpression: ['type', 'id', 'params', 'body', 'generator', 'async'],
|
||
|
Identifier: ['type', 'name'],
|
||
|
IfStatement: ['type', 'test', 'consequent', 'alternate'],
|
||
|
ImportDeclaration: ['type', 'specifiers', 'source'],
|
||
|
ImportDefaultSpecifier: ['type', 'local'],
|
||
|
ImportNamespaceSpecifier: ['type', 'local'],
|
||
|
ImportSpecifier: ['type', 'imported', 'local'],
|
||
|
LabeledStatement: ['type', 'label', 'body'],
|
||
|
Literal: ['type', 'value', 'regex'],
|
||
|
LogicalExpression: ['type', 'operator', 'left', 'right'],
|
||
|
MemberExpression: ['type', 'object', 'property', 'computed'],
|
||
|
MetaProperty: ['type', 'meta', 'property'],
|
||
|
MethodDefinition: ['type', 'key', 'value', 'kind', 'computed', 'static'],
|
||
|
NewExpression: ['type', 'callee', 'arguments'],
|
||
|
ObjectExpression: ['type', 'properties'],
|
||
|
ObjectPattern: ['type', 'properties'],
|
||
|
Program: ['type', 'body', 'sourceType'],
|
||
|
Property: ['type', 'key', 'value', 'kind', 'method', 'shorthand', 'computed'],
|
||
|
RestElement: ['type', 'argument'],
|
||
|
ReturnStatement: ['type', 'argument'],
|
||
|
SequenceExpression: ['type', 'expressions'],
|
||
|
SpreadElement: ['type', 'argument'],
|
||
|
Super: ['type'],
|
||
|
SwitchCase: ['type', 'test', 'consequent'],
|
||
|
SwitchStatement: ['type', 'discriminant', 'cases', 'lexical'],
|
||
|
TaggedTemplateExpression: ['type', 'tag', 'quasi'],
|
||
|
TemplateElement: ['type', 'tail', 'value'],
|
||
|
TemplateLiteral: ['type', 'quasis', 'expressions'],
|
||
|
ThisExpression: ['type'],
|
||
|
ThrowStatement: ['type', 'argument'],
|
||
|
TryStatement: ['type', 'block', 'handler', 'finalizer'],
|
||
|
UnaryExpression: ['type', 'operator', 'prefix', 'argument'],
|
||
|
UpdateExpression: ['type', 'operator', 'argument', 'prefix'],
|
||
|
VariableDeclaration: ['type', 'declarations', 'kind'],
|
||
|
VariableDeclarator: ['type', 'id', 'init'],
|
||
|
WhileStatement: ['type', 'test', 'body'],
|
||
|
WithStatement: ['type', 'object', 'body'],
|
||
|
YieldExpression: ['type', 'argument', 'delegate']
|
||
|
};
|
||
|
|
||
|
},{}],103:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
|
||
|
var isArray = _dereq_('core-js/library/fn/array/is-array');
|
||
|
var objectKeys = _dereq_('core-js/library/fn/object/keys');
|
||
|
var indexOf = _dereq_('core-js/library/fn/array/index-of');
|
||
|
var Map = _dereq_('core-js/library/fn/map');
|
||
|
var reduce = _dereq_('core-js/library/fn/array/reduce');
|
||
|
|
||
|
module.exports = function cloneWithWhitelist (astWhiteList) {
|
||
|
var whitelist = reduce(objectKeys(astWhiteList), function (props, key) {
|
||
|
var propNames = astWhiteList[key];
|
||
|
var prepend = (indexOf(propNames, 'type') === -1) ? ['type'] : [];
|
||
|
props[key] = prepend.concat(propNames || []);
|
||
|
return props;
|
||
|
}, {});
|
||
|
|
||
|
function cloneNodeOrObject (obj, seen) {
|
||
|
var props = obj.type ? whitelist[obj.type] : null;
|
||
|
if (props) {
|
||
|
return cloneNode(obj, props, seen);
|
||
|
} else {
|
||
|
return cloneObject(obj, seen);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function cloneArray (ary, seen) {
|
||
|
var i = ary.length;
|
||
|
var clone = [];
|
||
|
while (i--) {
|
||
|
clone[i] = cloneOf(ary[i], seen);
|
||
|
}
|
||
|
return clone;
|
||
|
}
|
||
|
|
||
|
function cloneNode (node, props, seen) {
|
||
|
var i, len, key;
|
||
|
var clone = {};
|
||
|
for (i = 0, len = props.length; i < len; i += 1) {
|
||
|
key = props[i];
|
||
|
if (node.hasOwnProperty(key)) {
|
||
|
clone[key] = cloneOf(node[key], seen);
|
||
|
}
|
||
|
}
|
||
|
return clone;
|
||
|
}
|
||
|
|
||
|
function cloneObject (obj, seen) {
|
||
|
var props = objectKeys(obj);
|
||
|
var i, len, key, value;
|
||
|
var clone = {};
|
||
|
for (i = 0, len = props.length; i < len; i += 1) {
|
||
|
key = props[i];
|
||
|
value = obj[key];
|
||
|
if (seen.has(value)) {
|
||
|
continue;
|
||
|
}
|
||
|
clone[key] = cloneOf(value, seen);
|
||
|
}
|
||
|
return clone;
|
||
|
}
|
||
|
|
||
|
function cloneOf (val, seen) {
|
||
|
if (typeof val === 'object' && val !== null) {
|
||
|
seen.set(val, true);
|
||
|
if (val instanceof RegExp) {
|
||
|
return new RegExp(val);
|
||
|
} else if (isArray(val)) {
|
||
|
return cloneArray(val, seen);
|
||
|
} else {
|
||
|
return cloneNodeOrObject(val, seen);
|
||
|
}
|
||
|
} else {
|
||
|
return val;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function cloneRoot (obj) {
|
||
|
var seen = new Map();
|
||
|
seen.set(obj, true);
|
||
|
return cloneNodeOrObject(obj, seen);
|
||
|
}
|
||
|
|
||
|
return cloneRoot;
|
||
|
};
|
||
|
|
||
|
},{"core-js/library/fn/array/index-of":4,"core-js/library/fn/array/is-array":5,"core-js/library/fn/array/reduce":7,"core-js/library/fn/map":8,"core-js/library/fn/object/keys":10}],104:[function(_dereq_,module,exports){
|
||
|
'use strict';
|
||
|
|
||
|
var defaultProps = _dereq_('./ast-properties');
|
||
|
var objectKeys = _dereq_('core-js/library/fn/object/keys');
|
||
|
var assign = _dereq_('core-js/library/fn/object/assign');
|
||
|
|
||
|
module.exports = function createWhitelist (options) {
|
||
|
var opts = assign({}, options);
|
||
|
var typeName, i, len;
|
||
|
var keys = objectKeys(defaultProps);
|
||
|
var result = {};
|
||
|
for (i = 0, len = keys.length; i < len; i += 1) {
|
||
|
typeName = keys[i];
|
||
|
result[typeName] = defaultProps[typeName].concat(opts.extra || []);
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
},{"./ast-properties":102,"core-js/library/fn/object/assign":9,"core-js/library/fn/object/keys":10}],105:[function(_dereq_,module,exports){
|
||
|
/*
|
||
|
Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||
|
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||
|
|
||
|
Redistribution and use in source and binary forms, with or without
|
||
|
modification, are permitted provided that the following conditions are met:
|
||
|
|
||
|
* Redistributions of source code must retain the above copyright
|
||
|
notice, this list of conditions and the following disclaimer.
|
||
|
* Redistributions in binary form must reproduce the above copyright
|
||
|
notice, this list of conditions and the following disclaimer in the
|
||
|
documentation and/or other materials provided with the distribution.
|
||
|
|
||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
*/
|
||
|
/*jslint vars:false, bitwise:true*/
|
||
|
/*jshint indent:4*/
|
||
|
/*global exports:true*/
|
||
|
(function clone(exports) {
|
||
|
'use strict';
|
||
|
|
||
|
var Syntax,
|
||
|
isArray,
|
||
|
VisitorOption,
|
||
|
VisitorKeys,
|
||
|
objectCreate,
|
||
|
objectKeys,
|
||
|
BREAK,
|
||
|
SKIP,
|
||
|
REMOVE;
|
||
|
|
||
|
function ignoreJSHintError() { }
|
||
|
|
||
|
isArray = Array.isArray;
|
||
|
if (!isArray) {
|
||
|
isArray = function isArray(array) {
|
||
|
return Object.prototype.toString.call(array) === '[object Array]';
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function deepCopy(obj) {
|
||
|
var ret = {}, key, val;
|
||
|
for (key in obj) {
|
||
|
if (obj.hasOwnProperty(key)) {
|
||
|
val = obj[key];
|
||
|
if (typeof val === 'object' && val !== null) {
|
||
|
ret[key] = deepCopy(val);
|
||
|
} else {
|
||
|
ret[key] = val;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
function shallowCopy(obj) {
|
||
|
var ret = {}, key;
|
||
|
for (key in obj) {
|
||
|
if (obj.hasOwnProperty(key)) {
|
||
|
ret[key] = obj[key];
|
||
|
}
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
ignoreJSHintError(shallowCopy);
|
||
|
|
||
|
// based on LLVM libc++ upper_bound / lower_bound
|
||
|
// MIT License
|
||
|
|
||
|
function upperBound(array, func) {
|
||
|
var diff, len, i, current;
|
||
|
|
||
|
len = array.length;
|
||
|
i = 0;
|
||
|
|
||
|
while (len) {
|
||
|
diff = len >>> 1;
|
||
|
current = i + diff;
|
||
|
if (func(array[current])) {
|
||
|
len = diff;
|
||
|
} else {
|
||
|
i = current + 1;
|
||
|
len -= diff + 1;
|
||
|
}
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
function lowerBound(array, func) {
|
||
|
var diff, len, i, current;
|
||
|
|
||
|
len = array.length;
|
||
|
i = 0;
|
||
|
|
||
|
while (len) {
|
||
|
diff = len >>> 1;
|
||
|
current = i + diff;
|
||
|
if (func(array[current])) {
|
||
|
i = current + 1;
|
||
|
len -= diff + 1;
|
||
|
} else {
|
||
|
len = diff;
|
||
|
}
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
ignoreJSHintError(lowerBound);
|
||
|
|
||
|
objectCreate = Object.create || (function () {
|
||
|
function F() { }
|
||
|
|
||
|
return function (o) {
|
||
|
F.prototype = o;
|
||
|
return new F();
|
||
|
};
|
||
|
})();
|
||
|
|
||
|
objectKeys = Object.keys || function (o) {
|
||
|
var keys = [], key;
|
||
|
for (key in o) {
|
||
|
keys.push(key);
|
||
|
}
|
||
|
return keys;
|
||
|
};
|
||
|
|
||
|
function extend(to, from) {
|
||
|
var keys = objectKeys(from), key, i, len;
|
||
|
for (i = 0, len = keys.length; i < len; i += 1) {
|
||
|
key = keys[i];
|
||
|
to[key] = from[key];
|
||
|
}
|
||
|
return to;
|
||
|
}
|
||
|
|
||
|
Syntax = {
|
||
|
AssignmentExpression: 'AssignmentExpression',
|
||
|
AssignmentPattern: 'AssignmentPattern',
|
||
|
ArrayExpression: 'ArrayExpression',
|
||
|
ArrayPattern: 'ArrayPattern',
|
||
|
ArrowFunctionExpression: 'ArrowFunctionExpression',
|
||
|
AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
|
||
|
BlockStatement: 'BlockStatement',
|
||
|
BinaryExpression: 'BinaryExpression',
|
||
|
BreakStatement: 'BreakStatement',
|
||
|
CallExpression: 'CallExpression',
|
||
|
CatchClause: 'CatchClause',
|
||
|
ClassBody: 'ClassBody',
|
||
|
ClassDeclaration: 'ClassDeclaration',
|
||
|
ClassExpression: 'ClassExpression',
|
||
|
ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
|
||
|
ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
|
||
|
ConditionalExpression: 'ConditionalExpression',
|
||
|
ContinueStatement: 'ContinueStatement',
|
||
|
DebuggerStatement: 'DebuggerStatement',
|
||
|
DirectiveStatement: 'DirectiveStatement',
|
||
|
DoWhileStatement: 'DoWhileStatement',
|
||
|
EmptyStatement: 'EmptyStatement',
|
||
|
ExportAllDeclaration: 'ExportAllDeclaration',
|
||
|
ExportDefaultDeclaration: 'ExportDefaultDeclaration',
|
||
|
ExportNamedDeclaration: 'ExportNamedDeclaration',
|
||
|
ExportSpecifier: 'ExportSpecifier',
|
||
|
ExpressionStatement: 'ExpressionStatement',
|
||
|
ForStatement: 'ForStatement',
|
||
|
ForInStatement: 'ForInStatement',
|
||
|
ForOfStatement: 'ForOfStatement',
|
||
|
FunctionDeclaration: 'FunctionDeclaration',
|
||
|
FunctionExpression: 'FunctionExpression',
|
||
|
GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
|
||
|
Identifier: 'Identifier',
|
||
|
IfStatement: 'IfStatement',
|
||
|
ImportDeclaration: 'ImportDeclaration',
|
||
|
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
|
||
|
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
|
||
|
ImportSpecifier: 'ImportSpecifier',
|
||
|
Literal: 'Literal',
|
||
|
LabeledStatement: 'LabeledStatement',
|
||
|
LogicalExpression: 'LogicalExpression',
|
||
|
MemberExpression: 'MemberExpression',
|
||
|
MetaProperty: 'MetaProperty',
|
||
|
MethodDefinition: 'MethodDefinition',
|
||
|
ModuleSpecifier: 'ModuleSpecifier',
|
||
|
NewExpression: 'NewExpression',
|
||
|
ObjectExpression: 'ObjectExpression',
|
||
|
ObjectPattern: 'ObjectPattern',
|
||
|
Program: 'Program',
|
||
|
Property: 'Property',
|
||
|
RestElement: 'RestElement',
|
||
|
ReturnStatement: 'ReturnStatement',
|
||
|
SequenceExpression: 'SequenceExpression',
|
||
|
SpreadElement: 'SpreadElement',
|
||
|
Super: 'Super',
|
||
|
SwitchStatement: 'SwitchStatement',
|
||
|
SwitchCase: 'SwitchCase',
|
||
|
TaggedTemplateExpression: 'TaggedTemplateExpression',
|
||
|
TemplateElement: 'TemplateElement',
|
||
|
TemplateLiteral: 'TemplateLiteral',
|
||
|
ThisExpression: 'ThisExpression',
|
||
|
ThrowStatement: 'ThrowStatement',
|
||
|
TryStatement: 'TryStatement',
|
||
|
UnaryExpression: 'UnaryExpression',
|
||
|
UpdateExpression: 'UpdateExpression',
|
||
|
VariableDeclaration: 'VariableDeclaration',
|
||
|
VariableDeclarator: 'VariableDeclarator',
|
||
|
WhileStatement: 'WhileStatement',
|
||
|
WithStatement: 'WithStatement',
|
||
|
YieldExpression: 'YieldExpression'
|
||
|
};
|
||
|
|
||
|
VisitorKeys = {
|
||
|
AssignmentExpression: ['left', 'right'],
|
||
|
AssignmentPattern: ['left', 'right'],
|
||
|
ArrayExpression: ['elements'],
|
||
|
ArrayPattern: ['elements'],
|
||
|
ArrowFunctionExpression: ['params', 'body'],
|
||
|
AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
|
||
|
BlockStatement: ['body'],
|
||
|
BinaryExpression: ['left', 'right'],
|
||
|
BreakStatement: ['label'],
|
||
|
CallExpression: ['callee', 'arguments'],
|
||
|
CatchClause: ['param', 'body'],
|
||
|
ClassBody: ['body'],
|
||
|
ClassDeclaration: ['id', 'superClass', 'body'],
|
||
|
ClassExpression: ['id', 'superClass', 'body'],
|
||
|
ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
|
||
|
ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
|
||
|
ConditionalExpression: ['test', 'consequent', 'alternate'],
|
||
|
ContinueStatement: ['label'],
|
||
|
DebuggerStatement: [],
|
||
|
DirectiveStatement: [],
|
||
|
DoWhileStatement: ['body', 'test'],
|
||
|
EmptyStatement: [],
|
||
|
ExportAllDeclaration: ['source'],
|
||
|
ExportDefaultDeclaration: ['declaration'],
|
||
|
ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
|
||
|
ExportSpecifier: ['exported', 'local'],
|
||
|
ExpressionStatement: ['expression'],
|
||
|
ForStatement: ['init', 'test', 'update', 'body'],
|
||
|
ForInStatement: ['left', 'right', 'body'],
|
||
|
ForOfStatement: ['left', 'right', 'body'],
|
||
|
FunctionDeclaration: ['id', 'params', 'body'],
|
||
|
FunctionExpression: ['id', 'params', 'body'],
|
||
|
GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
|
||
|
Identifier: [],
|
||
|
IfStatement: ['test', 'consequent', 'alternate'],
|
||
|
ImportDeclaration: ['specifiers', 'source'],
|
||
|
ImportDefaultSpecifier: ['local'],
|
||
|
ImportNamespaceSpecifier: ['local'],
|
||
|
ImportSpecifier: ['imported', 'local'],
|
||
|
Literal: [],
|
||
|
LabeledStatement: ['label', 'body'],
|
||
|
LogicalExpression: ['left', 'right'],
|
||
|
MemberExpression: ['object', 'property'],
|
||
|
MetaProperty: ['meta', 'property'],
|
||
|
MethodDefinition: ['key', 'value'],
|
||
|
ModuleSpecifier: [],
|
||
|
NewExpression: ['callee', 'arguments'],
|
||
|
ObjectExpression: ['properties'],
|
||
|
ObjectPattern: ['properties'],
|
||
|
Program: ['body'],
|
||
|
Property: ['key', 'value'],
|
||
|
RestElement: [ 'argument' ],
|
||
|
ReturnStatement: ['argument'],
|
||
|
SequenceExpression: ['expressions'],
|
||
|
SpreadElement: ['argument'],
|
||
|
Super: [],
|
||
|
SwitchStatement: ['discriminant', 'cases'],
|
||
|
SwitchCase: ['test', 'consequent'],
|
||
|
TaggedTemplateExpression: ['tag', 'quasi'],
|
||
|
TemplateElement: [],
|
||
|
TemplateLiteral: ['quasis', 'expressions'],
|
||
|
ThisExpression: [],
|
||
|
ThrowStatement: ['argument'],
|
||
|
TryStatement: ['block', 'handler', 'finalizer'],
|
||
|
UnaryExpression: ['argument'],
|
||
|
UpdateExpression: ['argument'],
|
||
|
VariableDeclaration: ['declarations'],
|
||
|
VariableDeclarator: ['id', 'init'],
|
||
|
WhileStatement: ['test', 'body'],
|
||
|
WithStatement: ['object', 'body'],
|
||
|
YieldExpression: ['argument']
|
||
|
};
|
||
|
|
||
|
// unique id
|
||
|
BREAK = {};
|
||
|
SKIP = {};
|
||
|
REMOVE = {};
|
||
|
|
||
|
VisitorOption = {
|
||
|
Break: BREAK,
|
||
|
Skip: SKIP,
|
||
|
Remove: REMOVE
|
||
|
};
|
||
|
|
||
|
function Reference(parent, key) {
|
||
|
this.parent = parent;
|
||
|
this.key = key;
|
||
|
}
|
||
|
|
||
|
Reference.prototype.replace = function replace(node) {
|
||
|
this.parent[this.key] = node;
|
||
|
};
|
||
|
|
||
|
Reference.prototype.remove = function remove() {
|
||
|
if (isArray(this.parent)) {
|
||
|
this.parent.splice(this.key, 1);
|
||
|
return true;
|
||
|
} else {
|
||
|
this.replace(null);
|
||
|
return false;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
function Element(node, path, wrap, ref) {
|
||
|
this.node = node;
|
||
|
this.path = path;
|
||
|
this.wrap = wrap;
|
||
|
this.ref = ref;
|
||
|
}
|
||
|
|
||
|
function Controller() { }
|
||
|
|
||
|
// API:
|
||
|
// return property path array from root to current node
|
||
|
Controller.prototype.path = function path() {
|
||
|
var i, iz, j, jz, result, element;
|
||
|
|
||
|
function addToPath(result, path) {
|
||
|
if (isArray(path)) {
|
||
|
for (j = 0, jz = path.length; j < jz; ++j) {
|
||
|
result.push(path[j]);
|
||
|
}
|
||
|
} else {
|
||
|
result.push(path);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// root node
|
||
|
if (!this.__current.path) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
// first node is sentinel, second node is root element
|
||
|
result = [];
|
||
|
for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
|
||
|
element = this.__leavelist[i];
|
||
|
addToPath(result, element.path);
|
||
|
}
|
||
|
addToPath(result, this.__current.path);
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
// API:
|
||
|
// return type of current node
|
||
|
Controller.prototype.type = function () {
|
||
|
var node = this.current();
|
||
|
return node.type || this.__current.wrap;
|
||
|
};
|
||
|
|
||
|
// API:
|
||
|
// return array of parent elements
|
||
|
Controller.prototype.parents = function parents() {
|
||
|
var i, iz, result;
|
||
|
|
||
|
// first node is sentinel
|
||
|
result = [];
|
||
|
for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
|
||
|
result.push(this.__leavelist[i].node);
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
// API:
|
||
|
// return current node
|
||
|
Controller.prototype.current = function current() {
|
||
|
return this.__current.node;
|
||
|
};
|
||
|
|
||
|
Controller.prototype.__execute = function __execute(callback, element) {
|
||
|
var previous, result;
|
||
|
|
||
|
result = undefined;
|
||
|
|
||
|
previous = this.__current;
|
||
|
this.__current = element;
|
||
|
this.__state = null;
|
||
|
if (callback) {
|
||
|
result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
|
||
|
}
|
||
|
this.__current = previous;
|
||
|
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
// API:
|
||
|
// notify control skip / break
|
||
|
Controller.prototype.notify = function notify(flag) {
|
||
|
this.__state = flag;
|
||
|
};
|
||
|
|
||
|
// API:
|
||
|
// skip child nodes of current node
|
||
|
Controller.prototype.skip = function () {
|
||
|
this.notify(SKIP);
|
||
|
};
|
||
|
|
||
|
// API:
|
||
|
// break traversals
|
||
|
Controller.prototype['break'] = function () {
|
||
|
this.notify(BREAK);
|
||
|
};
|
||
|
|
||
|
// API:
|
||
|
// remove node
|
||
|
Controller.prototype.remove = function () {
|
||
|
this.notify(REMOVE);
|
||
|
};
|
||
|
|
||
|
Controller.prototype.__initialize = function(root, visitor) {
|
||
|
this.visitor = visitor;
|
||
|
this.root = root;
|
||
|
this.__worklist = [];
|
||
|
this.__leavelist = [];
|
||
|
this.__current = null;
|
||
|
this.__state = null;
|
||
|
this.__fallback = null;
|
||
|
if (visitor.fallback === 'iteration') {
|
||
|
this.__fallback = objectKeys;
|
||
|
} else if (typeof visitor.fallback === 'function') {
|
||
|
this.__fallback = visitor.fallback;
|
||
|
}
|
||
|
|
||
|
this.__keys = VisitorKeys;
|
||
|
if (visitor.keys) {
|
||
|
this.__keys = extend(objectCreate(this.__keys), visitor.keys);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
function isNode(node) {
|
||
|
if (node == null) {
|
||
|
return false;
|
||
|
}
|
||
|
return typeof node === 'object' && typeof node.type === 'string';
|
||
|
}
|
||
|
|
||
|
function isProperty(nodeType, key) {
|
||
|
return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
|
||
|
}
|
||
|
|
||
|
Controller.prototype.traverse = function traverse(root, visitor) {
|
||
|
var worklist,
|
||
|
leavelist,
|
||
|
element,
|
||
|
node,
|
||
|
nodeType,
|
||
|
ret,
|
||
|
key,
|
||
|
current,
|
||
|
current2,
|
||
|
candidates,
|
||
|
candidate,
|
||
|
sentinel;
|
||
|
|
||
|
this.__initialize(root, visitor);
|
||
|
|
||
|
sentinel = {};
|
||
|
|
||
|
// reference
|
||
|
worklist = this.__worklist;
|
||
|
leavelist = this.__leavelist;
|
||
|
|
||
|
// initialize
|
||
|
worklist.push(new Element(root, null, null, null));
|
||
|
leavelist.push(new Element(null, null, null, null));
|
||
|
|
||
|
while (worklist.length) {
|
||
|
element = worklist.pop();
|
||
|
|
||
|
if (element === sentinel) {
|
||
|
element = leavelist.pop();
|
||
|
|
||
|
ret = this.__execute(visitor.leave, element);
|
||
|
|
||
|
if (this.__state === BREAK || ret === BREAK) {
|
||
|
return;
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (element.node) {
|
||
|
|
||
|
ret = this.__execute(visitor.enter, element);
|
||
|
|
||
|
if (this.__state === BREAK || ret === BREAK) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
worklist.push(sentinel);
|
||
|
leavelist.push(element);
|
||
|
|
||
|
if (this.__state === SKIP || ret === SKIP) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
node = element.node;
|
||
|
nodeType = node.type || element.wrap;
|
||
|
candidates = this.__keys[nodeType];
|
||
|
if (!candidates) {
|
||
|
if (this.__fallback) {
|
||
|
candidates = this.__fallback(node);
|
||
|
} else {
|
||
|
throw new Error('Unknown node type ' + nodeType + '.');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
current = candidates.length;
|
||
|
while ((current -= 1) >= 0) {
|
||
|
key = candidates[current];
|
||
|
candidate = node[key];
|
||
|
if (!candidate) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (isArray(candidate)) {
|
||
|
current2 = candidate.length;
|
||
|
while ((current2 -= 1) >= 0) {
|
||
|
if (!candidate[current2]) {
|
||
|
continue;
|
||
|
}
|
||
|
if (isProperty(nodeType, candidates[current])) {
|
||
|
element = new Element(candidate[current2], [key, current2], 'Property', null);
|
||
|
} else if (isNode(candidate[current2])) {
|
||
|
element = new Element(candidate[current2], [key, current2], null, null);
|
||
|
} else {
|
||
|
continue;
|
||
|
}
|
||
|
worklist.push(element);
|
||
|
}
|
||
|
} else if (isNode(candidate)) {
|
||
|
worklist.push(new Element(candidate, key, null, null));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Controller.prototype.replace = function replace(root, visitor) {
|
||
|
var worklist,
|
||
|
leavelist,
|
||
|
node,
|
||
|
nodeType,
|
||
|
target,
|
||
|
element,
|
||
|
current,
|
||
|
current2,
|
||
|
candidates,
|
||
|
candidate,
|
||
|
sentinel,
|
||
|
outer,
|
||
|
key;
|
||
|
|
||
|
function removeElem(element) {
|
||
|
var i,
|
||
|
key,
|
||
|
nextElem,
|
||
|
parent;
|
||
|
|
||
|
if (element.ref.remove()) {
|
||
|
// When the reference is an element of an array.
|
||
|
key = element.ref.key;
|
||
|
parent = element.ref.parent;
|
||
|
|
||
|
// If removed from array, then decrease following items' keys.
|
||
|
i = worklist.length;
|
||
|
while (i--) {
|
||
|
nextElem = worklist[i];
|
||
|
if (nextElem.ref && nextElem.ref.parent === parent) {
|
||
|
if (nextElem.ref.key < key) {
|
||
|
break;
|
||
|
}
|
||
|
--nextElem.ref.key;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.__initialize(root, visitor);
|
||
|
|
||
|
sentinel = {};
|
||
|
|
||
|
// reference
|
||
|
worklist = this.__worklist;
|
||
|
leavelist = this.__leavelist;
|
||
|
|
||
|
// initialize
|
||
|
outer = {
|
||
|
root: root
|
||
|
};
|
||
|
element = new Element(root, null, null, new Reference(outer, 'root'));
|
||
|
worklist.push(element);
|
||
|
leavelist.push(element);
|
||
|
|
||
|
while (worklist.length) {
|
||
|
element = worklist.pop();
|
||
|
|
||
|
if (element === sentinel) {
|
||
|
element = leavelist.pop();
|
||
|
|
||
|
target = this.__execute(visitor.leave, element);
|
||
|
|
||
|
// node may be replaced with null,
|
||
|
// so distinguish between undefined and null in this place
|
||
|
if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
|
||
|
// replace
|
||
|
element.ref.replace(target);
|
||
|
}
|
||
|
|
||
|
if (this.__state === REMOVE || target === REMOVE) {
|
||
|
removeElem(element);
|
||
|
}
|
||
|
|
||
|
if (this.__state === BREAK || target === BREAK) {
|
||
|
return outer.root;
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
target = this.__execute(visitor.enter, element);
|
||
|
|
||
|
// node may be replaced with null,
|
||
|
// so distinguish between undefined and null in this place
|
||
|
if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
|
||
|
// replace
|
||
|
element.ref.replace(target);
|
||
|
element.node = target;
|
||
|
}
|
||
|
|
||
|
if (this.__state === REMOVE || target === REMOVE) {
|
||
|
removeElem(element);
|
||
|
element.node = null;
|
||
|
}
|
||
|
|
||
|
if (this.__state === BREAK || target === BREAK) {
|
||
|
return outer.root;
|
||
|
}
|
||
|
|
||
|
// node may be null
|
||
|
node = element.node;
|
||
|
if (!node) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
worklist.push(sentinel);
|
||
|
leavelist.push(element);
|
||
|
|
||
|
if (this.__state === SKIP || target === SKIP) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
nodeType = node.type || element.wrap;
|
||
|
candidates = this.__keys[nodeType];
|
||
|
if (!candidates) {
|
||
|
if (this.__fallback) {
|
||
|
candidates = this.__fallback(node);
|
||
|
} else {
|
||
|
throw new Error('Unknown node type ' + nodeType + '.');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
current = candidates.length;
|
||
|
while ((current -= 1) >= 0) {
|
||
|
key = candidates[current];
|
||
|
candidate = node[key];
|
||
|
if (!candidate) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (isArray(candidate)) {
|
||
|
current2 = candidate.length;
|
||
|
while ((current2 -= 1) >= 0) {
|
||
|
if (!candidate[current2]) {
|
||
|
continue;
|
||
|
}
|
||
|
if (isProperty(nodeType, candidates[current])) {
|
||
|
element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
|
||
|
} else if (isNode(candidate[current2])) {
|
||
|
element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
|
||
|
} else {
|
||
|
continue;
|
||
|
}
|
||
|
worklist.push(element);
|
||
|
}
|
||
|
} else if (isNode(candidate)) {
|
||
|
worklist.push(new Element(candidate, key, null, new Reference(node, key)));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return outer.root;
|
||
|
};
|
||
|
|
||
|
function traverse(root, visitor) {
|
||
|
var controller = new Controller();
|
||
|
return controller.traverse(root, visitor);
|
||
|
}
|
||
|
|
||
|
function replace(root, visitor) {
|
||
|
var controller = new Controller();
|
||
|
return controller.replace(root, visitor);
|
||
|
}
|
||
|
|
||
|
function extendCommentRange(comment, tokens) {
|
||
|
var target;
|
||
|
|
||
|
target = upperBound(tokens, function search(token) {
|
||
|
return token.range[0] > comment.range[0];
|
||
|
});
|
||
|
|
||
|
comment.extendedRange = [comment.range[0], comment.range[1]];
|
||
|
|
||
|
if (target !== tokens.length) {
|
||
|
comment.extendedRange[1] = tokens[target].range[0];
|
||
|
}
|
||
|
|
||
|
target -= 1;
|
||
|
if (target >= 0) {
|
||
|
comment.extendedRange[0] = tokens[target].range[1];
|
||
|
}
|
||
|
|
||
|
return comment;
|
||
|
}
|
||
|
|
||
|
function attachComments(tree, providedComments, tokens) {
|
||
|
// At first, we should calculate extended comment ranges.
|
||
|
var comments = [], comment, len, i, cursor;
|
||
|
|
||
|
if (!tree.range) {
|
||
|
throw new Error('attachComments needs range information');
|
||
|
}
|
||
|
|
||
|
// tokens array is empty, we attach comments to tree as 'leadingComments'
|
||
|
if (!tokens.length) {
|
||
|
if (providedComments.length) {
|
||
|
for (i = 0, len = providedComments.length; i < len; i += 1) {
|
||
|
comment = deepCopy(providedComments[i]);
|
||
|
comment.extendedRange = [0, tree.range[0]];
|
||
|
comments.push(comment);
|
||
|
}
|
||
|
tree.leadingComments = comments;
|
||
|
}
|
||
|
return tree;
|
||
|
}
|
||
|
|
||
|
for (i = 0, len = providedComments.length; i < len; i += 1) {
|
||
|
comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
|
||
|
}
|
||
|
|
||
|
// This is based on John Freeman's implementation.
|
||
|
cursor = 0;
|
||
|
traverse(tree, {
|
||
|
enter: function (node) {
|
||
|
var comment;
|
||
|
|
||
|
while (cursor < comments.length) {
|
||
|
comment = comments[cursor];
|
||
|
if (comment.extendedRange[1] > node.range[0]) {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (comment.extendedRange[1] === node.range[0]) {
|
||
|
if (!node.leadingComments) {
|
||
|
node.leadingComments = [];
|
||
|
}
|
||
|
node.leadingComments.push(comment);
|
||
|
comments.splice(cursor, 1);
|
||
|
} else {
|
||
|
cursor += 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// already out of owned node
|
||
|
if (cursor === comments.length) {
|
||
|
return VisitorOption.Break;
|
||
|
}
|
||
|
|
||
|
if (comments[cursor].extendedRange[0] > node.range[1]) {
|
||
|
return VisitorOption.Skip;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
cursor = 0;
|
||
|
traverse(tree, {
|
||
|
leave: function (node) {
|
||
|
var comment;
|
||
|
|
||
|
while (cursor < comments.length) {
|
||
|
comment = comments[cursor];
|
||
|
if (node.range[1] < comment.extendedRange[0]) {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (node.range[1] === comment.extendedRange[0]) {
|
||
|
if (!node.trailingComments) {
|
||
|
node.trailingComments = [];
|
||
|
}
|
||
|
node.trailingComments.push(comment);
|
||
|
comments.splice(cursor, 1);
|
||
|
} else {
|
||
|
cursor += 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// already out of owned node
|
||
|
if (cursor === comments.length) {
|
||
|
return VisitorOption.Break;
|
||
|
}
|
||
|
|
||
|
if (comments[cursor].extendedRange[0] > node.range[1]) {
|
||
|
return VisitorOption.Skip;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return tree;
|
||
|
}
|
||
|
|
||
|
exports.version = _dereq_('./package.json').version;
|
||
|
exports.Syntax = Syntax;
|
||
|
exports.traverse = traverse;
|
||
|
exports.replace = replace;
|
||
|
exports.attachComments = attachComments;
|
||
|
exports.VisitorKeys = VisitorKeys;
|
||
|
exports.VisitorOption = VisitorOption;
|
||
|
exports.Controller = Controller;
|
||
|
exports.cloneEnvironment = function () { return clone({}); };
|
||
|
|
||
|
return exports;
|
||
|
}(exports));
|
||
|
/* vim: set sw=4 ts=4 et tw=80 : */
|
||
|
|
||
|
},{"./package.json":106}],106:[function(_dereq_,module,exports){
|
||
|
module.exports={"name":"estraverse","version":"4.2.0"}
|
||
|
},{}]},{},[1])(1)
|
||
|
});
|
||
|
|