Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

optimal

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimal - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

30

lib/ArrayBuilder.js

@@ -33,14 +33,4 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
var ArrayBuilder = function (_Builder) {

@@ -56,3 +46,3 @@ (0, _inherits3.default)(ArrayBuilder, _Builder);

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(contents instanceof _Builder3.default, 'A blueprint is required for array contents.');
_this.invariant(contents instanceof _Builder3.default, 'A blueprint is required for array contents.');
}

@@ -73,5 +63,21 @@

}
}, {
key: 'notEmpty',
value: function notEmpty() {
return this.addCheck(this.checkNotEmpty);
}
}, {
key: 'checkNotEmpty',
value: function checkNotEmpty(path, array) {
if ("production" !== process.env.NODE_ENV) {
this.invariant(array.length > 0, 'Array cannot be empty.', path);
}
}
}]);
return ArrayBuilder;
}(_Builder3.default);
}(_Builder3.default); /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/

@@ -78,0 +84,0 @@ exports.default = ArrayBuilder;

78

lib/Builder.js

@@ -23,6 +23,2 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
var _isObject = require('./isObject');

@@ -34,8 +30,2 @@

/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
var Builder = function () {

@@ -45,2 +35,3 @@ function Builder(type, defaultValue) {

this.checks = [];
this.currentConfig = {};
this.errorMessage = '';

@@ -50,5 +41,3 @@ this.nullable = true;

if ("production" !== process.env.NODE_ENV) {
if (typeof defaultValue === 'undefined') {
throw new TypeError('A default value for type "' + type + '" is required.');
}
this.invariant(typeof defaultValue !== 'undefined', 'A default value for type "' + type + '" is required.');
}

@@ -80,3 +69,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(value === this.defaultValue, 'Value may only be "' + String(this.defaultValue) + '".', path);
this.invariant(value === this.defaultValue, 'Value may only be "' + String(this.defaultValue) + '".', path);
}

@@ -90,3 +79,3 @@ }

case 'array':
(0, _invariant2.default)(Array.isArray(value), 'Must be an array.', path);
this.invariant(Array.isArray(value), 'Must be an array.', path);
break;

@@ -100,7 +89,7 @@

case 'shape':
(0, _invariant2.default)((0, _isObject2.default)(value), 'Must be a plain object.', path);
this.invariant((0, _isObject2.default)(value), 'Must be a plain object.', path);
break;
default:
(0, _invariant2.default)((typeof value === 'undefined' ? 'undefined' : (0, _typeof3.default)(value)) === this.type, 'Must be a ' + this.type + '.', path);
this.invariant((typeof value === 'undefined' ? 'undefined' : (0, _typeof3.default)(value)) === this.type, 'Must be a ' + this.type + '.', path);
break;

@@ -111,6 +100,31 @@ }

}, {
key: 'invariant',
value: function invariant(condition, message) {
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
if ("production" !== process.env.NODE_ENV) {
if (condition) {
return;
}
var name = this.currentConfig.name;
var prefix = '';
if (path) {
if (name) {
prefix += 'Invalid `' + name + '` option "' + path + '". ';
} else {
prefix += 'Invalid option "' + path + '". ';
}
}
throw new Error('' + prefix + (this.errorMessage || message));
}
}
}, {
key: 'message',
value: function message(_message) {
if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(typeof _message === 'string' && _message, 'A non-empty string is required for custom messages.');
this.invariant(typeof _message === 'string' && !!_message, 'A non-empty string is required for custom messages.');
}

@@ -126,3 +140,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)((0, _typeof3.default)(this.defaultValue) === this.type, 'only() requires a default ' + this.type + ' value.');
this.invariant((0, _typeof3.default)(this.defaultValue) === this.type, 'only() requires a default ' + this.type + ' value.');
}

@@ -144,2 +158,6 @@

var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
this.currentConfig = config;
var value = typeof initialValue === 'undefined' ? this.defaultValue : initialValue;

@@ -152,15 +170,7 @@

if ("production" !== process.env.NODE_ENV) {
try {
this.checks.forEach(function (checker) {
var _checker$func;
this.checks.forEach(function (checker) {
var _checker$func;
(_checker$func = checker.func).call.apply(_checker$func, [_this, path, value].concat((0, _toConsumableArray3.default)(checker.args)));
});
} catch (error) {
if (this.errorMessage) {
(0, _invariant2.default)(false, this.errorMessage, path);
} else {
throw error;
}
}
(_checker$func = checker.func).call.apply(_checker$func, [_this, path, value].concat((0, _toConsumableArray3.default)(checker.args)));
});
}

@@ -172,4 +182,8 @@

return Builder;
}();
}(); /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
exports.default = Builder;

@@ -1,1 +0,1 @@

