@jaysalvat/smart-model
Advanced tools
Comparing version 0.2.9 to 0.2.10
@@ -6,3 +6,3 @@ | ||
* https://github.com/jaysalvat/smart-model | ||
* @version 0.2.9 built 2021-02-19 21:35:08 | ||
* @version 0.2.10 built 2021-02-19 21:54:25 | ||
* @license ISC | ||
@@ -9,0 +9,0 @@ * @author Jay Salvat http://jaysalvat.com |
@@ -1,2 +0,2 @@ | ||
/*! SmartModel v0.2.9 */ | ||
/*! SmartModel v0.2.10 */ | ||
function e(e){return void 0===e}function t(t){return""===t||null===t||e(t)}function r(e){return"function"==typeof e}function n(e){return e?JSON.parse(JSON.stringify(e)):e}function o(e){return[].concat([],e)}function s(e,r,n){const s=[];return e.required&&t(n)?(s.push({message:`Invalid value 'required' on property '${r}'`,code:"required"}),s):(void 0===n||(!e.type||!e.required&&t(n)||o(e.type).some((e=>function(e,t){return typeof e==typeof t()||e instanceof t}(n,e)))||s.push({message:`Invalid type '${typeof n}' on property '${r}'`,code:"type"}),e.rule&&Object.keys(e.rule).forEach((t=>{(0,e.rule[t])(n)&&s.push({message:`Invalid value '${t}' on property '${r}'`,code:t})}))),s)}class c extends Error{constructor(e){super(e.message),Object.assign(this,e)}}class u extends class{constructor(e={},t={}){return new Proxy(this,{set(r,o,u){const i=n(r[o]),f=(a=u,p=i,!(JSON.stringify(a)===JSON.stringify(p)));var a,p;const l=e[o];function d(t,n){return Reflect.apply(t,r,n||[o,u,i,e])}if(!l)return t.strict||(r[o]=u),!0;if(d(r.onBeforeSet),f&&d(r.onBeforeUpdate),l.transform&&(u=d(l.transform,[u,e])),t.exceptions){const e=s(l,o,u);e.length&&e.forEach((e=>{throw new c({message:e.message,property:o,code:e.code})}))}return r[o]=u,d(r.onSet),f&&d(r.onUpdate),!0},get(t,n){const o=e[n];let s=t[n];if(!o)return t[n];function c(r,o){return Reflect.apply(r,t,o||[n,s,e])}return c(t.onBeforeGet),r(o)&&(s=c(o,[t,e])),r(o.format)&&(s=c(o.format,[s,e])),c(t.onGet),s},deleteProperty(t,r){const o=n(t[r]);function s(n,s){return Reflect.apply(n,t,s||[r,o,e])}if(e[r].required)throw new c({message:`Invalid delete on required propery ${r}`,property:r,code:"required"});return s(t.onBeforeDelete),Reflect.deleteProperty(t,r),s(t.onDelete),s(t.onUpdate),!0}})}}{constructor(t={},r={},n={}){super(t,n),Object.keys(t).forEach((n=>{e(r[n])&&(t[n].default?this[n]=t[n].default:this[n]=r[n])})),this.feed(r)}feed(e){Object.keys(e).forEach((t=>{this[t]=e[t]}))}onBeforeGet(){}onBeforeSet(){}onBeforeUpdate(){}onDelete(){}onGet(){}onBeforeDelete(){}onSet(){}onUpdate(){}}u.settings={strict:!1,exceptions:!0},u.create=function(e,t,r,n){r=Object.assign({},u.settings,r);const c={[e]:class extends u{constructor(e){super(t,e,r)}}}[e];return c.checkErrors=function(e,r){const n={};return Object.keys(t).forEach((c=>{let u=s(t[c],c,e[c]);u.length&&(r&&(u=u.filter((e=>!o(r).includes(e.code)))),u.length&&(n[c]=u))})),!!Object.keys(n).length&&n},c.hydrate=function(e){return t=e,Array.isArray(t)?e.map((e=>new c(e))):new c(e);var t},Object.assign(c.prototype,n),c};export default u; |
{ | ||
"name": "@jaysalvat/smart-model", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "Javascript object model", | ||
@@ -5,0 +5,0 @@ "main": "./build/smart-model.umd.js", |
@@ -36,3 +36,3 @@ import { terser } from 'rollup-plugin-terser' | ||
file: DIST + '/' + filename, | ||
name: format === 'umd' ? NAME : null, | ||
banner: !watched && (minify ? bannerLight : bannerFull), | ||
@@ -39,0 +39,0 @@ plugins: [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39847
21
1086