Comparing version 4.9.0 to 5.0.0
293
dist/core.js
@@ -20,34 +20,66 @@ "use strict"; | ||
var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _dotEvent.default(); | ||
events.storeQueue = Promise.resolve(); | ||
events.setName("store").setOps("delete", "merge", "set", "time", "toggle"); | ||
events.withOp("delete").onAny(del); | ||
events.withOp("merge").onAny(merge); | ||
events.withOp("set").onAny(set); | ||
events.withOp("time").onAny(time); | ||
events.get = get.bind({ | ||
events: events | ||
}); | ||
return events; | ||
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var store = { | ||
queue: Promise.resolve(), | ||
state: state | ||
}; | ||
var bind = { | ||
events: events, | ||
store: store | ||
}; | ||
events.setOps("store"); | ||
store.delete = del.bind(bind); | ||
store.get = get.bind(bind); | ||
store.merge = merge.bind(bind); | ||
store.set = set.bind(bind); | ||
store.setState = setState.bind(bind); | ||
store.time = time.bind(bind); | ||
return store; | ||
} | ||
function get(props) { | ||
var events = this.events; | ||
var state = events.state; | ||
var state = this.state, | ||
store = this.store; | ||
if (props) { | ||
return _dotPropImmutable.default.get(state, props); | ||
return _dotPropImmutable.default.get(state || store.state, props); | ||
} else { | ||
return state; | ||
return state || store.state; | ||
} | ||
} | ||
function del(_ref) { | ||
var event = _ref.event, | ||
store = _ref.store; | ||
var props = event.props; | ||
var state = store.state; | ||
store.setState(_dotPropImmutable.default.delete(state, props)); | ||
function del(_x) { | ||
return _del.apply(this, arguments); | ||
} | ||
function merge(_x) { | ||
function _del() { | ||
_del = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee(props) { | ||
var events, store, state; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
events = this.events, store = this.store; | ||
state = store.state; | ||
store.setState(_dotPropImmutable.default.delete(state, props)); | ||
_context.next = 5; | ||
return emitStore({ | ||
events: events, | ||
props: props, | ||
state: state | ||
}); | ||
case 5: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
return _del.apply(this, arguments); | ||
} | ||
function merge(_x2, _x3) { | ||
return _merge.apply(this, arguments); | ||
@@ -59,13 +91,14 @@ } | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee(_ref2) { | ||
var event, store, value, args, props, state; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
_regenerator.default.mark(function _callee2(props, value) { | ||
var events, store, state; | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
event = _ref2.event, store = _ref2.store, value = _ref2.value; | ||
_context.next = 3; | ||
events = this.events, store = this.store; | ||
_context2.next = 3; | ||
return enqueue({ | ||
event: event, | ||
fn: merge, | ||
events: events, | ||
fn: set, | ||
props: props, | ||
store: store, | ||
@@ -76,20 +109,25 @@ value: value | ||
case 3: | ||
if (!_context.sent) { | ||
_context.next = 5; | ||
if (!_context2.sent) { | ||
_context2.next = 5; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
return _context2.abrupt("return"); | ||
case 5: | ||
args = event.args, props = event.props; | ||
state = store.state; | ||
store.setState(_dotPropImmutable.default.merge(state, props, value || args[0])); | ||
store.setState(_dotPropImmutable.default.merge(state, props, value)); | ||
_context2.next = 9; | ||
return emitStore({ | ||
events: events, | ||
props: props, | ||
state: state | ||
}); | ||
case 8: | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
}, _callee2, this); | ||
})); | ||
@@ -99,3 +137,3 @@ return _merge.apply(this, arguments); | ||
function set(_x2) { | ||
function set(_x4, _x5) { | ||
return _set.apply(this, arguments); | ||
@@ -107,13 +145,14 @@ } | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee2(_ref3) { | ||
var event, store, value, args, props, state; | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
_regenerator.default.mark(function _callee3(props, value) { | ||
var events, store, state; | ||
return _regenerator.default.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
event = _ref3.event, store = _ref3.store, value = _ref3.value; | ||
_context2.next = 3; | ||
events = this.events, store = this.store; | ||
_context3.next = 3; | ||
return enqueue({ | ||
event: event, | ||
events: events, | ||
fn: set, | ||
props: props, | ||
store: store, | ||
@@ -124,20 +163,25 @@ value: value | ||
case 3: | ||
if (!_context2.sent) { | ||
_context2.next = 5; | ||
if (!_context3.sent) { | ||
_context3.next = 5; | ||
break; | ||
} | ||
return _context2.abrupt("return"); | ||
return _context3.abrupt("return"); | ||
case 5: | ||
args = event.args, props = event.props; | ||
state = store.state; | ||
store.setState(_dotPropImmutable.default.set(state, props, value || args[0])); | ||
store.setState(_dotPropImmutable.default.set(state, props, value)); | ||
_context3.next = 9; | ||
return emitStore({ | ||
events: events, | ||
props: props, | ||
state: state | ||
}); | ||
case 8: | ||
case 9: | ||
case "end": | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
}, _callee3, this); | ||
})); | ||
@@ -147,11 +191,33 @@ return _set.apply(this, arguments); | ||
function time(_ref4) { | ||
var event = _ref4.event, | ||
store = _ref4.store; | ||
var props = event.props; | ||
var state = store.state; | ||
store.setState(_dotPropImmutable.default.set(state, props, new Date().getTime())); | ||
function setState(_x6) { | ||
return _setState.apply(this, arguments); | ||
} | ||
function enqueue(_x3) { | ||
function _setState() { | ||
_setState = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee4(state) { | ||
var store; | ||
return _regenerator.default.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
store = this.store; | ||
store.state = state; | ||
case 2: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
})); | ||
return _setState.apply(this, arguments); | ||
} | ||
function time(props) { | ||
return set.call(this, props, new Date().getTime()); | ||
} | ||
function enqueue(_x7) { | ||
return _enqueue.apply(this, arguments); | ||
@@ -163,72 +229,95 @@ } | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee4(_ref5) { | ||
var event, fn, store, value, args; | ||
return _regenerator.default.wrap(function _callee4$(_context4) { | ||
_regenerator.default.mark(function _callee6(_ref) { | ||
var events, fn, props, store, value; | ||
return _regenerator.default.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
event = _ref5.event, fn = _ref5.fn, store = _ref5.store, value = _ref5.value; | ||
events = _ref.events, fn = _ref.fn, props = _ref.props, store = _ref.store, value = _ref.value; | ||
if (!value) { | ||
_context4.next = 3; | ||
if (!(typeof value !== "function")) { | ||
_context6.next = 3; | ||
break; | ||
} | ||
return _context4.abrupt("return"); | ||
return _context6.abrupt("return"); | ||
case 3: | ||
args = event.args; | ||
if (!(typeof args[0] === "function")) { | ||
_context4.next = 9; | ||
break; | ||
} | ||
store.storeQueue = store.storeQueue.then( | ||
store.queue = store.queue.then( | ||
/*#__PURE__*/ | ||
(0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee3() { | ||
return _regenerator.default.wrap(function _callee3$(_context3) { | ||
_regenerator.default.mark(function _callee5() { | ||
return _regenerator.default.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context3.t0 = fn; | ||
_context3.t1 = event; | ||
_context3.t2 = store; | ||
_context3.next = 5; | ||
return args[0](); | ||
_context5.t0 = fn; | ||
_context5.t1 = { | ||
events: events, | ||
store: store | ||
}; | ||
_context5.t2 = props; | ||
_context5.next = 5; | ||
return value(store); | ||
case 5: | ||
_context3.t3 = _context3.sent; | ||
_context3.t4 = { | ||
event: _context3.t1, | ||
store: _context3.t2, | ||
value: _context3.t3 | ||
}; | ||
_context3.next = 9; | ||
return (0, _context3.t0)(_context3.t4); | ||
_context5.t3 = _context5.sent; | ||
_context5.next = 8; | ||
return _context5.t0.call.call(_context5.t0, _context5.t1, _context5.t2, _context5.t3); | ||
case 9: | ||
case 8: | ||
case "end": | ||
return _context3.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
}, _callee5, this); | ||
}))); | ||
_context4.next = 8; | ||
return store.storeQueue; | ||
_context6.next = 6; | ||
return store.queue; | ||
case 8: | ||
return _context4.abrupt("return", true); | ||
case 6: | ||
return _context6.abrupt("return", true); | ||
case 9: | ||
case 7: | ||
case "end": | ||
return _context4.stop(); | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
}, _callee6, this); | ||
})); | ||
return _enqueue.apply(this, arguments); | ||
} | ||
function emitStore(_x8) { | ||
return _emitStore.apply(this, arguments); | ||
} | ||
function _emitStore() { | ||
_emitStore = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee7(_ref2) { | ||
var events, props, state; | ||
return _regenerator.default.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
events = _ref2.events, props = _ref2.props, state = _ref2.state; | ||
_context7.next = 3; | ||
return events.store(props, { | ||
prevGet: get.bind({ | ||
events: events, | ||
state: state | ||
}) | ||
}); | ||
case 3: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee7, this); | ||
})); | ||
return _emitStore.apply(this, arguments); | ||
} | ||
//# sourceMappingURL=core.js.map |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "4.9.0", | ||
"version": "5.0.0", | ||
"description": "Event emitter & store that promotes decoupled and readable code", | ||
@@ -18,0 +18,0 @@ "keywords": [ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
20098
274
1