"use strict";function unwrapExports(e){return e&&e.__esModule?e.default:e}function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function isObject$1(e){return"object"===(void 0===e?"undefined":_typeof(e))&&null!==e&&!Array.isArray(e)}function arrayOf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return new ArrayBuilder(e,t)}function bool(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new BoolBuilder(e)}function func(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return new FuncBuilder(e)}function instanceOf(e){return new InstanceBuilder(e)}function regex(){return instanceOf(RegExp)}function date(){return instanceOf(Date)}function number(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new NumberBuilder(e)}function objectOf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new ObjectBuilder(e,t)}function shape(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new ShapeBuilder(e,t)}function string(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return new StringBuilder(e)}function union(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new UnionBuilder(e,t)}function buildAndCheckOptions(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=_extends$1({},e),n={};return _Object$keys(t).forEach(function(i){var c=t[i],s=e[i],u=r?r+"."+i:i;c instanceof Builder?n[i]=c.runChecks(u,s):isObject$1(c)&&(n[i]=buildAndCheckOptions(s||{},c,u)),delete o[i]}),n}function Options(e,t){return buildAndCheckOptions(e,t({arrayOf:arrayOf,bool:bool,date:date,func:func,instanceOf:instanceOf,number:number,objectOf:objectOf,regex:regex,shape:shape,string:string,union:union}))}var _defined=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e},_toObject=function(e){return Object(_defined(e))},hasOwnProperty={}.hasOwnProperty,_has=function(e,t){return hasOwnProperty.call(e,t)},toString={}.toString,_cof=function(e){return toString.call(e).slice(8,-1)},_iobject=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==_cof(e)?e.split(""):Object(e)},_toIobject=function(e){return _iobject(_defined(e))},ceil=Math.ceil,floor=Math.floor,_toInteger=function(e){return isNaN(e=+e)?0:(e>0?floor:ceil)(e)},min=Math.min,_toLength=function(e){return e>0?min(_toInteger(e),9007199254740991):0},max=Math.max,min$1=Math.min,_toIndex=function(e,t){return e=_toInteger(e),e<0?max(e+t,0):min$1(e,t)},_arrayIncludes=function(e){return function(t,r,o){var n,i=_toIobject(t),c=_toLength(i.length),s=_toIndex(o,c);if(e&&r!=r){for(;c>s;)if((n=i[s++])!=n)return!0}else for(;c>s;s++)if((e||s in i)&&i[s]===r)return e||s||0;return!e&&-1}},_global=createCommonjsModule(function(e){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)}),SHARED="__core-js_shared__",store=_global[SHARED]||(_global[SHARED]={}),_shared=function(e){return store[e]||(store[e]={})},id=0,px=Math.random(),_uid=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++id+px).toString(36))},shared=_shared("keys"),_sharedKey=function(e){return shared[e]||(shared[e]=_uid(e))},arrayIndexOf=_arrayIncludes(!1),IE_PROTO=_sharedKey("IE_PROTO"),_objectKeysInternal=function(e,t){var r,o=_toIobject(e),n=0,i=[];for(r in o)r!=IE_PROTO&&_has(o,r)&&i.push(r);for(;t.length>n;)_has(o,r=t[n++])&&(~arrayIndexOf(i,r)||i.push(r));return i},_enumBugKeys="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),_objectKeys=Object.keys||function(e){return _objectKeysInternal(e,_enumBugKeys)},_core=createCommonjsModule(function(e){var t=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=t)}),_aFunction=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},_ctx=function(e,t,r){if(_aFunction(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,o){return e.call(t,r,o)};case 3:return function(r,o,n){return e.call(t,r,o,n)}}return function(){return e.apply(t,arguments)}},_isObject=function(e){return"object"==typeof e?null!==e:"function"==typeof e},_anObject=function(e){if(!_isObject(e))throw TypeError(e+" is not an object!");return e},_fails=function(e){try{return!!e()}catch(e){return!0}},_descriptors=!_fails(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),document$1=_global.document,is=_isObject(document$1)&&_isObject(document$1.createElement),_domCreate=function(e){return is?document$1.createElement(e):{}},_ie8DomDefine=!_descriptors&&!_fails(function(){return 7!=Object.defineProperty(_domCreate("div"),"a",{get:function(){return 7}}).a}),_toPrimitive=function(e,t){if(!_isObject(e))return e;var r,o;if(t&&"function"==typeof(r=e.toString)&&!_isObject(o=r.call(e)))return o;if("function"==typeof(r=e.valueOf)&&!_isObject(o=r.call(e)))return o;if(!t&&"function"==typeof(r=e.toString)&&!_isObject(o=r.call(e)))return o;throw TypeError("Can't convert object to primitive value")},dP=Object.defineProperty,f=_descriptors?Object.defineProperty:function(e,t,r){if(_anObject(e),t=_toPrimitive(t,!0),_anObject(r),_ie8DomDefine)try{return dP(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e},_objectDp={f:f},_propertyDesc=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},_hide=_descriptors?function(e,t,r){return _objectDp.f(e,t,_propertyDesc(1,r))}:function(e,t,r){return e[t]=r,e},PROTOTYPE="prototype",$export=function(e,t,r){var o,n,i,c=e&$export.F,s=e&$export.G,u=e&$export.S,a=e&$export.P,l=e&$export.B,f=e&$export.W,_=s?_core:_core[t]||(_core[t]={}),p=_[PROTOTYPE],y=s?_global:u?_global[t]:(_global[t]||{})[PROTOTYPE];s&&(r=t);for(o in r)(n=!c&&y&&void 0!==y[o])&&o in _||(i=n?y[o]:r[o],_[o]=s&&"function"!=typeof y[o]?r[o]:l&&n?_ctx(i,_global):f&&y[o]==i?function(e){var t=function(t,r,o){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,r)}return new e(t,r,o)}return e.apply(this,arguments)};return t[PROTOTYPE]=e[PROTOTYPE],t}(i):a&&"function"==typeof i?_ctx(Function.call,i):i,a&&((_.virtual||(_.virtual={}))[o]=i,e&$export.R&&p&&!p[o]&&_hide(p,o,i)))};$export.F=1,$export.G=2,$export.S=4,$export.P=8,$export.B=16,$export.W=32,$export.U=64,$export.R=128;var _export=$export,_objectSap=function(e,t){var r=(_core.Object||{})[e]||Object[e],o={};o[e]=t(r),_export(_export.S+_export.F*_fails(function(){r(1)}),"Object",o)};_objectSap("keys",function(){return function(e){return _objectKeys(_toObject(e))}});var keys$1=_core.Object.keys,keys=createCommonjsModule(function(e){e.exports={default:keys$1,__esModule:!0}}),_Object$keys=unwrapExports(keys),f$1=Object.getOwnPropertySymbols,_objectGops={f:f$1},f$2={}.propertyIsEnumerable,_objectPie={f:f$2},$assign=Object.assign,_objectAssign=!$assign||_fails(function(){var e={},t={},r=Symbol(),o="abcdefghijklmnopqrst";return e[r]=7,o.split("").forEach(function(e){t[e]=e}),7!=$assign({},e)[r]||Object.keys($assign({},t)).join("")!=o})?function(e,t){for(var r=_toObject(e),o=arguments.length,n=1,i=_objectGops.f,c=_objectPie.f;o>n;)for(var s,u=_iobject(arguments[n++]),a=i?_objectKeys(u).concat(i(u)):_objectKeys(u),l=a.length,f=0;l>f;)c.call(u,s=a[f++])&&(r[s]=u[s]);return r}:$assign;_export(_export.S+_export.F,"Object",{assign:_objectAssign});var assign$2=_core.Object.assign,assign=createCommonjsModule(function(e){e.exports={default:assign$2,__esModule:!0}}),_extends=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(assign);t.default=r.default||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}}),_extends$1=unwrapExports(_extends),_stringAt=function(e){return function(t,r){var o,n,i=String(_defined(t)),c=_toInteger(r),s=i.length;return c<0||c>=s?e?"":void 0:(o=i.charCodeAt(c),o<55296||o>56319||c+1===s||(n=i.charCodeAt(c+1))<56320||n>57343?e?i.charAt(c):o:e?i.slice(c,c+2):n-56320+(o-55296<<10)+65536)}},_library=!0,_redefine=_hide,_iterators={},_objectDps=_descriptors?Object.defineProperties:function(e,t){_anObject(e);for(var r,o=_objectKeys(t),n=o.length,i=0;n>i;)_objectDp.f(e,r=o[i++],t[r]);return e},_html=_global.document&&document.documentElement,IE_PROTO$1=_sharedKey("IE_PROTO"),Empty=function(){},PROTOTYPE$1="prototype",createDict=function(){var e,t=_domCreate("iframe"),r=_enumBugKeys.length;for(t.style.display="none",_html.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("<script>document.F=Object<\/script>"),e.close(),createDict=e.F;r--;)delete createDict[PROTOTYPE$1][_enumBugKeys[r]];return createDict()},_objectCreate=Object.create||function(e,t){var r;return null!==e?(Empty[PROTOTYPE$1]=_anObject(e),r=new Empty,Empty[PROTOTYPE$1]=null,r[IE_PROTO$1]=e):r=createDict(),void 0===t?r:_objectDps(r,t)},_wks=createCommonjsModule(function(e){var t=_shared("wks"),r=_global.Symbol,o="function"==typeof r;(e.exports=function(e){return t[e]||(t[e]=o&&r[e]||(o?r:_uid)("Symbol."+e))}).store=t}),def=_objectDp.f,TAG=_wks("toStringTag"),_setToStringTag=function(e,t,r){e&&!_has(e=r?e:e.prototype,TAG)&&def(e,TAG,{configurable:!0,value:t})},IteratorPrototype={};_hide(IteratorPrototype,_wks("iterator"),function(){return this});var _iterCreate=function(e,t,r){e.prototype=_objectCreate(IteratorPrototype,{next:_propertyDesc(1,r)}),_setToStringTag(e,t+" Iterator")},IE_PROTO$2=_sharedKey("IE_PROTO"),ObjectProto=Object.prototype,_objectGpo=Object.getPrototypeOf||function(e){return e=_toObject(e),_has(e,IE_PROTO$2)?e[IE_PROTO$2]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?ObjectProto:null},ITERATOR=_wks("iterator"),BUGGY=!([].keys&&"next"in[].keys()),FF_ITERATOR="@@iterator",KEYS="keys",VALUES="values",returnThis=function(){return this},_iterDefine=function(e,t,r,o,n,i,c){_iterCreate(r,t,o);var s,u,a,l=function(e){if(!BUGGY&&e in y)return y[e];switch(e){case KEYS:case VALUES:return function(){return new r(this,e)}}return function(){return new r(this,e)}},f=t+" Iterator",_=n==VALUES,p=!1,y=e.prototype,d=y[ITERATOR]||y[FF_ITERATOR]||n&&y[n],b=d||l(n),h=n?_?l("entries"):b:void 0,O="Array"==t?y.entries||d:d;if(O&&(a=_objectGpo(O.call(new e)))!==Object.prototype&&(_setToStringTag(a,f,!0),_library||_has(a,ITERATOR)||_hide(a,ITERATOR,returnThis)),_&&d&&d.name!==VALUES&&(p=!0,b=function(){return d.call(this)}),_library&&!c||!BUGGY&&!p&&y[ITERATOR]||_hide(y,ITERATOR,b),_iterators[t]=b,_iterators[f]=returnThis,n)if(s={values:_?b:l(VALUES),keys:i?b:l(KEYS),entries:h},c)for(u in s)u in y||_redefine(y,u,s[u]);else _export(_export.P+_export.F*(BUGGY||p),t,s);return s},$at=_stringAt(!0);_iterDefine(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,r=this._i;return r>=t.length?{value:void 0,done:!0}:(e=$at(t,r),this._i+=e.length,{value:e,done:!1})});var _iterCall=function(e,t,r,o){try{return o?t(_anObject(r)[0],r[1]):t(r)}catch(t){var n=e.return;throw void 0!==n&&_anObject(n.call(e)),t}},ITERATOR$1=_wks("iterator"),ArrayProto=Array.prototype,_isArrayIter=function(e){return void 0!==e&&(_iterators.Array===e||ArrayProto[ITERATOR$1]===e)},_createProperty=function(e,t,r){t in e?_objectDp.f(e,t,_propertyDesc(0,r)):e[t]=r},TAG$1=_wks("toStringTag"),ARG="Arguments"==_cof(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},_classof=function(e){var t,r,o;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=Object(e),TAG$1))?r:ARG?_cof(t):"Object"==(o=_cof(t))&&"function"==typeof t.callee?"Arguments":o},ITERATOR$2=_wks("iterator"),core_getIteratorMethod=_core.getIteratorMethod=function(e){if(void 0!=e)return e[ITERATOR$2]||e["@@iterator"]||_iterators[_classof(e)]},ITERATOR$3=_wks("iterator"),SAFE_CLOSING=!1;try{var riter=[7][ITERATOR$3]();riter.return=function(){SAFE_CLOSING=!0},Array.from(riter,function(){throw 2})}catch(e){}var _iterDetect=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var o=[7],n=o[ITERATOR$3]();n.next=function(){return{done:r=!0}},o[ITERATOR$3]=function(){return n},e(o)}catch(e){}return r};_export(_export.S+_export.F*!_iterDetect(function(e){Array.from(e)}),"Array",{from:function(e){var t,r,o,n,i=_toObject(e),c="function"==typeof this?this:Array,s=arguments.length,u=s>1?arguments[1]:void 0,a=void 0!==u,l=0,f=core_getIteratorMethod(i);if(a&&(u=_ctx(u,s>2?arguments[2]:void 0,2)),void 0==f||c==Array&&_isArrayIter(f))for(r=new c(t=_toLength(i.length));t>l;l++)_createProperty(r,l,a?u(i[l],l):i[l]);else for(n=f.call(i),r=new c;!(o=n.next()).done;l++)_createProperty(r,l,a?_iterCall(n,u,[o.value,l],!0):o.value);return r.length=l,r}});var from$2=_core.Array.from,from=createCommonjsModule(function(e){e.exports={default:from$2,__esModule:!0}}),toConsumableArray=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(from);t.default=function(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return(0,r.default)(e)}}),_addToUnscopables=function(){},_iterStep=function(e,t){return{value:t,done:!!e}},es6_array_iterator=_iterDefine(Array,"Array",function(e,t){this._t=_toIobject(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,r=this._i++;return!e||r>=e.length?(this._t=void 0,_iterStep(1)):"keys"==t?_iterStep(0,r):"values"==t?_iterStep(0,e[r]):_iterStep(0,[r,e[r]])},"values");_iterators.Arguments=_iterators.Array,_addToUnscopables("keys"),_addToUnscopables("values"),_addToUnscopables("entries");for(var TO_STRING_TAG=_wks("toStringTag"),collections=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],i=0;i<5;i++){var NAME=collections[i],Collection=_global[NAME],proto=Collection&&Collection.prototype;proto&&!proto[TO_STRING_TAG]&&_hide(proto,TO_STRING_TAG,NAME),_iterators[NAME]=_iterators.Array}var f$3=_wks,_wksExt={f:f$3},iterator$2=_wksExt.f("iterator"),iterator=createCommonjsModule(function(e){e.exports={default:iterator$2,__esModule:!0}}),_meta=createCommonjsModule(function(e){var t=_uid("meta"),r=_objectDp.f,o=0,n=Object.isExtensible||function(){return!0},i=!_fails(function(){return n(Object.preventExtensions({}))}),c=function(e){r(e,t,{value:{i:"O"+ ++o,w:{}}})},s=e.exports={KEY:t,NEED:!1,fastKey:function(e,r){if(!_isObject(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!_has(e,t)){if(!n(e))return"F";if(!r)return"E";c(e)}return e[t].i},getWeak:function(e,r){if(!_has(e,t)){if(!n(e))return!0;if(!r)return!1;c(e)}return e[t].w},onFreeze:function(e){return i&&s.NEED&&n(e)&&!_has(e,t)&&c(e),e}}}),defineProperty=_objectDp.f,_wksDefine=function(e){var t=_core.Symbol||(_core.Symbol=_library?{}:_global.Symbol||{});"_"==e.charAt(0)||e in t||defineProperty(t,e,{value:_wksExt.f(e)})},_keyof=function(e,t){for(var r,o=_toIobject(e),n=_objectKeys(o),i=n.length,c=0;i>c;)if(o[r=n[c++]]===t)return r},_enumKeys=function(e){var t=_objectKeys(e),r=_objectGops.f;if(r)for(var o,n=r(e),i=_objectPie.f,c=0;n.length>c;)i.call(e,o=n[c++])&&t.push(o);return t},_isArray=Array.isArray||function(e){return"Array"==_cof(e)},hiddenKeys=_enumBugKeys.concat("length","prototype"),f$5=Object.getOwnPropertyNames||function(e){return _objectKeysInternal(e,hiddenKeys)},_objectGopn={f:f$5},gOPN$1=_objectGopn.f,toString$1={}.toString,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return gOPN$1(e)}catch(e){return windowNames.slice()}},f$4=function(e){return windowNames&&"[object Window]"==toString$1.call(e)?getWindowNames(e):gOPN$1(_toIobject(e))},_objectGopnExt={f:f$4},gOPD$1=Object.getOwnPropertyDescriptor,f$6=_descriptors?gOPD$1:function(e,t){if(e=_toIobject(e),t=_toPrimitive(t,!0),_ie8DomDefine)try{return gOPD$1(e,t)}catch(e){}if(_has(e,t))return _propertyDesc(!_objectPie.f.call(e,t),e[t])},_objectGopd={f:f$6},META=_meta.KEY,gOPD=_objectGopd.f,dP$1=_objectDp.f,gOPN=_objectGopnExt.f,$Symbol=_global.Symbol,$JSON=_global.JSON,_stringify=$JSON&&$JSON.stringify,PROTOTYPE$2="prototype",HIDDEN=_wks("_hidden"),TO_PRIMITIVE=_wks("toPrimitive"),isEnum={}.propertyIsEnumerable,SymbolRegistry=_shared("symbol-registry"),AllSymbols=_shared("symbols"),OPSymbols=_shared("op-symbols"),ObjectProto$1=Object[PROTOTYPE$2],USE_NATIVE="function"==typeof $Symbol,QObject=_global.QObject,setter=!QObject||!QObject[PROTOTYPE$2]||!QObject[PROTOTYPE$2].findChild,setSymbolDesc=_descriptors&&_fails(function(){return 7!=_objectCreate(dP$1({},"a",{get:function(){return dP$1(this,"a",{value:7}).a}})).a})?function(e,t,r){var o=gOPD(ObjectProto$1,t);o&&delete ObjectProto$1[t],dP$1(e,t,r),o&&e!==ObjectProto$1&&dP$1(ObjectProto$1,t,o)}:dP$1,wrap=function(e){var t=AllSymbols[e]=_objectCreate($Symbol[PROTOTYPE$2]);return t._k=e,t},isSymbol=USE_NATIVE&&"symbol"==typeof $Symbol.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof $Symbol},$defineProperty=function(e,t,r){return e===ObjectProto$1&&$defineProperty(OPSymbols,t,r),_anObject(e),t=_toPrimitive(t,!0),_anObject(r),_has(AllSymbols,t)?(r.enumerable?(_has(e,HIDDEN)&&e[HIDDEN][t]&&(e[HIDDEN][t]=!1),r=_objectCreate(r,{enumerable:_propertyDesc(0,!1)})):(_has(e,HIDDEN)||dP$1(e,HIDDEN,_propertyDesc(1,{})),e[HIDDEN][t]=!0),setSymbolDesc(e,t,r)):dP$1(e,t,r)},$defineProperties=function(e,t){_anObject(e);for(var r,o=_enumKeys(t=_toIobject(t)),n=0,i=o.length;i>n;)$defineProperty(e,r=o[n++],t[r]);return e},$create=function(e,t){return void 0===t?_objectCreate(e):$defineProperties(_objectCreate(e),t)},$propertyIsEnumerable=function(e){var t=isEnum.call(this,e=_toPrimitive(e,!0));return!(this===ObjectProto$1&&_has(AllSymbols,e)&&!_has(OPSymbols,e))&&(!(t||!_has(this,e)||!_has(AllSymbols,e)||_has(this,HIDDEN)&&this[HIDDEN][e])||t)},$getOwnPropertyDescriptor=function(e,t){if(e=_toIobject(e),t=_toPrimitive(t,!0),e!==ObjectProto$1||!_has(AllSymbols,t)||_has(OPSymbols,t)){var r=gOPD(e,t);return!r||!_has(AllSymbols,t)||_has(e,HIDDEN)&&e[HIDDEN][t]||(r.enumerable=!0),r}},$getOwnPropertyNames=function(e){for(var t,r=gOPN(_toIobject(e)),o=[],n=0;r.length>n;)_has(AllSymbols,t=r[n++])||t==HIDDEN||t==META||o.push(t);return o},$getOwnPropertySymbols=function(e){for(var t,r=e===ObjectProto$1,o=gOPN(r?OPSymbols:_toIobject(e)),n=[],i=0;o.length>i;)!_has(AllSymbols,t=o[i++])||r&&!_has(ObjectProto$1,t)||n.push(AllSymbols[t]);return n};USE_NATIVE||(_redefine(($Symbol=function(){if(this instanceof $Symbol)throw TypeError("Symbol is not a constructor!");var e=_uid(arguments.length>0?arguments[0]:void 0),t=function(r){this===ObjectProto$1&&t.call(OPSymbols,r),_has(this,HIDDEN)&&_has(this[HIDDEN],e)&&(this[HIDDEN][e]=!1),setSymbolDesc(this,e,_propertyDesc(1,r))};return _descriptors&&setter&&setSymbolDesc(ObjectProto$1,e,{configurable:!0,set:t}),wrap(e)})[PROTOTYPE$2],"toString",function(){return this._k}),_objectGopd.f=$getOwnPropertyDescriptor,_objectDp.f=$defineProperty,_objectGopn.f=_objectGopnExt.f=$getOwnPropertyNames,_objectPie.f=$propertyIsEnumerable,_objectGops.f=$getOwnPropertySymbols,_descriptors&&!_library&&_redefine(ObjectProto$1,"propertyIsEnumerable",$propertyIsEnumerable,!0),_wksExt.f=function(e){return wrap(_wks(e))}),_export(_export.G+_export.W+_export.F*!USE_NATIVE,{Symbol:$Symbol});for(var symbols="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),i$1=0;symbols.length>i$1;)_wks(symbols[i$1++]);for(var symbols=_objectKeys(_wks.store),i$1=0;symbols.length>i$1;)_wksDefine(symbols[i$1++]);_export(_export.S+_export.F*!USE_NATIVE,"Symbol",{for:function(e){return _has(SymbolRegistry,e+="")?SymbolRegistry[e]:SymbolRegistry[e]=$Symbol(e)},keyFor:function(e){if(isSymbol(e))return _keyof(SymbolRegistry,e);throw TypeError(e+" is not a symbol!")},useSetter:function(){setter=!0},useSimple:function(){setter=!1}}),_export(_export.S+_export.F*!USE_NATIVE,"Object",{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor,getOwnPropertyNames:$getOwnPropertyNames,getOwnPropertySymbols:$getOwnPropertySymbols}),$JSON&&_export(_export.S+_export.F*(!USE_NATIVE||_fails(function(){var e=$Symbol();return"[null]"!=_stringify([e])||"{}"!=_stringify({a:e})||"{}"!=_stringify(Object(e))})),"JSON",{stringify:function(e){if(void 0!==e&&!isSymbol(e)){for(var t,r,o=[e],n=1;arguments.length>n;)o.push(arguments[n++]);return"function"==typeof(t=o[1])&&(r=t),!r&&_isArray(t)||(t=function(e,t){if(r&&(t=r.call(this,e,t)),!isSymbol(t))return t}),o[1]=t,_stringify.apply($JSON,o)}}}),$Symbol[PROTOTYPE$2][TO_PRIMITIVE]||_hide($Symbol[PROTOTYPE$2],TO_PRIMITIVE,$Symbol[PROTOTYPE$2].valueOf),_setToStringTag($Symbol,"Symbol"),_setToStringTag(Math,"Math",!0),_setToStringTag(_global.JSON,"JSON",!0),_wksDefine("asyncIterator"),_wksDefine("observable");var index=_core.Symbol,symbol=createCommonjsModule(function(e){e.exports={default:index,__esModule:!0}}),_typeof_1=createCommonjsModule(function(e,t){function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var o=r(iterator),n=r(symbol),i="function"==typeof n.default&&"symbol"==typeof o.default?function(e){return typeof e}:function(e){return e&&"function"==typeof n.default&&e.constructor===n.default&&e!==n.default.prototype?"symbol":typeof e};t.default="function"==typeof n.default&&"symbol"===i(o.default)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof n.default&&e.constructor===n.default&&e!==n.default.prototype?"symbol":void 0===e?"undefined":i(e)}}),_typeof=unwrapExports(_typeof_1),classCallCheck=createCommonjsModule(function(e,t){t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}}),_classCallCheck=unwrapExports(classCallCheck);_export(_export.S+_export.F*!_descriptors,"Object",{defineProperty:_objectDp.f});var $Object=_core.Object,defineProperty$3=function(e,t,r){return $Object.defineProperty(e,t,r)},defineProperty$1=createCommonjsModule(function(e){e.exports={default:defineProperty$3,__esModule:!0}}),createClass=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(defineProperty$1);t.default=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),(0,r.default)(e,n.key,n)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}()}),_createClass=unwrapExports(createClass),Builder=function(){function e(t,r){_classCallCheck(this,e),this.checks=[],this.errorMessage="",this.nullable=!0,this.defaultValue=r,this.type=t,this.addCheck(this.checkTypeOf)}return _createClass(e,[{key:"addCheck",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return this.checks.push({args:r,func:e}),this}},{key:"checkOnly",value:function(e,t){}},{key:"checkTypeOf",value:function(e,t){}},{key:"message",value:function(e){return this.errorMessage=e,this}},{key:"only",value:function(){return this.addCheck(this.checkOnly)}},{key:"required",value:function(){return this.nullable=!1,this}},{key:"runChecks",value:function(e,t){var r=void 0===t?this.defaultValue:t;return null===r&&this.nullable,r}}]),e}();_objectSap("getPrototypeOf",function(){return function(e){return _objectGpo(_toObject(e))}});var getPrototypeOf$1=_core.Object.getPrototypeOf,getPrototypeOf=createCommonjsModule(function(e){e.exports={default:getPrototypeOf$1,__esModule:!0}}),_Object$getPrototypeOf=unwrapExports(getPrototypeOf),possibleConstructorReturn=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(_typeof_1);t.default=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":(0,r.default)(t))&&"function"!=typeof t?e:t}}),_possibleConstructorReturn=unwrapExports(possibleConstructorReturn),check=function(e,t){if(_anObject(e),!_isObject(t)&&null!==t)throw TypeError(t+": can't set as prototype!")},_setProto={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{(r=_ctx(Function.call,_objectGopd.f(Object.prototype,"__proto__").set,2))(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,o){return check(e,o),t?e.__proto__=o:r(e,o),e}}({},!1):void 0),check:check};_export(_export.S,"Object",{setPrototypeOf:_setProto.set});var setPrototypeOf$2=_core.Object.setPrototypeOf,setPrototypeOf=createCommonjsModule(function(e){e.exports={default:setPrototypeOf$2,__esModule:!0}});_export(_export.S,"Object",{create:_objectCreate});var $Object$1=_core.Object,create$2=function(e,t){return $Object$1.create(e,t)},create=createCommonjsModule(function(e){e.exports={default:create$2,__esModule:!0}}),inherits=createCommonjsModule(function(e,t){function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var o=r(setPrototypeOf),n=r(create),i=r(_typeof_1);t.default=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":(0,i.default)(t)));e.prototype=(0,n.default)(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(o.default?(0,o.default)(e,t):e.__proto__=t)}}),_inherits=unwrapExports(inherits),ArrayBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"array",r));return o.addCheck(o.checkContents,e),o}return _inherits(t,e),_createClass(t,[{key:"checkContents",value:function(e,t,r){}}]),t}(Builder),BoolBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"boolean",e));return r.required(),r}return _inherits(t,e),t}(Builder),FuncBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"function",e))}return _inherits(t,e),t}(Builder),InstanceBuilder=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"instance",null));return r.refClass=e,r.addCheck(r.checkInstance,e),r}return _inherits(t,e),_createClass(t,[{key:"checkInstance",value:function(e,t,r){}}]),t}(Builder),NumberBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"number",e));return r.required(),r}return _inherits(t,e),_createClass(t,[{key:"between",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.addCheck(this.checkBetween,e,t,r)}},{key:"checkBetween",value:function(e,t,r,o){arguments.length>4&&void 0!==arguments[4]&&arguments[4]}},{key:"oneOf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.addCheck(this.checkOneOf,e)}},{key:"checkOneOf",value:function(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2]}}]),t}(Builder),ObjectBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"object",r));return o.addCheck(o.checkContents,e),o}return _inherits(t,e),_createClass(t,[{key:"checkContents",value:function(e,t,r){}}]),t}(Builder),ShapeBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"shape",r));return o.addCheck(o.checkContents,e),o}return _inherits(t,e),_createClass(t,[{key:"checkContents",value:function(e,t,r){}}]),t}(Builder),StringBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"string",e));return r.allowEmpty=!1,r.required(),r.addCheck(r.checkNotEmpty),r}return _inherits(t,e),_createClass(t,[{key:"contains",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.addCheck(this.checkContains,e,t)}},{key:"checkContains",value:function(e,t,r){arguments.length>3&&void 0!==arguments[3]&&arguments[3]}},{key:"match",value:function(e){return this.addCheck(this.checkMatch,e)}},{key:"checkMatch",value:function(e,t,r){}},{key:"empty",value:function(){return this.allowEmpty=!0,this}},{key:"checkNotEmpty",value:function(e,t){}},{key:"oneOf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.addCheck(this.checkOneOf,e)}},{key:"checkOneOf",value:function(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2]}}]),t}(Builder),UnionBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"union",r));return o.addCheck(o.checkUnions,e),o}return _inherits(t,e),_createClass(t,[{key:"checkUnions",value:function(e,t,r){}}]),t}(Builder);module.exports=Options;
"use strict";function unwrapExports(e){return e&&e.__esModule?e.default:e}function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function isObject$1(e){return"object"===(void 0===e?"undefined":_typeof(e))&&null!==e&&!Array.isArray(e)}function arrayOf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return new ArrayBuilder(e,t)}function bool(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new BoolBuilder(e)}function func(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return new FuncBuilder(e)}function instanceOf(e){return new InstanceBuilder(e)}function regex(){return instanceOf(RegExp)}function date(){return instanceOf(Date)}function number(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new NumberBuilder(e)}function objectOf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new ObjectBuilder(e,t)}function shape(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new ShapeBuilder(e,t)}function string(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return new StringBuilder(e)}function union(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new UnionBuilder(e,t)}function buildAndCheckOptions(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=_extends$1({},e),i={};return _Object$keys(t).forEach(function(c){var u=t[c],s=e[c],a=o?o+"."+c:c;u instanceof Builder?i[c]=u.runChecks(a,s,r):isObject$1(u)&&(i[c]=buildAndCheckOptions(s||{},u,r,a)),delete n[c]}),i}function Options(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return buildAndCheckOptions(e,t({arrayOf:arrayOf,bool:bool,date:date,func:func,instanceOf:instanceOf,number:number,objectOf:objectOf,regex:regex,shape:shape,string:string,union:union}),r)}var _defined=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e},_toObject=function(e){return Object(_defined(e))},hasOwnProperty={}.hasOwnProperty,_has=function(e,t){return hasOwnProperty.call(e,t)},toString={}.toString,_cof=function(e){return toString.call(e).slice(8,-1)},_iobject=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==_cof(e)?e.split(""):Object(e)},_toIobject=function(e){return _iobject(_defined(e))},ceil=Math.ceil,floor=Math.floor,_toInteger=function(e){return isNaN(e=+e)?0:(e>0?floor:ceil)(e)},min=Math.min,_toLength=function(e){return e>0?min(_toInteger(e),9007199254740991):0},max=Math.max,min$1=Math.min,_toIndex=function(e,t){return e=_toInteger(e),e<0?max(e+t,0):min$1(e,t)},_arrayIncludes=function(e){return function(t,r,o){var n,i=_toIobject(t),c=_toLength(i.length),u=_toIndex(o,c);if(e&&r!=r){for(;c>u;)if((n=i[u++])!=n)return!0}else for(;c>u;u++)if((e||u in i)&&i[u]===r)return e||u||0;return!e&&-1}},_global=createCommonjsModule(function(e){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)}),SHARED="__core-js_shared__",store=_global[SHARED]||(_global[SHARED]={}),_shared=function(e){return store[e]||(store[e]={})},id=0,px=Math.random(),_uid=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++id+px).toString(36))},shared=_shared("keys"),_sharedKey=function(e){return shared[e]||(shared[e]=_uid(e))},arrayIndexOf=_arrayIncludes(!1),IE_PROTO=_sharedKey("IE_PROTO"),_objectKeysInternal=function(e,t){var r,o=_toIobject(e),n=0,i=[];for(r in o)r!=IE_PROTO&&_has(o,r)&&i.push(r);for(;t.length>n;)_has(o,r=t[n++])&&(~arrayIndexOf(i,r)||i.push(r));return i},_enumBugKeys="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),_objectKeys=Object.keys||function(e){return _objectKeysInternal(e,_enumBugKeys)},_core=createCommonjsModule(function(e){var t=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=t)}),_aFunction=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},_ctx=function(e,t,r){if(_aFunction(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,o){return e.call(t,r,o)};case 3:return function(r,o,n){return e.call(t,r,o,n)}}return function(){return e.apply(t,arguments)}},_isObject=function(e){return"object"==typeof e?null!==e:"function"==typeof e},_anObject=function(e){if(!_isObject(e))throw TypeError(e+" is not an object!");return e},_fails=function(e){try{return!!e()}catch(e){return!0}},_descriptors=!_fails(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),document$1=_global.document,is=_isObject(document$1)&&_isObject(document$1.createElement),_domCreate=function(e){return is?document$1.createElement(e):{}},_ie8DomDefine=!_descriptors&&!_fails(function(){return 7!=Object.defineProperty(_domCreate("div"),"a",{get:function(){return 7}}).a}),_toPrimitive=function(e,t){if(!_isObject(e))return e;var r,o;if(t&&"function"==typeof(r=e.toString)&&!_isObject(o=r.call(e)))return o;if("function"==typeof(r=e.valueOf)&&!_isObject(o=r.call(e)))return o;if(!t&&"function"==typeof(r=e.toString)&&!_isObject(o=r.call(e)))return o;throw TypeError("Can't convert object to primitive value")},dP=Object.defineProperty,f=_descriptors?Object.defineProperty:function(e,t,r){if(_anObject(e),t=_toPrimitive(t,!0),_anObject(r),_ie8DomDefine)try{return dP(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e},_objectDp={f:f},_propertyDesc=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},_hide=_descriptors?function(e,t,r){return _objectDp.f(e,t,_propertyDesc(1,r))}:function(e,t,r){return e[t]=r,e},PROTOTYPE="prototype",$export=function(e,t,r){var o,n,i,c=e&$export.F,u=e&$export.G,s=e&$export.S,a=e&$export.P,l=e&$export.B,f=e&$export.W,_=u?_core:_core[t]||(_core[t]={}),p=_[PROTOTYPE],y=u?_global:s?_global[t]:(_global[t]||{})[PROTOTYPE];u&&(r=t);for(o in r)(n=!c&&y&&void 0!==y[o])&&o in _||(i=n?y[o]:r[o],_[o]=u&&"function"!=typeof y[o]?r[o]:l&&n?_ctx(i,_global):f&&y[o]==i?function(e){var t=function(t,r,o){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,r)}return new e(t,r,o)}return e.apply(this,arguments)};return t[PROTOTYPE]=e[PROTOTYPE],t}(i):a&&"function"==typeof i?_ctx(Function.call,i):i,a&&((_.virtual||(_.virtual={}))[o]=i,e&$export.R&&p&&!p[o]&&_hide(p,o,i)))};$export.F=1,$export.G=2,$export.S=4,$export.P=8,$export.B=16,$export.W=32,$export.U=64,$export.R=128;var _export=$export,_objectSap=function(e,t){var r=(_core.Object||{})[e]||Object[e],o={};o[e]=t(r),_export(_export.S+_export.F*_fails(function(){r(1)}),"Object",o)};_objectSap("keys",function(){return function(e){return _objectKeys(_toObject(e))}});var keys$1=_core.Object.keys,keys=createCommonjsModule(function(e){e.exports={default:keys$1,__esModule:!0}}),_Object$keys=unwrapExports(keys),f$1=Object.getOwnPropertySymbols,_objectGops={f:f$1},f$2={}.propertyIsEnumerable,_objectPie={f:f$2},$assign=Object.assign,_objectAssign=!$assign||_fails(function(){var e={},t={},r=Symbol(),o="abcdefghijklmnopqrst";return e[r]=7,o.split("").forEach(function(e){t[e]=e}),7!=$assign({},e)[r]||Object.keys($assign({},t)).join("")!=o})?function(e,t){for(var r=_toObject(e),o=arguments.length,n=1,i=_objectGops.f,c=_objectPie.f;o>n;)for(var u,s=_iobject(arguments[n++]),a=i?_objectKeys(s).concat(i(s)):_objectKeys(s),l=a.length,f=0;l>f;)c.call(s,u=a[f++])&&(r[u]=s[u]);return r}:$assign;_export(_export.S+_export.F,"Object",{assign:_objectAssign});var assign$2=_core.Object.assign,assign=createCommonjsModule(function(e){e.exports={default:assign$2,__esModule:!0}}),_extends=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(assign);t.default=r.default||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}}),_extends$1=unwrapExports(_extends),_stringAt=function(e){return function(t,r){var o,n,i=String(_defined(t)),c=_toInteger(r),u=i.length;return c<0||c>=u?e?"":void 0:(o=i.charCodeAt(c),o<55296||o>56319||c+1===u||(n=i.charCodeAt(c+1))<56320||n>57343?e?i.charAt(c):o:e?i.slice(c,c+2):n-56320+(o-55296<<10)+65536)}},_library=!0,_redefine=_hide,_iterators={},_objectDps=_descriptors?Object.defineProperties:function(e,t){_anObject(e);for(var r,o=_objectKeys(t),n=o.length,i=0;n>i;)_objectDp.f(e,r=o[i++],t[r]);return e},_html=_global.document&&document.documentElement,IE_PROTO$1=_sharedKey("IE_PROTO"),Empty=function(){},PROTOTYPE$1="prototype",createDict=function(){var e,t=_domCreate("iframe"),r=_enumBugKeys.length;for(t.style.display="none",_html.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("<script>document.F=Object<\/script>"),e.close(),createDict=e.F;r--;)delete createDict[PROTOTYPE$1][_enumBugKeys[r]];return createDict()},_objectCreate=Object.create||function(e,t){var r;return null!==e?(Empty[PROTOTYPE$1]=_anObject(e),r=new Empty,Empty[PROTOTYPE$1]=null,r[IE_PROTO$1]=e):r=createDict(),void 0===t?r:_objectDps(r,t)},_wks=createCommonjsModule(function(e){var t=_shared("wks"),r=_global.Symbol,o="function"==typeof r;(e.exports=function(e){return t[e]||(t[e]=o&&r[e]||(o?r:_uid)("Symbol."+e))}).store=t}),def=_objectDp.f,TAG=_wks("toStringTag"),_setToStringTag=function(e,t,r){e&&!_has(e=r?e:e.prototype,TAG)&&def(e,TAG,{configurable:!0,value:t})},IteratorPrototype={};_hide(IteratorPrototype,_wks("iterator"),function(){return this});var _iterCreate=function(e,t,r){e.prototype=_objectCreate(IteratorPrototype,{next:_propertyDesc(1,r)}),_setToStringTag(e,t+" Iterator")},IE_PROTO$2=_sharedKey("IE_PROTO"),ObjectProto=Object.prototype,_objectGpo=Object.getPrototypeOf||function(e){return e=_toObject(e),_has(e,IE_PROTO$2)?e[IE_PROTO$2]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?ObjectProto:null},ITERATOR=_wks("iterator"),BUGGY=!([].keys&&"next"in[].keys()),FF_ITERATOR="@@iterator",KEYS="keys",VALUES="values",returnThis=function(){return this},_iterDefine=function(e,t,r,o,n,i,c){_iterCreate(r,t,o);var u,s,a,l=function(e){if(!BUGGY&&e in y)return y[e];switch(e){case KEYS:case VALUES:return function(){return new r(this,e)}}return function(){return new r(this,e)}},f=t+" Iterator",_=n==VALUES,p=!1,y=e.prototype,d=y[ITERATOR]||y[FF_ITERATOR]||n&&y[n],h=d||l(n),b=n?_?l("entries"):h:void 0,O="Array"==t?y.entries||d:d;if(O&&(a=_objectGpo(O.call(new e)))!==Object.prototype&&(_setToStringTag(a,f,!0),_library||_has(a,ITERATOR)||_hide(a,ITERATOR,returnThis)),_&&d&&d.name!==VALUES&&(p=!0,h=function(){return d.call(this)}),_library&&!c||!BUGGY&&!p&&y[ITERATOR]||_hide(y,ITERATOR,h),_iterators[t]=h,_iterators[f]=returnThis,n)if(u={values:_?h:l(VALUES),keys:i?h:l(KEYS),entries:b},c)for(s in u)s in y||_redefine(y,s,u[s]);else _export(_export.P+_export.F*(BUGGY||p),t,u);return u},$at=_stringAt(!0);_iterDefine(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,r=this._i;return r>=t.length?{value:void 0,done:!0}:(e=$at(t,r),this._i+=e.length,{value:e,done:!1})});var _iterCall=function(e,t,r,o){try{return o?t(_anObject(r)[0],r[1]):t(r)}catch(t){var n=e.return;throw void 0!==n&&_anObject(n.call(e)),t}},ITERATOR$1=_wks("iterator"),ArrayProto=Array.prototype,_isArrayIter=function(e){return void 0!==e&&(_iterators.Array===e||ArrayProto[ITERATOR$1]===e)},_createProperty=function(e,t,r){t in e?_objectDp.f(e,t,_propertyDesc(0,r)):e[t]=r},TAG$1=_wks("toStringTag"),ARG="Arguments"==_cof(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},_classof=function(e){var t,r,o;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=Object(e),TAG$1))?r:ARG?_cof(t):"Object"==(o=_cof(t))&&"function"==typeof t.callee?"Arguments":o},ITERATOR$2=_wks("iterator"),core_getIteratorMethod=_core.getIteratorMethod=function(e){if(void 0!=e)return e[ITERATOR$2]||e["@@iterator"]||_iterators[_classof(e)]},ITERATOR$3=_wks("iterator"),SAFE_CLOSING=!1;try{var riter=[7][ITERATOR$3]();riter.return=function(){SAFE_CLOSING=!0},Array.from(riter,function(){throw 2})}catch(e){}var _iterDetect=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var o=[7],n=o[ITERATOR$3]();n.next=function(){return{done:r=!0}},o[ITERATOR$3]=function(){return n},e(o)}catch(e){}return r};_export(_export.S+_export.F*!_iterDetect(function(e){Array.from(e)}),"Array",{from:function(e){var t,r,o,n,i=_toObject(e),c="function"==typeof this?this:Array,u=arguments.length,s=u>1?arguments[1]:void 0,a=void 0!==s,l=0,f=core_getIteratorMethod(i);if(a&&(s=_ctx(s,u>2?arguments[2]:void 0,2)),void 0==f||c==Array&&_isArrayIter(f))for(r=new c(t=_toLength(i.length));t>l;l++)_createProperty(r,l,a?s(i[l],l):i[l]);else for(n=f.call(i),r=new c;!(o=n.next()).done;l++)_createProperty(r,l,a?_iterCall(n,s,[o.value,l],!0):o.value);return r.length=l,r}});var from$2=_core.Array.from,from=createCommonjsModule(function(e){e.exports={default:from$2,__esModule:!0}}),toConsumableArray=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(from);t.default=function(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return(0,r.default)(e)}}),_addToUnscopables=function(){},_iterStep=function(e,t){return{value:t,done:!!e}},es6_array_iterator=_iterDefine(Array,"Array",function(e,t){this._t=_toIobject(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,r=this._i++;return!e||r>=e.length?(this._t=void 0,_iterStep(1)):"keys"==t?_iterStep(0,r):"values"==t?_iterStep(0,e[r]):_iterStep(0,[r,e[r]])},"values");_iterators.Arguments=_iterators.Array,_addToUnscopables("keys"),_addToUnscopables("values"),_addToUnscopables("entries");for(var TO_STRING_TAG=_wks("toStringTag"),collections=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],i=0;i<5;i++){var NAME=collections[i],Collection=_global[NAME],proto=Collection&&Collection.prototype;proto&&!proto[TO_STRING_TAG]&&_hide(proto,TO_STRING_TAG,NAME),_iterators[NAME]=_iterators.Array}var f$3=_wks,_wksExt={f:f$3},iterator$2=_wksExt.f("iterator"),iterator=createCommonjsModule(function(e){e.exports={default:iterator$2,__esModule:!0}}),_meta=createCommonjsModule(function(e){var t=_uid("meta"),r=_objectDp.f,o=0,n=Object.isExtensible||function(){return!0},i=!_fails(function(){return n(Object.preventExtensions({}))}),c=function(e){r(e,t,{value:{i:"O"+ ++o,w:{}}})},u=e.exports={KEY:t,NEED:!1,fastKey:function(e,r){if(!_isObject(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!_has(e,t)){if(!n(e))return"F";if(!r)return"E";c(e)}return e[t].i},getWeak:function(e,r){if(!_has(e,t)){if(!n(e))return!0;if(!r)return!1;c(e)}return e[t].w},onFreeze:function(e){return i&&u.NEED&&n(e)&&!_has(e,t)&&c(e),e}}}),defineProperty=_objectDp.f,_wksDefine=function(e){var t=_core.Symbol||(_core.Symbol=_library?{}:_global.Symbol||{});"_"==e.charAt(0)||e in t||defineProperty(t,e,{value:_wksExt.f(e)})},_keyof=function(e,t){for(var r,o=_toIobject(e),n=_objectKeys(o),i=n.length,c=0;i>c;)if(o[r=n[c++]]===t)return r},_enumKeys=function(e){var t=_objectKeys(e),r=_objectGops.f;if(r)for(var o,n=r(e),i=_objectPie.f,c=0;n.length>c;)i.call(e,o=n[c++])&&t.push(o);return t},_isArray=Array.isArray||function(e){return"Array"==_cof(e)},hiddenKeys=_enumBugKeys.concat("length","prototype"),f$5=Object.getOwnPropertyNames||function(e){return _objectKeysInternal(e,hiddenKeys)},_objectGopn={f:f$5},gOPN$1=_objectGopn.f,toString$1={}.toString,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return gOPN$1(e)}catch(e){return windowNames.slice()}},f$4=function(e){return windowNames&&"[object Window]"==toString$1.call(e)?getWindowNames(e):gOPN$1(_toIobject(e))},_objectGopnExt={f:f$4},gOPD$1=Object.getOwnPropertyDescriptor,f$6=_descriptors?gOPD$1:function(e,t){if(e=_toIobject(e),t=_toPrimitive(t,!0),_ie8DomDefine)try{return gOPD$1(e,t)}catch(e){}if(_has(e,t))return _propertyDesc(!_objectPie.f.call(e,t),e[t])},_objectGopd={f:f$6},META=_meta.KEY,gOPD=_objectGopd.f,dP$1=_objectDp.f,gOPN=_objectGopnExt.f,$Symbol=_global.Symbol,$JSON=_global.JSON,_stringify=$JSON&&$JSON.stringify,PROTOTYPE$2="prototype",HIDDEN=_wks("_hidden"),TO_PRIMITIVE=_wks("toPrimitive"),isEnum={}.propertyIsEnumerable,SymbolRegistry=_shared("symbol-registry"),AllSymbols=_shared("symbols"),OPSymbols=_shared("op-symbols"),ObjectProto$1=Object[PROTOTYPE$2],USE_NATIVE="function"==typeof $Symbol,QObject=_global.QObject,setter=!QObject||!QObject[PROTOTYPE$2]||!QObject[PROTOTYPE$2].findChild,setSymbolDesc=_descriptors&&_fails(function(){return 7!=_objectCreate(dP$1({},"a",{get:function(){return dP$1(this,"a",{value:7}).a}})).a})?function(e,t,r){var o=gOPD(ObjectProto$1,t);o&&delete ObjectProto$1[t],dP$1(e,t,r),o&&e!==ObjectProto$1&&dP$1(ObjectProto$1,t,o)}:dP$1,wrap=function(e){var t=AllSymbols[e]=_objectCreate($Symbol[PROTOTYPE$2]);return t._k=e,t},isSymbol=USE_NATIVE&&"symbol"==typeof $Symbol.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof $Symbol},$defineProperty=function(e,t,r){return e===ObjectProto$1&&$defineProperty(OPSymbols,t,r),_anObject(e),t=_toPrimitive(t,!0),_anObject(r),_has(AllSymbols,t)?(r.enumerable?(_has(e,HIDDEN)&&e[HIDDEN][t]&&(e[HIDDEN][t]=!1),r=_objectCreate(r,{enumerable:_propertyDesc(0,!1)})):(_has(e,HIDDEN)||dP$1(e,HIDDEN,_propertyDesc(1,{})),e[HIDDEN][t]=!0),setSymbolDesc(e,t,r)):dP$1(e,t,r)},$defineProperties=function(e,t){_anObject(e);for(var r,o=_enumKeys(t=_toIobject(t)),n=0,i=o.length;i>n;)$defineProperty(e,r=o[n++],t[r]);return e},$create=function(e,t){return void 0===t?_objectCreate(e):$defineProperties(_objectCreate(e),t)},$propertyIsEnumerable=function(e){var t=isEnum.call(this,e=_toPrimitive(e,!0));return!(this===ObjectProto$1&&_has(AllSymbols,e)&&!_has(OPSymbols,e))&&(!(t||!_has(this,e)||!_has(AllSymbols,e)||_has(this,HIDDEN)&&this[HIDDEN][e])||t)},$getOwnPropertyDescriptor=function(e,t){if(e=_toIobject(e),t=_toPrimitive(t,!0),e!==ObjectProto$1||!_has(AllSymbols,t)||_has(OPSymbols,t)){var r=gOPD(e,t);return!r||!_has(AllSymbols,t)||_has(e,HIDDEN)&&e[HIDDEN][t]||(r.enumerable=!0),r}},$getOwnPropertyNames=function(e){for(var t,r=gOPN(_toIobject(e)),o=[],n=0;r.length>n;)_has(AllSymbols,t=r[n++])||t==HIDDEN||t==META||o.push(t);return o},$getOwnPropertySymbols=function(e){for(var t,r=e===ObjectProto$1,o=gOPN(r?OPSymbols:_toIobject(e)),n=[],i=0;o.length>i;)!_has(AllSymbols,t=o[i++])||r&&!_has(ObjectProto$1,t)||n.push(AllSymbols[t]);return n};USE_NATIVE||(_redefine(($Symbol=function(){if(this instanceof $Symbol)throw TypeError("Symbol is not a constructor!");var e=_uid(arguments.length>0?arguments[0]:void 0),t=function(r){this===ObjectProto$1&&t.call(OPSymbols,r),_has(this,HIDDEN)&&_has(this[HIDDEN],e)&&(this[HIDDEN][e]=!1),setSymbolDesc(this,e,_propertyDesc(1,r))};return _descriptors&&setter&&setSymbolDesc(ObjectProto$1,e,{configurable:!0,set:t}),wrap(e)})[PROTOTYPE$2],"toString",function(){return this._k}),_objectGopd.f=$getOwnPropertyDescriptor,_objectDp.f=$defineProperty,_objectGopn.f=_objectGopnExt.f=$getOwnPropertyNames,_objectPie.f=$propertyIsEnumerable,_objectGops.f=$getOwnPropertySymbols,_descriptors&&!_library&&_redefine(ObjectProto$1,"propertyIsEnumerable",$propertyIsEnumerable,!0),_wksExt.f=function(e){return wrap(_wks(e))}),_export(_export.G+_export.W+_export.F*!USE_NATIVE,{Symbol:$Symbol});for(var symbols="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),i$1=0;symbols.length>i$1;)_wks(symbols[i$1++]);for(var symbols=_objectKeys(_wks.store),i$1=0;symbols.length>i$1;)_wksDefine(symbols[i$1++]);_export(_export.S+_export.F*!USE_NATIVE,"Symbol",{for:function(e){return _has(SymbolRegistry,e+="")?SymbolRegistry[e]:SymbolRegistry[e]=$Symbol(e)},keyFor:function(e){if(isSymbol(e))return _keyof(SymbolRegistry,e);throw TypeError(e+" is not a symbol!")},useSetter:function(){setter=!0},useSimple:function(){setter=!1}}),_export(_export.S+_export.F*!USE_NATIVE,"Object",{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor,getOwnPropertyNames:$getOwnPropertyNames,getOwnPropertySymbols:$getOwnPropertySymbols}),$JSON&&_export(_export.S+_export.F*(!USE_NATIVE||_fails(function(){var e=$Symbol();return"[null]"!=_stringify([e])||"{}"!=_stringify({a:e})||"{}"!=_stringify(Object(e))})),"JSON",{stringify:function(e){if(void 0!==e&&!isSymbol(e)){for(var t,r,o=[e],n=1;arguments.length>n;)o.push(arguments[n++]);return"function"==typeof(t=o[1])&&(r=t),!r&&_isArray(t)||(t=function(e,t){if(r&&(t=r.call(this,e,t)),!isSymbol(t))return t}),o[1]=t,_stringify.apply($JSON,o)}}}),$Symbol[PROTOTYPE$2][TO_PRIMITIVE]||_hide($Symbol[PROTOTYPE$2],TO_PRIMITIVE,$Symbol[PROTOTYPE$2].valueOf),_setToStringTag($Symbol,"Symbol"),_setToStringTag(Math,"Math",!0),_setToStringTag(_global.JSON,"JSON",!0),_wksDefine("asyncIterator"),_wksDefine("observable");var index=_core.Symbol,symbol=createCommonjsModule(function(e){e.exports={default:index,__esModule:!0}}),_typeof_1=createCommonjsModule(function(e,t){function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var o=r(iterator),n=r(symbol),i="function"==typeof n.default&&"symbol"==typeof o.default?function(e){return typeof e}:function(e){return e&&"function"==typeof n.default&&e.constructor===n.default&&e!==n.default.prototype?"symbol":typeof e};t.default="function"==typeof n.default&&"symbol"===i(o.default)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof n.default&&e.constructor===n.default&&e!==n.default.prototype?"symbol":void 0===e?"undefined":i(e)}}),_typeof=unwrapExports(_typeof_1),classCallCheck=createCommonjsModule(function(e,t){t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}}),_classCallCheck=unwrapExports(classCallCheck);_export(_export.S+_export.F*!_descriptors,"Object",{defineProperty:_objectDp.f});var $Object=_core.Object,defineProperty$3=function(e,t,r){return $Object.defineProperty(e,t,r)},defineProperty$1=createCommonjsModule(function(e){e.exports={default:defineProperty$3,__esModule:!0}}),createClass=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(defineProperty$1);t.default=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),(0,r.default)(e,n.key,n)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}()}),_createClass=unwrapExports(createClass),Builder=function(){function e(t,r){_classCallCheck(this,e),this.checks=[],this.currentConfig={},this.errorMessage="",this.nullable=!0,this.defaultValue=r,this.type=t,this.addCheck(this.checkTypeOf)}return _createClass(e,[{key:"addCheck",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return this.checks.push({args:r,func:e}),this}},{key:"checkOnly",value:function(e,t){}},{key:"checkTypeOf",value:function(e,t){}},{key:"invariant",value:function(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2]}},{key:"message",value:function(e){return this.errorMessage=e,this}},{key:"only",value:function(){return this.addCheck(this.checkOnly)}},{key:"required",value:function(){return this.nullable=!1,this}},{key:"runChecks",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.currentConfig=r;var o=void 0===t?this.defaultValue:t;return null===o&&this.nullable,o}}]),e}();_objectSap("getPrototypeOf",function(){return function(e){return _objectGpo(_toObject(e))}});var getPrototypeOf$1=_core.Object.getPrototypeOf,getPrototypeOf=createCommonjsModule(function(e){e.exports={default:getPrototypeOf$1,__esModule:!0}}),_Object$getPrototypeOf=unwrapExports(getPrototypeOf),possibleConstructorReturn=createCommonjsModule(function(e,t){t.__esModule=!0;var r=function(e){return e&&e.__esModule?e:{default:e}}(_typeof_1);t.default=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":(0,r.default)(t))&&"function"!=typeof t?e:t}}),_possibleConstructorReturn=unwrapExports(possibleConstructorReturn),check=function(e,t){if(_anObject(e),!_isObject(t)&&null!==t)throw TypeError(t+": can't set as prototype!")},_setProto={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{(r=_ctx(Function.call,_objectGopd.f(Object.prototype,"__proto__").set,2))(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,o){return check(e,o),t?e.__proto__=o:r(e,o),e}}({},!1):void 0),check:check};_export(_export.S,"Object",{setPrototypeOf:_setProto.set});var setPrototypeOf$2=_core.Object.setPrototypeOf,setPrototypeOf=createCommonjsModule(function(e){e.exports={default:setPrototypeOf$2,__esModule:!0}});_export(_export.S,"Object",{create:_objectCreate});var $Object$1=_core.Object,create$2=function(e,t){return $Object$1.create(e,t)},create=createCommonjsModule(function(e){e.exports={default:create$2,__esModule:!0}}),inherits=createCommonjsModule(function(e,t){function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var o=r(setPrototypeOf),n=r(create),i=r(_typeof_1);t.default=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":(0,i.default)(t)));e.prototype=(0,n.default)(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(o.default?(0,o.default)(e,t):e.__proto__=t)}}),_inherits=unwrapExports(inherits),ArrayBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"array",r));return o.addCheck(o.checkContents,e),o}return _inherits(t,e),_createClass(t,[{key:"checkContents",value:function(e,t,r){}},{key:"notEmpty",value:function(){return this.addCheck(this.checkNotEmpty)}},{key:"checkNotEmpty",value:function(e,t){}}]),t}(Builder),BoolBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"boolean",e));return r.required(),r}return _inherits(t,e),t}(Builder),FuncBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"function",e))}return _inherits(t,e),t}(Builder),InstanceBuilder=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"instance",null));return r.refClass=e,r.addCheck(r.checkInstance,e),r}return _inherits(t,e),_createClass(t,[{key:"checkInstance",value:function(e,t,r){}}]),t}(Builder),NumberBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"number",e));return r.required(),r}return _inherits(t,e),_createClass(t,[{key:"between",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.addCheck(this.checkBetween,e,t,r)}},{key:"checkBetween",value:function(e,t,r,o){arguments.length>4&&void 0!==arguments[4]&&arguments[4]}},{key:"oneOf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.addCheck(this.checkOneOf,e)}},{key:"checkOneOf",value:function(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2]}}]),t}(Builder),ObjectBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"object",r));return o.addCheck(o.checkContents,e),o}return _inherits(t,e),_createClass(t,[{key:"checkContents",value:function(e,t,r){}},{key:"notEmpty",value:function(){return this.addCheck(this.checkNotEmpty)}},{key:"checkNotEmpty",value:function(e,t){}}]),t}(Builder),ShapeBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"shape",r));return o.addCheck(o.checkContents,e),o}return _inherits(t,e),_createClass(t,[{key:"checkContents",value:function(e,t,r){}}]),t}(Builder),StringBuilder=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"string",e));return r.allowEmpty=!1,r.required(),r.addCheck(r.checkNotEmpty),r}return _inherits(t,e),_createClass(t,[{key:"contains",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.addCheck(this.checkContains,e,t)}},{key:"checkContains",value:function(e,t,r){arguments.length>3&&void 0!==arguments[3]&&arguments[3]}},{key:"match",value:function(e){return this.addCheck(this.checkMatch,e)}},{key:"checkMatch",value:function(e,t,r){}},{key:"empty",value:function(){return this.allowEmpty=!0,this}},{key:"checkNotEmpty",value:function(e,t){}},{key:"oneOf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.addCheck(this.checkOneOf,e)}},{key:"checkOneOf",value:function(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2]}}]),t}(Builder),UnionBuilder=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||_Object$getPrototypeOf(t)).call(this,"union",r));return o.addCheck(o.checkUnions,e),o}return _inherits(t,e),_createClass(t,[{key:"checkUnions",value:function(e,t,r){}}]),t}(Builder);module.exports=Options;

