superstruct
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -184,3 +184,3 @@ function _defineProperty(obj, key, value) { | ||
const result = validate(value, struct); | ||
return !!result[0]; | ||
return !result[0]; | ||
} | ||
@@ -187,0 +187,0 @@ /** |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple, expressive way to validate data in JavaScript.", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "repository": "git://github.com/ianstormtaylor/superstruct.git", |
@@ -190,3 +190,3 @@ (function (global, factory) { | ||
const result = validate(value, struct); | ||
return !!result[0]; | ||
return !result[0]; | ||
} | ||
@@ -193,0 +193,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Superstruct={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var n=1;n<arguments.length;n++){var a=null!=arguments[n]?arguments[n]:{};n%2?r(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):r(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function o(e,t,r){return(o=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&u(a,r.prototype),a}).apply(null,arguments)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return o(e,arguments,a(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function l(e,t){return!0===e?[]:!1===e?[t.fail()]:e}var p=regeneratorRuntime.mark(m),d=function(e){var t=e.type,r=e.schema,n=e.coercer,a=void 0===n?function(e){return e}:n,u=e.validator,c=void 0===u?function(){return[]}:u,o=e.refiner,i=void 0===o?function(){return[]}:o;this.type=t,this.schema=r,this.coercer=a,this.validator=c,this.refiner=i},b=function(e){var t,r;function n(t,r){var a,u=regeneratorRuntime.mark(p),c=t.path,o=t.value,i=t.type,f=t.branch,s=function(e,t){if(null==e)return{};var r,n,a={},u=Object.keys(e);for(n=0;n<u.length;n++)r=u[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(t,["path","value","type","branch"]),l="Expected a value of type `"+i+"`"+(c.length?" for `"+c.join(".")+"`":"")+" but received `"+JSON.stringify(o)+"`.";function p(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t;case 2:return e.delegateYield(r,"t0",3);case 3:case"end":return e.stop()}}),u)}return(a=e.call(this,l)||this).value=o,Object.assign(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(a),s),a.type=i,a.path=c,a.branch=f,a.failures=p,a.stack=(new Error).stack,a.__proto__=n.prototype,a}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,n}(i(TypeError));function y(e,t){var r=h(e,t);if(r[0])throw r[0]}function v(e,t){var r=t.coercer(e);return y(r,t),r}function h(e,t,r){void 0===r&&(r=!1),r&&(e=t.coercer(e));var n=m(e,t),a=n[0];return a?[new b(a,n),void 0]:[void 0,e]}function m(e,t,r,a){var u,c,o,i;return regeneratorRuntime.wrap((function(f){for(;;)switch(f.prev=f.next){case 0:if(void 0===r&&(r=[]),void 0===a&&(a=[]),u=t.type,c={value:e,type:u,branch:a,path:r,fail:function(t){return void 0===t&&(t={}),n({value:e,type:u,path:r,branch:[].concat(a,[e])},t)},check:function(e,t,n,u){return m(e,t,void 0!==n?[].concat(r,[u]):r,void 0!==n?[].concat(a,[n]):a)}},o=l(t.validator(e,c),c),!(i=o[0])){f.next=12;break}return f.next=9,i;case 9:return f.delegateYield(o,"t0",10);case 10:f.next=13;break;case 12:return f.delegateYield(l(t.refiner(e,c),c),"t1",13);case 13:case"end":return f.stop()}}),p)}function g(e,t){var r=e.coercer;return new d(n(n({},e),{},{coercer:function(e){return r(t(e))}}))}function k(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function x(e,t,r){var a=e.refiner;return new d(n(n({},e),{},{type:t,refiner:regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(l(a(t,n),n),"t0",1);case 1:return e.delegateYield(l(r(t,n),n),"t1",2);case 2:case"end":return e.stop()}}),e)}))}))}function w(){return j("never",(function(){return!1}))}function j(e,t){return new d({type:e,validator:t,schema:null})}function O(e){return"string"==typeof e?'"'+e.replace(/"/g,'"')+'"':""+e}function R(e){var t=Object.keys(e);return function(r){if("object"!=typeof r||null==r)return r;for(var n,a={},u=new Set(Object.keys(r)),c=s(t);!(n=c()).done;){var o=n.value;u.delete(o);var i=e[o],f=r[o];a[o]=v(f,i)}for(var l,p=s(u);!(l=p()).done;){var d=l.value;a[d]=r[d]}return a}}e.Struct=d,e.StructError=b,e.any=function(){return j("any",(function(){return!0}))},e.array=function(e){return new d({type:"Array<"+e.type+">",schema:e,coercer:function(t){return Array.isArray(t)?t.map((function(t){return v(t,e)})):t},validator:regeneratorRuntime.mark((function t(r,n){var a,u,c,o,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Array.isArray(r)){t.next=4;break}return t.next=3,n.fail();case 3:return t.abrupt("return");case 4:a=s(r.entries());case 5:if((u=a()).done){t.next=10;break}return c=u.value,o=c[0],i=c[1],t.delegateYield(n.check(i,e,r,o),"t0",8);case 8:t.next=5;break;case 10:case"end":return t.stop()}}),t)}))})},e.assert=y,e.boolean=function(){return j("boolean",(function(e){return"boolean"==typeof e}))},e.coerce=v,e.coercion=g,e.date=function(){return j("Date",(function(e){return e instanceof Date&&!isNaN(e.getTime())}))},e.defaulted=function(e,t,r){return g(e,(function(e){var a="function"==typeof t?t():t;if(void 0===e)return a;if(!0!==r&&k(e)&&k(a)){var u=n({},e),c=!1;for(var o in a)void 0===u[o]&&(u[o]=a[o],c=!0);if(c)return u}return e}))},e.dynamic=function(e){return j("Dynamic<...>",(function(t,r){return r.check(t,e(t,r))}))},e.enums=function(e){return j("Enum<"+e.map(O)+">",(function(t){return e.includes(t)}))},e.func=function(){return j("Function",(function(e){return"function"==typeof e}))},e.instance=function(e){return j("InstanceOf<"+e.name+">",(function(t){return t instanceof e}))},e.intersection=function(e){return j(e.map((function(e){return e.type})).join(" & "),regeneratorRuntime.mark((function t(r,n){var a,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=s(e);case 1:if((u=a()).done){t.next=6;break}return c=u.value,t.delegateYield(n.check(r,c),"t0",4);case 4:t.next=1;break;case 6:case"end":return t.stop()}}),t)})))},e.is=function(e,t){return!!h(e,t)[0]},e.lazy=function(e){var t;return j("Lazy<...>",(function(r,n){return t||(t=e()),n.check(r,t)}))},e.length=function(e,t,r){return x(e,e.type+" & Length<"+t+","+r+">",(function(e){return t<e.length&&e.length<r}))},e.literal=function(e){return j("Literal<"+O(e)+">",(function(t){return t===e}))},e.map=function(e,t){return j("Map<"+e.type+","+t.type+">",regeneratorRuntime.mark((function r(n,a){var u,c,o,i,f;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n instanceof Map){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:u=s(n.entries());case 5:if((c=u()).done){r.next=11;break}return o=c.value,i=o[0],f=o[1],r.delegateYield(a.check(i,e,n,i),"t0",8);case 8:return r.delegateYield(a.check(f,t,n,i),"t1",9);case 9:r.next=5;break;case 11:case"end":return r.stop()}}),r)})))},e.masked=function(e){return g(e,(function(t){if(!k(t))return t;var r={};for(var n in e.schema)r[n]=t[n];return r}))},e.never=w,e.number=function(){return j("number",(function(e){return"number"==typeof e&&!isNaN(e)}))},e.object=function(e){var t=Object.keys(e),r=w();return new d({type:"Object<{"+t.join(",")+"}>",schema:e,coercer:R(e),validator:regeneratorRuntime.mark((function n(a,u){var c,o,i,f,l,p,d,b,y,v;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("object"==typeof a&&null!=a){n.next=4;break}return n.next=3,u.fail();case 3:return n.abrupt("return");case 4:c=new Set(Object.keys(a)),o=s(t);case 6:if((i=o()).done){n.next=14;break}return f=i.value,c.delete(f),l=e[f],p=a[f],n.delegateYield(u.check(p,l,a,f),"t0",12);case 12:n.next=6;break;case 14:d=s(c);case 15:if((b=d()).done){n.next=21;break}return y=b.value,v=a[y],n.delegateYield(u.check(v,r,a,y),"t1",19);case 19:n.next=15;break;case 21:case"end":return n.stop()}}),n)}))})},e.optional=function(e){return new d({type:e.type+"?",schema:e.schema,validator:function(t,r){return void 0===t||r.check(t,e)}})},e.partial=function(e){e instanceof d&&(e=e.schema);var t=Object.keys(e),r=w();return new d({type:"Partial<{"+t.join(",")+"}>",schema:e,coercer:R(e),validator:regeneratorRuntime.mark((function n(a,u){var c,o,i,f,l,p,d,b,y,v;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("object"==typeof a&&null!=a){n.next=4;break}return n.next=3,u.fail();case 3:return n.abrupt("return");case 4:c=new Set(Object.keys(a)),o=s(t);case 6:if((i=o()).done){n.next=16;break}if(f=i.value,c.delete(f),f in a){n.next=11;break}return n.abrupt("continue",14);case 11:return l=e[f],p=a[f],n.delegateYield(u.check(p,l,a,f),"t0",14);case 14:n.next=6;break;case 16:d=s(c);case 17:if((b=d()).done){n.next=23;break}return y=b.value,v=a[y],n.delegateYield(u.check(v,r,a,y),"t1",21);case 21:n.next=17;break;case 23:case"end":return n.stop()}}),n)}))})},e.pattern=function(e,t){return x(e,e.type+" & Pattern<"+t.source+">",(function(e){return t.test(e)}))},e.record=function(e,t){return j("Record<"+e.type+","+t.type+">",regeneratorRuntime.mark((function r(n,a){var u,c;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("object"==typeof n&&null!=n){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:r.t0=regeneratorRuntime.keys(n);case 5:if((r.t1=r.t0()).done){r.next=12;break}return u=r.t1.value,c=n[u],r.delegateYield(a.check(u,e,n,u),"t2",9);case 9:return r.delegateYield(a.check(c,t,n,u),"t3",10);case 10:r.next=5;break;case 12:case"end":return r.stop()}}),r)})))},e.refinement=x,e.set=function(e){return j("Set<"+e.type+">",(function(t,r){if(!(t instanceof Set))return!1;for(var n,a=s(t);!(n=a()).done;){var u=n.value;if(r.check(u,e)[0])return!1}return!0}))},e.string=function(){return j("string",(function(e){return"string"==typeof e}))},e.struct=j,e.tuple=function(e){var t=w();return j("["+e.map((function(e){return e.type})).join(",")+"]",regeneratorRuntime.mark((function r(n,a){var u,c,o,i,f,l,p,d;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Array.isArray(n)){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:u=s(e.entries());case 5:if((c=u()).done){r.next=11;break}return o=c.value,i=o[0],f=o[1],l=n[i],r.delegateYield(a.check(l,f,n,i),"t0",9);case 9:r.next=5;break;case 11:if(!(n.length>e.length)){r.next=15;break}return p=e.length,d=n[p],r.delegateYield(a.check(d,t,n,p),"t1",15);case 15:case"end":return r.stop()}}),r)})))},e.type=function(e){var t=Object.keys(e);return j("Type<{"+t.join(",")+"}>",regeneratorRuntime.mark((function r(n,a){var u,c,o,i,f;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("object"==typeof n&&null!=n){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:u=s(t);case 5:if((c=u()).done){r.next=12;break}return o=c.value,i=e[o],f=n[o],r.delegateYield(a.check(f,i,n,o),"t0",10);case 10:r.next=5;break;case 12:case"end":return r.stop()}}),r)})))},e.union=function(e){return j(""+e.map((function(e){return e.type})).join(" | "),regeneratorRuntime.mark((function t(r,n){var a,u,c,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=s(e);case 1:if((u=a()).done){t.next=8;break}if(c=u.value,o=n.check(r,c),0!==o.slice(0).length){t.next=6;break}return t.abrupt("return");case 6:t.next=1;break;case 8:return t.next=10,n.fail();case 10:case"end":return t.stop()}}),t)})))},e.validate=h,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Superstruct={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var n=1;n<arguments.length;n++){var a=null!=arguments[n]?arguments[n]:{};n%2?r(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):r(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function o(e,t,r){return(o=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&u(a,r.prototype),a}).apply(null,arguments)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return o(e,arguments,a(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function l(e,t){return!0===e?[]:!1===e?[t.fail()]:e}var p=regeneratorRuntime.mark(m),d=function(e){var t=e.type,r=e.schema,n=e.coercer,a=void 0===n?function(e){return e}:n,u=e.validator,c=void 0===u?function(){return[]}:u,o=e.refiner,i=void 0===o?function(){return[]}:o;this.type=t,this.schema=r,this.coercer=a,this.validator=c,this.refiner=i},b=function(e){var t,r;function n(t,r){var a,u=regeneratorRuntime.mark(p),c=t.path,o=t.value,i=t.type,f=t.branch,s=function(e,t){if(null==e)return{};var r,n,a={},u=Object.keys(e);for(n=0;n<u.length;n++)r=u[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(t,["path","value","type","branch"]),l="Expected a value of type `"+i+"`"+(c.length?" for `"+c.join(".")+"`":"")+" but received `"+JSON.stringify(o)+"`.";function p(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t;case 2:return e.delegateYield(r,"t0",3);case 3:case"end":return e.stop()}}),u)}return(a=e.call(this,l)||this).value=o,Object.assign(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(a),s),a.type=i,a.path=c,a.branch=f,a.failures=p,a.stack=(new Error).stack,a.__proto__=n.prototype,a}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,n}(i(TypeError));function y(e,t){var r=h(e,t);if(r[0])throw r[0]}function v(e,t){var r=t.coercer(e);return y(r,t),r}function h(e,t,r){void 0===r&&(r=!1),r&&(e=t.coercer(e));var n=m(e,t),a=n[0];return a?[new b(a,n),void 0]:[void 0,e]}function m(e,t,r,a){var u,c,o,i;return regeneratorRuntime.wrap((function(f){for(;;)switch(f.prev=f.next){case 0:if(void 0===r&&(r=[]),void 0===a&&(a=[]),u=t.type,c={value:e,type:u,branch:a,path:r,fail:function(t){return void 0===t&&(t={}),n({value:e,type:u,path:r,branch:[].concat(a,[e])},t)},check:function(e,t,n,u){return m(e,t,void 0!==n?[].concat(r,[u]):r,void 0!==n?[].concat(a,[n]):a)}},o=l(t.validator(e,c),c),!(i=o[0])){f.next=12;break}return f.next=9,i;case 9:return f.delegateYield(o,"t0",10);case 10:f.next=13;break;case 12:return f.delegateYield(l(t.refiner(e,c),c),"t1",13);case 13:case"end":return f.stop()}}),p)}function g(e,t){var r=e.coercer;return new d(n(n({},e),{},{coercer:function(e){return r(t(e))}}))}function k(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function x(e,t,r){var a=e.refiner;return new d(n(n({},e),{},{type:t,refiner:regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(l(a(t,n),n),"t0",1);case 1:return e.delegateYield(l(r(t,n),n),"t1",2);case 2:case"end":return e.stop()}}),e)}))}))}function w(){return j("never",(function(){return!1}))}function j(e,t){return new d({type:e,validator:t,schema:null})}function O(e){return"string"==typeof e?'"'+e.replace(/"/g,'"')+'"':""+e}function R(e){var t=Object.keys(e);return function(r){if("object"!=typeof r||null==r)return r;for(var n,a={},u=new Set(Object.keys(r)),c=s(t);!(n=c()).done;){var o=n.value;u.delete(o);var i=e[o],f=r[o];a[o]=v(f,i)}for(var l,p=s(u);!(l=p()).done;){var d=l.value;a[d]=r[d]}return a}}e.Struct=d,e.StructError=b,e.any=function(){return j("any",(function(){return!0}))},e.array=function(e){return new d({type:"Array<"+e.type+">",schema:e,coercer:function(t){return Array.isArray(t)?t.map((function(t){return v(t,e)})):t},validator:regeneratorRuntime.mark((function t(r,n){var a,u,c,o,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Array.isArray(r)){t.next=4;break}return t.next=3,n.fail();case 3:return t.abrupt("return");case 4:a=s(r.entries());case 5:if((u=a()).done){t.next=10;break}return c=u.value,o=c[0],i=c[1],t.delegateYield(n.check(i,e,r,o),"t0",8);case 8:t.next=5;break;case 10:case"end":return t.stop()}}),t)}))})},e.assert=y,e.boolean=function(){return j("boolean",(function(e){return"boolean"==typeof e}))},e.coerce=v,e.coercion=g,e.date=function(){return j("Date",(function(e){return e instanceof Date&&!isNaN(e.getTime())}))},e.defaulted=function(e,t,r){return g(e,(function(e){var a="function"==typeof t?t():t;if(void 0===e)return a;if(!0!==r&&k(e)&&k(a)){var u=n({},e),c=!1;for(var o in a)void 0===u[o]&&(u[o]=a[o],c=!0);if(c)return u}return e}))},e.dynamic=function(e){return j("Dynamic<...>",(function(t,r){return r.check(t,e(t,r))}))},e.enums=function(e){return j("Enum<"+e.map(O)+">",(function(t){return e.includes(t)}))},e.func=function(){return j("Function",(function(e){return"function"==typeof e}))},e.instance=function(e){return j("InstanceOf<"+e.name+">",(function(t){return t instanceof e}))},e.intersection=function(e){return j(e.map((function(e){return e.type})).join(" & "),regeneratorRuntime.mark((function t(r,n){var a,u,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=s(e);case 1:if((u=a()).done){t.next=6;break}return c=u.value,t.delegateYield(n.check(r,c),"t0",4);case 4:t.next=1;break;case 6:case"end":return t.stop()}}),t)})))},e.is=function(e,t){return!h(e,t)[0]},e.lazy=function(e){var t;return j("Lazy<...>",(function(r,n){return t||(t=e()),n.check(r,t)}))},e.length=function(e,t,r){return x(e,e.type+" & Length<"+t+","+r+">",(function(e){return t<e.length&&e.length<r}))},e.literal=function(e){return j("Literal<"+O(e)+">",(function(t){return t===e}))},e.map=function(e,t){return j("Map<"+e.type+","+t.type+">",regeneratorRuntime.mark((function r(n,a){var u,c,o,i,f;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n instanceof Map){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:u=s(n.entries());case 5:if((c=u()).done){r.next=11;break}return o=c.value,i=o[0],f=o[1],r.delegateYield(a.check(i,e,n,i),"t0",8);case 8:return r.delegateYield(a.check(f,t,n,i),"t1",9);case 9:r.next=5;break;case 11:case"end":return r.stop()}}),r)})))},e.masked=function(e){return g(e,(function(t){if(!k(t))return t;var r={};for(var n in e.schema)r[n]=t[n];return r}))},e.never=w,e.number=function(){return j("number",(function(e){return"number"==typeof e&&!isNaN(e)}))},e.object=function(e){var t=Object.keys(e),r=w();return new d({type:"Object<{"+t.join(",")+"}>",schema:e,coercer:R(e),validator:regeneratorRuntime.mark((function n(a,u){var c,o,i,f,l,p,d,b,y,v;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("object"==typeof a&&null!=a){n.next=4;break}return n.next=3,u.fail();case 3:return n.abrupt("return");case 4:c=new Set(Object.keys(a)),o=s(t);case 6:if((i=o()).done){n.next=14;break}return f=i.value,c.delete(f),l=e[f],p=a[f],n.delegateYield(u.check(p,l,a,f),"t0",12);case 12:n.next=6;break;case 14:d=s(c);case 15:if((b=d()).done){n.next=21;break}return y=b.value,v=a[y],n.delegateYield(u.check(v,r,a,y),"t1",19);case 19:n.next=15;break;case 21:case"end":return n.stop()}}),n)}))})},e.optional=function(e){return new d({type:e.type+"?",schema:e.schema,validator:function(t,r){return void 0===t||r.check(t,e)}})},e.partial=function(e){e instanceof d&&(e=e.schema);var t=Object.keys(e),r=w();return new d({type:"Partial<{"+t.join(",")+"}>",schema:e,coercer:R(e),validator:regeneratorRuntime.mark((function n(a,u){var c,o,i,f,l,p,d,b,y,v;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("object"==typeof a&&null!=a){n.next=4;break}return n.next=3,u.fail();case 3:return n.abrupt("return");case 4:c=new Set(Object.keys(a)),o=s(t);case 6:if((i=o()).done){n.next=16;break}if(f=i.value,c.delete(f),f in a){n.next=11;break}return n.abrupt("continue",14);case 11:return l=e[f],p=a[f],n.delegateYield(u.check(p,l,a,f),"t0",14);case 14:n.next=6;break;case 16:d=s(c);case 17:if((b=d()).done){n.next=23;break}return y=b.value,v=a[y],n.delegateYield(u.check(v,r,a,y),"t1",21);case 21:n.next=17;break;case 23:case"end":return n.stop()}}),n)}))})},e.pattern=function(e,t){return x(e,e.type+" & Pattern<"+t.source+">",(function(e){return t.test(e)}))},e.record=function(e,t){return j("Record<"+e.type+","+t.type+">",regeneratorRuntime.mark((function r(n,a){var u,c;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("object"==typeof n&&null!=n){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:r.t0=regeneratorRuntime.keys(n);case 5:if((r.t1=r.t0()).done){r.next=12;break}return u=r.t1.value,c=n[u],r.delegateYield(a.check(u,e,n,u),"t2",9);case 9:return r.delegateYield(a.check(c,t,n,u),"t3",10);case 10:r.next=5;break;case 12:case"end":return r.stop()}}),r)})))},e.refinement=x,e.set=function(e){return j("Set<"+e.type+">",(function(t,r){if(!(t instanceof Set))return!1;for(var n,a=s(t);!(n=a()).done;){var u=n.value;if(r.check(u,e)[0])return!1}return!0}))},e.string=function(){return j("string",(function(e){return"string"==typeof e}))},e.struct=j,e.tuple=function(e){var t=w();return j("["+e.map((function(e){return e.type})).join(",")+"]",regeneratorRuntime.mark((function r(n,a){var u,c,o,i,f,l,p,d;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Array.isArray(n)){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:u=s(e.entries());case 5:if((c=u()).done){r.next=11;break}return o=c.value,i=o[0],f=o[1],l=n[i],r.delegateYield(a.check(l,f,n,i),"t0",9);case 9:r.next=5;break;case 11:if(!(n.length>e.length)){r.next=15;break}return p=e.length,d=n[p],r.delegateYield(a.check(d,t,n,p),"t1",15);case 15:case"end":return r.stop()}}),r)})))},e.type=function(e){var t=Object.keys(e);return j("Type<{"+t.join(",")+"}>",regeneratorRuntime.mark((function r(n,a){var u,c,o,i,f;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("object"==typeof n&&null!=n){r.next=4;break}return r.next=3,a.fail();case 3:return r.abrupt("return");case 4:u=s(t);case 5:if((c=u()).done){r.next=12;break}return o=c.value,i=e[o],f=n[o],r.delegateYield(a.check(f,i,n,o),"t0",10);case 10:r.next=5;break;case 12:case"end":return r.stop()}}),r)})))},e.union=function(e){return j(""+e.map((function(e){return e.type})).join(" | "),regeneratorRuntime.mark((function t(r,n){var a,u,c,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=s(e);case 1:if((u=a()).done){t.next=8;break}if(c=u.value,o=n.check(r,c),0!==o.slice(0).length){t.next=6;break}return t.abrupt("return");case 6:t.next=1;break;case 8:return t.next=10,n.fail();case 10:case"end":return t.stop()}}),t)})))},e.validate=h,Object.defineProperty(e,"__esModule",{value:!0})})); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
255578