n4s 3.0.0 → 4.0.0-dev-1aae50

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/LICENSE +1 -2
  3. package/README.md +2 -5
  4. package/compose/package.json +7 -0
  5. package/compounds/package.json +7 -0
  6. package/dist/cjs/compose.development.js +139 -0
  7. package/dist/cjs/compose.js +7 -0
  8. package/dist/cjs/compose.production.js +1 -0
  9. package/dist/cjs/compounds.development.js +132 -0
  10. package/dist/cjs/compounds.js +7 -0
  11. package/dist/cjs/compounds.production.js +1 -0
  12. package/dist/cjs/n4s.development.js +602 -0
  13. package/dist/cjs/n4s.js +7 -0
  14. package/dist/cjs/n4s.production.js +1 -0
  15. package/dist/cjs/package.json +1 -0
  16. package/dist/cjs/schema.development.js +144 -0
  17. package/dist/cjs/schema.js +7 -0
  18. package/dist/cjs/schema.production.js +1 -0
  19. package/dist/es/compose.development.js +137 -0
  20. package/dist/es/compose.production.js +1 -0
  21. package/dist/es/compounds.development.js +130 -0
  22. package/dist/es/compounds.production.js +1 -0
  23. package/dist/es/n4s.development.js +597 -0
  24. package/dist/es/n4s.production.js +1 -0
  25. package/dist/es/package.json +1 -0
  26. package/dist/es/schema.development.js +140 -0
  27. package/dist/es/schema.production.js +1 -0
  28. package/dist/umd/compose.development.js +143 -0
  29. package/dist/umd/compose.production.js +1 -0
  30. package/dist/umd/compounds.development.js +136 -0
  31. package/dist/umd/compounds.production.js +1 -0
  32. package/dist/umd/n4s.development.js +606 -0
  33. package/dist/umd/n4s.production.js +1 -0
  34. package/dist/umd/schema.development.js +148 -0
  35. package/dist/umd/schema.production.js +1 -0
  36. package/docs/README.md +2 -5
  37. package/docs/_sidebar.md +1 -2
  38. package/docs/external.md +1 -28
  39. package/docs/rules.md +28 -0
  40. package/package.json +129 -42
  41. package/schema/package.json +7 -0
  42. package/tsconfig.json +8 -0
  43. package/types/compose.d.ts +134 -0
  44. package/types/compounds.d.ts +146 -0
  45. package/types/n4s.d.ts +167 -0
  46. package/types/schema.d.ts +151 -0
  47. package/config/jest/jest.setup.js +0 -14
  48. package/config/rollup/enforce.js +0 -8
  49. package/config/rollup/rollup.config.js +0 -3
  50. package/docs/compound.md +0 -187
  51. package/docs/custom.md +0 -52
  52. package/docs/template.md +0 -53
  53. package/esm/n4s.mjs.development.js +0 -1101
  54. package/esm/n4s.mjs.production.js +0 -1101
  55. package/esm/n4s.mjs.production.min.js +0 -1
  56. package/esm/package.json +0 -1
  57. package/jest.config.js +0 -3
  58. package/n4s.cjs.development.js +0 -1103
  59. package/n4s.cjs.production.js +0 -1103
  60. package/n4s.cjs.production.min.js +0 -1
  61. package/n4s.js +0 -7
  62. package/n4s.umd.development.js +0 -1109
  63. package/n4s.umd.production.js +0 -1192
  64. package/n4s.umd.production.min.js +0 -1
