Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 73fa3b4

Browse files
prepare 6.2.1 release (#231)
1 parent 6aaafba commit 73fa3b4

16 files changed

+105
-105
lines changed

.eslintrc.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ rules:
7575
- error
7676
- props: true
7777

78+
# https://eslint.org/docs/rules/no-restricted-syntax
79+
no-restricted-syntax:
80+
- error
81+
- selector: ForInStatement
82+
message: avoid for...in which can pick up properties from prototypes; use for...of, or plain for if you need array indices
83+
7884
# https://eslint.org/docs/rules/no-return-assign
7985
no-return-assign: error
8086

.ldrelease/config.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
version: 2
2+
13
repo:
24
public: node-server-sdk
35
private: node-server-sdk-private
46

5-
releasableBranches:
7+
branches:
68
- name: master
79
description: 6.x
810
- name: 5.x
@@ -11,11 +13,14 @@ publications:
1113
- url: https://www.npmjs.com/package/launchdarkly-node-server-sdk
1214
description: npm
1315

14-
template:
15-
name: npm
16+
jobs:
17+
- docker:
18+
image: node:12-buster
19+
template:
20+
name: npm
1621

1722
documentation:
18-
githubPages: true
23+
gitHubPages: true
1924
title: LaunchDarkly Server-Side Node SDK
2025

2126
sdk:

big_segments.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function BigSegmentStoreManager(store, config, logger) {
3737
return lastStatus;
3838
};
3939

40-
// Called by the evaluator when it needs to get the big segment membership state for a user.
40+
// Called by the evaluator when it needs to get the Big Segment membership state for a user.
4141
//
4242
// If there is a cached membership state for the user, it returns the cached state. Otherwise,
4343
// it converts the user key into the hash string used by the BigSegmentStore, queries the store,
@@ -59,7 +59,7 @@ function BigSegmentStoreManager(store, config, logger) {
5959
}
6060
cache.set(userKey, membership);
6161
} catch (e) {
62-
logger.error('Big segment store membership query returned error: ' + e);
62+
logger.error('Big Segment store membership query returned error: ' + e);
6363
return [null, 'STORE_ERROR'];
6464
}
6565
cache.set(userKey, membership);
@@ -78,18 +78,18 @@ function BigSegmentStoreManager(store, config, logger) {
7878
lastStatus = { available: false, stale: false };
7979
return;
8080
}
81-
logger.debug('Querying big segment store status');
81+
logger.debug('Querying Big Segment store status');
8282
let newStatus;
8383
try {
8484
const metadata = await store.getMetadata();
8585
newStatus = { available: true, stale: !metadata || !metadata.lastUpToDate || isStale(metadata.lastUpToDate) };
8686
} catch (e) {
87-
logger.error('Big segment store status query returned error: ' + e);
87+
logger.error('Big Segment store status query returned error: ' + e);
8888
newStatus = { available: false, stale: false };
8989
}
9090
if (!lastStatus || lastStatus.available !== newStatus.available || lastStatus.stale !== newStatus.stale) {
9191
logger.debug(
92-
'Big segment store status changed from %s to %s',
92+
'Big Segment store status changed from %s to %s',
9393
JSON.stringify(lastStatus),
9494
JSON.stringify(newStatus)
9595
);

caching_store_wrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ function CachingStoreWrapper(underlyingStore, ttl, description) {
195195
if (!cache) {
196196
return;
197197
}
198-
for (const kindNamespace in dataKind) {
199-
cache.del(allCacheKey(dataKind[kindNamespace]));
198+
for (const eachKind of Object.values(dataKind)) {
199+
cache.del(allCacheKey(eachKind));
200200
}
201201
}
202202

evaluator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ function segmentMatchUser(segment, user, queries, stateOut, cb) {
250250
}
251251

252252
if (!segment.generation) {
253-
// Big segment queries can only be done if the generation is known. If it's unset,
253+
// Big Segment queries can only be done if the generation is known. If it's unset,
254254
// that probably means the data store was populated by an older SDK that doesn't know
255255
// about the generation property and therefore dropped it from the JSON data. We'll treat
256256
// that as a "not configured" condition.
@@ -261,7 +261,7 @@ function segmentMatchUser(segment, user, queries, stateOut, cb) {
261261
if (stateOut.bigSegmentsStatus) {
262262
// We've already done the query at some point during the flag evaluation and stored
263263
// the result (if any) in stateOut.bigSegmentsMembership, so we don't need to do it
264-
// again. Even if multiple big segments are being referenced, the membership includes
264+
// again. Even if multiple Big Segments are being referenced, the membership includes
265265
// *all* of the user's segment memberships.
266266
return cb(bigSegmentMatchUser(stateOut.bigSegmentsMembership, segment, user));
267267
}
@@ -461,7 +461,7 @@ function sha1Hex(input) {
461461
}
462462

463463
function makeBigSegmentRef(segment) {
464-
// The format of big segment references is independent of what store implementation is being
464+
// The format of Big Segment references is independent of what store implementation is being
465465
// used; the store implementation receives only this string and does not know the details of
466466
// the data model. The Relay Proxy will use the same format when writing to the store.
467467
return segment.key + '.g' + segment.generation;

event_summarizer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ function EventSummarizer() {
3737

3838
es.getSummary = () => {
3939
const flagsOut = {};
40-
for (const i in counters) {
41-
const c = counters[i];
40+
for (const c of Object.values(counters)) {
4241
let flag = flagsOut[c.key];
4342
if (!flag) {
4443
flag = {

feature_store.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,9 @@ function InMemoryFeatureStore() {
4444
const results = {};
4545
const items = allData[kind.namespace] || {};
4646

47-
for (const key in items) {
48-
if (Object.hasOwnProperty.call(items, key)) {
49-
const item = items[key];
50-
if (item && !item.deleted) {
51-
results[key] = item;
52-
}
47+
for (const [key, item] of Object.entries(items)) {
48+
if (item && !item.deleted) {
49+
results[key] = item;
5350
}
5451
}
5552

feature_store_event_wrapper.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ function NamespacedDataSet() {
2929
}
3030

3131
function enumerate(callback) {
32-
for (const ns in itemsByNamespace) {
33-
const items = itemsByNamespace[ns];
32+
for (const [ns, items] of Object.entries(itemsByNamespace)) {
3433
const keys = Object.keys(items).sort(); // sort to make tests determinate
35-
for (const i in keys) {
36-
const key = keys[i];
34+
for (const key of keys) {
3735
callback(ns, key, items[key]);
3836
}
3937
}
@@ -138,16 +136,14 @@ function FeatureStoreEventWrapper(featureStore, emitter) {
138136
function computeDependencies(kind, item) {
139137
const ret = NamespacedDataSet();
140138
if (kind === dataKind.features) {
141-
for (const i in item.prerequisites || []) {
142-
ret.set(dataKind.features.namespace, item.prerequisites[i].key, true);
139+
for (const prereq of item.prerequisites || []) {
140+
ret.set(dataKind.features.namespace, prereq.key, true);
143141
}
144-
for (const i in item.rules || []) {
145-
const rule = item.rules[i];
146-
for (const j in rule.clauses || []) {
147-
const clause = rule.clauses[j];
142+
for (const rule of item.rules || []) {
143+
for (const clause of rule.clauses || []) {
148144
if (clause.op === 'segmentMatch') {
149-
for (const k in clause.values) {
150-
ret.set(dataKind.segments.namespace, clause.values[k], true);
145+
for (const value of clause.values) {
146+
ret.set(dataKind.segments.namespace, value, true);
151147
}
152148
}
153149
}
@@ -168,22 +164,21 @@ function FeatureStoreEventWrapper(featureStore, emitter) {
168164
featureStore.init(newData, () => {
169165
dependencyTracker.reset();
170166

171-
for (const namespace in newData) {
172-
const items = newData[namespace];
167+
for (const [namespace, items] of Object.entries(newData)) {
173168
const kind = dataKind[namespace];
174-
for (const key in items) {
169+
for (const key of Object.keys(items || {})) {
175170
const item = items[key];
176171
dependencyTracker.updateDependenciesFrom(namespace, key, computeDependencies(kind, item));
177172
}
178173
}
179174

180175
if (checkForChanges) {
181176
const updatedItems = NamespacedDataSet();
182-
for (const namespace in newData) {
177+
for (const namespace of Object.keys(newData)) {
183178
const oldDataForKind = oldData[namespace];
184179
const newDataForKind = newData[namespace];
185180
const mergedData = Object.assign({}, oldDataForKind, newDataForKind);
186-
for (const key in mergedData) {
181+
for (const key of Object.keys(mergedData)) {
187182
addIfModified(
188183
namespace,
189184
key,

0 commit comments

Comments
 (0)