Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jaysalvat/smart-model

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jaysalvat/smart-model - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

2

build/smart-model.esm.js
/**!
* SmartModel
* https://github.com/jaysalvat/smart-model
* @version 0.6.0 built 2021-02-26 08:03:42
* @version 0.6.1 built 2021-02-26 08:19:29
* @license ISC

@@ -6,0 +6,0 @@ * @author Jay Salvat http://jaysalvat.com

@@ -1,2 +0,2 @@

/*! SmartModel v0.6.0 */
/*! SmartModel v0.6.1 */
function e(e){return Array.isArray(e)}function t(e){return void 0===e}function r(e){return"function"==typeof e}function n(e){return e&&e.toString().startsWith("class")}function s(e){return e&&(e.prototype instanceof l||e instanceof l)}function o(e){return e&&"[object Object]"===e.toString()}function c(e,t=function(){}){return Object.keys(e).map((r=>t(r,e[r])))}function i(e){return[].concat([],e)}function u(e,t){return t=Object.assign({},e,t),c(e,(r=>{o(e[r])&&o(t[r])&&(t[r]=Object.assign({},e[r],u(e[r],t[r])))})),t}class p extends Error{constructor(e){super(e.message),Object.assign(this,e)}}function a(t,r,u,p,a){const f=[];return a.strict&&!c(t||{}).length&&f.push({message:`Property "${r}" can't be set in strict mode`,code:"strict"}),t.required&&a.empty(u)?(f.push({message:`Property "${r}" is "required"`,code:"required"}),f):t.readonly&&!p?(f.push({message:`Property "${r}" is "readonly"`,code:"readonly"}),f):(void 0===u||(!t.type||!t.required&&a.empty(u)||s(t.type)&&o(u)||i(t.type).some((t=>function(t,r){const s=r&&r.toString().match(/^\s*function (\w+)/),o=(s?s[1]:"object").toLowerCase();if("date"===o&&t instanceof r)return!0;if("array"===o&&e(t))return!0;if("object"===o){if(n(r)&&t instanceof r)return!0;if(!n(r)&&typeof t===o)return!0}else if(typeof t===o)return!0;return!1}(u,t)))||f.push({message:`Property "${r}" has an invalid type "${typeof u}"`,code:"type"}),t.rule&&c(t.rule,((e,t)=>{t(u)&&f.push({message:`Property "${r}" triggers the "${e}" rule error`,code:"rule:"+e})}))),f)}function f(e={},t,r){if(e.type){const n=!!s(e.type)&&e.type,c=!!o(e.type)&&e.type;if(n||c){const s=n||l.create(t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").match(/[a-z1-9]+/gi).map((e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())).join(""),c,r);return e.type=s,s}}return!1}p.throw=function(e,t,r,n,s){const c=t.split(":")[0];if(s=s&&s.constructor.name,!0===e.exceptions||o(e.exceptions)&&e.exceptions[c])throw new p({message:`[${s}] ${r}`,source:s,property:n,code:t})};class l extends class{constructor(n,o){return new Proxy(this,{set(i,u,l){const y=n[u]||{},$=i[u],h=t($),d=!(h||(g=l,m=$,JSON.stringify(g)===JSON.stringify(m)));var g,m;const b=f(y,u,o);function w(e,r){const s=Reflect.apply(e,i,r||[u,l,$,n]);return t(s)?l:s}var S;l=w(i.$onBeforeSet),d&&(l=w(i.$onBeforeUpdate)),r(y.transform)&&(l=w(y.transform,[l,n])),e(S=y.type)&&1===S.length&&s(S[0])&&!t(l)&&(l=y.type[0].$hydrate(l),y.type=Array);const j=a(y,u,l,h,o);if(j.length){if(!o.exceptions)return!0;p.throw(o,j[0].code,j[0].message,u,i)}return o.strict&&!c(y).length||(b&&!t(l)&&(l=new b(l)),i[u]=l,w(i.$onSet),d&&(w(i.$onUpdate),i.$applySubscribers(u,l))),!0},get(e,o){const i=n[o];let u=e[o];if(["$get"].includes(o))return function(){return function(e){return c(e=Object.assign({},e),(t=>{s(e[t])&&(e[t]=e[t].$get())})),e}(e)};if(!i)return e[o];function p(r,s){const c=Reflect.apply(r,e,s||[o,u,n]);return t(c)?u:c}return u=p(e.$onBeforeGet),r(i)&&(u=p(i,[e,n])),r(i.format)&&(u=p(i.format,[u,n])),u=p(e.$onGet),u},deleteProperty(e,t){const r=e[t];function s(s,o){return Reflect.apply(s,e,o||[t,r,n])}return(n[t]||{}).required&&p.throw(o,"required",`Property "${t}" is "required"`,t,e),!1===s(e.$onBeforeDelete)||(Reflect.deleteProperty(e,t),s(e.$onDelete),s(e.$onUpdate),e.$applySubscribers(t,r)),!0}})}}{constructor(e={},t={},r){super(e,r),this.$post(t)}$patch(e){c(e,(t=>{this[t]=e[t]}))}$post(e){const r=this.$schema();c(r,((r,n)=>{t(e[r])&&(this[r]=t(n.default)?void 0:n.default)})),c(this,((e,n)=>{t(r[e]&&t(n))&&this.$delete(e)})),this.$patch(e)}$put(e){return this.$post(e)}$delete(e){i(e).forEach((e=>{Reflect.deleteProperty(this,e)}))}$subscribe(e){return this.$subscribers().push(e),()=>{this.$subscribers(e)}}}l.settings={empty:e=>""===e||null===e||t(e),strict:!1,exceptions:{readonly:!1,required:!0,rule:!0,strict:!1,type:!0},methods:{$onBeforeGet:()=>{},$onBeforeSet:()=>{},$onBeforeUpdate:()=>{},$onDelete:()=>{},$onGet:()=>{},$onBeforeDelete:()=>{},$onSet:()=>{},$onUpdate:()=>{}}},l.create=function(t,r,n){let s=[];n=u(l.settings,n);const o={[t]:class extends l{constructor(e){super(r,e,n)}$schema(){return r}$subscribers(e){return e&&(s=s.filter((t=>t!==e))),s}$applySubscribers(e,t){c(s,((r,n)=>{Reflect.apply(n,this,[e,t,this])}))}}}[t];return o.$check=function(e={},t){const s={};return c(r,((r,o)=>{let c;const u=e[r],p=f(o,r,n);p&&(c=p.$check(u,t));let l=a(o,r,u,!1,n);c?s[r]=c:l.length&&(t&&(l=l.filter((e=>!i(t).includes(e.code)))),l.length&&(s[r]=l))})),!!c(s).length&&s},o.$hydrate=function(t){return e(t)?t.map((e=>new o(e))):new o(t)},Object.assign(o.prototype,n.methods),o};export default l;
/**!
* SmartModel
* https://github.com/jaysalvat/smart-model
* @version 0.6.0 built 2021-02-26 08:03:42
* @version 0.6.1 built 2021-02-26 08:19:29
* @license ISC

@@ -6,0 +6,0 @@ * @author Jay Salvat http://jaysalvat.com

@@ -1,2 +0,2 @@

/*! SmartModel v0.6.0 */
/*! SmartModel v0.6.1 */
var SmartModel=function(){"use strict";function e(e){return Array.isArray(e)}function t(e){return void 0===e}function r(e){return"function"==typeof e}function n(e){return e&&e.toString().startsWith("class")}function s(e){return e&&(e.prototype instanceof l||e instanceof l)}function o(e){return e&&"[object Object]"===e.toString()}function c(e,t=function(){}){return Object.keys(e).map((r=>t(r,e[r])))}function i(e){return[].concat([],e)}function u(e,t){return t=Object.assign({},e,t),c(e,(r=>{o(e[r])&&o(t[r])&&(t[r]=Object.assign({},e[r],u(e[r],t[r])))})),t}class p extends Error{constructor(e){super(e.message),Object.assign(this,e)}}function a(t,r,u,p,a){const f=[];return a.strict&&!c(t||{}).length&&f.push({message:`Property "${r}" can't be set in strict mode`,code:"strict"}),t.required&&a.empty(u)?(f.push({message:`Property "${r}" is "required"`,code:"required"}),f):t.readonly&&!p?(f.push({message:`Property "${r}" is "readonly"`,code:"readonly"}),f):(void 0===u||(!t.type||!t.required&&a.empty(u)||s(t.type)&&o(u)||i(t.type).some((t=>function(t,r){const s=r&&r.toString().match(/^\s*function (\w+)/),o=(s?s[1]:"object").toLowerCase();if("date"===o&&t instanceof r)return!0;if("array"===o&&e(t))return!0;if("object"===o){if(n(r)&&t instanceof r)return!0;if(!n(r)&&typeof t===o)return!0}else if(typeof t===o)return!0;return!1}(u,t)))||f.push({message:`Property "${r}" has an invalid type "${typeof u}"`,code:"type"}),t.rule&&c(t.rule,((e,t)=>{t(u)&&f.push({message:`Property "${r}" triggers the "${e}" rule error`,code:"rule:"+e})}))),f)}function f(e={},t,r){if(e.type){const n=!!s(e.type)&&e.type,c=!!o(e.type)&&e.type;if(n||c){const s=n||l.create(t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").match(/[a-z1-9]+/gi).map((e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())).join(""),c,r);return e.type=s,s}}return!1}p.throw=function(e,t,r,n,s){const c=t.split(":")[0];if(s=s&&s.constructor.name,!0===e.exceptions||o(e.exceptions)&&e.exceptions[c])throw new p({message:`[${s}] ${r}`,source:s,property:n,code:t})};class l extends class{constructor(n,o){return new Proxy(this,{set(i,u,l){const y=n[u]||{},$=i[u],h=t($),d=!(h||(g=l,m=$,JSON.stringify(g)===JSON.stringify(m)));var g,m;const b=f(y,u,o);function S(e,r){const s=Reflect.apply(e,i,r||[u,l,$,n]);return t(s)?l:s}var w;l=S(i.$onBeforeSet),d&&(l=S(i.$onBeforeUpdate)),r(y.transform)&&(l=S(y.transform,[l,n])),e(w=y.type)&&1===w.length&&s(w[0])&&!t(l)&&(l=y.type[0].$hydrate(l),y.type=Array);const j=a(y,u,l,h,o);if(j.length){if(!o.exceptions)return!0;p.throw(o,j[0].code,j[0].message,u,i)}return o.strict&&!c(y).length||(b&&!t(l)&&(l=new b(l)),i[u]=l,S(i.$onSet),d&&(S(i.$onUpdate),i.$applySubscribers(u,l))),!0},get(e,o){const i=n[o];let u=e[o];if(["$get"].includes(o))return function(){return function(e){return c(e=Object.assign({},e),(t=>{s(e[t])&&(e[t]=e[t].$get())})),e}(e)};if(!i)return e[o];function p(r,s){const c=Reflect.apply(r,e,s||[o,u,n]);return t(c)?u:c}return u=p(e.$onBeforeGet),r(i)&&(u=p(i,[e,n])),r(i.format)&&(u=p(i.format,[u,n])),u=p(e.$onGet),u},deleteProperty(e,t){const r=e[t];function s(s,o){return Reflect.apply(s,e,o||[t,r,n])}return(n[t]||{}).required&&p.throw(o,"required",`Property "${t}" is "required"`,t,e),!1===s(e.$onBeforeDelete)||(Reflect.deleteProperty(e,t),s(e.$onDelete),s(e.$onUpdate),e.$applySubscribers(t,r)),!0}})}}{constructor(e={},t={},r){super(e,r),this.$post(t)}$patch(e){c(e,(t=>{this[t]=e[t]}))}$post(e){const r=this.$schema();c(r,((r,n)=>{t(e[r])&&(this[r]=t(n.default)?void 0:n.default)})),c(this,((e,n)=>{t(r[e]&&t(n))&&this.$delete(e)})),this.$patch(e)}$put(e){return this.$post(e)}$delete(e){i(e).forEach((e=>{Reflect.deleteProperty(this,e)}))}$subscribe(e){return this.$subscribers().push(e),()=>{this.$subscribers(e)}}}return l.settings={empty:e=>""===e||null===e||t(e),strict:!1,exceptions:{readonly:!1,required:!0,rule:!0,strict:!1,type:!0},methods:{$onBeforeGet:()=>{},$onBeforeSet:()=>{},$onBeforeUpdate:()=>{},$onDelete:()=>{},$onGet:()=>{},$onBeforeDelete:()=>{},$onSet:()=>{},$onUpdate:()=>{}}},l.create=function(t,r,n){let s=[];n=u(l.settings,n);const o={[t]:class extends l{constructor(e){super(r,e,n)}$schema(){return r}$subscribers(e){return e&&(s=s.filter((t=>t!==e))),s}$applySubscribers(e,t){c(s,((r,n)=>{Reflect.apply(n,this,[e,t,this])}))}}}[t];return o.$check=function(e={},t){const s={};return c(r,((r,o)=>{let c;const u=e[r],p=f(o,r,n);p&&(c=p.$check(u,t));let l=a(o,r,u,!1,n);c?s[r]=c:l.length&&(t&&(l=l.filter((e=>!i(t).includes(e.code)))),l.length&&(s[r]=l))})),!!c(s).length&&s},o.$hydrate=function(t){return e(t)?t.map((e=>new o(e))):new o(t)},Object.assign(o.prototype,n.methods),o},l}();
/**!
* SmartModel
* https://github.com/jaysalvat/smart-model
* @version 0.6.0 built 2021-02-26 08:03:42
* @version 0.6.1 built 2021-02-26 08:19:29
* @license ISC

@@ -6,0 +6,0 @@ * @author Jay Salvat http://jaysalvat.com

@@ -1,2 +0,2 @@

/*! SmartModel v0.6.0 */
/*! SmartModel v0.6.1 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SmartModel=t()}(this,(function(){"use strict";function e(e){return Array.isArray(e)}function t(e){return void 0===e}function r(e){return"function"==typeof e}function n(e){return e&&e.toString().startsWith("class")}function o(e){return e&&(e.prototype instanceof l||e instanceof l)}function s(e){return e&&"[object Object]"===e.toString()}function i(e,t=function(){}){return Object.keys(e).map((r=>t(r,e[r])))}function c(e){return[].concat([],e)}function u(e,t){return t=Object.assign({},e,t),i(e,(r=>{s(e[r])&&s(t[r])&&(t[r]=Object.assign({},e[r],u(e[r],t[r])))})),t}class p extends Error{constructor(e){super(e.message),Object.assign(this,e)}}function a(t,r,u,p,a){const f=[];return a.strict&&!i(t||{}).length&&f.push({message:`Property "${r}" can't be set in strict mode`,code:"strict"}),t.required&&a.empty(u)?(f.push({message:`Property "${r}" is "required"`,code:"required"}),f):t.readonly&&!p?(f.push({message:`Property "${r}" is "readonly"`,code:"readonly"}),f):(void 0===u||(!t.type||!t.required&&a.empty(u)||o(t.type)&&s(u)||c(t.type).some((t=>function(t,r){const o=r&&r.toString().match(/^\s*function (\w+)/),s=(o?o[1]:"object").toLowerCase();if("date"===s&&t instanceof r)return!0;if("array"===s&&e(t))return!0;if("object"===s){if(n(r)&&t instanceof r)return!0;if(!n(r)&&typeof t===s)return!0}else if(typeof t===s)return!0;return!1}(u,t)))||f.push({message:`Property "${r}" has an invalid type "${typeof u}"`,code:"type"}),t.rule&&i(t.rule,((e,t)=>{t(u)&&f.push({message:`Property "${r}" triggers the "${e}" rule error`,code:"rule:"+e})}))),f)}function f(e={},t,r){if(e.type){const n=!!o(e.type)&&e.type,i=!!s(e.type)&&e.type;if(n||i){const o=n||l.create(t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").match(/[a-z1-9]+/gi).map((e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())).join(""),i,r);return e.type=o,o}}return!1}p.throw=function(e,t,r,n,o){const i=t.split(":")[0];if(o=o&&o.constructor.name,!0===e.exceptions||s(e.exceptions)&&e.exceptions[i])throw new p({message:`[${o}] ${r}`,source:o,property:n,code:t})};class l extends class{constructor(n,s){return new Proxy(this,{set(c,u,l){const y=n[u]||{},d=c[u],h=t(d),$=!(h||(g=l,m=d,JSON.stringify(g)===JSON.stringify(m)));var g,m;const b=f(y,u,s);function S(e,r){const o=Reflect.apply(e,c,r||[u,l,d,n]);return t(o)?l:o}var j;l=S(c.$onBeforeSet),$&&(l=S(c.$onBeforeUpdate)),r(y.transform)&&(l=S(y.transform,[l,n])),e(j=y.type)&&1===j.length&&o(j[0])&&!t(l)&&(l=y.type[0].$hydrate(l),y.type=Array);const w=a(y,u,l,h,s);if(w.length){if(!s.exceptions)return!0;p.throw(s,w[0].code,w[0].message,u,c)}return s.strict&&!i(y).length||(b&&!t(l)&&(l=new b(l)),c[u]=l,S(c.$onSet),$&&(S(c.$onUpdate),c.$applySubscribers(u,l))),!0},get(e,s){const c=n[s];let u=e[s];if(["$get"].includes(s))return function(){return function(e){return i(e=Object.assign({},e),(t=>{o(e[t])&&(e[t]=e[t].$get())})),e}(e)};if(!c)return e[s];function p(r,o){const i=Reflect.apply(r,e,o||[s,u,n]);return t(i)?u:i}return u=p(e.$onBeforeGet),r(c)&&(u=p(c,[e,n])),r(c.format)&&(u=p(c.format,[u,n])),u=p(e.$onGet),u},deleteProperty(e,t){const r=e[t];function o(o,s){return Reflect.apply(o,e,s||[t,r,n])}return(n[t]||{}).required&&p.throw(s,"required",`Property "${t}" is "required"`,t,e),!1===o(e.$onBeforeDelete)||(Reflect.deleteProperty(e,t),o(e.$onDelete),o(e.$onUpdate),e.$applySubscribers(t,r)),!0}})}}{constructor(e={},t={},r){super(e,r),this.$post(t)}$patch(e){i(e,(t=>{this[t]=e[t]}))}$post(e){const r=this.$schema();i(r,((r,n)=>{t(e[r])&&(this[r]=t(n.default)?void 0:n.default)})),i(this,((e,n)=>{t(r[e]&&t(n))&&this.$delete(e)})),this.$patch(e)}$put(e){return this.$post(e)}$delete(e){c(e).forEach((e=>{Reflect.deleteProperty(this,e)}))}$subscribe(e){return this.$subscribers().push(e),()=>{this.$subscribers(e)}}}return l.settings={empty:e=>""===e||null===e||t(e),strict:!1,exceptions:{readonly:!1,required:!0,rule:!0,strict:!1,type:!0},methods:{$onBeforeGet:()=>{},$onBeforeSet:()=>{},$onBeforeUpdate:()=>{},$onDelete:()=>{},$onGet:()=>{},$onBeforeDelete:()=>{},$onSet:()=>{},$onUpdate:()=>{}}},l.create=function(t,r,n){let o=[];n=u(l.settings,n);const s={[t]:class extends l{constructor(e){super(r,e,n)}$schema(){return r}$subscribers(e){return e&&(o=o.filter((t=>t!==e))),o}$applySubscribers(e,t){i(o,((r,n)=>{Reflect.apply(n,this,[e,t,this])}))}}}[t];return s.$check=function(e={},t){const o={};return i(r,((r,s)=>{let i;const u=e[r],p=f(s,r,n);p&&(i=p.$check(u,t));let l=a(s,r,u,!1,n);i?o[r]=i:l.length&&(t&&(l=l.filter((e=>!c(t).includes(e.code)))),l.length&&(o[r]=l))})),!!i(o).length&&o},s.$hydrate=function(t){return e(t)?t.map((e=>new s(e))):new s(t)},Object.assign(s.prototype,n.methods),s},l}));
{
"name": "@jaysalvat/smart-model",
"version": "0.6.0",
"version": "0.6.1",
"description": "SmartModel is a fun experiment over Javascript Proxy. It tends to bring useful tools and best practices to data objects.",

@@ -5,0 +5,0 @@ "main": "./build/smart-model.cjs.min.cjs",

@@ -14,5 +14,7 @@ ```

SmartModel is a fun experiment over Javascript Proxy. It tends to bring useful tools and best practices to data objects.
SmartModel is a fun experiment over ES6 Javascript Proxy.
- [x] Small footprint, <2Kb gzipped
It tends to bring useful tools and best practices to Javascript data objects.
- [x] Small footprint <2Kb gzipped
- [x] Value transformation

@@ -27,10 +29,12 @@ - [x] Value formatting

- [x] Nested models
- [x] Live cycle callbacks
- [x] Hooks
- [x] Subscriptions
**Important note** SmartModel uses javascript proxy. It unfortunately makes it incompatible with VueJs reactive properties.
### Compatibility
Works on modern browsers.
Should works on modern browsers.
[Check if tests pass](https://unpkg.com/@jaysalvat/smart-model@latest/test/index.html) on your browser.
SmartModel uses javascript proxy. It unfortunately makes it **incompatible with VueJs** reactive properties.
## Install

@@ -70,58 +74,56 @@

const Post = SmartModel.create('Post', {
title: {
required: true,
type: String,
},
body: {
required: true,
type: String,
rule: {
'tooShort': (value) => value.length < 100,
'tooLong': (value) => value.length > 1000,
}
},
createdAt: {
type: Date,
default: new Date(),
transform: (value) => new Date(value),
format: (value) => value.toLocaleString()
},
updatedAt: {
type: Date,
default: new Date(),
transform: (value) => new Date(value),
format: (value) => value.toLocaleString()
},
// Nested model
author: {
required: true,
type: {
firstname: {
required: true,
type: String
},
lastname: {
required: true,
type: String,
transform: (value) => value.toUpperCase()
},
fullname: (author) => author.firstname + ' ' + author.lastname
}
},
// Computed properties
bodyLength: (post) => post.body.length,
readingTime: (post) => readingTime(post.body)
},
// Settings
{
strict: true,
exceptions: true,
// Events
methods: {
$onUpdate() {
this.updatedAt = new Date()
}
title: {
required: true,
type: String
},
body: {
required: true,
type: String,
rule: {
tooShort: (value) => value.length < 100,
tooLong: (value) => value.length > 1000
}
},
createdAt: {
type: Date,
default: new Date(),
transform: (value) => new Date(value),
format: (value) => value.toLocaleString()
},
updatedAt: {
type: Date,
default: new Date(),
transform: (value) => new Date(value),
format: (value) => value.toLocaleString()
},
// Nested model
author: {
required: true,
type: {
firstname: {
required: true,
type: String
},
lastname: {
required: true,
type: String,
transform: (value) => value.toUpperCase()
},
fullname: (author) => author.firstname + ' ' + author.lastname
}
},
// Computed properties
bodyLength: (post) => post.body.length,
readingTime: (post) => readingTime(post.body)
},
// Settings
{
strict: true,
exceptions: true,
methods: {
$onUpdate() {
this.updatedAt = new Date()
}
}
)
})
```

@@ -140,7 +142,5 @@

```javascript
console.log(post)
Try a `console.log(post)`
```
```javascript
Post {

@@ -158,2 +158,4 @@ createdAt: 2020-01-31T09:50:00.000Z,

Let's try to log some other magic properties
```javascript

@@ -165,3 +167,5 @@ console.log(post.author.fullname)

```ssh
They return
```
James HETFIELD

@@ -465,3 +469,3 @@ 01/31/2020, 9:50:00 AM

#### $subscribe()
#### $subscribe

@@ -490,4 +494,3 @@ Adds an update listener. It will be called any time a value is updated.

Static method.
Returns an array of potential errors if a payload where passed to the model.
Returns an array of potential errors if a payload was passed to the model.

@@ -500,3 +503,2 @@ ```javascript

Static method.
Turns an object or an array of objects into models.

@@ -516,3 +518,3 @@ Useful with API responses.

.then(response => Post.$hydrate(response))
.then(response) => { /* Hydrated Post model */ }
.then(response) => { /* Hydrated Post model */ }
```

@@ -519,0 +521,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc