diff --git a/gulpfile.js b/gulpfile.js index 6ec63790..967cf75e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -48,10 +48,14 @@ var jasmineBrowser = require("gulp-jasmine-browser"); var concat = require("gulp-concat"); var watch = require("gulp-watch"); +var polyfills = [ + "./node_modules/regenerator/runtime.js" +]; + var files = { - y: ["src/**/*.js", "!src/**/*.spec.js"], + y: polyfills.concat(["src/**/*.js", "!src/**/*.spec.js"]), lint: ["src/**/*.js", "gulpfile.js"], - test: ["src/**/*.js"], + test: polyfills.concat(["./node_modules/regenerator/runtime.js", "src/**/*.js"]), build_test: ["build_test/y.js"] }; diff --git a/package.json b/package.json index f6ddf50c..f889295a 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,10 @@ "gulp-sourcemaps": "^1.5.2", "gulp-uglify": "^1.2.0", "gulp-watch": "^4.2.4", + "gulp-webpack": "^1.5.0", "minimist": "^1.1.1", - "pre-commit": "^1.0.10" + "pre-commit": "^1.0.10", + "promise-polyfill": "^2.0.2", + "regenerator": "^0.8.30" } } diff --git a/src/IndexdedDB.js b/src/IndexdedDB.js index 1c1250c5..d2b91531 100644 --- a/src/IndexdedDB.js +++ b/src/IndexdedDB.js @@ -1,16 +1,16 @@ -DB = (function(){ - class DBTransaction { +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 (event) { + req.onsuccess = function () { resolve(op); }; - req.onerror = function (event) { + req.onerror = function () { reject("Could not set Operation!"); }; }); @@ -18,198 +18,59 @@ DB = (function(){ getOperation (uid) { return new Promise((resolve, reject)=>{ var req = this.transaction.objectStore("OperationBuffer").get(uid); - req.onsuccess = function (event) { + req.onsuccess = function () { resolve(req.result); - } - req.onerror = function (event) { + }; + req.onerror = function () { reject("Could not get Operation"); - } + }; }); } - getOperations (state_map) { - var flow = Promise.resolve(); - var ops = []; - var ob = that.transaction.objectStore("OperationBuffer"); - - this.getStateVector().then((end_state_vector)=>{ - // convert to the db-structure - end_state_vector.forEach((end_state)=>{ - var 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] - range = IDBKeyRange.bound from, to - defer = Promise.defer() - - hb.openCursor(range).onsuccess = ()-> - 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 (generator : Function) { + this.ready.then(function(){ + var gen = generator(3);//new Transaction(db.transaction(["OperationBuffer", "StateVector"], "readwrite")) + gen.next(); + }); } } + return { + "DB": DB, + "Transaction": Transaction + }; +})(); -})() - -class DBTransaction - - getOperations: (state_map)-> - flow = Promise.resolve() - ops = [] - that = this - hb = that.t.objectStore("OperationBuffer") - - 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] - range = IDBKeyRange.bound from, to - defer = Promise.defer() - - hb.openCursor(range).onsuccess = ()-> - 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 - - setState: (state)-> - that = this - new Promise (resolve, reject)-> - req = that.t.objectStore("StateVector").put state - req.onsuccess = (event)-> - resolve state - req.onerror = (event)-> - reject "Could not set state vector!" - - getState: (user)-> - defer = Promise.defer() - req = @t.objectStore("StateVector").get user - req.onsuccess = (event)-> - defer.resolve req.result - req.onerror = (event)-> - defer.reject "Could not get state vector!" - defer.promise - - getStateVector: ()-> - defer = Promise.defer() - state_vector = [] - @t.objectStore("StateVector").openCursor().onsuccess = ()-> - cursor = event.target.result - if cursor? - state = cursor.value - state_vector.push state - cursor.continue() - else - # got all ops from this user - defer.resolve state_vector - defer.promise - - - -class Transaction - constructor: (@t)-> - - updateOperation: (op)-> - @t.setOperation op - - addOperation: (op)-> - that = this - @t.getState op.uid[0] - .then (state)-> - # only add operation if this is an expected operation - if not state? - state = - user: op.uid[0] - number: 0 - if op.uid[1] is state.number - state.number++ - that.t.setState state - else - return Promise.reject("Unexpected Operation") - .then that.t.setOperation op - - getOperation: (uid)-> - @t.getOperation uid - - getState: (user)-> - @t.getState user - - getOperations: (state_vector)-> - @t.getOperations state_vector - - -class window.DB - constructor: ()-> - @ready = (new Promise (resolve, reject)-> - req = indexedDB.open "Testy", 7 - req.onerror = ()-> - reject "Couldn't open the IndexedDB database!" - req.onsuccess = (event)-> - resolve event.target.result - req.onupgradeneeded = (event)-> - db = event.target.result - objectStore = db.createObjectStore "OperationBuffer", {keyPath: "uid"} - objectStore = db.createObjectStore "StateVector", {keyPath: "user"} - - ).catch (message)-> - throw new Error message - - requestTransaction: ()-> - @ready.then (db)-> - new Promise (resolve, reject)-> - resolve new Transaction( new DBTransaction(db.transaction(["OperationBuffer", "StateVector"], "readwrite")) ) - - removeDatabase: ()-> - req = indexedDB.deleteDatabase "Testy" - req.onsuccess = ()-> - console.log("Deleted database successfully"); - req.onblocked = ()-> - console.log("Database is currently being blocked") - console.dir arguments - req.onerror = ()-> - console.log("Couldn't delete database") - console.dir arguments - null - -window.db = new DB() - -window.addDummyDataSet = ()-> - db.requestTransaction().then (t)-> - t.getState("dmonad").then (state)-> - state ?= {number: 0} - t.addOperation({uid: ["dmonad", state.number]}) - -window.getOp = (num = 3)-> - db.requestTransaction().then (t)-> - t.getOperation(["dmonad", num]) - .then (op)-> - console.log("yay:") - console.log(op) - -window.getOps = (state_map = {dmonad: 5})-> - db.requestTransaction().then (t)-> - t.getOperations(state_map) - .then (op)-> - console.log("yay:") - console.log(op) +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.spec.js b/src/IndexedDB.spec.js index 8b137891..45fdf5c8 100644 --- a/src/IndexedDB.spec.js +++ b/src/IndexedDB.spec.js @@ -1 +1,24 @@ +/* @flow */ +/*eslint-env browser,jasmine,console */ +var number = 0; +function llater(time){ + return new Promise(function(yay){ + setTimeout(function(){ + yay(number++); + }, time); //eslint-disable-line no-undef + }); +} + +describe("IndexedDB", function() { + + 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; + }); + }); +}); diff --git a/y.js b/y.js index 554152b4..aee67a87 100644 --- a/y.js +++ b/y.js @@ -1,2 +1,2 @@ -"use strict";function _classCallCheck(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var OperationBuffer=function t(){_classCallCheck(this,t),this.i=4},Operation=function(){function t(n){_classCallCheck(this,t),this.i=n.i}return t.prototype.yay=function(){return this.i},t}(); +"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}(); //# sourceMappingURL=y.js.map \ No newline at end of file diff --git a/y.js.map b/y.js.map index 1b2324f3..3cde2d92 100644 --- a/y.js.map +++ b/y.js.map @@ -1 +1 @@ -{"version":3,"sources":["y.js","OperationBuffer.js","Operations.js"],"names":["_classCallCheck","instance","Constructor","TypeError","OperationBuffer","this","i","Operation","op","prototype","yay"],"mappings":"AAEA,YAEA,SAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCAEhH,GCJAC,iBAEA,QAFAA,KDKEJ,gBAAgBK,KCLlBD,GAGAC,KAAAC,EAAA,GCHAC,UAAA,WAEA,QAFAA,GAEAC,GFYIR,gBAAgBK,KEdpBE,GAGAF,KAAAC,EAAAE,EAAAF,EFoBE,MEvBFC,GAAAE,UAKAC,IAAA,WACA,MAAAL,MAAAC,GANAC","file":"y.js","sourcesContent":["/* @flow */\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","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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kBAAA,mBAAAC,QAAA,QACAF,EAAAC,kBAAA,eAAAC,QAAA,YAEA,SAAA,SAAAC,GACA,KAAA,IAAA7G,OAAA6G,KDinBI,MCloBJb,GAAAnI,UAoBArB,mBAAA,SAAAiB,GACAmB,KAAAsH,MAAApJ,KAAA,WACA,GAAAE,GAAAS,EAAA,EACAT,GAAAC,UAvBA+I,IA2BA,QACAA,GAAAA,EACAf,YAAAA,MExDA6B,gBAEA,QAFAA,KHyrBE1K,gBAAgBwC,KGzrBlBkI,GAGAlI,KAAAsD,EAAA,GCHA6E,UAAA,WAEA,QAFAA,GAEA3B,GJgsBIhJ,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