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.0.5 to 1.0.6

5

CHANGELOG.md

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

<a name="1.0.6"></a>
## [1.0.6](https://github.com/zerkalica/lom_atom/compare/v1.0.5...v1.0.6) (2017-08-13)
<a name="1.0.5"></a>

@@ -7,0 +12,0 @@ ## [1.0.5](https://github.com/zerkalica/lom_atom/compare/v1.0.4...v1.0.5) (2017-08-04)

197

dist/lom_atom.es.js

@@ -191,11 +191,10 @@ // eslint-disable-line

return this.cached;
} // console.log('set', this.field, 'value', normalized)
}
var context = this._context; // console.log('set', this.field, 'value', normalized)
if (force || this._context.force || normalized instanceof Error) {
this._context.force = false;
if (!force && !context.force || normalized instanceof Error) {
context.force = false;
this.status = ATOM_STATUS_ACTUAL;
this._context.newValue(this, this.cached, normalized);
var oldValue = this.cached;
this.cached = normalized instanceof Error ? createMock(normalized) : normalized;

@@ -206,2 +205,6 @@

}
context.newValue(this, oldValue, normalized);
context.beginTransaction();
context.endTransaction();
} else {

@@ -245,2 +248,3 @@ this.obsolete();

context.last = this;
context.beginTransaction();

@@ -262,4 +266,3 @@ try {

if (newValue !== undefined && this.cached !== newValue) {
this._context.newValue(this, this.cached, newValue);
var oldValue = this.cached;
this.cached = newValue;

@@ -270,2 +273,8 @@

}
this._context.newValue(this, oldValue, newValue);
context.endTransaction();
} else {
context.endTransaction(true);
}

@@ -331,14 +340,24 @@ };

