6to5-core
Advanced tools
Comparing version 3.5.3 to 3.6.0
@@ -40,4 +40,9 @@ var outputFileSync = require("output-file-sync"); | ||
_.each(util.readdirFilter(dirname), function (filename) { | ||
write(path.join(dirname, filename), filename); | ||
_.each(util.readdir(dirname), function (filename) { | ||
var src = path.join(dirname, filename); | ||
if (util.canCompile(filename)) { | ||
write(src, filename); | ||
} else { | ||
outputFileSync(path.join(commander.outDir, filename), fs.readFileSync(src)); | ||
} | ||
}); | ||
@@ -44,0 +49,0 @@ } else { |
@@ -15,2 +15,6 @@ var readdir = require("fs-readdir-recursive"); | ||
exports.readdir = readdir; | ||
exports.canCompile = util.canCompile; | ||
exports.addSourceMappingUrl = function (code, loc) { | ||
@@ -17,0 +21,0 @@ return code + "\n//# sourceMappingURL=" + path.basename(loc); |
@@ -1,2 +0,2 @@ | ||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){(function(global){"use strict";if(global._6to5Polyfill){throw new Error("only one instance of 6to5/polyfill is allowed")}global._6to5Polyfill=true;require("core-js/shim");require("regenerator-6to5/runtime")}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"core-js/shim":2,"regenerator-6to5/runtime":3}],2:[function(require,module,exports){!function(global,framework,undefined){"use strict";var OBJECT="Object",FUNCTION="Function",ARRAY="Array",STRING="String",NUMBER="Number",REGEXP="RegExp",DATE="Date",MAP="Map",SET="Set",WEAKMAP="WeakMap",WEAKSET="WeakSet",SYMBOL="Symbol",PROMISE="Promise",MATH="Math",ARGUMENTS="Arguments",PROTOTYPE="prototype",CONSTRUCTOR="constructor",TO_STRING="toString",TO_STRING_TAG=TO_STRING+"Tag",TO_LOCALE="toLocaleString",HAS_OWN="hasOwnProperty",FOR_EACH="forEach",ITERATOR="iterator",FF_ITERATOR="@@"+ITERATOR,PROCESS="process",CREATE_ELEMENT="createElement",Function=global[FUNCTION],Object=global[OBJECT],Array=global[ARRAY],String=global[STRING],Number=global[NUMBER],RegExp=global[REGEXP],Date=global[DATE],Map=global[MAP],Set=global[SET],WeakMap=global[WEAKMAP],WeakSet=global[WEAKSET],Symbol=global[SYMBOL],Math=global[MATH],TypeError=global.TypeError,setTimeout=global.setTimeout,setImmediate=global.setImmediate,clearImmediate=global.clearImmediate,process=global[PROCESS],nextTick=process&&process.nextTick,document=global.document,html=document&&document.documentElement,navigator=global.navigator,define=global.define,ArrayProto=Array[PROTOTYPE],ObjectProto=Object[PROTOTYPE],FunctionProto=Function[PROTOTYPE],Infinity=1/0,DOT=".";function isObject(it){return it!=null&&(typeof it=="object"||typeof it=="function")}function isFunction(it){return typeof it=="function"}var isNative=ctx(/./.test,/\[native code\]\s*\}\s*$/,1);var buildIn={Undefined:1,Null:1,Array:1,String:1,Arguments:1,Function:1,Error:1,Boolean:1,Number:1,Date:1,RegExp:1},toString=ObjectProto[TO_STRING];function setToStringTag(it,tag,stat){if(it&&!has(it=stat?it:it[PROTOTYPE],SYMBOL_TAG))hidden(it,SYMBOL_TAG,tag)}function cof(it){return it==undefined?it===undefined?"Undefined":"Null":toString.call(it).slice(8,-1)}function classof(it){var klass=cof(it),tag;return klass==OBJECT&&(tag=it[SYMBOL_TAG])?has(buildIn,tag)?"~"+tag:tag:klass}var call=FunctionProto.call,apply=FunctionProto.apply,REFERENCE_GET;function part(){var fn=assertFunction(this),length=arguments.length,args=Array(length),i=0,_=path._,holder=false;while(length>i)if((args[i]=arguments[i++])===_)holder=true;return function(){var that=this,_length=arguments.length,i=0,j=0,_args;if(!holder&&!_length)return invoke(fn,args,that);_args=args.slice();if(holder)for(;length>i;i++)if(_args[i]===_)_args[i]=arguments[j++];while(_length>j)_args.push(arguments[j++]);return invoke(fn,_args,that)}}function ctx(fn,that,length){assertFunction(fn);if(~length&&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(){return fn.apply(that,arguments)}}function invoke(fn,args,that){var un=that===undefined;switch(args.length|0){case 0:return un?fn():fn.call(that);case 1:return un?fn(args[0]):fn.call(that,args[0]);case 2:return un?fn(args[0],args[1]):fn.call(that,args[0],args[1]);case 3:return un?fn(args[0],args[1],args[2]):fn.call(that,args[0],args[1],args[2]);case 4:return un?fn(args[0],args[1],args[2],args[3]):fn.call(that,args[0],args[1],args[2],args[3]);case 5:return un?fn(args[0],args[1],args[2],args[3],args[4]):fn.call(that,args[0],args[1],args[2],args[3],args[4])}return fn.apply(that,args)}function construct(target,argumentsList){var proto=assertFunction(arguments.length<3?target:arguments[2])[PROTOTYPE],instance=create(isObject(proto)?proto:ObjectProto),result=apply.call(target,instance,argumentsList);return isObject(result)?result:instance}var create=Object.create,getPrototypeOf=Object.getPrototypeOf,setPrototypeOf=Object.setPrototypeOf,defineProperty=Object.defineProperty,defineProperties=Object.defineProperties,getOwnDescriptor=Object.getOwnPropertyDescriptor,getKeys=Object.keys,getNames=Object.getOwnPropertyNames,getSymbols=Object.getOwnPropertySymbols,isFrozen=Object.isFrozen,has=ctx(call,ObjectProto[HAS_OWN],2),ES5Object=Object,Dict;function toObject(it){return ES5Object(assertDefined(it))}function returnIt(it){return it}function returnThis(){return this}function get(object,key){if(has(object,key))return object[key]}function ownKeys(it){assertObject(it);return getSymbols?getNames(it).concat(getSymbols(it)):getNames(it)}var assign=Object.assign||function(target,source){var T=Object(assertDefined(target)),l=arguments.length,i=1;while(l>i){var S=ES5Object(arguments[i++]),keys=getKeys(S),length=keys.length,j=0,key;while(length>j)T[key=keys[j++]]=S[key]}return T};function keyOf(object,el){var O=toObject(object),keys=getKeys(O),length=keys.length,index=0,key;while(length>index)if(O[key=keys[index++]]===el)return key}function array(it){return String(it).split(",")}var push=ArrayProto.push,unshift=ArrayProto.unshift,slice=ArrayProto.slice,splice=ArrayProto.splice,indexOf=ArrayProto.indexOf,forEach=ArrayProto[FOR_EACH];function createArrayMethod(type){var isMap=type==1,isFilter=type==2,isSome=type==3,isEvery=type==4,isFindIndex=type==6,noholes=type==5||isFindIndex;return function(callbackfn){var O=Object(assertDefined(this)),that=arguments[1],self=ES5Object(O),f=ctx(callbackfn,that,3),length=toLength(self.length),index=0,result=isMap?Array(length):isFilter?[]:undefined,val,res;for(;length>index;index++)if(noholes||index in self){val=self[index];res=f(val,index,O);if(type){if(isMap)result[index]=res;else if(res)switch(type){case 3:return true;case 5:return val;case 6:return index;case 2:result.push(val)}else if(isEvery)return false}}return isFindIndex?-1:isSome||isEvery?isEvery:result}}function createArrayContains(isContains){return function(el){var O=toObject(this),length=toLength(O.length),index=toIndex(arguments[1],length);if(isContains&&el!=el){for(;length>index;index++)if(sameNaN(O[index]))return isContains||index}else for(;length>index;index++)if(isContains||index in O){if(O[index]===el)return isContains||index}return!isContains&&-1}}function generic(A,B){return typeof A=="function"?A:B}var MAX_SAFE_INTEGER=9007199254740991,ceil=Math.ceil,floor=Math.floor,max=Math.max,min=Math.min,random=Math.random,trunc=Math.trunc||function(it){return(it>0?floor:ceil)(it)};function sameNaN(number){return number!=number}function toInteger(it){return isNaN(it)?0:trunc(it)}function toLength(it){return it>0?min(toInteger(it),MAX_SAFE_INTEGER):0}function toIndex(index,length){var index=toInteger(index);return index<0?max(index+length,0):min(index,length)}function createReplacer(regExp,replace,isStatic){var replacer=isObject(replace)?function(part){return replace[part]}:replace;return function(it){return String(isStatic?it:this).replace(regExp,replacer)}}function createPointAt(toString){return function(pos){var s=String(assertDefined(this)),i=toInteger(pos),l=s.length,a,b;if(i<0||i>=l)return toString?"":undefined;a=s.charCodeAt(i);return a<55296||a>56319||i+1===l||(b=s.charCodeAt(i+1))<56320||b>57343?toString?s.charAt(i):a:toString?s.slice(i,i+2):(a-55296<<10)+(b-56320)+65536}}var REDUCE_ERROR="Reduce of empty object with no initial value";function assert(condition,msg1,msg2){if(!condition)throw TypeError(msg2?msg1+msg2:msg1)}function assertDefined(it){if(it==undefined)throw TypeError("Function called on null or undefined");return it}function assertFunction(it){assert(isFunction(it),it," is not a function!");return it}function assertObject(it){assert(isObject(it),it," is not an object!");return it}function assertInstance(it,Constructor,name){assert(it instanceof Constructor,name,": use the 'new' operator!")}function descriptor(bitmap,value){return{enumerable:!(bitmap&1),configurable:!(bitmap&2),writable:!(bitmap&4),value:value}}function simpleSet(object,key,value){object[key]=value;return object}function createDefiner(bitmap){return DESC?function(object,key,value){return defineProperty(object,key,descriptor(bitmap,value))}:simpleSet}function uid(key){return SYMBOL+"("+key+")_"+(++sid+random())[TO_STRING](36)}function getWellKnownSymbol(name,setter){return Symbol&&Symbol[name]||(setter?Symbol:safeSymbol)(SYMBOL+DOT+name)}var DESC=!!function(){try{return defineProperty({},DOT,ObjectProto)}catch(e){}}(),sid=0,hidden=createDefiner(1),set=Symbol?simpleSet:hidden,safeSymbol=Symbol||uid;function assignHidden(target,src){for(var key in src)hidden(target,key,src[key]);return target}var SYMBOL_UNSCOPABLES=getWellKnownSymbol("unscopables"),ArrayUnscopables=ArrayProto[SYMBOL_UNSCOPABLES]||{},SYMBOL_SPECIES=getWellKnownSymbol("species");function setSpecies(C){if(framework||!isNative(C))defineProperty(C,SYMBOL_SPECIES,{configurable:true,get:returnThis})}var SYMBOL_ITERATOR=getWellKnownSymbol(ITERATOR),SYMBOL_TAG=getWellKnownSymbol(TO_STRING_TAG),SUPPORT_FF_ITER=FF_ITERATOR in ArrayProto,ITER=safeSymbol("iter"),KEY=1,VALUE=2,Iterators={},IteratorPrototype={},NATIVE_ITERATORS=SYMBOL_ITERATOR in ArrayProto,BUGGY_ITERATORS="keys"in ArrayProto&&!("next"in[].keys());setIterator(IteratorPrototype,returnThis);function setIterator(O,value){hidden(O,SYMBOL_ITERATOR,value);SUPPORT_FF_ITER&&hidden(O,FF_ITERATOR,value)}function createIterator(Constructor,NAME,next,proto){Constructor[PROTOTYPE]=create(proto||IteratorPrototype,{next:descriptor(1,next)});setToStringTag(Constructor,NAME+" Iterator")}function defineIterator(Constructor,NAME,value,DEFAULT){var proto=Constructor[PROTOTYPE],iter=get(proto,SYMBOL_ITERATOR)||get(proto,FF_ITERATOR)||DEFAULT&&get(proto,DEFAULT)||value;if(framework){setIterator(proto,iter);if(iter!==value){var iterProto=getPrototypeOf(iter.call(new Constructor));setToStringTag(iterProto,NAME+" Iterator",true);has(proto,FF_ITERATOR)&&setIterator(iterProto,returnThis)}}Iterators[NAME]=iter;Iterators[NAME+" Iterator"]=returnThis;return iter}function defineStdIterators(Base,NAME,Constructor,next,DEFAULT,IS_SET){function createIter(kind){return function(){return new Constructor(this,kind)}}createIterator(Constructor,NAME,next);var entries=createIter(KEY+VALUE),values=createIter(VALUE);if(DEFAULT==VALUE)values=defineIterator(Base,NAME,values,"values");else entries=defineIterator(Base,NAME,entries,"entries");if(DEFAULT){$define(PROTO+FORCED*BUGGY_ITERATORS,NAME,{entries:entries,keys:IS_SET?values:createIter(KEY),values:values})}}function iterResult(done,value){return{value:value,done:!!done}}function isIterable(it){var O=Object(it),Symbol=global[SYMBOL],hasExt=(Symbol&&Symbol[ITERATOR]||FF_ITERATOR)in O;return hasExt||SYMBOL_ITERATOR in O||has(Iterators,classof(O))}function getIterator(it){var Symbol=global[SYMBOL],ext=it[Symbol&&Symbol[ITERATOR]||FF_ITERATOR],getIter=ext||it[SYMBOL_ITERATOR]||Iterators[classof(it)];return assertObject(getIter.call(it))}function stepCall(fn,value,entries){return entries?invoke(fn,value):fn(value)}function forOf(iterable,entries,fn,that){var iterator=getIterator(iterable),f=ctx(fn,that,entries?2:1),step;while(!(step=iterator.next()).done)if(stepCall(f,step.value,entries)===false)return}var NODE=cof(process)==PROCESS,core={},path=framework?global:core,old=global.core,exportGlobal,FORCED=1,GLOBAL=2,STATIC=4,PROTO=8,BIND=16,WRAP=32;function $define(type,name,source){var key,own,out,exp,isGlobal=type&GLOBAL,target=isGlobal?global:type&STATIC?global[name]:(global[name]||ObjectProto)[PROTOTYPE],exports=isGlobal?core:core[name]||(core[name]={});if(isGlobal)source=name;for(key in source){own=!(type&FORCED)&&target&&key in target&&(!isFunction(target[key])||isNative(target[key]));out=(own?target:source)[key];if(type&BIND&&own)exp=ctx(out,global);else if(type&WRAP&&!framework&&target[key]==out){exp=function(param){return this instanceof out?new out(param):out(param)};exp[PROTOTYPE]=out[PROTOTYPE]}else exp=type&PROTO&&isFunction(out)?ctx(call,out):out;if(exports[key]!=out)hidden(exports,key,exp);if(framework&&target&&!own){if(isGlobal)target[key]=out;else delete target[key]&&hidden(target,key,out)}}}if(typeof module!="undefined"&&module.exports)module.exports=core;else if(isFunction(define)&&define.amd)define(function(){return core});else exportGlobal=true;if(exportGlobal||framework){core.noConflict=function(){global.core=old;return core};global.core=core}$define(GLOBAL+FORCED,{global:global});!function(TAG,SymbolRegistry,AllSymbols,setter){if(!isNative(Symbol)){Symbol=function(description){assert(!(this instanceof Symbol),SYMBOL+" is not a "+CONSTRUCTOR);var tag=uid(description);AllSymbols[tag]=true;DESC&&setter&&defineProperty(ObjectProto,tag,{configurable:true,set:function(value){hidden(this,tag,value)}});return set(create(Symbol[PROTOTYPE]),TAG,tag)};hidden(Symbol[PROTOTYPE],TO_STRING,function(){return this[TAG]})}$define(GLOBAL+WRAP,{Symbol:Symbol});var symbolStatics={"for":function(key){return has(SymbolRegistry,key+="")?SymbolRegistry[key]:SymbolRegistry[key]=Symbol(key)},iterator:SYMBOL_ITERATOR,keyFor:part.call(keyOf,SymbolRegistry),species:SYMBOL_SPECIES,toStringTag:SYMBOL_TAG=getWellKnownSymbol(TO_STRING_TAG,true),unscopables:SYMBOL_UNSCOPABLES,pure:safeSymbol,set:set,useSetter:function(){setter=true},useSimple:function(){setter=false}};forEach.call(array("hasInstance,isConcatSpreadable,match,replace,search,split,toPrimitive"),function(it){symbolStatics[it]=getWellKnownSymbol(it)});$define(STATIC,SYMBOL,symbolStatics);setToStringTag(Symbol,SYMBOL);$define(STATIC+FORCED*!isNative(Symbol),OBJECT,{getOwnPropertyNames:function(it){var names=getNames(toObject(it)),result=[],key,i=0;while(names.length>i)has(AllSymbols,key=names[i++])||result.push(key);return result},getOwnPropertySymbols:function(it){var names=getNames(toObject(it)),result=[],key,i=0;while(names.length>i)has(AllSymbols,key=names[i++])&&result.push(key);return result}})}(safeSymbol("tag"),{},{},true);!function(RegExpProto,isFinite,tmp,NAME){var RangeError=global.RangeError,isInteger=Number.isInteger||function(it){return!isObject(it)&&isFinite(it)&&floor(it)===it},sign=Math.sign||function sign(x){return(x=+x)==0||x!=x?x:x<0?-1:1},E=Math.E,pow=Math.pow,abs=Math.abs,exp=Math.exp,log=Math.log,sqrt=Math.sqrt,fcc=String.fromCharCode,at=createPointAt(true);var objectStatic={assign:assign,is:function(x,y){return x===y?x!==0||1/x===1/y:x!=x&&y!=y}};"__proto__"in ObjectProto&&function(buggy,set){try{set=ctx(call,getOwnDescriptor(ObjectProto,"__proto__").set,2);set({},ArrayProto)}catch(e){buggy=true}objectStatic.setPrototypeOf=setPrototypeOf=setPrototypeOf||function(O,proto){assertObject(O);assert(proto===null||isObject(proto),proto,": can't set as prototype!");if(buggy)O.__proto__=proto;else set(O,proto);return O}}();$define(STATIC,OBJECT,objectStatic);function asinh(x){return!isFinite(x=+x)||x==0?x:x<0?-asinh(-x):log(x+sqrt(x*x+1))}function expm1(x){return(x=+x)==0?x:x>-1e-6&&x<1e-6?x+x*x/2:exp(x)-1}$define(STATIC,NUMBER,{EPSILON:pow(2,-52),isFinite:function(it){return typeof it=="number"&&isFinite(it)},isInteger:isInteger,isNaN:sameNaN,isSafeInteger:function(number){return isInteger(number)&&abs(number)<=MAX_SAFE_INTEGER},MAX_SAFE_INTEGER:MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:-MAX_SAFE_INTEGER,parseFloat:parseFloat,parseInt:parseInt});$define(STATIC,MATH,{acosh:function(x){return(x=+x)<1?NaN:isFinite(x)?log(x/E+sqrt(x+1)*sqrt(x-1)/E)+1:x},asinh:asinh,atanh:function(x){return(x=+x)==0?x:log((1+x)/(1-x))/2},cbrt:function(x){return sign(x=+x)*pow(abs(x),1/3)},clz32:function(x){return(x>>>=0)?32-x[TO_STRING](2).length:32},cosh:function(x){return(exp(x=+x)+exp(-x))/2},expm1:expm1,fround:function(x){return new Float32Array([x])[0]},hypot:function(value1,value2){var sum=0,len1=arguments.length,len2=len1,args=Array(len1),larg=-Infinity,arg;while(len1--){arg=args[len1]=+arguments[len1];if(arg==Infinity||arg==-Infinity)return Infinity;if(arg>larg)larg=arg}larg=arg||1;while(len2--)sum+=pow(args[len2]/larg,2);return larg*sqrt(sum)},imul:function(x,y){var UInt16=65535,xn=+x,yn=+y,xl=UInt16&xn,yl=UInt16&yn;return 0|xl*yl+((UInt16&xn>>>16)*yl+xl*(UInt16&yn>>>16)<<16>>>0)},log1p:function(x){return(x=+x)>-1e-8&&x<1e-8?x-x*x/2:log(1+x)},log10:function(x){return log(x)/Math.LN10},log2:function(x){return log(x)/Math.LN2},sign:sign,sinh:function(x){return abs(x=+x)<1?(expm1(x)-expm1(-x))/2:(exp(x-1)-exp(-x-1))*(E/2)},tanh:function(x){var a=expm1(x=+x),b=expm1(-x);return a==Infinity?1:b==Infinity?-1:(a-b)/(exp(x)+exp(-x))},trunc:trunc});setToStringTag(Math,MATH,true);function assertNotRegExp(it){if(cof(it)==REGEXP)throw TypeError()}$define(STATIC,STRING,{fromCodePoint:function(x){var res=[],len=arguments.length,i=0,code;while(len>i){code=+arguments[i++];if(toIndex(code,1114111)!==code)throw RangeError(code+" is not a valid code point");res.push(code<65536?fcc(code):fcc(((code-=65536)>>10)+55296,code%1024+56320))}return res.join("")},raw:function(callSite){var raw=toObject(callSite.raw),len=toLength(raw.length),sln=arguments.length,res=[],i=0;while(len>i){res.push(String(raw[i++]));if(i<sln)res.push(String(arguments[i]))}return res.join("")}});$define(PROTO,STRING,{codePointAt:createPointAt(false),endsWith:function(searchString){assertNotRegExp(searchString);var that=String(assertDefined(this)),endPosition=arguments[1],len=toLength(that.length),end=endPosition===undefined?len:min(toLength(endPosition),len);searchString+="";return that.slice(end-searchString.length,end)===searchString},includes:function(searchString){assertNotRegExp(searchString);return!!~String(assertDefined(this)).indexOf(searchString,arguments[1])},repeat:function(count){var str=String(assertDefined(this)),res="",n=toInteger(count);if(0>n||n==Infinity)throw RangeError("Count can't be negative");for(;n>0;(n>>>=1)&&(str+=str))if(n&1)res+=str;return res},startsWith:function(searchString){assertNotRegExp(searchString);var that=String(assertDefined(this)),index=toLength(min(arguments[1],that.length));searchString+="";return that.slice(index,index+searchString.length)===searchString}});defineStdIterators(String,STRING,function(iterated){set(this,ITER,{o:String(iterated),i:0})},function(){var iter=this[ITER],O=iter.o,index=iter.i,point;if(index>=O.length)return iterResult(1);point=at.call(O,index);iter.i+=point.length;return iterResult(0,point)});$define(STATIC,ARRAY,{from:function(arrayLike){var O=Object(assertDefined(arrayLike)),result=new(generic(this,Array)),mapfn=arguments[1],that=arguments[2],mapping=mapfn!==undefined,f=mapping?ctx(mapfn,that,2):undefined,index=0,length;if(isIterable(O))for(var iter=getIterator(O),step;!(step=iter.next()).done;index++){result[index]=mapping?f(step.value,index):step.value}else for(length=toLength(O.length);length>index;index++){result[index]=mapping?f(O[index],index):O[index]}result.length=index;return result},of:function(){var index=0,length=arguments.length,result=new(generic(this,Array))(length);while(length>index)result[index]=arguments[index++];result.length=length;return result}});$define(PROTO,ARRAY,{copyWithin:function(target,start){var O=Object(assertDefined(this)),len=toLength(O.length),to=toIndex(target,len),from=toIndex(start,len),end=arguments[2],fin=end===undefined?len:toIndex(end,len),count=min(fin-from,len-to),inc=1;if(from<to&&to<from+count){inc=-1;from=from+count-1;to=to+count-1}while(count-->0){if(from in O)O[to]=O[from];else delete O[to];to+=inc;from+=inc}return O},fill:function(value){var O=Object(assertDefined(this)),length=toLength(O.length),index=toIndex(arguments[1],length),end=arguments[2],endPos=end===undefined?length:toIndex(end,length);while(endPos>index)O[index++]=value;return O},find:createArrayMethod(5),findIndex:createArrayMethod(6)});defineStdIterators(Array,ARRAY,function(iterated,kind){set(this,ITER,{o:toObject(iterated),i:0,k:kind})},function(){var iter=this[ITER],O=iter.o,kind=iter.k,index=iter.i++;if(!O||index>=O.length)return iter.o=undefined,iterResult(1);if(kind==KEY)return iterResult(0,index);if(kind==VALUE)return iterResult(0,O[index]);return iterResult(0,[index,O[index]])},VALUE);Iterators[ARGUMENTS]=Iterators[ARRAY];setToStringTag(global.JSON,"JSON",true);function wrapObjectMethod(key,MODE){var fn=Object[key],exp=core[OBJECT][key],f=0,o={};if(!exp||isNative(exp)){o[key]=MODE==1?function(it){return isObject(it)?fn(it):it}:MODE==2?function(it){return isObject(it)?fn(it):true}:MODE==3?function(it){return isObject(it)?fn(it):false}:MODE==4?function(it,key){return fn(toObject(it),key)}:function(it){return fn(toObject(it))};try{fn(DOT)}catch(e){f=1}$define(STATIC+FORCED*f,OBJECT,o)}}wrapObjectMethod("freeze",1);wrapObjectMethod("seal",1);wrapObjectMethod("preventExtensions",1);wrapObjectMethod("isFrozen",2);wrapObjectMethod("isSealed",2);wrapObjectMethod("isExtensible",3);wrapObjectMethod("getOwnPropertyDescriptor",4);wrapObjectMethod("getPrototypeOf");wrapObjectMethod("keys");wrapObjectMethod("getOwnPropertyNames");if(framework){tmp[SYMBOL_TAG]=DOT;if(cof(tmp)!=DOT)hidden(ObjectProto,TO_STRING,function(){return"[object "+classof(this)+"]"});NAME in FunctionProto||defineProperty(FunctionProto,NAME,{configurable:true,get:function(){var match=String(this).match(/^\s*function ([^ (]*)/),name=match?match[1]:"";has(this,NAME)||defineProperty(this,NAME,descriptor(5,name));return name},set:function(value){has(this,NAME)||defineProperty(this,NAME,descriptor(0,value))}});if(DESC&&!function(){try{return RegExp(/a/g,"i")=="/a/i"}catch(e){}}()){var _RegExp=RegExp;RegExp=function RegExp(pattern,flags){return new _RegExp(cof(pattern)==REGEXP&&flags!==undefined?pattern.source:pattern,flags)};forEach.call(getNames(_RegExp),function(key){key in RegExp||defineProperty(RegExp,key,{configurable:true,get:function(){return _RegExp[key]},set:function(it){_RegExp[key]=it}})});RegExpProto[CONSTRUCTOR]=RegExp;RegExp[PROTOTYPE]=RegExpProto;hidden(global,REGEXP,RegExp)}if(/./g.flags!="g")defineProperty(RegExpProto,"flags",{configurable:true,get:createReplacer(/^.*\/(\w*)$/,"$1")});forEach.call(array("find,findIndex,fill,copyWithin,entries,keys,values"),function(it){ArrayUnscopables[it]=true});SYMBOL_UNSCOPABLES in ArrayProto||hidden(ArrayProto,SYMBOL_UNSCOPABLES,ArrayUnscopables)}setSpecies(RegExp);setSpecies(Array)}(RegExp[PROTOTYPE],isFinite,{},"name");isFunction(setImmediate)&&isFunction(clearImmediate)||function(ONREADYSTATECHANGE){var postMessage=global.postMessage,addEventListener=global.addEventListener,MessageChannel=global.MessageChannel,counter=0,queue={},defer,channel,port;setImmediate=function(fn){var args=[],i=1;while(arguments.length>i)args.push(arguments[i++]);queue[++counter]=function(){invoke(isFunction(fn)?fn:Function(fn),args)};defer(counter);return counter};clearImmediate=function(id){delete queue[id]};function run(id){if(has(queue,id)){var fn=queue[id];delete queue[id];fn()}}function listner(event){run(event.data)}if(NODE){defer=function(id){nextTick(part.call(run,id))}}else if(addEventListener&&isFunction(postMessage)&&!global.importScripts){defer=function(id){postMessage(id,"*")};addEventListener("message",listner,false)}else if(isFunction(MessageChannel)){channel=new MessageChannel;port=channel.port2;channel.port1.onmessage=listner;defer=ctx(port.postMessage,port,1)}else if(document&&ONREADYSTATECHANGE in document[CREATE_ELEMENT]("script")){defer=function(id){html.appendChild(document[CREATE_ELEMENT]("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this);run(id)}}}else{defer=function(id){setTimeout(part.call(run,id),0)}}}("onreadystatechange");$define(GLOBAL+BIND,{setImmediate:setImmediate,clearImmediate:clearImmediate});!function(Promise,test){isFunction(Promise)&&isFunction(Promise.resolve)&&Promise.resolve(test=new Promise(function(){}))==test||function(asap,DEF){function isThenable(o){var then;if(isObject(o))then=o.then;return isFunction(then)?then:false}function notify(def){var chain=def.chain;chain.length&&asap(function(){var msg=def.msg,ok=def.state==1,i=0;while(chain.length>i)!function(react){var cb=ok?react.ok:react.fail,ret,then;try{if(cb){ret=cb===true?msg:cb(msg);if(ret===react.P){react.rej(TypeError(PROMISE+"-chain cycle"))}else if(then=isThenable(ret)){then.call(ret,react.res,react.rej)}else react.res(ret)}else react.rej(msg)}catch(err){react.rej(err)}}(chain[i++]);chain.length=0})}function resolve(msg){var def=this,then,wrapper;if(def.done)return;def.done=true;def=def.def||def;try{if(then=isThenable(msg)){wrapper={def:def,done:false};then.call(msg,ctx(resolve,wrapper,1),ctx(reject,wrapper,1))}else{def.msg=msg;def.state=1;notify(def)}}catch(err){reject.call(wrapper||{def:def,done:false},err)}}function reject(msg){var def=this;if(def.done)return;def.done=true;def=def.def||def;def.msg=msg;def.state=2;notify(def)}function getConstructor(C){var S=assertObject(C)[SYMBOL_SPECIES];return S!=undefined?S:C}Promise=function(executor){assertFunction(executor);assertInstance(this,Promise,PROMISE);var def={chain:[],state:0,done:false,msg:undefined};hidden(this,DEF,def);try{executor(ctx(resolve,def,1),ctx(reject,def,1))}catch(err){reject.call(def,err)}};assignHidden(Promise[PROTOTYPE],{then:function(onFulfilled,onRejected){var S=assertObject(assertObject(this)[CONSTRUCTOR])[SYMBOL_SPECIES];var react={ok:isFunction(onFulfilled)?onFulfilled:true,fail:isFunction(onRejected)?onRejected:false},P=react.P=new(S!=undefined?S:Promise)(function(resolve,reject){react.res=assertFunction(resolve);react.rej=assertFunction(reject)}),def=this[DEF];def.chain.push(react);def.state&¬ify(def);return P},"catch":function(onRejected){return this.then(undefined,onRejected)}});assignHidden(Promise,{all:function(iterable){var Promise=getConstructor(this),values=[];return new Promise(function(resolve,reject){forOf(iterable,false,push,values);var remaining=values.length,results=Array(remaining);if(remaining)forEach.call(values,function(promise,index){Promise.resolve(promise).then(function(value){results[index]=value;--remaining||resolve(results)},reject)});else resolve(results)})},race:function(iterable){var Promise=getConstructor(this);return new Promise(function(resolve,reject){forOf(iterable,false,function(promise){Promise.resolve(promise).then(resolve,reject)})})},reject:function(r){return new(getConstructor(this))(function(resolve,reject){reject(r)})},resolve:function(x){return isObject(x)&&DEF in x&&getPrototypeOf(x)===this[PROTOTYPE]?x:new(getConstructor(this))(function(resolve,reject){resolve(x)})}})}(nextTick||setImmediate,safeSymbol("def"));setToStringTag(Promise,PROMISE);setSpecies(Promise);$define(GLOBAL+FORCED*!isNative(Promise),{Promise:Promise})}(global[PROMISE]);!function(){var UID=safeSymbol("uid"),O1=safeSymbol("O1"),WEAK=safeSymbol("weak"),LEAK=safeSymbol("leak"),LAST=safeSymbol("last"),FIRST=safeSymbol("first"),SIZE=DESC?safeSymbol("size"):"size",uid=0,tmp={};function getCollection(C,NAME,methods,commonMethods,isMap,isWeak){var ADDER=isMap?"set":"add",proto=C&&C[PROTOTYPE],O={};function initFromIterable(that,iterable){if(iterable!=undefined)forOf(iterable,isMap,that[ADDER],that);return that}function fixSVZ(key,chain){var method=proto[key];if(framework)proto[key]=function(a,b){var result=method.call(this,a===0?0:a,b);return chain?this:result}}if(!isNative(C)||!(isWeak||!BUGGY_ITERATORS&&has(proto,FOR_EACH)&&has(proto,"entries"))){C=isWeak?function(iterable){assertInstance(this,C,NAME);set(this,UID,uid++);initFromIterable(this,iterable)}:function(iterable){var that=this;assertInstance(that,C,NAME);set(that,O1,create(null));set(that,SIZE,0);set(that,LAST,undefined);set(that,FIRST,undefined);initFromIterable(that,iterable)};assignHidden(assignHidden(C[PROTOTYPE],methods),commonMethods);isWeak||defineProperty(C[PROTOTYPE],"size",{get:function(){return assertDefined(this[SIZE])}})}else{var Native=C,inst=new C,chain=inst[ADDER](isWeak?{}:-0,1),buggyZero;if(!NATIVE_ITERATORS||!C.length){C=function(iterable){assertInstance(this,C,NAME);return initFromIterable(new Native,iterable)};C[PROTOTYPE]=proto;if(framework)proto[CONSTRUCTOR]=C}isWeak||inst[FOR_EACH](function(val,key){buggyZero=1/key===-Infinity});if(buggyZero){fixSVZ("delete");fixSVZ("has");isMap&&fixSVZ("get")}if(buggyZero||chain!==inst)fixSVZ(ADDER,true)}setToStringTag(C,NAME);setSpecies(C);O[NAME]=C;$define(GLOBAL+WRAP+FORCED*!isNative(C),O);isWeak||defineStdIterators(C,NAME,function(iterated,kind){set(this,ITER,{o:iterated,k:kind})},function(){var iter=this[ITER],kind=iter.k,entry=iter.l;while(entry&&entry.r)entry=entry.p;if(!iter.o||!(iter.l=entry=entry?entry.n:iter.o[FIRST])){return iter.o=undefined,iterResult(1)}if(kind==KEY)return iterResult(0,entry.k);if(kind==VALUE)return iterResult(0,entry.v);return iterResult(0,[entry.k,entry.v])},isMap?KEY+VALUE:VALUE,!isMap);return C}function fastKey(it,create){if(!isObject(it))return(typeof it=="string"?"S":"P")+it;if(isFrozen(it))return"F";if(!has(it,UID)){if(!create)return"E";hidden(it,UID,++uid)}return"O"+it[UID]}function getEntry(that,key){var index=fastKey(key),entry;if(index!="F")return that[O1][index];for(entry=that[FIRST];entry;entry=entry.n){if(entry.k==key)return entry}}function def(that,key,value){var entry=getEntry(that,key),prev,index;if(entry)entry.v=value;else{that[LAST]=entry={i:index=fastKey(key,true),k:key,v:value,p:prev=that[LAST],n:undefined,r:false};if(!that[FIRST])that[FIRST]=entry;if(prev)prev.n=entry;that[SIZE]++;if(index!="F")that[O1][index]=entry}return that}var collectionMethods={clear:function(){for(var that=this,data=that[O1],entry=that[FIRST];entry;entry=entry.n){entry.r=true;entry.p=entry.n=undefined;delete data[entry.i]}that[FIRST]=that[LAST]=undefined;that[SIZE]=0},"delete":function(key){var that=this,entry=getEntry(that,key);if(entry){var next=entry.n,prev=entry.p;delete that[O1][entry.i];entry.r=true;if(prev)prev.n=next;if(next)next.p=prev;if(that[FIRST]==entry)that[FIRST]=next;if(that[LAST]==entry)that[LAST]=prev;that[SIZE]--}return!!entry},forEach:function(callbackfn){var f=ctx(callbackfn,arguments[1],3),entry;while(entry=entry?entry.n:this[FIRST]){f(entry.v,entry.k,this);while(entry&&entry.r)entry=entry.p}},has:function(key){return!!getEntry(this,key)}};Map=getCollection(Map,MAP,{get:function(key){var entry=getEntry(this,key);return entry&&entry.v},set:function(key,value){return def(this,key===0?0:key,value)}},collectionMethods,true);Set=getCollection(Set,SET,{add:function(value){return def(this,value=value===0?0:value,value)}},collectionMethods);function defWeak(that,key,value){if(isFrozen(assertObject(key)))leakStore(that).set(key,value);else{has(key,WEAK)||hidden(key,WEAK,{});key[WEAK][that[UID]]=value}return that}function leakStore(that){return that[LEAK]||hidden(that,LEAK,new Map)[LEAK]}var weakMethods={"delete":function(key){if(!isObject(key))return false;if(isFrozen(key))return leakStore(this)["delete"](key);return has(key,WEAK)&&has(key[WEAK],this[UID])&&delete key[WEAK][this[UID]]},has:function(key){if(!isObject(key))return false;if(isFrozen(key))return leakStore(this).has(key);return has(key,WEAK)&&has(key[WEAK],this[UID])}};WeakMap=getCollection(WeakMap,WEAKMAP,{get:function(key){if(isObject(key)){if(isFrozen(key))return leakStore(this).get(key);if(has(key,WEAK))return key[WEAK][this[UID]]}},set:function(key,value){return defWeak(this,key,value)}},weakMethods,true,true);if(framework&&DESC&&new WeakMap([[Object.freeze(tmp),7]]).get(tmp)!=7){forEach.call(array("delete,has,get,set"),function(key){var method=WeakMap[PROTOTYPE][key];WeakMap[PROTOTYPE][key]=function(a,b){if(isObject(a)&&isFrozen(a)){var result=leakStore(this)[key](a,b);return key=="set"?this:result | ||
}return method.call(this,a,b)}})}WeakSet=getCollection(WeakSet,WEAKSET,{add:function(value){return defWeak(this,value,true)}},weakMethods,false,true)}();!function(){function Enumerate(iterated){var keys=[],key;for(key in iterated)keys.push(key);set(this,ITER,{o:iterated,a:keys,i:0})}createIterator(Enumerate,OBJECT,function(){var iter=this[ITER],keys=iter.a,key;do{if(iter.i>=keys.length)return iterResult(1)}while(!((key=keys[iter.i++])in iter.o));return iterResult(0,key)});function wrap(fn){return function(it){assertObject(it);try{return fn.apply(undefined,arguments),true}catch(e){return false}}}function reflectGet(target,propertyKey){var receiver=arguments.length<3?target:arguments[2],desc=getOwnDescriptor(assertObject(target),propertyKey),proto;if(desc)return desc.get?desc.get.call(receiver):desc.value;return isObject(proto=getPrototypeOf(target))?reflectGet(proto,propertyKey,receiver):undefined}function reflectSet(target,propertyKey,V){var receiver=arguments.length<4?target:arguments[3],desc=getOwnDescriptor(assertObject(target),propertyKey),proto;if(desc){if(desc.writable===false)return false;if(desc.set)return desc.set.call(receiver,V),true}if(isObject(proto=getPrototypeOf(target)))return reflectSet(proto,propertyKey,V,receiver);desc=getOwnDescriptor(receiver,propertyKey)||descriptor(0);desc.value=V;return defineProperty(receiver,propertyKey,desc),true}var isExtensible=Object.isExtensible||returnIt;var reflect={apply:ctx(call,apply,3),construct:construct,defineProperty:wrap(defineProperty),deleteProperty:function(target,propertyKey){var desc=getOwnDescriptor(assertObject(target),propertyKey);return desc&&!desc.configurable?false:delete target[propertyKey]},enumerate:function(target){return new Enumerate(assertObject(target))},get:reflectGet,getOwnPropertyDescriptor:function(target,propertyKey){return getOwnDescriptor(assertObject(target),propertyKey)},getPrototypeOf:function(target){return getPrototypeOf(assertObject(target))},has:function(target,propertyKey){return propertyKey in target},isExtensible:function(target){return!!isExtensible(assertObject(target))},ownKeys:ownKeys,preventExtensions:wrap(Object.preventExtensions||returnIt),set:reflectSet};if(setPrototypeOf)reflect.setPrototypeOf=function(target,proto){return setPrototypeOf(assertObject(target),proto),true};$define(GLOBAL,{Reflect:{}});$define(STATIC,"Reflect",reflect)}();!function(){$define(PROTO,ARRAY,{includes:createArrayContains(true)});$define(PROTO,STRING,{at:createPointAt(true)});function createObjectToArray(isEntries){return function(object){var O=toObject(object),keys=getKeys(object),length=keys.length,i=0,result=Array(length),key;if(isEntries)while(length>i)result[i]=[key=keys[i++],O[key]];else while(length>i)result[i]=O[keys[i++]];return result}}$define(STATIC,OBJECT,{values:createObjectToArray(false),entries:createObjectToArray(true)});$define(STATIC,REGEXP,{escape:createReplacer(/([\\\-[\]{}()*+?.,^$|])/g,"\\$1",true)})}();!function(REFERENCE){REFERENCE_GET=getWellKnownSymbol(REFERENCE+"Get",true);var REFERENCE_SET=getWellKnownSymbol(REFERENCE+SET,true),REFERENCE_DELETE=getWellKnownSymbol(REFERENCE+"Delete",true);$define(STATIC,SYMBOL,{referenceGet:REFERENCE_GET,referenceSet:REFERENCE_SET,referenceDelete:REFERENCE_DELETE});hidden(FunctionProto,REFERENCE_GET,returnThis);function setMapMethods(Constructor){if(Constructor){var MapProto=Constructor[PROTOTYPE];hidden(MapProto,REFERENCE_GET,MapProto.get);hidden(MapProto,REFERENCE_SET,MapProto.set);hidden(MapProto,REFERENCE_DELETE,MapProto["delete"])}}setMapMethods(Map);setMapMethods(WeakMap)}("reference");!function(NodeList){if(framework&&NodeList&&!(SYMBOL_ITERATOR in NodeList[PROTOTYPE])){hidden(NodeList[PROTOTYPE],SYMBOL_ITERATOR,Iterators[ARRAY])}Iterators.NodeList=Iterators[ARRAY]}(global.NodeList);!function(arrayStatics){function setArrayStatics(keys,length){forEach.call(array(keys),function(key){if(key in ArrayProto)arrayStatics[key]=ctx(call,ArrayProto[key],length)})}setArrayStatics("pop,reverse,shift,keys,values,entries",1);setArrayStatics("indexOf,every,some,forEach,map,filter,find,findIndex,includes",3);setArrayStatics("join,slice,concat,push,splice,unshift,sort,lastIndexOf,"+"reduce,reduceRight,copyWithin,fill,turn");$define(STATIC,ARRAY,arrayStatics)}({})}(typeof self!="undefined"&&self.Math===Math?self:Function("return this")(),true)},{}],3:[function(require,module,exports){(function(global){!function(global){"use strict";var hasOwn=Object.prototype.hasOwnProperty;var undefined;var iteratorSymbol=typeof Symbol==="function"&&Symbol.iterator||"@@iterator";var inModule=typeof module==="object";var runtime=global.regeneratorRuntime;if(runtime){if(inModule){module.exports=runtime}return}runtime=global.regeneratorRuntime=inModule?module.exports:{};function wrap(innerFn,outerFn,self,tryList){return new Generator(innerFn,outerFn,self||null,tryList||[])}runtime.wrap=wrap;function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}var GenStateSuspendedStart="suspendedStart";var GenStateSuspendedYield="suspendedYield";var GenStateExecuting="executing";var GenStateCompleted="completed";var ContinueSentinel={};function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype;GeneratorFunction.prototype=Gp.constructor=GeneratorFunctionPrototype;GeneratorFunctionPrototype.constructor=GeneratorFunction;GeneratorFunction.displayName="GeneratorFunction";runtime.isGeneratorFunction=function(genFun){var ctor=typeof genFun==="function"&&genFun.constructor;return ctor?ctor===GeneratorFunction||(ctor.displayName||ctor.name)==="GeneratorFunction":false};runtime.mark=function(genFun){genFun.__proto__=GeneratorFunctionPrototype;genFun.prototype=Object.create(Gp);return genFun};runtime.async=function(innerFn,outerFn,self,tryList){return new Promise(function(resolve,reject){var generator=wrap(innerFn,outerFn,self,tryList);var callNext=step.bind(generator.next);var callThrow=step.bind(generator["throw"]);function step(arg){var record=tryCatch(this,null,arg);if(record.type==="throw"){reject(record.arg);return}var info=record.arg;if(info.done){resolve(info.value)}else{Promise.resolve(info.value).then(callNext,callThrow)}}callNext()})};function Generator(innerFn,outerFn,self,tryList){var generator=outerFn?Object.create(outerFn.prototype):this;var context=new Context(tryList);var state=GenStateSuspendedStart;function invoke(method,arg){if(state===GenStateExecuting){throw new Error("Generator is already running")}if(state===GenStateCompleted){return doneResult()}while(true){var delegate=context.delegate;if(delegate){var record=tryCatch(delegate.iterator[method],delegate.iterator,arg);if(record.type==="throw"){context.delegate=null;method="throw";arg=record.arg;continue}method="next";arg=undefined;var info=record.arg;if(info.done){context[delegate.resultName]=info.value;context.next=delegate.nextLoc}else{state=GenStateSuspendedYield;return info}context.delegate=null}if(method==="next"){if(state===GenStateSuspendedStart&&typeof arg!=="undefined"){throw new TypeError("attempt to send "+JSON.stringify(arg)+" to newborn generator")}if(state===GenStateSuspendedYield){context.sent=arg}else{delete context.sent}}else if(method==="throw"){if(state===GenStateSuspendedStart){state=GenStateCompleted;throw arg}if(context.dispatchException(arg)){method="next";arg=undefined}}else if(method==="return"){context.abrupt("return",arg)}state=GenStateExecuting;var record=tryCatch(innerFn,self,context);if(record.type==="normal"){state=context.done?GenStateCompleted:GenStateSuspendedYield;var info={value:record.arg,done:context.done};if(record.arg===ContinueSentinel){if(context.delegate&&method==="next"){arg=undefined}}else{return info}}else if(record.type==="throw"){state=GenStateCompleted;if(method==="next"){context.dispatchException(record.arg)}else{arg=record.arg}}}}generator.next=invoke.bind(generator,"next");generator["throw"]=invoke.bind(generator,"throw");generator["return"]=invoke.bind(generator,"return");return generator}Gp[iteratorSymbol]=function(){return this};Gp.toString=function(){return"[object Generator]"};function pushTryEntry(triple){var entry={tryLoc:triple[0]};if(1 in triple){entry.catchLoc=triple[1]}if(2 in triple){entry.finallyLoc=triple[2]}this.tryEntries.push(entry)}function resetTryEntry(entry,i){var record=entry.completion||{};record.type=i===0?"normal":"return";delete record.arg;entry.completion=record}function Context(tryList){this.tryEntries=[{tryLoc:"root"}];tryList.forEach(pushTryEntry,this);this.reset()}runtime.keys=function(object){var keys=[];for(var key in object){keys.push(key)}keys.reverse();return function next(){while(keys.length){var key=keys.pop();if(key in object){next.value=key;next.done=false;return next}}next.done=true;return next}};function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod){return iteratorMethod.call(iterable)}if(typeof iterable.next==="function"){return iterable}if(!isNaN(iterable.length)){var i=-1,next=function next(){while(++i<iterable.length){if(hasOwn.call(iterable,i)){next.value=iterable[i];next.done=false;return next}}next.value=undefined;next.done=true;return next};return next.next=next}}return{next:doneResult}}runtime.values=values;function doneResult(){return{value:undefined,done:true}}Context.prototype={constructor:Context,reset:function(){this.prev=0;this.next=0;this.sent=undefined;this.done=false;this.delegate=null;this.tryEntries.forEach(resetTryEntry);for(var tempIndex=0,tempName;hasOwn.call(this,tempName="t"+tempIndex)||tempIndex<20;++tempIndex){this[tempName]=null}},stop:function(){this.done=true;var rootEntry=this.tryEntries[0];var rootRecord=rootEntry.completion;if(rootRecord.type==="throw"){throw rootRecord.arg}return this.rval},dispatchException:function(exception){if(this.done){throw exception}var context=this;function handle(loc,caught){record.type="throw";record.arg=exception;context.next=loc;return!!caught}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];var record=entry.completion;if(entry.tryLoc==="root"){return handle("end")}if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc");var hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc){return handle(entry.catchLoc,true)}else if(this.prev<entry.finallyLoc){return handle(entry.finallyLoc)}}else if(hasCatch){if(this.prev<entry.catchLoc){return handle(entry.catchLoc,true)}}else if(hasFinally){if(this.prev<entry.finallyLoc){return handle(entry.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},_findFinallyEntry:function(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&(entry.finallyLoc===finallyLoc||this.prev<entry.finallyLoc)){return entry}}},abrupt:function(type,arg){var entry=this._findFinallyEntry();var record=entry?entry.completion:{};record.type=type;record.arg=arg;if(entry){this.next=entry.finallyLoc}else{this.complete(record)}return ContinueSentinel},complete:function(record){if(record.type==="throw"){throw record.arg}if(record.type==="break"||record.type==="continue"){this.next=record.arg}else if(record.type==="return"){this.rval=record.arg;this.next="end"}return ContinueSentinel},finish:function(finallyLoc){var entry=this._findFinallyEntry(finallyLoc);return this.complete(entry.completion)},"catch":function(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if(record.type==="throw"){var thrown=record.arg;resetTryEntry(entry,i)}return thrown}}throw new Error("illegal catch attempt")},delegateYield:function(iterable,resultName,nextLoc){this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc};return ContinueSentinel}}}(typeof global==="object"?global:typeof window==="object"?window:this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[1]); | ||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){(function(global){"use strict";if(global._6to5Polyfill){throw new Error("only one instance of 6to5/polyfill is allowed")}global._6to5Polyfill=true;require("core-js/shim");require("regenerator-6to5/runtime")}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"core-js/shim":2,"regenerator-6to5/runtime":3}],2:[function(require,module,exports){!function(global,framework,undefined){"use strict";var OBJECT="Object",FUNCTION="Function",ARRAY="Array",STRING="String",NUMBER="Number",REGEXP="RegExp",DATE="Date",MAP="Map",SET="Set",WEAKMAP="WeakMap",WEAKSET="WeakSet",SYMBOL="Symbol",PROMISE="Promise",MATH="Math",ARGUMENTS="Arguments",PROTOTYPE="prototype",CONSTRUCTOR="constructor",TO_STRING="toString",TO_STRING_TAG=TO_STRING+"Tag",TO_LOCALE="toLocaleString",HAS_OWN="hasOwnProperty",FOR_EACH="forEach",ITERATOR="iterator",FF_ITERATOR="@@"+ITERATOR,PROCESS="process",CREATE_ELEMENT="createElement",Function=global[FUNCTION],Object=global[OBJECT],Array=global[ARRAY],String=global[STRING],Number=global[NUMBER],RegExp=global[REGEXP],Date=global[DATE],Map=global[MAP],Set=global[SET],WeakMap=global[WEAKMAP],WeakSet=global[WEAKSET],Symbol=global[SYMBOL],Math=global[MATH],TypeError=global.TypeError,setTimeout=global.setTimeout,setImmediate=global.setImmediate,clearImmediate=global.clearImmediate,parseInt=global.parseInt,isFinite=global.isFinite,process=global[PROCESS],nextTick=process&&process.nextTick,document=global.document,html=document&&document.documentElement,navigator=global.navigator,define=global.define,ArrayProto=Array[PROTOTYPE],ObjectProto=Object[PROTOTYPE],FunctionProto=Function[PROTOTYPE],Infinity=1/0,DOT=".",CONSOLE_METHODS="assert,clear,count,debug,dir,dirxml,error,exception,"+"group,groupCollapsed,groupEnd,info,isIndependentlyComposed,log,"+"markTimeline,profile,profileEnd,table,time,timeEnd,timeline,"+"timelineEnd,timeStamp,trace,warn";function isObject(it){return it!==null&&(typeof it=="object"||typeof it=="function")}function isFunction(it){return typeof it=="function"}var isNative=ctx(/./.test,/\[native code\]\s*\}\s*$/,1);var toString=ObjectProto[TO_STRING];function setToStringTag(it,tag,stat){if(it&&!has(it=stat?it:it[PROTOTYPE],SYMBOL_TAG))hidden(it,SYMBOL_TAG,tag)}function cof(it){return toString.call(it).slice(8,-1)}function classof(it){var O,T;return it==undefined?it===undefined?"Undefined":"Null":typeof(T=(O=Object(it))[SYMBOL_TAG])=="string"?T:cof(O)}var call=FunctionProto.call,apply=FunctionProto.apply,REFERENCE_GET;function part(){var fn=assertFunction(this),length=arguments.length,args=Array(length),i=0,_=path._,holder=false;while(length>i)if((args[i]=arguments[i++])===_)holder=true;return function(){var that=this,_length=arguments.length,i=0,j=0,_args;if(!holder&&!_length)return invoke(fn,args,that);_args=args.slice();if(holder)for(;length>i;i++)if(_args[i]===_)_args[i]=arguments[j++];while(_length>j)_args.push(arguments[j++]);return invoke(fn,_args,that)}}function ctx(fn,that,length){assertFunction(fn);if(~length&&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(){return fn.apply(that,arguments)}}function invoke(fn,args,that){var un=that===undefined;switch(args.length|0){case 0:return un?fn():fn.call(that);case 1:return un?fn(args[0]):fn.call(that,args[0]);case 2:return un?fn(args[0],args[1]):fn.call(that,args[0],args[1]);case 3:return un?fn(args[0],args[1],args[2]):fn.call(that,args[0],args[1],args[2]);case 4:return un?fn(args[0],args[1],args[2],args[3]):fn.call(that,args[0],args[1],args[2],args[3]);case 5:return un?fn(args[0],args[1],args[2],args[3],args[4]):fn.call(that,args[0],args[1],args[2],args[3],args[4])}return fn.apply(that,args)}function construct(target,argumentsList){var proto=assertFunction(arguments.length<3?target:arguments[2])[PROTOTYPE],instance=create(isObject(proto)?proto:ObjectProto),result=apply.call(target,instance,argumentsList);return isObject(result)?result:instance}var create=Object.create,getPrototypeOf=Object.getPrototypeOf,setPrototypeOf=Object.setPrototypeOf,defineProperty=Object.defineProperty,defineProperties=Object.defineProperties,getOwnDescriptor=Object.getOwnPropertyDescriptor,getKeys=Object.keys,getNames=Object.getOwnPropertyNames,getSymbols=Object.getOwnPropertySymbols,isFrozen=Object.isFrozen,has=ctx(call,ObjectProto[HAS_OWN],2),ES5Object=Object,Dict;function toObject(it){return ES5Object(assertDefined(it))}function returnIt(it){return it}function returnThis(){return this}function get(object,key){if(has(object,key))return object[key]}function ownKeys(it){assertObject(it);return getSymbols?getNames(it).concat(getSymbols(it)):getNames(it)}var assign=Object.assign||function(target,source){var T=Object(assertDefined(target)),l=arguments.length,i=1;while(l>i){var S=ES5Object(arguments[i++]),keys=getKeys(S),length=keys.length,j=0,key;while(length>j)T[key=keys[j++]]=S[key]}return T};function keyOf(object,el){var O=toObject(object),keys=getKeys(O),length=keys.length,index=0,key;while(length>index)if(O[key=keys[index++]]===el)return key}function array(it){return String(it).split(",")}var push=ArrayProto.push,unshift=ArrayProto.unshift,slice=ArrayProto.slice,splice=ArrayProto.splice,indexOf=ArrayProto.indexOf,forEach=ArrayProto[FOR_EACH];function createArrayMethod(type){var isMap=type==1,isFilter=type==2,isSome=type==3,isEvery=type==4,isFindIndex=type==6,noholes=type==5||isFindIndex;return function(callbackfn){var O=Object(assertDefined(this)),that=arguments[1],self=ES5Object(O),f=ctx(callbackfn,that,3),length=toLength(self.length),index=0,result=isMap?Array(length):isFilter?[]:undefined,val,res;for(;length>index;index++)if(noholes||index in self){val=self[index];res=f(val,index,O);if(type){if(isMap)result[index]=res;else if(res)switch(type){case 3:return true;case 5:return val;case 6:return index;case 2:result.push(val)}else if(isEvery)return false}}return isFindIndex?-1:isSome||isEvery?isEvery:result}}function createArrayContains(isContains){return function(el){var O=toObject(this),length=toLength(O.length),index=toIndex(arguments[1],length);if(isContains&&el!=el){for(;length>index;index++)if(sameNaN(O[index]))return isContains||index}else for(;length>index;index++)if(isContains||index in O){if(O[index]===el)return isContains||index}return!isContains&&-1}}function generic(A,B){return typeof A=="function"?A:B}var MAX_SAFE_INTEGER=9007199254740991,pow=Math.pow,abs=Math.abs,ceil=Math.ceil,floor=Math.floor,max=Math.max,min=Math.min,random=Math.random,trunc=Math.trunc||function(it){return(it>0?floor:ceil)(it)};function sameNaN(number){return number!=number}function toInteger(it){return isNaN(it)?0:trunc(it)}function toLength(it){return it>0?min(toInteger(it),MAX_SAFE_INTEGER):0}function toIndex(index,length){var index=toInteger(index);return index<0?max(index+length,0):min(index,length)}function createReplacer(regExp,replace,isStatic){var replacer=isObject(replace)?function(part){return replace[part]}:replace;return function(it){return String(isStatic?it:this).replace(regExp,replacer)}}function createPointAt(toString){return function(pos){var s=String(assertDefined(this)),i=toInteger(pos),l=s.length,a,b;if(i<0||i>=l)return toString?"":undefined;a=s.charCodeAt(i);return a<55296||a>56319||i+1===l||(b=s.charCodeAt(i+1))<56320||b>57343?toString?s.charAt(i):a:toString?s.slice(i,i+2):(a-55296<<10)+(b-56320)+65536}}var REDUCE_ERROR="Reduce of empty object with no initial value";function assert(condition,msg1,msg2){if(!condition)throw TypeError(msg2?msg1+msg2:msg1)}function assertDefined(it){if(it==undefined)throw TypeError("Function called on null or undefined");return it}function assertFunction(it){assert(isFunction(it),it," is not a function!");return it}function assertObject(it){assert(isObject(it),it," is not an object!");return it}function assertInstance(it,Constructor,name){assert(it instanceof Constructor,name,": use the 'new' operator!")}function descriptor(bitmap,value){return{enumerable:!(bitmap&1),configurable:!(bitmap&2),writable:!(bitmap&4),value:value}}function simpleSet(object,key,value){object[key]=value;return object}function createDefiner(bitmap){return DESC?function(object,key,value){return defineProperty(object,key,descriptor(bitmap,value))}:simpleSet}function uid(key){return SYMBOL+"("+key+")_"+(++sid+random())[TO_STRING](36)}function getWellKnownSymbol(name,setter){return Symbol&&Symbol[name]||(setter?Symbol:safeSymbol)(SYMBOL+DOT+name)}var DESC=!!function(){try{return defineProperty({},"a",{get:function(){return 2}}).a==2}catch(e){}}(),sid=0,hidden=createDefiner(1),set=Symbol?simpleSet:hidden,safeSymbol=Symbol||uid;function assignHidden(target,src){for(var key in src)hidden(target,key,src[key]);return target}var SYMBOL_UNSCOPABLES=getWellKnownSymbol("unscopables"),ArrayUnscopables=ArrayProto[SYMBOL_UNSCOPABLES]||{},SYMBOL_SPECIES=getWellKnownSymbol("species");function setSpecies(C){if(framework||!isNative(C))defineProperty(C,SYMBOL_SPECIES,{configurable:true,get:returnThis})}var SYMBOL_ITERATOR=getWellKnownSymbol(ITERATOR),SYMBOL_TAG=getWellKnownSymbol(TO_STRING_TAG),SUPPORT_FF_ITER=FF_ITERATOR in ArrayProto,ITER=safeSymbol("iter"),KEY=1,VALUE=2,Iterators={},IteratorPrototype={},NATIVE_ITERATORS=SYMBOL_ITERATOR in ArrayProto,BUGGY_ITERATORS="keys"in ArrayProto&&!("next"in[].keys());setIterator(IteratorPrototype,returnThis);function setIterator(O,value){hidden(O,SYMBOL_ITERATOR,value);SUPPORT_FF_ITER&&hidden(O,FF_ITERATOR,value)}function createIterator(Constructor,NAME,next,proto){Constructor[PROTOTYPE]=create(proto||IteratorPrototype,{next:descriptor(1,next)});setToStringTag(Constructor,NAME+" Iterator")}function defineIterator(Constructor,NAME,value,DEFAULT){var proto=Constructor[PROTOTYPE],iter=get(proto,SYMBOL_ITERATOR)||get(proto,FF_ITERATOR)||DEFAULT&&get(proto,DEFAULT)||value;if(framework){setIterator(proto,iter);if(iter!==value){var iterProto=getPrototypeOf(iter.call(new Constructor));setToStringTag(iterProto,NAME+" Iterator",true);has(proto,FF_ITERATOR)&&setIterator(iterProto,returnThis)}}Iterators[NAME]=iter;Iterators[NAME+" Iterator"]=returnThis;return iter}function defineStdIterators(Base,NAME,Constructor,next,DEFAULT,IS_SET){function createIter(kind){return function(){return new Constructor(this,kind)}}createIterator(Constructor,NAME,next);var entries=createIter(KEY+VALUE),values=createIter(VALUE);if(DEFAULT==VALUE)values=defineIterator(Base,NAME,values,"values");else entries=defineIterator(Base,NAME,entries,"entries");if(DEFAULT){$define(PROTO+FORCED*BUGGY_ITERATORS,NAME,{entries:entries,keys:IS_SET?values:createIter(KEY),values:values})}}function iterResult(done,value){return{value:value,done:!!done}}function isIterable(it){var O=Object(it),Symbol=global[SYMBOL],hasExt=(Symbol&&Symbol[ITERATOR]||FF_ITERATOR)in O;return hasExt||SYMBOL_ITERATOR in O||has(Iterators,classof(O))}function getIterator(it){var Symbol=global[SYMBOL],ext=it[Symbol&&Symbol[ITERATOR]||FF_ITERATOR],getIter=ext||it[SYMBOL_ITERATOR]||Iterators[classof(it)];return assertObject(getIter.call(it))}function stepCall(fn,value,entries){return entries?invoke(fn,value):fn(value)}function forOf(iterable,entries,fn,that){var iterator=getIterator(iterable),f=ctx(fn,that,entries?2:1),step;while(!(step=iterator.next()).done)if(stepCall(f,step.value,entries)===false)return}var NODE=cof(process)==PROCESS,core={},path=framework?global:core,old=global.core,exportGlobal,FORCED=1,GLOBAL=2,STATIC=4,PROTO=8,BIND=16,WRAP=32;function $define(type,name,source){var key,own,out,exp,isGlobal=type&GLOBAL,target=isGlobal?global:type&STATIC?global[name]:(global[name]||ObjectProto)[PROTOTYPE],exports=isGlobal?core:core[name]||(core[name]={});if(isGlobal)source=name;for(key in source){own=!(type&FORCED)&&target&&key in target&&(!isFunction(target[key])||isNative(target[key]));out=(own?target:source)[key];if(type&BIND&&own)exp=ctx(out,global);else if(type&WRAP&&!framework&&target[key]==out){exp=function(param){return this instanceof out?new out(param):out(param)};exp[PROTOTYPE]=out[PROTOTYPE]}else exp=type&PROTO&&isFunction(out)?ctx(call,out):out;if(exports[key]!=out)hidden(exports,key,exp);if(framework&&target&&!own){if(isGlobal)target[key]=out;else delete target[key]&&hidden(target,key,out)}}}if(typeof module!="undefined"&&module.exports)module.exports=core;else if(isFunction(define)&&define.amd)define(function(){return core});else exportGlobal=true;if(exportGlobal||framework){core.noConflict=function(){global.core=old;return core};global.core=core}!function(TAG,SymbolRegistry,AllSymbols,setter){if(!isNative(Symbol)){Symbol=function(description){assert(!(this instanceof Symbol),SYMBOL+" is not a "+CONSTRUCTOR);var tag=uid(description),sym=set(create(Symbol[PROTOTYPE]),TAG,tag);AllSymbols[tag]=sym;DESC&&setter&&defineProperty(ObjectProto,tag,{configurable:true,set:function(value){hidden(this,tag,value)}});return sym};hidden(Symbol[PROTOTYPE],TO_STRING,function(){return this[TAG]})}$define(GLOBAL+WRAP,{Symbol:Symbol});var symbolStatics={"for":function(key){return has(SymbolRegistry,key+="")?SymbolRegistry[key]:SymbolRegistry[key]=Symbol(key)},iterator:SYMBOL_ITERATOR,keyFor:part.call(keyOf,SymbolRegistry),species:SYMBOL_SPECIES,toStringTag:SYMBOL_TAG=getWellKnownSymbol(TO_STRING_TAG,true),unscopables:SYMBOL_UNSCOPABLES,pure:safeSymbol,set:set,useSetter:function(){setter=true},useSimple:function(){setter=false}};forEach.call(array("hasInstance,isConcatSpreadable,match,replace,search,split,toPrimitive"),function(it){symbolStatics[it]=getWellKnownSymbol(it)});$define(STATIC,SYMBOL,symbolStatics);setToStringTag(Symbol,SYMBOL);$define(STATIC+FORCED*!isNative(Symbol),OBJECT,{getOwnPropertyNames:function(it){var names=getNames(toObject(it)),result=[],key,i=0;while(names.length>i)has(AllSymbols,key=names[i++])||result.push(key);return result},getOwnPropertySymbols:function(it){var names=getNames(toObject(it)),result=[],key,i=0;while(names.length>i)has(AllSymbols,key=names[i++])&&result.push(AllSymbols[key]);return result}})}(safeSymbol("tag"),{},{},true);!function(tmp){var objectStatic={assign:assign,is:function(x,y){return x===y?x!==0||1/x===1/y:x!=x&&y!=y}};"__proto__"in ObjectProto&&function(buggy,set){try{set=ctx(call,getOwnDescriptor(ObjectProto,"__proto__").set,2);set({},ArrayProto)}catch(e){buggy=true}objectStatic.setPrototypeOf=setPrototypeOf=setPrototypeOf||function(O,proto){assertObject(O);assert(proto===null||isObject(proto),proto,": can't set as prototype!");if(buggy)O.__proto__=proto;else set(O,proto);return O}}();$define(STATIC,OBJECT,objectStatic);if(framework){tmp[SYMBOL_TAG]=DOT;if(cof(tmp)!=DOT)hidden(ObjectProto,TO_STRING,function(){return"[object "+classof(this)+"]"})}setToStringTag(Math,MATH,true);setToStringTag(global.JSON,"JSON",true)}({});!function(){function wrapObjectMethod(key,MODE){var fn=Object[key],exp=core[OBJECT][key],f=0,o={};if(!exp||isNative(exp)){o[key]=MODE==1?function(it){return isObject(it)?fn(it):it}:MODE==2?function(it){return isObject(it)?fn(it):true}:MODE==3?function(it){return isObject(it)?fn(it):false}:MODE==4?function(it,key){return fn(toObject(it),key)}:function(it){return fn(toObject(it))};try{fn(DOT)}catch(e){f=1}$define(STATIC+FORCED*f,OBJECT,o)}}wrapObjectMethod("freeze",1);wrapObjectMethod("seal",1);wrapObjectMethod("preventExtensions",1);wrapObjectMethod("isFrozen",2);wrapObjectMethod("isSealed",2);wrapObjectMethod("isExtensible",3);wrapObjectMethod("getOwnPropertyDescriptor",4);wrapObjectMethod("getPrototypeOf");wrapObjectMethod("keys");wrapObjectMethod("getOwnPropertyNames")}();!function(NAME){NAME in FunctionProto||defineProperty(FunctionProto,NAME,{configurable:true,get:function(){var match=String(this).match(/^\s*function ([^ (]*)/),name=match?match[1]:"";has(this,NAME)||defineProperty(this,NAME,descriptor(5,name));return name},set:function(value){has(this,NAME)||defineProperty(this,NAME,descriptor(0,value))}})}("name");!function(isInteger){$define(STATIC,NUMBER,{EPSILON:pow(2,-52),isFinite:function(it){return typeof it=="number"&&isFinite(it)},isInteger:isInteger,isNaN:sameNaN,isSafeInteger:function(number){return isInteger(number)&&abs(number)<=MAX_SAFE_INTEGER},MAX_SAFE_INTEGER:MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:-MAX_SAFE_INTEGER,parseFloat:parseFloat,parseInt:parseInt})}(Number.isInteger||function(it){return!isObject(it)&&isFinite(it)&&floor(it)===it});!function(){var E=Math.E,exp=Math.exp,log=Math.log,sqrt=Math.sqrt,sign=Math.sign||function(x){return(x=+x)==0||x!=x?x:x<0?-1:1};function asinh(x){return!isFinite(x=+x)||x==0?x:x<0?-asinh(-x):log(x+sqrt(x*x+1))}function expm1(x){return(x=+x)==0?x:x>-1e-6&&x<1e-6?x+x*x/2:exp(x)-1}$define(STATIC,MATH,{acosh:function(x){return(x=+x)<1?NaN:isFinite(x)?log(x/E+sqrt(x+1)*sqrt(x-1)/E)+1:x},asinh:asinh,atanh:function(x){return(x=+x)==0?x:log((1+x)/(1-x))/2},cbrt:function(x){return sign(x=+x)*pow(abs(x),1/3)},clz32:function(x){return(x>>>=0)?32-x[TO_STRING](2).length:32},cosh:function(x){return(exp(x=+x)+exp(-x))/2},expm1:expm1,fround:function(x){return new Float32Array([x])[0]},hypot:function(value1,value2){var sum=0,len1=arguments.length,len2=len1,args=Array(len1),larg=-Infinity,arg;while(len1--){arg=args[len1]=+arguments[len1];if(arg==Infinity||arg==-Infinity)return Infinity;if(arg>larg)larg=arg}larg=arg||1;while(len2--)sum+=pow(args[len2]/larg,2);return larg*sqrt(sum)},imul:function(x,y){var UInt16=65535,xn=+x,yn=+y,xl=UInt16&xn,yl=UInt16&yn;return 0|xl*yl+((UInt16&xn>>>16)*yl+xl*(UInt16&yn>>>16)<<16>>>0)},log1p:function(x){return(x=+x)>-1e-8&&x<1e-8?x-x*x/2:log(1+x)},log10:function(x){return log(x)/Math.LN10},log2:function(x){return log(x)/Math.LN2},sign:sign,sinh:function(x){return abs(x=+x)<1?(expm1(x)-expm1(-x))/2:(exp(x-1)-exp(-x-1))*(E/2)},tanh:function(x){var a=expm1(x=+x),b=expm1(-x);return a==Infinity?1:b==Infinity?-1:(a-b)/(exp(x)+exp(-x))},trunc:trunc})}();!function(RangeError,fromCharCode){function assertNotRegExp(it){if(cof(it)==REGEXP)throw TypeError()}$define(STATIC,STRING,{fromCodePoint:function(x){var res=[],len=arguments.length,i=0,code;while(len>i){code=+arguments[i++];if(toIndex(code,1114111)!==code)throw RangeError(code+" is not a valid code point");res.push(code<65536?fromCharCode(code):fromCharCode(((code-=65536)>>10)+55296,code%1024+56320))}return res.join("")},raw:function(callSite){var raw=toObject(callSite.raw),len=toLength(raw.length),sln=arguments.length,res=[],i=0;while(len>i){res.push(String(raw[i++]));if(i<sln)res.push(String(arguments[i]))}return res.join("")}});$define(PROTO,STRING,{codePointAt:createPointAt(false),endsWith:function(searchString){assertNotRegExp(searchString);var that=String(assertDefined(this)),endPosition=arguments[1],len=toLength(that.length),end=endPosition===undefined?len:min(toLength(endPosition),len);searchString+="";return that.slice(end-searchString.length,end)===searchString},includes:function(searchString){assertNotRegExp(searchString);return!!~String(assertDefined(this)).indexOf(searchString,arguments[1])},repeat:function(count){var str=String(assertDefined(this)),res="",n=toInteger(count);if(0>n||n==Infinity)throw RangeError("Count can't be negative");for(;n>0;(n>>>=1)&&(str+=str))if(n&1)res+=str;return res},startsWith:function(searchString){assertNotRegExp(searchString);var that=String(assertDefined(this)),index=toLength(min(arguments[1],that.length));searchString+="";return that.slice(index,index+searchString.length)===searchString}})}(global.RangeError,String.fromCharCode);!function(){$define(STATIC,ARRAY,{from:function(arrayLike){var O=Object(assertDefined(arrayLike)),mapfn=arguments[1],mapping=mapfn!==undefined,f=mapping?ctx(mapfn,arguments[2],2):undefined,index=0,length,result,iter,step;if(isIterable(O))for(iter=getIterator(O),result=new(generic(this,Array));!(step=iter.next()).done;index++){result[index]=mapping?f(step.value,index):step.value}else for(result=new(generic(this,Array))(length=toLength(O.length));length>index;index++){result[index]=mapping?f(O[index],index):O[index]}result.length=index;return result},of:function(){var index=0,length=arguments.length,result=new(generic(this,Array))(length);while(length>index)result[index]=arguments[index++];result.length=length;return result}});$define(PROTO,ARRAY,{copyWithin:function(target,start){var O=Object(assertDefined(this)),len=toLength(O.length),to=toIndex(target,len),from=toIndex(start,len),end=arguments[2],fin=end===undefined?len:toIndex(end,len),count=min(fin-from,len-to),inc=1;if(from<to&&to<from+count){inc=-1;from=from+count-1;to=to+count-1}while(count-->0){if(from in O)O[to]=O[from];else delete O[to];to+=inc;from+=inc}return O},fill:function(value){var O=Object(assertDefined(this)),length=toLength(O.length),index=toIndex(arguments[1],length),end=arguments[2],endPos=end===undefined?length:toIndex(end,length);while(endPos>index)O[index++]=value;return O},find:createArrayMethod(5),findIndex:createArrayMethod(6)});if(framework){forEach.call(array("find,findIndex,fill,copyWithin,entries,keys,values"),function(it){ArrayUnscopables[it]=true});SYMBOL_UNSCOPABLES in ArrayProto||hidden(ArrayProto,SYMBOL_UNSCOPABLES,ArrayUnscopables)}setSpecies(Array)}();!function(at){defineStdIterators(Array,ARRAY,function(iterated,kind){set(this,ITER,{o:toObject(iterated),i:0,k:kind})},function(){var iter=this[ITER],O=iter.o,kind=iter.k,index=iter.i++;if(!O||index>=O.length){iter.o=undefined;return iterResult(1)}if(kind==KEY)return iterResult(0,index);if(kind==VALUE)return iterResult(0,O[index]);return iterResult(0,[index,O[index]])},VALUE);Iterators[ARGUMENTS]=Iterators[ARRAY];defineStdIterators(String,STRING,function(iterated){set(this,ITER,{o:String(iterated),i:0})},function(){var iter=this[ITER],O=iter.o,index=iter.i,point;if(index>=O.length)return iterResult(1);point=at.call(O,index);iter.i+=point.length;return iterResult(0,point)})}(createPointAt(true));!function(RegExpProto,_RegExp){function assertRegExpWrapper(fn){return function(){assert(cof(this)===REGEXP);return fn(this)}}if(DESC&&!function(){try{return RegExp(/a/g,"i")=="/a/i"}catch(e){}}()){RegExp=function RegExp(pattern,flags){return new _RegExp(cof(pattern)==REGEXP&&flags!==undefined?pattern.source:pattern,flags)};forEach.call(getNames(_RegExp),function(key){key in RegExp||defineProperty(RegExp,key,{configurable:true,get:function(){return _RegExp[key]},set:function(it){_RegExp[key]=it}})});RegExpProto[CONSTRUCTOR]=RegExp;RegExp[PROTOTYPE]=RegExpProto;hidden(global,REGEXP,RegExp)}if(/./g.flags!="g")defineProperty(RegExpProto,"flags",{configurable:true,get:assertRegExpWrapper(createReplacer(/^.*\/(\w*)$/,"$1",true))});forEach.call(array("sticky,unicode"),function(key){key in/./||defineProperty(RegExpProto,key,DESC?{configurable:true,get:assertRegExpWrapper(function(){return false})}:descriptor(5,false))});setSpecies(RegExp)}(RegExp[PROTOTYPE],RegExp);isFunction(setImmediate)&&isFunction(clearImmediate)||function(ONREADYSTATECHANGE){var postMessage=global.postMessage,addEventListener=global.addEventListener,MessageChannel=global.MessageChannel,counter=0,queue={},defer,channel,port;setImmediate=function(fn){var args=[],i=1;while(arguments.length>i)args.push(arguments[i++]);queue[++counter]=function(){invoke(isFunction(fn)?fn:Function(fn),args)};defer(counter);return counter};clearImmediate=function(id){delete queue[id]};function run(id){if(has(queue,id)){var fn=queue[id];delete queue[id];fn()}}function listner(event){run(event.data)}if(NODE){defer=function(id){nextTick(part.call(run,id))}}else if(addEventListener&&isFunction(postMessage)&&!global.importScripts){defer=function(id){postMessage(id,"*")};addEventListener("message",listner,false)}else if(isFunction(MessageChannel)){channel=new MessageChannel;port=channel.port2;channel.port1.onmessage=listner;defer=ctx(port.postMessage,port,1)}else if(document&&ONREADYSTATECHANGE in document[CREATE_ELEMENT]("script")){defer=function(id){html.appendChild(document[CREATE_ELEMENT]("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this);run(id)}}}else{defer=function(id){setTimeout(run,0,id)}}}("onreadystatechange");$define(GLOBAL+BIND,{setImmediate:setImmediate,clearImmediate:clearImmediate});!function(Promise,test){isFunction(Promise)&&isFunction(Promise.resolve)&&Promise.resolve(test=new Promise(function(){}))==test||function(asap,DEF){function isThenable(o){var then;if(isObject(o))then=o.then;return isFunction(then)?then:false}function notify(def){var chain=def.chain;chain.length&&asap(function(){var msg=def.msg,ok=def.state==1,i=0;while(chain.length>i)!function(react){var cb=ok?react.ok:react.fail,ret,then;try{if(cb){ret=cb===true?msg:cb(msg);if(ret===react.P){react.rej(TypeError(PROMISE+"-chain cycle"))}else if(then=isThenable(ret)){then.call(ret,react.res,react.rej)}else react.res(ret)}else react.rej(msg)}catch(err){react.rej(err)}}(chain[i++]);chain.length=0})}function resolve(msg){var def=this,then,wrapper;if(def.done)return;def.done=true;def=def.def||def;try{if(then=isThenable(msg)){wrapper={def:def,done:false};then.call(msg,ctx(resolve,wrapper,1),ctx(reject,wrapper,1))}else{def.msg=msg;def.state=1;notify(def)}}catch(err){reject.call(wrapper||{def:def,done:false},err)}}function reject(msg){var def=this;if(def.done)return;def.done=true;def=def.def||def;def.msg=msg;def.state=2;notify(def)}function getConstructor(C){var S=assertObject(C)[SYMBOL_SPECIES];return S!=undefined?S:C}Promise=function(executor){assertFunction(executor);assertInstance(this,Promise,PROMISE);var def={chain:[],state:0,done:false,msg:undefined};hidden(this,DEF,def);try{executor(ctx(resolve,def,1),ctx(reject,def,1))}catch(err){reject.call(def,err)}};assignHidden(Promise[PROTOTYPE],{then:function(onFulfilled,onRejected){var S=assertObject(assertObject(this)[CONSTRUCTOR])[SYMBOL_SPECIES];var react={ok:isFunction(onFulfilled)?onFulfilled:true,fail:isFunction(onRejected)?onRejected:false},P=react.P=new(S!=undefined?S:Promise)(function(resolve,reject){react.res=assertFunction(resolve);react.rej=assertFunction(reject)}),def=this[DEF];def.chain.push(react);def.state&¬ify(def);return P},"catch":function(onRejected){return this.then(undefined,onRejected)}});assignHidden(Promise,{all:function(iterable){var Promise=getConstructor(this),values=[];return new Promise(function(resolve,reject){forOf(iterable,false,push,values);var remaining=values.length,results=Array(remaining);if(remaining)forEach.call(values,function(promise,index){Promise.resolve(promise).then(function(value){results[index]=value;--remaining||resolve(results)},reject)});else resolve(results)})},race:function(iterable){var Promise=getConstructor(this);return new Promise(function(resolve,reject){forOf(iterable,false,function(promise){Promise.resolve(promise).then(resolve,reject)})})},reject:function(r){return new(getConstructor(this))(function(resolve,reject){reject(r)})},resolve:function(x){return isObject(x)&&DEF in x&&getPrototypeOf(x)===this[PROTOTYPE]?x:new(getConstructor(this))(function(resolve,reject){resolve(x)})}})}(nextTick||setImmediate,safeSymbol("def"));setToStringTag(Promise,PROMISE);setSpecies(Promise);$define(GLOBAL+FORCED*!isNative(Promise),{Promise:Promise})}(global[PROMISE]);!function(){var UID=safeSymbol("uid"),O1=safeSymbol("O1"),WEAK=safeSymbol("weak"),LEAK=safeSymbol("leak"),LAST=safeSymbol("last"),FIRST=safeSymbol("first"),SIZE=DESC?safeSymbol("size"):"size",uid=0,tmp={};function getCollection(C,NAME,methods,commonMethods,isMap,isWeak){var ADDER=isMap?"set":"add",proto=C&&C[PROTOTYPE],O={};function initFromIterable(that,iterable){if(iterable!=undefined)forOf(iterable,isMap,that[ADDER],that);return that}function fixSVZ(key,chain){var method=proto[key];if(framework)proto[key]=function(a,b){var result=method.call(this,a===0?0:a,b);return chain?this:result}}if(!isNative(C)||!(isWeak||!BUGGY_ITERATORS&&has(proto,FOR_EACH)&&has(proto,"entries"))){C=isWeak?function(iterable){assertInstance(this,C,NAME);set(this,UID,uid++);initFromIterable(this,iterable)}:function(iterable){var that=this;assertInstance(that,C,NAME);set(that,O1,create(null));set(that,SIZE,0);set(that,LAST,undefined);set(that,FIRST,undefined);initFromIterable(that,iterable)};assignHidden(assignHidden(C[PROTOTYPE],methods),commonMethods);isWeak||defineProperty(C[PROTOTYPE],"size",{get:function(){return assertDefined(this[SIZE])}})}else{var Native=C,inst=new C,chain=inst[ADDER](isWeak?{}:-0,1),buggyZero;if(!NATIVE_ITERATORS||!C.length){C=function(iterable){assertInstance(this,C,NAME);return initFromIterable(new Native,iterable)};C[PROTOTYPE]=proto;if(framework)proto[CONSTRUCTOR]=C}isWeak||inst[FOR_EACH](function(val,key){buggyZero=1/key===-Infinity});if(buggyZero){fixSVZ("delete");fixSVZ("has");isMap&&fixSVZ("get")}if(buggyZero||chain!==inst)fixSVZ(ADDER,true)}setToStringTag(C,NAME);setSpecies(C);O[NAME]=C;$define(GLOBAL+WRAP+FORCED*!isNative(C),O);isWeak||defineStdIterators(C,NAME,function(iterated,kind){set(this,ITER,{o:iterated,k:kind})},function(){var iter=this[ITER],kind=iter.k,entry=iter.l;while(entry&&entry.r)entry=entry.p;if(!iter.o||!(iter.l=entry=entry?entry.n:iter.o[FIRST])){iter.o=undefined;return iterResult(1)}if(kind==KEY)return iterResult(0,entry.k);if(kind==VALUE)return iterResult(0,entry.v);return iterResult(0,[entry.k,entry.v])},isMap?KEY+VALUE:VALUE,!isMap);return C}function fastKey(it,create){if(!isObject(it))return(typeof it=="string"?"S":"P")+it;if(isFrozen(it))return"F";if(!has(it,UID)){if(!create)return"E";hidden(it,UID,++uid)}return"O"+it[UID]}function getEntry(that,key){var index=fastKey(key),entry;if(index!="F")return that[O1][index];for(entry=that[FIRST];entry;entry=entry.n){if(entry.k==key)return entry}}function def(that,key,value){var entry=getEntry(that,key),prev,index;if(entry)entry.v=value;else{that[LAST]=entry={i:index=fastKey(key,true),k:key,v:value,p:prev=that[LAST],n:undefined,r:false};if(!that[FIRST])that[FIRST]=entry;if(prev)prev.n=entry;that[SIZE]++;if(index!="F")that[O1][index]=entry}return that}var collectionMethods={clear:function(){for(var that=this,data=that[O1],entry=that[FIRST];entry;entry=entry.n){entry.r=true;if(entry.p)entry.p=entry.p.n=undefined;delete data[entry.i]}that[FIRST]=that[LAST]=undefined;that[SIZE]=0},"delete":function(key){var that=this,entry=getEntry(that,key);if(entry){var next=entry.n,prev=entry.p;delete that[O1][entry.i];entry.r=true;if(prev)prev.n=next;if(next)next.p=prev;if(that[FIRST]==entry)that[FIRST]=next;if(that[LAST]==entry)that[LAST]=prev;that[SIZE]--}return!!entry},forEach:function(callbackfn){var f=ctx(callbackfn,arguments[1],3),entry;while(entry=entry?entry.n:this[FIRST]){f(entry.v,entry.k,this);while(entry&&entry.r)entry=entry.p}},has:function(key){return!!getEntry(this,key)}};Map=getCollection(Map,MAP,{get:function(key){var entry=getEntry(this,key);return entry&&entry.v},set:function(key,value){return def(this,key===0?0:key,value)}},collectionMethods,true);Set=getCollection(Set,SET,{add:function(value){return def(this,value=value===0?0:value,value)}},collectionMethods);function defWeak(that,key,value){if(isFrozen(assertObject(key)))leakStore(that).set(key,value);else{has(key,WEAK)||hidden(key,WEAK,{});key[WEAK][that[UID]]=value}return that}function leakStore(that){return that[LEAK]||hidden(that,LEAK,new Map)[LEAK]}var weakMethods={"delete":function(key){if(!isObject(key))return false;if(isFrozen(key))return leakStore(this)["delete"](key);return has(key,WEAK)&&has(key[WEAK],this[UID])&&delete key[WEAK][this[UID]]},has:function(key){if(!isObject(key))return false;if(isFrozen(key))return leakStore(this).has(key); | ||
return has(key,WEAK)&&has(key[WEAK],this[UID])}};WeakMap=getCollection(WeakMap,WEAKMAP,{get:function(key){if(isObject(key)){if(isFrozen(key))return leakStore(this).get(key);if(has(key,WEAK))return key[WEAK][this[UID]]}},set:function(key,value){return defWeak(this,key,value)}},weakMethods,true,true);if(framework&&(new WeakMap).set(Object.freeze(tmp),7).get(tmp)!=7){forEach.call(array("delete,has,get,set"),function(key){var method=WeakMap[PROTOTYPE][key];WeakMap[PROTOTYPE][key]=function(a,b){if(isObject(a)&&isFrozen(a)){var result=leakStore(this)[key](a,b);return key=="set"?this:result}return method.call(this,a,b)}})}WeakSet=getCollection(WeakSet,WEAKSET,{add:function(value){return defWeak(this,value,true)}},weakMethods,false,true)}();!function(){function Enumerate(iterated){var keys=[],key;for(key in iterated)keys.push(key);set(this,ITER,{o:iterated,a:keys,i:0})}createIterator(Enumerate,OBJECT,function(){var iter=this[ITER],keys=iter.a,key;do{if(iter.i>=keys.length)return iterResult(1)}while(!((key=keys[iter.i++])in iter.o));return iterResult(0,key)});function wrap(fn){return function(it){assertObject(it);try{return fn.apply(undefined,arguments),true}catch(e){return false}}}function reflectGet(target,propertyKey){var receiver=arguments.length<3?target:arguments[2],desc=getOwnDescriptor(assertObject(target),propertyKey),proto;if(desc)return has(desc,"value")?desc.value:desc.get===undefined?undefined:desc.get.call(receiver);return isObject(proto=getPrototypeOf(target))?reflectGet(proto,propertyKey,receiver):undefined}function reflectSet(target,propertyKey,V){var receiver=arguments.length<4?target:arguments[3],ownDesc=getOwnDescriptor(assertObject(target),propertyKey),existingDescriptor,proto;if(!ownDesc){if(isObject(proto=getPrototypeOf(target))){return reflectSet(proto,propertyKey,V,receiver)}ownDesc=descriptor(0)}if(has(ownDesc,"value")){if(ownDesc.writable===false||!isObject(receiver))return false;existingDescriptor=getOwnDescriptor(receiver,propertyKey)||descriptor(0);existingDescriptor.value=V;return defineProperty(receiver,propertyKey,existingDescriptor),true}return ownDesc.set===undefined?false:(ownDesc.set.call(receiver,V),true)}var isExtensible=Object.isExtensible||returnIt;var reflect={apply:ctx(call,apply,3),construct:construct,defineProperty:wrap(defineProperty),deleteProperty:function(target,propertyKey){var desc=getOwnDescriptor(assertObject(target),propertyKey);return desc&&!desc.configurable?false:delete target[propertyKey]},enumerate:function(target){return new Enumerate(assertObject(target))},get:reflectGet,getOwnPropertyDescriptor:function(target,propertyKey){return getOwnDescriptor(assertObject(target),propertyKey)},getPrototypeOf:function(target){return getPrototypeOf(assertObject(target))},has:function(target,propertyKey){return propertyKey in target},isExtensible:function(target){return!!isExtensible(assertObject(target))},ownKeys:ownKeys,preventExtensions:wrap(Object.preventExtensions||returnIt),set:reflectSet};if(setPrototypeOf)reflect.setPrototypeOf=function(target,proto){return setPrototypeOf(assertObject(target),proto),true};$define(GLOBAL,{Reflect:{}});$define(STATIC,"Reflect",reflect)}();!function(){$define(PROTO,ARRAY,{includes:createArrayContains(true)});$define(PROTO,STRING,{at:createPointAt(true)});function createObjectToArray(isEntries){return function(object){var O=toObject(object),keys=getKeys(object),length=keys.length,i=0,result=Array(length),key;if(isEntries)while(length>i)result[i]=[key=keys[i++],O[key]];else while(length>i)result[i]=O[keys[i++]];return result}}$define(STATIC,OBJECT,{values:createObjectToArray(false),entries:createObjectToArray(true)});$define(STATIC,REGEXP,{escape:createReplacer(/([\\\-[\]{}()*+?.,^$|])/g,"\\$1",true)})}();!function(REFERENCE){REFERENCE_GET=getWellKnownSymbol(REFERENCE+"Get",true);var REFERENCE_SET=getWellKnownSymbol(REFERENCE+SET,true),REFERENCE_DELETE=getWellKnownSymbol(REFERENCE+"Delete",true);$define(STATIC,SYMBOL,{referenceGet:REFERENCE_GET,referenceSet:REFERENCE_SET,referenceDelete:REFERENCE_DELETE});hidden(FunctionProto,REFERENCE_GET,returnThis);function setMapMethods(Constructor){if(Constructor){var MapProto=Constructor[PROTOTYPE];hidden(MapProto,REFERENCE_GET,MapProto.get);hidden(MapProto,REFERENCE_SET,MapProto.set);hidden(MapProto,REFERENCE_DELETE,MapProto["delete"])}}setMapMethods(Map);setMapMethods(WeakMap)}("reference");!function(arrayStatics){function setArrayStatics(keys,length){forEach.call(array(keys),function(key){if(key in ArrayProto)arrayStatics[key]=ctx(call,ArrayProto[key],length)})}setArrayStatics("pop,reverse,shift,keys,values,entries",1);setArrayStatics("indexOf,every,some,forEach,map,filter,find,findIndex,includes",3);setArrayStatics("join,slice,concat,push,splice,unshift,sort,lastIndexOf,"+"reduce,reduceRight,copyWithin,fill,turn");$define(STATIC,ARRAY,arrayStatics)}({});!function(NodeList){if(framework&&NodeList&&!(SYMBOL_ITERATOR in NodeList[PROTOTYPE])){hidden(NodeList[PROTOTYPE],SYMBOL_ITERATOR,Iterators[ARRAY])}Iterators.NodeList=Iterators[ARRAY]}(global.NodeList)}(typeof self!="undefined"&&self.Math===Math?self:Function("return this")(),true)},{}],3:[function(require,module,exports){(function(global){!function(global){"use strict";var hasOwn=Object.prototype.hasOwnProperty;var undefined;var iteratorSymbol=typeof Symbol==="function"&&Symbol.iterator||"@@iterator";var inModule=typeof module==="object";var runtime=global.regeneratorRuntime;if(runtime){if(inModule){module.exports=runtime}return}runtime=global.regeneratorRuntime=inModule?module.exports:{};function wrap(innerFn,outerFn,self,tryLocsList){return new Generator(innerFn,outerFn,self||null,tryLocsList||[])}runtime.wrap=wrap;function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}var GenStateSuspendedStart="suspendedStart";var GenStateSuspendedYield="suspendedYield";var GenStateExecuting="executing";var GenStateCompleted="completed";var ContinueSentinel={};function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype;GeneratorFunction.prototype=Gp.constructor=GeneratorFunctionPrototype;GeneratorFunctionPrototype.constructor=GeneratorFunction;GeneratorFunction.displayName="GeneratorFunction";runtime.isGeneratorFunction=function(genFun){var ctor=typeof genFun==="function"&&genFun.constructor;return ctor?ctor===GeneratorFunction||(ctor.displayName||ctor.name)==="GeneratorFunction":false};runtime.mark=function(genFun){genFun.__proto__=GeneratorFunctionPrototype;genFun.prototype=Object.create(Gp);return genFun};runtime.async=function(innerFn,outerFn,self,tryLocsList){return new Promise(function(resolve,reject){var generator=wrap(innerFn,outerFn,self,tryLocsList);var callNext=step.bind(generator.next);var callThrow=step.bind(generator["throw"]);function step(arg){var record=tryCatch(this,null,arg);if(record.type==="throw"){reject(record.arg);return}var info=record.arg;if(info.done){resolve(info.value)}else{Promise.resolve(info.value).then(callNext,callThrow)}}callNext()})};function Generator(innerFn,outerFn,self,tryLocsList){var generator=outerFn?Object.create(outerFn.prototype):this;var context=new Context(tryLocsList);var state=GenStateSuspendedStart;function invoke(method,arg){if(state===GenStateExecuting){throw new Error("Generator is already running")}if(state===GenStateCompleted){return doneResult()}while(true){var delegate=context.delegate;if(delegate){var record=tryCatch(delegate.iterator[method],delegate.iterator,arg);if(record.type==="throw"){context.delegate=null;method="throw";arg=record.arg;continue}method="next";arg=undefined;var info=record.arg;if(info.done){context[delegate.resultName]=info.value;context.next=delegate.nextLoc}else{state=GenStateSuspendedYield;return info}context.delegate=null}if(method==="next"){if(state===GenStateSuspendedStart&&typeof arg!=="undefined"){throw new TypeError("attempt to send "+JSON.stringify(arg)+" to newborn generator")}if(state===GenStateSuspendedYield){context.sent=arg}else{delete context.sent}}else if(method==="throw"){if(state===GenStateSuspendedStart){state=GenStateCompleted;throw arg}if(context.dispatchException(arg)){method="next";arg=undefined}}else if(method==="return"){context.abrupt("return",arg)}state=GenStateExecuting;var record=tryCatch(innerFn,self,context);if(record.type==="normal"){state=context.done?GenStateCompleted:GenStateSuspendedYield;var info={value:record.arg,done:context.done};if(record.arg===ContinueSentinel){if(context.delegate&&method==="next"){arg=undefined}}else{return info}}else if(record.type==="throw"){state=GenStateCompleted;if(method==="next"){context.dispatchException(record.arg)}else{arg=record.arg}}}}generator.next=invoke.bind(generator,"next");generator["throw"]=invoke.bind(generator,"throw");generator["return"]=invoke.bind(generator,"return");return generator}Gp[iteratorSymbol]=function(){return this};Gp.toString=function(){return"[object Generator]"};function pushTryEntry(locs){var entry={tryLoc:locs[0]};if(1 in locs){entry.catchLoc=locs[1]}if(2 in locs){entry.finallyLoc=locs[2];entry.afterLoc=locs[3]}this.tryEntries.push(entry)}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal";delete record.arg;entry.completion=record}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}];tryLocsList.forEach(pushTryEntry,this);this.reset()}runtime.keys=function(object){var keys=[];for(var key in object){keys.push(key)}keys.reverse();return function next(){while(keys.length){var key=keys.pop();if(key in object){next.value=key;next.done=false;return next}}next.done=true;return next}};function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod){return iteratorMethod.call(iterable)}if(typeof iterable.next==="function"){return iterable}if(!isNaN(iterable.length)){var i=-1,next=function next(){while(++i<iterable.length){if(hasOwn.call(iterable,i)){next.value=iterable[i];next.done=false;return next}}next.value=undefined;next.done=true;return next};return next.next=next}}return{next:doneResult}}runtime.values=values;function doneResult(){return{value:undefined,done:true}}Context.prototype={constructor:Context,reset:function(){this.prev=0;this.next=0;this.sent=undefined;this.done=false;this.delegate=null;this.tryEntries.forEach(resetTryEntry);for(var tempIndex=0,tempName;hasOwn.call(this,tempName="t"+tempIndex)||tempIndex<20;++tempIndex){this[tempName]=null}},stop:function(){this.done=true;var rootEntry=this.tryEntries[0];var rootRecord=rootEntry.completion;if(rootRecord.type==="throw"){throw rootRecord.arg}return this.rval},dispatchException:function(exception){if(this.done){throw exception}var context=this;function handle(loc,caught){record.type="throw";record.arg=exception;context.next=loc;return!!caught}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];var record=entry.completion;if(entry.tryLoc==="root"){return handle("end")}if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc");var hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc){return handle(entry.catchLoc,true)}else if(this.prev<entry.finallyLoc){return handle(entry.finallyLoc)}}else if(hasCatch){if(this.prev<entry.catchLoc){return handle(entry.catchLoc,true)}}else if(hasFinally){if(this.prev<entry.finallyLoc){return handle(entry.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},_findFinallyEntry:function(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&(entry.finallyLoc===finallyLoc||this.prev<entry.finallyLoc)){return entry}}},abrupt:function(type,arg){var entry=this._findFinallyEntry();var record=entry?entry.completion:{};record.type=type;record.arg=arg;if(entry){this.next=entry.finallyLoc}else{this.complete(record)}return ContinueSentinel},complete:function(record,afterLoc){if(record.type==="throw"){throw record.arg}if(record.type==="break"||record.type==="continue"){this.next=record.arg}else if(record.type==="return"){this.rval=record.arg;this.next="end"}else if(record.type==="normal"&&afterLoc){this.next=afterLoc}return ContinueSentinel},finish:function(finallyLoc){var entry=this._findFinallyEntry(finallyLoc);return this.complete(entry.completion,entry.afterLoc)},"catch":function(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if(record.type==="throw"){var thrown=record.arg;resetTryEntry(entry)}return thrown}}throw new Error("illegal catch attempt")},delegateYield:function(iterable,resultName,nextLoc){this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc};return ContinueSentinel}}}(typeof global==="object"?global:typeof window==="object"?window:this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[1]); |
# Contributing | ||
Contributions are always welcome, no matter how large or small. Before contributing, please read the [code of conduct](https://github.com/6to5/6to5/blob/master/CODE_OF_CONDUCT.md). | ||
Contributions are always welcome, no matter how large or small. Before | ||
contributing, please read the | ||
[code of conduct](https://github.com/6to5/6to5/blob/master/CODE_OF_CONDUCT.md). | ||
**NOTE:** Please do not send pull requests that fix linting issues. It's highly | ||
likely that they've already been fixed by the time it's submitted and it just | ||
pollutes the git tree. | ||
## Developing | ||
@@ -15,3 +21,4 @@ | ||
* Ensure the test are passing (`make test`) | ||
* Create new pull request explaining your proposed change or reference an issue in your commit message | ||
* Create new pull request explaining your proposed change or reference an issue | ||
in your commit message | ||
@@ -18,0 +25,0 @@ #### Code Standards |
var t = require("../types"); | ||
var _ = require("lodash"); | ||
var includes = require("lodash/collection/includes"); | ||
@@ -41,3 +41,3 @@ exports.AssignmentExpression = function (node, parent, detected) { | ||
exports.AssignmentPattern = function (node, parent, detected) { | ||
if (t.isFunction(parent) && _.contains(parent.params, node)) { | ||
if (t.isFunction(parent) && includes(parent.params, node)) { | ||
detected("es6.parameters.default"); | ||
@@ -44,0 +44,0 @@ } |
@@ -6,3 +6,3 @@ "use strict"; | ||
var isBoolean = require("lodash/lang/isBoolean"); | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var isNumber = require("lodash/lang/isNumber"); | ||
@@ -163,3 +163,3 @@ var util = require("../util"); | ||
if (Array.isArray(cha)) { | ||
return contains(cha, last); | ||
return includes(cha, last); | ||
} else { | ||
@@ -166,0 +166,0 @@ return cha === last; |
@@ -24,3 +24,3 @@ "use strict"; | ||
if (node.alternate) { | ||
if (this.isLast("}")) this.push(" "); | ||
if (this.isLast("}")) this.space(); | ||
this.keyword("else"); | ||
@@ -27,0 +27,0 @@ |
@@ -6,4 +6,2 @@ "use strict"; | ||
require("./types/node"); | ||
// estraverse | ||
@@ -10,0 +8,0 @@ |
@@ -11,3 +11,3 @@ "use strict"; | ||
var defaults = require("lodash/object/defaults"); | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var clone = require("../helpers/clone"); | ||
@@ -45,2 +45,3 @@ var parse = require("../helpers/parse"); | ||
"to-array", | ||
"to-consumable-array", | ||
"sliced-to-array", | ||
@@ -128,3 +129,6 @@ "object-without-properties", | ||
// normalize windows path separators to unix | ||
opts.filename = opts.filename.replace(/\\/g, "/"); | ||
opts.filename = util.normalisePathSeparator(opts.filename); | ||
if (opts.sourceRoot) { | ||
opts.sourceRoot = util.normalisePathSeparator(opts.sourceRoot); | ||
} | ||
@@ -138,3 +142,3 @@ opts.basename = path.basename(opts.filename, path.extname(opts.filename)); | ||
if (contains(opts.loose, "all")) { | ||
if (includes(opts.loose, "all") || includes(opts.loose, true)) { | ||
opts.loose = Object.keys(transform.transformers); | ||
@@ -179,2 +183,11 @@ } | ||
var ensureEnabled = function (key) { | ||
var namespace = transform.transformerNamespaces[key]; | ||
if (namespace === "es7") opts.experimental = true; | ||
if (namespace === "playground") opts.playground = true; | ||
}; | ||
each(opts.whitelist, ensureEnabled); | ||
each(opts.optional, ensureEnabled); | ||
return opts; | ||
@@ -184,3 +197,3 @@ }; | ||
File.prototype.isLoose = function (key) { | ||
return contains(this.opts.loose, key); | ||
return includes(this.opts.loose, key); | ||
}; | ||
@@ -222,18 +235,2 @@ | ||
File.prototype.toArray = function (node, i) { | ||
if (t.isArrayExpression(node)) { | ||
return node; | ||
} else if (t.isIdentifier(node) && node.name === "arguments") { | ||
return t.callExpression(t.memberExpression(this.addHelper("slice"), t.identifier("call")), [node]); | ||
} else { | ||
var declarationName = "to-array"; | ||
var args = [node]; | ||
if (i) { | ||
args.push(t.literal(i)); | ||
declarationName = "sliced-to-array"; | ||
} | ||
return t.callExpression(this.addHelper(declarationName), args); | ||
} | ||
}; | ||
File.prototype.getModuleFormatter = function (type) { | ||
@@ -309,3 +306,3 @@ var ModuleFormatter = isFunction(type) ? type : transform.moduleFormatters[type]; | ||
File.prototype.addHelper = function (name) { | ||
if (!contains(File.helpers, name)) { | ||
if (!includes(File.helpers, name)) { | ||
throw new ReferenceError("Unknown helper " + name); | ||
@@ -336,2 +333,6 @@ } | ||
File.prototype.logDeopt = function () { | ||
// todo, (node, msg) | ||
}; | ||
File.prototype.errorWithNode = function (node, msg, Error) { | ||
@@ -465,3 +466,3 @@ Error = Error || SyntaxError; | ||
i++; | ||
} while (scope.hasReference(uid)); | ||
} while (scope.hasBinding(uid) || scope.hasGlobal(uid)); | ||
return uid; | ||
@@ -473,3 +474,3 @@ }; | ||
var id = t.identifier(this.generateUid(name, scope)); | ||
scope.addDeclarationToFunctionScope("var", id); | ||
scope.getFunctionParent().registerBinding("uid", id); | ||
return id; | ||
@@ -476,0 +477,0 @@ }; |
@@ -9,2 +9,3 @@ "use strict"; | ||
var isString = require("lodash/lang/isString"); | ||
var messages = require("../../messages"); | ||
var esutils = require("esutils"); | ||
@@ -32,3 +33,3 @@ var react = require("./react"); | ||
exports.JSXNamespacedName = function (node, parent, scope, file) { | ||
throw file.errorWithNode(node, "Namespace tags are not supported. ReactJSX is not XML."); | ||
throw file.errorWithNode(node, messages.get("JSXNamespacedTags")); | ||
}; | ||
@@ -35,0 +36,0 @@ |
@@ -21,3 +21,3 @@ "use strict"; | ||
if (t.isIdentifier(ref) && scope.hasReference(ref.name)) { | ||
if (t.isIdentifier(ref) && scope.hasGlobal(ref.name)) { | ||
// the object reference that we need to save is locally declared | ||
@@ -24,0 +24,0 @@ // so as per the previous comment we can be 100% sure evaluating |
@@ -16,3 +16,3 @@ "use strict"; | ||
// for the wrapper | ||
var localDeclar = scope.getBinding(state.id); | ||
var localDeclar = scope.getBindingIdentifier(state.id); | ||
if (localDeclar !== state.outerDeclar) return; | ||
@@ -35,3 +35,3 @@ | ||
selfReference: false, | ||
outerDeclar: scope.getBinding(id), | ||
outerDeclar: scope.getBindingIdentifier(id), | ||
}; | ||
@@ -38,0 +38,0 @@ |
@@ -5,3 +5,4 @@ "use strict"; | ||
var t = require("../../types"); | ||
var messages = require("../../messages"); | ||
var t = require("../../types"); | ||
@@ -236,3 +237,3 @@ /** | ||
if (isIllegalBareSuper(node, parent)) { | ||
throw this.file.errorWithNode(node, "Illegal use of bare super"); | ||
throw this.file.errorWithNode(node, messages.get("classesIllegalBareSuper")); | ||
} | ||
@@ -253,3 +254,3 @@ | ||
var methodName = methodNode.key.name || "METHOD_NAME"; | ||
throw this.file.errorWithNode(node, "Direct super call is illegal in non-constructor, use super." + methodName + "() instead"); | ||
throw this.file.errorWithNode(node, messages.get("classesIllegalSuperCall", methodName)); | ||
} | ||
@@ -256,0 +257,0 @@ } else if (t.isMemberExpression(callee) && isSuper(callee.object, callee)) { |
@@ -59,4 +59,5 @@ "use strict"; | ||
transform.transformers = object(); | ||
transform.namespaces = object(); | ||
transform.transformerNamespaces = object(); | ||
transform.transformers = object(); | ||
transform.namespaces = object(); | ||
@@ -70,6 +71,8 @@ transform.deprecatedTransformerMap = require("./transformers/deprecated"); | ||
var namespace = key.split(".")[0]; | ||
transform.namespaces[namespace] = transform.namespaces[namespace] || []; | ||
transform.namespaces[namespace].push(key); | ||
transform.transformerNamespaces[key] = namespace; | ||
transform.transformers[key] = new Transformer(key, transformer); | ||
}); |
@@ -5,6 +5,7 @@ "use strict"; | ||
var messages = require("../../messages"); | ||
var extend = require("lodash/object/extend"); | ||
var object = require("../../helpers/object"); | ||
var util = require("../../util"); | ||
var t = require("../../types"); | ||
var extend = require("lodash/object/extend"); | ||
@@ -128,9 +129,2 @@ function DefaultFormatter(file) { | ||
DefaultFormatter.prototype.checkLocalReference = function (node) { | ||
var file = this.file; | ||
if (this.isLocalReference(node)) { | ||
throw file.errorWithNode(node, "Illegal assignment of module import"); | ||
} | ||
}; | ||
DefaultFormatter.prototype.remapExportAssignment = function (node) { | ||
@@ -151,3 +145,3 @@ return t.assignmentExpression( | ||
var name = node.name; | ||
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.getBinding(name); | ||
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.getBindingIdentifier(name); | ||
}; | ||
@@ -219,3 +213,3 @@ | ||
if (t.isIdentifier(node, { name: "__esModule" })) { | ||
throw this.file.errorWithNode(node, "Illegal export __esModule - this is used internally for CommonJS interop"); | ||
throw this.file.errorWithNode(node, messages.get("modulesIllegalExportName", node.name)); | ||
} | ||
@@ -222,0 +216,0 @@ }; |
@@ -9,3 +9,3 @@ "use strict"; | ||
var t = require("../../types"); | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var values = require("lodash/object/values"); | ||
@@ -85,3 +85,3 @@ | ||
if (contains(this.file.dynamicImported, node)) { | ||
if (includes(this.file.dynamicImported, node)) { | ||
// Prevent unnecessary renaming of dynamic imports. | ||
@@ -88,0 +88,0 @@ this.ids[node.source.value] = ref; |
@@ -6,3 +6,3 @@ "use strict"; | ||
var DefaultFormatter = require("./_default"); | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var util = require("../../util"); | ||
@@ -18,4 +18,9 @@ var t = require("../../types"); | ||
CommonJSFormatter.prototype.init = function () { | ||
var file = this.file; | ||
var scope = file.scope; | ||
scope.rename("module"); | ||
if (!this.noInteropRequireImport && this.hasNonDefaultExports) { | ||
this.file.ast.program.body.push(util.template("exports-module-declaration", true)); | ||
file.ast.program.body.push(util.template("exports-module-declaration", true)); | ||
} | ||
@@ -31,3 +36,3 @@ }; | ||
if (t.isSpecifierDefault(specifier)) { | ||
if (!contains(this.file.dynamicImported, node)) { | ||
if (!includes(this.file.dynamicImported, node)) { | ||
if (this.noInteropRequireImport) { | ||
@@ -34,0 +39,0 @@ ref = t.memberExpression(ref, t.identifier("default")); |
module.exports = TransformerPass; | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
@@ -28,10 +28,10 @@ /** | ||
var blacklist = opts.blacklist; | ||
if (blacklist.length && contains(blacklist, key)) return false; | ||
if (blacklist.length && includes(blacklist, key)) return false; | ||
// whitelist | ||
var whitelist = opts.whitelist; | ||
if (whitelist.length) return contains(whitelist, key); | ||
if (whitelist.length) return includes(whitelist, key); | ||
// optional | ||
if (transformer.optional && !contains(opts.optional, key)) return false; | ||
if (transformer.optional && !includes(opts.optional, key)) return false; | ||
@@ -38,0 +38,0 @@ // experimental |
@@ -13,3 +13,3 @@ "use strict"; | ||
// declared node is different in this scope | ||
if (scope.getBinding(node.name) !== declared) return; | ||
if (scope.getBindingIdentifier(node.name) !== declared) return; | ||
@@ -16,0 +16,0 @@ var assert = t.callExpression( |
@@ -139,3 +139,3 @@ "use strict"; | ||
var ownBinding = scope.getBinding(node.name); | ||
var ownBinding = scope.getBindingIdentifier(node.name); | ||
if (ownBinding === remap.binding) { | ||
@@ -179,3 +179,3 @@ node.name = remap.uid; | ||
if (scope.parentHasReference(key)) { | ||
if (scope.parentHasBinding(key) || scope.hasGlobal(key)) { | ||
var uid = scope.generateUidIdentifier(ref.name).name; | ||
@@ -182,0 +182,0 @@ ref.name = uid; |
@@ -6,2 +6,3 @@ "use strict"; | ||
var defineMap = require("../../helpers/define-map"); | ||
var messages = require("../../../messages"); | ||
var util = require("../../../util"); | ||
@@ -13,3 +14,3 @@ var t = require("../../../types"); | ||
exports.ClassDeclaration = function (node, parent, scope, file) { | ||
return new Class(node, file, scope, true).run(); | ||
return new ClassTransformer(node, file, scope, true).run(); | ||
}; | ||
@@ -30,3 +31,3 @@ | ||
return new Class(node, file, scope, false).run(); | ||
return new ClassTransformer(node, file, scope, false).run(); | ||
}; | ||
@@ -43,3 +44,3 @@ | ||
function Class(node, file, scope, isStatement) { | ||
function ClassTransformer(node, file, scope, isStatement) { | ||
this.isStatement = isStatement; | ||
@@ -68,3 +69,3 @@ this.scope = scope; | ||
Class.prototype.run = function () { | ||
ClassTransformer.prototype.run = function () { | ||
var superName = this.superName; | ||
@@ -146,3 +147,3 @@ var className = this.className; | ||
Class.prototype.buildBody = function () { | ||
ClassTransformer.prototype.buildBody = function () { | ||
var constructor = this.constructor; | ||
@@ -176,2 +177,4 @@ var className = this.className; | ||
body.unshift(node); | ||
} else if (t.isClassProperty(node)) { | ||
this.pushProperty(node); | ||
} | ||
@@ -219,3 +222,3 @@ } | ||
Class.prototype.pushMethod = function (node) { | ||
ClassTransformer.prototype.pushMethod = function (node) { | ||
var methodName = node.key; | ||
@@ -257,2 +260,26 @@ | ||
/** | ||
* Description | ||
* | ||
* @param {Node} node | ||
*/ | ||
ClassTransformer.prototype.pushProperty = function (node) { | ||
if (!node.value) return; | ||
var key; | ||
if (node.static) { | ||
key = t.memberExpression(this.className, node.key); | ||
this.body.push( | ||
t.expressionStatement(t.assignmentExpression("=", key, node.value)) | ||
); | ||
} else { | ||
key = t.memberExpression(t.thisExpression(), node.key); | ||
this.constructor.body.body.unshift( | ||
t.expressionStatement(t.assignmentExpression("=", key, node.value)) | ||
); | ||
} | ||
}; | ||
/** | ||
* Replace the constructor body of our class. | ||
@@ -263,5 +290,5 @@ * | ||
Class.prototype.pushConstructor = function (method) { | ||
ClassTransformer.prototype.pushConstructor = function (method) { | ||
if (method.kind) { | ||
throw this.file.errorWithNode(method, "illegal kind for constructor method"); | ||
throw this.file.errorWithNode(method, messages.get("classesIllegalConstructorKind")); | ||
} | ||
@@ -268,0 +295,0 @@ |
"use strict"; | ||
var t = require("../../../types"); | ||
var messages = require("../../../messages"); | ||
var t = require("../../../types"); | ||
@@ -14,6 +15,6 @@ exports.check = function (node) { | ||
for (var key in ids) { | ||
var id = ids[key]; | ||
for (var name in ids) { | ||
var id = ids[name]; | ||
var constant = state.constants[key]; | ||
var constant = state.constants[name]; | ||
@@ -23,13 +24,15 @@ // no constant exists | ||
var constantIdentifier = constant.identifier; | ||
// check if the assignment id matches the constant declaration id | ||
// if it does then it was the id used to initially declare the | ||
// constant so we can just ignore it | ||
if (id === constant) continue; | ||
if (id === constantIdentifier) continue; | ||
// check if there's been a local binding that shadows this constant | ||
if (!scope.bindingEquals(key, constant)) continue; | ||
if (!scope.bindingIdentifierEquals(name, constantIdentifier)) continue; | ||
throw state.file.errorWithNode(id, key + " is read-only"); | ||
throw state.file.errorWithNode(id, messages.get("readOnly", name)); | ||
} | ||
} else if (t.isScope(node)) { | ||
} else if (t.isScope(node, parent)) { | ||
this.skip(); | ||
@@ -40,5 +43,5 @@ } | ||
exports.Scope = function (node, parent, scope, file) { | ||
exports.Scopable = function (node, parent, scope, file) { | ||
scope.traverse(node, visitor, { | ||
constants: scope.getAllDeclarationsOfKind("const"), | ||
constants: scope.getAllBindingsOfKind("const"), | ||
file: file | ||
@@ -45,0 +48,0 @@ }); |
"use strict"; | ||
var t = require("../../../types"); | ||
var messages = require("../../../messages"); | ||
var t = require("../../../types"); | ||
exports.check = t.isPattern; | ||
function Destructuring(opts) { | ||
function DestructuringTransformer(opts) { | ||
this.blockHoist = opts.blockHoist; | ||
@@ -16,3 +17,3 @@ this.operator = opts.operator; | ||
Destructuring.prototype.buildVariableAssignment = function (id, init) { | ||
DestructuringTransformer.prototype.buildVariableAssignment = function (id, init) { | ||
var op = this.operator; | ||
@@ -36,3 +37,3 @@ if (t.isMemberExpression(id)) op = "="; | ||
Destructuring.prototype.buildVariableDeclaration = function (id, init) { | ||
DestructuringTransformer.prototype.buildVariableDeclaration = function (id, init) { | ||
var declar = t.variableDeclaration("var", [ | ||
@@ -45,3 +46,3 @@ t.variableDeclarator(id, init) | ||
Destructuring.prototype.push = function (elem, parentId) { | ||
DestructuringTransformer.prototype.push = function (elem, parentId) { | ||
if (t.isObjectPattern(elem)) { | ||
@@ -58,3 +59,3 @@ this.pushObjectPattern(elem, parentId); | ||
Destructuring.prototype.pushAssignmentPattern = function (pattern, parentId) { | ||
DestructuringTransformer.prototype.pushAssignmentPattern = function (pattern, parentId) { | ||
var tempParentId = this.scope.generateUidBasedOnNode(parentId); | ||
@@ -78,3 +79,3 @@ | ||
Destructuring.prototype.pushObjectSpread = function (pattern, parentId, prop, i) { | ||
DestructuringTransformer.prototype.pushObjectSpread = function (pattern, parentId, prop, i) { | ||
// get all the keys that appear in this object before the current spread | ||
@@ -100,3 +101,3 @@ var keys = []; | ||
Destructuring.prototype.pushObjectProperty = function (prop, parentId) { | ||
DestructuringTransformer.prototype.pushObjectProperty = function (prop, parentId) { | ||
if (t.isLiteral(prop.key)) prop.computed = true; | ||
@@ -114,3 +115,3 @@ | ||
Destructuring.prototype.pushObjectPattern = function (pattern, parentId) { | ||
DestructuringTransformer.prototype.pushObjectPattern = function (pattern, parentId) { | ||
if (!pattern.properties.length) { | ||
@@ -147,3 +148,3 @@ this.nodes.push(t.expressionStatement( | ||
Destructuring.prototype.pushArrayPattern = function (pattern, parentId) { | ||
DestructuringTransformer.prototype.pushArrayPattern = function (pattern, parentId) { | ||
if (!pattern.elements) return; | ||
@@ -154,8 +155,10 @@ | ||
var toArray = this.file.toArray(parentId, count); | ||
var toArray = this.scope.toArray(parentId, count); | ||
var _parentId = this.scope.generateUidBasedOnNode(parentId, this.file); | ||
var _parentId = this.scope.generateUidBasedOnNode(parentId); | ||
this.nodes.push(this.buildVariableDeclaration(_parentId, toArray)); | ||
parentId = _parentId; | ||
this.scope.assignTypeGeneric(parentId.name, "Array"); | ||
for (var i = 0; i < pattern.elements.length; i++) { | ||
@@ -170,3 +173,3 @@ var elem = pattern.elements[i]; | ||
if (t.isRestElement(elem)) { | ||
newPatternId = this.file.toArray(parentId); | ||
newPatternId = this.scope.toArray(parentId); | ||
@@ -186,3 +189,3 @@ if (i > 0) { | ||
Destructuring.prototype.init = function (pattern, parentId) { | ||
DestructuringTransformer.prototype.init = function (pattern, parentId) { | ||
if (!t.isArrayExpression(parentId) && !t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) { | ||
@@ -231,3 +234,3 @@ var key = this.scope.generateUidBasedOnNode(parentId); | ||
var destructuring = new Destructuring({ | ||
var destructuring = new DestructuringTransformer({ | ||
kind: left.kind, | ||
@@ -250,3 +253,3 @@ file: file, | ||
var hasDestructuring = false; | ||
var hasDestructuringTransformer = false; | ||
@@ -256,6 +259,6 @@ node.params = node.params.map(function (pattern, i) { | ||
hasDestructuring = true; | ||
hasDestructuringTransformer = true; | ||
var parentId = scope.generateUidIdentifier("ref"); | ||
var destructuring = new Destructuring({ | ||
var destructuring = new DestructuringTransformer({ | ||
blockHoist: node.params.length - i, | ||
@@ -272,3 +275,3 @@ nodes: nodes, | ||
if (!hasDestructuring) return; | ||
if (!hasDestructuringTransformer) return; | ||
@@ -290,3 +293,3 @@ t.ensureBlock(node); | ||
var destructuring = new Destructuring({ | ||
var destructuring = new DestructuringTransformer({ | ||
kind: "let", | ||
@@ -317,3 +320,3 @@ file: file, | ||
var destructuring = new Destructuring({ | ||
var destructuring = new DestructuringTransformer({ | ||
operator: expr.operator, | ||
@@ -341,3 +344,3 @@ file: file, | ||
var destructuring = new Destructuring({ | ||
var destructuring = new DestructuringTransformer({ | ||
operator: node.operator, | ||
@@ -377,3 +380,3 @@ file: file, | ||
var destructuring = new Destructuring({ | ||
var destructuring = new DestructuringTransformer({ | ||
nodes: nodes, | ||
@@ -409,3 +412,3 @@ scope: scope, | ||
if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) { | ||
throw file.errorWithNode(node, "Cannot use this node within the current parent"); | ||
throw file.errorWithNode(node, messages.get("invalidParentForThisNode")); | ||
} | ||
@@ -412,0 +415,0 @@ |
"use strict"; | ||
var util = require("../../../util"); | ||
var t = require("../../../types"); | ||
var messages = require("../../../messages"); | ||
var util = require("../../../util"); | ||
var t = require("../../../types"); | ||
@@ -53,3 +54,3 @@ exports.check = t.isForOfStatement; | ||
} else { | ||
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement"); | ||
throw file.errorWithNode(left, messages.get("unknownForHead", left.type)); | ||
} | ||
@@ -93,3 +94,3 @@ | ||
} else { | ||
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement"); | ||
throw file.errorWithNode(left, messages.get("unknownForHead", left.type)); | ||
} | ||
@@ -96,0 +97,0 @@ |
@@ -21,3 +21,3 @@ "use strict"; | ||
if (!state.scope.hasOwnBinding(node.name)) return; | ||
if (state.scope.bindingEquals(node.name, node)) return; | ||
if (state.scope.bindingIdentifierEquals(node.name, node)) return; | ||
@@ -59,3 +59,5 @@ state.iife = true; | ||
if (!t.isAssignmentPattern(param)) { | ||
lastNonDefaultParam = i + 1; | ||
if (!t.isRestElement(param)) { | ||
lastNonDefaultParam = i + 1; | ||
} | ||
@@ -76,6 +78,8 @@ if (!t.isIdentifier(param)) { | ||
node.params[i] = scope.generateUidIdentifier("x"); | ||
var placeholder = scope.generateUidIdentifier("x"); | ||
placeholder._isDefaultPlaceholder = true; | ||
node.params[i] = placeholder; | ||
if (!state.iife) { | ||
if (t.isIdentifier(right) && scope.hasOwnReference(right.name)) { | ||
if (t.isIdentifier(right) && scope.hasOwnBinding(right.name)) { | ||
state.iife = true; | ||
@@ -82,0 +86,0 @@ } else { |
@@ -63,2 +63,4 @@ "use strict"; | ||
scope.assignTypeGeneric(rest.name, "Array"); | ||
var loop = util.template("rest", { | ||
@@ -65,0 +67,0 @@ ARGUMENTS: argsId, |
"use strict"; | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var t = require("../../../types"); | ||
@@ -8,4 +8,4 @@ | ||
var getSpreadLiteral = function (spread, file) { | ||
return file.toArray(spread.argument); | ||
var getSpreadLiteral = function (spread, scope) { | ||
return scope.toArray(spread.argument, true); | ||
}; | ||
@@ -22,3 +22,3 @@ | ||
var build = function (props, file) { | ||
var build = function (props, scope) { | ||
var nodes = []; | ||
@@ -38,3 +38,3 @@ | ||
push(); | ||
nodes.push(getSpreadLiteral(prop, file)); | ||
nodes.push(getSpreadLiteral(prop, scope)); | ||
} else { | ||
@@ -50,7 +50,7 @@ _props.push(prop); | ||
exports.ArrayExpression = function (node, parent, scope, file) { | ||
exports.ArrayExpression = function (node, parent, scope) { | ||
var elements = node.elements; | ||
if (!hasSpread(elements)) return; | ||
var nodes = build(elements, file); | ||
var nodes = build(elements, scope); | ||
var first = nodes.shift(); | ||
@@ -66,3 +66,3 @@ | ||
exports.CallExpression = function (node, parent, scope, file) { | ||
exports.CallExpression = function (node, parent, scope) { | ||
var args = node.arguments; | ||
@@ -79,3 +79,3 @@ if (!hasSpread(args)) return; | ||
} else { | ||
nodes = build(args, file); | ||
nodes = build(args, scope); | ||
} | ||
@@ -112,5 +112,5 @@ | ||
var nativeType = t.isIdentifier(node.callee) && contains(t.NATIVE_TYPE_NAMES, node.callee.name); | ||
var nativeType = t.isIdentifier(node.callee) && includes(t.NATIVE_TYPE_NAMES, node.callee.name); | ||
var nodes = build(args, file); | ||
var nodes = build(args, scope); | ||
@@ -117,0 +117,0 @@ if (nativeType) { |
"use strict"; | ||
var util = require("../../../util"); | ||
var t = require("../../../types"); | ||
var reduceRight = require("lodash/collection/reduceRight"); | ||
var messages = require("../../../messages"); | ||
var flatten = require("lodash/array/flatten"); | ||
var util = require("../../../util"); | ||
var map = require("lodash/collection/map"); | ||
var t = require("../../../types"); | ||
@@ -10,199 +14,347 @@ function returnBlock(expr) { | ||
function transformExpression(node, scope, state) { | ||
if (!node) return; | ||
function TailCallTransformer(node, scope, file) { | ||
this.hasTailRecursion = false; | ||
this.needsArguments = false; | ||
this.setsArguments = false; | ||
this.needsThis = false; | ||
this.ownerId = node.id; | ||
this.vars = []; | ||
return (function subTransform(node) { | ||
switch (node.type) { | ||
case "ConditionalExpression": | ||
var callConsequent = subTransform(node.consequent); | ||
var callAlternate = subTransform(node.alternate); | ||
if (!callConsequent && !callAlternate) { | ||
return; | ||
} | ||
this.scope = scope; | ||
this.file = file; | ||
this.node = node; | ||
} | ||
// if ternary operator had tail recursion in value, convert to optimized if-statement | ||
node.type = "IfStatement"; | ||
node.consequent = callConsequent ? t.toBlock(callConsequent) : returnBlock(node.consequent); | ||
if (callAlternate) { | ||
node.alternate = t.isIfStatement(callAlternate) ? callAlternate : t.toBlock(callAlternate); | ||
} else { | ||
node.alternate = returnBlock(node.alternate); | ||
} | ||
return node; | ||
TailCallTransformer.prototype.getArgumentsId = function () { | ||
return this.argumentsId = this.argumentsId || this.scope.generateUidIdentifier("arguments"); | ||
}; | ||
case "LogicalExpression": | ||
// only call in right-value of can be optimized | ||
var callRight = subTransform(node.right); | ||
if (!callRight) { | ||
return; | ||
} | ||
TailCallTransformer.prototype.getThisId = function () { | ||
return this.thisId = this.thisId || this.scope.generateUidIdentifier("this"); | ||
}; | ||
// cache left value as it might have side-effects | ||
var leftId = state.getLeftId(); | ||
var testExpr = t.assignmentExpression( | ||
"=", | ||
leftId, | ||
node.left | ||
); | ||
if (node.operator === "&&") { | ||
testExpr = t.unaryExpression("!", testExpr); | ||
} | ||
return [t.ifStatement(testExpr, returnBlock(leftId))].concat(callRight); | ||
TailCallTransformer.prototype.getLeftId = function () { | ||
return this.leftId = this.leftId || this.scope.generateUidIdentifier("left"); | ||
}; | ||
case "SequenceExpression": | ||
var seq = node.expressions; | ||
TailCallTransformer.prototype.getFunctionId = function () { | ||
return this.functionId = this.functionId || this.scope.generateUidIdentifier("function"); | ||
}; | ||
// only last element can be optimized | ||
var lastCall = subTransform(seq[seq.length - 1]); | ||
if (!lastCall) { | ||
return; | ||
} | ||
TailCallTransformer.prototype.getParams = function () { | ||
var params = this.params; | ||
// remove converted expression from sequence | ||
// and convert to regular expression if needed | ||
if (--seq.length === 1) { | ||
node = seq[0]; | ||
} | ||
if (!params) { | ||
params = this.node.params; | ||
this.paramDecls = []; | ||
return [t.expressionStatement(node)].concat(lastCall); | ||
for (var i = 0; i < params.length; i++) { | ||
var param = params[i]; | ||
if (!param._isDefaultPlaceholder) { | ||
this.paramDecls.push(t.variableDeclarator( | ||
param, | ||
params[i] = this.scope.generateUidIdentifier("x") | ||
)); | ||
} | ||
} | ||
} | ||
case "CallExpression": | ||
var callee = node.callee, prop, thisBinding, args; | ||
return this.params = params; | ||
}; | ||
if (t.isMemberExpression(callee, { computed: false }) && | ||
t.isIdentifier(prop = callee.property)) { | ||
switch (prop.name) { | ||
case "call": | ||
args = t.arrayExpression(node.arguments.slice(1)); | ||
break; | ||
TailCallTransformer.prototype.hasDeopt = function () { | ||
// check if the ownerId has been reassigned, if it has then it's not safe to | ||
// perform optimisations | ||
var ownerIdInfo = this.scope.getBindingInfo(this.ownerId.name); | ||
return ownerIdInfo && ownerIdInfo.reassigned; | ||
}; | ||
case "apply": | ||
args = node.arguments[1] || t.identifier("undefined"); | ||
break; | ||
TailCallTransformer.prototype.run = function () { | ||
var scope = this.scope; | ||
var node = this.node; | ||
default: | ||
return; | ||
} | ||
// only tail recursion can be optimized as for now, so we can skip anonymous | ||
// functions entirely | ||
var ownerId = this.ownerId; | ||
if (!ownerId) return; | ||
thisBinding = node.arguments[0]; | ||
callee = callee.object; | ||
} | ||
// traverse the function and look for tail recursion | ||
scope.traverse(node, firstPass, this); | ||
// only tail recursion can be optimized as for now | ||
if (!t.isIdentifier(callee) || !scope.bindingEquals(callee.name, state.ownerId)) { | ||
return; | ||
} | ||
if (!this.hasTailRecursion) return; | ||
state.hasTailRecursion = true; | ||
if (this.hasDeopt()) { | ||
this.file.logDeopt(node, messages.get("tailCallReassignmentDeopt")); | ||
return; | ||
} | ||
return [ | ||
t.expressionStatement(t.assignmentExpression( | ||
"=", | ||
state.getArgumentsId(), | ||
args || t.arrayExpression(node.arguments) | ||
)), | ||
// | ||
t.expressionStatement(t.assignmentExpression( | ||
"=", | ||
state.getThisId(), | ||
thisBinding || t.identifier("undefined") | ||
)), | ||
scope.traverse(node, secondPass, this); | ||
t.returnStatement(t.assignmentExpression( | ||
"=", | ||
state.getShouldContinueId(), | ||
t.literal(true) | ||
)) | ||
]; | ||
} | ||
})(node); | ||
} | ||
if (!this.needsThis || !this.needsArguments) { | ||
scope.traverse(node, thirdPass, this); | ||
} | ||
var functionChildrenVisitor = { | ||
enter: function (node, parent, scope, state) { | ||
if (t.isReturnStatement(node)) { | ||
// prevent entrance by current visitor | ||
this.skip(); | ||
// transform return argument into statement if | ||
// it contains tail recursion | ||
return transformExpression(node.argument, scope, state); | ||
} else if (t.isFunction(node)) { | ||
return this.skip(); | ||
} else if (t.isTryStatement(parent)) { | ||
if (node === parent.block) { | ||
return this.skip(); | ||
} else if (node === parent.finalizer) { | ||
return; | ||
} else { | ||
if (parent.finalizer) { | ||
this.skip(); | ||
} | ||
return; | ||
} | ||
var body = t.ensureBlock(node).body; | ||
if (this.vars.length > 0) { | ||
var declarations = flatten(map(this.vars, function (decl) { | ||
return decl.declarations; | ||
}, this)); | ||
var statement = reduceRight(declarations, function (expr, decl) { | ||
return t.assignmentExpression("=", decl.id, expr); | ||
}, t.identifier("undefined")); | ||
body.unshift(t.expressionStatement(statement)); | ||
} | ||
var paramDecls = this.paramDecls; | ||
if (paramDecls.length > 0) { | ||
body.unshift(t.variableDeclaration("var", paramDecls)); | ||
} | ||
node.body = util.template("tail-call-body", { | ||
THIS_ID: this.thisId, | ||
ARGUMENTS_ID: this.argumentsId, | ||
FUNCTION_ID: this.getFunctionId(), | ||
BLOCK: node.body | ||
}); | ||
var topVars = []; | ||
if (this.needsThis) { | ||
topVars.push(t.variableDeclarator(this.getThisId(), t.thisExpression())); | ||
} | ||
if (this.needsArguments || this.setsArguments) { | ||
var decl = t.variableDeclarator(this.getArgumentsId()); | ||
if (this.needsArguments) { | ||
decl.init = t.identifier("arguments"); | ||
} | ||
topVars.push(decl); | ||
} | ||
var leftId = this.leftId; | ||
if (leftId) { | ||
topVars.push(t.variableDeclarator(leftId)); | ||
} | ||
if (topVars.length > 0) { | ||
node.body.body.unshift(t.variableDeclaration("var", topVars)); | ||
} | ||
}; | ||
var functionVisitor = { | ||
enter: function (node, parent, scope, state) { | ||
// traverse all child nodes of this function and find `arguments` and `this` | ||
scope.traverse(node, functionChildrenVisitor, state); | ||
TailCallTransformer.prototype.subTransform = function (node) { | ||
if (!node) return; | ||
return this.skip(); | ||
var handler = this["subTransform" + node.type]; | ||
if (handler) return handler.call(this, node); | ||
}; | ||
TailCallTransformer.prototype.subTransformConditionalExpression = function (node) { | ||
var callConsequent = this.subTransform(node.consequent); | ||
var callAlternate = this.subTransform(node.alternate); | ||
if (!callConsequent && !callAlternate) { | ||
return; | ||
} | ||
// if ternary operator had tail recursion in value, convert to optimized if-statement | ||
node.type = "IfStatement"; | ||
node.consequent = callConsequent ? t.toBlock(callConsequent) : returnBlock(node.consequent); | ||
if (callAlternate) { | ||
node.alternate = t.isIfStatement(callAlternate) ? callAlternate : t.toBlock(callAlternate); | ||
} else { | ||
node.alternate = returnBlock(node.alternate); | ||
} | ||
return [node]; | ||
}; | ||
exports.FunctionDeclaration = | ||
exports.FunctionExpression = function (node, parent, scope) { | ||
// only tail recursion can be optimized as for now, | ||
// so we can skip anonymous functions entirely | ||
var ownerId = node.id; | ||
if (!ownerId) return; | ||
TailCallTransformer.prototype.subTransformLogicalExpression = function (node) { | ||
// only call in right-value of can be optimized | ||
var callRight = this.subTransform(node.right); | ||
if (!callRight) return; | ||
var argumentsId, thisId, shouldContinueId, leftId; | ||
// cache left value as it might have side-effects | ||
var leftId = this.getLeftId(); | ||
var testExpr = t.assignmentExpression( | ||
"=", | ||
leftId, | ||
node.left | ||
); | ||
var state = { | ||
hasTailRecursion: false, | ||
ownerId: ownerId, | ||
if (node.operator === "&&") { | ||
testExpr = t.unaryExpression("!", testExpr); | ||
} | ||
getArgumentsId: function () { | ||
return argumentsId = argumentsId || scope.generateUidIdentifier("arguments"); | ||
}, | ||
return [t.ifStatement(testExpr, returnBlock(leftId))].concat(callRight); | ||
}; | ||
getThisId: function () { | ||
return thisId = thisId || scope.generateUidIdentifier("this"); | ||
}, | ||
TailCallTransformer.prototype.subTransformSequenceExpression = function (node) { | ||
var seq = node.expressions; | ||
getShouldContinueId: function () { | ||
return shouldContinueId = shouldContinueId || scope.generateUidIdentifier("shouldContinue"); | ||
}, | ||
// only last element can be optimized | ||
var lastCall = this.subTransform(seq[seq.length - 1]); | ||
if (!lastCall) { | ||
return; | ||
} | ||
getLeftId: function () { | ||
return leftId = leftId || scope.generateUidIdentifier("left"); | ||
// remove converted expression from sequence | ||
// and convert to regular expression if needed | ||
if (--seq.length === 1) { | ||
node = seq[0]; | ||
} | ||
return [t.expressionStatement(node)].concat(lastCall); | ||
}; | ||
TailCallTransformer.prototype.subTransformCallExpression = function (node) { | ||
var callee = node.callee, thisBinding, args; | ||
if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) { | ||
switch (callee.property.name) { | ||
case "call": | ||
args = t.arrayExpression(node.arguments.slice(1)); | ||
break; | ||
case "apply": | ||
args = node.arguments[1] || t.identifier("undefined"); | ||
break; | ||
default: | ||
return; | ||
} | ||
}; | ||
// traverse the function and look for tail recursion | ||
scope.traverse(node, functionVisitor, state); | ||
thisBinding = node.arguments[0]; | ||
callee = callee.object; | ||
} | ||
if (!state.hasTailRecursion) return; | ||
// only tail recursion can be optimized as for now | ||
if (!t.isIdentifier(callee) || !this.scope.bindingIdentifierEquals(callee.name, this.ownerId)) { | ||
return; | ||
} | ||
var block = t.ensureBlock(node); | ||
this.hasTailRecursion = true; | ||
if (leftId) { | ||
block.body.unshift(t.variableDeclaration("var", [ | ||
t.variableDeclarator(leftId) | ||
])); | ||
if (this.hasDeopt()) return; | ||
var body = []; | ||
if (!t.isThisExpression(thisBinding)) { | ||
body.push(t.expressionStatement(t.assignmentExpression( | ||
"=", | ||
this.getThisId(), | ||
thisBinding || t.identifier("undefined") | ||
))); | ||
} | ||
var resultId = scope.generateUidIdentifier("result"); | ||
state.getShouldContinueId(); | ||
if (!args) { | ||
args = t.arrayExpression(node.arguments); | ||
} | ||
node.body = util.template("tail-call-body", { | ||
SHOULD_CONTINUE_ID: shouldContinueId, | ||
ARGUMENTS_ID: argumentsId, | ||
RESULT_ID: resultId, | ||
FUNCTION: t.functionExpression(null, node.params, block), | ||
THIS_ID: thisId, | ||
}); | ||
var argumentsId = this.getArgumentsId(); | ||
var params = this.getParams(); | ||
body.push(t.expressionStatement(t.assignmentExpression( | ||
"=", | ||
argumentsId, | ||
args | ||
))); | ||
var i, param; | ||
if (t.isArrayExpression(args)) { | ||
var elems = args.elements; | ||
for (i = 0; i < elems.length && i < params.length; i++) { | ||
param = params[i]; | ||
var elem = elems[i] || (elems[i] = t.identifier("undefined")); | ||
if (!param._isDefaultPlaceholder) { | ||
elems[i] = t.assignmentExpression("=", param, elem); | ||
} | ||
} | ||
} else { | ||
this.setsArguments = true; | ||
for (i = 0; i < params.length; i++) { | ||
param = params[i]; | ||
if (!param._isDefaultPlaceholder) { | ||
body.push(t.expressionStatement(t.assignmentExpression( | ||
"=", | ||
param, | ||
t.memberExpression(argumentsId, t.literal(i), true) | ||
))); | ||
} | ||
} | ||
} | ||
body.push(t.continueStatement(this.getFunctionId())); | ||
return body; | ||
}; | ||
// looks for and replaces tail recursion calls | ||
var firstPass = { | ||
enter: function (node, parent, scope, state) { | ||
if (t.isReturnStatement(node)) { | ||
this.skip(); | ||
return state.subTransform(node.argument); | ||
} else if (t.isTryStatement(parent)) { | ||
if (node === parent.block) { | ||
this.skip(); | ||
} else if (parent.finalizer && node !== parent.finalizer) { | ||
this.skip(); | ||
} | ||
} else if (t.isFunction(node)) { | ||
this.skip(); | ||
} else if (t.isVariableDeclaration(node)) { | ||
this.skip(); | ||
state.vars.push(node); | ||
} | ||
} | ||
}; | ||
// hoists up function declarations, replaces `this` and `arguments` and marks | ||
// them as needed | ||
var secondPass = { | ||
enter: function (node, parent, scope, state) { | ||
if (t.isThisExpression(node)) { | ||
state.needsThis = true; | ||
return state.getThisId(); | ||
} else if (t.isReferencedIdentifier(node, parent, { name: "arguments" })) { | ||
state.needsArguments = true; | ||
return state.getArgumentsId(); | ||
} else if (t.isFunction(node)) { | ||
this.skip(); | ||
if (t.isFunctionDeclaration(node)) { | ||
node = t.variableDeclaration("var", [ | ||
t.variableDeclarator(node.id, t.toExpression(node)) | ||
]); | ||
node._blockHoist = 2; | ||
return node; | ||
} | ||
} | ||
} | ||
}; | ||
// optimizes recursion by removing `this` and `arguments` if they aren't used | ||
var thirdPass = { | ||
enter: function (node, parent, scope, state) { | ||
if (!t.isExpressionStatement(node)) return; | ||
var expr = node.expression; | ||
if (!t.isAssignmentExpression(expr)) return; | ||
if (!state.needsThis && expr.left === state.getThisId()) { | ||
this.remove(); | ||
} else if (!state.needsArguments && expr.left === state.getArgumentsId() && t.isArrayExpression(expr.right)) { | ||
return map(expr.right.elements, function (elem) { | ||
return t.expressionStatement(elem); | ||
}); | ||
} | ||
} | ||
}; | ||
exports.Function = function (node, parent, scope, file) { | ||
var tailCall = new TailCallTransformer(node, scope, file); | ||
tailCall.run(); | ||
}; |
@@ -34,3 +34,2 @@ module.exports = { | ||
"es7.exponentiationOperator": require("./es7/exponentiation-operator"), | ||
"es6.spread": require("./es6/spread"), | ||
"es6.templateLiterals": require("./es6/template-literals"), | ||
@@ -51,7 +50,11 @@ | ||
// needs to be before `es6.parameters.default` as default parameters will destroy the rest param | ||
"es6.parameters.rest": require("./es6/parameters.rest"), | ||
// needs to be after `es6.parameters.rest` as we use `toArray` and avoid turning an already known array into one | ||
"es6.spread": require("./es6/spread"), | ||
// needs to be before `es6.blockScoping` as default parameters have a TDZ | ||
"es6.parameters.default": require("./es6/parameters.default"), | ||
"es6.parameters.rest": require("./es6/parameters.rest"), | ||
// needs to be before `es6.blockScoping` as let variables may be produced | ||
@@ -67,2 +70,4 @@ "es6.destructuring": require("./es6/destructuring"), | ||
// needs to be after `es6.parameters.*` and `es6.blockScoping` due to needing pure | ||
// identifiers in parameters and variable declarators | ||
"es6.tailCall": require("./es6/tail-call"), | ||
@@ -69,0 +74,0 @@ |
@@ -9,6 +9,10 @@ "use strict"; | ||
exports.CallExpression = function (node) { | ||
exports.CallExpression = function (node, parent) { | ||
if (isConsole(node.callee)) { | ||
this.remove(); | ||
if (t.isExpressionStatement(parent)) { | ||
this.parentPath.remove(); | ||
} else { | ||
this.remove(); | ||
} | ||
} | ||
}; |
@@ -5,8 +5,6 @@ //var t = require("../../../types"); | ||
exports.Scope = function () { | ||
// todo: get all binding identifiers, generate compact names | ||
// that wont collide and then call the remap identifier helper | ||
// this transformer **has** to be ran last as it will absolutley | ||
// destroy the scope tree | ||
exports.Scopable = function () { | ||
//for (var name in scope.bindings) { | ||
// scope.rename(name, scope.generateUidIdentifier("a").name); | ||
//} | ||
}; |
@@ -7,3 +7,3 @@ "use strict"; | ||
var has = require("lodash/object/has"); | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
@@ -34,7 +34,7 @@ var coreHas = function (node) { | ||
if (!node.computed && coreHas(obj) && has(core[obj.name], prop.name) && !scope.getBinding(obj.name)) { | ||
if (!node.computed && coreHas(obj) && has(core[obj.name], prop.name) && !scope.getBindingIdentifier(obj.name)) { | ||
this.skip(); | ||
return t.prependToMemberExpression(node, file.get("coreIdentifier")); | ||
} | ||
} else if (t.isReferencedIdentifier(node, parent) && !t.isMemberExpression(parent) && contains(ALIASABLE_CONSTRUCTORS, node.name) && !scope.getBinding(node.name)) { | ||
} else if (t.isReferencedIdentifier(node, parent) && !t.isMemberExpression(parent) && includes(ALIASABLE_CONSTRUCTORS, node.name) && !scope.getBindingIdentifier(node.name)) { | ||
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise | ||
@@ -41,0 +41,0 @@ return t.memberExpression(file.get("coreIdentifier"), node); |
"use strict"; | ||
var build = require("../../helpers/build-conditional-assignment-operator-transformer"); | ||
var t = require("../../../types"); | ||
var messages = require("../../../messages"); | ||
var build = require("../../helpers/build-conditional-assignment-operator-transformer"); | ||
var t = require("../../../types"); | ||
@@ -14,3 +15,3 @@ exports.playground = true; | ||
if (!t.isMemberExpression(left) && !t.isIdentifier(left)) { | ||
throw file.errorWithNode(left, "Expected type MemeberExpression or Identifier"); | ||
throw file.errorWithNode(left, messages.get("expectedMemberExpressionOrIdentifier")); | ||
} | ||
@@ -17,0 +18,0 @@ return true; |
"use strict"; | ||
var t = require("../../../types"); | ||
var messages = require("../../../messages"); | ||
var t = require("../../../types"); | ||
@@ -12,4 +13,4 @@ exports.check = t.isFor; | ||
var declar = left.declarations[0]; | ||
if (declar.init) throw file.errorWithNode(declar, "No assignments allowed in for-in/of head"); | ||
if (declar.init) throw file.errorWithNode(declar, messages.get("noAssignmentsInForHead")); | ||
} | ||
}; |
"use strict"; | ||
var messages = require("../../../messages"); | ||
exports.check = function (node) { | ||
@@ -10,4 +12,4 @@ return node.kind === "set"; | ||
if (node.kind === "set" && node.value.params.length !== 1) { | ||
throw file.errorWithNode(node.value, "Setters must have only one parameter"); | ||
throw file.errorWithNode(node.value, messages.get("settersInvalidParamLength")); | ||
} | ||
}; |
"use strict"; | ||
var levenshtein = require("../../../helpers/levenshtein"); | ||
var messages = require("../../../messages"); | ||
var t = require("../../../types"); | ||
@@ -12,4 +13,2 @@ | ||
var msg = "Reference to undeclared variable"; | ||
// get the closest declaration to offer as a suggestion | ||
@@ -32,4 +31,7 @@ // the variable name may have just been mistyped | ||
var msg; | ||
if (closest) { | ||
msg += " - Did you mean " + closest + "?"; | ||
msg = messages.get("undeclaredVariableSuggestion", node.name, closest); | ||
} else { | ||
msg = messages.get("undeclaredVariable", node.name); | ||
} | ||
@@ -36,0 +38,0 @@ |
"use strict"; | ||
/* jshint maxparams:7 */ | ||
module.exports = TraversalContext; | ||
@@ -6,0 +4,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
var TraversalContext = require("./context"); | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var t = require("../types"); | ||
@@ -106,3 +106,3 @@ | ||
// the node we're searching in is blacklisted | ||
if (contains(blacklistTypes, tree.type)) return false; | ||
if (includes(blacklistTypes, tree.type)) return false; | ||
@@ -109,0 +109,0 @@ // the type we're looking for is the same as the passed node |
@@ -8,3 +8,3 @@ "use strict"; | ||
var traverse = require("./index"); | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var Scope = require("./scope"); | ||
@@ -53,3 +53,3 @@ var t = require("../types"); | ||
// we're entering a new scope so let's construct it! | ||
if (t.isScope(node)) { | ||
if (t.isScope(node, parent)) { | ||
ourScope = new Scope(node, parent, scope); | ||
@@ -101,3 +101,3 @@ } | ||
if (isArray) { | ||
if (contains(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.obj)) { | ||
if (includes(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.obj)) { | ||
t.ensureBlock(this.obj, this.key); | ||
@@ -104,0 +104,0 @@ } |
@@ -5,5 +5,6 @@ "use strict"; | ||
var contains = require("lodash/collection/contains"); | ||
var includes = require("lodash/collection/includes"); | ||
var traverse = require("./index"); | ||
var defaults = require("lodash/object/defaults"); | ||
var messages = require("../messages"); | ||
var globals = require("globals"); | ||
@@ -14,3 +15,2 @@ var flatten = require("lodash/array/flatten"); | ||
var each = require("lodash/collection/each"); | ||
var has = require("lodash/object/has"); | ||
var t = require("../types"); | ||
@@ -139,8 +139,46 @@ | ||
Scope.prototype.checkBlockScopedCollisions = function (key, id) { | ||
if (this.declarationKinds["let"][key] || this.declarationKinds["const"][key]) { | ||
throw this.file.errorWithNode(id, "Duplicate declaration " + key, TypeError); | ||
Scope.prototype.checkBlockScopedCollisions = function (kind, name, id) { | ||
var local = this.getOwnBindingInfo(name); | ||
if (!local) return; | ||
if (kind === "param") return; | ||
if (kind === "hoisted" && local.kind === "let") return; | ||
if (local.kind === "let" || local.kind === "const") { | ||
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError); | ||
} | ||
}; | ||
Scope.prototype.rename = function (oldName, newName) { | ||
newName = newName || this.generateUidIdentifier(oldName).name; | ||
var info = this.getBindingInfo(oldName); | ||
if (!info) return; | ||
var binding = info.identifier; | ||
var scope = info.scope; | ||
scope.traverse(scope.block, { | ||
enter: function (node, parent, scope) { | ||
if (t.isReferencedIdentifier(node, parent) && node.name === oldName) { | ||
node.name = newName; | ||
} else if (t.isDeclaration(node)) { | ||
var ids = t.getBindingIdentifiers(node); | ||
for (var name in ids) { | ||
if (name === oldName) ids[name].name = newName; | ||
} | ||
} else if (t.isScope(node, parent)) { | ||
if (!scope.bindingIdentifierEquals(oldName, binding)) { | ||
this.skip(); | ||
} | ||
} | ||
} | ||
}); | ||
this.clearOwnBinding(oldName); | ||
scope.bindings[newName] = info; | ||
binding.name = newName; | ||
}; | ||
Scope.prototype.inferType = function (node) { | ||
@@ -153,6 +191,2 @@ var target; | ||
if (t.isLiteral(target) || t.isArrayExpression(target) || t.isObjectExpression(target)) { | ||
// todo: possibly call some helper that will resolve these to a flow type annotation | ||
} | ||
if (t.isCallExpression(target)) { | ||
@@ -167,7 +201,26 @@ // todo: resolve this to a return type | ||
if (t.isIdentifier(target)) { | ||
return this.getType(target.name); | ||
// todo | ||
} | ||
}; | ||
Scope.prototype.registerType = function (key, id, node) { | ||
Scope.prototype.isTypeGeneric = function (name, genericName) { | ||
var info = this.getBindingInfo(name); | ||
if (!info) return false; | ||
var type = info.typeAnnotation; | ||
return t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, { name: genericName }); | ||
}; | ||
Scope.prototype.assignTypeGeneric = function (name, type) { | ||
this.assignType(name, t.genericTypeAnnotation(t.identifier(type))); | ||
}; | ||
Scope.prototype.assignType = function (name, type) { | ||
var info = this.getBindingInfo(name); | ||
if (!info) return; | ||
info.identifier.typeAnnotation = info.typeAnnotation = type; | ||
}; | ||
Scope.prototype.getTypeAnnotation = function (key, id, node) { | ||
var type; | ||
@@ -185,28 +238,78 @@ | ||
if (t.isTypeAnnotation(type)) type = type.typeAnnotation; | ||
this.types[key] = type; | ||
return type; | ||
} | ||
}; | ||
Scope.prototype.register = function (node, reference, kind) { | ||
if (t.isVariableDeclaration(node)) { | ||
return this.registerVariableDeclaration(node); | ||
Scope.prototype.toArray = function (node, i) { | ||
var file = this.file; | ||
if (t.isIdentifier(node) && this.isTypeGeneric(node.name, "Array")) { | ||
return node; | ||
} | ||
if (t.isArrayExpression(node)) { | ||
return node; | ||
} | ||
if (t.isIdentifier(node, { name: "arguments" })) { | ||
return t.callExpression(t.memberExpression(file.addHelper("slice"), t.identifier("call")), [node]); | ||
} | ||
var helperName = "to-array"; | ||
var args = [node]; | ||
if (i === true) { | ||
helperName = "to-consumable-array"; | ||
} else if (i) { | ||
args.push(t.literal(i)); | ||
helperName = "sliced-to-array"; | ||
} | ||
return t.callExpression(file.addHelper(helperName), args); | ||
}; | ||
Scope.prototype.clearOwnBinding = function (name) { | ||
delete this.bindings[name]; | ||
}; | ||
Scope.prototype.registerDeclaration = function (node) { | ||
if (t.isFunctionDeclaration(node)) { | ||
this.registerBinding("hoisted", node); | ||
} else if (t.isVariableDeclaration(node)) { | ||
for (var i = 0; i < node.declarations.length; i++) { | ||
this.registerBinding(node.kind, node.declarations[i]); | ||
} | ||
} else if (t.isClassDeclaration(node)) { | ||
this.registerBinding("let", node); | ||
} else if (t.isImportDeclaration(node) || t.isExportDeclaration(node)) { | ||
this.registerBinding("module", node); | ||
} else { | ||
this.registerBinding("unknown", node); | ||
} | ||
}; | ||
Scope.prototype.registerBindingReassignment = function (node) { | ||
var ids = t.getBindingIdentifiers(node); | ||
for (var name in ids) { | ||
var info = this.getBindingInfo(name); | ||
if (info) info.reassigned = true; | ||
} | ||
}; | ||
extend(this.references, ids); | ||
Scope.prototype.registerBinding = function (kind, node) { | ||
if (!kind) throw new ReferenceError("no `kind`"); | ||
if (reference) return; | ||
var ids = t.getBindingIdentifiers(node); | ||
for (var key in ids) { | ||
var id = ids[key]; | ||
for (var name in ids) { | ||
var id = ids[name]; | ||
this.checkBlockScopedCollisions(key, id); | ||
this.checkBlockScopedCollisions(kind, name, id); | ||
this.registerType(key, id, node); | ||
this.bindings[key] = id; | ||
this.bindings[name] = { | ||
typeAnnotation: this.getTypeAnnotation(name, id, node), | ||
reassigned: false, | ||
identifier: id, | ||
scope: this, | ||
kind: kind | ||
}; | ||
} | ||
var kinds = this.declarationKinds[kind]; | ||
if (kinds) extend(kinds, ids); | ||
}; | ||
@@ -217,3 +320,3 @@ | ||
for (var i = 0; i < declars.length; i++) { | ||
this.register(declars[i], false, declar.kind); | ||
this.registerBinding(declars[i], declar.kind); | ||
} | ||
@@ -227,3 +330,3 @@ }; | ||
var declar = node[key]; | ||
if (t.isVar(declar)) state.scope.register(declar); | ||
if (t.isVar(declar)) state.scope.registerBinding("var", declar); | ||
}); | ||
@@ -246,10 +349,28 @@ } | ||
// we've ran into a declaration! | ||
if (t.isDeclaration(node)) state.scope.register(node); | ||
if (t.isDeclaration(node)) state.scope.registerDeclaration(node); | ||
} | ||
}; | ||
Scope.prototype.addGlobal = function (node) { | ||
this.globals[node.name] = node; | ||
}; | ||
Scope.prototype.hasGlobal = function (name) { | ||
var scope = this; | ||
do { | ||
if (scope.globals[name]) return true; | ||
} while (scope = scope.parent); | ||
return false; | ||
}; | ||
var programReferenceVisitor = { | ||
enter: function (node, parent, scope, state) { | ||
if (t.isReferencedIdentifier(node, parent) && !scope.hasReference(node.name)) { | ||
state.register(node, true); | ||
if (t.isReferencedIdentifier(node, parent) && !scope.hasBinding(node.name)) { | ||
state.addGlobal(node); | ||
} else if (t.isLabeledStatement(node)) { | ||
state.addGlobal(node); | ||
} else if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) { | ||
scope.registerBindingReassignment(node); | ||
} | ||
@@ -261,5 +382,5 @@ } | ||
enter: function (node, parent, scope, state) { | ||
if (t.isBlockScoped(node)) { | ||
state.register(node); | ||
} else if (t.isScope(node)) { | ||
if (t.isFunctionDeclaration(node) || t.isBlockScoped(node)) { | ||
state.registerDeclaration(node); | ||
} else if (t.isScope(node, parent)) { | ||
this.skip(); | ||
@@ -271,3 +392,2 @@ } | ||
Scope.prototype.crawl = function () { | ||
var parent = this.parent; | ||
var block = this.block; | ||
@@ -285,11 +405,4 @@ var i; | ||
info = block._scopeInfo = { | ||
declarationKinds: { | ||
"const": object(), | ||
"var": object(), | ||
"let": object() | ||
}, | ||
references: object(), | ||
bindings: object(), | ||
types: object(), | ||
bindings: object(), | ||
globals: object() | ||
}; | ||
@@ -299,11 +412,2 @@ | ||
// | ||
if (parent && t.isBlockStatement(block)) { | ||
if (t.isLoop(parent.block, { body: block }) || | ||
t.isFunction(parent.block, { body: block })) { | ||
return; | ||
} | ||
} | ||
// ForStatement - left, init | ||
@@ -314,3 +418,3 @@ | ||
var node = block[t.FOR_INIT_KEYS[i]]; | ||
if (t.isBlockScoped(node)) this.register(node, false, true); | ||
if (t.isBlockScoped(node)) this.registerBinding("let", node); | ||
} | ||
@@ -327,3 +431,3 @@ | ||
if (!t.isProperty(this.parentBlock, { method: true })) { | ||
this.register(block.id); | ||
this.registerBinding("var", block.id); | ||
} | ||
@@ -336,3 +440,3 @@ } | ||
for (i = 0; i < block.params.length; i++) { | ||
this.register(block.params[i]); | ||
this.registerBinding("param", block.params[i]); | ||
} | ||
@@ -351,3 +455,3 @@ this.traverse(block.body, blockVariableVisitor, this); | ||
if (t.isCatchClause(block)) { | ||
this.register(block.param); | ||
this.registerBinding("let", block.param); | ||
} | ||
@@ -358,3 +462,3 @@ | ||
if (t.isComprehensionExpression(block)) { | ||
this.register(block); | ||
this.registerBinding("let", block); | ||
} | ||
@@ -405,22 +509,2 @@ | ||
/** | ||
* Walk up the scope tree until we hit a `Function` and then | ||
* push our `node` to it's references. | ||
* | ||
* @param {String} kind | ||
* @param {Object} node | ||
*/ | ||
Scope.prototype.addDeclarationToFunctionScope = function (kind, node) { | ||
var scope = this.getFunctionParent(); | ||
var ids = t.getBindingIdentifiers(node); | ||
extend(scope.bindings, ids); | ||
extend(scope.references, ids); | ||
// this ignores the duplicate declaration logic specified in `getInfo` | ||
// but it doesn't really matter | ||
extend(scope.declarationKinds[kind], ids); | ||
}; | ||
/** | ||
* Walk up the scope tree until we hit either a Function or reach the | ||
@@ -463,3 +547,3 @@ * very top and hit Program. | ||
Scope.prototype.getAllDeclarationsOfKind = function (kind) { | ||
Scope.prototype.getAllBindingsOfKind = function (kind) { | ||
var ids = object(); | ||
@@ -469,3 +553,6 @@ | ||
do { | ||
defaults(ids, scope.declarationKinds[kind]); | ||
for (var name in scope.bindings) { | ||
var binding = scope.bindings[name]; | ||
if (binding.kind === kind) ids[name] = binding; | ||
} | ||
scope = scope.parent; | ||
@@ -477,58 +564,49 @@ } while (scope); | ||
// | ||
// misc | ||
Scope.prototype.get = function (id, type) { | ||
return id && (this.getOwn(id, type) || this.parentGet(id, type)); | ||
Scope.prototype.bindingIdentifierEquals = function (name, node) { | ||
return this.getBindingIdentifier(name) === node; | ||
}; | ||
Scope.prototype.getOwn = function (id, type) { | ||
var refs = { | ||
reference: this.references, | ||
binding: this.bindings, | ||
type: this.types | ||
}[type]; | ||
return refs && has(refs, id) && refs[id]; | ||
// get | ||
Scope.prototype.getBindingInfo = function (name) { | ||
var scope = this; | ||
do { | ||
var binding = scope.getOwnBindingInfo(name); | ||
if (binding) return binding; | ||
} while (scope = scope.parent); | ||
}; | ||
Scope.prototype.parentGet = function (id, type) { | ||
return this.parent && this.parent.get(id, type); | ||
Scope.prototype.getOwnBindingInfo = function (name) { | ||
return this.bindings[name]; | ||
}; | ||
Scope.prototype.has = function (id, type) { | ||
if (!id) return false; | ||
if (this.hasOwn(id, type)) return true; | ||
if (this.parentHas(id, type)) return true; | ||
if (contains(Scope.defaultDeclarations, id)) return true; | ||
return false; | ||
Scope.prototype.getBindingIdentifier = function (name) { | ||
var info = this.getBindingInfo(name); | ||
return info && info.identifier; | ||
}; | ||
Scope.prototype.hasOwn = function (id, type) { | ||
return !!this.getOwn(id, type); | ||
Scope.prototype.getOwnBindingIdentifier = function (name) { | ||
var binding = this.bindings[name]; | ||
return binding && binding.identifier; | ||
}; | ||
Scope.prototype.parentHas = function (id, type) { | ||
return this.parent && this.parent.has(id, type); | ||
// has | ||
Scope.prototype.hasOwnBinding = function (name) { | ||
return !!this.getOwnBindingInfo(name); | ||
}; | ||
each({ | ||
reference: "Reference", | ||
binding: "Binding", | ||
type: "Type" | ||
}, function (title, type) { | ||
Scope.prototype[type + "Equals"] = function (id, node) { | ||
return this["get" + title](id) === node; | ||
}; | ||
Scope.prototype.hasBinding = function (name) { | ||
if (!name) return false; | ||
if (this.hasOwnBinding(name)) return true; | ||
if (this.parentHasBinding(name)) return true; | ||
if (includes(Scope.defaultDeclarations, name)) return true; | ||
return false; | ||
}; | ||
each([ | ||
"get", | ||
"has", | ||
"getOwn", | ||
"hasOwn", | ||
"parentGet", | ||
"parentHas", | ||
], function (methodName) { | ||
Scope.prototype[methodName + title] = function (id) { | ||
return this[methodName](id, type); | ||
}; | ||
}); | ||
}); | ||
Scope.prototype.parentHasBinding = function (name) { | ||
return this.parent && this.parent.hasBinding(name); | ||
}; |
@@ -6,3 +6,3 @@ { | ||
"DebuggerStatement": ["Statement"], | ||
"DoWhileStatement": ["Statement", "Loop", "While", "Scope"], | ||
"DoWhileStatement": ["Statement", "Loop", "While", "Scopable"], | ||
"IfStatement": ["Statement"], | ||
@@ -13,3 +13,3 @@ "ReturnStatement": ["Statement"], | ||
"TryStatement": ["Statement"], | ||
"WhileStatement": ["Statement", "Loop", "While", "Scope"], | ||
"WhileStatement": ["Statement", "Loop", "While", "Scopable"], | ||
"WithStatement": ["Statement"], | ||
@@ -23,9 +23,9 @@ "EmptyStatement": ["Statement"], | ||
"ArrowFunctionExpression": ["Scope", "Function", "Expression"], | ||
"FunctionDeclaration": ["Statement", "Declaration", "Scope", "Function"], | ||
"FunctionExpression": ["Scope", "Function", "Expression"], | ||
"ArrowFunctionExpression": ["Scopable", "Function", "Expression"], | ||
"FunctionDeclaration": ["Statement", "Declaration", "Scopable", "Function"], | ||
"FunctionExpression": ["Scopable", "Function", "Expression"], | ||
"BlockStatement": ["Statement", "Scope"], | ||
"Program": ["Scope"], | ||
"CatchClause": ["Scope"], | ||
"BlockStatement": ["Statement", "Scopable"], | ||
"Program": ["Scopable"], | ||
"CatchClause": ["Scopable"], | ||
@@ -42,5 +42,5 @@ "LogicalExpression": ["Binary", "Expression"], | ||
"ForOfStatement": ["Statement", "For", "Scope", "Loop"], | ||
"ForInStatement": ["Statement", "For", "Scope", "Loop"], | ||
"ForStatement": ["Statement", "For", "Scope", "Loop"], | ||
"ForOfStatement": ["Statement", "For", "Scopable", "Loop"], | ||
"ForInStatement": ["Statement", "For", "Scopable", "Loop"], | ||
"ForStatement": ["Statement", "For", "Scopable", "Loop"], | ||
@@ -60,3 +60,3 @@ "ObjectPattern": ["Pattern"], | ||
"CallExpression": ["Expression"], | ||
"ComprehensionExpression": ["Expression", "Scope"], | ||
"ComprehensionExpression": ["Expression", "Scopable"], | ||
"ConditionalExpression": ["Expression"], | ||
@@ -63,0 +63,0 @@ "Identifier": ["Expression"], |
{ | ||
"ArrayExpression": ["elements"], | ||
"ArrowFunctionExpression": ["params", "body"], | ||
"AssignmentExpression": ["operator", "left", "right"], | ||
"BinaryExpression": ["operator", "left", "right"], | ||
"BlockStatement": ["body"], | ||
"CallExpression": ["callee", "arguments"], | ||
"ConditionalExpression": ["test", "consequent", "alternate"], | ||
"ExpressionStatement": ["expression"], | ||
"File": ["program", "comments", "tokens"], | ||
"FunctionExpression": ["id", "params", "body", "generator"], | ||
"FunctionDeclaration": ["id", "params", "body", "generator"], | ||
"Identifier": ["name"], | ||
"IfStatement": ["test", "consequent", "alternate"], | ||
"ImportDeclaration": ["specifiers", "source"], | ||
"ImportSpecifier": ["id", "name"], | ||
"Literal": ["value"], | ||
"LogicalExpression": ["operator", "left", "right"], | ||
"MemberExpression": ["object", "property", "computed"], | ||
"MethodDefinition": ["key", "value", "computed", "kind"], | ||
"NewExpression": ["callee", "arguments"], | ||
"ObjectExpression": ["properties"], | ||
"Program": ["body"], | ||
"Property": ["kind", "key", "value", "computed"], | ||
"ReturnStatement": ["argument"], | ||
"SequenceExpression": ["expressions"], | ||
"ThrowExpression": ["argument"], | ||
"UnaryExpression": ["operator", "argument", "prefix"], | ||
"VariableDeclaration": ["kind", "declarations"], | ||
"VariableDeclarator": ["id", "init"], | ||
"WithStatement": ["object", "body"], | ||
"YieldExpression": ["argument", "delegate"] | ||
"ArrayExpression": { | ||
"elements": null | ||
}, | ||
"ArrowFunctionExpression": { | ||
"params": null, | ||
"body": null | ||
}, | ||
"AssignmentExpression": { | ||
"operator": null, | ||
"left": null, | ||
"right": null | ||
}, | ||
"BinaryExpression": { | ||
"operator": null, | ||
"left": null, | ||
"right": null | ||
}, | ||
"BlockStatement": { | ||
"body": null | ||
}, | ||
"CallExpression": { | ||
"callee": null, | ||
"arguments": null | ||
}, | ||
"ConditionalExpression": { | ||
"test": null, | ||
"consequent": null, | ||
"alternate": null | ||
}, | ||
"ExpressionStatement": { | ||
"expression": null | ||
}, | ||
"File": { | ||
"program": null, | ||
"comments": null, | ||
"tokens": null | ||
}, | ||
"FunctionExpression": { | ||
"id": null, | ||
"params": null, | ||
"body": null, | ||
"generator": false | ||
}, | ||
"FunctionDeclaration": { | ||
"id": null, | ||
"params": null, | ||
"body": null, | ||
"generator": false | ||
}, | ||
"GenericTypeAnnotation": { | ||
"id": null, | ||
"typeParameters": null | ||
}, | ||
"Identifier": { | ||
"name": null | ||
}, | ||
"IfStatement": { | ||
"test": null, | ||
"consequent": null, | ||
"alternate": null | ||
}, | ||
"ImportDeclaration": { | ||
"specifiers": null, | ||
"source": null | ||
}, | ||
"ImportSpecifier": { | ||
"id": null, | ||
"name": null | ||
}, | ||
"Literal": { | ||
"value": null | ||
}, | ||
"LogicalExpression": { | ||
"operator": null, | ||
"left": null, | ||
"right": null | ||
}, | ||
"MemberExpression": { | ||
"object": null, | ||
"property": null, | ||
"computed": false | ||
}, | ||
"MethodDefinition": { | ||
"key": null, | ||
"value": null, | ||
"computed": false, | ||
"static": false, | ||
"kind": null | ||
}, | ||
"NewExpression": { | ||
"callee": null, | ||
"arguments": null | ||
}, | ||
"ObjectExpression": { | ||
"properties": null | ||
}, | ||
"Program": { | ||
"body": null | ||
}, | ||
"Property": { | ||
"kind": null, | ||
"key": null, | ||
"value": null, | ||
"computed": false | ||
}, | ||
"ReturnStatement": { | ||
"argument": null | ||
}, | ||
"SequenceExpression": { | ||
"expressions": null | ||
}, | ||
"ThrowExpression": { | ||
"argument": null | ||
}, | ||
"UnaryExpression": { | ||
"operator": null, | ||
"argument": null, | ||
"prefix": null | ||
}, | ||
"VariableDeclaration": { | ||
"kind": null, | ||
"declarations": null | ||
}, | ||
"VariableDeclarator": { | ||
"id": null, | ||
"init": null | ||
}, | ||
"WithStatement": { | ||
"object": null, | ||
"body": null | ||
}, | ||
"YieldExpression": { | ||
"argument": null, | ||
"delegate": null | ||
} | ||
} |
"use strict"; | ||
var toFastProperties = require("../helpers/to-fast-properties"); | ||
var defaults = require("lodash/object/defaults"); | ||
var isString = require("lodash/lang/isString"); | ||
@@ -9,3 +8,2 @@ var compact = require("lodash/array/compact"); | ||
var object = require("../helpers/object"); | ||
var Node = require("./node"); | ||
var each = require("lodash/collection/each"); | ||
@@ -76,5 +74,5 @@ var uniq = require("lodash/array/uniq"); | ||
t.is = function (type, node, opts, skipAliasCheck) { | ||
if (!node) return; | ||
if (!node) return false; | ||
var typeMatches = (type === node.type); | ||
var typeMatches = type === node.type; | ||
@@ -102,13 +100,28 @@ if (!typeMatches && !skipAliasCheck) { | ||
t.BUILDER_KEYS = defaults(require("./builder-keys"), t.VISITOR_KEYS); | ||
t.BUILDER_KEYS = require("./builder-keys"); | ||
each(t.VISITOR_KEYS, function (keys, type) { | ||
if (t.BUILDER_KEYS[type]) return; | ||
var defs = {}; | ||
each(keys, function (key) { | ||
defs[key] = null; | ||
}); | ||
t.BUILDER_KEYS[type] = defs; | ||
}); | ||
each(t.BUILDER_KEYS, function (keys, type) { | ||
t[type[0].toLowerCase() + type.slice(1)] = function () { | ||
var args = arguments; | ||
var node = new Node; | ||
var node = {}; | ||
node.start = null; | ||
node.type = type; | ||
each(keys, function (key, i) { | ||
node[key] = args[i]; | ||
}); | ||
var i = 0; | ||
for (var key in keys) { | ||
var arg = arguments[i++]; | ||
if (arg === undefined) arg = keys[key]; | ||
node[key] = arg; | ||
} | ||
return node; | ||
@@ -311,3 +324,3 @@ }; | ||
if (t.isAssignmentPattern(parent)) { | ||
return parent.right !== node; | ||
return parent.right === node; | ||
} | ||
@@ -342,4 +355,4 @@ | ||
* | ||
* @param {Object} node | ||
* @param {Object} parent | ||
* @param {Node} node | ||
* @parma {Node} parent | ||
* @returns {Boolean} | ||
@@ -431,2 +444,6 @@ */ | ||
if (allowPartial && i === parts.length) { | ||
return true; | ||
} | ||
if (t.isIdentifier(node)) { | ||
@@ -454,7 +471,3 @@ // this part doesn't match | ||
if (++i > parts.length) { | ||
if (allowPartial) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
return false; | ||
} | ||
@@ -610,6 +623,7 @@ } | ||
ClassDeclaration: ["id"], | ||
MemeberExpression: ["object"], | ||
MemberExpression: ["object"], | ||
SpreadElement: ["argument"], | ||
RestElement: ["argument"], | ||
UpdateExpression: ["argument"], | ||
SpreadProperty: ["argument"], | ||
Property: ["value"], | ||
@@ -776,3 +790,25 @@ ComprehensionBlock: ["left"], | ||
/** | ||
* Description | ||
* | ||
* @param {Node} node | ||
* @param {Node} parent | ||
* @returns {Boolean} | ||
*/ | ||
t.isScope = function (node, parent) { | ||
if (t.isBlockStatement(node)) { | ||
if (t.isLoop(parent.block, { body: node })) { | ||
return false; | ||
} | ||
if (t.isFunction(parent.block, { body: node })) { | ||
return false; | ||
} | ||
} | ||
return t.isScopable(node); | ||
}; | ||
toFastProperties(t); | ||
toFastProperties(t.VISITOR_KEYS); |
@@ -76,3 +76,3 @@ { | ||
"BooleanTypeAnnotation": [], | ||
"ClassProperty": ["key"], | ||
"ClassProperty": ["key", "value"], | ||
"DeclareClass": [], | ||
@@ -79,0 +79,0 @@ "DeclareFunction": [], |
@@ -33,2 +33,6 @@ "use strict"; | ||
exports.normalisePathSeparator = function (filename) { | ||
return filename.replace(/\\/g, "/"); | ||
}; | ||
exports.isInteger = function (i) { | ||
@@ -84,2 +88,5 @@ return isNumber(i) && i % 1 === 0; | ||
enter: function (node, parent, scope, nodes) { | ||
if (t.isExpressionStatement(node)) { | ||
node = node.expression; | ||
} | ||
if (t.isIdentifier(node) && has(nodes, node.name)) { | ||
@@ -86,0 +93,0 @@ return nodes[node.name]; |
{ | ||
"name": "6to5-core", | ||
"description": "Turn ES6 code into readable vanilla ES5 with source maps", | ||
"version": "3.5.3", | ||
"version": "3.6.0", | ||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
@@ -25,7 +25,7 @@ "homepage": "https://6to5.org/", | ||
"dependencies": { | ||
"acorn-6to5": "0.11.1-28", | ||
"acorn-6to5": "0.11.1-29", | ||
"ast-types": "~0.6.1", | ||
"chalk": "^0.5.1", | ||
"commander": "2.6.0", | ||
"core-js": "^0.4.9", | ||
"core-js": "^0.5.2", | ||
"debug": "^2.1.1", | ||
@@ -41,3 +41,3 @@ "detect-indent": "3.0.0", | ||
"private": "0.1.6", | ||
"regenerator-6to5": "0.8.9-8", | ||
"regenerator-6to5": "0.8.10-1", | ||
"regexpu": "1.1.0", | ||
@@ -44,0 +44,0 @@ "roadrunner": "1.0.4", |
@@ -1,1 +0,1 @@ | ||
(function(global){var to5Runtime=global.to5Runtime={};to5Runtime.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};to5Runtime.defaults=function(obj,defaults){for(var key in defaults){if(obj[key]===undefined){obj[key]=defaults[key]}}return obj};to5Runtime.prototypeProperties=function(child,staticProps,instanceProps){if(staticProps)Object.defineProperties(child,staticProps);if(instanceProps)Object.defineProperties(child.prototype,instanceProps)};to5Runtime.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};to5Runtime.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};to5Runtime.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};to5Runtime.interopRequire=function(obj){return obj&&obj.__esModule?obj.default:obj};to5Runtime.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};to5Runtime.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else{var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}};to5Runtime.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};to5Runtime.hasOwn=Object.prototype.hasOwnProperty;to5Runtime.slice=Array.prototype.slice;to5Runtime.bind=Function.prototype.bind;to5Runtime.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};to5Runtime.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};to5Runtime.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};to5Runtime._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};to5Runtime._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};to5Runtime.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};to5Runtime.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};to5Runtime.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};to5Runtime.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};to5Runtime.temporalUndefined={};to5Runtime.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};to5Runtime.tailCall=function(){function Tail(func,args,context){this.func=func;this.args=args;this.context=context}Tail.prototype._isTailDescriptor=true;var isRunning=false;return function(func,args,context){var result=new Tail(func,args,context);if(!isRunning){isRunning=true;do{result=result.func.apply(result.context,result.args)}while(result instanceof Tail||result&&result._isTailDescriptor);isRunning=false}return result}}()})(typeof global==="undefined"?self:global); | ||
(function(global){var to5Runtime=global.to5Runtime={};to5Runtime.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};to5Runtime.defaults=function(obj,defaults){var keys=Object.getOwnPropertyNames(defaults);for(var i=0;i<keys.length;i++){var key=keys[i];var value=Object.getOwnPropertyDescriptor(defaults,key);if(value&&value.configurable&&obj[key]===undefined){Object.defineProperty(obj,key,value)}}return obj};to5Runtime.prototypeProperties=function(child,staticProps,instanceProps){if(staticProps)Object.defineProperties(child,staticProps);if(instanceProps)Object.defineProperties(child.prototype,instanceProps)};to5Runtime.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};to5Runtime.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};to5Runtime.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};to5Runtime.interopRequire=function(obj){return obj&&obj.__esModule?obj.default:obj};to5Runtime.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};to5Runtime.toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};to5Runtime.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else{var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}};to5Runtime.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};to5Runtime.hasOwn=Object.prototype.hasOwnProperty;to5Runtime.slice=Array.prototype.slice;to5Runtime.bind=Function.prototype.bind;to5Runtime.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};to5Runtime.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};to5Runtime.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};to5Runtime._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};to5Runtime._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};to5Runtime.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};to5Runtime.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};to5Runtime.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};to5Runtime.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};to5Runtime.temporalUndefined={};to5Runtime.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};to5Runtime.tailCall=function(){function Tail(func,args,context){this.func=func;this.args=args;this.context=context}Tail.prototype._isTailDescriptor=true;var isRunning=false;return function(func,args,context){var result=new Tail(func,args,context);if(!isRunning){isRunning=true;do{result=result.func.apply(result.context,result.args)}while(result instanceof Tail||result&&result._isTailDescriptor);isRunning=false}return result}}()})(typeof global==="undefined"?self:global); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1550435
13193
155
+ Addedacorn-6to5@0.11.1-29(transitive)
+ Addedcore-js@0.5.4(transitive)
+ Addedregenerator-6to5@0.8.10-1(transitive)
- Removedacorn-6to5@0.11.1-28(transitive)
- Removedcore-js@0.4.10(transitive)
- Removedregenerator-6to5@0.8.9-8(transitive)
Updatedacorn-6to5@0.11.1-29
Updatedcore-js@^0.5.2
Updatedregenerator-6to5@0.8.10-1