Created
November 9, 2016 00:24
-
-
Save jakiestfu/2244d5309da1f35792b38887ee513dc7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ "es2015-rollup" ], | |
"plugins": ["transform-class-properties"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? factory() : | |
typeof define === 'function' && define.amd ? define(factory) : | |
(factory()); | |
}(this, (function () { 'use strict'; | |
var asyncGenerator = function () { | |
function AwaitValue(value) { | |
this.value = value; | |
} | |
function AsyncGenerator(gen) { | |
var front, back; | |
function send(key, arg) { | |
return new Promise(function (resolve, reject) { | |
var request = { | |
key: key, | |
arg: arg, | |
resolve: resolve, | |
reject: reject, | |
next: null | |
}; | |
if (back) { | |
back = back.next = request; | |
} else { | |
front = back = request; | |
resume(key, arg); | |
} | |
}); | |
} | |
function resume(key, arg) { | |
try { | |
var result = gen[key](arg); | |
var value = result.value; | |
if (value instanceof AwaitValue) { | |
Promise.resolve(value.value).then(function (arg) { | |
resume("next", arg); | |
}, function (arg) { | |
resume("throw", arg); | |
}); | |
} else { | |
settle(result.done ? "return" : "normal", result.value); | |
} | |
} catch (err) { | |
settle("throw", err); | |
} | |
} | |
function settle(type, value) { | |
switch (type) { | |
case "return": | |
front.resolve({ | |
value: value, | |
done: true | |
}); | |
break; | |
case "throw": | |
front.reject(value); | |
break; | |
default: | |
front.resolve({ | |
value: value, | |
done: false | |
}); | |
break; | |
} | |
front = front.next; | |
if (front) { | |
resume(front.key, front.arg); | |
} else { | |
back = null; | |
} | |
} | |
this._invoke = send; | |
if (typeof gen.return !== "function") { | |
this.return = undefined; | |
} | |
} | |
if (typeof Symbol === "function" && Symbol.asyncIterator) { | |
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | |
return this; | |
}; | |
} | |
AsyncGenerator.prototype.next = function (arg) { | |
return this._invoke("next", arg); | |
}; | |
AsyncGenerator.prototype.throw = function (arg) { | |
return this._invoke("throw", arg); | |
}; | |
AsyncGenerator.prototype.return = function (arg) { | |
return this._invoke("return", arg); | |
}; | |
return { | |
wrap: function (fn) { | |
return function () { | |
return new AsyncGenerator(fn.apply(this, arguments)); | |
}; | |
}, | |
await: function (value) { | |
return new AwaitValue(value); | |
} | |
}; | |
}(); | |
var get = function get(object, property, receiver) { | |
if (object === null) object = Function.prototype; | |
var desc = Object.getOwnPropertyDescriptor(object, property); | |
if (desc === undefined) { | |
var parent = Object.getPrototypeOf(object); | |
if (parent === null) { | |
return undefined; | |
} else { | |
return get(parent, property, receiver); | |
} | |
} else if ("value" in desc) { | |
return desc.value; | |
} else { | |
var getter = desc.get; | |
if (getter === undefined) { | |
return undefined; | |
} | |
return getter.call(receiver); | |
} | |
}; | |
var set = function set(object, property, value, receiver) { | |
var desc = Object.getOwnPropertyDescriptor(object, property); | |
if (desc === undefined) { | |
var parent = Object.getPrototypeOf(object); | |
if (parent !== null) { | |
set(parent, property, value, receiver); | |
} | |
} else if ("value" in desc && desc.writable) { | |
desc.value = value; | |
} else { | |
var setter = desc.set; | |
if (setter !== undefined) { | |
setter.call(receiver, value); | |
} | |
} | |
return value; | |
}; | |
}))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "studyjs", | |
"version": "1.1.2", | |
"author": "Jacob Kelley <[email protected]>", | |
"homepage": "https://github.com/dollarshaveclub/study", | |
"description": "A client side A/B tester", | |
"license": "MIT", | |
"main": "./index.js", | |
"repository": { | |
"type": "git", | |
"url": "git://github.com/dollarshaveclub/study.git" | |
}, | |
"scripts": { | |
"build": "./node_modules/gulp/bin/gulp.js build", | |
"build-watch": "./node_modules/gulp/bin/gulp.js build-watch", | |
"test": "./node_modules/mocha-phantomjs/bin/mocha-phantomjs --reporter spec test/runner.html", | |
"pages": "git push -f origin master:gh-pages", | |
"postpublish": "git tag $npm_package_version && git push origin --tags" | |
}, | |
"devDependencies": { | |
"babel-plugin-transform-class-properties": "^6.18.0", | |
"babel-preset-es2015-rollup": "^1.1.1", | |
"babel-preset-es2015": "6.9.0", | |
"rollup-plugin-babel": "^2.6.1", | |
"rollup-plugin-uglify": "^1.0.1", | |
"rollup-stream": "^1.11.0", | |
"vinyl-source-stream": "^1.1.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment