Comparing version 0.0.5 to 0.0.6
@@ -7,3 +7,2 @@ export declare type AppState = {}; | ||
readonly name: String; | ||
static DEFAULT_EXPERIMENT_NAME: string; | ||
value?: any; | ||
@@ -10,0 +9,0 @@ constructor(name: String); |
@@ -15,9 +15,6 @@ "use strict"; | ||
appKey: appKey, | ||
experiments: (_a = {}, | ||
_a[Experiment.DEFAULT_EXPERIMENT_NAME] = new Experiment(Experiment.DEFAULT_EXPERIMENT_NAME), | ||
_a), | ||
defaultCompletions: [] | ||
experiments: {}, | ||
defaultCompletions: {} | ||
}; | ||
resolve({}); | ||
var _a; | ||
}); | ||
@@ -59,3 +56,2 @@ } | ||
}; | ||
Experiment.DEFAULT_EXPERIMENT_NAME = "default"; | ||
return Experiment; | ||
@@ -66,3 +62,3 @@ }()); | ||
var ex = experiment(experimentName); | ||
state.defaultCompletions.push(ex.complete); | ||
state.defaultCompletions[experimentName] = ex; | ||
return ex.flipCoin(); | ||
@@ -73,3 +69,3 @@ } | ||
var ex = experiment(experimentName); | ||
state.defaultCompletions.push(ex.complete); | ||
state.defaultCompletions[experimentName] = ex; | ||
return ex.oneOf.apply(ex, options); | ||
@@ -80,5 +76,8 @@ } | ||
if (score === void 0) { score = 1; } | ||
state.defaultCompletions.forEach(function (c) { return c(score); }); | ||
var completions = state.defaultCompletions; | ||
Object.getOwnPropertyNames(completions).forEach(function (name) { | ||
return completions[name].complete(score); | ||
}); | ||
} | ||
exports.complete = complete; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
"use strict";var state;function log(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,["AUTOTUNE"].concat(e))}function initialize(n){return new Promise(function(e){var t;state={appKey:n,experiments:(t={},t[Experiment.DEFAULT_EXPERIMENT_NAME]=new Experiment(Experiment.DEFAULT_EXPERIMENT_NAME),t),defaultCompletions:[]},e({})})}function experiment(e){var t=state.experiments[e];return void 0===t&&(t=state.experiments[e]=new Experiment(e)),t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.initialize=initialize,exports.experiment=experiment;var Experiment=function(){function e(e){this.name=e}return e.prototype.setValue=function(e){return void 0===this.value&&(this.value=e),this.value},e.prototype.complete=function(e){void 0===e&&(e=1),log("Completed "+this.name+" with score "+e)},e.prototype.flipCoin=function(){return this.oneOf(!0,!1)},e.prototype.oneOf=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[Math.floor(Math.random()*e.length)];return this.setValue(n)},e.DEFAULT_EXPERIMENT_NAME="default",e}();function flipCoin(e){var t=experiment(e);return state.defaultCompletions.push(t.complete),t.flipCoin()}function oneOf(e,t){var n=experiment(e);return state.defaultCompletions.push(n.complete),n.oneOf.apply(n,t)}function complete(t){void 0===t&&(t=1),state.defaultCompletions.forEach(function(e){return e(t)})}exports.Experiment=Experiment,exports.flipCoin=flipCoin,exports.oneOf=oneOf,exports.complete=complete; | ||
"use strict";var state;function log(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,["AUTOTUNE"].concat(e))}function initialize(t){return new Promise(function(e){state={appKey:t,experiments:{},defaultCompletions:{}},e({})})}function experiment(e){var t=state.experiments[e];return void 0===t&&(t=state.experiments[e]=new Experiment(e)),t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.initialize=initialize,exports.experiment=experiment;var Experiment=function(){function e(e){this.name=e}return e.prototype.setValue=function(e){return void 0===this.value&&(this.value=e),this.value},e.prototype.complete=function(e){void 0===e&&(e=1),log("Completed "+this.name+" with score "+e)},e.prototype.flipCoin=function(){return this.oneOf(!0,!1)},e.prototype.oneOf=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[Math.floor(Math.random()*e.length)];return this.setValue(n)},e}();function flipCoin(e){var t=experiment(e);return(state.defaultCompletions[e]=t).flipCoin()}function oneOf(e,t){var n=experiment(e);return(state.defaultCompletions[e]=n).oneOf.apply(n,t)}function complete(t){void 0===t&&(t=1);var n=state.defaultCompletions;Object.getOwnPropertyNames(n).forEach(function(e){return n[e].complete(t)})}exports.Experiment=Experiment,exports.flipCoin=flipCoin,exports.oneOf=oneOf,exports.complete=complete; |
{ | ||
"name": "autotune", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Automatically tune JavaScript apps", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
9072
93