@@ -35,14 +35,4 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
var InstanceBuilder = function (_Builder) {

@@ -57,3 +47,3 @@ (0, _inherits3.default)(InstanceBuilder, _Builder);

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(typeof refClass === 'function', 'A class reference is required.');
_this.invariant(typeof refClass === 'function', 'A class reference is required.');
}

@@ -70,3 +60,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(value instanceof refClass, 'Must be an instance of "' + (refClass.name || refClass.constructor.name) + '".', path);
this.invariant(value instanceof refClass, 'Must be an instance of "' + (refClass.name || refClass.constructor.name) + '".', path);
}

@@ -76,3 +66,7 @@ }

return InstanceBuilder;
}(_Builder3.default);
}(_Builder3.default); /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/

@@ -79,0 +73,0 @@ exports.default = InstanceBuilder;

@@ -33,17 +33,11 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
function isNumber(value) {
return typeof value === 'number';
}
} /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/

@@ -69,3 +63,3 @@ var NumberBuilder = function (_Builder) {

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(isNumber(min) && isNumber(max), 'number.between() requires a minimum and maximum number.');
this.invariant(isNumber(min) && isNumber(max), 'number.between() requires a minimum and maximum number.');
}

@@ -81,3 +75,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(isNumber(value) && (inclusive ? value >= min && value <= max : value > min && value < max), 'Number must be between ' + min + ' and ' + max + (inclusive ? ' inclusive' : '') + '.', path);
this.invariant(isNumber(value) && (inclusive ? value >= min && value <= max : value > min && value < max), 'Number must be between ' + min + ' and ' + max + (inclusive ? ' inclusive' : '') + '.', path);
}

