Comparing version 3.0.13 to 3.0.14
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="3.0.14"></a> | ||
## [3.0.14](https://github.com/zerkalica/lom_atom/compare/v3.0.13...v3.0.14) (2017-12-08) | ||
<a name="3.0.13"></a> | ||
@@ -7,0 +12,0 @@ ## [3.0.13](https://github.com/zerkalica/lom_atom/compare/v3.0.12...v3.0.13) (2017-12-07) |
@@ -54,2 +54,29 @@ function _defineProperties(target, props) { | ||
}(Error); | ||
var atomId = Symbol('lom_atom'); | ||
var RecoverableError = | ||
/*#__PURE__*/ | ||
function (_Error2) { | ||
_inheritsLoose(RecoverableError, _Error2); | ||
function RecoverableError(error, atom) { | ||
var _this2; | ||
_this2 = _Error2.call(this, error.message || error) || this; | ||
_this2.retry = function () { | ||
_this2[atomId].value(undefined, ATOM_FORCE_CACHE); | ||
}; | ||
_this2.stack = error.stack // $FlowFixMe new.target | ||
; | ||
_this2['__proto__'] = new.target.prototype; | ||
_this2[catchedId] = true; | ||
_this2[atomId] = atom; | ||
return _this2; | ||
} | ||
return RecoverableError; | ||
}(Error); | ||
function getId(t, hk) { | ||
@@ -142,3 +169,3 @@ return (t.constructor.displayName || t.constructor.name) + "." + hk; | ||
function disleadSlaves(master) { | ||
function deleteSlave(master) { | ||
master.dislead(this); | ||
@@ -153,3 +180,3 @@ } | ||
function deleteMasters(slave) { | ||
function deleteMaster(slave) { | ||
slave.removeMaster(this); | ||
@@ -195,3 +222,3 @@ } | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this); | ||
this._masters.forEach(deleteSlave, this); | ||
@@ -202,3 +229,3 @@ this._masters = null; | ||
if (this._slaves) { | ||
this._slaves.forEach(deleteMasters, this); | ||
this._slaves.forEach(deleteMaster, this); | ||
@@ -322,3 +349,3 @@ this._slaves = null; | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this); | ||
this._masters.forEach(deleteSlave, this); | ||
} | ||
@@ -342,3 +369,3 @@ | ||
newValue = error instanceof Error ? error : new Error(error.stack || error); | ||
newValue = error instanceof AtomWait || error instanceof RecoverableError ? error : new RecoverableError(error, this); | ||
} | ||
@@ -390,5 +417,6 @@ | ||
_proto.removeMaster = function removeMaster(master) { | ||
if (!this._masters) return; | ||
this._masters.delete(master); | ||
var masters = this._masters; | ||
if (!masters) return; | ||
masters.delete(master); | ||
if (masters.size === 0) this._masters = null; | ||
}; | ||
@@ -833,2 +861,3 @@ | ||
}, | ||
// unchanged: {value} | ||
manual: { | ||
@@ -893,3 +922,3 @@ value: memManual | ||
export { Atom, action, detached, mem, ConsoleLogger, defaultContext, AtomWait }; | ||
export { Atom, action, detached, mem, ConsoleLogger, defaultContext, RecoverableError, AtomWait }; | ||
//# sourceMappingURL=lom_atom.es.js.map |
@@ -58,2 +58,29 @@ 'use strict'; | ||
}(Error); | ||
var atomId = Symbol('lom_atom'); | ||
var RecoverableError = | ||
/*#__PURE__*/ | ||
function (_Error2) { | ||
_inheritsLoose(RecoverableError, _Error2); | ||
function RecoverableError(error, atom) { | ||
var _this2; | ||
_this2 = _Error2.call(this, error.message || error) || this; | ||
_this2.retry = function () { | ||
_this2[atomId].value(undefined, ATOM_FORCE_CACHE); | ||
}; | ||
_this2.stack = error.stack // $FlowFixMe new.target | ||
; | ||
_this2['__proto__'] = new.target.prototype; | ||
_this2[catchedId] = true; | ||
_this2[atomId] = atom; | ||
return _this2; | ||
} | ||
return RecoverableError; | ||
}(Error); | ||
function getId(t, hk) { | ||
@@ -146,3 +173,3 @@ return (t.constructor.displayName || t.constructor.name) + "." + hk; | ||
function disleadSlaves(master) { | ||
function deleteSlave(master) { | ||
master.dislead(this); | ||
@@ -157,3 +184,3 @@ } | ||
function deleteMasters(slave) { | ||
function deleteMaster(slave) { | ||
slave.removeMaster(this); | ||
@@ -199,3 +226,3 @@ } | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this); | ||
this._masters.forEach(deleteSlave, this); | ||
@@ -206,3 +233,3 @@ this._masters = null; | ||
if (this._slaves) { | ||
this._slaves.forEach(deleteMasters, this); | ||
this._slaves.forEach(deleteMaster, this); | ||
@@ -326,3 +353,3 @@ this._slaves = null; | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this); | ||
this._masters.forEach(deleteSlave, this); | ||
} | ||
@@ -346,3 +373,3 @@ | ||
newValue = error instanceof Error ? error : new Error(error.stack || error); | ||
newValue = error instanceof AtomWait || error instanceof RecoverableError ? error : new RecoverableError(error, this); | ||
} | ||
@@ -394,5 +421,6 @@ | ||
_proto.removeMaster = function removeMaster(master) { | ||
if (!this._masters) return; | ||
this._masters.delete(master); | ||
var masters = this._masters; | ||
if (!masters) return; | ||
masters.delete(master); | ||
if (masters.size === 0) this._masters = null; | ||
}; | ||
@@ -837,2 +865,3 @@ | ||
}, | ||
// unchanged: {value} | ||
manual: { | ||
@@ -903,3 +932,4 @@ value: memManual | ||
exports.defaultContext = defaultContext; | ||
exports.RecoverableError = RecoverableError; | ||
exports.AtomWait = AtomWait; | ||
//# sourceMappingURL=lom_atom.js.map |
@@ -60,2 +60,29 @@ (function (global, factory) { | ||
}(Error); | ||
var atomId = Symbol('lom_atom'); | ||
var RecoverableError = | ||
/*#__PURE__*/ | ||
function (_Error2) { | ||
_inheritsLoose(RecoverableError, _Error2); | ||
function RecoverableError(error, atom) { | ||
var _this2; | ||
_this2 = _Error2.call(this, error.message || error) || this; | ||
_this2.retry = function () { | ||
_this2[atomId].value(undefined, ATOM_FORCE_CACHE); | ||
}; | ||
_this2.stack = error.stack // $FlowFixMe new.target | ||
; | ||
_this2['__proto__'] = new.target.prototype; | ||
_this2[catchedId] = true; | ||
_this2[atomId] = atom; | ||
return _this2; | ||
} | ||
return RecoverableError; | ||
}(Error); | ||
function getId(t, hk) { | ||
@@ -148,3 +175,3 @@ return (t.constructor.displayName || t.constructor.name) + "." + hk; | ||
function disleadSlaves(master) { | ||
function deleteSlave(master) { | ||
master.dislead(this); | ||
@@ -159,3 +186,3 @@ } | ||
function deleteMasters(slave) { | ||
function deleteMaster(slave) { | ||
slave.removeMaster(this); | ||
@@ -201,3 +228,3 @@ } | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this); | ||
this._masters.forEach(deleteSlave, this); | ||
@@ -208,3 +235,3 @@ this._masters = null; | ||
if (this._slaves) { | ||
this._slaves.forEach(deleteMasters, this); | ||
this._slaves.forEach(deleteMaster, this); | ||
@@ -328,3 +355,3 @@ this._slaves = null; | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this); | ||
this._masters.forEach(deleteSlave, this); | ||
} | ||
@@ -348,3 +375,3 @@ | ||
newValue = error instanceof Error ? error : new Error(error.stack || error); | ||
newValue = error instanceof AtomWait || error instanceof RecoverableError ? error : new RecoverableError(error, this); | ||
} | ||
@@ -396,5 +423,6 @@ | ||
_proto.removeMaster = function removeMaster(master) { | ||
if (!this._masters) return; | ||
this._masters.delete(master); | ||
var masters = this._masters; | ||
if (!masters) return; | ||
masters.delete(master); | ||
if (masters.size === 0) this._masters = null; | ||
}; | ||
@@ -839,2 +867,3 @@ | ||
}, | ||
// unchanged: {value} | ||
manual: { | ||
@@ -905,2 +934,3 @@ value: memManual | ||
exports.defaultContext = defaultContext; | ||
exports.RecoverableError = RecoverableError; | ||
exports.AtomWait = AtomWait; | ||
@@ -907,0 +937,0 @@ |
{ | ||
"name": "lom_atom", | ||
"version": "3.0.13", | ||
"version": "3.0.14", | ||
"description": "Alternative implementation of eigenmethod mol_atom state management library", | ||
@@ -65,8 +65,8 @@ "publishConfig": { | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.52.0", | ||
"rollup": "^0.52.1", | ||
"rollup-plugin-babel": "^4.0.0-beta.0", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"standard-version": "^4.2.0", | ||
"uglify-es": "^3.2.0" | ||
"uglify-es": "^3.2.1" | ||
} | ||
} |
@@ -21,3 +21,3 @@ // @flow | ||
import {AtomWait, origId, proxify} from './utils' | ||
import {AtomWait, RecoverableError, origId, proxify} from './utils' | ||
import conform from './conform' | ||
@@ -33,3 +33,3 @@ | ||
function disleadSlaves(master: IAtomInt) { | ||
function deleteSlave(master: IAtomInt) { | ||
master.dislead((this: IAtomInt)) | ||
@@ -44,3 +44,3 @@ } | ||
function deleteMasters(slave: IAtomInt) { | ||
function deleteMaster(slave: IAtomInt) { | ||
slave.removeMaster((this: IAtomInt)) | ||
@@ -116,7 +116,7 @@ } | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this) | ||
this._masters.forEach(deleteSlave, this) | ||
this._masters = null | ||
} | ||
if (this._slaves) { | ||
this._slaves.forEach(deleteMasters, this) | ||
this._slaves.forEach(deleteMaster, this) | ||
this._slaves = null | ||
@@ -232,3 +232,3 @@ } | ||
if (this._masters) { | ||
this._masters.forEach(disleadSlaves, this) | ||
this._masters.forEach(deleteSlave, this) | ||
} | ||
@@ -252,5 +252,5 @@ let newValue: V | Error | ||
} | ||
newValue = error instanceof Error | ||
newValue = error instanceof AtomWait || error instanceof RecoverableError | ||
? error | ||
: new Error(error.stack || error) | ||
: new RecoverableError(error, this) | ||
} | ||
@@ -297,4 +297,6 @@ context.current = slave | ||
removeMaster(master: IAtomInt) { | ||
if (!this._masters) return | ||
this._masters.delete(master) | ||
const masters = this._masters | ||
if (!masters) return | ||
masters.delete(master) | ||
if (masters.size === 0) this._masters = null | ||
} | ||
@@ -301,0 +303,0 @@ |
@@ -178,2 +178,3 @@ // @flow | ||
}: any), | ||
// unchanged: {value} | ||
manual: { value: memManual }, | ||
@@ -180,0 +181,0 @@ key: { value: memkey } |
@@ -9,3 +9,3 @@ // @flow | ||
export {defaultContext} from './Context' | ||
export {AtomWait} from './utils' | ||
export {RecoverableError, AtomWait} from './utils' | ||
@@ -12,0 +12,0 @@ export type { |
// @flow | ||
import {catchedId} from './interfaces' | ||
import {ATOM_FORCE_CACHE, catchedId} from './interfaces' | ||
import type {IAtom} from './interfaces' | ||
@@ -13,3 +14,18 @@ export class AtomWait extends Error { | ||
} | ||
const atomId = Symbol('lom_atom') | ||
export class RecoverableError<V> extends Error { | ||
constructor(error: Error, atom: IAtom<V>) { | ||
super(error.message || error) | ||
this.stack = error.stack | ||
// $FlowFixMe new.target | ||
;(this: Object)['__proto__'] = new.target.prototype | ||
;(this: Object)[catchedId] = true | ||
;(this: Object)[atomId] = atom | ||
} | ||
retry = () => { | ||
;(this: Object)[atomId].value(undefined, ATOM_FORCE_CACHE) | ||
} | ||
} | ||
export function getId(t: Object, hk: string): string { | ||
@@ -16,0 +32,0 @@ return `${t.constructor.displayName || t.constructor.name}.${hk}` |
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
331462
3391