Comparing version 2.6.0 to 2.6.1
@@ -11,2 +11,4 @@ "use strict"; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _dotPropImmutable = _interopRequireDefault(require("@invrs/dot-prop-immutable")); | ||
@@ -18,45 +20,45 @@ | ||
// Constants | ||
var opEventRegex = /(before|after)(delete|get|merge|set|toggle|update)/i; | ||
var opEventRegex = /^(before|after)(delete|get|merge|set|toggle|update)(:?)/i; | ||
exports.opEventRegex = opEventRegex; | ||
// Helpers | ||
function parseArgs(event, prop, listener) { | ||
if (typeof event === "function") { | ||
return ["afterupdate", undefined, event]; | ||
} | ||
function parseArgs() { | ||
var event = "afterupdate", | ||
eventMatch, | ||
listener, | ||
prop; | ||
var isEvent = typeof event === "string" && event.match(opEventRegex); | ||
if (isEvent) { | ||
event = event.toLowerCase(); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
if (isEvent && prop && listener) { | ||
var newEvent = eventFromProp(event, prop); | ||
return [newEvent, prop, listener]; | ||
} | ||
for (var _i = 0; _i < args.length; _i++) { | ||
var arg = args[_i]; | ||
var type = (0, _typeof2.default)(arg); | ||
if (isEvent && listener) { | ||
return [event, undefined, listener]; | ||
} | ||
if (type === "string") { | ||
var match = arg.match(opEventRegex); | ||
if (isEvent && prop) { | ||
return [event, undefined, prop]; | ||
if (match) { | ||
eventMatch = match; | ||
event = arg; | ||
} else { | ||
prop = arg; | ||
} | ||
} else if (type === "function") { | ||
listener = arg; | ||
} | ||
} | ||
if (isEvent && !prop) { | ||
return [event]; | ||
if (event) { | ||
event = event.toLowerCase(); | ||
} | ||
if (event && prop) { | ||
var _newEvent = eventFromProp("afterupdate", event); | ||
var needsProp = !eventMatch || !eventMatch[3]; | ||
return [_newEvent, event, prop]; | ||
if (event && prop && needsProp) { | ||
event = eventFromProp(event, prop); | ||
} | ||
if (event) { | ||
var _newEvent2 = eventFromProp("afterupdate", event); | ||
return [_newEvent2, event]; | ||
} | ||
return [event, prop, listener]; | ||
} | ||
@@ -63,0 +65,0 @@ |
@@ -334,9 +334,6 @@ "use strict"; | ||
return _context4.abrupt("return", new _promise.default(function (resolve) { | ||
var unsub = (0, _get2.default)(DotStore.prototype.__proto__ || (0, _getPrototypeOf.default)(DotStore.prototype), "on", _this2).call(_this2, event, (0, _changed.changeListener)({ | ||
listener: function listener(options) { | ||
resolve(options); | ||
unsub(); | ||
}, | ||
prop: prop | ||
})); | ||
var unsub = _this2.on(event, prop, function (options) { | ||
resolve(options); | ||
unsub(); | ||
}); | ||
})); | ||
@@ -428,3 +425,3 @@ | ||
var _parseArgs7 = (0, _args6.parseArgs)(event, undefined, listener); | ||
var _parseArgs7 = (0, _args6.parseArgs)(event, listener); | ||
@@ -431,0 +428,0 @@ var _parseArgs8 = (0, _slicedToArray2.default)(_parseArgs7, 3); |
{ | ||
"name": "dot-store", | ||
"version": "2.6.0", | ||
"version": "2.6.1", | ||
"description": "Like Redux, but easy", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
55925