@@ -91,3 +85,3 @@ }

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(Array.isArray(list) && list.length > 0 && list.every(isNumber), 'number.oneOf() requires a non-empty array of numbers.');
this.invariant(Array.isArray(list) && list.length > 0 && list.every(isNumber), 'number.oneOf() requires a non-empty array of numbers.');
}

@@ -103,3 +97,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(list.includes(value), 'Number must be one of: ' + list.join(', '), path);
this.invariant(list.indexOf(value) >= 0, 'Number must be one of: ' + list.join(', '), path);
}

@@ -106,0 +100,0 @@ }

@@ -37,14 +37,4 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
var ObjectBuilder = function (_Builder) {

@@ -60,3 +50,3 @@ (0, _inherits3.default)(ObjectBuilder, _Builder);

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(contents instanceof _Builder3.default, 'A blueprint is required for object contents.');
_this.invariant(contents instanceof _Builder3.default, 'A blueprint is required for object contents.');
}

@@ -77,5 +67,21 @@

}
}, {
key: 'notEmpty',
value: function notEmpty() {
return this.addCheck(this.checkNotEmpty);
}
}, {
key: 'checkNotEmpty',
value: function checkNotEmpty(path, object) {
if ("production" !== process.env.NODE_ENV) {
this.invariant((0, _keys2.default)(object).length > 0, 'Object cannot be empty.', path);
}
}
}]);
return ObjectBuilder;
}(_Builder3.default);
}(_Builder3.default); /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/

