Comparing version 2.0.5 to 2.0.6
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="2.0.6"></a> | ||
## [2.0.6](https://github.com/zerkalica/lom_atom/compare/v2.0.5...v2.0.6) (2017-11-04) | ||
<a name="2.0.5"></a> | ||
@@ -7,0 +12,0 @@ ## [2.0.5](https://github.com/zerkalica/lom_atom/compare/v2.0.4...v2.0.5) (2017-10-29) |
@@ -121,6 +121,8 @@ // eslint-disable-line | ||
}]]); | ||
var done = Symbol('lom_conform_done'); | ||
function conform(target, source, isComponent) { | ||
var stack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
if (target === source) return source; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target.constructor !== source.constructor) return target; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
target[done] = true; | ||
var conformHandler = handlers.get(target.constructor); | ||
@@ -279,3 +281,3 @@ if (!conformHandler) return target; | ||
if (nextRaw === undefined) return prev; | ||
var next = nextRaw instanceof Error ? createMock(nextRaw) : prev instanceof Error ? nextRaw : conform(nextRaw, prev, this.isComponent); | ||
var next = nextRaw instanceof Error ? createMock(nextRaw) : conform(nextRaw, prev, this.isComponent); | ||
@@ -468,3 +470,8 @@ if (prev !== next) { | ||
if (from && !(from instanceof Error) && _typeof(from) === 'object' && typeof from.destructor === 'function' && this._owners.get(from) === atom) { | ||
from.destructor(); | ||
try { | ||
from.destructor(); | ||
} catch (e) { | ||
console.error(e); | ||
if (this._logger) this._logger.error(atom, e, this._namespace); | ||
} | ||
@@ -609,3 +616,3 @@ this._owners.delete(from); | ||
var hostAtoms = new WeakMap(); | ||
Object.defineProperty(proto, name + "()", { | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
@@ -720,4 +727,4 @@ return hostAtoms.get(this); | ||
var key = keys[i]; | ||
var _value = params[key]; | ||
result += "." + key + ":" + (_typeof(_value) === 'object' ? JSON.stringify(_value) : _value); | ||
var value = params[key]; | ||
result += "." + key + ":" + (_typeof(value) === 'object' ? JSON.stringify(value) : value); | ||
} | ||
@@ -745,3 +752,3 @@ | ||
var hostAtoms = new WeakMap(); | ||
Object.defineProperty(proto, name + "()", { | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
@@ -748,0 +755,0 @@ return hostAtoms.get(this); |
@@ -125,6 +125,8 @@ 'use strict'; | ||
}]]); | ||
var done = Symbol('lom_conform_done'); | ||
function conform(target, source, isComponent) { | ||
var stack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
if (target === source) return source; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target.constructor !== source.constructor) return target; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
target[done] = true; | ||
var conformHandler = handlers.get(target.constructor); | ||
@@ -283,3 +285,3 @@ if (!conformHandler) return target; | ||
if (nextRaw === undefined) return prev; | ||
var next = nextRaw instanceof Error ? createMock(nextRaw) : prev instanceof Error ? nextRaw : conform(nextRaw, prev, this.isComponent); | ||
var next = nextRaw instanceof Error ? createMock(nextRaw) : conform(nextRaw, prev, this.isComponent); | ||
@@ -472,3 +474,8 @@ if (prev !== next) { | ||
if (from && !(from instanceof Error) && _typeof(from) === 'object' && typeof from.destructor === 'function' && this._owners.get(from) === atom) { | ||
from.destructor(); | ||
try { | ||
from.destructor(); | ||
} catch (e) { | ||
console.error(e); | ||
if (this._logger) this._logger.error(atom, e, this._namespace); | ||
} | ||
@@ -613,3 +620,3 @@ this._owners.delete(from); | ||
var hostAtoms = new WeakMap(); | ||
Object.defineProperty(proto, name + "()", { | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
@@ -724,4 +731,4 @@ return hostAtoms.get(this); | ||
var key = keys[i]; | ||
var _value = params[key]; | ||
result += "." + key + ":" + (_typeof(_value) === 'object' ? JSON.stringify(_value) : _value); | ||
var value = params[key]; | ||
result += "." + key + ":" + (_typeof(value) === 'object' ? JSON.stringify(value) : value); | ||
} | ||
@@ -749,3 +756,3 @@ | ||
var hostAtoms = new WeakMap(); | ||
Object.defineProperty(proto, name + "()", { | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
@@ -752,0 +759,0 @@ return hostAtoms.get(this); |
@@ -127,6 +127,8 @@ (function (global, factory) { | ||
}]]); | ||
var done = Symbol('lom_conform_done'); | ||
function conform(target, source, isComponent) { | ||
var stack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
if (target === source) return source; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target.constructor !== source.constructor) return target; | ||
if (isComponent || !target || _typeof(target) !== 'object' || !source || _typeof(source) !== 'object' || target instanceof Error || source instanceof Error || target.constructor !== source.constructor || target[done] !== undefined) return target; | ||
target[done] = true; | ||
var conformHandler = handlers.get(target.constructor); | ||
@@ -285,3 +287,3 @@ if (!conformHandler) return target; | ||
if (nextRaw === undefined) return prev; | ||
var next = nextRaw instanceof Error ? createMock(nextRaw) : prev instanceof Error ? nextRaw : conform(nextRaw, prev, this.isComponent); | ||
var next = nextRaw instanceof Error ? createMock(nextRaw) : conform(nextRaw, prev, this.isComponent); | ||
@@ -474,3 +476,8 @@ if (prev !== next) { | ||
if (from && !(from instanceof Error) && _typeof(from) === 'object' && typeof from.destructor === 'function' && this._owners.get(from) === atom) { | ||
from.destructor(); | ||
try { | ||
from.destructor(); | ||
} catch (e) { | ||
console.error(e); | ||
if (this._logger) this._logger.error(atom, e, this._namespace); | ||
} | ||
@@ -615,3 +622,3 @@ this._owners.delete(from); | ||
var hostAtoms = new WeakMap(); | ||
Object.defineProperty(proto, name + "()", { | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
@@ -726,4 +733,4 @@ return hostAtoms.get(this); | ||
var key = keys[i]; | ||
var _value = params[key]; | ||
result += "." + key + ":" + (_typeof(_value) === 'object' ? JSON.stringify(_value) : _value); | ||
var value = params[key]; | ||
result += "." + key + ":" + (_typeof(value) === 'object' ? JSON.stringify(value) : value); | ||
} | ||
@@ -751,3 +758,3 @@ | ||
var hostAtoms = new WeakMap(); | ||
Object.defineProperty(proto, name + "()", { | ||
Object.defineProperty(proto, rname + "()", { | ||
get: function get$$1() { | ||
@@ -754,0 +761,0 @@ return hostAtoms.get(this); |
{ | ||
"name": "lom_atom", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Alternative implementation of eigenmethod mol_atom state management library", | ||
@@ -62,3 +62,3 @@ "publishConfig": { | ||
"chokidar-cli": "^1.2.0", | ||
"flow-bin": "^0.57.3", | ||
"flow-bin": "^0.58.0", | ||
"mocha": "^4.0.1", | ||
@@ -71,4 +71,4 @@ "rimraf": "^2.6.2", | ||
"standard-version": "^4.2.0", | ||
"uglify-es": "^3.1.5" | ||
"uglify-es": "^3.1.6" | ||
} | ||
} |
@@ -191,3 +191,3 @@ // @flow | ||
? createMock(nextRaw) | ||
: (prev instanceof Error ? nextRaw : conform(nextRaw, prev, this.isComponent)) | ||
: conform(nextRaw, prev, this.isComponent) | ||
@@ -194,0 +194,0 @@ if (prev !== next) { |
@@ -48,2 +48,4 @@ // @flow | ||
const done = Symbol('lom_conform_done') | ||
export default function conform<Target, Source>(target: Target, source: Source, isComponent: boolean, stack: any[] = []): Target { | ||
@@ -56,5 +58,10 @@ if (target === source) return (source: any) | ||
|| !source || typeof source !== 'object' | ||
|| target instanceof Error | ||
|| source instanceof Error | ||
|| target.constructor !== source.constructor | ||
|| (target: Object)[done] !== undefined | ||
) return target | ||
;(target: Object)[done] = true | ||
const conformHandler = handlers.get(target.constructor) | ||
@@ -61,0 +68,0 @@ if (!conformHandler) return target |
@@ -79,3 +79,8 @@ // @flow | ||
) { | ||
from.destructor() | ||
try { | ||
from.destructor() | ||
} catch(e) { | ||
console.error(e) | ||
if (this._logger) this._logger.error(atom, e, this._namespace) | ||
} | ||
this._owners.delete(from) | ||
@@ -82,0 +87,0 @@ } |
@@ -96,5 +96,7 @@ // @flow | ||
} | ||
export type IAtomPropHandler<V> = (next?: V | Error, force?: IAtomForce, oldValue?: V) => V | ||
// | Error | ||
export type IAtomHandler<V, K> = (key: K, next?: V | Error, force?: IAtomForce, oldValue?: V) => V | ||
| (next?: V | Error, force?: IAtomForce, oldValue?: V) => V | ||
| IAtomPropHandler<V> | ||
@@ -105,1 +107,11 @@ export interface IAtomOwner { | ||
} | ||
export type TypedPropertyDescriptor<T> = { | ||
enumerable?: boolean; | ||
configurable?: boolean; | ||
writable?: boolean; | ||
value?: T; | ||
initializer?: () => T; | ||
get?: () => T; | ||
set?: (value: T | Error) => void; | ||
} |
// @flow | ||
import {ATOM_FORCE_CACHE, ATOM_FORCE_NONE, ATOM_FORCE_UPDATE} from './interfaces' | ||
import type {IAtom, IAtomHandler, IAtomForce, IContext} from './interfaces' | ||
import type {TypedPropertyDescriptor, IAtom, IAtomPropHandler, IAtomHandler, IAtomForce, IContext} from './interfaces' | ||
import {defaultContext} from './Context' | ||
@@ -8,12 +8,2 @@ import {AtomWait} from './utils' | ||
type TypedPropertyDescriptor<T> = { | ||
enumerable?: boolean; | ||
configurable?: boolean; | ||
writable?: boolean; | ||
value?: T; | ||
initializer?: () => T; | ||
get?: () => T; | ||
set?: (value: T | Error) => void; | ||
} | ||
function getId(t: Object, hk: string): string { | ||
@@ -35,4 +25,3 @@ return `${t.constructor.displayName || t.constructor.name}.${hk}` | ||
const hostAtoms: WeakMap<Object, IAtom<V>> = new WeakMap() | ||
Object.defineProperty(proto, `${name}()`, { | ||
Object.defineProperty(proto, `${rname}()`, { | ||
get() { | ||
@@ -178,3 +167,3 @@ return hostAtoms.get(this) | ||
const hostAtoms: WeakMap<Object, Map<string, IAtom<V>>> = new WeakMap() | ||
Object.defineProperty(proto, `${name}()`, { | ||
Object.defineProperty(proto, `${rname}()`, { | ||
get() { | ||
@@ -281,7 +270,7 @@ return hostAtoms.get(this) | ||
export function detached<P: Object, V, K>( | ||
export function detached<P: Object, V>( | ||
proto: P, | ||
name: string, | ||
descr: TypedPropertyDescriptor<*> | ||
): TypedPropertyDescriptor<any> | void { | ||
descr: TypedPropertyDescriptor<IAtomPropHandler<V>> | ||
): TypedPropertyDescriptor<IAtomPropHandler<V>> { | ||
return memMethod(proto, name, descr, true) | ||
@@ -288,0 +277,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
297278
3523