n4s 3.1.0 → 4.0.0-dev-e266d9
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.
- package/CHANGELOG.md +129 -0
- package/LICENSE +1 -2
- package/README.md +2 -5
- package/compose/package.json +7 -0
- package/compounds/package.json +7 -0
- package/dist/cjs/compose.development.js +139 -0
- package/dist/cjs/compose.js +7 -0
- package/dist/cjs/compose.production.js +1 -0
- package/dist/cjs/compounds.development.js +132 -0
- package/dist/cjs/compounds.js +7 -0
- package/dist/cjs/compounds.production.js +1 -0
- package/dist/cjs/n4s.development.js +602 -0
- package/dist/cjs/n4s.js +7 -0
- package/dist/cjs/n4s.production.js +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/schema.development.js +144 -0
- package/dist/cjs/schema.js +7 -0
- package/dist/cjs/schema.production.js +1 -0
- package/dist/es/compose.development.js +137 -0
- package/dist/es/compose.production.js +1 -0
- package/dist/es/compounds.development.js +130 -0
- package/dist/es/compounds.production.js +1 -0
- package/dist/es/n4s.development.js +597 -0
- package/dist/es/n4s.production.js +1 -0
- package/dist/es/package.json +1 -0
- package/dist/es/schema.development.js +140 -0
- package/dist/es/schema.production.js +1 -0
- package/dist/umd/compose.development.js +143 -0
- package/dist/umd/compose.production.js +1 -0
- package/dist/umd/compounds.development.js +136 -0
- package/dist/umd/compounds.production.js +1 -0
- package/dist/umd/n4s.development.js +606 -0
- package/dist/umd/n4s.production.js +1 -0
- package/dist/umd/schema.development.js +148 -0
- package/dist/umd/schema.production.js +1 -0
- package/docs/README.md +2 -5
- package/docs/_sidebar.md +0 -1
- package/docs/external.md +1 -28
- package/package.json +129 -53
- package/schema/package.json +7 -0
- package/tsconfig.json +8 -0
- package/types/compose.d.ts +134 -0
- package/types/compounds.d.ts +146 -0
- package/types/n4s.d.ts +167 -0
- package/types/schema.d.ts +151 -0
- package/config/jest/jest.setup.js +0 -14
- package/config/rollup/enforce.js +0 -8
- package/config/rollup/rollup.config.js +0 -3
- package/docs/compound.md +0 -187
- package/docs/custom.md +0 -52
- package/docs/template.md +0 -53
- package/esm/n4s.es.development.js +0 -1142
- package/esm/n4s.es.production.js +0 -1142
- package/esm/n4s.es.production.min.js +0 -1
- package/esm/package.json +0 -1
- package/jest.config.js +0 -3
- package/n4s.cjs.development.js +0 -1144
- package/n4s.cjs.production.js +0 -1144
- package/n4s.cjs.production.min.js +0 -1
- package/n4s.js +0 -7
- package/n4s.umd.development.js +0 -1231
- package/n4s.umd.production.js +0 -1231
- package/n4s.umd.production.min.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=Object.assign;function e(e){t(this,e)}function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r(t){return function(){return!t.apply(this,arguments)}}function i(t){return!!t===t}e.prototype.setFailFast=function(t){return this.failFast=!!t,this},e.unwrap=function(t){return e.is(t)?t.value:t},e.wrap=function(t){return e.is(t)?t:new e({value:t})},e.is=function(t){return t instanceof e};let s=r(i);function u(t){return!(isNaN(parseFloat(t))||isNaN(Number(t))||!isFinite(t))}let a=r(u);function o(t,e){return t.length===Number(e)}let l=r(o);function f(t){if(t){if(u(t))return 0===t;if(n(t,"length"))return o(t,0);if("object"==typeof t)return o(Object.keys(t),0)}return!0}let c=r(f);function h(t){return null===t}let d=r(h);function p(t){return void 0===t}let b=r(p);function m(t){p(t)||(i(t)?this.setFailed(!t):this.extend(t))}function y(t,e){let r=m.is(t),i=m.is(e);if(r&&i){if(t.setFailed(t.failed||e.failed),f(t.children)&&f(e.children))return t;if(t.children&&e.children){for(let n in t.children)y(t.children[n],e.children[n]);for(let r in e.children)n(t.children,r)||t.setChild(r,e.children[r]);return t}if(t.children){if(!e.children)return t}else t.children=e.children}else{if(r)return t;if(i)return e}return new m(!1)}m.is=function(t){return t instanceof m},m.prototype.asArray=function(){return this.isArray=!0,this},m.prototype.setAttribute=function(t,e){return this[t]=e,this},m.prototype.setFailed=function(t){return this.setAttribute(this.warn?"hasWarnings":"hasErrors",t),this.setAttribute("failed",t)},m.prototype.setChild=function(t,e){if(h(e))return null;let n=this.hasWarnings||e.hasWarnings||e.warn||this.warn;return this.setAttribute("hasWarnings",n&&e.failed||!1),this.setAttribute("hasErrors",this.hasErrors||e.hasErrors||!n&&e.failed||!1),this.setFailed(this.failed||e.failed),this.children=this.children||{},this.children[t]=e},m.prototype.getChild=function(t){return(this.children||{})[t]},m.prototype.extend=function(e){if(h(e))return this;e=m.is(e)?e:(new m).setAttribute("warn",!!this.warn).setFailed(!e);let n=this.failed||e.failed,r=y(e,this).children;t(this,e),f(r)||(this.children=r),this.setFailed(n),this.setAttribute("hasWarnings",!(!this.hasWarnings&&!e.hasWarnings)),this.setAttribute("hasErrors",!(!this.hasErrors&&!e.hasErrors))},Object.defineProperty(m.prototype,"pass",{get(){return!this.failed}});function N(t){return"function"==typeof t}function g(t,n){return!n.pass&&!n.warn&&(!!e.is(t)&&t.failFast)}function w(t,e){let n=new m(!0);for(let r of function(t){return[].concat(t)}(t)){if(g(e,n))break;n.extend(F(r,e))}return n}function F(t,e){return t.run(e)}function E(t,e,n){let r=new m(!0);f(e)&&r.setFailed(!0);let i=[],s=0;for(let u of e){if(h(e=F(u,t)))return null;let a=e.pass;if(a?s++:i.push(e),n)if("any"===n.mode){if(a){r.extend(e);break}}else{if(r.extend(e),"all"===n.mode&&!a)break;if("one"===n.mode&&(r.setFailed(1!==s),1<s))break}else if(r.extend(e),a)break}return r.pass&&0===s&&(r.setFailed(!0),i.forEach((t=>r.extend(t)))),r}function v(t,e){var n;return null!==(n=Object.getOwnPropertyDescriptor(t,"name"))&&void 0!==n&&n.configurable?Object.defineProperty(t,"name",{value:e}):t}function A(t,e){return v((function(){let e=Array.from(arguments),n=e.splice(t.length-1);return t.apply(null,e.concat([n]))}),e||t.name)}var O=A((function(t,e){return E(t,e,{mode:"all"})}));var k=A((function(t,e){return E(t,e,{mode:"any"})}));function x(t){return!!Array.isArray(t)}let W=r(x);function j(t,r,i){let s=e.unwrap(t),u=new m(!0);for(let n in r){let i=r[n],a=s[n];if(g(a,u))break;u.setChild(n,F(i,new e({value:a,obj:s,key:n}).setFailFast(t.failFast)))}if(!(i||{}).loose)for(let t in s)if(!n(r,t))return u.setFailed(!0);return u}var q={allOf:O,anyOf:k,isArrayOf:A((function(t,n){let r=e.unwrap(t),i=new m(!0).asArray();if(W(r))return i.setFailed(!0);for(let s=0;s<r.length;s++)i.setChild(s,E(new e({value:r[s],obj:r,key:s}).setFailFast(t.failFast),n,{mode:"any"}));return i})),loose:(t,e)=>j(t,e,{loose:!0}),oneOf:A((function(t,e){return E(t,e,{mode:"one"})})),optional:A((function(t,e){let{obj:r,key:i}=t;return!(n(r,i)&&!p(r[i]||h(r[i]))&&!f(e))||E(r[i],e,{mode:"all"})})),shape:j};function T(t,e){return N(t)?t.apply(null,e):t}var P={warn:function(t,e=!0){return e},message:function(t,n){return T(n,[e.unwrap(t)])},when:function(t,n,r){return r(t=!T(n,[e.unwrap(t)].concat(e.is(t)?[t.key,t.obj]:[])))}};function B(t){return String(t)===t}function C(t,e){return B(t)&&B(e)&&t.endsWith(e)}let S=r(C);function R(t,e){return t===e}let U=r(R);function $(t,e){return u(t)&&u(e)&&Number(t)>Number(e)}function D(t,e){return u(t)&&u(e)&&Number(t)>=Number(e)}function I(t,e){return!!(Array.isArray(e)&&/^[s|n|b]/.test(typeof t)||B(e)&&B(t))&&-1!==e.indexOf(t)}let M=r(I);function z(t,e){return u(t)&&u(e)&&Number(t)<=Number(e)}function G(t,e,n){return D(t,e)&&z(t,n)}let H=r(G);function J(t){return"string"==typeof t&&""===t.trim()}let K=r(J),L=t=>!!u(t)&&0==t%2;function Q(t){return Number.isNaN(t)}let V=r(Q);function X(t){return!!u(t)&&0>Number(t)}let Y=r(X);function Z(t){return"number"==typeof t}let _=r(Z),tt=t=>!!u(t)&&0!=t%2,et=r(B);function nt(t){return!!t}let rt=r(nt);function it(t,e){return u(t)&&u(e)&&Number(t)<Number(e)}function st(t,e){return t.length>Number(e)}function ut(t,e){return t.length>=Number(e)}function at(t,e){return e instanceof RegExp?e.test(t):!!B(e)&&new RegExp(e).test(t)}let ot=r(at);function lt(t,e){return u(t)&&u(e)&&Number(t)===Number(e)}let ft=r(lt);function ct(t,e){return t.length<Number(e)}function ht(t,e){return t.length<=Number(e)}function dt(t,e){return B(t)&&B(e)&&t.startsWith(e)}let pt=r(dt);var bt=t({doesNotEndWith:S,doesNotStartWith:pt,endsWith:C,equals:R,greaterThan:$,greaterThanOrEquals:D,gt:$,gte:D,inside:I,isArray:x,isBetween:G,isBoolean:i,isBlank:J,isEmpty:f,isEven:L,isFalsy:rt,isNaN:Q,isNegative:X,isNotArray:W,isNotBetween:H,isNotBlank:K,isNotBoolean:s,isNotEmpty:c,isNotNaN:V,isNotNull:d,isNotNumber:_,isNotNumeric:a,isNotString:et,isNotUndefined:b,isNull:h,isNumber:Z,isNumeric:u,isOdd:tt,isPositive:Y,isString:B,isTruthy:nt,isUndefined:p,lengthEquals:o,lengthNotEquals:l,lessThan:it,lessThanOrEquals:z,longerThan:st,longerThanOrEquals:ut,lt:it,lte:z,matches:at,notEquals:U,notInside:M,notMatches:ot,numberEquals:lt,numberNotEquals:ft,shorterThan:ct,shorterThanOrEquals:ht,startsWith:dt},q,P);let mt=Function("return this")(),yt=()=>N(mt.Proxy);function Nt(t,e){if(yt())return new Proxy(t,{get:(t,r)=>n(t,r)?t[r]:(t=>n(bt,t)&&N(bt[t]))(r)?e(r):t[r]});for(let n in bt)N(t[n])||Object.defineProperties(t,{[n]:{get:()=>e(n)}});return t}function gt(t){return n(q,t.name)}function wt(t){let n=[],r=[],i=t=>A((s=>{const u=bt[t];P[u.name]===u?r.push(((t,e,n)=>{e.setAttribute(u.name,u(t,s[0],n))})):n.push(v((t=>u.apply(null,[gt(u)?e.wrap(t):e.unwrap(t)].concat(s))),t));const a=Nt({},i);return a.run=t=>{const e=new m(!0);let i=!1;if(r.forEach((n=>{n(t,e,(t=>i=t))})),i)return null;for(const r of n)try{if(e.extend(r(t)),!e.pass)break}catch(t){e.setFailed(!0);break}return e},a.test=t=>a.run(e.wrap(t).setFailFast(!0)).pass,a}),t);return i(t)}function Ft(t,e){i(t)||t&&i(t.pass)||((t,e=Error)=>{throw new e(`[n4s]: ${t}`)})(e.name+"wrong return value")}function Et(t,{rule:e,value:n}){return n=function(t){return{message:Error(`invalid ${typeof t} value`)}}(n),Ft(t,e),i(t)?(n.pass=t,n):(n.pass=t.pass,t.message&&(n.message=T(t.message)),n)}function vt(t,n,r=[]){let i=gt(t),s=i?e.wrap(n).setFailFast(!0):e.unwrap(n);if(r=t.apply(null,[s].concat(r)),i||(r=Et(r,{rule:t,value:n})),!r.pass)throw r.message}let At=t=>{const e=Nt({},(n=>A((r=>(vt(bt[n],t,r),e)))));return e},Ot=Nt(At,wt);var kt,xt;xt=At,(kt=Ot).extend=e=>(t(bt,e),yt()||Nt(xt,wt),kt),function(t){t.template=A((t=>{let n=e=>{vt(w.bind(null,t),e);const n=Nt({},(t=>A((r=>(vt(bt[t],e,r),n)))));return n};return n.run=e=>w(t,e),n.test=n=>w(t,e.wrap(n).setFailFast(!0)).pass,n}))}(Ot),module.exports=Ot;
|