@@ -82,0 +88,0 @@ exports.default = ObjectBuilder;

@@ -56,3 +56,4 @@ 'use strict';

function buildAndCheckOptions(baseOptions, blueprint) {
var parentPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var parentPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';

@@ -68,5 +69,5 @@ var unknownOptions = (0, _extends3.default)({}, baseOptions);

if (builder instanceof _Builder2.default) {
options[key] = builder.runChecks(path, value);
options[key] = builder.runChecks(path, value, config);
} else if ((0, _isObject2.default)(builder)) {
options[key] = buildAndCheckOptions(value || {}, builder, path);
options[key] = buildAndCheckOptions(value || {}, builder, config, path);
} else if ("production" !== process.env.NODE_ENV) {

@@ -82,3 +83,3 @@ throw new Error('Unknown blueprint option. Must be a builder or plain object.');

if (unknownKeys.length > 0) {
if (!config.unknown && unknownKeys.length > 0) {
throw new Error('Unknown options ' + unknownKeys.join(', ') + '.');

@@ -92,2 +93,4 @@ }

function Options(baseOptions, factory) {
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if ("production" !== process.env.NODE_ENV) {

@@ -113,3 +116,3 @@ if (!(0, _isObject2.default)(baseOptions)) {

union: _UnionBuilder.union
}));
}), config);
}

