New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

autotune

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autotune - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

15

dist/index.d.ts
export declare type AppState = {};
export declare type Completion = (score?: number) => void;
export declare function initialize(appKey: string): Promise<AppState>;
export declare function experiment(name: String): Experiment;
export declare function experiment(name: string): Experiment;
export declare class Experiment {
readonly name: String;
static DEFAULT_EXPERIMENT_NAME: string;
value?: any;
constructor(name: String);
setValue(value: any): any;
complete(score?: number): void;
flipCoin(experimentName: string): boolean;
oneOf<T>(experimentName: string, options: T[]): T;
flipCoin(): boolean;
oneOf<T>(...options: T[]): T;
}
export declare const complete: (score?: number) => void;
export declare const flipCoin: (experimentName: string) => boolean;
export declare const oneOf: <T>(experimentName: string, options: T[]) => T;
export declare function flipCoin(experimentName: string): boolean;
export declare function oneOf<T>(experimentName: string, options: T[]): T;
export declare function complete(score?: number): void;

63

dist/index.js

@@ -13,6 +13,20 @@ (function (factory) {

var state;
function log() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
console.log.apply(console, ["AUTOTUNE"].concat(args));
}
function initialize(appKey) {
return new Promise(function (resolve) {
state = { appKey: appKey };
state = {
appKey: appKey,
experiments: (_a = {},
_a[Experiment.DEFAULT_EXPERIMENT_NAME] = new Experiment(Experiment.DEFAULT_EXPERIMENT_NAME),
_a),
defaultCompletions: []
};
resolve({});
var _a;
});

@@ -22,3 +36,7 @@ }

function experiment(name) {
return new Experiment(name);
var ex = state.experiments[name];
if (ex === undefined) {
ex = state.experiments[name] = new Experiment(name);
}
return ex;
}

@@ -30,10 +48,22 @@ exports.experiment = experiment;

}
Experiment.prototype.setValue = function (value) {
if (this.value === undefined) {
this.value = value;
}
return this.value;
};
Experiment.prototype.complete = function (score) {
if (score === void 0) { score = 1; }
log("Completed " + this.name + " with score " + score);
};
Experiment.prototype.flipCoin = function (experimentName) {
return Math.random() < 0.5;
Experiment.prototype.flipCoin = function () {
return this.oneOf(true, false);
};
Experiment.prototype.oneOf = function (experimentName, options) {
return options[Math.floor(Math.random() * options.length)];
Experiment.prototype.oneOf = function () {
var options = [];
for (var _i = 0; _i < arguments.length; _i++) {
options[_i] = arguments[_i];
}
var one = options[Math.floor(Math.random() * options.length)];
return this.setValue(one);
};

@@ -44,7 +74,20 @@ Experiment.DEFAULT_EXPERIMENT_NAME = "default";

exports.Experiment = Experiment;
var defaultExperiment = new Experiment(Experiment.DEFAULT_EXPERIMENT_NAME);
exports.complete = defaultExperiment.complete;
exports.flipCoin = defaultExperiment.flipCoin;
exports.oneOf = defaultExperiment.oneOf;
function flipCoin(experimentName) {
var ex = experiment(experimentName);
state.defaultCompletions.push(ex.complete);
return ex.flipCoin();
}
exports.flipCoin = flipCoin;
function oneOf(experimentName, options) {
var ex = experiment(experimentName);
state.defaultCompletions.push(ex.complete);
return ex.oneOf.apply(ex, options);
}
exports.oneOf = oneOf;
function complete(score) {
if (score === void 0) { score = 1; }
state.defaultCompletions.forEach(function (c) { return c(score); });
}
exports.complete = complete;
});
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof module&&"object"==typeof module.exports){var n=e(require,exports);void 0!==n&&(module.exports=n)}else"function"==typeof define&&define.amd&&define(["require","exports"],e)}(function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.initialize=function(n){return new Promise(function(e){({appKey:n}),e({})})},n.experiment=function(e){return new o(e)};var o=function(){function e(e){this.name=e}return e.prototype.complete=function(e){void 0===e&&(e=1)},e.prototype.flipCoin=function(e){return Math.random()<.5},e.prototype.oneOf=function(e,n){return n[Math.floor(Math.random()*n.length)]},e.DEFAULT_EXPERIMENT_NAME="default",e}(),t=new(n.Experiment=o)(o.DEFAULT_EXPERIMENT_NAME);n.complete=t.complete,n.flipCoin=t.flipCoin,n.oneOf=t.oneOf});
!function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define(["require","exports"],e)}(function(e,t){"use strict";var n;function i(e){var t=n.experiments[e];return void 0===t&&(t=n.experiments[e]=new r(e)),t}Object.defineProperty(t,"__esModule",{value:!0}),t.initialize=function(o){return new Promise(function(e){var t;n={appKey:o,experiments:(t={},t[r.DEFAULT_EXPERIMENT_NAME]=new r(r.DEFAULT_EXPERIMENT_NAME),t),defaultCompletions:[]},e({})})},t.experiment=i;var r=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),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,["AUTOTUNE"].concat(e))}("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 o=e[Math.floor(Math.random()*e.length)];return this.setValue(o)},e.DEFAULT_EXPERIMENT_NAME="default",e}();t.Experiment=r,t.flipCoin=function(e){var t=i(e);return n.defaultCompletions.push(t.complete),t.flipCoin()},t.oneOf=function(e,t){var o=i(e);return n.defaultCompletions.push(o.complete),o.oneOf.apply(o,t)},t.complete=function(t){void 0===t&&(t=1),n.defaultCompletions.forEach(function(e){return e(t)})}});
{
"name": "autotune",
"version": "0.0.3",
"version": "0.0.4",
"description": "Automatically tune JavaScript apps",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc