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

lom_atom

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lom_atom - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Change Log

<a name="1.1.1"></a>
## [1.1.1](https://github.com/zerkalica/lom_atom/compare/v1.1.0...v1.1.1) (2017-09-06)
<a name="1.1.0"></a>

@@ -7,0 +12,0 @@ # [1.1.0](https://github.com/zerkalica/lom_atom/compare/v1.0.14...v1.1.0) (2017-09-05)

98

dist/lom_atom.es.js

@@ -162,3 +162,3 @@ // eslint-disable-line

} else {
ptr[this.field] = undefined;
ptr[this.field] = null;
}

@@ -452,5 +452,20 @@ }

var NoSerializableException = function (_Error) {
inheritsLoose(NoSerializableException, _Error);
function NoSerializableException(host, field) {
var _this2;
_this2 = _Error.call(this, "" + (host.displayName || host.constructor.name) + (field ? "." + field : '') + " not a serializable") || this // $FlowFixMe new.target
;
_this2['__proto__'] = new.target.prototype;
return _this2;
}
return NoSerializableException;
}(Error);
var Context = function () {
function Context() {
var _this2 = this;
var _this3 = this;

@@ -464,6 +479,6 @@ this.last = null;

this.__run = function () {
if (_this2._scheduled) {
_this2._scheduled = false;
if (_this3._scheduled) {
_this3._scheduled = false;
_this2._run();
_this3._run();
}

@@ -502,4 +517,4 @@ };

// }
var k = key === undefined ? field : getKey(key);
var atom = host[k + '@'];
var k = key === undefined ? field + '@' : field + '.' + getKey(key) + '@';
var atom = host[k];

@@ -520,4 +535,6 @@ if (atom === undefined) {

if (_typeof(ptr) !== 'object') {
throw new Error((host.displayName || host.constructor.name) + "." + field + " need an object");
throw new NoSerializableException(host, field);
}
} else if (ptr[field] === null) {
ptr[field] = undefined;
}

@@ -532,3 +549,3 @@ }

;
host[k + '@'] = atom;
host[k] = atom;
}

@@ -539,6 +556,61 @@

Context.prototype.setHostState = function setHostState(host, state) {
host.__lom_state = state;
Context.prototype.getState = function getState(host) {
if (!host.__lom_state) {
throw new NoSerializableException(host);
}
return host.__lom_state;
};
Context.prototype.setState = function setState(host, state, init) {
if (init) {
host.__lom_state = state;
return;
}
var oldState = host.__lom_state;
if (oldState === undefined) {
throw new NoSerializableException(host);
}
var fields = Object.keys(state);
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var value = state[field];
if (host[field + '?'] !== undefined) {
if (_typeof(value) !== 'object' || value === null) {
throw new NoSerializableException(host, field);
}
var keys = Object.keys(value);
for (var j = 0; j < keys.length; j++) {
var key = keys[j];
var atom = host[field + '.' + key + '@'];
if (atom !== undefined) {
atom.set(value[key]);
} else {
if (!oldState[field]) {
oldState[field] = {};
}
oldState[field][key] = value[key];
}
}
} else {
var _atom = host[field + '@'];
if (_atom !== undefined) {
_atom.set(value);
} else {
oldState[field] = value;
}
}
}
};
Context.prototype.destroyHost = function destroyHost(atom) {

@@ -550,4 +622,4 @@ if (this._logger !== undefined) {

var host = atom.host;
var k = atom.key === undefined ? atom.field : getKey(atom.key);
host[k + '@'] = undefined;
var k = atom.key === undefined ? atom.field + '@' : atom.field + '.' + getKey(atom.key) + '@';
host[k] = undefined;

@@ -554,0 +626,0 @@ if (host._destroyProp !== undefined) {

@@ -166,3 +166,3 @@ 'use strict';

} else {
ptr[this.field] = undefined;
ptr[this.field] = null;
}

@@ -456,5 +456,20 @@ }

var NoSerializableException = function (_Error) {
inheritsLoose(NoSerializableException, _Error);
function NoSerializableException(host, field) {
var _this2;
_this2 = _Error.call(this, "" + (host.displayName || host.constructor.name) + (field ? "." + field : '') + " not a serializable") || this // $FlowFixMe new.target
;
_this2['__proto__'] = new.target.prototype;
return _this2;
}
return NoSerializableException;
}(Error);
var Context = function () {
function Context() {
var _this2 = this;
var _this3 = this;

@@ -468,6 +483,6 @@ this.last = null;

this.__run = function () {
if (_this2._scheduled) {
_this2._scheduled = false;
if (_this3._scheduled) {
_this3._scheduled = false;
_this2._run();
_this3._run();
}

@@ -506,4 +521,4 @@ };

// }
var k = key === undefined ? field : getKey(key);
var atom = host[k + '@'];
var k = key === undefined ? field + '@' : field + '.' + getKey(key) + '@';
var atom = host[k];

@@ -524,4 +539,6 @@ if (atom === undefined) {

if (_typeof(ptr) !== 'object') {
throw new Error((host.displayName || host.constructor.name) + "." + field + " need an object");
throw new NoSerializableException(host, field);
}
} else if (ptr[field] === null) {
ptr[field] = undefined;
}

@@ -536,3 +553,3 @@ }

;
host[k + '@'] = atom;
host[k] = atom;
}

@@ -543,6 +560,61 @@

Context.prototype.setHostState = function setHostState(host, state) {
host.__lom_state = state;
Context.prototype.getState = function getState(host) {
if (!host.__lom_state) {
throw new NoSerializableException(host);
}
return host.__lom_state;
};
Context.prototype.setState = function setState(host, state, init) {
if (init) {
host.__lom_state = state;
return;
}
var oldState = host.__lom_state;
if (oldState === undefined) {
throw new NoSerializableException(host);
}
var fields = Object.keys(state);
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var value = state[field];
if (host[field + '?'] !== undefined) {
if (_typeof(value) !== 'object' || value === null) {
throw new NoSerializableException(host, field);
}
var keys = Object.keys(value);
for (var j = 0; j < keys.length; j++) {
var key = keys[j];
var atom = host[field + '.' + key + '@'];
if (atom !== undefined) {
atom.set(value[key]);
} else {
if (!oldState[field]) {
oldState[field] = {};
}
oldState[field][key] = value[key];
}
}
} else {
var _atom = host[field + '@'];
if (_atom !== undefined) {
_atom.set(value);
} else {
oldState[field] = value;
}
}
}
};
Context.prototype.destroyHost = function destroyHost(atom) {

@@ -554,4 +626,4 @@ if (this._logger !== undefined) {

var host = atom.host;
var k = atom.key === undefined ? atom.field : getKey(atom.key);
host[k + '@'] = undefined;
var k = atom.key === undefined ? atom.field + '@' : atom.field + '.' + getKey(atom.key) + '@';
host[k] = undefined;

@@ -558,0 +630,0 @@ if (host._destroyProp !== undefined) {

@@ -168,3 +168,3 @@ (function (global, factory) {

} else {
ptr[this.field] = undefined;
ptr[this.field] = null;
}

@@ -458,5 +458,20 @@ }

var NoSerializableException = function (_Error) {
inheritsLoose(NoSerializableException, _Error);
function NoSerializableException(host, field) {
var _this2;
_this2 = _Error.call(this, "" + (host.displayName || host.constructor.name) + (field ? "." + field : '') + " not a serializable") || this // $FlowFixMe new.target
;
_this2['__proto__'] = new.target.prototype;
return _this2;
}
return NoSerializableException;
}(Error);
var Context = function () {
function Context() {
var _this2 = this;
var _this3 = this;

@@ -470,6 +485,6 @@ this.last = null;

this.__run = function () {
if (_this2._scheduled) {
_this2._scheduled = false;
if (_this3._scheduled) {
_this3._scheduled = false;
_this2._run();
_this3._run();
}

@@ -508,4 +523,4 @@ };

// }
var k = key === undefined ? field : getKey(key);
var atom = host[k + '@'];
var k = key === undefined ? field + '@' : field + '.' + getKey(key) + '@';
var atom = host[k];

@@ -526,4 +541,6 @@ if (atom === undefined) {

if (_typeof(ptr) !== 'object') {
throw new Error((host.displayName || host.constructor.name) + "." + field + " need an object");
throw new NoSerializableException(host, field);
}
} else if (ptr[field] === null) {
ptr[field] = undefined;
}

@@ -538,3 +555,3 @@ }

;
host[k + '@'] = atom;
host[k] = atom;
}

@@ -545,6 +562,61 @@

Context.prototype.setHostState = function setHostState(host, state) {
host.__lom_state = state;
Context.prototype.getState = function getState(host) {
if (!host.__lom_state) {
throw new NoSerializableException(host);
}
return host.__lom_state;
};
Context.prototype.setState = function setState(host, state, init) {
if (init) {
host.__lom_state = state;
return;
}
var oldState = host.__lom_state;
if (oldState === undefined) {
throw new NoSerializableException(host);
}
var fields = Object.keys(state);
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var value = state[field];
if (host[field + '?'] !== undefined) {
if (_typeof(value) !== 'object' || value === null) {
throw new NoSerializableException(host, field);
}
var keys = Object.keys(value);
for (var j = 0; j < keys.length; j++) {
var key = keys[j];
var atom = host[field + '.' + key + '@'];
if (atom !== undefined) {
atom.set(value[key]);
} else {
if (!oldState[field]) {
oldState[field] = {};
}
oldState[field][key] = value[key];
}
}
} else {
var _atom = host[field + '@'];
if (_atom !== undefined) {
_atom.set(value);
} else {
oldState[field] = value;
}
}
}
};
Context.prototype.destroyHost = function destroyHost(atom) {

@@ -556,4 +628,4 @@ if (this._logger !== undefined) {

var host = atom.host;
var k = atom.key === undefined ? atom.field : getKey(atom.key);
host[k + '@'] = undefined;
var k = atom.key === undefined ? atom.field + '@' : atom.field + '.' + getKey(atom.key) + '@';
host[k] = undefined;

@@ -560,0 +632,0 @@ if (host._destroyProp !== undefined) {

2

package.json
{
"name": "lom_atom",
"version": "1.1.0",
"version": "1.1.1",
"description": "Observable state management",

@@ -5,0 +5,0 @@ "publishConfig": {

@@ -109,3 +109,3 @@ // @flow

} else {
ptr[this.field] = undefined
ptr[this.field] = null
}

@@ -112,0 +112,0 @@ }

@@ -81,2 +81,10 @@ // @flow

export class NoSerializableException extends Error {
constructor(host: IAtomHost, field?: string) {
super(`${host.displayName || host.constructor.name}${field ? `.${field}` : ''} not a serializable`)
// $FlowFixMe new.target
;(this: Object)['__proto__'] = new.target.prototype
}
}
export default class Context implements IContext {

@@ -126,5 +134,8 @@ last: ?IAtomInt = null

const k = key === undefined ? field : getKey(key)
let atom: IAtom<V> | void = host[k + '@']
const k = key === undefined
? (field + '@')
: (field + '.' + getKey(key) + '@')
let atom: IAtom<V> | void = host[k]
if (atom === undefined) {

@@ -141,4 +152,6 @@ let ptr: Object | void = host.__lom_state

if (typeof ptr !== 'object') {
throw new Error(`${host.displayName || host.constructor.name}.${field} need an object`)
throw new NoSerializableException(host, field)
}
} else if (ptr[field] === null) {
ptr[field] = undefined
}

@@ -151,3 +164,3 @@ }

// dict.set(k, atom)
;(host: Object)[k + '@'] = (atom: any)
;(host: Object)[k] = (atom: any)
}

@@ -158,6 +171,50 @@

setHostState(host: IAtomHost, state: Object) {
host.__lom_state = state
getState(host: Object): Object {
if (!host.__lom_state) {
throw new NoSerializableException(host)
}
return host.__lom_state
}
setState(host: Object, state: Object, init?: boolean) {
if (init) {
host.__lom_state = state
return
}
const oldState = host.__lom_state
if (oldState === undefined) {
throw new NoSerializableException(host)
}
const fields = Object.keys(state)
for (let i = 0; i < fields.length; i++) {
const field = fields[i]
const value = state[field]
if (host[field + '?'] !== undefined) {
if (typeof value !== 'object' || value === null) {
throw new NoSerializableException(host, field)
}
const keys = Object.keys(value)
for (let j = 0; j < keys.length; j++) {
const key = keys[j]
const atom: IAtom<*> | void = host[field + '.' + key + '@']
if (atom !== undefined) {
atom.set(value[key])
} else {
if (!oldState[field]) {
oldState[field] = {}
}
oldState[field][key] = value[key]
}
}
} else {
const atom: IAtom<*> | void = host[field + '@']
if (atom !== undefined) {
atom.set(value)
} else {
oldState[field] = value
}
}
}
}
destroyHost(atom: IAtomInt) {

@@ -170,4 +227,7 @@ if (this._logger !== undefined) {

const k = atom.key === undefined ? atom.field : getKey(atom.key)
host[k + '@'] = (undefined: any)
const k = atom.key === undefined
? (atom.field + '@')
: (atom.field + '.' + getKey(atom.key) + '@')
host[k] = (undefined: any)
if (host._destroyProp !== undefined) {

@@ -174,0 +234,0 @@ host._destroyProp(atom.key || atom.field, atom.cached)

@@ -27,2 +27,4 @@ // @flow

): IAtom<V>;
setState(host: Object, state: Object): void;
getState(host: Object): Object;
hasAtom(host: IAtomHost, key: mixed): boolean;

@@ -29,0 +31,0 @@

Sorry, the diff of this file is not supported yet

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