@@ -37,6 +37,2 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
var _isObject = require('./isObject');

@@ -48,2 +44,8 @@

/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
var ShapeBuilder = function (_Builder) {

@@ -59,3 +61,3 @@ (0, _inherits3.default)(ShapeBuilder, _Builder);

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)((0, _isObject2.default)(contents) && (0, _keys2.default)(contents).length > 0 && (0, _keys2.default)(contents).every(function (key) {
_this.invariant((0, _isObject2.default)(contents) && (0, _keys2.default)(contents).length > 0 && (0, _keys2.default)(contents).every(function (key) {
return contents[key] instanceof _Builder3.default;

@@ -82,7 +84,3 @@ }), 'A non-empty object of properties to blueprints are required for a shape.');

return ShapeBuilder;
}(_Builder3.default); /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
}(_Builder3.default);

@@ -89,0 +87,0 @@ exports.default = ShapeBuilder;

@@ -33,17 +33,11 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
function isString(value) {
return typeof value === 'string' && value !== '';
}
} /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/

@@ -73,3 +67,3 @@ var StringBuilder = function (_Builder) {

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(isString(token), 'string.contains() requires a non-empty string.');
this.invariant(isString(token), 'string.contains() requires a non-empty string.');
}

@@ -85,3 +79,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(value.includes(token, index), 'String does not include "' + token + '".', path);
this.invariant(value.indexOf(token, index) >= 0, 'String does not include "' + token + '".', path);
}

