superstruct
Advanced tools
Comparing version 0.8.2 to 0.8.3
@@ -35,3 +35,3 @@ function _defineProperty(obj, key, value) { | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -42,3 +42,3 @@ }); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -45,0 +45,0 @@ }); |
@@ -39,3 +39,3 @@ 'use strict'; | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -46,3 +46,3 @@ }); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -49,0 +49,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { Struct, Superstruct } from '..'; | ||
export declare const createDynamic: (schema: (value: any, branch: any[], path: (string | number)[]) => Struct, defaults: any, struct: Superstruct) => Struct; | ||
import { Branch, Path, Struct, Superstruct } from '..'; | ||
export declare const createDynamic: (schema: (value: any, branch: Branch, path: Path) => Struct, defaults: any, struct: Superstruct) => Struct; |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple, expressive way to validate data in JavaScript.", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"license": "MIT", | ||
@@ -11,3 +11,3 @@ "repository": "git://github.com/ianstormtaylor/superstruct.git", | ||
"types": "./lib/index.d.ts", | ||
"main": "./lib/index.js", | ||
"main": "./lib/index.cjs", | ||
"module": "./lib/index.es.js", | ||
@@ -75,3 +75,3 @@ "files": [ | ||
"test": "yarn test:types && yarn test:mocha", | ||
"test:mocha": "yarn build:cjs && mocha --require ./test/register --require source-map-support/register ./test/index.ts", | ||
"test:mocha": "yarn build:cjs && mocha --require ./test/register.cjs --require source-map-support/register ./test/index.ts", | ||
"test:types": "yarn build:types && tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit", | ||
@@ -78,0 +78,0 @@ "watch": "yarn build:cjs --watch" |
@@ -1,2 +0,2 @@ | ||
import { Struct, Superstruct } from '..'; | ||
export declare const createDynamic: (schema: (value: any, branch: any[], path: (string | number)[]) => Struct, defaults: any, struct: Superstruct) => Struct; | ||
import { Branch, Path, Struct, Superstruct } from '..'; | ||
export declare const createDynamic: (schema: (value: any, branch: Branch, path: Path) => Struct, defaults: any, struct: Superstruct) => Struct; |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = global || self, factory(global.Superstruct = {})); | ||
}(this, function (exports) { 'use strict'; | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -42,3 +42,3 @@ function _defineProperty(obj, key, value) { | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -49,3 +49,3 @@ }); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -1643,2 +1643,2 @@ }); | ||
})); | ||
}))); |
@@ -1,1 +0,1 @@ | ||
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r=r||self).Superstruct={})}(this,(function(r){"use strict";function t(r,t,n){return t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function n(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);t&&(e=e.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.push.apply(n,e)}return n}function e(r){for(var e=1;e<arguments.length;e++){var u=null!=arguments[e]?arguments[e]:{};e%2?n(u,!0).forEach((function(n){t(r,n,u[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(u)):n(u).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(u,t))}))}return r}function u(r){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function a(r,t){return(a=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function i(r,t,n){return(i=function(){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(r){return!1}}()?Reflect.construct:function(r,t,n){var e=[null];e.push.apply(e,t);var u=new(Function.bind.apply(r,e));return n&&a(u,n.prototype),u}).apply(null,arguments)}function o(r){var t="function"==typeof Map?new Map:void 0;return(o=function(r){if(null===r||(n=r,-1===Function.toString.call(n).indexOf("[native code]")))return r;var n;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return i(r,arguments,u(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a(e,r)})(r)}var c=Object.prototype.toString,f=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var t=typeof r;if("boolean"===t)return"boolean";if("string"===t)return"string";if("number"===t)return"number";if("symbol"===t)return"symbol";if("function"===t)return"GeneratorFunction"===l(r)?"generatorfunction":"function";if(function(r){return Array.isArray?Array.isArray(r):r instanceof Array}(r))return"array";if(function(r){if(r.constructor&&"function"==typeof r.constructor.isBuffer)return r.constructor.isBuffer(r);return!1}(r))return"buffer";if(function(r){try{if("number"==typeof r.length&&"function"==typeof r.callee)return!0}catch(r){if(-1!==r.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(r){return r instanceof Date||"function"==typeof r.toDateString&&"function"==typeof r.getDate&&"function"==typeof r.setDate}(r))return"date";if(function(r){return r instanceof Error||"string"==typeof r.message&&r.constructor&&"number"==typeof r.constructor.stackTraceLimit}(r))return"error";if(function(r){return r instanceof RegExp||"string"==typeof r.flags&&"boolean"==typeof r.ignoreCase&&"boolean"==typeof r.multiline&&"boolean"==typeof r.global}(r))return"regexp";switch(l(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(r){return"function"==typeof r.throw&&"function"==typeof r.return&&"function"==typeof r.next}(r))return"generator";switch(t=c.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")};function l(r){return r.constructor?r.constructor.name:null}var s={any:function(r){return void 0!==r},arguments:function(r){return"arguments"===f(r)},array:function(r){return"array"===f(r)},boolean:function(r){return"boolean"===f(r)},buffer:function(r){return"buffer"===f(r)},date:function(r){return"date"===f(r)&&!isNaN(r)},error:function(r){return"error"===f(r)},float32array:function(r){return"float32array"===f(r)},float64array:function(r){return"float64array"===f(r)},function:function(r){return"function"===f(r)},generatorfunction:function(r){return"generatorfunction"===f(r)},int16array:function(r){return"int16array"===f(r)},int32array:function(r){return"int32array"===f(r)},int8array:function(r){return"int8array"===f(r)},map:function(r){return"map"===f(r)},null:function(r){return"null"===f(r)},number:function(r){return"number"===f(r)},object:function(r){return"object"===f(r)},promise:function(r){return"promise"===f(r)},regexp:function(r){return"regexp"===f(r)},set:function(r){return"set"===f(r)},string:function(r){return"string"===f(r)},symbol:function(r){return"symbol"===f(r)},uint16array:function(r){return"uint16array"===f(r)},uint32array:function(r){return"uint32array"===f(r)},uint8array:function(r){return"uint8array"===f(r)},uint8clampedarray:function(r){return"uint8clampedarray"===f(r)},undefined:function(r){return"undefined"===f(r)},weakmap:function(r){return"weakmap"===f(r)},weakset:function(r){return"weakset"===f(r)}},p="Invariant failed";function y(r,t){if(!r)throw new Error(p)}var v=function(r){var t,n;function e(t){var n;t.length>0||y(!1);var u=t[0],a=u.path,i=u.value,o=u.type,c=u.branch,f=function(r,t){if(null==r)return{};var n,e,u={},a=Object.keys(r);for(e=0;e<a.length;e++)n=a[e],t.indexOf(n)>=0||(u[n]=r[n]);return u}(u,["path","value","type","branch"]),l="Expected a value of type `"+o+"`"+(a.length?" for `"+a.join(".")+"`":"")+" but received `"+JSON.stringify(i)+"`.";return(n=r.call(this,l)||this).type=o,n.value=i,Object.assign(function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(n),f),n.path=a,n.branch=c,n.failures=t,n.stack=(new Error).stack,n.__proto__=e.prototype,n}return n=r,(t=e).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,e}(o(TypeError)),d=Symbol("STRUCT"),h=function(r){return"function"==typeof r&&r[d]},b=function(r){var t=r.struct.Error,n=function r(t){return r.assert(t)};return Object.defineProperty(n,d,{value:!0}),n.kind=r.kind,n.type=r.type,n.default=function(){return"function"==typeof r.defaults?r.defaults():r.defaults},n.test=function(r){return!n.check(r,[r],[])[0]},n.assert=function(r){var e=n.check(r,[r],[]),u=e[0],a=e[1];if(u)throw new t(u);return a},n.validate=function(r){var e=n.check(r,[r],[]),u=e[0],a=e[1];return u?[new t(u)]:[void 0,a]},n.check=function(r,t,e){return void 0===r&&(r=n.default()),[[n.fail({value:r,branch:t,path:e})]]},n.fail=function(r){return e({},r,{type:"type"in r?r.type:n.type})},n},g=function(r,t,n){Array.isArray(r)&&0!==r.length||y(!1);var e=r.map((function(r){return n(r)})),u=e.map((function(r){return r.type})).join(" | "),a=b({kind:"union",type:u,defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=e,i=Array.isArray(u),o=0;for(u=i?u:u[Symbol.iterator]();;){var c;if(i){if(o>=u.length)break;c=u[o++]}else{if((o=u.next()).done)break;c=o.value}var f=c.check(r,t,n),l=f[0],s=f[1];if(!l)return[void 0,s]}return[[a.fail({value:r,branch:t,path:n})]]},a},k=function(r){void 0===r&&(r={});var t=function r(t,n){return function(r,t,n){if(h(r))return r;if(Array.isArray(r)){if(1===r.length){var e=r[0];return n.array([e],t)}if(r.length>1)return n.tuple(r,t)}if("function"==typeof r)return n.function(r,t);if("object"==typeof r)return n.object(r,t);if("string"==typeof r){var u,a=!1;if(r.endsWith("?")&&(a=!0,r=r.slice(0,-1)),r.includes("|")){var i=r.split(/\s*\|\s*/g);u=n.union(i,t)}else if(r.includes("&")){var o=r.split(/\s*&\s*/g);u=n.intersection(o,t)}else u=n.scalar(r,t);return a&&(u=n.union([u,"undefined"],void 0)),u}throw new Error("A schema definition must be an object, array, string or function, but you passed: "+r)}(t,n,r)};return t.array=function(r,n){return function(r,t,n){Array.isArray(r)&&1===r.length||y(!1);var e=n(r[0],void 0),u=b({kind:"array",type:e.type+"[]",defaults:t,struct:n});return u.check=function(r,t,n){if(void 0===r&&(r=u.default()),!Array.isArray(r))return[[u.fail({value:r,branch:t,path:n})]];for(var a=[],i=[],o=0;o<r.length;o++){var c=r[o],f=e.check(c,t.concat(c),n.concat(o)),l=f[0],s=f[1];l?i.push.apply(i,l):a[o]=s}return i.length?[i]:[void 0,a]},u}(r,n,t)},t.dynamic=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=b({kind:"dynamic",type:"dynamic<…>",defaults:t,struct:n});return e.check=function(t,n,u){return void 0===t&&(t=e.default()),r(t,n,u).check(t,n,u)},e}(r,n,t)},t.enum=function(r,n){return function(r,t,n){Array.isArray(r)||y(!1);var e=n((function(t){return r.includes(t)}),t);return e.kind="enum",e.type=r.map((function(r){return"string"==typeof r?'"'+r+'"':""+r})).join(" | "),e}(r,n,t)},t.function=function(r,n){return function(r,t,n){var u=b({kind:"function",type:"function<…>",defaults:t,struct:n});return u.check=function(t,n,a){void 0===t&&(t=u.default());var i=r(t,n,a);if(!0===i)return[void 0,t];var o=[];if(!1===i)o.push(u.fail({value:t,branch:n,path:a}));else if(Array.isArray(i)&&i.length>0){var c=i,f=Array.isArray(c),l=0;for(c=f?c:c[Symbol.iterator]();;){var s;if(f){if(l>=c.length)break;s=c[l++]}else{if((l=c.next()).done)break;s=l.value}var p=s;o.push(u.fail(e({value:t,branch:n,path:a},p)))}}else"object"==typeof i?o.push(u.fail(e({value:t,branch:n,path:a},i))):y(!1);return[o]},u}(r,n,t)},t.instance=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=n((function(t){return t instanceof r}),t);return e.kind="instance",e.type="instance<"+r.name+">",e}(r,n,t)},t.interface=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"interface",type:"interface<{"+Object.keys(r).join()+"}>",defaults:t,struct:n});return a.check=function(r,t,n){if(void 0===r&&(r=a.default()),"object"!=typeof r&&"function"!=typeof r)return[[a.fail({value:r,branch:t,path:n})]];var u=[];for(var i in e){var o=e[i],c=r[i],f=o.check(c,t.concat(c),n.concat(i))[0];f&&u.push.apply(u,f)}return u.length?[u]:[void 0,r]},a}(r,n,t)},t.intersection=function(r,n){return function(r,t,n){Array.isArray(r)&&0!==r.length||y(!1);var e=r.map((function(r){return n(r)})),u=e.map((function(r){return r.type})).join(" & "),a=b({kind:"intersection",type:u,defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=r,i=e,o=Array.isArray(i),c=0;for(i=o?i:i[Symbol.iterator]();;){var f;if(o){if(c>=i.length)break;f=i[c++]}else{if((c=i.next()).done)break;f=c.value}var l=f.check(r,t,n),s=l[0],p=l[1];if(s)return[[a.fail({value:r,branch:t,path:n})]];u=p}return[void 0,u]},a}(r,n,t)},t.lazy=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=b({kind:"lazy",type:"lazy<…>",defaults:t,struct:n});return e.check=function(){return Object.assign(e,r()),e.check.apply(e,arguments)},e}(r,n,t)},t.literal=function(r,n){return function(r,t,n){var e=n((function(t){return t===r}),t);return e.kind="literal",e.type="string"==typeof r?'"'+r+'"':""+r,e}(r,n,t)},t.object=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[],c=new Set(Object.keys(e).concat(Object.keys(r))),l=Array.isArray(c),s=0;for(c=l?c:c[Symbol.iterator]();;){var p;if(l){if(s>=c.length)break;p=c[s++]}else{if((s=c.next()).done)break;p=s.value}var y=p,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=u&&y in u&&(v="function"==typeof u[y]?u[y](r,t,n):u[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?o.push.apply(o,k):void 0!==m&&y in e&&(i[y]=m)}else o.push(a.fail({type:void 0,value:v,path:d,branch:r}))}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.optional=function(r,n){return g([r,"undefined"],n,t)},t.partial=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n.union([r[u],"undefined"]);var a=b({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[],c=r,l=Array.isArray(c),s=0;for(c=l?c:c[Symbol.iterator]();;){var p;if(l){if(s>=c.length)break;p=c[s++]}else{if((s=c.next()).done)break;p=s.value}var y=p,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=u&&y in u&&(v="function"==typeof u[y]?u[y](r,t,n):u[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?o.push.apply(o,k):void 0!==m&&y in e&&(i[y]=m)}else o.push(a.fail({type:void 0,value:v,path:d,branch:r}))}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.pick=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"pick",type:"pick<{"+Object.keys(r).join()+"}>",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[];for(var c in e){var l=r[c],s=n.concat(c),p=t.concat(l),y=e[c];void 0===l&&null!=u&&c in u&&(l="function"==typeof u[c]?u[c](r,t,n):u[c]);var v=y.check(l,p,s),d=v[0],h=v[1];d?o.push.apply(o,d):void 0!==h&&c in e&&(i[c]=h)}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.record=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length||y(!1);var u=n(r[0]),a=n(r[1]),i=b({kind:"record",type:"record<"+u.type+","+a.type+">",defaults:t,struct:n});return i.check=function(r,t,n){var o=i.default();if(r=o?e({},o,{},r):r,"object"!==f(r))return[[i.fail({value:r,branch:t,path:n})]];var c={},l=[];for(var s in r){var p=r[s],y=n.concat(s),v=t.concat(p),d=u.check(s,v,y),h=d[0],b=d[1];if(h)l.push.apply(l,h);else{var g=a.check(p,v,y),k=g[0],m=g[1];k?l.push.apply(l,k):c[b]=m}}return l.length?[l]:[void 0,c]},i}(r,n,t)},t.scalar=function(r,n){return function(r,t,n){"string"!=typeof r&&y(!1);var e=n.Types;r in e||y(!1);var u=n(e[r],t);return u.kind="scalar",u.type=r,u}(r,n,t)},t.size=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length&&r.every((function(r){return"number"==typeof r}))||y(!1);var e=r[0],u=r[1],a=n((function(r){return null!=r&&"number"==typeof r.length&&r.length>=e&&r.length<=u}),t);return a.kind="size",a.type="size<"+e+","+u+">",a}(r,n,t)},t.tuple=function(r,n){return function(r,t,n){Array.isArray(r)||y(!1);var e=r.map((function(r){return n(r)})),u=b({kind:"tuple",type:"["+e.map((function(r){return r.type})).join()+"]",defaults:t,struct:n});return u.check=function(r,t,n){if(void 0===r&&(r=u.default()),!Array.isArray(r))return[[u.fail({value:r,branch:t,path:n})]];for(var a=[],i=[],o=Math.max(r.length,e.length),c=0;c<o;c++){var f=e[c],l=r[c],s=n.concat(c),p=t.concat(l);if(f){var y=f.check(l,p,s),v=y[0],d=y[1];v?i.push.apply(i,v):a[c]=d}else i.push(u.fail({type:void 0,value:l,path:s,branch:p}))}return i.length?[i]:[void 0,a]},u}(r,n,t)},t.union=function(r,n){return g(r,n,t)},t.Error=r.error||v,t.Types=e({},s,{},r.types),t},m=k();r.StructError=v,r.Types=s,r.isStruct=h,r.struct=m,r.superstruct=k,Object.defineProperty(r,"__esModule",{value:!0})})); | ||
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r=r||self).Superstruct={})}(this,(function(r){"use strict";function t(r,t,n){return t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function n(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);t&&(e=e.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.push.apply(n,e)}return n}function e(r){for(var e=1;e<arguments.length;e++){var u=null!=arguments[e]?arguments[e]:{};e%2?n(Object(u),!0).forEach((function(n){t(r,n,u[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(u)):n(Object(u)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(u,t))}))}return r}function u(r){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function a(r,t){return(a=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function i(r,t,n){return(i=function(){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(r){return!1}}()?Reflect.construct:function(r,t,n){var e=[null];e.push.apply(e,t);var u=new(Function.bind.apply(r,e));return n&&a(u,n.prototype),u}).apply(null,arguments)}function o(r){var t="function"==typeof Map?new Map:void 0;return(o=function(r){if(null===r||(n=r,-1===Function.toString.call(n).indexOf("[native code]")))return r;var n;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return i(r,arguments,u(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a(e,r)})(r)}var c=Object.prototype.toString,f=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var t=typeof r;if("boolean"===t)return"boolean";if("string"===t)return"string";if("number"===t)return"number";if("symbol"===t)return"symbol";if("function"===t)return"GeneratorFunction"===l(r)?"generatorfunction":"function";if(function(r){return Array.isArray?Array.isArray(r):r instanceof Array}(r))return"array";if(function(r){if(r.constructor&&"function"==typeof r.constructor.isBuffer)return r.constructor.isBuffer(r);return!1}(r))return"buffer";if(function(r){try{if("number"==typeof r.length&&"function"==typeof r.callee)return!0}catch(r){if(-1!==r.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(r){return r instanceof Date||"function"==typeof r.toDateString&&"function"==typeof r.getDate&&"function"==typeof r.setDate}(r))return"date";if(function(r){return r instanceof Error||"string"==typeof r.message&&r.constructor&&"number"==typeof r.constructor.stackTraceLimit}(r))return"error";if(function(r){return r instanceof RegExp||"string"==typeof r.flags&&"boolean"==typeof r.ignoreCase&&"boolean"==typeof r.multiline&&"boolean"==typeof r.global}(r))return"regexp";switch(l(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(r){return"function"==typeof r.throw&&"function"==typeof r.return&&"function"==typeof r.next}(r))return"generator";switch(t=c.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")};function l(r){return r.constructor?r.constructor.name:null}var s={any:function(r){return void 0!==r},arguments:function(r){return"arguments"===f(r)},array:function(r){return"array"===f(r)},boolean:function(r){return"boolean"===f(r)},buffer:function(r){return"buffer"===f(r)},date:function(r){return"date"===f(r)&&!isNaN(r)},error:function(r){return"error"===f(r)},float32array:function(r){return"float32array"===f(r)},float64array:function(r){return"float64array"===f(r)},function:function(r){return"function"===f(r)},generatorfunction:function(r){return"generatorfunction"===f(r)},int16array:function(r){return"int16array"===f(r)},int32array:function(r){return"int32array"===f(r)},int8array:function(r){return"int8array"===f(r)},map:function(r){return"map"===f(r)},null:function(r){return"null"===f(r)},number:function(r){return"number"===f(r)},object:function(r){return"object"===f(r)},promise:function(r){return"promise"===f(r)},regexp:function(r){return"regexp"===f(r)},set:function(r){return"set"===f(r)},string:function(r){return"string"===f(r)},symbol:function(r){return"symbol"===f(r)},uint16array:function(r){return"uint16array"===f(r)},uint32array:function(r){return"uint32array"===f(r)},uint8array:function(r){return"uint8array"===f(r)},uint8clampedarray:function(r){return"uint8clampedarray"===f(r)},undefined:function(r){return"undefined"===f(r)},weakmap:function(r){return"weakmap"===f(r)},weakset:function(r){return"weakset"===f(r)}},p="Invariant failed";function y(r,t){if(!r)throw new Error(p)}var v=function(r){var t,n;function e(t){var n;t.length>0||y(!1);var u=t[0],a=u.path,i=u.value,o=u.type,c=u.branch,f=function(r,t){if(null==r)return{};var n,e,u={},a=Object.keys(r);for(e=0;e<a.length;e++)n=a[e],t.indexOf(n)>=0||(u[n]=r[n]);return u}(u,["path","value","type","branch"]),l="Expected a value of type `"+o+"`"+(a.length?" for `"+a.join(".")+"`":"")+" but received `"+JSON.stringify(i)+"`.";return(n=r.call(this,l)||this).type=o,n.value=i,Object.assign(function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(n),f),n.path=a,n.branch=c,n.failures=t,n.stack=(new Error).stack,n.__proto__=e.prototype,n}return n=r,(t=e).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,e}(o(TypeError)),d=Symbol("STRUCT"),h=function(r){return"function"==typeof r&&r[d]},b=function(r){var t=r.struct.Error,n=function r(t){return r.assert(t)};return Object.defineProperty(n,d,{value:!0}),n.kind=r.kind,n.type=r.type,n.default=function(){return"function"==typeof r.defaults?r.defaults():r.defaults},n.test=function(r){return!n.check(r,[r],[])[0]},n.assert=function(r){var e=n.check(r,[r],[]),u=e[0],a=e[1];if(u)throw new t(u);return a},n.validate=function(r){var e=n.check(r,[r],[]),u=e[0],a=e[1];return u?[new t(u)]:[void 0,a]},n.check=function(r,t,e){return void 0===r&&(r=n.default()),[[n.fail({value:r,branch:t,path:e})]]},n.fail=function(r){return e({},r,{type:"type"in r?r.type:n.type})},n},g=function(r,t,n){Array.isArray(r)&&0!==r.length||y(!1);var e=r.map((function(r){return n(r)})),u=e.map((function(r){return r.type})).join(" | "),a=b({kind:"union",type:u,defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=e,i=Array.isArray(u),o=0;for(u=i?u:u[Symbol.iterator]();;){var c;if(i){if(o>=u.length)break;c=u[o++]}else{if((o=u.next()).done)break;c=o.value}var f=c.check(r,t,n),l=f[0],s=f[1];if(!l)return[void 0,s]}return[[a.fail({value:r,branch:t,path:n})]]},a},k=function(r){void 0===r&&(r={});var t=function r(t,n){return function(r,t,n){if(h(r))return r;if(Array.isArray(r)){if(1===r.length){var e=r[0];return n.array([e],t)}if(r.length>1)return n.tuple(r,t)}if("function"==typeof r)return n.function(r,t);if("object"==typeof r)return n.object(r,t);if("string"==typeof r){var u,a=!1;if(r.endsWith("?")&&(a=!0,r=r.slice(0,-1)),r.includes("|")){var i=r.split(/\s*\|\s*/g);u=n.union(i,t)}else if(r.includes("&")){var o=r.split(/\s*&\s*/g);u=n.intersection(o,t)}else u=n.scalar(r,t);return a&&(u=n.union([u,"undefined"],void 0)),u}throw new Error("A schema definition must be an object, array, string or function, but you passed: "+r)}(t,n,r)};return t.array=function(r,n){return function(r,t,n){Array.isArray(r)&&1===r.length||y(!1);var e=n(r[0],void 0),u=b({kind:"array",type:e.type+"[]",defaults:t,struct:n});return u.check=function(r,t,n){if(void 0===r&&(r=u.default()),!Array.isArray(r))return[[u.fail({value:r,branch:t,path:n})]];for(var a=[],i=[],o=0;o<r.length;o++){var c=r[o],f=e.check(c,t.concat(c),n.concat(o)),l=f[0],s=f[1];l?i.push.apply(i,l):a[o]=s}return i.length?[i]:[void 0,a]},u}(r,n,t)},t.dynamic=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=b({kind:"dynamic",type:"dynamic<…>",defaults:t,struct:n});return e.check=function(t,n,u){return void 0===t&&(t=e.default()),r(t,n,u).check(t,n,u)},e}(r,n,t)},t.enum=function(r,n){return function(r,t,n){Array.isArray(r)||y(!1);var e=n((function(t){return r.includes(t)}),t);return e.kind="enum",e.type=r.map((function(r){return"string"==typeof r?'"'+r+'"':""+r})).join(" | "),e}(r,n,t)},t.function=function(r,n){return function(r,t,n){var u=b({kind:"function",type:"function<…>",defaults:t,struct:n});return u.check=function(t,n,a){void 0===t&&(t=u.default());var i=r(t,n,a);if(!0===i)return[void 0,t];var o=[];if(!1===i)o.push(u.fail({value:t,branch:n,path:a}));else if(Array.isArray(i)&&i.length>0){var c=i,f=Array.isArray(c),l=0;for(c=f?c:c[Symbol.iterator]();;){var s;if(f){if(l>=c.length)break;s=c[l++]}else{if((l=c.next()).done)break;s=l.value}var p=s;o.push(u.fail(e({value:t,branch:n,path:a},p)))}}else"object"==typeof i?o.push(u.fail(e({value:t,branch:n,path:a},i))):y(!1);return[o]},u}(r,n,t)},t.instance=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=n((function(t){return t instanceof r}),t);return e.kind="instance",e.type="instance<"+r.name+">",e}(r,n,t)},t.interface=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"interface",type:"interface<{"+Object.keys(r).join()+"}>",defaults:t,struct:n});return a.check=function(r,t,n){if(void 0===r&&(r=a.default()),"object"!=typeof r&&"function"!=typeof r)return[[a.fail({value:r,branch:t,path:n})]];var u=[];for(var i in e){var o=e[i],c=r[i],f=o.check(c,t.concat(c),n.concat(i))[0];f&&u.push.apply(u,f)}return u.length?[u]:[void 0,r]},a}(r,n,t)},t.intersection=function(r,n){return function(r,t,n){Array.isArray(r)&&0!==r.length||y(!1);var e=r.map((function(r){return n(r)})),u=e.map((function(r){return r.type})).join(" & "),a=b({kind:"intersection",type:u,defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=r,i=e,o=Array.isArray(i),c=0;for(i=o?i:i[Symbol.iterator]();;){var f;if(o){if(c>=i.length)break;f=i[c++]}else{if((c=i.next()).done)break;f=c.value}var l=f.check(r,t,n),s=l[0],p=l[1];if(s)return[[a.fail({value:r,branch:t,path:n})]];u=p}return[void 0,u]},a}(r,n,t)},t.lazy=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=b({kind:"lazy",type:"lazy<…>",defaults:t,struct:n});return e.check=function(){return Object.assign(e,r()),e.check.apply(e,arguments)},e}(r,n,t)},t.literal=function(r,n){return function(r,t,n){var e=n((function(t){return t===r}),t);return e.kind="literal",e.type="string"==typeof r?'"'+r+'"':""+r,e}(r,n,t)},t.object=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[],c=new Set(Object.keys(e).concat(Object.keys(r))),l=Array.isArray(c),s=0;for(c=l?c:c[Symbol.iterator]();;){var p;if(l){if(s>=c.length)break;p=c[s++]}else{if((s=c.next()).done)break;p=s.value}var y=p,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=u&&y in u&&(v="function"==typeof u[y]?u[y](r,t,n):u[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?o.push.apply(o,k):void 0!==m&&y in e&&(i[y]=m)}else o.push(a.fail({type:void 0,value:v,path:d,branch:r}))}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.optional=function(r,n){return g([r,"undefined"],n,t)},t.partial=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n.union([r[u],"undefined"]);var a=b({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[],c=r,l=Array.isArray(c),s=0;for(c=l?c:c[Symbol.iterator]();;){var p;if(l){if(s>=c.length)break;p=c[s++]}else{if((s=c.next()).done)break;p=s.value}var y=p,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=u&&y in u&&(v="function"==typeof u[y]?u[y](r,t,n):u[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?o.push.apply(o,k):void 0!==m&&y in e&&(i[y]=m)}else o.push(a.fail({type:void 0,value:v,path:d,branch:r}))}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.pick=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"pick",type:"pick<{"+Object.keys(r).join()+"}>",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[];for(var c in e){var l=r[c],s=n.concat(c),p=t.concat(l),y=e[c];void 0===l&&null!=u&&c in u&&(l="function"==typeof u[c]?u[c](r,t,n):u[c]);var v=y.check(l,p,s),d=v[0],h=v[1];d?o.push.apply(o,d):void 0!==h&&c in e&&(i[c]=h)}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.record=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length||y(!1);var u=n(r[0]),a=n(r[1]),i=b({kind:"record",type:"record<"+u.type+","+a.type+">",defaults:t,struct:n});return i.check=function(r,t,n){var o=i.default();if(r=o?e({},o,{},r):r,"object"!==f(r))return[[i.fail({value:r,branch:t,path:n})]];var c={},l=[];for(var s in r){var p=r[s],y=n.concat(s),v=t.concat(p),d=u.check(s,v,y),h=d[0],b=d[1];if(h)l.push.apply(l,h);else{var g=a.check(p,v,y),k=g[0],m=g[1];k?l.push.apply(l,k):c[b]=m}}return l.length?[l]:[void 0,c]},i}(r,n,t)},t.scalar=function(r,n){return function(r,t,n){"string"!=typeof r&&y(!1);var e=n.Types;r in e||y(!1);var u=n(e[r],t);return u.kind="scalar",u.type=r,u}(r,n,t)},t.size=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length&&r.every((function(r){return"number"==typeof r}))||y(!1);var e=r[0],u=r[1],a=n((function(r){return null!=r&&"number"==typeof r.length&&r.length>=e&&r.length<=u}),t);return a.kind="size",a.type="size<"+e+","+u+">",a}(r,n,t)},t.tuple=function(r,n){return function(r,t,n){Array.isArray(r)||y(!1);var e=r.map((function(r){return n(r)})),u=b({kind:"tuple",type:"["+e.map((function(r){return r.type})).join()+"]",defaults:t,struct:n});return u.check=function(r,t,n){if(void 0===r&&(r=u.default()),!Array.isArray(r))return[[u.fail({value:r,branch:t,path:n})]];for(var a=[],i=[],o=Math.max(r.length,e.length),c=0;c<o;c++){var f=e[c],l=r[c],s=n.concat(c),p=t.concat(l);if(f){var y=f.check(l,p,s),v=y[0],d=y[1];v?i.push.apply(i,v):a[c]=d}else i.push(u.fail({type:void 0,value:l,path:s,branch:p}))}return i.length?[i]:[void 0,a]},u}(r,n,t)},t.union=function(r,n){return g(r,n,t)},t.Error=r.error||v,t.Types=e({},s,{},r.types),t},m=k();r.StructError=v,r.Types=s,r.isStruct=h,r.struct=m,r.superstruct=k,Object.defineProperty(r,"__esModule",{value:!0})})); |
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
514941
84
7288