superstruct
Advanced tools
Comparing version 0.0.3 to 0.0.4
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Superstruct=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var toString=Object.prototype.toString;module.exports=function(val){switch(toString.call(val)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}if(val===null)return"null";if(val===undefined)return"undefined";if(val!==val)return"nan";if(val&&val.nodeType===1)return"element";if(isBuffer(val))return"buffer";val=val.valueOf?val.valueOf():Object.prototype.valueOf.apply(val);return typeof val};function isBuffer(obj){return!!(obj!=null&&(obj._isBuffer||obj.constructor&&typeof obj.constructor.isBuffer==="function"&&obj.constructor.isBuffer(obj)))}},{}],2:[function(require,module,exports){var getNative=require("./_getNative"),root=require("./_root");var DataView=getNative(root,"DataView");module.exports=DataView},{"./_getNative":54,"./_root":90}],3:[function(require,module,exports){var hashClear=require("./_hashClear"),hashDelete=require("./_hashDelete"),hashGet=require("./_hashGet"),hashHas=require("./_hashHas"),hashSet=require("./_hashSet");function Hash(entries){var index=-1,length=entries==null?0:entries.length;this.clear();while(++index<length){var entry=entries[index];this.set(entry[0],entry[1])}}Hash.prototype.clear=hashClear;Hash.prototype["delete"]=hashDelete;Hash.prototype.get=hashGet;Hash.prototype.has=hashHas;Hash.prototype.set=hashSet;module.exports=Hash},{"./_hashClear":61,"./_hashDelete":62,"./_hashGet":63,"./_hashHas":64,"./_hashSet":65}],4:[function(require,module,exports){var listCacheClear=require("./_listCacheClear"),listCacheDelete=require("./_listCacheDelete"),listCacheGet=require("./_listCacheGet"),listCacheHas=require("./_listCacheHas"),listCacheSet=require("./_listCacheSet");function ListCache(entries){var index=-1,length=entries==null?0:entries.length;this.clear();while(++index<length){var entry=entries[index];this.set(entry[0],entry[1])}}ListCache.prototype.clear=listCacheClear;ListCache.prototype["delete"]=listCacheDelete;ListCache.prototype.get=listCacheGet;ListCache.prototype.has=listCacheHas;ListCache.prototype.set=listCacheSet;module.exports=ListCache},{"./_listCacheClear":73,"./_listCacheDelete":74,"./_listCacheGet":75,"./_listCacheHas":76,"./_listCacheSet":77}],5:[function(require,module,exports){var getNative=require("./_getNative"),root=require("./_root");var Map=getNative(root,"Map");module.exports=Map},{"./_getNative":54,"./_root":90}],6:[function(require,module,exports){var mapCacheClear=require("./_mapCacheClear"),mapCacheDelete=require("./_mapCacheDelete"),mapCacheGet=require("./_mapCacheGet"),mapCacheHas=require("./_mapCacheHas"),mapCacheSet=require("./_mapCacheSet");function MapCache(entries){var index=-1,length=entries==null?0:entries.length;this.clear();while(++index<length){var entry=entries[index];this.set(entry[0],entry[1])}}MapCache.prototype.clear=mapCacheClear;MapCache.prototype["delete"]=mapCacheDelete;MapCache.prototype.get=mapCacheGet;MapCache.prototype.has=mapCacheHas;MapCache.prototype.set=mapCacheSet;module.exports=MapCache},{"./_mapCacheClear":78,"./_mapCacheDelete":79,"./_mapCacheGet":80,"./_mapCacheHas":81,"./_mapCacheSet":82}],7:[function(require,module,exports){var getNative=require("./_getNative"),root=require("./_root");var Promise=getNative(root,"Promise");module.exports=Promise},{"./_getNative":54,"./_root":90}],8:[function(require,module,exports){var getNative=require("./_getNative"),root=require("./_root");var Set=getNative(root,"Set");module.exports=Set},{"./_getNative":54,"./_root":90}],9:[function(require,module,exports){var ListCache=require("./_ListCache"),stackClear=require("./_stackClear"),stackDelete=require("./_stackDelete"),stackGet=require("./_stackGet"),stackHas=require("./_stackHas"),stackSet=require("./_stackSet");function Stack(entries){var data=this.__data__=new ListCache(entries);this.size=data.size}Stack.prototype.clear=stackClear;Stack.prototype["delete"]=stackDelete;Stack.prototype.get=stackGet;Stack.prototype.has=stackHas;Stack.prototype.set=stackSet;module.exports=Stack},{"./_ListCache":4,"./_stackClear":92,"./_stackDelete":93,"./_stackGet":94,"./_stackHas":95,"./_stackSet":96}],10:[function(require,module,exports){var root=require("./_root");var Symbol=root.Symbol;module.exports=Symbol},{"./_root":90}],11:[function(require,module,exports){var root=require("./_root");var Uint8Array=root.Uint8Array;module.exports=Uint8Array},{"./_root":90}],12:[function(require,module,exports){var getNative=require("./_getNative"),root=require("./_root");var WeakMap=getNative(root,"WeakMap");module.exports=WeakMap},{"./_getNative":54,"./_root":90}],13:[function(require,module,exports){function addMapEntry(map,pair){map.set(pair[0],pair[1]);return map}module.exports=addMapEntry},{}],14:[function(require,module,exports){function addSetEntry(set,value){set.add(value);return set}module.exports=addSetEntry},{}],15:[function(require,module,exports){function arrayEach(array,iteratee){var index=-1,length=array==null?0:array.length;while(++index<length){if(iteratee(array[index],index,array)===false){break}}return array}module.exports=arrayEach},{}],16:[function(require,module,exports){function arrayFilter(array,predicate){var index=-1,length=array==null?0:array.length,resIndex=0,result=[];while(++index<length){var value=array[index];if(predicate(value,index,array)){result[resIndex++]=value}}return result}module.exports=arrayFilter},{}],17:[function(require,module,exports){var baseTimes=require("./_baseTimes"),isArguments=require("./isArguments"),isArray=require("./isArray"),isBuffer=require("./isBuffer"),isIndex=require("./_isIndex"),isTypedArray=require("./isTypedArray");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function arrayLikeKeys(value,inherited){var isArr=isArray(value),isArg=!isArr&&isArguments(value),isBuff=!isArr&&!isArg&&isBuffer(value),isType=!isArr&&!isArg&&!isBuff&&isTypedArray(value),skipIndexes=isArr||isArg||isBuff||isType,result=skipIndexes?baseTimes(value.length,String):[],length=result.length;for(var key in value){if((inherited||hasOwnProperty.call(value,key))&&!(skipIndexes&&(key=="length"||isBuff&&(key=="offset"||key=="parent")||isType&&(key=="buffer"||key=="byteLength"||key=="byteOffset")||isIndex(key,length)))){result.push(key)}}return result}module.exports=arrayLikeKeys},{"./_baseTimes":34,"./_isIndex":69,"./isArguments":100,"./isArray":101,"./isBuffer":103,"./isTypedArray":108}],18:[function(require,module,exports){function arrayPush(array,values){var index=-1,length=values.length,offset=array.length;while(++index<length){array[offset+index]=values[index]}return array}module.exports=arrayPush},{}],19:[function(require,module,exports){function arrayReduce(array,iteratee,accumulator,initAccum){var index=-1,length=array==null?0:array.length;if(initAccum&&length){accumulator=array[++index]}while(++index<length){accumulator=iteratee(accumulator,array[index],index,array)}return accumulator}module.exports=arrayReduce},{}],20:[function(require,module,exports){var baseAssignValue=require("./_baseAssignValue"),eq=require("./eq");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function assignValue(object,key,value){var objValue=object[key];if(!(hasOwnProperty.call(object,key)&&eq(objValue,value))||value===undefined&&!(key in object)){baseAssignValue(object,key,value)}}module.exports=assignValue},{"./_baseAssignValue":24,"./eq":99}],21:[function(require,module,exports){var eq=require("./eq");function assocIndexOf(array,key){var length=array.length;while(length--){if(eq(array[length][0],key)){return length}}return-1}module.exports=assocIndexOf},{"./eq":99}],22:[function(require,module,exports){var copyObject=require("./_copyObject"),keys=require("./keys");function baseAssign(object,source){return object&©Object(source,keys(source),object)}module.exports=baseAssign},{"./_copyObject":45,"./keys":109}],23:[function(require,module,exports){var copyObject=require("./_copyObject"),keysIn=require("./keysIn");function baseAssignIn(object,source){return object&©Object(source,keysIn(source),object)}module.exports=baseAssignIn},{"./_copyObject":45,"./keysIn":110}],24:[function(require,module,exports){var defineProperty=require("./_defineProperty");function baseAssignValue(object,key,value){if(key=="__proto__"&&defineProperty){defineProperty(object,key,{configurable:true,enumerable:true,value:value,writable:true})}else{object[key]=value}}module.exports=baseAssignValue},{"./_defineProperty":49}],25:[function(require,module,exports){var Stack=require("./_Stack"),arrayEach=require("./_arrayEach"),assignValue=require("./_assignValue"),baseAssign=require("./_baseAssign"),baseAssignIn=require("./_baseAssignIn"),cloneBuffer=require("./_cloneBuffer"),copyArray=require("./_copyArray"),copySymbols=require("./_copySymbols"),copySymbolsIn=require("./_copySymbolsIn"),getAllKeys=require("./_getAllKeys"),getAllKeysIn=require("./_getAllKeysIn"),getTag=require("./_getTag"),initCloneArray=require("./_initCloneArray"),initCloneByTag=require("./_initCloneByTag"),initCloneObject=require("./_initCloneObject"),isArray=require("./isArray"),isBuffer=require("./isBuffer"),isObject=require("./isObject"),keys=require("./keys");var CLONE_DEEP_FLAG=1,CLONE_FLAT_FLAG=2,CLONE_SYMBOLS_FLAG=4;var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",genTag="[object GeneratorFunction]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[dataViewTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[setTag]=cloneableTags[stringTag]=cloneableTags[symbolTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=true;cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=false;function baseClone(value,bitmask,customizer,key,object,stack){var result,isDeep=bitmask&CLONE_DEEP_FLAG,isFlat=bitmask&CLONE_FLAT_FLAG,isFull=bitmask&CLONE_SYMBOLS_FLAG;if(customizer){result=object?customizer(value,key,object,stack):customizer(value)}if(result!==undefined){return result}if(!isObject(value)){return value}var isArr=isArray(value);if(isArr){result=initCloneArray(value);if(!isDeep){return copyArray(value,result)}}else{var tag=getTag(value),isFunc=tag==funcTag||tag==genTag;if(isBuffer(value)){return cloneBuffer(value,isDeep)}if(tag==objectTag||tag==argsTag||isFunc&&!object){result=isFlat||isFunc?{}:initCloneObject(value);if(!isDeep){return isFlat?copySymbolsIn(value,baseAssignIn(result,value)):copySymbols(value,baseAssign(result,value))}}else{if(!cloneableTags[tag]){return object?value:{}}result=initCloneByTag(value,tag,baseClone,isDeep)}}stack||(stack=new Stack);var stacked=stack.get(value);if(stacked){return stacked}stack.set(value,result);var keysFunc=isFull?isFlat?getAllKeysIn:getAllKeys:isFlat?keysIn:keys;var props=isArr?undefined:keysFunc(value);arrayEach(props||value,function(subValue,key){if(props){key=subValue;subValue=value[key]}assignValue(result,key,baseClone(subValue,bitmask,customizer,key,value,stack))});return result}module.exports=baseClone},{"./_Stack":9,"./_arrayEach":15,"./_assignValue":20,"./_baseAssign":22,"./_baseAssignIn":23,"./_cloneBuffer":37,"./_copyArray":44,"./_copySymbols":46,"./_copySymbolsIn":47,"./_getAllKeys":51,"./_getAllKeysIn":52,"./_getTag":59,"./_initCloneArray":66,"./_initCloneByTag":67,"./_initCloneObject":68,"./isArray":101,"./isBuffer":103,"./isObject":106,"./keys":109}],26:[function(require,module,exports){var isObject=require("./isObject");var objectCreate=Object.create;var baseCreate=function(){function object(){}return function(proto){if(!isObject(proto)){return{}}if(objectCreate){return objectCreate(proto)}object.prototype=proto;var result=new object;object.prototype=undefined;return result}}();module.exports=baseCreate},{"./isObject":106}],27:[function(require,module,exports){var arrayPush=require("./_arrayPush"),isArray=require("./isArray");function baseGetAllKeys(object,keysFunc,symbolsFunc){var result=keysFunc(object);return isArray(object)?result:arrayPush(result,symbolsFunc(object))}module.exports=baseGetAllKeys},{"./_arrayPush":18,"./isArray":101}],28:[function(require,module,exports){var Symbol=require("./_Symbol"),getRawTag=require("./_getRawTag"),objectToString=require("./_objectToString");var nullTag="[object Null]",undefinedTag="[object Undefined]";var symToStringTag=Symbol?Symbol.toStringTag:undefined;function baseGetTag(value){if(value==null){return value===undefined?undefinedTag:nullTag}return symToStringTag&&symToStringTag in Object(value)?getRawTag(value):objectToString(value)}module.exports=baseGetTag},{"./_Symbol":10,"./_getRawTag":56,"./_objectToString":88}],29:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),isObjectLike=require("./isObjectLike");var argsTag="[object Arguments]";function baseIsArguments(value){return isObjectLike(value)&&baseGetTag(value)==argsTag}module.exports=baseIsArguments},{"./_baseGetTag":28,"./isObjectLike":107}],30:[function(require,module,exports){var isFunction=require("./isFunction"),isMasked=require("./_isMasked"),isObject=require("./isObject"),toSource=require("./_toSource");var reRegExpChar=/[\\^$.*+?()[\]{}|]/g;var reIsHostCtor=/^\[object .+?Constructor\]$/;var funcProto=Function.prototype,objectProto=Object.prototype;var funcToString=funcProto.toString;var hasOwnProperty=objectProto.hasOwnProperty;var reIsNative=RegExp("^"+funcToString.call(hasOwnProperty).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(value){if(!isObject(value)||isMasked(value)){return false}var pattern=isFunction(value)?reIsNative:reIsHostCtor;return pattern.test(toSource(value))}module.exports=baseIsNative},{"./_isMasked":71,"./_toSource":97,"./isFunction":104,"./isObject":106}],31:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),isLength=require("./isLength"),isObjectLike=require("./isObjectLike");var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=true;typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;function baseIsTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[baseGetTag(value)]}module.exports=baseIsTypedArray},{"./_baseGetTag":28,"./isLength":105,"./isObjectLike":107}],32:[function(require,module,exports){var isPrototype=require("./_isPrototype"),nativeKeys=require("./_nativeKeys");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function baseKeys(object){if(!isPrototype(object)){return nativeKeys(object)}var result=[];for(var key in Object(object)){if(hasOwnProperty.call(object,key)&&key!="constructor"){result.push(key)}}return result}module.exports=baseKeys},{"./_isPrototype":72,"./_nativeKeys":85}],33:[function(require,module,exports){var isObject=require("./isObject"),isPrototype=require("./_isPrototype"),nativeKeysIn=require("./_nativeKeysIn");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function baseKeysIn(object){if(!isObject(object)){return nativeKeysIn(object)}var isProto=isPrototype(object),result=[];for(var key in object){if(!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key)}}return result}module.exports=baseKeysIn},{"./_isPrototype":72,"./_nativeKeysIn":86,"./isObject":106}],34:[function(require,module,exports){function baseTimes(n,iteratee){var index=-1,result=Array(n);while(++index<n){result[index]=iteratee(index)}return result}module.exports=baseTimes},{}],35:[function(require,module,exports){function baseUnary(func){return function(value){return func(value)}}module.exports=baseUnary},{}],36:[function(require,module,exports){var Uint8Array=require("./_Uint8Array");function cloneArrayBuffer(arrayBuffer){var result=new arrayBuffer.constructor(arrayBuffer.byteLength);new Uint8Array(result).set(new Uint8Array(arrayBuffer));return result}module.exports=cloneArrayBuffer},{"./_Uint8Array":11}],37:[function(require,module,exports){var root=require("./_root");var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports;var Buffer=moduleExports?root.Buffer:undefined,allocUnsafe=Buffer?Buffer.allocUnsafe:undefined;function cloneBuffer(buffer,isDeep){if(isDeep){return buffer.slice()}var length=buffer.length,result=allocUnsafe?allocUnsafe(length):new buffer.constructor(length);buffer.copy(result);return result}module.exports=cloneBuffer},{"./_root":90}],38:[function(require,module,exports){var cloneArrayBuffer=require("./_cloneArrayBuffer");function cloneDataView(dataView,isDeep){var buffer=isDeep?cloneArrayBuffer(dataView.buffer):dataView.buffer;return new dataView.constructor(buffer,dataView.byteOffset,dataView.byteLength)}module.exports=cloneDataView},{"./_cloneArrayBuffer":36}],39:[function(require,module,exports){var addMapEntry=require("./_addMapEntry"),arrayReduce=require("./_arrayReduce"),mapToArray=require("./_mapToArray");var CLONE_DEEP_FLAG=1;function cloneMap(map,isDeep,cloneFunc){var array=isDeep?cloneFunc(mapToArray(map),CLONE_DEEP_FLAG):mapToArray(map);return arrayReduce(array,addMapEntry,new map.constructor)}module.exports=cloneMap},{"./_addMapEntry":13,"./_arrayReduce":19,"./_mapToArray":83}],40:[function(require,module,exports){var reFlags=/\w*$/;function cloneRegExp(regexp){var result=new regexp.constructor(regexp.source,reFlags.exec(regexp));result.lastIndex=regexp.lastIndex;return result}module.exports=cloneRegExp},{}],41:[function(require,module,exports){var addSetEntry=require("./_addSetEntry"),arrayReduce=require("./_arrayReduce"),setToArray=require("./_setToArray");var CLONE_DEEP_FLAG=1;function cloneSet(set,isDeep,cloneFunc){var array=isDeep?cloneFunc(setToArray(set),CLONE_DEEP_FLAG):setToArray(set);return arrayReduce(array,addSetEntry,new set.constructor)}module.exports=cloneSet},{"./_addSetEntry":14,"./_arrayReduce":19,"./_setToArray":91}],42:[function(require,module,exports){var Symbol=require("./_Symbol");var symbolProto=Symbol?Symbol.prototype:undefined,symbolValueOf=symbolProto?symbolProto.valueOf:undefined;function cloneSymbol(symbol){return symbolValueOf?Object(symbolValueOf.call(symbol)):{}}module.exports=cloneSymbol},{"./_Symbol":10}],43:[function(require,module,exports){var cloneArrayBuffer=require("./_cloneArrayBuffer");function cloneTypedArray(typedArray,isDeep){var buffer=isDeep?cloneArrayBuffer(typedArray.buffer):typedArray.buffer;return new typedArray.constructor(buffer,typedArray.byteOffset,typedArray.length)}module.exports=cloneTypedArray},{"./_cloneArrayBuffer":36}],44:[function(require,module,exports){function copyArray(source,array){var index=-1,length=source.length;array||(array=Array(length));while(++index<length){array[index]=source[index]}return array}module.exports=copyArray},{}],45:[function(require,module,exports){var assignValue=require("./_assignValue"),baseAssignValue=require("./_baseAssignValue");function copyObject(source,props,object,customizer){var isNew=!object;object||(object={});var index=-1,length=props.length;while(++index<length){var key=props[index];var newValue=customizer?customizer(object[key],source[key],key,object,source):undefined;if(newValue===undefined){newValue=source[key]}if(isNew){baseAssignValue(object,key,newValue)}else{assignValue(object,key,newValue)}}return object}module.exports=copyObject},{"./_assignValue":20,"./_baseAssignValue":24}],46:[function(require,module,exports){var copyObject=require("./_copyObject"),getSymbols=require("./_getSymbols");function copySymbols(source,object){return copyObject(source,getSymbols(source),object)}module.exports=copySymbols},{"./_copyObject":45,"./_getSymbols":57}],47:[function(require,module,exports){var copyObject=require("./_copyObject"),getSymbolsIn=require("./_getSymbolsIn");function copySymbolsIn(source,object){return copyObject(source,getSymbolsIn(source),object)}module.exports=copySymbolsIn},{"./_copyObject":45,"./_getSymbolsIn":58}],48:[function(require,module,exports){var root=require("./_root");var coreJsData=root["__core-js_shared__"];module.exports=coreJsData},{"./_root":90}],49:[function(require,module,exports){var getNative=require("./_getNative");var defineProperty=function(){try{var func=getNative(Object,"defineProperty");func({},"",{});return func}catch(e){}}();module.exports=defineProperty},{"./_getNative":54}],50:[function(require,module,exports){(function(global){var freeGlobal=typeof global=="object"&&global&&global.Object===Object&&global;module.exports=freeGlobal}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],51:[function(require,module,exports){var baseGetAllKeys=require("./_baseGetAllKeys"),getSymbols=require("./_getSymbols"),keys=require("./keys");function getAllKeys(object){return baseGetAllKeys(object,keys,getSymbols)}module.exports=getAllKeys},{"./_baseGetAllKeys":27,"./_getSymbols":57,"./keys":109}],52:[function(require,module,exports){var baseGetAllKeys=require("./_baseGetAllKeys"),getSymbolsIn=require("./_getSymbolsIn"),keysIn=require("./keysIn");function getAllKeysIn(object){return baseGetAllKeys(object,keysIn,getSymbolsIn)}module.exports=getAllKeysIn},{"./_baseGetAllKeys":27,"./_getSymbolsIn":58,"./keysIn":110}],53:[function(require,module,exports){var isKeyable=require("./_isKeyable");function getMapData(map,key){var data=map.__data__;return isKeyable(key)?data[typeof key=="string"?"string":"hash"]:data.map}module.exports=getMapData},{"./_isKeyable":70}],54:[function(require,module,exports){var baseIsNative=require("./_baseIsNative"),getValue=require("./_getValue");function getNative(object,key){var value=getValue(object,key);return baseIsNative(value)?value:undefined}module.exports=getNative},{"./_baseIsNative":30,"./_getValue":60}],55:[function(require,module,exports){var overArg=require("./_overArg");var getPrototype=overArg(Object.getPrototypeOf,Object);module.exports=getPrototype},{"./_overArg":89}],56:[function(require,module,exports){var Symbol=require("./_Symbol");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var nativeObjectToString=objectProto.toString;var symToStringTag=Symbol?Symbol.toStringTag:undefined;function getRawTag(value){var isOwn=hasOwnProperty.call(value,symToStringTag),tag=value[symToStringTag];try{value[symToStringTag]=undefined;var unmasked=true}catch(e){}var result=nativeObjectToString.call(value);if(unmasked){if(isOwn){value[symToStringTag]=tag}else{delete value[symToStringTag]}}return result}module.exports=getRawTag},{"./_Symbol":10}],57:[function(require,module,exports){var arrayFilter=require("./_arrayFilter"),stubArray=require("./stubArray");var objectProto=Object.prototype;var propertyIsEnumerable=objectProto.propertyIsEnumerable;var nativeGetSymbols=Object.getOwnPropertySymbols;var getSymbols=!nativeGetSymbols?stubArray:function(object){if(object==null){return[]}object=Object(object);return arrayFilter(nativeGetSymbols(object),function(symbol){return propertyIsEnumerable.call(object,symbol)})};module.exports=getSymbols},{"./_arrayFilter":16,"./stubArray":111}],58:[function(require,module,exports){var arrayPush=require("./_arrayPush"),getPrototype=require("./_getPrototype"),getSymbols=require("./_getSymbols"),stubArray=require("./stubArray");var nativeGetSymbols=Object.getOwnPropertySymbols;var getSymbolsIn=!nativeGetSymbols?stubArray:function(object){var result=[];while(object){arrayPush(result,getSymbols(object));object=getPrototype(object)}return result};module.exports=getSymbolsIn},{"./_arrayPush":18,"./_getPrototype":55,"./_getSymbols":57,"./stubArray":111}],59:[function(require,module,exports){var DataView=require("./_DataView"),Map=require("./_Map"),Promise=require("./_Promise"),Set=require("./_Set"),WeakMap=require("./_WeakMap"),baseGetTag=require("./_baseGetTag"),toSource=require("./_toSource");var mapTag="[object Map]",objectTag="[object Object]",promiseTag="[object Promise]",setTag="[object Set]",weakMapTag="[object WeakMap]";var dataViewTag="[object DataView]";var dataViewCtorString=toSource(DataView),mapCtorString=toSource(Map),promiseCtorString=toSource(Promise),setCtorString=toSource(Set),weakMapCtorString=toSource(WeakMap);var getTag=baseGetTag;if(DataView&&getTag(new DataView(new ArrayBuffer(1)))!=dataViewTag||Map&&getTag(new Map)!=mapTag||Promise&&getTag(Promise.resolve())!=promiseTag||Set&&getTag(new Set)!=setTag||WeakMap&&getTag(new WeakMap)!=weakMapTag){getTag=function(value){var result=baseGetTag(value),Ctor=result==objectTag?value.constructor:undefined,ctorString=Ctor?toSource(Ctor):"";if(ctorString){switch(ctorString){case dataViewCtorString:return dataViewTag;case mapCtorString:return mapTag;case promiseCtorString:return promiseTag;case setCtorString:return setTag;case weakMapCtorString:return weakMapTag}}return result}}module.exports=getTag},{"./_DataView":2,"./_Map":5,"./_Promise":7,"./_Set":8,"./_WeakMap":12,"./_baseGetTag":28,"./_toSource":97}],60:[function(require,module,exports){function getValue(object,key){return object==null?undefined:object[key]}module.exports=getValue},{}],61:[function(require,module,exports){var nativeCreate=require("./_nativeCreate");function hashClear(){this.__data__=nativeCreate?nativeCreate(null):{};this.size=0}module.exports=hashClear},{"./_nativeCreate":84}],62:[function(require,module,exports){function hashDelete(key){var result=this.has(key)&&delete this.__data__[key];this.size-=result?1:0;return result}module.exports=hashDelete},{}],63:[function(require,module,exports){var nativeCreate=require("./_nativeCreate");var HASH_UNDEFINED="__lodash_hash_undefined__";var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function hashGet(key){var data=this.__data__;if(nativeCreate){var result=data[key];return result===HASH_UNDEFINED?undefined:result}return hasOwnProperty.call(data,key)?data[key]:undefined}module.exports=hashGet},{"./_nativeCreate":84}],64:[function(require,module,exports){var nativeCreate=require("./_nativeCreate");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function hashHas(key){var data=this.__data__;return nativeCreate?data[key]!==undefined:hasOwnProperty.call(data,key)}module.exports=hashHas},{"./_nativeCreate":84}],65:[function(require,module,exports){var nativeCreate=require("./_nativeCreate");var HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet(key,value){var data=this.__data__;this.size+=this.has(key)?0:1;data[key]=nativeCreate&&value===undefined?HASH_UNDEFINED:value;return this}module.exports=hashSet},{"./_nativeCreate":84}],66:[function(require,module,exports){var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function initCloneArray(array){var length=array.length,result=array.constructor(length);if(length&&typeof array[0]=="string"&&hasOwnProperty.call(array,"index")){result.index=array.index;result.input=array.input}return result}module.exports=initCloneArray},{}],67:[function(require,module,exports){var cloneArrayBuffer=require("./_cloneArrayBuffer"),cloneDataView=require("./_cloneDataView"),cloneMap=require("./_cloneMap"),cloneRegExp=require("./_cloneRegExp"),cloneSet=require("./_cloneSet"),cloneSymbol=require("./_cloneSymbol"),cloneTypedArray=require("./_cloneTypedArray");var boolTag="[object Boolean]",dateTag="[object Date]",mapTag="[object Map]",numberTag="[object Number]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]";var arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";function initCloneByTag(object,tag,cloneFunc,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return cloneArrayBuffer(object);case boolTag:case dateTag:return new Ctor(+object);case dataViewTag:return cloneDataView(object,isDeep);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:return cloneTypedArray(object,isDeep);case mapTag:return cloneMap(object,isDeep,cloneFunc);case numberTag:case stringTag:return new Ctor(object);case regexpTag:return cloneRegExp(object);case setTag:return cloneSet(object,isDeep,cloneFunc);case symbolTag:return cloneSymbol(object)}}module.exports=initCloneByTag},{"./_cloneArrayBuffer":36,"./_cloneDataView":38,"./_cloneMap":39,"./_cloneRegExp":40,"./_cloneSet":41,"./_cloneSymbol":42,"./_cloneTypedArray":43}],68:[function(require,module,exports){ | ||
var baseCreate=require("./_baseCreate"),getPrototype=require("./_getPrototype"),isPrototype=require("./_isPrototype");function initCloneObject(object){return typeof object.constructor=="function"&&!isPrototype(object)?baseCreate(getPrototype(object)):{}}module.exports=initCloneObject},{"./_baseCreate":26,"./_getPrototype":55,"./_isPrototype":72}],69:[function(require,module,exports){var MAX_SAFE_INTEGER=9007199254740991;var reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(value,length){length=length==null?MAX_SAFE_INTEGER:length;return!!length&&(typeof value=="number"||reIsUint.test(value))&&(value>-1&&value%1==0&&value<length)}module.exports=isIndex},{}],70:[function(require,module,exports){function isKeyable(value){var type=typeof value;return type=="string"||type=="number"||type=="symbol"||type=="boolean"?value!=="__proto__":value===null}module.exports=isKeyable},{}],71:[function(require,module,exports){var coreJsData=require("./_coreJsData");var maskSrcKey=function(){var uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return uid?"Symbol(src)_1."+uid:""}();function isMasked(func){return!!maskSrcKey&&maskSrcKey in func}module.exports=isMasked},{"./_coreJsData":48}],72:[function(require,module,exports){var objectProto=Object.prototype;function isPrototype(value){var Ctor=value&&value.constructor,proto=typeof Ctor=="function"&&Ctor.prototype||objectProto;return value===proto}module.exports=isPrototype},{}],73:[function(require,module,exports){function listCacheClear(){this.__data__=[];this.size=0}module.exports=listCacheClear},{}],74:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");var arrayProto=Array.prototype;var splice=arrayProto.splice;function listCacheDelete(key){var data=this.__data__,index=assocIndexOf(data,key);if(index<0){return false}var lastIndex=data.length-1;if(index==lastIndex){data.pop()}else{splice.call(data,index,1)}--this.size;return true}module.exports=listCacheDelete},{"./_assocIndexOf":21}],75:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");function listCacheGet(key){var data=this.__data__,index=assocIndexOf(data,key);return index<0?undefined:data[index][1]}module.exports=listCacheGet},{"./_assocIndexOf":21}],76:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");function listCacheHas(key){return assocIndexOf(this.__data__,key)>-1}module.exports=listCacheHas},{"./_assocIndexOf":21}],77:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");function listCacheSet(key,value){var data=this.__data__,index=assocIndexOf(data,key);if(index<0){++this.size;data.push([key,value])}else{data[index][1]=value}return this}module.exports=listCacheSet},{"./_assocIndexOf":21}],78:[function(require,module,exports){var Hash=require("./_Hash"),ListCache=require("./_ListCache"),Map=require("./_Map");function mapCacheClear(){this.size=0;this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}module.exports=mapCacheClear},{"./_Hash":3,"./_ListCache":4,"./_Map":5}],79:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheDelete(key){var result=getMapData(this,key)["delete"](key);this.size-=result?1:0;return result}module.exports=mapCacheDelete},{"./_getMapData":53}],80:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheGet(key){return getMapData(this,key).get(key)}module.exports=mapCacheGet},{"./_getMapData":53}],81:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheHas(key){return getMapData(this,key).has(key)}module.exports=mapCacheHas},{"./_getMapData":53}],82:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheSet(key,value){var data=getMapData(this,key),size=data.size;data.set(key,value);this.size+=data.size==size?0:1;return this}module.exports=mapCacheSet},{"./_getMapData":53}],83:[function(require,module,exports){function mapToArray(map){var index=-1,result=Array(map.size);map.forEach(function(value,key){result[++index]=[key,value]});return result}module.exports=mapToArray},{}],84:[function(require,module,exports){var getNative=require("./_getNative");var nativeCreate=getNative(Object,"create");module.exports=nativeCreate},{"./_getNative":54}],85:[function(require,module,exports){var overArg=require("./_overArg");var nativeKeys=overArg(Object.keys,Object);module.exports=nativeKeys},{"./_overArg":89}],86:[function(require,module,exports){function nativeKeysIn(object){var result=[];if(object!=null){for(var key in Object(object)){result.push(key)}}return result}module.exports=nativeKeysIn},{}],87:[function(require,module,exports){var freeGlobal=require("./_freeGlobal");var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports;var freeProcess=moduleExports&&freeGlobal.process;var nodeUtil=function(){try{return freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}();module.exports=nodeUtil},{"./_freeGlobal":50}],88:[function(require,module,exports){var objectProto=Object.prototype;var nativeObjectToString=objectProto.toString;function objectToString(value){return nativeObjectToString.call(value)}module.exports=objectToString},{}],89:[function(require,module,exports){function overArg(func,transform){return function(arg){return func(transform(arg))}}module.exports=overArg},{}],90:[function(require,module,exports){var freeGlobal=require("./_freeGlobal");var freeSelf=typeof self=="object"&&self&&self.Object===Object&&self;var root=freeGlobal||freeSelf||Function("return this")();module.exports=root},{"./_freeGlobal":50}],91:[function(require,module,exports){function setToArray(set){var index=-1,result=Array(set.size);set.forEach(function(value){result[++index]=value});return result}module.exports=setToArray},{}],92:[function(require,module,exports){var ListCache=require("./_ListCache");function stackClear(){this.__data__=new ListCache;this.size=0}module.exports=stackClear},{"./_ListCache":4}],93:[function(require,module,exports){function stackDelete(key){var data=this.__data__,result=data["delete"](key);this.size=data.size;return result}module.exports=stackDelete},{}],94:[function(require,module,exports){function stackGet(key){return this.__data__.get(key)}module.exports=stackGet},{}],95:[function(require,module,exports){function stackHas(key){return this.__data__.has(key)}module.exports=stackHas},{}],96:[function(require,module,exports){var ListCache=require("./_ListCache"),Map=require("./_Map"),MapCache=require("./_MapCache");var LARGE_ARRAY_SIZE=200;function stackSet(key,value){var data=this.__data__;if(data instanceof ListCache){var pairs=data.__data__;if(!Map||pairs.length<LARGE_ARRAY_SIZE-1){pairs.push([key,value]);this.size=++data.size;return this}data=this.__data__=new MapCache(pairs)}data.set(key,value);this.size=data.size;return this}module.exports=stackSet},{"./_ListCache":4,"./_Map":5,"./_MapCache":6}],97:[function(require,module,exports){var funcProto=Function.prototype;var funcToString=funcProto.toString;function toSource(func){if(func!=null){try{return funcToString.call(func)}catch(e){}try{return func+""}catch(e){}}return""}module.exports=toSource},{}],98:[function(require,module,exports){var baseClone=require("./_baseClone");var CLONE_DEEP_FLAG=1,CLONE_SYMBOLS_FLAG=4;function cloneDeep(value){return baseClone(value,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG)}module.exports=cloneDeep},{"./_baseClone":25}],99:[function(require,module,exports){function eq(value,other){return value===other||value!==value&&other!==other}module.exports=eq},{}],100:[function(require,module,exports){var baseIsArguments=require("./_baseIsArguments"),isObjectLike=require("./isObjectLike");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var propertyIsEnumerable=objectProto.propertyIsEnumerable;var isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(value){return isObjectLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")};module.exports=isArguments},{"./_baseIsArguments":29,"./isObjectLike":107}],101:[function(require,module,exports){var isArray=Array.isArray;module.exports=isArray},{}],102:[function(require,module,exports){var isFunction=require("./isFunction"),isLength=require("./isLength");function isArrayLike(value){return value!=null&&isLength(value.length)&&!isFunction(value)}module.exports=isArrayLike},{"./isFunction":104,"./isLength":105}],103:[function(require,module,exports){var root=require("./_root"),stubFalse=require("./stubFalse");var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports;var Buffer=moduleExports?root.Buffer:undefined;var nativeIsBuffer=Buffer?Buffer.isBuffer:undefined;var isBuffer=nativeIsBuffer||stubFalse;module.exports=isBuffer},{"./_root":90,"./stubFalse":112}],104:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),isObject=require("./isObject");var asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(value){if(!isObject(value)){return false}var tag=baseGetTag(value);return tag==funcTag||tag==genTag||tag==asyncTag||tag==proxyTag}module.exports=isFunction},{"./_baseGetTag":28,"./isObject":106}],105:[function(require,module,exports){var MAX_SAFE_INTEGER=9007199254740991;function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}module.exports=isLength},{}],106:[function(require,module,exports){function isObject(value){var type=typeof value;return value!=null&&(type=="object"||type=="function")}module.exports=isObject},{}],107:[function(require,module,exports){function isObjectLike(value){return value!=null&&typeof value=="object"}module.exports=isObjectLike},{}],108:[function(require,module,exports){var baseIsTypedArray=require("./_baseIsTypedArray"),baseUnary=require("./_baseUnary"),nodeUtil=require("./_nodeUtil");var nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray;var isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;module.exports=isTypedArray},{"./_baseIsTypedArray":31,"./_baseUnary":35,"./_nodeUtil":87}],109:[function(require,module,exports){var arrayLikeKeys=require("./_arrayLikeKeys"),baseKeys=require("./_baseKeys"),isArrayLike=require("./isArrayLike");function keys(object){return isArrayLike(object)?arrayLikeKeys(object):baseKeys(object)}module.exports=keys},{"./_arrayLikeKeys":17,"./_baseKeys":32,"./isArrayLike":102}],110:[function(require,module,exports){var arrayLikeKeys=require("./_arrayLikeKeys"),baseKeysIn=require("./_baseKeysIn"),isArrayLike=require("./isArrayLike");function keysIn(object){return isArrayLike(object)?arrayLikeKeys(object,true):baseKeysIn(object)}module.exports=keysIn},{"./_arrayLikeKeys":17,"./_baseKeysIn":33,"./isArrayLike":102}],111:[function(require,module,exports){function stubArray(){return[]}module.exports=stubArray},{}],112:[function(require,module,exports){function stubFalse(){return false}module.exports=stubFalse},{}],113:[function(require,module,exports){"use strict";function _classCallCheck(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(r,t){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?r:t}function _inherits(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(r,t):r.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var StructError=function(r){function t(r,e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r));o.name="StructError";for(var n in e)o[n]=e[n];return Error.captureStackTrace(o,o.constructor),o}return _inherits(t,r),t}(Error),ElementInvalidError=function(r){function t(r){var e=r.type,o=r.index,n=r.value,a=r.path,c=void 0===a?[]:a;_classCallCheck(this,t);var i="The element at `"+o+'` in an array was invalid. It should be of type "'+e+'", but it was: '+n,u=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i,{code:"element_invalid",type:e,path:c,index:o,value:n}));return Error.captureStackTrace(u,u.constructor),u}return _inherits(t,r),t}(StructError),PropertyInvalidError=function(r){function t(r){var e=r.type,o=r.key,n=r.value,a=r.path,c=void 0===a?[]:a;_classCallCheck(this,t);var i="The `"+o+'` property in an object was invalid. It should be of type "'+e+'", but it was: '+n,u=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i,{code:"property_invalid",type:e,path:c,key:o,value:n}));return Error.captureStackTrace(u,u.constructor),u}return _inherits(t,r),t}(StructError),PropertyRequiredError=function(r){function t(r){var e=r.type,o=r.key,n=r.path,a=void 0===n?[]:n;_classCallCheck(this,t);var c="The `"+o+'` property is required but was not defined. It should be of type "'+e+'".',i=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,c,{code:"property_required",type:e,path:a,key:o}));return Error.captureStackTrace(i,i.constructor),i}return _inherits(t,r),t}(StructError),PropertyUnknownError=function(r){function t(r){var e=r.key,o=r.path,n=void 0===o?[]:o;_classCallCheck(this,t);var a="The `"+e+"` property in an object was not recognized.",c=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,a,{code:"property_unknown",path:n,key:e}));return Error.captureStackTrace(c,c.constructor),c}return _inherits(t,r),t}(StructError),ValueInvalidError=function(r){function t(r){var e=r.type,o=r.value,n=r.path,a=void 0===n?[]:n;_classCallCheck(this,t);var c='Expected the value "'+o+'" to match type "'+e+'".',i=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,c,{code:"value_invalid",type:e,path:a,value:o}));return Error.captureStackTrace(i,i.constructor),i}return _inherits(t,r),t}(StructError),ValueRequiredError=function(r){function t(r){var e=r.type,o=r.path,n=void 0===o?[]:o;_classCallCheck(this,t);var a='A required property was not defined. It should be of type "'+e+'".',c=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,a,{code:"value_required",type:e,path:n}));return Error.captureStackTrace(c,c.constructor),c}return _inherits(t,r),t}(StructError);exports.ElementInvalidError=ElementInvalidError,exports.PropertyInvalidError=PropertyInvalidError,exports.PropertyRequiredError=PropertyRequiredError,exports.PropertyUnknownError=PropertyUnknownError,exports.ValueInvalidError=ValueInvalidError,exports.ValueRequiredError=ValueRequiredError},{}],114:[function(require,module,exports){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function superstruct(){function e(e,r){var t=e.endsWith("?"),o=t?e.slice(0,-1):e,n=o.split(/\s*\|\s*/g),a=n.map(function(e){var r=u[e];if("function"!=typeof r)throw new Error('No struct validator function found for type "'+e+'".');return r});return function(e){if(!t&&void 0===e)throw new _errors.ValueRequiredError({type:o});if(void 0!==e&&!a.some(function(r){return r(e)}))throw new _errors.ValueInvalidError({type:o,value:e});return e}}function r(e,r){if(1!==e.length)throw new Error("List structs must be defined as an array with a single element, but you passed "+e.length+" elements.");e=e[0];var t=o(e);return function(e){if(void 0===e)throw new _errors.ValueRequiredError({type:"array"});if("array"!==(0,_componentType2.default)(e))throw new _errors.ValueInvalidError({type:"array",value:e});return e.map(function(e,r){try{return t(e)}catch(e){var o=[r].concat(e.path);switch(e.code){case"value_invalid":throw new _errors.ElementInvalidError(_extends({},e,{index:r,path:o}));default:throw"path"in e&&(e.path=o),e}}})}}function t(e,r){var t={};for(var n in e){var u=o(e[n]);t[n]=u}return function(e){var r=!1;if(void 0===e)r=!0,e={};else if("object"!==(0,_componentType2.default)(e))throw new _errors.ValueInvalidError({type:"object",value:e});var o={};for(var n in t){var u=t[n],a=e[n],i=void 0;try{i=u(a)}catch(e){var s=[n].concat(e.path);switch(e.code){case"value_invalid":throw new _errors.PropertyInvalidError(_extends({},e,{key:n,path:s}));case"value_required":throw r?new _errors.ValueRequiredError({type:"object"}):new _errors.PropertyRequiredError(_extends({},e,{key:n,path:s}));default:throw"path"in e&&(e.path=s),e}}n in e&&(o[n]=i)}for(var p in e)if(!(p in t))throw new _errors.PropertyUnknownError({key:p,path:[p]});return r?void 0:o}}function o(o,n){var u=void 0;if("function"===(0,_componentType2.default)(o))u=o;else if("string"===(0,_componentType2.default)(o))u=e(o,n);else if("array"===(0,_componentType2.default)(o))u=r(o,n);else{if("object"!==(0,_componentType2.default)(o))throw new Error("A struct schema definition must be a string, array or object, but you passed: "+o);u=t(o,n)}return function(e){return void 0===e&&(e="function"==typeof n?n():(0,_cloneDeep2.default)(n)),u(e)}}var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=_extends({},_types2.default,n.types||{});return o}Object.defineProperty(exports,"__esModule",{value:!0}),exports.superstruct=exports.struct=void 0;var _extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},_cloneDeep=require("lodash/cloneDeep"),_cloneDeep2=_interopRequireDefault(_cloneDeep),_componentType=require("component-type"),_componentType2=_interopRequireDefault(_componentType),_types=require("./types"),_types2=_interopRequireDefault(_types),_errors=require("./errors"),struct=superstruct();exports.default=struct,exports.struct=struct,exports.superstruct=superstruct},{"./errors":113,"./types":115,"component-type":1,"lodash/cloneDeep":98}],115:[function(require,module,exports){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var _componentType=require("component-type"),_componentType2=_interopRequireDefault(_componentType);exports.default={any:function(e){return void 0!==e},array:function(e){return"array"===(0,_componentType2.default)(e)},boolean:function(e){return"boolean"===(0,_componentType2.default)(e)},buffer:function(e){return"buffer"===(0,_componentType2.default)(e)},date:function(e){return"date"===(0,_componentType2.default)(e)},error:function(e){return"error"===(0,_componentType2.default)(e)},function:function(e){return"string"===(0,_componentType2.default)(e)},null:function(e){return"null"===(0,_componentType2.default)(e)},number:function(e){return"number"===(0,_componentType2.default)(e)},object:function(e){return"object"===(0,_componentType2.default)(e)},regexp:function(e){return"regexp"===(0,_componentType2.default)(e)},string:function(e){return"string"===(0,_componentType2.default)(e)},undefined:function(e){return"undefined"===(0,_componentType2.default)(e)}}},{"component-type":1}]},{},[114])(114)}); | ||
var baseCreate=require("./_baseCreate"),getPrototype=require("./_getPrototype"),isPrototype=require("./_isPrototype");function initCloneObject(object){return typeof object.constructor=="function"&&!isPrototype(object)?baseCreate(getPrototype(object)):{}}module.exports=initCloneObject},{"./_baseCreate":26,"./_getPrototype":55,"./_isPrototype":72}],69:[function(require,module,exports){var MAX_SAFE_INTEGER=9007199254740991;var reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(value,length){length=length==null?MAX_SAFE_INTEGER:length;return!!length&&(typeof value=="number"||reIsUint.test(value))&&(value>-1&&value%1==0&&value<length)}module.exports=isIndex},{}],70:[function(require,module,exports){function isKeyable(value){var type=typeof value;return type=="string"||type=="number"||type=="symbol"||type=="boolean"?value!=="__proto__":value===null}module.exports=isKeyable},{}],71:[function(require,module,exports){var coreJsData=require("./_coreJsData");var maskSrcKey=function(){var uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return uid?"Symbol(src)_1."+uid:""}();function isMasked(func){return!!maskSrcKey&&maskSrcKey in func}module.exports=isMasked},{"./_coreJsData":48}],72:[function(require,module,exports){var objectProto=Object.prototype;function isPrototype(value){var Ctor=value&&value.constructor,proto=typeof Ctor=="function"&&Ctor.prototype||objectProto;return value===proto}module.exports=isPrototype},{}],73:[function(require,module,exports){function listCacheClear(){this.__data__=[];this.size=0}module.exports=listCacheClear},{}],74:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");var arrayProto=Array.prototype;var splice=arrayProto.splice;function listCacheDelete(key){var data=this.__data__,index=assocIndexOf(data,key);if(index<0){return false}var lastIndex=data.length-1;if(index==lastIndex){data.pop()}else{splice.call(data,index,1)}--this.size;return true}module.exports=listCacheDelete},{"./_assocIndexOf":21}],75:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");function listCacheGet(key){var data=this.__data__,index=assocIndexOf(data,key);return index<0?undefined:data[index][1]}module.exports=listCacheGet},{"./_assocIndexOf":21}],76:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");function listCacheHas(key){return assocIndexOf(this.__data__,key)>-1}module.exports=listCacheHas},{"./_assocIndexOf":21}],77:[function(require,module,exports){var assocIndexOf=require("./_assocIndexOf");function listCacheSet(key,value){var data=this.__data__,index=assocIndexOf(data,key);if(index<0){++this.size;data.push([key,value])}else{data[index][1]=value}return this}module.exports=listCacheSet},{"./_assocIndexOf":21}],78:[function(require,module,exports){var Hash=require("./_Hash"),ListCache=require("./_ListCache"),Map=require("./_Map");function mapCacheClear(){this.size=0;this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}module.exports=mapCacheClear},{"./_Hash":3,"./_ListCache":4,"./_Map":5}],79:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheDelete(key){var result=getMapData(this,key)["delete"](key);this.size-=result?1:0;return result}module.exports=mapCacheDelete},{"./_getMapData":53}],80:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheGet(key){return getMapData(this,key).get(key)}module.exports=mapCacheGet},{"./_getMapData":53}],81:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheHas(key){return getMapData(this,key).has(key)}module.exports=mapCacheHas},{"./_getMapData":53}],82:[function(require,module,exports){var getMapData=require("./_getMapData");function mapCacheSet(key,value){var data=getMapData(this,key),size=data.size;data.set(key,value);this.size+=data.size==size?0:1;return this}module.exports=mapCacheSet},{"./_getMapData":53}],83:[function(require,module,exports){function mapToArray(map){var index=-1,result=Array(map.size);map.forEach(function(value,key){result[++index]=[key,value]});return result}module.exports=mapToArray},{}],84:[function(require,module,exports){var getNative=require("./_getNative");var nativeCreate=getNative(Object,"create");module.exports=nativeCreate},{"./_getNative":54}],85:[function(require,module,exports){var overArg=require("./_overArg");var nativeKeys=overArg(Object.keys,Object);module.exports=nativeKeys},{"./_overArg":89}],86:[function(require,module,exports){function nativeKeysIn(object){var result=[];if(object!=null){for(var key in Object(object)){result.push(key)}}return result}module.exports=nativeKeysIn},{}],87:[function(require,module,exports){var freeGlobal=require("./_freeGlobal");var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports;var freeProcess=moduleExports&&freeGlobal.process;var nodeUtil=function(){try{return freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}();module.exports=nodeUtil},{"./_freeGlobal":50}],88:[function(require,module,exports){var objectProto=Object.prototype;var nativeObjectToString=objectProto.toString;function objectToString(value){return nativeObjectToString.call(value)}module.exports=objectToString},{}],89:[function(require,module,exports){function overArg(func,transform){return function(arg){return func(transform(arg))}}module.exports=overArg},{}],90:[function(require,module,exports){var freeGlobal=require("./_freeGlobal");var freeSelf=typeof self=="object"&&self&&self.Object===Object&&self;var root=freeGlobal||freeSelf||Function("return this")();module.exports=root},{"./_freeGlobal":50}],91:[function(require,module,exports){function setToArray(set){var index=-1,result=Array(set.size);set.forEach(function(value){result[++index]=value});return result}module.exports=setToArray},{}],92:[function(require,module,exports){var ListCache=require("./_ListCache");function stackClear(){this.__data__=new ListCache;this.size=0}module.exports=stackClear},{"./_ListCache":4}],93:[function(require,module,exports){function stackDelete(key){var data=this.__data__,result=data["delete"](key);this.size=data.size;return result}module.exports=stackDelete},{}],94:[function(require,module,exports){function stackGet(key){return this.__data__.get(key)}module.exports=stackGet},{}],95:[function(require,module,exports){function stackHas(key){return this.__data__.has(key)}module.exports=stackHas},{}],96:[function(require,module,exports){var ListCache=require("./_ListCache"),Map=require("./_Map"),MapCache=require("./_MapCache");var LARGE_ARRAY_SIZE=200;function stackSet(key,value){var data=this.__data__;if(data instanceof ListCache){var pairs=data.__data__;if(!Map||pairs.length<LARGE_ARRAY_SIZE-1){pairs.push([key,value]);this.size=++data.size;return this}data=this.__data__=new MapCache(pairs)}data.set(key,value);this.size=data.size;return this}module.exports=stackSet},{"./_ListCache":4,"./_Map":5,"./_MapCache":6}],97:[function(require,module,exports){var funcProto=Function.prototype;var funcToString=funcProto.toString;function toSource(func){if(func!=null){try{return funcToString.call(func)}catch(e){}try{return func+""}catch(e){}}return""}module.exports=toSource},{}],98:[function(require,module,exports){var baseClone=require("./_baseClone");var CLONE_DEEP_FLAG=1,CLONE_SYMBOLS_FLAG=4;function cloneDeep(value){return baseClone(value,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG)}module.exports=cloneDeep},{"./_baseClone":25}],99:[function(require,module,exports){function eq(value,other){return value===other||value!==value&&other!==other}module.exports=eq},{}],100:[function(require,module,exports){var baseIsArguments=require("./_baseIsArguments"),isObjectLike=require("./isObjectLike");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var propertyIsEnumerable=objectProto.propertyIsEnumerable;var isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(value){return isObjectLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")};module.exports=isArguments},{"./_baseIsArguments":29,"./isObjectLike":107}],101:[function(require,module,exports){var isArray=Array.isArray;module.exports=isArray},{}],102:[function(require,module,exports){var isFunction=require("./isFunction"),isLength=require("./isLength");function isArrayLike(value){return value!=null&&isLength(value.length)&&!isFunction(value)}module.exports=isArrayLike},{"./isFunction":104,"./isLength":105}],103:[function(require,module,exports){var root=require("./_root"),stubFalse=require("./stubFalse");var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports;var Buffer=moduleExports?root.Buffer:undefined;var nativeIsBuffer=Buffer?Buffer.isBuffer:undefined;var isBuffer=nativeIsBuffer||stubFalse;module.exports=isBuffer},{"./_root":90,"./stubFalse":112}],104:[function(require,module,exports){var baseGetTag=require("./_baseGetTag"),isObject=require("./isObject");var asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(value){if(!isObject(value)){return false}var tag=baseGetTag(value);return tag==funcTag||tag==genTag||tag==asyncTag||tag==proxyTag}module.exports=isFunction},{"./_baseGetTag":28,"./isObject":106}],105:[function(require,module,exports){var MAX_SAFE_INTEGER=9007199254740991;function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}module.exports=isLength},{}],106:[function(require,module,exports){function isObject(value){var type=typeof value;return value!=null&&(type=="object"||type=="function")}module.exports=isObject},{}],107:[function(require,module,exports){function isObjectLike(value){return value!=null&&typeof value=="object"}module.exports=isObjectLike},{}],108:[function(require,module,exports){var baseIsTypedArray=require("./_baseIsTypedArray"),baseUnary=require("./_baseUnary"),nodeUtil=require("./_nodeUtil");var nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray;var isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;module.exports=isTypedArray},{"./_baseIsTypedArray":31,"./_baseUnary":35,"./_nodeUtil":87}],109:[function(require,module,exports){var arrayLikeKeys=require("./_arrayLikeKeys"),baseKeys=require("./_baseKeys"),isArrayLike=require("./isArrayLike");function keys(object){return isArrayLike(object)?arrayLikeKeys(object):baseKeys(object)}module.exports=keys},{"./_arrayLikeKeys":17,"./_baseKeys":32,"./isArrayLike":102}],110:[function(require,module,exports){var arrayLikeKeys=require("./_arrayLikeKeys"),baseKeysIn=require("./_baseKeysIn"),isArrayLike=require("./isArrayLike");function keysIn(object){return isArrayLike(object)?arrayLikeKeys(object,true):baseKeysIn(object)}module.exports=keysIn},{"./_arrayLikeKeys":17,"./_baseKeysIn":33,"./isArrayLike":102}],111:[function(require,module,exports){function stubArray(){return[]}module.exports=stubArray},{}],112:[function(require,module,exports){function stubFalse(){return false}module.exports=stubFalse},{}],113:[function(require,module,exports){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function superstruct(){function e(e,t){var r=e.endsWith("?"),n=r?e.slice(0,-1):e,o=n.split(/\s*\|\s*/g),a=o.map(function(e){var t=u[e];if("function"!=typeof t)throw new Error('No struct validator function found for type "'+e+'".');return t});return function(e){if(!r&&void 0===e)throw new StructError("value_required",{type:n});if(void 0!==e&&!a.some(function(t){return t(e)}))throw new StructError("value_invalid",{type:n,value:e});return e}}function t(e,t){if(1!==e.length)throw new Error("List structs must be defined as an array with a single element, but you passed "+e.length+" elements.");e=e[0];var r=n(e);return function(e){if(void 0===e)throw new StructError("value_required",{type:"array"});if("array"!==(0,_componentType2.default)(e))throw new StructError("value_invalid",{type:"array",value:e});return e.map(function(e,t){try{return r(e)}catch(e){var n=[t].concat(e.path);switch(e.code){case"value_invalid":throw new StructError("element_invalid",_extends({},e,{index:t,path:n}));default:throw"path"in e&&(e.path=n),e}}})}}function r(e,t){var r={};for(var o in e){var u=n(e[o]);r[o]=u}return function(e){var t=!1;if(void 0===e)t=!0,e={};else if("object"!==(0,_componentType2.default)(e))throw new StructError("value_invalid",{type:"object",value:e});var n={};for(var o in r){var u=r[o],a=e[o],c=void 0;try{c=u(a)}catch(e){var i=[o].concat(e.path);switch(e.code){case"value_invalid":throw new StructError("property_invalid",_extends({},e,{key:o,path:i}));case"value_required":throw t?new StructError("value_required",{type:"object"}):new StructError("property_required",_extends({},e,{key:o,path:i}));default:throw"path"in e&&(e.path=i),e}}o in e&&(n[o]=c)}for(var p in e)if(!(p in r))throw new StructError("property_unknown",{key:p,path:[p]});return t?void 0:n}}function n(n,o){var u=void 0;if("function"===(0,_componentType2.default)(n))u=n;else if("string"===(0,_componentType2.default)(n))u=e(n,o);else if("array"===(0,_componentType2.default)(n))u=t(n,o);else{if("object"!==(0,_componentType2.default)(n))throw new Error("A struct schema definition must be a string, array or object, but you passed: "+n);u=r(n,o)}return function(e){return void 0===e&&(e="function"==typeof o?o():(0,_cloneDeep2.default)(o)),u(e)}}var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=_extends({},DEFAULT_TYPES,o.types||{});return n}Object.defineProperty(exports,"__esModule",{value:!0}),exports.StructError=exports.superstruct=exports.struct=void 0;var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_cloneDeep=require("lodash/cloneDeep"),_cloneDeep2=_interopRequireDefault(_cloneDeep),_componentType=require("component-type"),_componentType2=_interopRequireDefault(_componentType),DEFAULT_TYPES={any:function(e){return void 0!==e},array:function(e){return"array"===(0,_componentType2.default)(e)},boolean:function(e){return"boolean"===(0,_componentType2.default)(e)},buffer:function(e){return"buffer"===(0,_componentType2.default)(e)},date:function(e){return"date"===(0,_componentType2.default)(e)},error:function(e){return"error"===(0,_componentType2.default)(e)},function:function(e){return"string"===(0,_componentType2.default)(e)},null:function(e){return"null"===(0,_componentType2.default)(e)},number:function(e){return"number"===(0,_componentType2.default)(e)},object:function(e){return"object"===(0,_componentType2.default)(e)},regexp:function(e){return"regexp"===(0,_componentType2.default)(e)},string:function(e){return"string"===(0,_componentType2.default)(e)},undefined:function(e){return"undefined"===(0,_componentType2.default)(e)}},StructError=function(e){function t(e,r){_classCallCheck(this,t),r.code=e,r.path=r.path||[];var n=r.index,o=r.key,u=r.value,a=r.type;switch(e){case"element_invalid":e="Expected the element at index `"+n+'` to be of type "'+a+'", but it was `'+u+"`.";break;case"property_invalid":case"property_required":e="Expected the `"+o+'` property to be of type "'+a+'", but it was `'+u+"`.";break;case"property_unknown":e="Unexpected `"+o+"` property that was not defined in the struct.";break;case"value_invalid":case"value_required":e='Expected a value of type "'+a+'" but received `'+u+"`.";break;default:throw new Error('Unknown struct error code: "'+e+'"')}var c=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));c.name="StructError";for(var i in r)c[i]=r[i];return Error.captureStackTrace(c,c.constructor),c}return _inherits(t,e),t}(Error),struct=superstruct();exports.default=struct,exports.struct=struct,exports.superstruct=superstruct,exports.StructError=StructError},{"component-type":1,"lodash/cloneDeep":98}]},{},[113])(113)}); |
@@ -25,2 +25,32 @@ 'use strict'; | ||
data.code = message; | ||
var index = data.index, | ||
key = data.key, | ||
value = data.value, | ||
type = data.type; | ||
switch (message) { | ||
case 'element_invalid': | ||
message = 'The element at `' + index + '` in an array was invalid. It should be of type "' + type + '", but it was: ' + value; | ||
break; | ||
case 'property_invalid': | ||
message = 'The `' + key + '` property in an object was invalid. It should be of type "' + type + '", but it was: ' + value; | ||
break; | ||
case 'property_required': | ||
message = 'The `' + key + '` property is required but was not defined. It should be of type "' + type + '".'; | ||
break; | ||
case 'property_unknown': | ||
message = 'The `' + key + '` property in an object was not recognized.'; | ||
break; | ||
case 'value_invalid': | ||
message = 'Expected the value "' + value + '" to match type "' + type + '".'; | ||
break; | ||
case 'value_required': | ||
message = 'A required property was not defined. It should be of type "' + type + '".'; | ||
break; | ||
default: | ||
throw new Error('Unknown struct error code: "' + message + '"'); | ||
} | ||
var _this = _possibleConstructorReturn(this, (StructError.__proto__ || Object.getPrototypeOf(StructError)).call(this, message)); | ||
@@ -30,4 +60,4 @@ | ||
for (var key in data) { | ||
_this[key] = data[key]; | ||
for (var k in data) { | ||
_this[k] = data[k]; | ||
} | ||
@@ -34,0 +64,0 @@ |
157
lib/index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.superstruct = exports.struct = undefined; | ||
exports.StructError = exports.superstruct = exports.struct = undefined; | ||
@@ -19,11 +19,113 @@ var _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; }; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _types2 = _interopRequireDefault(_types); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _errors = require('./errors'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/** | ||
* Default types. | ||
* | ||
* @type {Object} | ||
*/ | ||
var DEFAULT_TYPES = { | ||
any: function any(v) { | ||
return v !== undefined; | ||
}, | ||
array: function array(v) { | ||
return (0, _componentType2.default)(v) === 'array'; | ||
}, | ||
boolean: function boolean(v) { | ||
return (0, _componentType2.default)(v) === 'boolean'; | ||
}, | ||
buffer: function buffer(v) { | ||
return (0, _componentType2.default)(v) === 'buffer'; | ||
}, | ||
date: function date(v) { | ||
return (0, _componentType2.default)(v) === 'date'; | ||
}, | ||
error: function error(v) { | ||
return (0, _componentType2.default)(v) === 'error'; | ||
}, | ||
function: function _function(v) { | ||
return (0, _componentType2.default)(v) === 'string'; | ||
}, | ||
null: function _null(v) { | ||
return (0, _componentType2.default)(v) === 'null'; | ||
}, | ||
number: function number(v) { | ||
return (0, _componentType2.default)(v) === 'number'; | ||
}, | ||
object: function object(v) { | ||
return (0, _componentType2.default)(v) === 'object'; | ||
}, | ||
regexp: function regexp(v) { | ||
return (0, _componentType2.default)(v) === 'regexp'; | ||
}, | ||
string: function string(v) { | ||
return (0, _componentType2.default)(v) === 'string'; | ||
}, | ||
undefined: function undefined(v) { | ||
return (0, _componentType2.default)(v) === 'undefined'; | ||
} | ||
/** | ||
* Define a struct error. | ||
* | ||
* @type {StructError} | ||
*/ | ||
}; | ||
var StructError = function (_Error) { | ||
_inherits(StructError, _Error); | ||
function StructError(message, data) { | ||
_classCallCheck(this, StructError); | ||
data.code = message; | ||
data.path = data.path || []; | ||
var index = data.index, | ||
key = data.key, | ||
value = data.value, | ||
type = data.type; | ||
switch (message) { | ||
case 'element_invalid': | ||
message = 'Expected the element at index `' + index + '` to be of type "' + type + '", but it was `' + value + '`.'; | ||
break; | ||
case 'property_invalid': | ||
case 'property_required': | ||
message = 'Expected the `' + key + '` property to be of type "' + type + '", but it was `' + value + '`.'; | ||
break; | ||
case 'property_unknown': | ||
message = 'Unexpected `' + key + '` property that was not defined in the struct.'; | ||
break; | ||
case 'value_invalid': | ||
case 'value_required': | ||
message = 'Expected a value of type "' + type + '" but received `' + value + '`.'; | ||
break; | ||
default: | ||
throw new Error('Unknown struct error code: "' + message + '"'); | ||
} | ||
var _this = _possibleConstructorReturn(this, (StructError.__proto__ || Object.getPrototypeOf(StructError)).call(this, message)); | ||
_this.name = 'StructError'; | ||
for (var k in data) { | ||
_this[k] = data[k]; | ||
} | ||
Error.captureStackTrace(_this, _this.constructor); | ||
return _this; | ||
} | ||
return StructError; | ||
}(Error); | ||
/** | ||
* Create a struct factory from a set of `options`. | ||
@@ -38,3 +140,3 @@ * | ||
var TYPES = _extends({}, _types2.default, options.types || {}); | ||
var TYPES = _extends({}, DEFAULT_TYPES, options.types || {}); | ||
@@ -66,3 +168,3 @@ /** | ||
if (!isOptional && value === undefined) { | ||
throw new _errors.ValueRequiredError({ type: type }); | ||
throw new StructError('value_required', { type: type }); | ||
} | ||
@@ -73,3 +175,3 @@ | ||
})) { | ||
throw new _errors.ValueInvalidError({ type: type, value: value }); | ||
throw new StructError('value_invalid', { type: type, value: value }); | ||
} | ||
@@ -100,5 +202,5 @@ | ||
if (value === undefined) { | ||
throw new _errors.ValueRequiredError({ type: type }); | ||
throw new StructError('value_required', { type: type }); | ||
} else if ((0, _componentType2.default)(value) !== 'array') { | ||
throw new _errors.ValueInvalidError({ type: type, value: value }); | ||
throw new StructError('value_invalid', { type: type, value: value }); | ||
} | ||
@@ -114,3 +216,3 @@ | ||
case 'value_invalid': | ||
throw new _errors.ElementInvalidError(_extends({}, e, { index: index, path: path })); | ||
throw new StructError('element_invalid', _extends({}, e, { index: index, path: path })); | ||
default: | ||
@@ -139,5 +241,5 @@ if ('path' in e) e.path = path; | ||
for (var key in schema) { | ||
var fn = struct(schema[key]); | ||
structs[key] = fn; | ||
for (var _key in schema) { | ||
var fn = struct(schema[_key]); | ||
structs[_key] = fn; | ||
} | ||
@@ -152,3 +254,3 @@ | ||
} else if ((0, _componentType2.default)(value) !== 'object') { | ||
throw new _errors.ValueInvalidError({ type: type, value: value }); | ||
throw new StructError('value_invalid', { type: type, value: value }); | ||
} | ||
@@ -158,5 +260,5 @@ | ||
for (var _key in structs) { | ||
var s = structs[_key]; | ||
var v = value[_key]; | ||
for (var _key2 in structs) { | ||
var s = structs[_key2]; | ||
var v = value[_key2]; | ||
var r = void 0; | ||
@@ -167,9 +269,9 @@ | ||
} catch (e) { | ||
var path = [_key].concat(e.path); | ||
var path = [_key2].concat(e.path); | ||
switch (e.code) { | ||
case 'value_invalid': | ||
throw new _errors.PropertyInvalidError(_extends({}, e, { key: _key, path: path })); | ||
throw new StructError('property_invalid', _extends({}, e, { key: _key2, path: path })); | ||
case 'value_required': | ||
throw isUndefined ? new _errors.ValueRequiredError({ type: type }) : new _errors.PropertyRequiredError(_extends({}, e, { key: _key, path: path })); | ||
throw isUndefined ? new StructError('value_required', { type: type }) : new StructError('property_required', _extends({}, e, { key: _key2, path: path })); | ||
default: | ||
@@ -181,10 +283,10 @@ if ('path' in e) e.path = path; | ||
if (_key in value) { | ||
ret[_key] = r; | ||
if (_key2 in value) { | ||
ret[_key2] = r; | ||
} | ||
} | ||
for (var _key2 in value) { | ||
if (!(_key2 in structs)) { | ||
throw new _errors.PropertyUnknownError({ key: _key2, path: [_key2] }); | ||
for (var _key3 in value) { | ||
if (!(_key3 in structs)) { | ||
throw new StructError('property_unknown', { key: _key3, path: [_key3] }); | ||
} | ||
@@ -246,2 +348,3 @@ } | ||
exports.struct = struct; | ||
exports.superstruct = superstruct; | ||
exports.superstruct = superstruct; | ||
exports.StructError = StructError; |
{ | ||
"name": "superstruct", | ||
"description": "A simple, expressive way to validate data in Javascript.", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/ianstormtaylor/superstruct.git", |
@@ -5,14 +5,69 @@ | ||
import DEFAULT_TYPES from './types' | ||
/** | ||
* Default types. | ||
* | ||
* @type {Object} | ||
*/ | ||
import { | ||
ElementInvalidError, | ||
PropertyInvalidError, | ||
PropertyRequiredError, | ||
PropertyUnknownError, | ||
ValueInvalidError, | ||
ValueRequiredError, | ||
} from './errors' | ||
const DEFAULT_TYPES = { | ||
any: v => v !== undefined, | ||
array: v => typeOf(v) === 'array', | ||
boolean: v => typeOf(v) === 'boolean', | ||
buffer: v => typeOf(v) === 'buffer', | ||
date: v => typeOf(v) === 'date', | ||
error: v => typeOf(v) === 'error', | ||
function: v => typeOf(v) === 'string', | ||
null: v => typeOf(v) === 'null', | ||
number: v => typeOf(v) === 'number', | ||
object: v => typeOf(v) === 'object', | ||
regexp: v => typeOf(v) === 'regexp', | ||
string: v => typeOf(v) === 'string', | ||
undefined: v => typeOf(v) === 'undefined', | ||
} | ||
/** | ||
* Define a struct error. | ||
* | ||
* @type {StructError} | ||
*/ | ||
class StructError extends Error { | ||
constructor(message, data) { | ||
data.code = message | ||
data.path = data.path || [] | ||
const { index, key, value, type } = data | ||
switch (message) { | ||
case 'element_invalid': | ||
message = `Expected the element at index \`${index}\` to be of type "${type}", but it was \`${value}\`.` | ||
break | ||
case 'property_invalid': | ||
case 'property_required': | ||
message = `Expected the \`${key}\` property to be of type "${type}", but it was \`${value}\`.` | ||
break | ||
case 'property_unknown': | ||
message = `Unexpected \`${key}\` property that was not defined in the struct.` | ||
break | ||
case 'value_invalid': | ||
case 'value_required': | ||
message = `Expected a value of type "${type}" but received \`${value}\`.` | ||
break | ||
default: | ||
throw new Error(`Unknown struct error code: "${message}"`) | ||
} | ||
super(message) | ||
this.name = 'StructError' | ||
for (const k in data) { | ||
this[k] = data[k] | ||
} | ||
Error.captureStackTrace(this, this.constructor) | ||
} | ||
} | ||
/** | ||
* Create a struct factory from a set of `options`. | ||
@@ -55,7 +110,7 @@ * | ||
if (!isOptional && value === undefined) { | ||
throw new ValueRequiredError({ type }) | ||
throw new StructError('value_required', { type }) | ||
} | ||
if (value !== undefined && !fns.some(fn => fn(value))) { | ||
throw new ValueInvalidError({ type, value }) | ||
throw new StructError('value_invalid', { type, value }) | ||
} | ||
@@ -86,5 +141,5 @@ | ||
if (value === undefined) { | ||
throw new ValueRequiredError({ type }) | ||
throw new StructError('value_required', { type }) | ||
} else if (typeOf(value) !== 'array') { | ||
throw new ValueInvalidError({ type, value }) | ||
throw new StructError('value_invalid', { type, value }) | ||
} | ||
@@ -100,3 +155,3 @@ | ||
case 'value_invalid': | ||
throw new ElementInvalidError({ ...e, index, path }) | ||
throw new StructError('element_invalid', { ...e, index, path }) | ||
default: | ||
@@ -137,3 +192,3 @@ if ('path' in e) e.path = path | ||
} else if (typeOf(value) !== 'object') { | ||
throw new ValueInvalidError({ type, value }) | ||
throw new StructError('value_invalid', { type, value }) | ||
} | ||
@@ -155,7 +210,7 @@ | ||
case 'value_invalid': | ||
throw new PropertyInvalidError({ ...e, key, path }) | ||
throw new StructError('property_invalid', { ...e, key, path }) | ||
case 'value_required': | ||
throw isUndefined | ||
? new ValueRequiredError({ type }) | ||
: new PropertyRequiredError({ ...e, key, path }) | ||
? new StructError('value_required', { type }) | ||
: new StructError('property_required', { ...e, key, path }) | ||
default: | ||
@@ -174,3 +229,3 @@ if ('path' in e) e.path = path | ||
if (!(key in structs)) { | ||
throw new PropertyUnknownError({ key, path: [key] }) | ||
throw new StructError('property_unknown', { key, path: [key] }) | ||
} | ||
@@ -233,2 +288,2 @@ } | ||
export default struct | ||
export { struct, superstruct } | ||
export { struct, superstruct, StructError } |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
606985
23
3735