@@ -93,3 +87,3 @@ }

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(pattern instanceof RegExp, 'string.match() requires a regular expression to match against.');
this.invariant(pattern instanceof RegExp, 'string.match() requires a regular expression to match against.');
}

@@ -103,3 +97,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(value.match(pattern), 'String does not match pattern "' + pattern.source + '".', path);
this.invariant(value.match(pattern), 'String does not match pattern "' + pattern.source + '".', path);
}

@@ -119,3 +113,3 @@ }

if (!this.allowEmpty) {
(0, _invariant2.default)(isString(value), 'String cannot be empty.', path);
this.invariant(isString(value), 'String cannot be empty.', path);
}

@@ -130,3 +124,3 @@ }

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(Array.isArray(list) && list.length > 0 && list.every(isString), 'string.oneOf() requires a non-empty array of strings.');
this.invariant(Array.isArray(list) && list.length > 0 && list.every(isString), 'string.oneOf() requires a non-empty array of strings.');
}

@@ -142,3 +136,3 @@

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(list.includes(value), 'String must be one of: ' + list.join(', '), path);
this.invariant(list.indexOf(value) >= 0, 'String must be one of: ' + list.join(', '), path);
}

@@ -145,0 +139,0 @@ }

@@ -37,6 +37,2 @@ 'use strict';

var _invariant = require('./invariant');
var _invariant2 = _interopRequireDefault(_invariant);
var _typeOf = require('./typeOf');

@@ -48,2 +44,8 @@

/**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
var UnionBuilder = function (_Builder) {

@@ -59,3 +61,3 @@ (0, _inherits3.default)(UnionBuilder, _Builder);

if ("production" !== process.env.NODE_ENV) {
(0, _invariant2.default)(Array.isArray(builders) && builders.length > 0 && builders.every(function (builder) {
_this.invariant(Array.isArray(builders) && builders.length > 0 && builders.every(function (builder) {
return builder instanceof _Builder3.default;

@@ -72,2 +74,4 @@ }), 'A non-empty array of blueprints are required for a union.');

value: function checkUnions(path, value, builders) {
var _this2 = this;
if ("production" !== process.env.NODE_ENV) {

@@ -79,5 +83,5 @@ var usage = {};

if (usage[builder.type]) {
(0, _invariant2.default)(false, 'Only one instance of "' + builder.type + '" may be used.', path);
_this2.invariant(false, 'Multiple instances of "' + builder.type + '" is not supported.', path);
} else if (builder.type === 'union') {
(0, _invariant2.default)(false, 'Nested unions are not supported.', path);
_this2.invariant(false, 'Nested unions are not supported.', path);
} else {

@@ -89,3 +93,3 @@ usage[builder.type] = true;

if (usage.shape && usage.object) {
(0, _invariant2.default)(false, 'Sibling objects and shapes are not supported.', path);
this.invariant(false, 'Objects and shapes within the same union are not supported.', path);
}

@@ -102,3 +106,3 @@

(0, _invariant2.default)(checked, 'Type must be one of ' + (0, _keys2.default)(usage).join(', ') + '.', path);
this.invariant(checked, 'Type must be one of ' + (0, _keys2.default)(usage).join(', ') + '.', path);
}

@@ -108,7 +112,3 @@ }

return UnionBuilder;
}(_Builder3.default); /**
* @copyright 2017, Miles Johnson
* @license https://opensource.org/licenses/MIT
*
*/
}(_Builder3.default);

@@ -115,0 +115,0 @@ exports.default = UnionBuilder;

