This commit is contained in:
Bruno Windels 2018-10-15 17:01:30 +02:00
parent 478c06c32e
commit f9f7abb0d1

View file

@ -17,8 +17,12 @@ limitations under the License.
import SdkConfig from './SdkConfig'; import SdkConfig from './SdkConfig';
function hashCode(str) { function hashCode(str) {
var hash = 0, i, chr; let hash = 0;
if (str.length === 0) return hash; let i;
let chr;
if (str.length === 0) {
return hash;
}
for (i = 0; i < str.length; i++) { for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i); chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr; hash = ((hash << 5) - hash) + chr;
@ -38,7 +42,8 @@ export function phasedRollOutExpiredForUser(username, feature, now, rollOutConfi
return true; return true;
} }
if (!Number.isFinite(featureConfig.offset) || !Number.isFinite(featureConfig.period)) { if (!Number.isFinite(featureConfig.offset) || !Number.isFinite(featureConfig.period)) {
console.error(`phased rollout of ${feature} is misconfigured, offset and/or period are not numbers, so disabling`, featureConfig); console.error(`phased rollout of ${feature} is misconfigured, ` +
`offset and/or period are not numbers, so disabling`, featureConfig);
return false; return false;
} }
@ -52,7 +57,7 @@ export function phasedRollOutExpiredForUser(username, feature, now, rollOutConfi
const result = now >= enableAt; const result = now >= enableAt;
const bucketStr = `(bucket ${userBucket}/${bucketCount})`; const bucketStr = `(bucket ${userBucket}/${bucketCount})`;
if (result) { if (result) {
console.log(`${feature} enabled for ${username} ${bucketStr}`) console.log(`${feature} enabled for ${username} ${bucketStr}`);
} else { } else {
console.log(`${feature} will be enabled for ${username} in ${Math.ceil((enableAt - now)/1000)}s ${bucketStr}`); console.log(`${feature} will be enabled for ${username} in ${Math.ceil((enableAt - now)/1000)}s ${bucketStr}`);
} }