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 3.0.10 to 3.0.11

5

CHANGELOG.md

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

<a name="3.0.11"></a>
## [3.0.11](https://github.com/zerkalica/lom_atom/compare/v3.0.10...v3.0.11) (2017-12-06)
<a name="3.0.10"></a>

@@ -7,0 +12,0 @@ ## [3.0.10](https://github.com/zerkalica/lom_atom/compare/v3.0.9...v3.0.10) (2017-12-03)

63

dist/lom_atom.es.js

@@ -30,4 +30,6 @@ function _defineProperties(target, props) {

var catchedId = Symbol('lom_atom_catched');
var origId = Symbol('orig_error');
var ATOM_FORCE_CACHE = 1;
var ATOM_FORCE_ASYNC = 2;
var AtomWait =

@@ -69,2 +71,15 @@ /*#__PURE__*/

};
var origId = Symbol('orig_error');
var throwOnAccess = {
get: function get(target, key) {
if (key === origId) return target.valueOf();
throw target.valueOf();
},
ownKeys: function ownKeys(target) {
throw target.valueOf();
}
};
function proxify(v) {
return new Proxy(v, throwOnAccess);
}

@@ -121,12 +136,2 @@ var handlers = new Map([[Array, function arrayHandler(target, source, stack) {

var throwOnAccess = {
get: function get(target, key) {
if (key === origId) return target.valueOf();
throw target.valueOf();
},
ownKeys: function ownKeys(target) {
throw target.valueOf();
}
};
function checkSlave(slave) {

@@ -216,3 +221,3 @@ slave.check();

if (forceCache === true) {
if (forceCache === ATOM_FORCE_CACHE) {
if (next === undefined) {

@@ -252,3 +257,11 @@ this.reset();

return this.current;
var current = this.current;
if (current instanceof Error) {
if (forceCache === ATOM_FORCE_ASYNC) return proxify(current); // return proxify((current: any))
throw current;
}
return current;
};

@@ -296,3 +309,3 @@

var prev = this.current;
var next = nextRaw instanceof Error ? nextRaw[origId] ? nextRaw : new Proxy(nextRaw, throwOnAccess) : conform(nextRaw, prev, this.isComponent);
var next = nextRaw instanceof Error ? nextRaw[origId] || nextRaw : conform(nextRaw, prev, this.isComponent);

@@ -406,4 +419,2 @@ if (prev !== next) {

this.current = null;
this.isCacheForce = false;
this.isDeepReset = false;
this._logger = undefined;

@@ -469,3 +480,3 @@ this._updating = [];

// }
logger.newValue(atom, from instanceof Error && from[origId] ? from[origId] : from, to instanceof Error && to[origId] ? to[origId] : to);
logger.newValue(atom, from, to);
} catch (error) {

@@ -597,2 +608,4 @@ console.error(error);

}
} catch (e) {
if (!(e instanceof AtomWait)) throw e;
} finally {

@@ -646,2 +659,4 @@ context.endTransaction(oldNamespace);

}
} catch (e) {
if (!(e instanceof AtomWait)) throw e;
} finally {

@@ -717,3 +732,3 @@ context.endTransaction(oldNamespace);

if (force) {
atom.status = 5; // atom.reset()
atom.status = ATOM_STATUS_OBSOLETE; // atom.reset()
}

@@ -743,3 +758,3 @@

var isForceCache = false;
var isForceCache = 0;

@@ -856,3 +871,3 @@ function mem(proto, name, descr, deepReset) {

function cache(data) {
isForceCache = false;
isForceCache = 0;
return data;

@@ -864,6 +879,12 @@ }

get: function get() {
isForceCache = true;
isForceCache = 1;
return cache;
}
},
async: {
get: function get() {
isForceCache = 2;
return cache;
}
},
manual: {

@@ -870,0 +891,0 @@ value: memManual

@@ -34,4 +34,6 @@ 'use strict';

var catchedId = Symbol('lom_atom_catched');
var origId = Symbol('orig_error');
var ATOM_FORCE_CACHE = 1;
var ATOM_FORCE_ASYNC = 2;
var AtomWait =

@@ -73,2 +75,15 @@ /*#__PURE__*/

};
var origId = Symbol('orig_error');
var throwOnAccess = {
get: function get(target, key) {
if (key === origId) return target.valueOf();
throw target.valueOf();
},
ownKeys: function ownKeys(target) {
throw target.valueOf();
}
};
function proxify(v) {
return new Proxy(v, throwOnAccess);
}

@@ -125,12 +140,2 @@ var handlers = new Map([[Array, function arrayHandler(target, source, stack) {

var throwOnAccess = {
get: function get(target, key) {
if (key === origId) return target.valueOf();
throw target.valueOf();
},
ownKeys: function ownKeys(target) {
throw target.valueOf();
}
};
function checkSlave(slave) {

@@ -220,3 +225,3 @@ slave.check();

if (forceCache === true) {
if (forceCache === ATOM_FORCE_CACHE) {
if (next === undefined) {

@@ -256,3 +261,11 @@ this.reset();

return this.current;
var current = this.current;
if (current instanceof Error) {
if (forceCache === ATOM_FORCE_ASYNC) return proxify(current); // return proxify((current: any))
throw current;
}
return current;
};

@@ -300,3 +313,3 @@

var prev = this.current;
var next = nextRaw instanceof Error ? nextRaw[origId] ? nextRaw : new Proxy(nextRaw, throwOnAccess) : conform(nextRaw, prev, this.isComponent);
var next = nextRaw instanceof Error ? nextRaw[origId] || nextRaw : conform(nextRaw, prev, this.isComponent);

@@ -410,4 +423,2 @@ if (prev !== next) {

this.current = null;
this.isCacheForce = false;
this.isDeepReset = false;
this._logger = undefined;

@@ -473,3 +484,3 @@ this._updating = [];

// }
logger.newValue(atom, from instanceof Error && from[origId] ? from[origId] : from, to instanceof Error && to[origId] ? to[origId] : to);
logger.newValue(atom, from, to);
} catch (error) {

@@ -601,2 +612,4 @@ console.error(error);

}
} catch (e) {
if (!(e instanceof AtomWait)) throw e;
} finally {

@@ -650,2 +663,4 @@ context.endTransaction(oldNamespace);

}
} catch (e) {
if (!(e instanceof AtomWait)) throw e;
} finally {

@@ -721,3 +736,3 @@ context.endTransaction(oldNamespace);

if (force) {
atom.status = 5; // atom.reset()
atom.status = ATOM_STATUS_OBSOLETE; // atom.reset()
}

@@ -747,3 +762,3 @@

var isForceCache = false;
var isForceCache = 0;

@@ -860,3 +875,3 @@ function mem(proto, name, descr, deepReset) {

function cache(data) {
isForceCache = false;
isForceCache = 0;
return data;

@@ -868,6 +883,12 @@ }

get: function get() {
isForceCache = true;
isForceCache = 1;
return cache;
}
},
async: {
get: function get() {
isForceCache = 2;
return cache;
}
},
manual: {

@@ -874,0 +895,0 @@ value: memManual

@@ -36,4 +36,6 @@ (function (global, factory) {

var catchedId = Symbol('lom_atom_catched');
var origId = Symbol('orig_error');
var ATOM_FORCE_CACHE = 1;
var ATOM_FORCE_ASYNC = 2;
var AtomWait =

@@ -75,2 +77,15 @@ /*#__PURE__*/

};
var origId = Symbol('orig_error');
var throwOnAccess = {
get: function get(target, key) {
if (key === origId) return target.valueOf();
throw target.valueOf();
},
ownKeys: function ownKeys(target) {
throw target.valueOf();
}
};
function proxify(v) {
return new Proxy(v, throwOnAccess);
}

@@ -127,12 +142,2 @@ var handlers = new Map([[Array, function arrayHandler(target, source, stack) {

var throwOnAccess = {
get: function get(target, key) {
if (key === origId) return target.valueOf();
throw target.valueOf();
},
ownKeys: function ownKeys(target) {
throw target.valueOf();
}
};
function checkSlave(slave) {

@@ -222,3 +227,3 @@ slave.check();

if (forceCache === true) {
if (forceCache === ATOM_FORCE_CACHE) {
if (next === undefined) {

@@ -258,3 +263,11 @@ this.reset();

return this.current;
var current = this.current;
if (current instanceof Error) {
if (forceCache === ATOM_FORCE_ASYNC) return proxify(current); // return proxify((current: any))
throw current;
}
return current;
};

@@ -302,3 +315,3 @@

var prev = this.current;
var next = nextRaw instanceof Error ? nextRaw[origId] ? nextRaw : new Proxy(nextRaw, throwOnAccess) : conform(nextRaw, prev, this.isComponent);
var next = nextRaw instanceof Error ? nextRaw[origId] || nextRaw : conform(nextRaw, prev, this.isComponent);

@@ -412,4 +425,2 @@ if (prev !== next) {

this.current = null;
this.isCacheForce = false;
this.isDeepReset = false;
this._logger = undefined;

@@ -475,3 +486,3 @@ this._updating = [];

// }
logger.newValue(atom, from instanceof Error && from[origId] ? from[origId] : from, to instanceof Error && to[origId] ? to[origId] : to);
logger.newValue(atom, from, to);
} catch (error) {

@@ -603,2 +614,4 @@ console.error(error);

}
} catch (e) {
if (!(e instanceof AtomWait)) throw e;
} finally {

@@ -652,2 +665,4 @@ context.endTransaction(oldNamespace);

}
} catch (e) {
if (!(e instanceof AtomWait)) throw e;
} finally {

@@ -723,3 +738,3 @@ context.endTransaction(oldNamespace);

if (force) {
atom.status = 5; // atom.reset()
atom.status = ATOM_STATUS_OBSOLETE; // atom.reset()
}

@@ -749,3 +764,3 @@

var isForceCache = false;
var isForceCache = 0;

@@ -862,3 +877,3 @@ function mem(proto, name, descr, deepReset) {

function cache(data) {
isForceCache = false;
isForceCache = 0;
return data;

@@ -870,6 +885,12 @@ }

get: function get() {
isForceCache = true;
isForceCache = 1;
return cache;
}
},
async: {
get: function get() {
isForceCache = 2;
return cache;
}
},
manual: {

@@ -876,0 +897,0 @@ value: memManual

{
"name": "lom_atom",
"version": "3.0.10",
"version": "3.0.11",
"description": "Alternative implementation of eigenmethod mol_atom state management library",

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

@@ -115,2 +115,6 @@ # lom_atom

}
@mem todosWithUserParallel() {
return {todos: mem.async(this.todos), user: mem.async(this.user)}
}
}

@@ -125,2 +129,3 @@ const list = new TodoList()

* ``` @mem.manual get user() {...} ``` - exclude user from deep reset. ``` mem.reset(list.todosWithUser) ``` resets todos but not user. If you want to reset user, use helper directly on user: ``` mem.cache(list.user) ```
* ``` mem.async(this.todos) ``` - initiate parallel loading todos and user (wrap error in proxy, do not throw error if data are fetching).

@@ -127,0 +132,0 @@ ## Key-value

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

catchedId,
origId,
ATOM_FORCE_NONE, ATOM_FORCE_CACHE, ATOM_FORCE_ASYNC,
ATOM_STATUS_DESTROYED,

@@ -13,2 +13,3 @@ ATOM_STATUS_DEEP_RESET,

import type {
IAtomForce,
IAtom,

@@ -22,16 +23,5 @@ IAtomInt,

import {AtomWait} from './utils'
import {AtomWait, origId, proxify} from './utils'
import conform from './conform'
const throwOnAccess = {
get<V: Object>(target: Error, key: string): V {
if (key === origId) return (target: Object).valueOf()
throw target.valueOf()
},
ownKeys(target: Error): string[] {
throw target.valueOf()
}
}
function checkSlave(slave: IAtomInt) {

@@ -59,3 +49,3 @@ slave.check()

current: V | Error | void
current: V | Error
_next: V | Error | void

@@ -92,3 +82,3 @@ _suggested: V | Error | void

this._context = context
this.current = undefined
this.current = (undefined: any)
this._next = undefined

@@ -129,3 +119,3 @@ this._suggested = undefined

this._context.destroyHost(this)
this.current = undefined
this.current = (undefined: any)
this._next = undefined

@@ -145,5 +135,5 @@ this._suggested = undefined

value(next?: V | Error, forceCache?: boolean): V {
value(next?: V | Error, forceCache?: IAtomForce): V {
const context = this._context
if (forceCache === true) {
if (forceCache === ATOM_FORCE_CACHE) {
if (next === undefined) {

@@ -183,4 +173,10 @@ this.reset()

}
const current: V | Error = this.current
if (current instanceof Error) {
if (forceCache === ATOM_FORCE_ASYNC) return proxify((current: any))
// return proxify((current: any))
throw current
}
return (this.current: any)
return current
}

@@ -226,3 +222,3 @@

const next: V | Error = nextRaw instanceof Error
? ((nextRaw: Object)[origId] ? nextRaw : new Proxy(nextRaw, throwOnAccess))
? (nextRaw: Object)[origId] || nextRaw
: conform(nextRaw, prev, this.isComponent)

@@ -229,0 +225,0 @@

@@ -9,3 +9,3 @@ // @flow

} from './interfaces'
import {origId, ATOM_STATUS_DESTROYED} from './interfaces'
import {ATOM_STATUS_DESTROYED} from './interfaces'
import {scheduleNative} from './utils'

@@ -22,4 +22,2 @@

current: ?IAtomInt = null
isCacheForce: boolean = false
isDeepReset: boolean = false

@@ -72,7 +70,3 @@ _logger: ILogger | void = undefined

// }
logger.newValue(
atom,
from instanceof Error && (from: Object)[origId] ? (from: Object)[origId] : from,
to instanceof Error && (to: Object)[origId] ? (to: Object)[origId] : to
)
logger.newValue(atom, from, to)
} catch (error) {

@@ -79,0 +73,0 @@ console.error(error)

// @flow
import type {TypedPropertyDescriptor, IContext} from '../interfaces'
import {getId, setFunctionName} from '../utils'
import {getId, setFunctionName, AtomWait} from '../utils'
import {defaultContext} from '../Context'

@@ -23,2 +23,4 @@

}
} catch(e) {
if (!(e instanceof AtomWait)) throw e
} finally {

@@ -51,2 +53,4 @@ context.endTransaction(oldNamespace)

}
} catch(e) {
if (!(e instanceof AtomWait)) throw e
} finally {

@@ -53,0 +57,0 @@ context.endTransaction(oldNamespace)

// @flow
import {ATOM_STATUS_OBSOLETE} from '../interfaces'
import type {IAtom, TypedPropertyDescriptor} from '../interfaces'

@@ -30,3 +31,3 @@ import Atom from '../Atom'

if (force) {
atom.status =5
atom.status = ATOM_STATUS_OBSOLETE
// atom.reset()

@@ -33,0 +34,0 @@ }

@@ -28,3 +28,3 @@ // @flow

let isForceCache = false
let isForceCache = 0

@@ -161,3 +161,3 @@ function mem<V>(

function cache<V>(data: V): V {
isForceCache = false
isForceCache = 0
return data

@@ -169,6 +169,12 @@ }

get<V>(): (v: V) => V {
isForceCache = true
isForceCache = 1
return cache
}
}: any),
async: ({
get<V>(): (v: V) => V {
isForceCache = 2
return cache
}
}: any),
manual: { value: memManual },

@@ -188,2 +194,3 @@ key: { value: memkey }

cache<V>(v: V): V;
async<V>(v: V): V;

@@ -190,0 +197,0 @@ key: IMemKey;

@@ -37,20 +37,26 @@ // @flow

export const ATOM_STATUS_DESTROYED = 0
export const ATOM_STATUS_OBSOLETE = 1
export const ATOM_STATUS_CHECKING = 2
export const ATOM_STATUS_PULLING = 3
export const ATOM_STATUS_ACTUAL = 4
export const ATOM_STATUS_DEEP_RESET = 5
export const ATOM_STATUS_DESTROYED: 0 = 0
export const ATOM_STATUS_OBSOLETE: 1 = 1
export const ATOM_STATUS_CHECKING: 2 = 2
export const ATOM_STATUS_PULLING: 3 = 3
export const ATOM_STATUS_ACTUAL: 4 = 4
export const ATOM_STATUS_DEEP_RESET: 5 = 5
export const catchedId = Symbol('lom_atom_catched')
export const origId = Symbol('orig_error')
export type IAtomStatus = typeof ATOM_STATUS_OBSOLETE
| typeof ATOM_STATUS_CHECKING | typeof ATOM_STATUS_PULLING | typeof ATOM_STATUS_ACTUAL
| typeof ATOM_STATUS_DEEP_RESET | typeof ATOM_STATUS_DESTROYED
export const ATOM_FORCE_NONE: 0 = 0
export const ATOM_FORCE_CACHE: 1 = 1
export const ATOM_FORCE_ASYNC: 2 = 2
export type IAtomForce = typeof ATOM_FORCE_NONE | typeof ATOM_FORCE_CACHE | typeof ATOM_FORCE_ASYNC
export interface IAtom<V> {
status: IAtomStatus;
current: V | Error | void;
current: V | Error;
+field: string;
+displayName: string;
value(v?: V | Error, forceCache?: boolean): V;
value(v?: V | Error, forceCache?: IAtomForce): V;
reset(): void;

@@ -57,0 +63,0 @@ destructor(): void;

@@ -26,1 +26,18 @@ // @flow

: (handler: () => void) => setTimeout(handler, 16)
export const origId = Symbol('orig_error')
const throwOnAccess = {
get<V: Object>(target: Error, key: string): V {
if (key === origId) return (target: Object).valueOf()
throw target.valueOf()
},
ownKeys(target: Error): string[] {
throw target.valueOf()
}
}
export function proxify<V>(v: V): V {
return (new Proxy(v, (throwOnAccess: any)): any)
}

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