LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download
    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing

    • article
      Blog
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
Expand sidebarExpand sidebar
rod-js/Compiled (minified)Compiled (minified)
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
github
GitHubGitHub
schemas/libraries/rod-js/download_compiled/minified.js
var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,t)=>()=>(e&&(t=e(e=0)),t),a=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},s=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(var c=n(a),l=0,u=c.length,d;l<u;l++)d=c[l],!r.call(i,d)&&d!==o&&e(i,d,{get:(e=>a[e]).bind(null,d),enumerable:!(s=t(a,d))||s.enumerable});return i},c=t=>r.call(t,`module.exports`)?t[`module.exports`]:s(e({},`__esModule`,{value:!0}),t),l=o({RodSchema:()=>D,default:()=>E,initSync:()=>T,main:()=>u});function u(){I.main()}function d(){let e={__proto__:null,__wbg_Error_8c4e43fe74559d73:function(e,t){return Error(g(e,t))},__wbg_String_8f0eb39a4a4c2f66:function(e,t){let n=b(String(t),I.__wbindgen_malloc,I.__wbindgen_realloc),r=F;h().setInt32(e+4,r,!0),h().setInt32(e+0,n,!0)},__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2:function(e,t){let n=t,r=typeof n==`bigint`?n:void 0;h().setBigInt64(e+8,y(r)?BigInt(0):r,!0),h().setInt32(e+0,!y(r),!0)},__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25:function(e){let t=e,n=typeof t==`boolean`?t:void 0;return y(n)?16777215:n?1:0},__wbg___wbindgen_debug_string_0bc8482c6e3508ae:function(e,t){let n=b(p(t),I.__wbindgen_malloc,I.__wbindgen_realloc),r=F;h().setInt32(e+4,r,!0),h().setInt32(e+0,n,!0)},__wbg___wbindgen_in_47fa6863be6f2f25:function(e,t){return e in t},__wbg___wbindgen_is_bigint_31b12575b56f32fc:function(e){return typeof e==`bigint`},__wbg___wbindgen_is_function_0095a73b8b156f76:function(e){return typeof e==`function`},__wbg___wbindgen_is_null_ac34f5003991759a:function(e){return e===null},__wbg___wbindgen_is_object_5ae8e5880f2c1fbd:function(e){let t=e;return typeof t==`object`&&!!t},__wbg___wbindgen_is_string_cd444516edc5b180:function(e){return typeof e==`string`},__wbg___wbindgen_is_undefined_9e4d92534c42d778:function(e){return e===void 0},__wbg___wbindgen_jsval_eq_11888390b0186270:function(e,t){return e===t},__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811:function(e,t){return e==t},__wbg___wbindgen_number_get_8ff4255516ccad3e:function(e,t){let n=t,r=typeof n==`number`?n:void 0;h().setFloat64(e+8,y(r)?0:r,!0),h().setInt32(e+0,!y(r),!0)},__wbg___wbindgen_string_get_72fb696202c56729:function(e,t){let n=t,r=typeof n==`string`?n:void 0;var i=y(r)?0:b(r,I.__wbindgen_malloc,I.__wbindgen_realloc),a=F;h().setInt32(e+4,a,!0),h().setInt32(e+0,i,!0)},__wbg___wbindgen_throw_be289d5034ed271b:function(e,t){throw Error(g(e,t))},__wbg_call_389efe28435a9388:function(){return v(function(e,t){return e.call(t)},arguments)},__wbg_done_57b39ecd9addfe81:function(e){return e.done},__wbg_entries_58c7934c745daac7:function(e){return Object.entries(e)},__wbg_error_7534b8e9a36f1ab4:function(e,t){let n,r;try{n=e,r=t,console.error(g(e,t))}finally{I.__wbindgen_free(n,r,1)}},__wbg_from_bddd64e7d5ff6941:function(e){return Array.from(e)},__wbg_get_0bdeda968867e10e:function(){return v(function(e,t){return Reflect.get(e,t>>>0)},arguments)},__wbg_get_9b94d73e6221f75c:function(e,t){return e[t>>>0]},__wbg_get_b3ed3ad4be2bc8ac:function(){return v(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04:function(e){let t;try{t=e instanceof ArrayBuffer}catch{t=!1}return t},__wbg_instanceof_Map_53af74335dec57f4:function(e){let t;try{t=e instanceof Map}catch{t=!1}return t},__wbg_instanceof_Uint8Array_9b9075935c74707c:function(e){let t;try{t=e instanceof Uint8Array}catch{t=!1}return t},__wbg_isArray_d314bb98fcf08331:function(e){return Array.isArray(e)},__wbg_isSafeInteger_bfbc7332a9768d2a:function(e){return Number.isSafeInteger(e)},__wbg_iterator_6ff6560ca1568e55:function(){return Symbol.iterator},__wbg_keys_b50a709a76add04e:function(e){return Object.keys(e)},__wbg_length_32ed9a279acd054c:function(e){return e.length},__wbg_length_35a7bace40f36eac:function(e){return e.length},__wbg_length_68dc7c5cf1b6d349:function(e){return e.length},__wbg_new_361308b2356cecd0:function(){return{}},__wbg_new_3eb36ae241fe6f44:function(){return[]},__wbg_new_8a6f238a6ece86ea:function(){return Error()},__wbg_new_dca287b076112a51:function(){return new Map},__wbg_new_dd2b680c8bf6ae29:function(e){return new Uint8Array(e)},__wbg_new_from_slice_a3d2629dc1826784:function(e,t){return new Uint8Array(m(e,t))},__wbg_new_with_length_1763c527b2923202:function(e){return Array(e>>>0)},__wbg_next_3482f54c49e8af19:function(){return v(function(e){return e.next()},arguments)},__wbg_next_418f80d8f5303233:function(e){return e.next},__wbg_prototypesetcall_bdcdcc5842e4d77d:function(e,t,n){Uint8Array.prototype.set.call(m(e,t),n)},__wbg_push_8ffdcb2063340ba5:function(e,t){return e.push(t)},__wbg_set_1eb0999cf5d27fc8:function(e,t,n){return e.set(t,n)},__wbg_set_3f1d0b984ed272ed:function(e,t,n){e[t]=n},__wbg_set_6cb8631f80447a67:function(){return v(function(e,t,n){return Reflect.set(e,t,n)},arguments)},__wbg_set_f43e577aea94465b:function(e,t,n){e[t>>>0]=n},__wbg_stack_0ed75d68575b0f3c:function(e,t){let n=t.stack,r=b(n,I.__wbindgen_malloc,I.__wbindgen_realloc),i=F;h().setInt32(e+4,i,!0),h().setInt32(e+0,r,!0)},__wbg_stringify_8d1cc6ff383e8bae:function(){return v(function(e){return JSON.stringify(e)},arguments)},__wbg_value_0546255b415e96c1:function(e){return e.value},__wbindgen_cast_0000000000000001:function(e){return e},__wbindgen_cast_0000000000000002:function(e){return e},__wbindgen_cast_0000000000000003:function(e,t){return g(e,t)},__wbindgen_cast_0000000000000004:function(e){return BigInt.asUintN(64,e)},__wbindgen_init_externref_table:function(){let e=I.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}};return{__proto__:null,"./rod_wasm_bg.js":e}}function f(e){let t=I.__externref_table_alloc();return I.__wbindgen_externrefs.set(t,e),t}function p(e){let t=typeof e;if(t==`number`||t==`boolean`||e==null)return`${e}`;if(t==`string`)return`"${e}"`;if(t==`symbol`){let t=e.description;return t==null?`Symbol`:`Symbol(${t})`}if(t==`function`){let t=e.name;return typeof t==`string`&&t.length>0?`Function(${t})`:`Function`}if(Array.isArray(e)){let t=e.length,n=`[`;t>0&&(n+=p(e[0]));for(let r=1;r<t;r++)n+=`, `+p(e[r]);return n+=`]`,n}let n=/\[object ([^\]]+)\]/.exec(toString.call(e)),r;if(n&&n.length>1)r=n[1];else return toString.call(e);if(r==`Object`)try{return`Object(`+JSON.stringify(e)+`)`}catch{return`Object`}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:r}function m(e,t){return e>>>=0,_().subarray(e/1,e/1+t)}function h(){return(k===null||k.buffer.detached===!0||k.buffer.detached===void 0&&k.buffer!==I.memory.buffer)&&(k=new DataView(I.memory.buffer)),k}function g(e,t){return e>>>=0,S(e,t)}function _(){return(A===null||A.byteLength===0)&&(A=new Uint8Array(I.memory.buffer)),A}function v(e,t){try{return e.apply(this,t)}catch(e){let t=f(e);I.__wbindgen_exn_store(t)}}function y(e){return e==null}function b(e,t,n){if(n===void 0){let n=P.encode(e),r=t(n.length,1)>>>0;return _().subarray(r,r+n.length).set(n),F=n.length,r}let r=e.length,i=t(r,1)>>>0,a=_(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=_().subarray(i+o,i+r),a=P.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return F=o,i}function x(e){let t=I.__wbindgen_externrefs.get(e);return I.__externref_table_dealloc(e),t}function S(e,t){return N+=t,N>=M&&(j=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),j.decode(),N=t),j.decode(_().subarray(e,e+t))}function C(e,t){return I=e.exports,k=null,A=null,I.__wbindgen_start(),I}async function w(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}function T(e){if(I!==void 0)return I;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=d();return e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e)),C(new WebAssembly.Instance(e,t),e)}async function E(e){if(I!==void 0)return I;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`)),e===void 0&&(e=new URL(`rod_wasm_bg.wasm`,import.meta.url));let t=d();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await w(await e,t);return C(n,r)}var D,O,k,A,j,M,N,P,F,I,L=i((()=>{D=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,O.unregister(this),e}free(){let e=this.__destroy_into_raw();I.__wbg_rodschema_free(e,0)}check_batch(e){let t=I.rodschema_check_batch(this.__wbg_ptr,e);if(t[2])throw x(t[1]);return x(t[0])}check_batch_eager(e){let t=I.rodschema_check_batch_eager(this.__wbg_ptr,e);if(t[2])throw x(t[1]);return x(t[0])}constructor(e){let t=I.rodschema_new(e);if(t[2])throw x(t[1]);return this.__wbg_ptr=t[0]>>>0,O.register(this,this.__wbg_ptr,this),this}validate_batch(e){let t=I.rodschema_validate_batch(this.__wbg_ptr,e);if(t[2])throw x(t[1]);return x(t[0])}validate_eager(e){let t=I.rodschema_validate_eager(this.__wbg_ptr,e);if(t[2])throw x(t[1]);return x(t[0])}validate_lazy(e){let t=I.rodschema_validate_lazy(this.__wbg_ptr,e);if(t[2])throw x(t[1]);return x(t[0])}},Symbol.dispose&&(D.prototype[Symbol.dispose]=D.prototype.free),O=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>I.__wbg_rodschema_free(e>>>0,1)),k=null,A=null,j=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),j.decode(),M=2146435072,N=0,P=new TextEncoder,`encodeInto`in P||(P.encodeInto=function(e,t){let n=P.encode(e);return t.set(n),{read:e.length,written:n.length}}),F=0})),R=a((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!==`default`&&t(i,r,a[o]);return n(i,r),i}})();Object.defineProperty(e,`__esModule`,{value:!0}),e.browserBridge=void 0;let i=r((L(),c(l))),a=new Map,o=!1;e.browserBridge={async init(){o||=(await(0,i.default)(),!0)},getSchema(e){if(!o)throw Error(`Rod not initialized. Call rod.init()`);let t=JSON.stringify(e);if(a.has(t))return a.get(t);let n=new i.RodSchema(e);return a.set(t,n),n}}})),z=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RodNever=e.RodAny=e.RodDiscriminatedUnion=e.RodUnion=e.RodSet=e.RodMap=e.RodRecord=e.RodTuple=e.RodObject=e.RodArray=e.RodEnum=e.RodLiteral=e.RodDate=e.RodBoolean=e.RodNumber=e.RodString=e.RodDynamic=e.RodType=void 0;var t=class{bridge;def;_compiled=null;constructor(e,t){this.bridge=t,this.def={type:e}}getCompiled(){return this._compiled||=this.bridge.getSchema(this.toSpec()),this._compiled}toSpec(){return this.def}parse(e,t){let n=this.getCompiled(),r=(t?.mode??`lazy`)===`lazy`?n.validate_lazy(e):n.validate_eager(e);if(!r.success)throw Error(JSON.stringify(r.error));return r.data}safeParse(e,t){try{return{success:!0,data:this.parse(e,t)}}catch(e){return{success:!1,error:JSON.parse(e.message)}}}checkBatch(e){return this.getCompiled().check_batch(e)}checkBatchEager(e){return this.getCompiled().check_batch_eager(e)}parseBatch(e){return this.getCompiled().validate_batch(e)}};e.RodType=t,e.RodDynamic=class extends t{constructor(e,t){super(e.type||`unknown`,t),this.def=e}},e.RodString=class extends t{constructor(e){super(`string`,e)}min(e){return this.def.min=e,this}max(e){return this.def.max=e,this}length(e){return this.def.length=e,this}email(){return this.def.email=!0,this}url(){return this.def.url=!0,this}uuid(){return this.def.uuid=!0,this}cuid(){return this.def.cuid=!0,this}datetime(){return this.def.datetime=!0,this}ip(){return this.def.ip=!0,this}regex(e){return this.def.regex=e,this}startsWith(e){return this.def.starts_with=e,this}endsWith(e){return this.def.ends_with=e,this}includes(e){return this.def.includes=e,this}trim(){return this.def.trim=!0,this}},e.RodNumber=class extends t{constructor(e){super(`number`,e)}min(e){return this.def.min=e,this}max(e){return this.def.max=e,this}int(){return this.def.int=!0,this}},e.RodBoolean=class extends t{constructor(e){super(`boolean`,e)}},e.RodDate=class extends t{constructor(e){super(`date`,e)}min(e){return this.def.min=e,this}max(e){return this.def.max=e,this}},e.RodLiteral=class extends t{constructor(e,t){super(`literal`,t),this.def.value=e}},e.RodEnum=class extends t{constructor(e,t){super(`enum`,t),this.def.values=e}},e.RodArray=class extends t{constructor(e,t){super(`array`,t),this.def.items=e.toSpec()}min(e){return this.def.min=e,this}max(e){return this.def.max=e,this}},e.RodObject=class extends t{constructor(e,t){super(`object`,t);let n={};for(let t in e)n[t]=e[t].toSpec();this.def.properties=n}strict(){return this.def.strict=!0,this}passthrough(){return this}},e.RodTuple=class extends t{constructor(e,t){super(`tuple`,t),this.def.items=e.map(e=>e.toSpec())}},e.RodRecord=class extends t{constructor(e,t,n){super(`record`,n),this.def.key=e.toSpec(),this.def.value=t.toSpec()}},e.RodMap=class extends t{constructor(e,t,n){super(`map`,n),this.def.key=e.toSpec(),this.def.value=t.toSpec()}},e.RodSet=class extends t{constructor(e,t){super(`set`,t),this.def.value=e.toSpec()}min(e){return this.def.min=e,this}},e.RodUnion=class extends t{constructor(e,t){super(`union`,t),this.def.options=e.map(e=>e.toSpec())}},e.RodDiscriminatedUnion=class extends t{constructor(e,t,n){super(`discriminatedUnion`,n),this.def.discriminator=e,this.def.options=t.map(e=>e.toSpec())}},e.RodAny=class extends t{constructor(e){super(`any`,e)}},e.RodNever=class extends t{constructor(e){super(`never`,e)}}})),B=a((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!==`default`&&t(i,r,a[o]);return n(i,r),i}})();Object.defineProperty(e,`__esModule`,{value:!0}),e.createRod=a;let i=r(z());function a(e){return{init:()=>e.init(),fromJSON:t=>new i.RodDynamic(t,e),string:()=>new i.RodString(e),number:()=>new i.RodNumber(e),boolean:()=>new i.RodBoolean(e),date:()=>new i.RodDate(e),literal:t=>new i.RodLiteral(t,e),enum:t=>new i.RodEnum(t,e),array:t=>new i.RodArray(t,e),object:t=>new i.RodObject(t,e),tuple:t=>new i.RodTuple(t,e),record:(t,n)=>new i.RodRecord(t,n,e),map:(t,n)=>new i.RodMap(t,n,e),set:t=>new i.RodSet(t,e),union:t=>new i.RodUnion(t,e),discriminatedUnion:(t,n)=>new i.RodDiscriminatedUnion(t,n,e),any:()=>new i.RodAny(e),never:()=>new i.RodNever(e)}}})),V=a((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.rod=void 0;let r=R();e.rod=(0,B().createRod)(r.browserBridge),n(z(),e)}))();await V.rod.init();const H=V.rod.object({id:V.rod.number(),created:V.rod.date(),title:V.rod.string().min(1).max(100),type:V.rod.enum([`jpg`,`png`]),size:V.rod.number(),url:V.rod.string().url()}),U=V.rod.object({id:V.rod.number(),stars:V.rod.number().min(0).max(5),title:V.rod.string().min(1).max(100),text:V.rod.string().min(1).max(1e3),images:V.rod.array(H)});V.rod.object({id:V.rod.number(),created:V.rod.date(),title:V.rod.string().min(1).max(100),brand:V.rod.string().min(1).max(30),description:V.rod.string().min(1).max(500),price:V.rod.number().min(1).max(1e4),discount:V.rod.union([V.rod.number().min(1).max(100),V.rod.literal(null)]),quantity:V.rod.number().min(0).max(10),tags:V.rod.array(V.rod.string().min(1).max(30)),images:V.rod.array(H),ratings:V.rod.array(U)}).parse({});
Created by eskimojo for Open Circle