{
"name": "optimal",
"version": "0.3.0",
"version": "0.3.1",
"description": "Options object builder and validator.",

@@ -46,3 +46,3 @@ "main": "./lib/index.js",

"devDependencies": {
"@milesj/build-tool-config": "^0.13.0"
"@milesj/build-tool-config": "^0.14.0"
},

@@ -49,0 +49,0 @@ "babel": {

@@ -8,3 +8,2 @@ /**

import Builder from './Builder';
import invariant from './invariant';

@@ -16,3 +15,6 @@ export default class ArrayBuilder<T> extends Builder<?T[]> {

if (__DEV__) {
invariant((contents instanceof Builder), 'A blueprint is required for array contents.');
this.invariant(
(contents instanceof Builder),
'A blueprint is required for array contents.',
);
}

@@ -30,2 +32,16 @@

}
notEmpty(): this {
return this.addCheck(this.checkNotEmpty);
}
checkNotEmpty(path: string, array: *) {
if (__DEV__) {
this.invariant(
(array.length > 0),
'Array cannot be empty.',
path,
);
}
}
}

@@ -32,0 +48,0 @@

@@ -7,6 +7,5 @@ /**

import invariant from './invariant';
import isObject from './isObject';
import type { SupportedType, Checker } from './types';
import type { SupportedType, Checker, Config } from './types';

@@ -18,2 +17,3 @@ export default class Builder<T> {

}[] = [];
currentConfig: Config = {};
defaultValue: T;

@@ -26,5 +26,6 @@ errorMessage: string = '';

if (__DEV__) {
if (typeof defaultValue === 'undefined') {
throw new TypeError(`A default value for type "${type}" is required.`);
}
this.invariant(
(typeof defaultValue !== 'undefined'),
`A default value for type "${type}" is required.`,
);
}

@@ -55,3 +56,3 @@

if (__DEV__) {
invariant(
this.invariant(
(value === this.defaultValue),

@@ -71,3 +72,3 @@ `Value may only be "${String(this.defaultValue)}".`,

case 'array':
invariant(Array.isArray(value), 'Must be an array.', path);
this.invariant(Array.isArray(value), 'Must be an array.', path);
break;

@@ -82,3 +83,3 @@

case 'shape':
invariant(isObject(value), 'Must be a plain object.', path);
this.invariant(isObject(value), 'Must be a plain object.', path);
break;

@@ -88,3 +89,3 @@

// eslint-disable-next-line valid-typeof
invariant((typeof value === this.type), `Must be a ${this.type}.`, path);
this.invariant((typeof value === this.type), `Must be a ${this.type}.`, path);
break;

@@ -96,2 +97,26 @@ }

/**
* Throw an error if the condition is falsy.
*/
invariant(condition: boolean, message: string, path: string = '') {
if (__DEV__) {
if (condition) {
return;
}
const { name } = this.currentConfig;
let prefix = '';
if (path) {
if (name) {
prefix += `Invalid \`${name}\` option "${path}". `;
} else {
prefix += `Invalid option "${path}". `;
}
}
throw new Error(`${prefix}${this.errorMessage || message}`);
}
}
/**
* Set a custom error message for all checks.

@@ -101,4 +126,4 @@ */

if (__DEV__) {
invariant(
(typeof message === 'string' && message),
this.invariant(
(typeof message === 'string' && !!message),
'A non-empty string is required for custom messages.',

@@ -118,3 +143,3 @@ );

if (__DEV__) {
invariant(
this.invariant(
// eslint-disable-next-line valid-typeof

@@ -141,3 +166,5 @@ (typeof this.defaultValue === this.type),

*/
runChecks(path: string, initialValue: *): * {
runChecks(path: string, initialValue: *, config: Config = {}): * {
this.currentConfig = config;
const value = (typeof initialValue === 'undefined') ? this.defaultValue : initialValue;

@@ -152,13 +179,5 @@

if (__DEV__) {
try {
this.checks.forEach((checker) => {
checker.func.call(this, path, value, ...checker.args);
});
} catch (error) {
if (this.errorMessage) {
invariant(false, this.errorMessage, path);
} else {
throw error;
}
}
this.checks.forEach((checker) => {
checker.func.call(this, path, value, ...checker.args);
});
}

@@ -165,0 +184,0 @@

@@ -8,3 +8,2 @@ /**

import Builder from './Builder';
import invariant from './invariant';

@@ -18,3 +17,6 @@ export default class InstanceBuilder<T> extends Builder<?T> {

if (__DEV__) {
invariant((typeof refClass === 'function'), 'A class reference is required.');
this.invariant(
(typeof refClass === 'function'),
'A class reference is required.',
);
}

@@ -28,3 +30,3 @@

if (__DEV__) {
invariant(
this.invariant(
(value instanceof refClass),

@@ -31,0 +33,0 @@ // $FlowIgnore constructor check

@@ -8,3 +8,2 @@ /**

import Builder from './Builder';
import invariant from './invariant';

@@ -25,3 +24,3 @@ function isNumber(value: *): boolean {

if (__DEV__) {
invariant(
this.invariant(
(isNumber(min) && isNumber(max)),

@@ -37,3 +36,3 @@ 'number.between() requires a minimum and maximum number.',

if (__DEV__) {
invariant(
this.invariant(
(

@@ -51,3 +50,3 @@ isNumber(value) &&

if (__DEV__) {
invariant(
this.invariant(
(Array.isArray(list) && list.length > 0 && list.every(isNumber)),

@@ -63,3 +62,7 @@ 'number.oneOf() requires a non-empty array of numbers.',

if (__DEV__) {
invariant(list.includes(value), `Number must be one of: ${list.join(', ')}`, path);
this.invariant(
(list.indexOf(value) >= 0),
`Number must be one of: ${list.join(', ')}`,
path,
);
}

@@ -66,0 +69,0 @@ }

@@ -8,3 +8,2 @@ /**

import Builder from './Builder';
import invariant from './invariant';

@@ -16,3 +15,6 @@ export default class ObjectBuilder<T> extends Builder<?{ [key: string]: T }> {

if (__DEV__) {
invariant((contents instanceof Builder), 'A blueprint is required for object contents.');
this.invariant(
(contents instanceof Builder),
'A blueprint is required for object contents.',
);
}

@@ -30,2 +32,16 @@

}
notEmpty(): this {
return this.addCheck(this.checkNotEmpty);
}
checkNotEmpty(path: string, object: *) {
if (__DEV__) {
this.invariant(
(Object.keys(object).length > 0),
'Object cannot be empty.',
path,
);
}
}
}

@@ -32,0 +48,0 @@

@@ -20,3 +20,3 @@ /**

import type { Factory, Blueprint } from './types';
import type { Factory, Blueprint, Config } from './types';

@@ -26,2 +26,3 @@ function buildAndCheckOptions(

blueprint: Blueprint,
config: Config = {},
parentPath: string = '',

@@ -40,7 +41,7 @@ ) {

if (builder instanceof Builder) {
options[key] = builder.runChecks(path, value);
options[key] = builder.runChecks(path, value, config);
// Builder is a plain object, so let's recursively try again
} else if (isObject(builder)) {
options[key] = buildAndCheckOptions(value || {}, builder, path);
options[key] = buildAndCheckOptions(value || {}, builder, config, path);

@@ -60,3 +61,3 @@ // Oops

if (unknownKeys.length > 0) {
if (!config.unknown && unknownKeys.length > 0) {
throw new Error(`Unknown options ${unknownKeys.join(', ')}.`);

@@ -69,3 +70,3 @@ }

export default function Options(baseOptions: Object, factory: Factory) {
export default function Options(baseOptions: Object, factory: Factory, config: Config = {}) {
if (__DEV__) {

@@ -81,3 +82,3 @@ if (!isObject(baseOptions)) {

// Generate the options blueprint based on the builders provided by the factory,
// and run validation checks on each property and value recursively
// and run validation checks on each property and value recursively.
return buildAndCheckOptions(baseOptions, factory({

@@ -95,3 +96,3 @@ arrayOf,

union,
}));
}), config);
}

@@ -8,3 +8,2 @@ /**

import Builder from './Builder';
import invariant from './invariant';
import isObject from './isObject';

@@ -20,7 +19,10 @@

if (__DEV__) {
invariant((
isObject(contents) &&
Object.keys(contents).length > 0 &&
Object.keys(contents).every(key => (contents[key] instanceof Builder))
), 'A non-empty object of properties to blueprints are required for a shape.');
this.invariant(
(
isObject(contents) &&
Object.keys(contents).length > 0 &&
Object.keys(contents).every(key => (contents[key] instanceof Builder))
),
'A non-empty object of properties to blueprints are required for a shape.',
);
}

@@ -27,0 +29,0 @@

@@ -8,3 +8,2 @@ /**

import Builder from './Builder';
import invariant from './invariant';

@@ -30,3 +29,3 @@ function isString(value: *): boolean {

if (__DEV__) {
invariant(
this.invariant(
isString(token),

@@ -42,3 +41,7 @@ 'string.contains() requires a non-empty string.',

if (__DEV__) {
invariant(value.includes(token, index), `String does not include "${token}".`, path);
this.invariant(
(value.indexOf(token, index) >= 0),
`String does not include "${token}".`,
path,
);
}

@@ -49,3 +52,3 @@ }

if (__DEV__) {
invariant(
this.invariant(
(pattern instanceof RegExp),

@@ -61,3 +64,7 @@ 'string.match() requires a regular expression to match against.',

if (__DEV__) {
invariant(value.match(pattern), `String does not match pattern "${pattern.source}".`, path);
this.invariant(
value.match(pattern),
`String does not match pattern "${pattern.source}".`,
path,
);
}

@@ -75,3 +82,7 @@ }

if (!this.allowEmpty) {
invariant(isString(value), 'String cannot be empty.', path);
this.invariant(
isString(value),
'String cannot be empty.',
path,
);
}

@@ -83,3 +94,3 @@ }

if (__DEV__) {
invariant(
this.invariant(
(Array.isArray(list) && list.length > 0 && list.every(isString)),

@@ -95,3 +106,7 @@ 'string.oneOf() requires a non-empty array of strings.',

if (__DEV__) {
invariant(list.includes(value), `String must be one of: ${list.join(', ')}`, path);
this.invariant(
(list.indexOf(value) >= 0),
`String must be one of: ${list.join(', ')}`,
path,
);
}

@@ -98,0 +113,0 @@ }

@@ -43,1 +43,6 @@ /**

export type Factory = (factories: FactoryMap) => Blueprint;
export type Config = {
name?: string,
unknown?: boolean,
};

@@ -8,3 +8,2 @@ /**

import Builder from './Builder';
import invariant from './invariant';
import typeOf from './typeOf';

@@ -17,7 +16,10 @@

if (__DEV__) {
invariant((
Array.isArray(builders) &&
builders.length > 0 &&
builders.every(builder => (builder instanceof Builder))
), 'A non-empty array of blueprints are required for a union.');
this.invariant(
(
Array.isArray(builders) &&
builders.length > 0 &&
builders.every(builder => (builder instanceof Builder))
),
'A non-empty array of blueprints are required for a union.',
);
}

@@ -36,6 +38,6 @@

if (usage[builder.type]) {
invariant(false, `Only one instance of "${builder.type}" may be used.`, path);
this.invariant(false, `Multiple instances of "${builder.type}" is not supported.`, path);
} else if (builder.type === 'union') {
invariant(false, 'Nested unions are not supported.', path);
this.invariant(false, 'Nested unions are not supported.', path);

@@ -48,3 +50,3 @@ } else {

if (usage.shape && usage.object) {
invariant(false, 'Sibling objects and shapes are not supported.', path);
this.invariant(false, 'Objects and shapes within the same union are not supported.', path);
}

@@ -65,3 +67,3 @@

invariant(checked, `Type must be one of ${Object.keys(usage).join(', ')}.`, path);
this.invariant(checked, `Type must be one of ${Object.keys(usage).join(', ')}.`, path);
}

@@ -68,0 +70,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc