@naturalcycles/abba 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/abba.js CHANGED
@@ -120,7 +120,7 @@ export class Abba {
120
120
  async updateExclusions(experimentId, updatedExclusions) {
121
121
  const experiments = await this.experimentDao.getAll();
122
122
  const requiresUpdating = [];
123
- experiments.map(experiment => {
123
+ for (const experiment of experiments) {
124
124
  // Make sure it's mutual
125
125
  if (updatedExclusions.includes(experiment.id) &&
126
126
  !experiment.exclusions.includes(experimentId)) {
@@ -133,7 +133,7 @@ export class Abba {
133
133
  experiment.exclusions = experiment.exclusions.filter(id => id !== experimentId);
134
134
  requiresUpdating.push(experiment);
135
135
  }
136
- });
136
+ }
137
137
  await this.experimentDao.saveBatch(requiresUpdating, { saveMethod: 'update' });
138
138
  }
139
139
  async softDeleteExperiment(experimentId) {
package/dist/util.js CHANGED
@@ -44,15 +44,13 @@ export function determineBucket(buckets) {
44
44
  const bucketRoll = randomService.rollDie();
45
45
  let range;
46
46
  const bucket = buckets.find(b => {
47
- if (!range) {
48
- range = [0, b.ratio];
49
- }
50
- else {
47
+ if (range) {
51
48
  range = [range[1], range[1] + b.ratio];
52
49
  }
53
- if (bucketRoll > range[0] && bucketRoll <= range[1]) {
54
- return b;
50
+ else {
51
+ range = [0, b.ratio];
55
52
  }
53
+ return bucketRoll > range[0] && bucketRoll <= range[1];
56
54
  });
57
55
  _assert(bucket, 'Could not determine bucket from ratios', {
58
56
  code: AbbaErrorCode.BucketDeterminationFailed,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/abba",
3
3
  "type": "module",
4
- "version": "2.15.0",
4
+ "version": "2.16.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/db-lib": "^10",
7
7
  "@naturalcycles/js-lib": "^15",
@@ -10,7 +10,7 @@
10
10
  "tslib": "^2"
11
11
  },
12
12
  "devDependencies": {
13
- "@naturalcycles/dev-lib": "0.0.0",
13
+ "@naturalcycles/dev-lib": "20.79.0",
14
14
  "@types/semver": "^7",
15
15
  "typescript": "^7"
16
16
  },
package/src/abba.ts CHANGED
@@ -190,7 +190,7 @@ export class Abba {
190
190
  const experiments = await this.experimentDao.getAll()
191
191
 
192
192
  const requiresUpdating: Experiment[] = []
193
- experiments.map(experiment => {
193
+ for (const experiment of experiments) {
194
194
  // Make sure it's mutual
195
195
  if (
196
196
  updatedExclusions.includes(experiment.id) &&
@@ -208,7 +208,7 @@ export class Abba {
208
208
  experiment.exclusions = experiment.exclusions.filter(id => id !== experimentId)
209
209
  requiresUpdating.push(experiment)
210
210
  }
211
- })
211
+ }
212
212
 
213
213
  await this.experimentDao.saveBatch(requiresUpdating, { saveMethod: 'update' })
214
214
  }
package/src/util.ts CHANGED
@@ -68,15 +68,13 @@ export function determineBucket(buckets: readonly Bucket[]): Bucket {
68
68
  const bucketRoll = randomService.rollDie()
69
69
  let range: [number, number] | undefined
70
70
  const bucket = buckets.find(b => {
71
- if (!range) {
72
- range = [0, b.ratio]
73
- } else {
71
+ if (range) {
74
72
  range = [range[1], range[1] + b.ratio]
73
+ } else {
74
+ range = [0, b.ratio]
75
75
  }
76
76
 
77
- if (bucketRoll > range[0] && bucketRoll <= range[1]) {
78
- return b
79
- }
77
+ return bucketRoll > range[0] && bucketRoll <= range[1]
80
78
  })
81
79
 
82
80
  _assert(bucket, 'Could not determine bucket from ratios', {