runcheck 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{e as f,f as t,g as o}from"./chunk-SYJIFZCW.js";var s=f.withAutofix(r=>r==null||r===0||r===1?{fixed:!!r}:r==="true"||r==="false"?{fixed:r==="true"}:!1),n=t.withAutofix(r=>typeof r=="number"&&!Number.isNaN(r)?{fixed:r.toString()}:!1),u=o.withAutofix(r=>{if(typeof r=="string"){let e=Number(r);if(!Number.isNaN(e))return{fixed:e}}return!1});export{s as rc_boolean_autofix,u as rc_number_autofix,n as rc_string_autofix};
1
+ import{e as f,f as t,g as o}from"./chunk-7DLJSWI7.js";var s=f.withAutofix(r=>r==null||r===0||r===1?{fixed:!!r}:r==="true"||r==="false"?{fixed:r==="true"}:!1),n=t.withAutofix(r=>typeof r=="number"&&!Number.isNaN(r)?{fixed:r.toString()}:!1),u=o.withAutofix(r=>{if(typeof r=="string"){let e=Number(r);if(!Number.isNaN(e))return{fixed:e}}return!1});export{s as rc_boolean_autofix,u as rc_number_autofix,n as rc_string_autofix};
@@ -0,0 +1 @@
1
+ function m(e){return{...this,a:e}}function i(e,r,n,t){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let a=t();if(a&&(a===!0||"data"in a)){let s=a===!0?r:a.data;return e.t&&!e.t(s)?[!1,[e.n(s)]]:[!0,s]}if(e.a!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let s=e.i(r);if(s)return e.t&&!e.t(s.fixed)?[!1,[e.n(s.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,s.fixed])}return[!1,a&&"errors"in a?a.errors:[e.n(r)]]}function A(e){return{...this,y:!0,i:e}}function S(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function P(){return{...this,c:!0}}function V(e){return`Type '${k(e)}' is not assignable to '${this.e}'`}function q(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function E(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:m,where:S,optional:P,n:V,nullable:q,withAutofix:A,nullish:E},N={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},v={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},K={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},F={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},C={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},U={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},z={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},B={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function D(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function M(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},e:e.length==1?`${k(e[0])}_literal`:"literals"}}function W(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(t.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function G(e,r){return{...r,o:e}}function h(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),a=n.slice(1);return`$${r}${a}: ${t}`}return`$${r}: ${e}`}function w(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t=new Set(Object.keys(r)),a={},s=[];for(let[c,l]of Object.entries(e)){let d=c,u,y=c;l.o?(u=r[l.o],y=l.o,u===void 0&&(u=r[c],y=c)):u=r[c],t.delete(y);let[p,R]=l.r(u,n);if(p)a[d]=R;else{let T=R;for(let _ of T)s.push(h(_,`.${c}`))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)s.push(`Key '${c}' is not defined in the object shape`);return s.length>0?{errors:s}:{data:a}})}}}function H(e){return{...w(e),e:"strict_obj"}}function J(e,r){return w({...e.s,...r.s})}function L(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t={},a=[];for(let[s,c]of Object.entries(r)){let l=r[s],[d,u]=e.r(c,n);if(d)t[s]=l;else{let y=u;for(let p of y)a.push(h(p,`.${s}`))}}return a.length>0?{errors:a}:{data:t}})}}}function $(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function g(e,r,n,t=!1,a){let s=-1,c=[],l=new Set;for(let d of e){s++;let u=Array.isArray(r)?r[s]:r,y=u.r(d,n),[p,R]=y,T=a?.unique;if(p&&T){let f=R,x=typeof T=="string";x&&(f=R[T]),l.has(f)?y=[!1,[x?h(`Type '${u.s?.[T]?.e}' with value "${f}" is not unique`,`.${T}`):`${u.e} value is not unique`]]:l.add(f)}let[_,b]=y;if(_)c.push(b);else if(t){n.warnings.push(...b.map(f=>h(f,`[${s}]`)));continue}else return{errors:b.map(f=>h(f,`[${s}]`))}}return{data:c}}function Q(e,r){return $(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!1,r):!1)}}}function X(e,r){return $(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!0,r):!1)}}}function Y(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:g.call(this,r,e,n))}}}function j(e,r){let n={warnings:[]},[t,a]=r.r(e,n);return t?{error:!1,data:a,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:a}}function Z(e){return r=>j(r,e)}function ee(e,r){let n=j(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function I(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function re(e){return r=>I(r,e)}function ne(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function te(e,r){return{...o,e:e.e,r(n,t){let[a,s]=e.r(n,t);return a?[!0,r(s)]:[!1,s]}}}function k(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{N as a,v as b,K as c,F as d,C as e,U as f,z as g,B as h,D as i,M as j,W as k,G as l,w as m,H as n,J as o,L as p,Q as q,X as r,Y as s,j as t,Z as u,ee as v,I as w,re as x,ne as y,te as z};
package/dist/runcheck.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var P=(e,r)=>{for(var n in r)_(e,n,{get:r[n],enumerable:!0})},V=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of A(r))!S.call(e,s)&&s!==n&&_(e,s,{get:()=>r[s],enumerable:!(t=m(r,s))||t.enumerable});return e};var q=e=>V(_({},"__esModule",{value:!0}),e);var ue={};P(ue,{rc_any:()=>B,rc_array:()=>re,rc_boolean:()=>M,rc_date:()=>H,rc_instanceof:()=>J,rc_is_valid:()=>j,rc_literals:()=>L,rc_loose_array:()=>ne,rc_loose_parse:()=>ae,rc_null:()=>z,rc_number:()=>G,rc_obj_intersection:()=>Z,rc_object:()=>b,rc_parse:()=>x,rc_parser:()=>se,rc_record:()=>ee,rc_recursive:()=>ie,rc_rename_key:()=>X,rc_strict_obj:()=>Y,rc_string:()=>W,rc_transform:()=>ce,rc_tuple:()=>te,rc_undefined:()=>U,rc_union:()=>Q,rc_unknown:()=>D,rc_validator:()=>oe});module.exports=q(ue);function E(e){return{...this,o:e}}function i(e,r,n,t){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let s=t();if(s&&(s===!0||"data"in s)){let a=s===!0?r:s.data;return e.t&&!e.t(a)?[!1,[e.n(a)]]:[!0,a]}if(e.o!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.o];if(e.y&&e.i){let a=e.i(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[e.n(a.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,a.fixed])}return[!1,s&&"errors"in s?s.errors:[e.n(r)]]}function I(e){return{...this,y:!0,i:e}}function N(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function v(){return{...this,c:!0}}function K(e){return`Type '${k(e)}' is not assignable to '${this.e}'`}function F(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function C(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:E,where:N,optional:v,n:K,nullable:F,withAutofix:I,nullish:C},U={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},z={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},B={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},D={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},M={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},W={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},G={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},H={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function J(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function L(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},e:e.length==1?`${k(e[0])}_literal`:"literals"}}function Q(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(t.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function X(e,r){return{...r,a:e}}function p(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),s=n.slice(1);return`$${r}${s}: ${t}`}return`$${r}: ${e}`}function b(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t=new Set(Object.keys(r)),s={},a=[];for(let[c,y]of Object.entries(e)){let d=c,u,f=c;y.a?(u=r[y.a],f=y.a,u===void 0&&(u=r[c],f=c)):u=r[c],t.delete(f);let[T,R]=y.r(u,n);if(T)s[d]=R;else{let h=R;for(let l of h)a.push(p(l,`.${c}`))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)a.push(`Key '${c}' is not defined in the object shape`);return a.length>0?{errors:a}:{data:s}})}}}function Y(e){return{...b(e),e:"strict_obj"}}function Z(e,r){return b({...e.s,...r.s})}function ee(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t={},s=[];for(let[a,c]of Object.entries(r)){let y=r[a],[d,u]=e.r(c,n);if(d)t[a]=y;else{let f=u;for(let T of f)s.push(p(T,`.${a}`))}}return s.length>0?{errors:s}:{data:t}})}}}function $(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function g(e,r,n,t=!1,s){let a=-1,c=[],y=new Set;for(let d of e){a++;let u=Array.isArray(r)?r[a]:r,f=u.r(d,n),T=s?.unique;if(f[0]&&T){let l=d,w=typeof T=="string";w&&(l=d[T]),y.has(l)?f=[!1,[w?p(`Type '${u.s?.[T]?.e}' with value "${l}" is not unique`,`.${T}`):`${u.e} value is not unique`]]:y.add(l)}let[R,h]=f;if(R)t&&c.push(d);else if(t){n.warnings.push(...h.map(l=>p(l,`[${a}]`)));continue}else return{errors:h.map(l=>p(l,`[${a}]`))}}return t?{data:c}:!0}function re(e,r){return $(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!1,r):!1)}}}function ne(e,r){return $(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!0,r):!1)}}}function te(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:g.call(this,r,e,n))}}}function x(e,r){let n={warnings:[]},[t,s]=r.r(e,n);return t?{error:!1,data:s,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:s}}function se(e){return r=>x(r,e)}function ae(e,r){let n=x(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function j(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function oe(e){return r=>j(r,e)}function ie(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function ce(e,r){return{...o,e:e.e,r(n,t){let[s,a]=e.r(n,t);return s?[!0,r(a)]:[!1,a]}}}function k(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}0&&(module.exports={rc_any,rc_array,rc_boolean,rc_date,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_null,rc_number,rc_obj_intersection,rc_object,rc_parse,rc_parser,rc_record,rc_recursive,rc_rename_key,rc_strict_obj,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_validator});
1
+ "use strict";var g=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var q=(e,r)=>{for(var n in r)g(e,n,{get:r[n],enumerable:!0})},E=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of P(r))!V.call(e,t)&&t!==n&&g(e,t,{get:()=>r[t],enumerable:!(s=S(r,t))||s.enumerable});return e};var I=e=>E(g({},"__esModule",{value:!0}),e);var ye={};q(ye,{rc_any:()=>M,rc_array:()=>te,rc_boolean:()=>G,rc_date:()=>L,rc_instanceof:()=>Q,rc_is_valid:()=>O,rc_literals:()=>X,rc_loose_array:()=>se,rc_loose_parse:()=>ie,rc_null:()=>D,rc_number:()=>J,rc_obj_intersection:()=>re,rc_object:()=>x,rc_parse:()=>$,rc_parser:()=>oe,rc_record:()=>ne,rc_recursive:()=>ue,rc_rename_key:()=>Z,rc_strict_obj:()=>ee,rc_string:()=>H,rc_transform:()=>le,rc_tuple:()=>ae,rc_undefined:()=>B,rc_union:()=>Y,rc_unknown:()=>W,rc_validator:()=>ce});module.exports=I(ye);function N(e){return{...this,o:e}}function i(e,r,n,s){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let t=s();if(t&&(t===!0||"data"in t)){let a=t===!0?r:t.data;return e.t&&!e.t(a)?[!1,[e.n(a)]]:[!0,a]}if(e.o!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.o];if(e.y&&e.i){let a=e.i(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[e.n(a.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,a.fixed])}return[!1,t&&"errors"in t?t.errors:[e.n(r)]]}function v(e){return{...this,y:!0,i:e}}function K(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function F(){return{...this,c:!0}}function C(e){return`Type '${m(e)}' is not assignable to '${this.e}'`}function U(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function z(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:N,where:K,optional:F,n:C,nullable:U,withAutofix:v,nullish:z},B={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},D={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},M={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},W={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},G={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},H={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},J={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},L={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function Q(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function X(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let s of e)if(r===s)return!0;return!1})},e:e.length==1?`${m(e[0])}_literal`:"literals"}}function Y(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let s of e)if(s.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function Z(e,r){return{...r,a:e}}function h(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",s]=e.split(": "),t=n.slice(1);return`$${r}${t}: ${s}`}return`$${r}: ${e}`}function x(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!A(r))return!1;let s=new Set(Object.keys(r)),t={},a=[];for(let[c,l]of Object.entries(e)){let d=c,u,y=c;l.a?(u=r[l.a],y=l.a,u===void 0&&(u=r[c],y=c)):u=r[c],s.delete(y);let[p,R]=l.r(u,n);if(p)t[d]=R;else{let T=R;for(let _ of T)a.push(h(_,`.${c}`))}}if(this.e==="strict_obj"&&s.size>0)for(let c of s)a.push(`Key '${c}' is not defined in the object shape`);return a.length>0?{errors:a}:{data:t}})}}}function ee(e){return{...x(e),e:"strict_obj"}}function re(e,r){return x({...e.s,...r.s})}function ne(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!A(r))return!1;let s={},t=[];for(let[a,c]of Object.entries(r)){let l=r[a],[d,u]=e.r(c,n);if(d)s[a]=l;else{let y=u;for(let p of y)t.push(h(p,`.${a}`))}}return t.length>0?{errors:t}:{data:s}})}}}function k(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function w(e,r,n,s=!1,t){let a=-1,c=[],l=new Set;for(let d of e){a++;let u=Array.isArray(r)?r[a]:r,y=u.r(d,n),[p,R]=y,T=t?.unique;if(p&&T){let f=R,j=typeof T=="string";j&&(f=R[T]),l.has(f)?y=[!1,[j?h(`Type '${u.s?.[T]?.e}' with value "${f}" is not unique`,`.${T}`):`${u.e} value is not unique`]]:l.add(f)}let[_,b]=y;if(_)c.push(b);else if(s){n.warnings.push(...b.map(f=>h(f,`[${a}]`)));continue}else return{errors:b.map(f=>h(f,`[${a}]`))}}return{data:c}}function te(e,r){return k(e,r?.unique),{...o,e:`${e.e}[]`,r(n,s){return i(this,n,s,()=>Array.isArray(n)?n.length===0?!0:w.call(this,n,e,s,!1,r):!1)}}}function se(e,r){return k(e,r?.unique),{...o,e:`${e.e}[]`,r(n,s){return i(this,n,s,()=>Array.isArray(n)?n.length===0?!0:w.call(this,n,e,s,!0,r):!1)}}}function ae(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:w.call(this,r,e,n))}}}function $(e,r){let n={warnings:[]},[s,t]=r.r(e,n);return s?{error:!1,data:t,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:t}}function oe(e){return r=>$(r,e)}function ie(e,r){let n=$(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function O(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function ce(e){return r=>O(r,e)}function ue(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function le(e,r){return{...o,e:e.e,r(n,s){let[t,a]=e.r(n,s);return t?[!0,r(a)]:[!1,a]}}}function m(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function A(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}0&&(module.exports={rc_any,rc_array,rc_boolean,rc_date,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_null,rc_number,rc_obj_intersection,rc_object,rc_parse,rc_parser,rc_record,rc_recursive,rc_rename_key,rc_strict_obj,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_validator});
package/dist/runcheck.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-SYJIFZCW.js";export{c as rc_any,q as rc_array,e as rc_boolean,h as rc_date,i as rc_instanceof,w as rc_is_valid,j as rc_literals,r as rc_loose_array,v as rc_loose_parse,b as rc_null,g as rc_number,o as rc_obj_intersection,m as rc_object,t as rc_parse,u as rc_parser,p as rc_record,y as rc_recursive,l as rc_rename_key,n as rc_strict_obj,f as rc_string,z as rc_transform,s as rc_tuple,a as rc_undefined,k as rc_union,d as rc_unknown,x as rc_validator};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-7DLJSWI7.js";export{c as rc_any,q as rc_array,e as rc_boolean,h as rc_date,i as rc_instanceof,w as rc_is_valid,j as rc_literals,r as rc_loose_array,v as rc_loose_parse,b as rc_null,g as rc_number,o as rc_obj_intersection,m as rc_object,t as rc_parse,u as rc_parser,p as rc_record,y as rc_recursive,l as rc_rename_key,n as rc_strict_obj,f as rc_string,z as rc_transform,s as rc_tuple,a as rc_undefined,k as rc_union,d as rc_unknown,x as rc_validator};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "runcheck",
3
3
  "description": "A tiny (less than 2 KiB Gzipped) and treeshakable! lib for typescript runtime type checks with autofix support",
4
- "version": "0.14.0",
4
+ "version": "0.14.1",
5
5
  "license": "MIT",
6
6
  "scripts": {
7
7
  "test": "vitest --ui",
@@ -1 +0,0 @@
1
- function k(e){return{...this,a:e}}function i(e,r,n,t){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let a=t();if(a&&(a===!0||"data"in a)){let s=a===!0?r:a.data;return e.t&&!e.t(s)?[!1,[e.n(s)]]:[!0,s]}if(e.a!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let s=e.i(r);if(s)return e.t&&!e.t(s.fixed)?[!1,[e.n(s.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,s.fixed])}return[!1,a&&"errors"in a?a.errors:[e.n(r)]]}function O(e){return{...this,y:!0,i:e}}function m(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function A(){return{...this,c:!0}}function S(e){return`Type '${$(e)}' is not assignable to '${this.e}'`}function P(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function V(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:k,where:m,optional:A,n:S,nullable:P,withAutofix:O,nullish:V},E={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},I={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},N={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},v={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},K={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},F={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},C={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},U={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function z(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function B(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},e:e.length==1?`${$(e[0])}_literal`:"literals"}}function D(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(t.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function M(e,r){return{...r,o:e}}function p(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),a=n.slice(1);return`$${r}${a}: ${t}`}return`$${r}: ${e}`}function g(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!j(r))return!1;let t=new Set(Object.keys(r)),a={},s=[];for(let[c,y]of Object.entries(e)){let d=c,u,f=c;y.o?(u=r[y.o],f=y.o,u===void 0&&(u=r[c],f=c)):u=r[c],t.delete(f);let[T,R]=y.r(u,n);if(T)a[d]=R;else{let h=R;for(let l of h)s.push(p(l,`.${c}`))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)s.push(`Key '${c}' is not defined in the object shape`);return s.length>0?{errors:s}:{data:a}})}}}function W(e){return{...g(e),e:"strict_obj"}}function G(e,r){return g({...e.s,...r.s})}function H(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!j(r))return!1;let t={},a=[];for(let[s,c]of Object.entries(r)){let y=r[s],[d,u]=e.r(c,n);if(d)t[s]=y;else{let f=u;for(let T of f)a.push(p(T,`.${s}`))}}return a.length>0?{errors:a}:{data:t}})}}}function x(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function _(e,r,n,t=!1,a){let s=-1,c=[],y=new Set;for(let d of e){s++;let u=Array.isArray(r)?r[s]:r,f=u.r(d,n),T=a?.unique;if(f[0]&&T){let l=d,b=typeof T=="string";b&&(l=d[T]),y.has(l)?f=[!1,[b?p(`Type '${u.s?.[T]?.e}' with value "${l}" is not unique`,`.${T}`):`${u.e} value is not unique`]]:y.add(l)}let[R,h]=f;if(R)t&&c.push(d);else if(t){n.warnings.push(...h.map(l=>p(l,`[${s}]`)));continue}else return{errors:h.map(l=>p(l,`[${s}]`))}}return t?{data:c}:!0}function J(e,r){return x(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:_.call(this,n,e,t,!1,r):!1)}}}function L(e,r){return x(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:_.call(this,n,e,t,!0,r):!1)}}}function Q(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:_.call(this,r,e,n))}}}function w(e,r){let n={warnings:[]},[t,a]=r.r(e,n);return t?{error:!1,data:a,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:a}}function X(e){return r=>w(r,e)}function Y(e,r){let n=w(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function q(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function Z(e){return r=>q(r,e)}function ee(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function re(e,r){return{...o,e:e.e,r(n,t){let[a,s]=e.r(n,t);return a?[!0,r(s)]:[!1,s]}}}function $(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{E as a,I as b,N as c,v as d,K as e,F as f,C as g,U as h,z as i,B as j,D as k,M as l,g as m,W as n,G as o,H as p,J as q,L as r,Q as s,w as t,X as u,Y as v,q as w,Z as x,ee as y,re as z};