Comparing version 0.4.0 to 0.4.1
@@ -5,3 +5,3 @@ var util = require('./util') | ||
this.experimentsByName = {} | ||
this.experimentsByVariable = {} | ||
this.experimentsByVariable = {} | ||
this.activeSubjectKeys = {} | ||
@@ -72,6 +72,8 @@ } | ||
ExperimentIndex.prototype.getFirstMatch = function (variable, subject, now) { | ||
var self = this | ||
return this.getLive(variable, now).filter( | ||
function (x) { | ||
return this.activeSubjectKeys[x.key(subject)] | ||
}.bind(this) | ||
return self.activeSubjectKeys[x.key(subject)] | ||
} | ||
)[0] | ||
@@ -78,0 +80,0 @@ } |
{ | ||
"name": "abatar", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A/B testing minion", | ||
@@ -14,3 +14,4 @@ "main": "index.js", | ||
"author": "Danny Coates", | ||
"license": "MPL 2.0", | ||
"license": "MPL-2.0", | ||
"repository": "dannycoates/abatar", | ||
"dependencies": { | ||
@@ -23,4 +24,4 @@ "js-sha1": "0.2.0" | ||
"tape": "4.0.0", | ||
"zuul": "2.1.1" | ||
"zuul": "3.3.0" | ||
} | ||
} |
@@ -283,1 +283,31 @@ var test = require('tape') | ||
) | ||
test( | ||
'getFirstMatch returns first match', | ||
function (t) { | ||
var x1 = new Experiment( | ||
{ | ||
name: 'foo', | ||
startDate: '2014-06-01', | ||
independentVariables: ['bar'], | ||
groupingFunction: function () { return { bar: 'x' }} | ||
} | ||
) | ||
x1.active = true | ||
var x2 = new Experiment( | ||
{ | ||
name: 'baz', | ||
startDate: '2014-06-01', | ||
independentVariables: ['boaz'], | ||
groupingFunction: function () { return { boaz: 'x' }} | ||
} | ||
) | ||
x2.active = true | ||
now = Date.parse('2015-01-01') | ||
var index = new ExperimentIndex() | ||
index.add(x1, '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33').add(x2, '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a34') | ||
t.equal(index.getFirstMatch('zar', {}, now), undefined, 'no releases') | ||
t.notEqual(index.getFirstMatch('bar', {}, now), undefined, 'no releases') | ||
t.end() | ||
} | ||
) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
49568
1139