New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 1.0.0-1 to 1.0.0

8

dist/build.full.js

@@ -376,10 +376,8 @@ (function (global, factory) {

// eslint-disable-next-line new-cap
serializr.createModelSchema(model, serializeSchema, function (_ref2) {
var json = _ref2.json;
return new model(json);
});
// eslint-disable-next-line new-cap
var instance = new model(json);
attachInterceptors(instance);
return instance;
});
properties.forEach(function (_ref3, name) {

@@ -386,0 +384,0 @@ var type = _ref3.type,

@@ -373,10 +373,8 @@ import { SKIP, createModelSchema, custom, deserialize, getDefaultModelSchema, identifier, list, object, primitive, serialize, update } from 'serializr';

// eslint-disable-next-line new-cap
createModelSchema(model, serializeSchema, function (_ref2) {
var json = _ref2.json;
return new model(json);
});
// eslint-disable-next-line new-cap
var instance = new model(json);
attachInterceptors(instance);
return instance;
});
properties.forEach(function (_ref3, name) {

@@ -383,0 +381,0 @@ var type = _ref3.type,

@@ -174,8 +174,5 @@ import {

createModelSchema(model, serializeSchema, ({ json }) => {
// eslint-disable-next-line new-cap
const instance = new model(json);
attachInterceptors(instance);
return instance;
});
// eslint-disable-next-line new-cap
createModelSchema(model, serializeSchema, ({ json }) => new model(json));
properties.forEach(({ type, options }, name) => {

@@ -182,0 +179,0 @@ if (Associations[type] || options.model) {

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

@@ -25,3 +25,3 @@ "main": "dist/build.full.js",

"peerDependencies": {
"mobx": "^3.0",
"mobx": "^3.0 || ^4.0",
"serializr": "^1.1"

@@ -28,0 +28,0 @@ },

@@ -36,9 +36,8 @@ import { findModel } from '../lib/model-lookup';

fit('handles null/undefined hasMany values', () => {
it('handles null/undefined hasMany values', () => {
const ship = Container.deserialize({ boxes: [{ id: 1 }, null, undefined] });
expect(ship.boxes).toHaveLength(3);
console.log(ship.boxes[1])
//ship.boxes.forEach(b => expect(b).toBeInstanceOf(Box));
// expect(ship.boxes[0].id).toEqual(1);
// expect(ship.boxes[1].id).toBeUndefined();
ship.boxes.forEach(b => expect(b).toBeInstanceOf(Box));
expect(ship.boxes[0].id).toEqual(1);
expect(ship.boxes[1].id).toBeUndefined();
});

@@ -45,0 +44,0 @@

import { autorun } from 'mobx';
import { Box, Container, Ship, Registration, Radio, Dimension } from './test-models';
import { Box, Container, Ship, Registration, Radio, Dimension, NonIdentified } from './test-models';
import { isSerializable } from '../lib/serializable';

@@ -221,2 +221,14 @@

});
it('can decroate models without an identifiedBy', () => {
const model = new NonIdentified();
const modifiedSpy = jest.fn();
autorun(() => modifiedSpy(model.name));
expect(modifiedSpy).toHaveBeenCalledTimes(1);
model.name = 'set';
expect(modifiedSpy).toHaveBeenCalledTimes(2);
model.box = { width: 12, height: 12 };
expect(model.box).toBeInstanceOf(Box);
expect(model.box.volume).toEqual(144);
});
});

@@ -141,1 +141,9 @@ import { observable, computed } from 'mobx';

}
export class NonIdentified {
@identifier id;
@field name;
@belongsTo({ model: Box }) box;
}

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