reaping.delete(atom);
atom.destroyed(true);
if (!atom.slaves) {
atom.destroyed(true);
}
}
var animationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : function (fn) {
return setTimeout(fn, 0);
};
var lastId = 0;
function getKey(params) {
if (typeof params === 'string' || typeof params === 'number' || typeof params === 'function' || !params) {
return params || '';
if (typeof params === 'string' || typeof params === 'number') {
return params;
}
if (!params) {
return 0;
}
if (typeof params === 'function') {
params.__id = params.__id || ++lastId;
return params.__id;
}
return _typeof(params) === 'object' ? Object.keys(params).sort().map(function (key) {

@@ -351,4 +370,2 @@ return key + ":" + JSON.stringify(params[key]);

function Context() {
var _this = this;
this.last = null;

@@ -359,13 +376,9 @@ this.force = false;

this._reaping = new Set();
this._scheduled = false;
this._atomMap = new WeakMap();
this._run = function () {
if (_this._scheduled) {
_this.run();
}
};
this._pendCount = 0;
}
Context.prototype.getAtom = function getAtom(field, host, key, normalize, isComponent) {
var k = key === undefined ? field : getKey(key);
var map = this._atomMap.get(host);

@@ -379,8 +392,7 @@

var k = key === undefined ? field : getKey(key);
var atom = map.get(k);
var atom = map.get(k); // let atom: IAtom<V> | void = host[k + '@']
if (atom === undefined) {
atom = new Atom(field, host, this, key, normalize, isComponent);
map.set(k, atom); // host[field + '@'] = atom
map.set(k, atom); // host[k + '@'] = atom
}

@@ -392,3 +404,7 @@

Context.prototype.destroyHost = function destroyHost(atom) {
var host = atom.host;
var host = atom.host; // host[(atom.key === undefined ? atom.field : getKey(atom.key)) + '@'] = undefined
//
// if (host._destroy !== undefined) {
// host._destroy()
// }

@@ -433,4 +449,2 @@ var map = this._atomMap.get(host);

this._updating.push(atom);
this._schedule();
};

@@ -441,4 +455,2 @@

this._reaping.add(atom);
this._schedule();
};

@@ -451,37 +463,39 @@

Context.prototype._schedule = function _schedule() {
if (this._scheduled) {
return;
}
this._scheduled = true;
animationFrame(this._run);
Context.prototype.beginTransaction = function beginTransaction() {
this._pendCount++;
};
Context.prototype.run = function run() {
var reaping = this._reaping;
var updating = this._updating;
var start = 0;
this.beginTransaction();
this.endTransaction();
};
do {
var end = updating.length;
Context.prototype.endTransaction = function endTransaction(noUpdate) {
if (this._pendCount === 1 && noUpdate !== true) {
var reaping = this._reaping;
var updating = this._updating;
var start = 0;
for (var i = start; i < end; i++) {
var atom = updating[i];
do {
var end = updating.length;
if (!reaping.has(atom) && !atom.destroyed()) {
atom.actualize();
for (var i = start; i < end; i++) {
var atom = updating[i];
if (!reaping.has(atom) && !atom.destroyed()) {
atom.actualize();
}
}
}
start = end;
} while (updating.length > start);
start = end;
} while (updating.length > start);
updating.length = 0;
updating.length = 0;
while (reaping.size > 0) {
reaping.forEach(reap);
while (reaping.size > 0) {
reaping.forEach(reap);
}
}
this._scheduled = false;
this._pendCount--;
};

@@ -592,2 +606,75 @@

}
function createAction(t, hk) {
function action() {
var result = void 0;
defaultContext.beginTransaction();
switch (arguments.length) {
case 0:
result = t[hk]();
break;
case 1:
result = t[hk](arguments[0]);
break;
case 2:
result = t[hk](arguments[0], arguments[1]);
break;
case 3:
result = t[hk](arguments[0], arguments[1], arguments[2]);
break;
case 4:
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]);
break;
case 5:
result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
break;
default:
result = t[hk].apply(t, arguments);
}
defaultContext.endTransaction();
return result;
}
action.displayName = hk;
return action;
}
function action(proto, field, descr) {
var hk = field + "$";
if (descr.value === undefined) {
throw new TypeError(field + " is not an function (next?: V)");
}
proto[hk] = descr.value;
var definingProperty = false;
return {
enumerable: descr.enumerable,
configurable: descr.configurable,
get: function get() {
if (definingProperty) {
return this[hk];
}
definingProperty = true;
var actionFn = createAction(this, hk);
Object.defineProperty(this, field, {
configurable: true,
get: function get() {
return actionFn;
}
});
definingProperty = false;
return actionFn;
}
};
}
function mem() {

@@ -607,3 +694,3 @@ if (arguments.length === 3) {

export { Atom, mem, memkey, detached, force, defaultContext, animationFrame };
export { Atom, mem, memkey, detached, force, action, defaultContext };
//# sourceMappingURL=lom_atom.es.js.map

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

"use strict";function createMock(t){return new Proxy(t,throwOnAccess)}function defaultNormalize(t,e){if(t===e)return t;if(t instanceof Array&&e instanceof Array&&t.length===e.length){for(var o=0;o<t.length;o++)if(t[o]!==e[o])return t;return e}return t}function checkSlave(t){t.check()}function obsoleteSlave(t){t.obsolete()}function disleadThis(t){t.dislead(this)}function actualizeMaster(t){this.status===ATOM_STATUS_CHECKING&&t.actualize()}function reap(t,e,o){o.delete(t),t.destroyed(!0)}function getKey(t){return"string"!=typeof t&&"number"!=typeof t&&"function"!=typeof t&&t?"object"===_typeof(t)?Object.keys(t).sort().map(function(e){return e+":"+JSON.stringify(t[e])}).join("."):JSON.stringify(t):t||""}function memMethod(t,e,o,i,s){var n=e+"$";if(void 0===o.value)throw new TypeError(e+" is not an function (next?: V)");return t[n]=o.value,{enumerable:o.enumerable,configurable:o.configurable,value:function(t,e){return defaultContext.getAtom(n,this,void 0,i,s).value(t,e)}}}function createGetSetHandler(t,e){return function(o){return void 0===o?t.call(this):(e.call(this,o),o)}}function createValueHandler(t){return function(e){return void 0===e&&void 0!==t?t.call(this):e}}function memProp(t,e,o,i){var s=e+"$";if(void 0===t[s]){t[s]=void 0===o.get&&void 0===o.set?createValueHandler(o.initializer):createGetSetHandler(o.get,o.set);return{enumerable:o.enumerable,configurable:o.configurable,get:function(){return defaultContext.getAtom(s,this,void 0,i).get()},set:function(t){defaultContext.getAtom(s,this,void 0,i).set(t)}}}}function memkeyProp(t,e,o,i){var s=o.value;if(void 0===s)throw new TypeError(e+" is not an function (rawKey: K, next?: V)");var n=e+"$";return t[n]=s,{enumerable:o.enumerable,configurable:o.configurable,value:function(t,e,o){return defaultContext.getAtom(n,this,t,i).value(e,o)}}}function memkey(){if(3===arguments.length)return memkeyProp(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,o,i){return memkeyProp(e,o,i,t)}}function forceGet(){return defaultContext.force=!0,this}function force(t,e,o){return{enumerable:o.enumerable,configurable:o.configurable,get:forceGet}}function detached(t,e,o){return memMethod(t,e,o,void 0,!0)}function mem(){if(3===arguments.length)return void 0===arguments[2].value?memProp(arguments[0],arguments[1],arguments[2]):memMethod(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,o,i){return void 0===i.value?memProp(e,o,i,t):memMethod(e,o,i,t)}}Object.defineProperty(exports,"__esModule",{value:!0});var ATOM_STATUS_DESTROYED=0,ATOM_STATUS_OBSOLETE=1,ATOM_STATUS_CHECKING=2,ATOM_STATUS_PULLING=3,ATOM_STATUS_ACTUAL=4,catchedId=Symbol("lom_atom_catched"),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},inheritsLoose=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e},throwOnAccess={get:function(t){throw t.valueOf()},ownKeys:function(t){throw t.valueOf()}},AtomWait=function(t){function e(){var e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Wait...";return e=t.call(this,o)||this,e.__proto__=new.target.prototype,e[catchedId]=!0,e}return inheritsLoose(e,t),e}(Error),Atom=function(){function t(t,e,o,i,s,n){this.status=ATOM_STATUS_OBSOLETE,this.cached=void 0,this._masters=null,this._slaves=null,this.field=t,this.key=i,this.host=e,this.isComponent=n||!1,this._normalize=s||defaultNormalize,this._context=o}return t.prototype.destroyed=function(t){return void 0===t?this.status===ATOM_STATUS_DESTROYED:!!t&&(this.status!==ATOM_STATUS_DESTROYED&&(this._masters&&(this._masters.forEach(disleadThis,this),this._masters=null),this._checkSlaves(),void 0!==this.host&&this._context.destroyHost(this),this.cached=void 0,this.status=ATOM_STATUS_DESTROYED,this.key=void 0),!0)},t.prototype.get=function(t){t||this._context.force?(this._context.force=!1,this._pullPush(void 0,!0)):this.actualize();var e=this._context.last;if(e&&(!e.isComponent||!this.isComponent)){var o=this._slaves;o||(this._context.unreap(this),o=this._slaves=new Set),o.add(e),e.addMaster(this)}return this.cached},t.prototype.set=function(t,e){var o=this._normalize(t,this.cached);return this.cached===o?o:void 0===o?this.cached:(e||this._context.force||o instanceof Error?(this._context.force=!1,this.status=ATOM_STATUS_ACTUAL,this._context.newValue(this,this.cached,o),this.cached=o instanceof Error?createMock(o):o,this._slaves&&this._slaves.forEach(obsoleteSlave)):(this.obsolete(),this.actualize(o)),this.cached)},t.prototype.actualize=function(t){this.status!==ATOM_STATUS_ACTUAL&&(this.status===ATOM_STATUS_CHECKING&&(this._masters&&this._masters.forEach(actualizeMaster,this),this.status===ATOM_STATUS_CHECKING&&(this.status=ATOM_STATUS_ACTUAL)),this.status!==ATOM_STATUS_ACTUAL&&this._pullPush(t))},t.prototype._pullPush=function(t,e){this._masters&&this._masters.forEach(disleadThis,this);var o=void 0;this.status=ATOM_STATUS_PULLING;var i=this._context,s=i.last;i.last=this;try{o=this._normalize(void 0===this.key?this.host[this.field](t,e,this.cached):this.host[this.field](this.key,t,e,this.cached),this.cached)}catch(t){void 0===t[catchedId]&&(t[catchedId]=!0,console.error(t.stack||t)),o=createMock(t)}i.last=s,this.status=ATOM_STATUS_ACTUAL,void 0!==o&&this.cached!==o&&(this._context.newValue(this,this.cached,o),this.cached=o,this._slaves&&this._slaves.forEach(obsoleteSlave))},t.prototype.dislead=function(t){var e=this._slaves;e&&(1===e.size?(this._slaves=null,this._context.proposeToReap(this)):e.delete(t))},t.prototype._checkSlaves=function(){this._slaves?this._slaves.forEach(checkSlave):this._context.proposeToPull(this)},t.prototype.check=function(){this.status===ATOM_STATUS_ACTUAL&&(this.status=ATOM_STATUS_CHECKING,this._checkSlaves())},t.prototype.obsolete=function(){this.status!==ATOM_STATUS_OBSOLETE&&(this.status=ATOM_STATUS_OBSOLETE,this._checkSlaves())},t.prototype.addMaster=function(t){this._masters||(this._masters=new Set),this._masters.add(t)},t.prototype.value=function(t,e){return void 0===t?this.get(e):this.set(t,e)},t}(),animationFrame="function"==typeof requestAnimationFrame?requestAnimationFrame:function(t){return setTimeout(t,0)},Context=function(){function t(){var t=this;this.last=null,this.force=!1,this._logger=null,this._updating=[],this._reaping=new Set,this._scheduled=!1,this._atomMap=new WeakMap,this._run=function(){t._scheduled&&t.run()}}return t.prototype.getAtom=function(t,e,o,i,s){var n=this._atomMap.get(e);void 0===n&&(n=new Map,this._atomMap.set(e,n));var r=void 0===o?t:getKey(o),a=n.get(r);return void 0===a&&(a=new Atom(t,e,this,o,i,s),n.set(r,a)),a},t.prototype.destroyHost=function(t){var e=t.host,o=this._atomMap.get(e);void 0!==o&&(void 0!==e._destroyProp&&e._destroyProp(void 0===t.key?t.field:t.key,t.cached),o.delete(void 0===t.key?t.field:getKey(t.key)),0===o.size&&(void 0!==e._destroy&&e._destroy(),this._atomMap.delete(e)))},t.prototype.setLogger=function(t){this._logger=t},t.prototype.newValue=function(t,e,o){this._logger&&(o instanceof AtomWait?this._logger.pulling(t):o instanceof Error?this._logger.error(t,o):this._logger.newValue(t,e,o))},t.prototype.proposeToPull=function(t){this._updating.push(t),this._schedule()},t.prototype.proposeToReap=function(t){this._reaping.add(t),this._schedule()},t.prototype.unreap=function(t){this._reaping.delete(t)},t.prototype._schedule=function(){this._scheduled||(this._scheduled=!0,animationFrame(this._run))},t.prototype.run=function(){var t=this._reaping,e=this._updating,o=0;do{for(var i=e.length,s=o;s<i;s++){var n=e[s];t.has(n)||n.destroyed()||n.actualize()}o=i}while(e.length>o);for(e.length=0;t.size>0;)t.forEach(reap);this._scheduled=!1},t}(),defaultContext=new Context;mem.Wait=AtomWait,mem.key=memkey,mem.detached=detached,exports.Atom=Atom,exports.mem=mem,exports.memkey=memkey,exports.detached=detached,exports.force=force,exports.defaultContext=defaultContext,exports.animationFrame=animationFrame;
"use strict";function createMock(t){return new Proxy(t,throwOnAccess)}function defaultNormalize(t,e){if(t===e)return t;if(t instanceof Array&&e instanceof Array&&t.length===e.length){for(var o=0;o<t.length;o++)if(t[o]!==e[o])return t;return e}return t}function checkSlave(t){t.check()}function obsoleteSlave(t){t.obsolete()}function disleadThis(t){t.dislead(this)}function actualizeMaster(t){this.status===ATOM_STATUS_CHECKING&&t.actualize()}function reap(t,e,o){o.delete(t),t.slaves||t.destroyed(!0)}function getKey(t){return"string"==typeof t||"number"==typeof t?t:t?"function"==typeof t?(t.__id=t.__id||++lastId,t.__id):"object"===_typeof(t)?Object.keys(t).sort().map(function(e){return e+":"+JSON.stringify(t[e])}).join("."):JSON.stringify(t):0}function memMethod(t,e,o,i,n){var s=e+"$";if(void 0===o.value)throw new TypeError(e+" is not an function (next?: V)");return t[s]=o.value,{enumerable:o.enumerable,configurable:o.configurable,value:function(t,e){return defaultContext.getAtom(s,this,void 0,i,n).value(t,e)}}}function createGetSetHandler(t,e){return function(o){return void 0===o?t.call(this):(e.call(this,o),o)}}function createValueHandler(t){return function(e){return void 0===e&&void 0!==t?t.call(this):e}}function memProp(t,e,o,i){var n=e+"$";if(void 0===t[n]){t[n]=void 0===o.get&&void 0===o.set?createValueHandler(o.initializer):createGetSetHandler(o.get,o.set);return{enumerable:o.enumerable,configurable:o.configurable,get:function(){return defaultContext.getAtom(n,this,void 0,i).get()},set:function(t){defaultContext.getAtom(n,this,void 0,i).set(t)}}}}function memkeyProp(t,e,o,i){var n=o.value;if(void 0===n)throw new TypeError(e+" is not an function (rawKey: K, next?: V)");var s=e+"$";return t[s]=n,{enumerable:o.enumerable,configurable:o.configurable,value:function(t,e,o){return defaultContext.getAtom(s,this,t,i).value(e,o)}}}function memkey(){if(3===arguments.length)return memkeyProp(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,o,i){return memkeyProp(e,o,i,t)}}function forceGet(){return defaultContext.force=!0,this}function force(t,e,o){return{enumerable:o.enumerable,configurable:o.configurable,get:forceGet}}function detached(t,e,o){return memMethod(t,e,o,void 0,!0)}function createAction(t,e){function o(){var o=void 0;switch(defaultContext.beginTransaction(),arguments.length){case 0:o=t[e]();break;case 1:o=t[e](arguments[0]);break;case 2:o=t[e](arguments[0],arguments[1]);break;case 3:o=t[e](arguments[0],arguments[1],arguments[2]);break;case 4:o=t[e](arguments[0],arguments[1],arguments[2],arguments[3]);break;case 5:o=t[e](arguments[0],arguments[1],arguments[2],arguments[3],arguments[4]);break;default:o=t[e].apply(t,arguments)}return defaultContext.endTransaction(),o}return o.displayName=e,o}function action(t,e,o){var i=e+"$";if(void 0===o.value)throw new TypeError(e+" is not an function (next?: V)");t[i]=o.value;var n=!1;return{enumerable:o.enumerable,configurable:o.configurable,get:function(){if(n)return this[i];n=!0;var t=createAction(this,i);return Object.defineProperty(this,e,{configurable:!0,get:function(){return t}}),n=!1,t}}}function mem(){if(3===arguments.length)return void 0===arguments[2].value?memProp(arguments[0],arguments[1],arguments[2]):memMethod(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,o,i){return void 0===i.value?memProp(e,o,i,t):memMethod(e,o,i,t)}}Object.defineProperty(exports,"__esModule",{value:!0});var ATOM_STATUS_DESTROYED=0,ATOM_STATUS_OBSOLETE=1,ATOM_STATUS_CHECKING=2,ATOM_STATUS_PULLING=3,ATOM_STATUS_ACTUAL=4,catchedId=Symbol("lom_atom_catched"),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},inheritsLoose=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e},throwOnAccess={get:function(t){throw t.valueOf()},ownKeys:function(t){throw t.valueOf()}},AtomWait=function(t){function e(){var e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Wait...";return e=t.call(this,o)||this,e.__proto__=new.target.prototype,e[catchedId]=!0,e}return inheritsLoose(e,t),e}(Error),Atom=function(){function t(t,e,o,i,n,s){this.status=ATOM_STATUS_OBSOLETE,this.cached=void 0,this._masters=null,this._slaves=null,this.field=t,this.key=i,this.host=e,this.isComponent=s||!1,this._normalize=n||defaultNormalize,this._context=o}return t.prototype.destroyed=function(t){return void 0===t?this.status===ATOM_STATUS_DESTROYED:!!t&&(this.status!==ATOM_STATUS_DESTROYED&&(this._masters&&(this._masters.forEach(disleadThis,this),this._masters=null),this._checkSlaves(),void 0!==this.host&&this._context.destroyHost(this),this.cached=void 0,this.status=ATOM_STATUS_DESTROYED,this.key=void 0),!0)},t.prototype.get=function(t){t||this._context.force?(this._context.force=!1,this._pullPush(void 0,!0)):this.actualize();var e=this._context.last;if(e&&(!e.isComponent||!this.isComponent)){var o=this._slaves;o||(this._context.unreap(this),o=this._slaves=new Set),o.add(e),e.addMaster(this)}return this.cached},t.prototype.set=function(t,e){var o=this._normalize(t,this.cached);if(this.cached===o)return o;if(void 0===o)return this.cached;var i=this._context;if(!e&&!i.force||o instanceof Error){i.force=!1,this.status=ATOM_STATUS_ACTUAL;var n=this.cached;this.cached=o instanceof Error?createMock(o):o,this._slaves&&this._slaves.forEach(obsoleteSlave),i.newValue(this,n,o),i.beginTransaction(),i.endTransaction()}else this.obsolete(),this.actualize(o);return this.cached},t.prototype.actualize=function(t){this.status!==ATOM_STATUS_ACTUAL&&(this.status===ATOM_STATUS_CHECKING&&(this._masters&&this._masters.forEach(actualizeMaster,this),this.status===ATOM_STATUS_CHECKING&&(this.status=ATOM_STATUS_ACTUAL)),this.status!==ATOM_STATUS_ACTUAL&&this._pullPush(t))},t.prototype._pullPush=function(t,e){this._masters&&this._masters.forEach(disleadThis,this);var o=void 0;this.status=ATOM_STATUS_PULLING;var i=this._context,n=i.last;i.last=this,i.beginTransaction();try{o=this._normalize(void 0===this.key?this.host[this.field](t,e,this.cached):this.host[this.field](this.key,t,e,this.cached),this.cached)}catch(t){void 0===t[catchedId]&&(t[catchedId]=!0,console.error(t.stack||t)),o=createMock(t)}if(i.last=n,this.status=ATOM_STATUS_ACTUAL,void 0!==o&&this.cached!==o){var s=this.cached;this.cached=o,this._slaves&&this._slaves.forEach(obsoleteSlave),this._context.newValue(this,s,o),i.endTransaction()}else i.endTransaction(!0)},t.prototype.dislead=function(t){var e=this._slaves;e&&(1===e.size?(this._slaves=null,this._context.proposeToReap(this)):e.delete(t))},t.prototype._checkSlaves=function(){this._slaves?this._slaves.forEach(checkSlave):this._context.proposeToPull(this)},t.prototype.check=function(){this.status===ATOM_STATUS_ACTUAL&&(this.status=ATOM_STATUS_CHECKING,this._checkSlaves())},t.prototype.obsolete=function(){this.status!==ATOM_STATUS_OBSOLETE&&(this.status=ATOM_STATUS_OBSOLETE,this._checkSlaves())},t.prototype.addMaster=function(t){this._masters||(this._masters=new Set),this._masters.add(t)},t.prototype.value=function(t,e){return void 0===t?this.get(e):this.set(t,e)},t}(),lastId=0,Context=function(){function t(){this.last=null,this.force=!1,this._logger=null,this._updating=[],this._reaping=new Set,this._atomMap=new WeakMap,this._pendCount=0}return t.prototype.getAtom=function(t,e,o,i,n){var s=void 0===o?t:getKey(o),r=this._atomMap.get(e);void 0===r&&(r=new Map,this._atomMap.set(e,r));var a=r.get(s);return void 0===a&&(a=new Atom(t,e,this,o,i,n),r.set(s,a)),a},t.prototype.destroyHost=function(t){var e=t.host,o=this._atomMap.get(e);void 0!==o&&(void 0!==e._destroyProp&&e._destroyProp(void 0===t.key?t.field:t.key,t.cached),o.delete(void 0===t.key?t.field:getKey(t.key)),0===o.size&&(void 0!==e._destroy&&e._destroy(),this._atomMap.delete(e)))},t.prototype.setLogger=function(t){this._logger=t},t.prototype.newValue=function(t,e,o){this._logger&&(o instanceof AtomWait?this._logger.pulling(t):o instanceof Error?this._logger.error(t,o):this._logger.newValue(t,e,o))},t.prototype.proposeToPull=function(t){this._updating.push(t)},t.prototype.proposeToReap=function(t){this._reaping.add(t)},t.prototype.unreap=function(t){this._reaping.delete(t)},t.prototype.beginTransaction=function(){this._pendCount++},t.prototype.run=function(){this.beginTransaction(),this.endTransaction()},t.prototype.endTransaction=function(t){if(1===this._pendCount&&!0!==t){var e=this._reaping,o=this._updating,i=0;do{for(var n=o.length,s=i;s<n;s++){var r=o[s];e.has(r)||r.destroyed()||r.actualize()}i=n}while(o.length>i);for(o.length=0;e.size>0;)e.forEach(reap)}this._pendCount--},t}(),defaultContext=new Context;mem.Wait=AtomWait,mem.key=memkey,mem.detached=detached,exports.Atom=Atom,exports.mem=mem,exports.memkey=memkey,exports.detached=detached,exports.force=force,exports.action=action,exports.defaultContext=defaultContext;
//# sourceMappingURL=lom_atom.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.lom_atom={})}(this,function(t){"use strict";function e(t){return new Proxy(t,k)}function i(t,e){if(t===e)return t;if(t instanceof Array&&e instanceof Array&&t.length===e.length){for(var i=0;i<t.length;i++)if(t[i]!==e[i])return t;return e}return t}function o(t){t.check()}function s(t){t.obsolete()}function n(t){t.dislead(this)}function r(t){this.status===g&&t.actualize()}function a(t,e,i){i.delete(t),t.destroyed(!0)}function h(t){return"string"!=typeof t&&"number"!=typeof t&&"function"!=typeof t&&t?"object"===w(t)?Object.keys(t).sort().map(function(e){return e+":"+JSON.stringify(t[e])}).join("."):JSON.stringify(t):t||""}function u(t,e,i,o,s){var n=e+"$";if(void 0===i.value)throw new TypeError(e+" is not an function (next?: V)");return t[n]=i.value,{enumerable:i.enumerable,configurable:i.configurable,value:function(t,e){return A.getAtom(n,this,void 0,o,s).value(t,e)}}}function c(t,e){return function(i){return void 0===i?t.call(this):(e.call(this,i),i)}}function l(t){return function(e){return void 0===e&&void 0!==t?t.call(this):e}}function f(t,e,i,o){var s=e+"$";if(void 0===t[s]){t[s]=void 0===i.get&&void 0===i.set?l(i.initializer):c(i.get,i.set);return{enumerable:i.enumerable,configurable:i.configurable,get:function(){return A.getAtom(s,this,void 0,o).get()},set:function(t){A.getAtom(s,this,void 0,o).set(t)}}}}function d(t,e,i,o){var s=i.value;if(void 0===s)throw new TypeError(e+" is not an function (rawKey: K, next?: V)");var n=e+"$";return t[n]=s,{enumerable:i.enumerable,configurable:i.configurable,value:function(t,e,i){return A.getAtom(n,this,t,o).value(e,i)}}}function p(){if(3===arguments.length)return d(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,i,o){return d(e,i,o,t)}}function _(){return A.force=!0,this}function v(t,e,i){return u(t,e,i,void 0,!0)}function y(){if(3===arguments.length)return void 0===arguments[2].value?f(arguments[0],arguments[1],arguments[2]):u(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,i,o){return void 0===o.value?f(e,i,o,t):u(e,i,o,t)}}var m=1,g=2,b=Symbol("lom_atom_catched"),w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e},k={get:function(t){throw t.valueOf()},ownKeys:function(t){throw t.valueOf()}},S=function(t){function e(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Wait...";return e=t.call(this,i)||this,e.__proto__=new.target.prototype,e[b]=!0,e}return x(e,t),e}(Error),E=function(){function t(t,e,o,s,n,r){this.status=m,this.cached=void 0,this._masters=null,this._slaves=null,this.field=t,this.key=s,this.host=e,this.isComponent=r||!1,this._normalize=n||i,this._context=o}return t.prototype.destroyed=function(t){return void 0===t?0===this.status:!!t&&(0!==this.status&&(this._masters&&(this._masters.forEach(n,this),this._masters=null),this._checkSlaves(),void 0!==this.host&&this._context.destroyHost(this),this.cached=void 0,this.status=0,this.key=void 0),!0)},t.prototype.get=function(t){t||this._context.force?(this._context.force=!1,this._pullPush(void 0,!0)):this.actualize();var e=this._context.last;if(e&&(!e.isComponent||!this.isComponent)){var i=this._slaves;i||(this._context.unreap(this),i=this._slaves=new Set),i.add(e),e.addMaster(this)}return this.cached},t.prototype.set=function(t,i){var o=this._normalize(t,this.cached);return this.cached===o?o:void 0===o?this.cached:(i||this._context.force||o instanceof Error?(this._context.force=!1,this.status=4,this._context.newValue(this,this.cached,o),this.cached=o instanceof Error?e(o):o,this._slaves&&this._slaves.forEach(s)):(this.obsolete(),this.actualize(o)),this.cached)},t.prototype.actualize=function(t){4!==this.status&&(this.status===g&&(this._masters&&this._masters.forEach(r,this),this.status===g&&(this.status=4)),4!==this.status&&this._pullPush(t))},t.prototype._pullPush=function(t,i){this._masters&&this._masters.forEach(n,this);var o=void 0;this.status=3;var r=this._context,a=r.last;r.last=this;try{o=this._normalize(void 0===this.key?this.host[this.field](t,i,this.cached):this.host[this.field](this.key,t,i,this.cached),this.cached)}catch(t){void 0===t[b]&&(t[b]=!0,console.error(t.stack||t)),o=e(t)}r.last=a,this.status=4,void 0!==o&&this.cached!==o&&(this._context.newValue(this,this.cached,o),this.cached=o,this._slaves&&this._slaves.forEach(s))},t.prototype.dislead=function(t){var e=this._slaves;e&&(1===e.size?(this._slaves=null,this._context.proposeToReap(this)):e.delete(t))},t.prototype._checkSlaves=function(){this._slaves?this._slaves.forEach(o):this._context.proposeToPull(this)},t.prototype.check=function(){4===this.status&&(this.status=g,this._checkSlaves())},t.prototype.obsolete=function(){this.status!==m&&(this.status=m,this._checkSlaves())},t.prototype.addMaster=function(t){this._masters||(this._masters=new Set),this._masters.add(t)},t.prototype.value=function(t,e){return void 0===t?this.get(e):this.set(t,e)},t}(),z="function"==typeof requestAnimationFrame?requestAnimationFrame:function(t){return setTimeout(t,0)},A=new(function(){function t(){var t=this;this.last=null,this.force=!1,this._logger=null,this._updating=[],this._reaping=new Set,this._scheduled=!1,this._atomMap=new WeakMap,this._run=function(){t._scheduled&&t.run()}}return t.prototype.getAtom=function(t,e,i,o,s){var n=this._atomMap.get(e);void 0===n&&(n=new Map,this._atomMap.set(e,n));var r=void 0===i?t:h(i),a=n.get(r);return void 0===a&&(a=new E(t,e,this,i,o,s),n.set(r,a)),a},t.prototype.destroyHost=function(t){var e=t.host,i=this._atomMap.get(e);void 0!==i&&(void 0!==e._destroyProp&&e._destroyProp(void 0===t.key?t.field:t.key,t.cached),i.delete(void 0===t.key?t.field:h(t.key)),0===i.size&&(void 0!==e._destroy&&e._destroy(),this._atomMap.delete(e)))},t.prototype.setLogger=function(t){this._logger=t},t.prototype.newValue=function(t,e,i){this._logger&&(i instanceof S?this._logger.pulling(t):i instanceof Error?this._logger.error(t,i):this._logger.newValue(t,e,i))},t.prototype.proposeToPull=function(t){this._updating.push(t),this._schedule()},t.prototype.proposeToReap=function(t){this._reaping.add(t),this._schedule()},t.prototype.unreap=function(t){this._reaping.delete(t)},t.prototype._schedule=function(){this._scheduled||(this._scheduled=!0,z(this._run))},t.prototype.run=function(){var t=this._reaping,e=this._updating,i=0;do{for(var o=e.length,s=i;s<o;s++){var n=e[s];t.has(n)||n.destroyed()||n.actualize()}i=o}while(e.length>i);for(e.length=0;t.size>0;)t.forEach(a);this._scheduled=!1},t}());y.Wait=S,y.key=p,y.detached=v,t.Atom=E,t.mem=y,t.memkey=p,t.detached=v,t.force=function(t,e,i){return{enumerable:i.enumerable,configurable:i.configurable,get:_}},t.defaultContext=A,t.animationFrame=z,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.lom_atom={})}(this,function(t){"use strict";function e(t){return new Proxy(t,T)}function i(t,e){if(t===e)return t;if(t instanceof Array&&e instanceof Array&&t.length===e.length){for(var i=0;i<t.length;i++)if(t[i]!==e[i])return t;return e}return t}function n(t){t.check()}function o(t){t.obsolete()}function s(t){t.dislead(this)}function r(t){this.status===b&&t.actualize()}function a(t,e,i){i.delete(t),t.slaves||t.destroyed(!0)}function u(t){return"string"==typeof t||"number"==typeof t?t:t?"function"==typeof t?(t.__id=t.__id||++z,t.__id):"object"===w(t)?Object.keys(t).sort().map(function(e){return e+":"+JSON.stringify(t[e])}).join("."):JSON.stringify(t):0}function c(t,e,i,n,o){var s=e+"$";if(void 0===i.value)throw new TypeError(e+" is not an function (next?: V)");return t[s]=i.value,{enumerable:i.enumerable,configurable:i.configurable,value:function(t,e){return M.getAtom(s,this,void 0,n,o).value(t,e)}}}function h(t,e){return function(i){return void 0===i?t.call(this):(e.call(this,i),i)}}function l(t){return function(e){return void 0===e&&void 0!==t?t.call(this):e}}function f(t,e,i,n){var o=e+"$";if(void 0===t[o]){t[o]=void 0===i.get&&void 0===i.set?l(i.initializer):h(i.get,i.set);return{enumerable:i.enumerable,configurable:i.configurable,get:function(){return M.getAtom(o,this,void 0,n).get()},set:function(t){M.getAtom(o,this,void 0,n).set(t)}}}}function d(t,e,i,n){var o=i.value;if(void 0===o)throw new TypeError(e+" is not an function (rawKey: K, next?: V)");var s=e+"$";return t[s]=o,{enumerable:i.enumerable,configurable:i.configurable,value:function(t,e,i){return M.getAtom(s,this,t,n).value(e,i)}}}function p(){if(3===arguments.length)return d(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,i,n){return d(e,i,n,t)}}function v(){return M.force=!0,this}function _(t,e,i){return c(t,e,i,void 0,!0)}function y(t,e){function i(){var i=void 0;switch(M.beginTransaction(),arguments.length){case 0:i=t[e]();break;case 1:i=t[e](arguments[0]);break;case 2:i=t[e](arguments[0],arguments[1]);break;case 3:i=t[e](arguments[0],arguments[1],arguments[2]);break;case 4:i=t[e](arguments[0],arguments[1],arguments[2],arguments[3]);break;case 5:i=t[e](arguments[0],arguments[1],arguments[2],arguments[3],arguments[4]);break;default:i=t[e].apply(t,arguments)}return M.endTransaction(),i}return i.displayName=e,i}function g(){if(3===arguments.length)return void 0===arguments[2].value?f(arguments[0],arguments[1],arguments[2]):c(arguments[0],arguments[1],arguments[2]);var t=arguments[0];return function(e,i,n){return void 0===n.value?f(e,i,n,t):c(e,i,n,t)}}var m=1,b=2,k=Symbol("lom_atom_catched"),w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e},T={get:function(t){throw t.valueOf()},ownKeys:function(t){throw t.valueOf()}},S=function(t){function e(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Wait...";return e=t.call(this,i)||this,e.__proto__=new.target.prototype,e[k]=!0,e}return x(e,t),e}(Error),E=function(){function t(t,e,n,o,s,r){this.status=m,this.cached=void 0,this._masters=null,this._slaves=null,this.field=t,this.key=o,this.host=e,this.isComponent=r||!1,this._normalize=s||i,this._context=n}return t.prototype.destroyed=function(t){return void 0===t?0===this.status:!!t&&(0!==this.status&&(this._masters&&(this._masters.forEach(s,this),this._masters=null),this._checkSlaves(),void 0!==this.host&&this._context.destroyHost(this),this.cached=void 0,this.status=0,this.key=void 0),!0)},t.prototype.get=function(t){t||this._context.force?(this._context.force=!1,this._pullPush(void 0,!0)):this.actualize();var e=this._context.last;if(e&&(!e.isComponent||!this.isComponent)){var i=this._slaves;i||(this._context.unreap(this),i=this._slaves=new Set),i.add(e),e.addMaster(this)}return this.cached},t.prototype.set=function(t,i){var n=this._normalize(t,this.cached);if(this.cached===n)return n;if(void 0===n)return this.cached;var s=this._context;if(!i&&!s.force||n instanceof Error){s.force=!1,this.status=4;var r=this.cached;this.cached=n instanceof Error?e(n):n,this._slaves&&this._slaves.forEach(o),s.newValue(this,r,n),s.beginTransaction(),s.endTransaction()}else this.obsolete(),this.actualize(n);return this.cached},t.prototype.actualize=function(t){4!==this.status&&(this.status===b&&(this._masters&&this._masters.forEach(r,this),this.status===b&&(this.status=4)),4!==this.status&&this._pullPush(t))},t.prototype._pullPush=function(t,i){this._masters&&this._masters.forEach(s,this);var n=void 0;this.status=3;var r=this._context,a=r.last;r.last=this,r.beginTransaction();try{n=this._normalize(void 0===this.key?this.host[this.field](t,i,this.cached):this.host[this.field](this.key,t,i,this.cached),this.cached)}catch(t){void 0===t[k]&&(t[k]=!0,console.error(t.stack||t)),n=e(t)}if(r.last=a,this.status=4,void 0!==n&&this.cached!==n){var u=this.cached;this.cached=n,this._slaves&&this._slaves.forEach(o),this._context.newValue(this,u,n),r.endTransaction()}else r.endTransaction(!0)},t.prototype.dislead=function(t){var e=this._slaves;e&&(1===e.size?(this._slaves=null,this._context.proposeToReap(this)):e.delete(t))},t.prototype._checkSlaves=function(){this._slaves?this._slaves.forEach(n):this._context.proposeToPull(this)},t.prototype.check=function(){4===this.status&&(this.status=b,this._checkSlaves())},t.prototype.obsolete=function(){this.status!==m&&(this.status=m,this._checkSlaves())},t.prototype.addMaster=function(t){this._masters||(this._masters=new Set),this._masters.add(t)},t.prototype.value=function(t,e){return void 0===t?this.get(e):this.set(t,e)},t}(),z=0,M=new(function(){function t(){this.last=null,this.force=!1,this._logger=null,this._updating=[],this._reaping=new Set,this._atomMap=new WeakMap,this._pendCount=0}return t.prototype.getAtom=function(t,e,i,n,o){var s=void 0===i?t:u(i),r=this._atomMap.get(e);void 0===r&&(r=new Map,this._atomMap.set(e,r));var a=r.get(s);return void 0===a&&(a=new E(t,e,this,i,n,o),r.set(s,a)),a},t.prototype.destroyHost=function(t){var e=t.host,i=this._atomMap.get(e);void 0!==i&&(void 0!==e._destroyProp&&e._destroyProp(void 0===t.key?t.field:t.key,t.cached),i.delete(void 0===t.key?t.field:u(t.key)),0===i.size&&(void 0!==e._destroy&&e._destroy(),this._atomMap.delete(e)))},t.prototype.setLogger=function(t){this._logger=t},t.prototype.newValue=function(t,e,i){this._logger&&(i instanceof S?this._logger.pulling(t):i instanceof Error?this._logger.error(t,i):this._logger.newValue(t,e,i))},t.prototype.proposeToPull=function(t){this._updating.push(t)},t.prototype.proposeToReap=function(t){this._reaping.add(t)},t.prototype.unreap=function(t){this._reaping.delete(t)},t.prototype.beginTransaction=function(){this._pendCount++},t.prototype.run=function(){this.beginTransaction(),this.endTransaction()},t.prototype.endTransaction=function(t){if(1===this._pendCount&&!0!==t){var e=this._reaping,i=this._updating,n=0;do{for(var o=i.length,s=n;s<o;s++){var r=i[s];e.has(r)||r.destroyed()||r.actualize()}n=o}while(i.length>n);for(i.length=0;e.size>0;)e.forEach(a)}this._pendCount--},t}());g.Wait=S,g.key=p,g.detached=_,t.Atom=E,t.mem=g,t.memkey=p,t.detached=_,t.force=function(t,e,i){return{enumerable:i.enumerable,configurable:i.configurable,get:v}},t.action=function(t,e,i){var n=e+"$";if(void 0===i.value)throw new TypeError(e+" is not an function (next?: V)");t[n]=i.value;var o=!1;return{enumerable:i.enumerable,configurable:i.configurable,get:function(){if(o)return this[n];o=!0;var t=y(this,n);return Object.defineProperty(this,e,{configurable:!0,get:function(){return t}}),o=!1,t}}},t.defaultContext=M,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=lom_atom.umd.js.map
{
"name": "lom_atom",
"version": "1.0.5",
"version": "1.0.6",
"description": "Observable state management",

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

@@ -129,9 +129,8 @@ // @flow

}
const context = this._context
// console.log('set', this.field, 'value', normalized)
if (force || this._context.force || normalized instanceof Error) {
this._context.force = false
if ((!force && !context.force) || normalized instanceof Error) {
context.force = false
this.status = ATOM_STATUS_ACTUAL
this._context.newValue(this, this.cached, normalized)
const oldValue = this.cached
this.cached = normalized instanceof Error

@@ -143,2 +142,5 @@ ? createMock(normalized)

}
context.newValue(this, oldValue, normalized)
context.beginTransaction()
context.endTransaction()
} else {

@@ -183,2 +185,3 @@ this.obsolete()

context.last = this
context.beginTransaction()
try {

@@ -204,3 +207,3 @@ newValue = this._normalize(

if (newValue !== undefined && this.cached !== newValue) {
this._context.newValue(this, this.cached, newValue)
const oldValue = this.cached
this.cached = newValue

@@ -210,2 +213,6 @@ if (this._slaves) {

}
this._context.newValue(this, oldValue, newValue)
context.endTransaction()
} else {
context.endTransaction(true)
}

@@ -212,0 +219,0 @@ }

@@ -17,13 +17,19 @@ // @flow

reaping.delete(atom)
atom.destroyed(true)
if (!atom.slaves) {
atom.destroyed(true)
}
}
export const animationFrame = typeof requestAnimationFrame === 'function'
? requestAnimationFrame
: (fn: () => void) => setTimeout(fn, 0)
function getKey(params: any): string | number | Function {
if (typeof params === 'string' || typeof params === 'number' || typeof params === 'function' || !params) {
return params || ''
let lastId = 0
function getKey(params: any): string | number {
if (typeof params === 'string' || typeof params === 'number') {
return params
}
if (!params) {
return 0
}
if (typeof params === 'function') {
params.__id = params.__id || ++lastId
return params.__id
}

@@ -45,11 +51,4 @@ return typeof params === 'object'

_reaping: Set<IAtomInt> = new Set()
_scheduled: boolean = false
_atomMap: WeakMap<IAtomHost, Map<mixed, IAtom<any>>> = new WeakMap()
_atomMap: WeakMap<IAtomHost, Map<string | number, IAtom<any>>> = new WeakMap()
_run: () => void = () => {
if (this._scheduled) {
this.run()
}
}
getAtom<V>(

@@ -62,2 +61,3 @@ field: string,

): IAtom<V> {
const k = key === undefined ? field : getKey(key)
let map = this._atomMap.get(host)

@@ -68,8 +68,9 @@ if (map === undefined) {

}
const k = key === undefined ? field : getKey(key)
let atom: IAtom<V> | void = map.get(k)
// let atom: IAtom<V> | void = host[k + '@']
if (atom === undefined) {
atom = new Atom(field, host, this, key, normalize, isComponent)
map.set(k, atom)
// host[field + '@'] = atom
// host[k + '@'] = atom
}

@@ -82,2 +83,9 @@

const host = atom.host
// host[(atom.key === undefined ? atom.field : getKey(atom.key)) + '@'] = undefined
//
// if (host._destroy !== undefined) {
// host._destroy()
// }
const map = this._atomMap.get(host)

@@ -88,2 +96,3 @@ if (map !== undefined) {

}
map.delete(atom.key === undefined ? atom.field : getKey(atom.key))

@@ -118,3 +127,2 @@ if (map.size === 0) {

this._updating.push(atom)
this._schedule()
}

@@ -125,3 +133,2 @@

this._reaping.add(atom)
this._schedule()
}

@@ -134,33 +141,37 @@

_pendCount = 0
_schedule() {
if (this._scheduled) {
return
}
this._scheduled = true
animationFrame(this._run)
beginTransaction() {
this._pendCount++
}
run() {
const reaping = this._reaping
const updating = this._updating
let start = 0
do {
const end = updating.length
this.beginTransaction()
this.endTransaction()
}
for (let i = start; i < end; i++) {
const atom: IAtomInt = updating[i]
if (!reaping.has(atom) && !atom.destroyed()) {
atom.actualize()
endTransaction(noUpdate?: boolean) {
if (this._pendCount === 1 && noUpdate !== true) {
const reaping = this._reaping
const updating = this._updating
let start = 0
do {
const end = updating.length
for (let i = start; i < end; i++) {
const atom: IAtomInt = updating[i]
if (!reaping.has(atom) && !atom.destroyed()) {
atom.actualize()
}
}
}
start = end
} while (updating.length > start)
updating.length = 0
start = end
} while (updating.length > start)
updating.length = 0
while (reaping.size > 0) {
reaping.forEach(reap)
while (reaping.size > 0) {
reaping.forEach(reap)
}
}
this._scheduled = false
this._pendCount--
}

@@ -167,0 +178,0 @@ }

// @flow
type s = string
export {default as Atom} from './Atom'
export {default as mem, memkey, detached, force} from './mem'
export {defaultContext, animationFrame} from './Context'
export {default as mem, memkey, detached, force, action} from './mem'
export {defaultContext} from './Context'

@@ -9,0 +7,0 @@ export type {

@@ -32,3 +32,5 @@ // @flow

unreap(atom: IAtomInt): void;
beginTransaction(): void;
run(): void;
endTransaction(noUpdate?: boolean): void;
}

@@ -35,0 +37,0 @@

@@ -180,2 +180,59 @@ // @flow

function createAction(t: Object, hk: string): (...args: any[]) => any {
function action() {
let result: mixed | void
defaultContext.beginTransaction()
switch (arguments.length) {
case 0: result = t[hk](); break
case 1: result = t[hk](arguments[0]); break
case 2: result = t[hk](arguments[0], arguments[1]); break
case 3: result = t[hk](arguments[0], arguments[1], arguments[2]); break
case 4: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3]); break
case 5: result = t[hk](arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break
default: result = t[hk].apply(t, arguments)
}
defaultContext.endTransaction()
return result
}
action.displayName = hk
return action
}
export function action<V, P: Object>(
proto: P,
field: string,
descr: TypedPropertyDescriptor<*>
): TypedPropertyDescriptor<*> {
const hk = `${field}$`
if (descr.value === undefined) {
throw new TypeError(`${field} is not an function (next?: V)`)
}
proto[hk] = descr.value
let definingProperty = false
return {
enumerable: descr.enumerable,
configurable: descr.configurable,
get() {
if (definingProperty) {
return this[hk]
}
definingProperty = true
const actionFn = createAction(this, hk)
Object.defineProperty(this, field, {
configurable: true,
get() {
return actionFn
}
})
definingProperty = false
return actionFn
}
}
}
declare function mem<V, P: Object>(normalize: INormalize<V>): () => IMemProp<V, P>

@@ -182,0 +239,0 @@ declare function mem<V, P: Object>(

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