@pagedip/lib-observer
Advanced tools
Comparing version 1.0.0 to 1.0.1-rc.0
214
index.js
@@ -11,198 +11,6 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
var _Object$assign; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
var defineProperty = function (obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
}; | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
var _Object$assign; | ||
function Event(target, type, data) { | ||
@@ -221,12 +29,12 @@ if (data) Object.assign(this, data); | ||
Object.assign(Event.prototype, (_Object$assign = {}, defineProperty(_Object$assign, "__pagedip_observer_event__", true), defineProperty(_Object$assign, "stopPropagation", function stopPropagation() { | ||
Object.assign(Event.prototype, (_Object$assign = {}, _defineProperty(_Object$assign, "__pagedip_observer_event__", true), _defineProperty(_Object$assign, "stopPropagation", function stopPropagation() { | ||
this.bubbles = false; | ||
return this; | ||
}), defineProperty(_Object$assign, "stopImmediatePropagation", function stopImmediatePropagation() { | ||
}), _defineProperty(_Object$assign, "stopImmediatePropagation", function stopImmediatePropagation() { | ||
this.stopped = true; | ||
return this; | ||
}), defineProperty(_Object$assign, "preventDefault", function preventDefault() { | ||
}), _defineProperty(_Object$assign, "preventDefault", function preventDefault() { | ||
this.defaultPrevented = true; | ||
return this; | ||
}), defineProperty(_Object$assign, "reduce", function reduce(fn, memo) { | ||
}), _defineProperty(_Object$assign, "reduce", function reduce(fn, memo) { | ||
var _this = this; | ||
@@ -281,2 +89,6 @@ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function Observer(parent) { | ||
@@ -431,3 +243,3 @@ events.EventEmitter.call(this); | ||
return (_observerHandlers$eve = _this4._observerHandlers[event.type]).call.apply(_observerHandlers$eve, [_this4, event].concat(toConsumableArray(args))); | ||
return (_observerHandlers$eve = _this4._observerHandlers[event.type]).call.apply(_observerHandlers$eve, [_this4, event].concat(_toConsumableArray(args))); | ||
} | ||
@@ -438,7 +250,7 @@ | ||
return (_observerParent = _this4._observerParent).fire.apply(_observerParent, [event].concat(toConsumableArray(args))); | ||
return (_observerParent = _this4._observerParent).fire.apply(_observerParent, [event].concat(_toConsumableArray(args))); | ||
} | ||
return event.reduce(function (m, fn, ob) { | ||
return fn.call.apply(fn, [ob, event].concat(toConsumableArray(args))); | ||
return fn.call.apply(fn, [ob, event].concat(_toConsumableArray(args))); | ||
}); | ||
@@ -445,0 +257,0 @@ }); |
{ | ||
"name": "@pagedip/lib-observer", | ||
"version": "1.0.0", | ||
"version": "1.0.1-rc.0", | ||
"author": "Tyler Johnson <tyler@beneaththeink.com>", | ||
@@ -19,8 +19,8 @@ "repository": { | ||
"dependencies": { | ||
"@pagedip/util-hidden": "^1.0.0", | ||
"@pagedip/util-immutable": "^1.0.0" | ||
"@pagedip/util-hidden": "^1.0.1-rc.0", | ||
"@pagedip/util-immutable": "^1.0.1-rc.0" | ||
}, | ||
"devDependencies": { | ||
"npm-run-all": "^4.1.1", | ||
"rollup": "^0.50.0", | ||
"npm-run-all": "^4.1.2", | ||
"rollup": "^0.53.3", | ||
"shx": "^0.2.2" | ||
@@ -31,3 +31,3 @@ }, | ||
], | ||
"gitHead": "8aae2d936f98f6f3b228a7c1a97f36ef409ea957" | ||
"gitHead": "67860f9c5f27665fa10de204a4ea7623ec5d32bd" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8568
203
2