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.2.0 to 0.2.1

13

dist/build.full.js

@@ -67,6 +67,17 @@ (function (global, factory) {

function objectSerializer() {
return {
serializer: function serializer(obj) {
return obj.toJS();
},
deserializer: function deserializer(json, cb) {
cb(null, mobx.observable.map(json));
}
};
}
function getSerializer(options, defaultSerializer) {
var serializer = void 0;
if (options.type === 'object') {
serializer = serializr.map;
serializer = objectSerializer;
} else if (options.type === 'array') {

@@ -73,0 +84,0 @@ serializer = serializr.list;

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

import { createModelSchema, deserialize, getDefaultModelSchema, identifier, list, map, object, primitive, serialize, update } from 'serializr';
import { createModelSchema, deserialize, getDefaultModelSchema, identifier, list, object, primitive, serialize, update } from 'serializr';
import { action, observable } from 'mobx';

@@ -64,6 +64,17 @@

function objectSerializer() {
return {
serializer: function serializer(obj) {
return obj.toJS();
},
deserializer: function deserializer(json, cb) {
cb(null, observable.map(json));
}
};
}
function getSerializer(options, defaultSerializer) {
var serializer = void 0;
if (options.type === 'object') {
serializer = map;
serializer = objectSerializer;
} else if (options.type === 'array') {

@@ -70,0 +81,0 @@ serializer = list;

import {
serialize, deserialize, createModelSchema, primitive, list, object,
identifier, getDefaultModelSchema, update, map,
identifier, getDefaultModelSchema, update,
} from 'serializr';
import {
observable,
} from 'mobx';

@@ -21,6 +24,13 @@ import { registerModel, findModel } from './model-lookup';

function objectSerializer() {
return {
serializer(obj) { return obj.toJS(); },
deserializer(json, cb) { cb(null, observable.map(json)); },
};
}
function getSerializer(options, defaultSerializer) {
let serializer;
if (options.type === 'object') {
serializer = map;
serializer = objectSerializer;
} else if (options.type === 'array') {

@@ -27,0 +37,0 @@ serializer = list;

2

package.json
{
"name": "mobx-decorated-models",
"version": "0.2.0",
"version": "0.2.1",
"description": "Decorators to make using Mobx for model type structures easier",

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

@@ -31,2 +31,20 @@ import { Container, Box } from './test-models';

it('can serialize/deserialize nested objects', () => {
const box = new Box();
box.update({
metadata: {
one: 1,
two: ['one', 'three'],
four: { test: true },
},
});
expect(box.serialize().metadata).toEqual(
expect.objectContaining({
one: 1,
four: expect.objectContaining({ test: true }),
two: expect.arrayContaining(['one', 'three']),
}),
);
});
it('adds update method to prototype', () => {

@@ -33,0 +51,0 @@ const attrs = { id: 2, width: 3, depth: 12, height: 4, container: {

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