@@ -1 +0,0 @@
1
- "use strict";function t(t){Object.assign(this,t)}function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function n(t){return function(){return!t.apply(this,arguments)}}function r(t){return!!t===t}t.prototype.setFailFast=function(t){return this.failFast=!!t,this},t.unwrap=function(e){return t.is(e)?e.value:e},t.wrap=function(e){return t.is(e)?e:new t({value:e})},t.is=function(e){return e instanceof t};let i=n(r);function s(t){return!(isNaN(parseFloat(t))||isNaN(Number(t))||!isFinite(t))}let u=n(s);function a(t,e){return t.length===Number(e)}let o=n(a);function l(t){if(t){if(s(t))return 0===t;if(e(t,"length"))return a(t,0);if("object"==typeof t)return a(Object.keys(t),0)}return!0}let f=n(l);function c(t){return void 0===t}let h=n(c);function d(t){c(t)||(r(t)?this.setFailed(!t):this.extend(t))}function p(t,n){let r=d.is(t),i=d.is(n);if(r&&i){if(t.setFailed(t.failed||n.failed),l(t.children)&&l(n.children))return t;if(t.children&&n.children){for(let e in t.children)p(t.children[e],n.children[e]);for(let r in n.children)e(t.children,r)||t.setChild(r,n.children[r]);return t}if(t.children){if(!n.children)return t}else t.children=n.children}else{if(r)return t;if(i)return n}return new d(!1)}d.is=function(t){return t instanceof d},d.prototype.asArray=function(){return this.isArray=!0,this},d.prototype.setAttribute=function(t,e){return this[t]=e,this},d.prototype.setFailed=function(t){return this.setAttribute(this.warn?"hasWarnings":"hasErrors",t),this.setAttribute("failed",t)},d.prototype.setChild=function(t,e){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},d.prototype.getChild=function(t){return(this.children||{})[t]},d.prototype.extend=function(t){t=d.is(t)?t:(new d).setAttribute("warn",!!this.warn).setFailed(!t);let e=this.failed||t.failed,n=p(t,this).children;Object.assign(this,t),l(n)||(this.children=n),this.setFailed(e),this.setAttribute("hasWarnings",!(!this.hasWarnings&&!t.hasWarnings)),this.setAttribute("hasErrors",!(!this.hasErrors&&!t.hasErrors))},Object.defineProperty(d.prototype,"pass",{get(){return!this.failed}});function b(t){return"function"==typeof t}function m(e,n){return!n.pass&&!n.warn&&(!!t.is(e)&&e.failFast)}function N(t,e){let n=new d(!0);for(let r of function(t){return[].concat(t)}(t)){if(m(e,n))break;n.extend(y(r,e))}return n}function y(t,e){return t.run(e)}function g(t,e,n){let r=new d(!0);l(e)&&r.setFailed(!0);let i=[],s=0;for(let u of e){let a=(e=y(u,t)).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 w(t,e){return Object.defineProperty(t,"name",{value:e})}function F(t,e){return w(((...e)=>{let n=e.splice(t.length-1);return t.apply(null,e.concat([n]))}),e||t.name)}var E=F((function(t,e){return g(t,e,{mode:"all"})}));var v=F((function(t,e){return g(t,e,{mode:"any"})}));function O(t){return!!Array.isArray(t)}let A=n(O);var x=F((function(e,n){let r=t.unwrap(e),i=new d(!0).asArray();if(A(r))return i.setFailed(!0);for(let s=0;s<r.length;s++)i.setChild(s,g(t.wrap(r[s]).setFailFast(e.failFast),n,{mode:"any"}));return i}));var W=F((function(t,e){return g(t,e,{mode:"one"})}));function j(t){return null===t}let k=n(j);function q(n,r,i){let s=t.unwrap(n),u=new d(!0);for(let e in r){let i=r[e],a=s[e];if(m(a,u))break;u.setChild(e,y(i,new t({value:a,obj:s,key:e}).setFailFast(n.failFast)))}if(!(i||{}).loose)for(let t in s)if(!e(r,t))return u.setFailed(!0);return u}var T={allOf:E,anyOf:v,isArrayOf:x,loose:(t,e)=>q(t,e,{loose:!0}),oneOf:W,optional:F((function(t,n){let{obj:r,key:i}=t;return!(e(r,i)&&!c(r[i]||j(r[i]))&&!l(n))||g(r[i],n,{mode:"all"})})),shape:q};function P(t,e){return b(t)?t.apply(null,e):t}var C={warn:function(t,e=!0){return e},message:function(e,n){return P(n,[t.unwrap(e)])}};function B(t){return String(t)===t}function S(t,e){return B(t)&&B(e)&&t.endsWith(e)}let $=n(S);function R(t,e){return t===e}let U=n(R);function I(t,e){return s(t)&&s(e)&&Number(t)>Number(e)}function M(t,e){return s(t)&&s(e)&&Number(t)>=Number(e)}function z(t,e){return!!(Array.isArray(e)&&/^[s|n|b]/.test(typeof t)||B(e)&&B(t))&&-1!==e.indexOf(t)}let D=n(z);function G(t,e){return s(t)&&s(e)&&Number(t)<=Number(e)}function H(t,e,n){return M(t,e)&&G(t,n)}let J=n(H),K=t=>!!s(t)&&0==t%2;function L(t){return Number.isNaN(t)}let Q=n(L);function V(t){return!!s(t)&&0>Number(t)}let X=n(V);function Y(t){return"number"==typeof t}let Z=n(Y),_=t=>!!s(t)&&0!=t%2,tt=n(B);function et(t){return!!t}let nt=n(et);function rt(t,e){return s(t)&&s(e)&&Number(t)<Number(e)}function it(t,e){return t.length>Number(e)}function st(t,e){return t.length>=Number(e)}function ut(t,e){return e instanceof RegExp?e.test(t):!!B(e)&&new RegExp(e).test(t)}let at=n(ut);function ot(t,e){return s(t)&&s(e)&&Number(t)===Number(e)}let lt=n(ot);function ft(t,e){return t.length<Number(e)}function ct(t,e){return t.length<=Number(e)}function ht(t,e){return B(t)&&B(e)&&t.startsWith(e)}let dt=n(ht);var pt=Object.assign({doesNotEndWith:$,doesNotStartWith:dt,endsWith:S,equals:R,greaterThan:I,greaterThanOrEquals:M,gt:I,gte:M,inside:z,isArray:O,isBetween:H,isBoolean:r,isEmpty:l,isEven:K,isFalsy:nt,isNaN:L,isNegative:V,isNotArray:A,isNotBetween:J,isNotBoolean:i,isNotEmpty:f,isNotNaN:Q,isNotNull:k,isNotNumber:Z,isNotNumeric:u,isNotString:tt,isNotUndefined:h,isNull:j,isNumber:Y,isNumeric:s,isOdd:_,isPositive:X,isString:B,isTruthy:et,isUndefined:c,lengthEquals:a,lengthNotEquals:o,lessThan:rt,lessThanOrEquals:G,longerThan:it,longerThanOrEquals:st,lt:rt,lte:G,matches:ut,notEquals:U,notInside:D,notMatches:at,numberEquals:ot,numberNotEquals:lt,shorterThan:ft,shorterThanOrEquals:ct,startsWith:ht},T,C);let bt=Function("return this")(),mt=()=>b(bt.Proxy);function Nt(t,n){if(mt())return new Proxy(t,{get:(t,r)=>e(t,r)?t[r]:(t=>e(pt,t)&&b(pt[t]))(r)?n(r):t[r]});for(let e in pt)b(t[e])||Object.defineProperties(t,{[e]:{get:()=>n(e)}});return t}function yt(t){return e(T,t.name)}function gt(e){let n=[],r=[],i=e=>F((s=>{const u=pt[e];C[u.name]===u?r.push(((t,e)=>{e.setAttribute(u.name,u(t,s[0]))})):n.push(w((e=>u.apply(null,[yt(u)?t.wrap(e):t.unwrap(e)].concat(s))),e));const a=Nt({},i);return a.run=t=>{const e=new d(!0);r.forEach((n=>{n(t,e)}));for(const r of n)try{if(e.extend(r(t)),!e.pass)break}catch(t){e.setFailed(!0);break}return e},a.test=e=>a.run(t.wrap(e).setFailFast(!0)).pass,a}),e);return i(e)}function wt(t,e){r(t)||t&&r(t.pass)||((t,e=Error)=>{throw new e(`[n4s]: ${t}`)})(e.name+"wrong return value")}function Ft(t,e){return`[n4s]:${t.name} ${e}`}function Et(t,{rule:e,value:n}){return n=function(t,e){return{message:Ft(e,`invalid ${typeof t} value`)}}(n,e),wt(t,e),r(t)?(n.pass=t,n):(n.pass=t.pass,t.message&&(n.message=Ft(e,P(t.message))),n)}function vt(e,n,r=[]){let i=yt(e),s=i?t.wrap(n).setFailFast(!0):t.unwrap(n);if(r=e.apply(null,[s].concat(r)),i||(r=Et(r,{rule:e,value:n})),!r.pass)throw Error(r.message)}let Ot=t=>{const e=Nt({},(n=>F((r=>(vt(pt[n],t,r),e)))));return e},At=Nt(Ot,gt);var xt,Wt;Wt=Ot,(xt=At).extend=t=>(Object.assign(pt,t),mt()||Nt(Wt,gt),xt),function(e){e.template=F((e=>{let n=t=>{vt(N.bind(null,e),t);const n=Nt({},(e=>F((r=>(vt(pt[e],t,r),n)))));return n};return n.run=t=>N(e,t),n.test=n=>N(e,t.wrap(n).setFailFast(!0)).pass,n}))}(At),module.exports=At;
package/n4s.js DELETED
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./n4s.umd.production.min.js')
5
- } else {
6
- module.exports = require('./n4s.umd.development.js')
7
- }