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

mobx-decorated-models

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-decorated-models - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

script/cibuild

232

dist/build.full.js

@@ -64,2 +64,116 @@ (function (global, factory) {

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
function setupModel(_ref) {
var attrs = _ref.attrs,
Klass = _ref.modelClass,
array = _ref.array,
defaultAttributes = _ref.defaultAttributes,
inverseOf = _ref.inverseOf,
parentModel = _ref.parentModel,
parentModelProp = _ref.parentModelProp;
if (!attrs) {
return attrs;
}
var isObject = (typeof attrs === 'undefined' ? 'undefined' : _typeof(attrs)) === 'object';
var canWrite = Object.isExtensible(attrs);
if (isObject && canWrite) {
if (defaultAttributes) {
if (typeof defaultAttributes === 'function') {
defaultAttributes = defaultAttributes.call(parentModel, array, parentModel);
}
Object.keys(defaultAttributes).forEach(function (key) {
if (!attrs[key]) {
attrs[key] = defaultAttributes[key];
}
});
}
if (inverseOf) {
attrs[inverseOf] = parentModel;
if (parentModelProp) {
attrs[inverseOf + '_association_name'] = parentModelProp;
}
}
}
var model = Klass && typeof Klass === 'function' && !(attrs instanceof Klass) ? new Klass(attrs) : attrs;
if (inverseOf) {
markNonserializable(model, inverseOf);
}
return model;
}
var PendingLookups = [];

@@ -149,3 +263,3 @@

}
cb(err, value);
cb(err, model);
};

@@ -155,3 +269,3 @@ if (value instanceof modelKlass) {

} else {
defaultSerializer.deserializer(value, setter);
setter(null, setupModel(Object.assign({}, options, { attrs: value, modelClass: modelKlass })));
}

@@ -240,116 +354,2 @@ },

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
function setupModel(_ref) {
var attrs = _ref.attrs,
Klass = _ref.modelClass,
array = _ref.array,
defaultAttributes = _ref.defaultAttributes,
inverseOf = _ref.inverseOf,
parentModel = _ref.parentModel,
parentModelProp = _ref.parentModelProp;
if (!attrs) {
return attrs;
}
var isObject = (typeof attrs === 'undefined' ? 'undefined' : _typeof(attrs)) === 'object';
var canWrite = Object.isExtensible(attrs);
if (isObject && canWrite) {
if (defaultAttributes) {
if (typeof defaultAttributes === 'function') {
defaultAttributes = defaultAttributes.call(parentModel, array, parentModel);
}
Object.keys(defaultAttributes).forEach(function (key) {
if (!attrs[key]) {
attrs[key] = defaultAttributes[key];
}
});
}
if (inverseOf) {
attrs[inverseOf] = parentModel;
if (parentModelProp) {
attrs[inverseOf + '_association_name'] = parentModelProp;
}
}
}
var model = Klass && typeof Klass === 'function' && !(attrs instanceof Klass) ? new Klass(attrs) : attrs;
if (inverseOf) {
markNonserializable(model, inverseOf);
}
return model;
}
function onCollectionChangeInterceptor(_ref, parentModel, parentModelProp) {

@@ -356,0 +356,0 @@ var modelClass = _ref.modelClass,

@@ -61,2 +61,116 @@ import { SKIP, createModelSchema, custom, deserialize, getDefaultModelSchema, identifier, list, object, primitive, serialize, update } from 'serializr';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
function setupModel(_ref) {
var attrs = _ref.attrs,
Klass = _ref.modelClass,
array = _ref.array,
defaultAttributes = _ref.defaultAttributes,
inverseOf = _ref.inverseOf,
parentModel = _ref.parentModel,
parentModelProp = _ref.parentModelProp;
if (!attrs) {
return attrs;
}
var isObject = (typeof attrs === 'undefined' ? 'undefined' : _typeof(attrs)) === 'object';
var canWrite = Object.isExtensible(attrs);
if (isObject && canWrite) {
if (defaultAttributes) {
if (typeof defaultAttributes === 'function') {
defaultAttributes = defaultAttributes.call(parentModel, array, parentModel);
}
Object.keys(defaultAttributes).forEach(function (key) {
if (!attrs[key]) {
attrs[key] = defaultAttributes[key];
}
});
}
if (inverseOf) {
attrs[inverseOf] = parentModel;
if (parentModelProp) {
attrs[inverseOf + '_association_name'] = parentModelProp;
}
}
}
var model = Klass && typeof Klass === 'function' && !(attrs instanceof Klass) ? new Klass(attrs) : attrs;
if (inverseOf) {
markNonserializable(model, inverseOf);
}
return model;
}
var PendingLookups = [];

@@ -146,3 +260,3 @@

}
cb(err, value);
cb(err, model);
};

