From 6f99ee5c34e482424b74a0d86f4866b9f72cf044 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 18 Jun 2015 02:35:52 +0200 Subject: [PATCH] requestTransaction accepts Promises&Generators --- .eslintrc | 3 +- gulpfile.js | 67 ++++++++++++++----------- src/IndexdedDB.js | 76 ----------------------------- src/IndexedDB.js | 110 ++++++++++++++++++++++++++++++++++++++++++ src/IndexedDB.spec.js | 43 ++++++++++------- y.js | 2 +- y.js.map | 2 +- 7 files changed, 179 insertions(+), 124 deletions(-) delete mode 100644 src/IndexdedDB.js create mode 100644 src/IndexedDB.js diff --git a/.eslintrc b/.eslintrc index 49f809ed..556740f4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,6 +8,7 @@ }, "parser": "babel-eslint", "globals": { - "OperationBuffer": true + "OperationBuffer": true, + "IndexedDB": true } } diff --git a/gulpfile.js b/gulpfile.js index 967cf75e..544c10b5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -55,7 +55,7 @@ var polyfills = [ var files = { y: polyfills.concat(["src/**/*.js", "!src/**/*.spec.js"]), lint: ["src/**/*.js", "gulpfile.js"], - test: polyfills.concat(["./node_modules/regenerator/runtime.js", "src/**/*.js"]), + test: polyfills.concat(["src/**/*.js"]), build_test: ["build_test/y.js"] }; @@ -68,19 +68,6 @@ var options = minimist(process.argv.slice(2), { } }); -gulp.task("build_test", function () { - return gulp.src(files.test) - .pipe(sourcemaps.init()) - .pipe(concat(options.name)) - .pipe(babel({ - loose: "all", - modules: "ignore" - })) - .pipe(uglify()) - .pipe(sourcemaps.write()) - .pipe(gulp.dest("build_test")); -}); - gulp.task("build", function () { return gulp.src(files.y) .pipe(sourcemaps.init()) @@ -94,14 +81,6 @@ gulp.task("build", function () { .pipe(gulp.dest(".")); }); -gulp.task("test", ["build_test"], function () { - return gulp.src(files.build_test) - .pipe(jasmine({ - verbose: true, - includeStuckTrace: true - })); -}); - gulp.task("lint", function(){ return gulp.src(files.lint) .pipe(eslint()) @@ -109,13 +88,47 @@ gulp.task("lint", function(){ .pipe(eslint.failOnError()); }); -gulp.task("develop", ["test", "build"], function(){ - gulp.src(files.build_test) - .pipe(watch(files.build_test)) +gulp.task("test", function () { + return gulp.src(files.test) + .pipe(sourcemaps.init()) + .pipe(concat("jasmine")) + .pipe(babel({ + loose: "all", + modules: "ignore" + })) + .pipe(uglify()) + .pipe(sourcemaps.write()) + .pipe(gulp.dest("build")) + .pipe(jasmine({ + verbose: true, + includeStuckTrace: true + })); +}); + +gulp.task("build_jasmine_browser", function(){ + gulp.src(files.test) + .pipe(sourcemaps.init()) + .pipe(concat("jasmine_browser.js")) + .pipe(babel({ + loose: "all", + modules: "ignore", + blacklist: ["regenerator"] + })) + .pipe(sourcemaps.write()) + .pipe(gulp.dest("build")); +}); + +gulp.task("develop", ["build_jasmine_browser", "test", "build"], function(){ + + gulp.watch(files.test, ["build_jasmine_browser"]); + gulp.watch(files.test, ["test"]); + gulp.watch(files.test, ["build"]); + + return gulp.src("build/jasmine_browser.js") + .pipe(watch("build/jasmine_browser.js")) .pipe(jasmineBrowser.specRunner()) .pipe(jasmineBrowser.server({port: options.testport})); - gulp.watch(files.test, ["build_test", "build"]); - return gulp.watch(files.build_test, ["test"]); + }); gulp.task("default", ["build", "test"]); diff --git a/src/IndexdedDB.js b/src/IndexdedDB.js deleted file mode 100644 index d2b91531..00000000 --- a/src/IndexdedDB.js +++ /dev/null @@ -1,76 +0,0 @@ - -var IndexedDB = (function(){ //eslint-disable-line no-unused-vars - class Transaction { - constructor (transaction) { - this.transaction = transaction; - } - setOperation (op) { - return new Promise((resolve, reject)=> { - var req = this.transaction.objectStore("OperationBuffer").put(op); - req.onsuccess = function () { - resolve(op); - }; - req.onerror = function () { - reject("Could not set Operation!"); - }; - }); - } - getOperation (uid) { - return new Promise((resolve, reject)=>{ - var req = this.transaction.objectStore("OperationBuffer").get(uid); - req.onsuccess = function () { - resolve(req.result); - }; - req.onerror = function () { - reject("Could not get Operation"); - }; - }); - } - } - class DB { - constructor (namespace : string) { - this.namespace = namespace; - this.ready = new Promise(function(yay, nay){ - var req = indexedDB.open(namespace); //eslint-disable-line no-undef - req.onerror = function(){ - nay("Couldn't open the IndexedDB database!"); - }; - req.onsuccess = function(event){ - yay(event.target.result); - }; - req.onupgradeneeded = function(event){ - var db = event.target.result; - db.createObjectStore("OperationBuffer", {keyPath: "uid"}); - db.createObjectStore("StateVector", {keyPath: "user"}); - }; - }).catch(function(message){ - throw new Error(message); - }); - } - requestTransaction (generator : Function) { - this.ready.then(function(){ - var gen = generator(3);//new Transaction(db.transaction(["OperationBuffer", "StateVector"], "readwrite")) - gen.next(); - }); - } - } - return { - "DB": DB, - "Transaction": Transaction - }; -})(); - -function requestTransaction(makeGen : Function){ //eslint-disable-line no-unused-vars - var gen = makeGen([1, 2, 3]); - function handle(result : Object){ - if (result.done) { - return result.value; - } - return result.value.then(function(res){ - return handle(gen.next(res)); - }, function(err){ - return handle(gen.throw(err)); - }); - } - return handle(gen.next()); -} diff --git a/src/IndexedDB.js b/src/IndexedDB.js new file mode 100644 index 00000000..6283b98f --- /dev/null +++ b/src/IndexedDB.js @@ -0,0 +1,110 @@ + +var IndexedDB = (function(){ //eslint-disable-line no-unused-vars + var GeneratorFunction = (function*(){}).constructor; + + class Transaction { + constructor (transaction) { + this.transaction = transaction; + } + setOperation (op) { + return new Promise((resolve, reject)=> { + var req = this.transaction.objectStore("OperationBuffer").put(op); + req.onsuccess = function () { + resolve(op); + }; + req.onerror = function () { + reject("Could not set Operation!"); + }; + }); + } + getOperation (uid) { + return new Promise((resolve, reject)=>{ + var req = this.transaction.objectStore("OperationBuffer").get(uid); + req.onsuccess = function () { + resolve(req.result); + }; + req.onerror = function () { + reject("Could not get Operation"); + }; + }); + } + getOperations () { + return function* () { + var op = yield this.getOperation(["u1", 0]); + return op.uid; + }; + } + /* + getOperations: (state_map)-> + flow = Promise.resolve() + ops = [] + that = this + hb = that.t.objectStore("HistoryBuffer") + + that.getStateVector().then (end_state_vector)-> + for end_state of end_state_vector + # convert to the db-structure + do (end_state = end_state)-> + start_state = + user: end_state.name + state: state_map[end_state] ? 0 + + flow = flow.then ()-> + from = [start_state.user, start_state.number] + to = [end_state.user, end_state.number] + cursor = event.target.result + if cursor? + ops.push cursor.value # add Operation + cursor.continue() + else + # got all ops from this user + defer.resolve ops + defer.promise + */ + } + class DB { + constructor (namespace : string) { + this.namespace = namespace; + this.ready = new Promise(function(yay, nay){ + var req = indexedDB.open(namespace); //eslint-disable-line no-undef + req.onerror = function(){ + nay("Couldn't open the IndexedDB database!"); + }; + req.onsuccess = function(event){ + yay(event.target.result); + }; + req.onupgradeneeded = function(event){ + var db = event.target.result; + db.createObjectStore("OperationBuffer", {keyPath: "uid"}); + db.createObjectStore("StateVector", {keyPath: "user"}); + }; + }).catch(function(message){ + throw new Error(message); + }); + } + requestTransaction (makeGen : Function) { + this.ready.then(function(db){ + var transaction = new Transaction(db.transaction(["OperationBuffer", "StateVector"], "readwrite")); + var gen = makeGen.apply(transaction); + function handle(result : Object){ + var v = result.value; + if (result.done) { + return v; + } else if (v.constructor === Promise) { + return result.value.then(function(res){ + return handle(gen.next(res)); + }, function(err){ + return handle(gen.throw(err)); + }); + } else if (v.constructor === GeneratorFunction){ + return handle(v.apply(transaction).next()); + } else { + throw new Error("I do only accept Promises and Generators!"); + } + } + return handle(gen.next()); + }); + } + } + return DB; +})(); diff --git a/src/IndexedDB.spec.js b/src/IndexedDB.spec.js index 45fdf5c8..279a24de 100644 --- a/src/IndexedDB.spec.js +++ b/src/IndexedDB.spec.js @@ -1,24 +1,31 @@ /* @flow */ -/*eslint-env browser,jasmine,console */ +/*eslint-env browser,jasmine */ -var number = 0; -function llater(time){ - return new Promise(function(yay){ - setTimeout(function(){ - yay(number++); - }, time); //eslint-disable-line no-undef - }); -} +if(typeof window !== "undefined"){ + describe("IndexedDB", function() { + var ob = new IndexedDB("Test"); -describe("IndexedDB", function() { + it("can create transactions", function(done) { + ob.requestTransaction(function*(){ + var op = yield this.setOperation({ + "uid": ["u1", 0], + "stuff": true + }); + expect(yield this.getOperation(["u1", 0])) + .toEqual(op); + done(); + }); + }); - it("can create transactions", function(done) { - requestTransaction(function*(numbers){ - expect(numbers).toEqual([1, 2, 3]); - expect(yield llater(10)).toEqual(0); - expect(yield llater(50)).toEqual(1); - done(); - return 10; + it("receive remaining operations", function(done){ + ob.requestTransaction(function*(){ + expect(yield this.getOperations(["u1", 0])) + .toEqual({ + "uid": ["u1", 0], + "stuff": true + }); + done(); + }); }); }); -}); +} diff --git a/y.js b/y.js index aee67a87..922f7c44 100644 --- a/y.js +++ b/y.js @@ -1,2 +1,2 @@ -"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function requestTransaction(t){function e(t){return t.done?t.value:t.value.then(function(t){return e(r.next(t))},function(t){return e(r["throw"](t))})}var r=t([1,2,3]);return e(r.next())}!function(t){function e(t,e,r,o){var i=Object.create((e||n).prototype);return i._invoke=s(t,r||null,new h(o||[])),i}function r(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(n){return{type:"throw",arg:n}}}function n(){}function o(){}function i(){}function a(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function c(t){this.arg=t}function u(t){function e(e,r){var n=t[e](r),a=n.value;return a instanceof c?Promise.resolve(a.arg).then(o,i):Promise.resolve(a).then(function(t){return n.value=t,n},i)}function r(t,r){var o=n?n.then(function(){return e(t,r)}):new Promise(function(n){n(e(t,r))});return n=o["catch"](a),o}"object"==typeof process&&process.domain&&(e=process.domain.bind(e));var n,o=e.bind(t,"next"),i=e.bind(t,"throw"),a=e.bind(t,"return");this._invoke=r}function s(t,e,n){var o=x;return function(i,a){if(o===b)throw new Error("Generator is already running");if(o===E)return y();for(;;){var c=n.delegate;if(c){if("return"===i||"throw"===i&&c.iterator[i]===v){n.delegate=null;var u=c.iterator["return"];if(u){var s=r(u,c.iterator,a);if("throw"===s.type){i="throw",a=s.arg;continue}}if("return"===i)continue}var s=r(c.iterator[i],c.iterator,a);if("throw"===s.type){n.delegate=null,i="throw",a=s.arg;continue}i="next",a=v;var f=s.arg;if(!f.done)return o=L,f;n[c.resultName]=f.value,n.next=c.nextLoc,n.delegate=null}if("next"===i)o===L?n.sent=a:delete n.sent;else if("throw"===i){if(o===x)throw o=E,a;n.dispatchException(a)&&(i="next",a=v)}else"return"===i&&n.abrupt("return",a);o=b;var s=r(t,e,n);if("normal"===s.type){o=n.done?E:L;var f={value:s.arg,done:n.done};if(s.arg!==k)return f;n.delegate&&"next"===i&&(a=v)}else"throw"===s.type&&(o=E,i="throw",a=s.arg)}}}function f(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function l(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset()}function p(t){if(t){var e=t[g];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function o(){for(;++re;++e)this[t]=null},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,n){return i.type="throw",i.arg=t,r.next=e,!!n}if(this.done)throw t;for(var r=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=d.call(o,"catchLoc"),c=d.call(o,"finallyLoc");if(a&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&d.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),l(r),k}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;l(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:p(t),resultName:e,nextLoc:r},k}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:void 0);var IndexedDB=function(){var t=function(){function t(e){_classCallCheck(this,t),this.transaction=e}return t.prototype.setOperation=function(t){var e=this;return new Promise(function(r,n){var o=e.transaction.objectStore("OperationBuffer").put(t);o.onsuccess=function(){r(t)},o.onerror=function(){n("Could not set Operation!")}})},t.prototype.getOperation=function(t){var e=this;return new Promise(function(r,n){var o=e.transaction.objectStore("OperationBuffer").get(t);o.onsuccess=function(){r(o.result)},o.onerror=function(){n("Could not get Operation")}})},t}(),e=function(){function t(e){_classCallCheck(this,t),this.namespace=e,this.ready=new Promise(function(t,r){var n=indexedDB.open(e);n.onerror=function(){r("Couldn't open the IndexedDB database!")},n.onsuccess=function(e){t(e.target.result)},n.onupgradeneeded=function(t){var e=t.target.result;e.createObjectStore("OperationBuffer",{keyPath:"uid"}),e.createObjectStore("StateVector",{keyPath:"user"})}})["catch"](function(t){throw new Error(t)})}return t.prototype.requestTransaction=function(t){this.ready.then(function(){var e=t(3);e.next()})},t}();return{DB:e,Transaction:t}}(),OperationBuffer=function t(){_classCallCheck(this,t),this.i=4},Operation=function(){function t(e){_classCallCheck(this,t),this.i=e.i}return t.prototype.yay=function(){return this.i},t}(); +"use strict";function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}!function(t){function r(t,r,e,o){var i=Object.create((r||n).prototype);return i._invoke=s(t,e||null,new h(o||[])),i}function e(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(n){return{type:"throw",arg:n}}}function n(){}function o(){}function i(){}function a(t){["next","throw","return"].forEach(function(r){t[r]=function(t){return this._invoke(r,t)}})}function c(t){this.arg=t}function u(t){function r(r,e){var n=t[r](e),a=n.value;return a instanceof c?Promise.resolve(a.arg).then(o,i):Promise.resolve(a).then(function(t){return n.value=t,n},i)}function e(t,e){var o=n?n.then(function(){return r(t,e)}):new Promise(function(n){n(r(t,e))});return n=o["catch"](a),o}"object"==typeof process&&process.domain&&(r=process.domain.bind(r));var n,o=r.bind(t,"next"),i=r.bind(t,"throw"),a=r.bind(t,"return");this._invoke=e}function s(t,r,n){var o=x;return function(i,a){if(o===L)throw new Error("Generator is already running");if(o===E)return y();for(;;){var c=n.delegate;if(c){if("return"===i||"throw"===i&&c.iterator[i]===v){n.delegate=null;var u=c.iterator["return"];if(u){var s=e(u,c.iterator,a);if("throw"===s.type){i="throw",a=s.arg;continue}}if("return"===i)continue}var s=e(c.iterator[i],c.iterator,a);if("throw"===s.type){n.delegate=null,i="throw",a=s.arg;continue}i="next",a=v;var f=s.arg;if(!f.done)return o=b,f;n[c.resultName]=f.value,n.next=c.nextLoc,n.delegate=null}if("next"===i)o===b?n.sent=a:delete n.sent;else if("throw"===i){if(o===x)throw o=E,a;n.dispatchException(a)&&(i="next",a=v)}else"return"===i&&n.abrupt("return",a);o=L;var s=e(t,r,n);if("normal"===s.type){o=n.done?E:b;var f={value:s.arg,done:n.done};if(s.arg!==O)return f;n.delegate&&"next"===i&&(a=v)}else"throw"===s.type&&(o=E,i="throw",a=s.arg)}}}function f(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function l(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset()}function p(t){if(t){var r=t[g];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function o(){for(;++er;++r)this[t]=null},stop:function(){this.done=!0;var t=this.tryEntries[0],r=t.completion;if("throw"===r.type)throw r.arg;return this.rval},dispatchException:function(t){function r(r,n){return i.type="throw",i.arg=t,e.next=r,!!n}if(this.done)throw t;for(var e=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=d.call(o,"catchLoc"),c=d.call(o,"finallyLoc");if(a&&c){if(this.prev=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&d.call(n,"finallyLoc")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),l(e),O}},"catch":function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;l(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:p(t),resultName:r,nextLoc:e},O}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:void 0);var IndexedDB=function(){var t=regeneratorRuntime.mark(function n(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}},n,this)}).constructor,r=function(){function t(r){_classCallCheck(this,t),this.transaction=r}return t.prototype.setOperation=function(t){var r=this;return new Promise(function(e,n){var o=r.transaction.objectStore("OperationBuffer").put(t);o.onsuccess=function(){e(t)},o.onerror=function(){n("Could not set Operation!")}})},t.prototype.getOperation=function(t){var r=this;return new Promise(function(e,n){var o=r.transaction.objectStore("OperationBuffer").get(t);o.onsuccess=function(){e(o.result)},o.onerror=function(){n("Could not get Operation")}})},t.prototype.getOperations=function(){this.transaction.objectStore("OperationBuffer");return regeneratorRuntime.mark(function t(){var r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getOperation(["u1",0]);case 2:return r=t.sent,t.abrupt("return",r.uid);case 4:case"end":return t.stop()}},t,this)})},t}(),e=function(){function e(t){_classCallCheck(this,e),this.namespace=t,this.ready=new Promise(function(r,e){var n=indexedDB.open(t);n.onerror=function(){e("Couldn't open the IndexedDB database!")},n.onsuccess=function(t){r(t.target.result)},n.onupgradeneeded=function(t){var r=t.target.result;r.createObjectStore("OperationBuffer",{keyPath:"uid"}),r.createObjectStore("StateVector",{keyPath:"user"})}})["catch"](function(t){throw new Error(t)})}return e.prototype.requestTransaction=function(e){this.ready.then(function(n){function o(r){for(var e=!0;e;){var n=r;c=void 0,e=!1;var c=n.value;if(n.done)return c;if(c.constructor===Promise)return n.value.then(function(t){return o(a.next(t))},function(t){return o(a["throw"](t))});if(c.constructor!==t)throw new Error("I do only accept Promises and Generators!");r=c.apply(i).next(),e=!0}}var i=new r(n.transaction(["OperationBuffer","StateVector"],"readwrite")),a=e.apply(i);return o(a.next())})},e}();return e}(),OperationBuffer=function t(){_classCallCheck(this,t),this.i=4},Operation=function(){function t(r){_classCallCheck(this,t),this.i=r.i}return t.prototype.yay=function(){return this.i},t}(); //# sourceMappingURL=y.js.map \ No newline at end of file diff --git a/y.js.map b/y.js.map index 3cde2d92..6a9dd9d0 100644 --- a/y.js.map +++ b/y.js.map @@ -1 +1 @@ -{"version":3,"sources":["y.js","IndexdedDB.js","runtime.js","OperationBuffer.js","Operations.js"],"names":["_classCallCheck","instance","Constructor","TypeError","requestTransaction","makeGen","handle","result","done","value","then","res","gen","next","err","global","wrap","innerFn","outerFn","self","tryLocsList","generator","Object","create","Generator","prototype","_invoke","makeInvokeMethod","Context","tryCatch","fn","obj","arg","type","call","GeneratorFunction","GeneratorFunctionPrototype","defineIteratorMethods","forEach","method","this","AwaitArgument","AsyncIterator","invoke","Promise","resolve","invokeNext","invokeThrow","unwrapped","enqueue","enqueueResult","previousPromise","invokeReturn","process","domain","bind","context","state","GenStateSuspendedStart","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","iterator","undefined","returnMethod","record","info","GenStateSuspendedYield","resultName","nextLoc","sent","dispatchException","abrupt","ContinueSentinel","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","values","iterable","iteratorMethod","iteratorSymbol","isNaN","length","i","hasOwn","hasOwnProperty","Symbol","inModule","module","runtime","regeneratorRuntime","exports","Gp","constructor","displayName","isGeneratorFunction","genFun","ctor","name","mark","__proto__","awrap","async","iter","toString","keys","object","key","reverse","pop","prev","tempName","tempIndex","stop","rootEntry","rootRecord","rval","exception","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","window","IndexedDB","Transaction","transaction","setOperation","op","_this","reject","req","objectStore","put","onsuccess","onerror","getOperation","uid","_this2","get","DB","namespace","ready","yay","nay","indexedDB","open","event","target","onupgradeneeded","db","createObjectStore","keyPath","message","OperationBuffer","Operation"],"mappings":"AAUA,YAEA,SAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCCkDhH,QAAAC,oBAAAC,GAEA,QAAAC,GAAAC,GACA,MAAAA,GAAAC,KACAD,EAAAE,MAEAF,EAAAE,MAAAC,KAAA,SAAAC,GACA,MAAAL,GAAAM,EAAAC,KAAAF,KACA,SAAAG,GACA,MAAAR,GAAAM,EAAA,SAAAE,MARA,GAAAF,GAAAP,GAAA,EAAA,EAAA,GAWA,OAAAC,GAAAM,EAAAC,SChEA,SAAAE,GAyBA,QAAAC,GAAAC,EAAAC,EAAAC,EAAAC,GAEA,GAAAC,GAAAC,OAAAC,QAAAL,GAAAM,GAAAC,UAOA,OALAJ,GAAAK,QAAAC,EACAV,EAAAE,GAAA,KACA,GAAAS,GAAAR,QAGAC,EAcA,QAAAQ,GAAAC,EAAAC,EAAAC,GACA,IACA,OAAAC,KAAA,SAAAD,IAAAF,EAAAI,KAAAH,EAAAC,IACA,MAAAlB,GACA,OAAAmB,KAAA,QAAAD,IAAAlB,IAiBA,QAAAU,MACA,QAAAW,MACA,QAAAC,MASA,QAAAC,GAAAZ,IACA,OAAA,QAAA,UAAAa,QAAA,SAAAC,GACAd,EAAAc,GAAA,SAAAP,GACA,MAAAQ,MAAAd,QAAAa,EAAAP,MA8BA,QAAAS,GAAAT,GACAQ,KAAAR,IAAAA,EAGA,QAAAU,GAAArB,GAGA,QAAAsB,GAAAJ,EAAAP,GACA,GAA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gBAAgBwC,KIlsBpBmI,GAGAnI,KAAAsD,EAAAkD,EAAAlD,EJwsBE,MI3sBF6E,GAAAlJ,UAKAsI,IAAA,WACA,MAAAvH,MAAAsD,GANA6E","file":"y.js","sourcesContent":[null,"\nvar IndexedDB = (function(){ //eslint-disable-line no-unused-vars\n class Transaction {\n constructor (transaction) {\n this.transaction = transaction;\n }\n setOperation (op) {\n return new Promise((resolve, reject)=> {\n var req = this.transaction.objectStore(\"OperationBuffer\").put(op);\n req.onsuccess = function () {\n resolve(op);\n };\n req.onerror = function () {\n reject(\"Could not set Operation!\");\n };\n });\n }\n getOperation (uid) {\n return new Promise((resolve, reject)=>{\n var req = this.transaction.objectStore(\"OperationBuffer\").get(uid);\n req.onsuccess = function () {\n resolve(req.result);\n };\n req.onerror = function () {\n reject(\"Could not get Operation\");\n };\n });\n }\n }\n class DB {\n constructor (namespace : string) {\n this.namespace = namespace;\n this.ready = new Promise(function(yay, nay){\n var req = indexedDB.open(namespace); //eslint-disable-line no-undef\n req.onerror = function(){\n nay(\"Couldn't open the IndexedDB database!\");\n };\n req.onsuccess = function(event){\n yay(event.target.result);\n };\n req.onupgradeneeded = function(event){\n var db = event.target.result;\n db.createObjectStore(\"OperationBuffer\", {keyPath: \"uid\"});\n db.createObjectStore(\"StateVector\", {keyPath: \"user\"});\n };\n }).catch(function(message){\n throw new Error(message);\n });\n }\n requestTransaction (generator : Function) {\n this.ready.then(function(){\n var gen = generator(3);//new Transaction(db.transaction([\"OperationBuffer\", \"StateVector\"], \"readwrite\"))\n gen.next();\n });\n }\n }\n return {\n \"DB\": DB,\n \"Transaction\": Transaction\n };\n})();\n\nfunction requestTransaction(makeGen : Function){ //eslint-disable-line no-unused-vars\n var gen = makeGen([1, 2, 3]);\n function handle(result : Object){\n if (result.done) {\n return result.value;\n }\n return result.value.then(function(res){\n return handle(gen.next(res));\n }, function(err){\n return handle(gen.throw(err));\n });\n }\n return handle(gen.next());\n}\n","/**\n * Copyright (c) 2014, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * https://raw.github.com/facebook/regenerator/master/LICENSE file. An\n * additional grant of patent rights can be found in the PATENTS file in\n * the same directory.\n */\n\n!(function(global) {\n \"use strict\";\n\n var hasOwn = Object.prototype.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var iteratorSymbol =\n typeof Symbol === \"function\" && Symbol.iterator || \"@@iterator\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided, then outerFn.prototype instanceof Generator.\n var generator = Object.create((outerFn || Generator).prototype);\n\n generator._invoke = makeInvokeMethod(\n innerFn, self || null,\n new Context(tryLocsList || [])\n );\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n genFun.__proto__ = GeneratorFunctionPrototype;\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `value instanceof AwaitArgument` to determine if the yielded value is\n // meant to be awaited. Some may consider the name of this method too\n // cutesy, but they are curmudgeons.\n runtime.awrap = function(arg) {\n return new AwaitArgument(arg);\n };\n\n function AwaitArgument(arg) {\n this.arg = arg;\n }\n\n function AsyncIterator(generator) {\n // This invoke function is written in a style that assumes some\n // calling function (or Promise) will handle exceptions.\n function invoke(method, arg) {\n var result = generator[method](arg);\n var value = result.value;\n return value instanceof AwaitArgument\n ? Promise.resolve(value.arg).then(invokeNext, invokeThrow)\n : Promise.resolve(value).then(function(unwrapped) {\n result.value = unwrapped;\n return result;\n }, invokeThrow);\n }\n\n if (typeof process === \"object\" && process.domain) {\n invoke = process.domain.bind(invoke);\n }\n\n var invokeNext = invoke.bind(generator, \"next\");\n var invokeThrow = invoke.bind(generator, \"throw\");\n var invokeReturn = invoke.bind(generator, \"return\");\n var previousPromise;\n\n function enqueue(method, arg) {\n var enqueueResult =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(function() {\n return invoke(method, arg);\n }) : new Promise(function(resolve) {\n resolve(invoke(method, arg));\n });\n\n // Avoid propagating enqueueResult failures to Promises returned by\n // later invocations of the iterator, and call generator.return() to\n // allow the generator a chance to clean up.\n previousPromise = enqueueResult[\"catch\"](invokeReturn);\n\n return enqueueResult;\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n if (method === \"return\" ||\n (method === \"throw\" && delegate.iterator[method] === undefined)) {\n // A return or throw (when the delegate iterator has no throw\n // method) always terminates the yield* loop.\n context.delegate = null;\n\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n var returnMethod = delegate.iterator[\"return\"];\n if (returnMethod) {\n var record = tryCatch(returnMethod, delegate.iterator, arg);\n if (record.type === \"throw\") {\n // If the return method threw an exception, let that\n // exception prevail over the original return or throw.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n }\n\n if (method === \"return\") {\n // Continue with the outer return, now that the delegate\n // iterator has been terminated.\n continue;\n }\n }\n\n var record = tryCatch(\n delegate.iterator[method],\n delegate.iterator,\n arg\n );\n\n if (record.type === \"throw\") {\n context.delegate = null;\n\n // Like returning generator.throw(uncaught), but without the\n // overhead of an extra function call.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n\n // Delegate generator ran and handled its own exceptions so\n // regardless of what the method was, we continue as if it is\n // \"next\" with an undefined arg.\n method = \"next\";\n arg = undefined;\n\n var info = record.arg;\n if (info.done) {\n context[delegate.resultName] = info.value;\n context.next = delegate.nextLoc;\n } else {\n state = GenStateSuspendedYield;\n return info;\n }\n\n context.delegate = null;\n }\n\n if (method === \"next\") {\n if (state === GenStateSuspendedYield) {\n context.sent = arg;\n } else {\n delete context.sent;\n }\n\n } else if (method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw arg;\n }\n\n if (context.dispatchException(arg)) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n method = \"next\";\n arg = undefined;\n }\n\n } else if (method === \"return\") {\n context.abrupt(\"return\", arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n var info = {\n value: record.arg,\n done: context.done\n };\n\n if (record.arg === ContinueSentinel) {\n if (context.delegate && method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n arg = undefined;\n }\n } else {\n return info;\n }\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(arg) call above.\n method = \"throw\";\n arg = record.arg;\n }\n }\n };\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset();\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function() {\n this.prev = 0;\n this.next = 0;\n this.sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.tryEntries.forEach(resetTryEntry);\n\n // Pre-initialize at least 20 temporary variables to enable hidden\n // class optimizations for simple generators.\n for (var tempIndex = 0, tempName;\n hasOwn.call(this, tempName = \"t\" + tempIndex) || tempIndex < 20;\n ++tempIndex) {\n this[tempName] = null;\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n return !!caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.next = finallyEntry.finallyLoc;\n } else {\n this.complete(record);\n }\n\n return ContinueSentinel;\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = record.arg;\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n return ContinueSentinel;\n }\n };\n})(\n // Among the various tricks for obtaining a reference to the global\n // object, this seems to be the most reliable technique that does not\n // use indirect eval (which violates Content Security Policy).\n typeof global === \"object\" ? global :\n typeof window === \"object\" ? window :\n typeof self === \"object\" ? self : this\n);\n","/* @flow */\n\nclass OperationBuffer { //eslint-disable-line no-unused-vars\n i : number;\n constructor () {\n this.i = 4;\n }\n}\n","/* @flow */\n\nclass Operation { //eslint-disable-line no-unused-vars\n i : number;\n constructor (op) {\n this.i = op.i;\n }\n yay () {\n return this.i;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["y.js","runtime.js","IndexedDB.js","OperationBuffer.js","Operations.js"],"names":["_classCallCheck","instance","Constructor","TypeError","global","wrap","innerFn","outerFn","self","tryLocsList","generator","Object","create","Generator","prototype","_invoke","makeInvokeMethod","Context","tryCatch","fn","obj","arg","type","call","err","GeneratorFunction","GeneratorFunctionPrototype","defineIteratorMethods","forEach","method","this","AwaitArgument","AsyncIterator","invoke","result","value","Promise","resolve","then","invokeNext","invokeThrow","unwrapped","enqueue","enqueueResult","previousPromise","invokeReturn","process","domain","bind","context","state","GenStateSuspendedStart","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","iterator","undefined","returnMethod","record","info","done","GenStateSuspendedYield","resultName","next","nextLoc","sent","dispatchException","abrupt","ContinueSentinel","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","values","iterable","iteratorMethod","iteratorSymbol","isNaN","length","i","hasOwn","hasOwnProperty","Symbol","inModule","module","runtime","regeneratorRuntime","exports","Gp","constructor","displayName","isGeneratorFunction","genFun","ctor","name","mark","__proto__","awrap","async","iter","toString","keys","object","key","reverse","pop","prev","tempName","tempIndex","stop","rootEntry","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","window","IndexedDB","callee$1$0","context$2$0","Transaction","transaction","setOperation","op","_this","reject","req","objectStore","put","onsuccess","onerror","getOperation","uid","_this2","get","getOperations","callee$3$0","context$4$0","DB","namespace","ready","yay","nay","indexedDB","open","event","target","onupgradeneeded","db","createObjectStore","keyPath","message","requestTransaction","makeGen","_x","_again","v","res","gen","apply","OperationBuffer","Operation"],"mappings":"AAUA,YAEA,SAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,sCCFhH,SAAAC,GAyBA,QAAAC,GAAAC,EAAAC,EAAAC,EAAAC,GAEA,GAAAC,GAAAC,OAAAC,QAAAL,GAAAM,GAAAC,UAOA,OALAJ,GAAAK,QAAAC,EACAV,EAAAE,GAAA,KACA,GAAAS,GAAAR,QAGAC,EAcA,QAAAQ,GAAAC,EAAAC,EAAAC,GACA,IACA,OAAAC,KAAA,SAAAD,IAAAF,EAAAI,KAAAH,EAAAC,IACA,MAAAG,GACA,OAAAF,KAAA,QAAAD,IAAAG,IAiBA,QAAAX,MACA,QAAAY,MACA,QAAAC,MASA,QAAAC,GAAAb,IACA,OAAA,QAAA,UAAAc,QAAA,SAAAC,GACAf,EAAAe,GAAA,SAAAR,GACA,MAAAS,MAAAf,QAAAc,EAAAR,MA8BA,QAAAU,GAAAV,GACAS,KAAAT,IAAAA,EAGA,QAAAW,GAAAtB,GAGA,QAAAuB,GAAAJ,EAAAR,GACA,GAAAa,GAAAxB,EAAAmB,GAAAR,GACAc,EAAAD,EAAAC,KACA,OAAAA,aAAAJ,GACAK,QAAAC,QAAAF,EAAAd,KAAAiB,KAAAC,EAAAC,GACAJ,QAAAC,QAAAF,GAAAG,KAAA,SAAAG,GAEA,MADAP,GAAAC,MAAAM,EACAP,GACAM,GAYA,QAAAE,GAAAb,EAAAR,GACA,GAAAsB,GAaAC,EAAAA,EAAAN,KAAA,WACA,MAAAL,GAAAJ,EAAAR,KACA,GAAAe,SAAA,SAAAC,GACAA,EAAAJ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qH,KFiqBI,MElrBJb,GAAA/I,UAoBA6J,mBAAA,SAAAC,GACA9I,KAAAiI,MAAAzH,KAAA,SAAAiI,GAGA,QAAA3C,GAAAiD,GF+nBqB,IAFX,GAAIC,IAAS,EAEKA,GE/nB5B,CFgoBY,GEhoBZ5I,GAAA2I,CACAE,GAAArH,OFioBYoH,GAAS,CEjoBrB,IAAAC,GAAA7I,EAAAC,KACA,IAAAD,EAAA4B,KACA,MAAAiH,EACA,IAAAA,EAAA5E,cAAA/D,QACA,MAAAF,GAAAC,MAAAG,KAAA,SAAA0I,GACA,MAAApD,GAAAqD,EAAAhH,KAAA+G,KACA,SAAAxJ,GACA,MAAAoG,GAAAqD,EAAA,SAAAzJ,KAEA,IAAAuJ,EAAA5E,cAAA1E,EAGA,KAAA,IAAA4B,OAAA,4CFioBcwH,GEnoBdE,EAAAG,MAAAtC,GAAA3E,OFooBc6G,GAAS,GEjpBvB,GAAAlC,GAAA,GAAAD,GAAA4B,EAAA3B,aAAA,kBAAA,eAAA,cACAqC,EAAAL,EAAAM,MAAAtC,EAiBA,OAAAhB,GAAAqD,EAAAhH,WAxCA4F,IA4CA,OAAAA,MC7GAsB,gBAEA,QAFAA,KH4vBEnL,gBAAgB8B,KG5vBlBqJ,GAGArJ,KAAA2D,EAAA,GCHA2F,UAAA,WAEA,QAFAA,GAEAtC,GJmwBI9I,gBAAgB8B,KIrwBpBsJ,GAGAtJ,KAAA2D,EAAAqD,EAAArD,EJ2wBE,MI9wBF2F,GAAAtK,UAKAkJ,IAAA,WACA,MAAAlI,MAAA2D,GANA2F","file":"y.js","sourcesContent":[null,"/**\n * Copyright (c) 2014, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * https://raw.github.com/facebook/regenerator/master/LICENSE file. An\n * additional grant of patent rights can be found in the PATENTS file in\n * the same directory.\n */\n\n!(function(global) {\n \"use strict\";\n\n var hasOwn = Object.prototype.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var iteratorSymbol =\n typeof Symbol === \"function\" && Symbol.iterator || \"@@iterator\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided, then outerFn.prototype instanceof Generator.\n var generator = Object.create((outerFn || Generator).prototype);\n\n generator._invoke = makeInvokeMethod(\n innerFn, self || null,\n new Context(tryLocsList || [])\n );\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n genFun.__proto__ = GeneratorFunctionPrototype;\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `value instanceof AwaitArgument` to determine if the yielded value is\n // meant to be awaited. Some may consider the name of this method too\n // cutesy, but they are curmudgeons.\n runtime.awrap = function(arg) {\n return new AwaitArgument(arg);\n };\n\n function AwaitArgument(arg) {\n this.arg = arg;\n }\n\n function AsyncIterator(generator) {\n // This invoke function is written in a style that assumes some\n // calling function (or Promise) will handle exceptions.\n function invoke(method, arg) {\n var result = generator[method](arg);\n var value = result.value;\n return value instanceof AwaitArgument\n ? Promise.resolve(value.arg).then(invokeNext, invokeThrow)\n : Promise.resolve(value).then(function(unwrapped) {\n result.value = unwrapped;\n return result;\n }, invokeThrow);\n }\n\n if (typeof process === \"object\" && process.domain) {\n invoke = process.domain.bind(invoke);\n }\n\n var invokeNext = invoke.bind(generator, \"next\");\n var invokeThrow = invoke.bind(generator, \"throw\");\n var invokeReturn = invoke.bind(generator, \"return\");\n var previousPromise;\n\n function enqueue(method, arg) {\n var enqueueResult =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(function() {\n return invoke(method, arg);\n }) : new Promise(function(resolve) {\n resolve(invoke(method, arg));\n });\n\n // Avoid propagating enqueueResult failures to Promises returned by\n // later invocations of the iterator, and call generator.return() to\n // allow the generator a chance to clean up.\n previousPromise = enqueueResult[\"catch\"](invokeReturn);\n\n return enqueueResult;\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n if (method === \"return\" ||\n (method === \"throw\" && delegate.iterator[method] === undefined)) {\n // A return or throw (when the delegate iterator has no throw\n // method) always terminates the yield* loop.\n context.delegate = null;\n\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n var returnMethod = delegate.iterator[\"return\"];\n if (returnMethod) {\n var record = tryCatch(returnMethod, delegate.iterator, arg);\n if (record.type === \"throw\") {\n // If the return method threw an exception, let that\n // exception prevail over the original return or throw.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n }\n\n if (method === \"return\") {\n // Continue with the outer return, now that the delegate\n // iterator has been terminated.\n continue;\n }\n }\n\n var record = tryCatch(\n delegate.iterator[method],\n delegate.iterator,\n arg\n );\n\n if (record.type === \"throw\") {\n context.delegate = null;\n\n // Like returning generator.throw(uncaught), but without the\n // overhead of an extra function call.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n\n // Delegate generator ran and handled its own exceptions so\n // regardless of what the method was, we continue as if it is\n // \"next\" with an undefined arg.\n method = \"next\";\n arg = undefined;\n\n var info = record.arg;\n if (info.done) {\n context[delegate.resultName] = info.value;\n context.next = delegate.nextLoc;\n } else {\n state = GenStateSuspendedYield;\n return info;\n }\n\n context.delegate = null;\n }\n\n if (method === \"next\") {\n if (state === GenStateSuspendedYield) {\n context.sent = arg;\n } else {\n delete context.sent;\n }\n\n } else if (method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw arg;\n }\n\n if (context.dispatchException(arg)) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n method = \"next\";\n arg = undefined;\n }\n\n } else if (method === \"return\") {\n context.abrupt(\"return\", arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n var info = {\n value: record.arg,\n done: context.done\n };\n\n if (record.arg === ContinueSentinel) {\n if (context.delegate && method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n arg = undefined;\n }\n } else {\n return info;\n }\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(arg) call above.\n method = \"throw\";\n arg = record.arg;\n }\n }\n };\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset();\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function() {\n this.prev = 0;\n this.next = 0;\n this.sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.tryEntries.forEach(resetTryEntry);\n\n // Pre-initialize at least 20 temporary variables to enable hidden\n // class optimizations for simple generators.\n for (var tempIndex = 0, tempName;\n hasOwn.call(this, tempName = \"t\" + tempIndex) || tempIndex < 20;\n ++tempIndex) {\n this[tempName] = null;\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n return !!caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.next = finallyEntry.finallyLoc;\n } else {\n this.complete(record);\n }\n\n return ContinueSentinel;\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = record.arg;\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n return ContinueSentinel;\n }\n };\n})(\n // Among the various tricks for obtaining a reference to the global\n // object, this seems to be the most reliable technique that does not\n // use indirect eval (which violates Content Security Policy).\n typeof global === \"object\" ? global :\n typeof window === \"object\" ? window :\n typeof self === \"object\" ? self : this\n);\n","\nvar IndexedDB = (function(){ //eslint-disable-line no-unused-vars\n var GeneratorFunction = (function*(){}).constructor;\n\n class Transaction {\n constructor (transaction) {\n this.transaction = transaction;\n }\n setOperation (op) {\n return new Promise((resolve, reject)=> {\n var req = this.transaction.objectStore(\"OperationBuffer\").put(op);\n req.onsuccess = function () {\n resolve(op);\n };\n req.onerror = function () {\n reject(\"Could not set Operation!\");\n };\n });\n }\n getOperation (uid) {\n return new Promise((resolve, reject)=>{\n var req = this.transaction.objectStore(\"OperationBuffer\").get(uid);\n req.onsuccess = function () {\n resolve(req.result);\n };\n req.onerror = function () {\n reject(\"Could not get Operation\");\n };\n });\n }\n getOperations () {\n var ops = [];\n var ob = this.transaction.objectStore(\"OperationBuffer\");\n\n return function* () {\n var op = yield this.getOperation([\"u1\",0]);\n return op.uid;\n };\n }\n /*\n getOperations: (state_map)->\n flow = Promise.resolve()\n ops = []\n that = this\n hb = that.t.objectStore(\"HistoryBuffer\")\n\n that.getStateVector().then (end_state_vector)->\n for end_state of end_state_vector\n # convert to the db-structure\n do (end_state = end_state)->\n start_state =\n user: end_state.name\n state: state_map[end_state] ? 0\n\n flow = flow.then ()->\n from = [start_state.user, start_state.number]\n to = [end_state.user, end_state.number]\n cursor = event.target.result\n if cursor?\n ops.push cursor.value # add Operation\n cursor.continue()\n else\n # got all ops from this user\n defer.resolve ops\n defer.promise\n */\n }\n class DB {\n constructor (namespace : string) {\n this.namespace = namespace;\n this.ready = new Promise(function(yay, nay){\n var req = indexedDB.open(namespace); //eslint-disable-line no-undef\n req.onerror = function(){\n nay(\"Couldn't open the IndexedDB database!\");\n };\n req.onsuccess = function(event){\n yay(event.target.result);\n };\n req.onupgradeneeded = function(event){\n var db = event.target.result;\n db.createObjectStore(\"OperationBuffer\", {keyPath: \"uid\"});\n db.createObjectStore(\"StateVector\", {keyPath: \"user\"});\n };\n }).catch(function(message){\n throw new Error(message);\n });\n }\n requestTransaction (makeGen : Function) {\n this.ready.then(function(db){\n var transaction = new Transaction(db.transaction([\"OperationBuffer\", \"StateVector\"], \"readwrite\"));\n var gen = makeGen.apply(transaction);\n function handle(result : Object){\n var v = result.value\n if (result.done) {\n return v;\n } else if (v.constructor === Promise) {\n return result.value.then(function(res){\n return handle(gen.next(res));\n }, function(err){\n return handle(gen.throw(err));\n });\n } else if (v.constructor === GeneratorFunction){\n return handle(v.apply(transaction).next());\n } else {\n throw new Error(\"I do only accept Promises and Generators!\")\n }\n }\n return handle(gen.next());\n });\n }\n }\n return DB;\n})();\n","/* @flow */\n\nclass OperationBuffer { //eslint-disable-line no-unused-vars\n i : number;\n constructor () {\n this.i = 4;\n }\n}\n","/* @flow */\n\nclass Operation { //eslint-disable-line no-unused-vars\n i : number;\n constructor (op) {\n this.i = op.i;\n }\n yay () {\n return this.i;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file