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
- 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)}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[].concat(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)}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}});var E=F((function(t,e){return g(t,e,{mode:"all"})})),O=F((function(t,e){return g(t,e,{mode:"any"})}));function v(t){return!!Array.isArray(t)}let A=n(v);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})),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:O,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]||null===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 $(t){return String(t)===t}function B(t,e){return $(t)&&$(e)&&t.endsWith(e)}let S=n(B);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)||$(e)&&$(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);function K(t){return Number.isNaN(t)}let L=n(K);function Q(t){return!!s(t)&&0>Number(t)}let V=n(Q);function X(t){return"number"==typeof t}let Y=n(X),Z=n($);function _(t){return!!t}let tt=n(_);function et(t,e){return s(t)&&s(e)&&Number(t)<Number(e)}function nt(t,e){return e instanceof RegExp?e.test(t):!!$(e)&&new RegExp(e).test(t)}let rt=n(nt);function it(t,e){return s(t)&&s(e)&&Number(t)===Number(e)}let st=n(it);function ut(t,e){return $(t)&&$(e)&&t.startsWith(e)}let at=n(ut);var ot=Object.assign({doesNotEndWith:S,doesNotStartWith:at,endsWith:B,equals:R,greaterThan:I,greaterThanOrEquals:M,gt:I,gte:M,inside:z,isArray:v,isBetween:H,isBoolean:r,isEmpty:l,isEven:t=>!!s(t)&&0==t%2,isFalsy:tt,isNaN:K,isNegative:Q,isNotArray:A,isNotBetween:J,isNotBoolean:i,isNotEmpty:f,isNotNaN:L,isNotNull:k,isNotNumber:Y,isNotNumeric:u,isNotString:Z,isNotUndefined:h,isNull:j,isNumber:X,isNumeric:s,isOdd:t=>!!s(t)&&0!=t%2,isPositive:V,isString:$,isTruthy:_,isUndefined:c,lengthEquals:a,lengthNotEquals:o,lessThan:et,lessThanOrEquals:G,longerThan:function(t,e){return t.length>Number(e)},longerThanOrEquals:function(t,e){return t.length>=Number(e)},lt:et,lte:G,matches:nt,notEquals:U,notInside:D,notMatches:rt,numberEquals:it,numberNotEquals:st,shorterThan:function(t,e){return t.length<Number(e)},shorterThanOrEquals:function(t,e){return t.length<=Number(e)},startsWith:ut},T,C);let lt=Function("return this")();function ft(t,n){if(b(lt.Proxy))return new Proxy(t,{get:(t,r)=>e(t,r)?t[r]:e(ot,r)&&b(ot[r])?n(r):t[r]});for(let e in ot)b(t[e])||Object.defineProperties(t,{[e]:{get:()=>n(e)}});return t}function ct(n){let r=[],i=[],s=n=>F((u=>{const a=ot[n];C[a.name]===a?i.push(((t,e)=>{e.setAttribute(a.name,a(t,u[0]))})):r.push(w((n=>a.apply(null,[e(T,a.name)?t.wrap(n):t.unwrap(n)].concat(u))),n));const o=ft({},s);return o.run=t=>{const e=new d(!0);i.forEach((n=>{n(t,e)}));for(const n of r)try{if(e.extend(n(t)),!e.pass)break}catch(t){e.setFailed(!0);break}return e},o.test=e=>o.run(t.wrap(e).setFailFast(!0)).pass,o}),n);return s(n)}function ht(t,{rule:e,value:n}){return n={message:`[n4s]:${e.name} invalid ${typeof n} value`},r(t)||t&&r(t.pass)||((t,e=Error)=>{throw new e(`[n4s]: ${t}`)})(e.name+"wrong return value"),r(t)?(n.pass=t,n):(n.pass=t.pass,t.message&&(t=P(t.message),n.message=`[n4s]:${e.name} ${t}`),n)}function dt(n,r,i=[]){let s=e(T,n.name),u=s?t.wrap(r).setFailFast(!0):t.unwrap(r);if(i=n.apply(null,[u].concat(i)),s||(i=ht(i,{rule:n,value:r})),!i.pass)throw Error(i.message)}let pt=t=>{const e=ft({},(n=>F((r=>(dt(ot[n],t,r),e)))));return e},bt=ft(pt,ct);var mt,Nt;Nt=pt,(mt=bt).extend=t=>(Object.assign(ot,t),b(lt.Proxy)||ft(Nt,ct),mt),bt.template=F((e=>{let n=t=>{dt(N.bind(null,e),t);const n=ft({},(e=>F((r=>(dt(ot[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}));export default bt;
package/esm/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"module"}
package/jest.config.js DELETED
@@ -1,3 +0,0 @@
1
- const baseConfig = require('../../config/jest/jest.config');
2
-
3
- module.exports = baseConfig();