@@ -152,3 +266,3 @@ if (value instanceof modelKlass) {

} else {
defaultSerializer.deserializer(value, setter);
setter(null, setupModel(Object.assign({}, options, { attrs: value, modelClass: modelKlass })));
}

@@ -237,116 +351,2 @@ },

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
function setupModel(_ref) {
var attrs = _ref.attrs,
Klass = _ref.modelClass,
array = _ref.array,
defaultAttributes = _ref.defaultAttributes,
inverseOf = _ref.inverseOf,
parentModel = _ref.parentModel,
parentModelProp = _ref.parentModelProp;
if (!attrs) {
return attrs;
}
var isObject = (typeof attrs === 'undefined' ? 'undefined' : _typeof(attrs)) === 'object';
var canWrite = Object.isExtensible(attrs);
if (isObject && canWrite) {
if (defaultAttributes) {
if (typeof defaultAttributes === 'function') {
defaultAttributes = defaultAttributes.call(parentModel, array, parentModel);
}
Object.keys(defaultAttributes).forEach(function (key) {
if (!attrs[key]) {
attrs[key] = defaultAttributes[key];
}
});
}
if (inverseOf) {
attrs[inverseOf] = parentModel;
if (parentModelProp) {
attrs[inverseOf + '_association_name'] = parentModelProp;
}
}
}
var model = Klass && typeof Klass === 'function' && !(attrs instanceof Klass) ? new Klass(attrs) : attrs;
if (inverseOf) {
markNonserializable(model, inverseOf);
}
return model;
}
function onCollectionChangeInterceptor(_ref, parentModel, parentModelProp) {

@@ -353,0 +353,0 @@ var modelClass = _ref.modelClass,

@@ -11,2 +11,3 @@ import {

import getModelSchema from './schema';
import setupModel from './setup-model';

@@ -90,3 +91,3 @@ const PendingLookups = [];

}
cb(err, value);
cb(err, model);
};

@@ -96,3 +97,5 @@ if (value instanceof modelKlass) {

} else {
defaultSerializer.deserializer(value, setter);
setter(null, setupModel(Object.assign(
{}, options, { attrs: value, modelClass: modelKlass },
)));
}

@@ -99,0 +102,0 @@ },

{
"name": "mobx-decorated-models",
"version": "0.6.4",
"version": "0.6.5",
"description": "Decorators to make using Mobx for model type structures easier",

@@ -12,5 +12,5 @@ "main": "dist/build.full.js",

"scripts": {
"test": "$(npm bin)/jest",
"build": "rollup -c",
"prepublish": "npm run build && npm test"
"test": "./script/test",
"build": "./script/cibuild",
"prepublish": "./script/prepublish"
},

@@ -25,3 +25,3 @@ "keywords": [

],
"dependencies": {
"peerDependencies": {
"mobx": "^3.0",

@@ -45,5 +45,7 @@ "serializr": "^1.1"

"jest-cli": "^20.0.4",
"mobx": "^3.0",
"rollup": "^0.43.0",
"rollup-plugin-babel": "^2.7.1"
"rollup-plugin-babel": "^2.7.1",
"serializr": "^1.1"
}
}

@@ -6,4 +6,4 @@ import babel from 'rollup-plugin-babel';

const external = Object.keys(pkg.dependencies);
export default {

@@ -14,3 +14,10 @@ entry: 'index.js',

],
external,
external: [
'serializr',
'mobx',
],
globals: {
serializr: 'serializr',
mobx: 'mobx',
},
targets: [

@@ -17,0 +24,0 @@ {

@@ -114,2 +114,14 @@ import { findModel } from '../lib/model-lookup';

it('only builds a single class for belongsTo', () => {
const box = new Box();
Ship.buildSpy = jest.fn();
box.update({
watercraft: {
name: 'test1234',
},
});
expect(box.watercraft).toBeInstanceOf(Ship);
expect(Ship.buildSpy).toHaveBeenCalledTimes(1);
});
it('hasMany', () => {

@@ -116,0 +128,0 @@ const container = new Container({ id: 1, name: 'C23', location: 'z1' });

@@ -66,2 +66,3 @@ import { autorun } from 'mobx';

});
expect(ship.box.vessel).toBe(ship);
expect(ship.box.vessel_association_name).toEqual('box');

@@ -68,0 +69,0 @@ });

@@ -34,2 +34,6 @@ import { observable, computed } from 'mobx';

@belongsTo({ inverseOf: 'vessel' }) box;
constructor(attrs) {
if (this.constructor.buildSpy) { this.constructor.buildSpy(attrs); }
}
}

@@ -36,0 +40,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