Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devcycle/nodejs-server-sdk

Package Overview
Dependencies
Maintainers
6
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devcycle/nodejs-server-sdk - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

61

dist/main.js

@@ -63,36 +63,31 @@ /******/ (() => { // webpackBootstrap

};
const getCurrentRolloutPercentage = (rollout) => {
if (typeof rollout.startPercentage !== 'number') {
// no valid start percentage is set, interpret this as no rollout configured and return 100%
return 1;
const getCurrentRolloutPercentage = (rollout, currentDate) => {
var _a, _b;
const start = rollout.startPercentage;
const startDate = rollout.startDate;
if (rollout.type === 'schedule') {
return currentDate >= startDate ? 1 : 0;
}
// coerce to numbers to appease the TS gods
const { startDate, targetDate } = rollout;
const startTime = startDate === null || startDate === void 0 ? void 0 : startDate.getTime();
const targetTime = targetDate === null || targetDate === void 0 ? void 0 : targetDate.getTime();
const now = Date.now();
if (targetTime && !startTime) {
throw new Error('Invalid rollout: targetTime provided with no startTime or targetPercentage');
if (!(typeof start === 'number')) {
throw new Error('Invalid rollout configuration');
}
// Rollout hasn't started yet
if (startTime && now < startTime) {
return -1;
const _currentStage = (0,lodash__WEBPACK_IMPORTED_MODULE_0__.last)((_a = rollout.stages) === null || _a === void 0 ? void 0 : _a.filter((stage) => stage.date <= currentDate));
const nextStage = (0,lodash__WEBPACK_IMPORTED_MODULE_0__.first)((_b = rollout.stages) === null || _b === void 0 ? void 0 : _b.filter((stage) => stage.date > currentDate));
const currentStage = _currentStage || (startDate < currentDate ? {
percentage: start,
date: startDate
} : null);
if (!currentStage) {
return 0;
}
// This implies that there is no rollout, everyone gets it right away
if (!rollout.targetPercentage) {
return rollout.startPercentage;
if (!nextStage || nextStage.type === 'discrete') {
return currentStage.percentage;
}
// Rollout is complete
if (targetTime && now >= targetTime) {
return rollout.targetPercentage;
// In case you want to permanent rollout to some percentage of the audience
const currentDatePercentage = (currentDate.getTime() - currentStage.date.getTime()) /
(nextStage.date.getTime() - currentStage.date.getTime());
if (currentDatePercentage === 0) {
return 0;
}
else if (!targetTime || !startTime) {
return rollout.startPercentage;
}
else {
const timeDiff = (now - startTime) / (targetTime - startTime);
const rolloutDiff = (rollout.targetPercentage - rollout.startPercentage);
return (timeDiff * rolloutDiff) + rollout.startPercentage;
}
return (currentStage.percentage +
(nextStage.percentage - currentStage.percentage) * currentDatePercentage);
};

@@ -103,4 +98,4 @@ const doesUserPassRollout = ({ rollout, boundedHash }) => {

}
const rolloutPercentage = getCurrentRolloutPercentage(rollout);
return (boundedHash <= rolloutPercentage);
const rolloutPercentage = getCurrentRolloutPercentage(rollout, new Date());
return !!rolloutPercentage && (boundedHash <= rolloutPercentage);
};

@@ -143,3 +138,3 @@ const bucketForSegmentedFeature = ({ boundedHash, target }) => {

const { rolloutHash, bucketingHash } = generateBoundedHashes(user.user_id, target._id);
if (!doesUserPassRollout({ boundedHash: rolloutHash, rollout: target.rollout })) {
if (target.rollout && !doesUserPassRollout({ boundedHash: rolloutHash, rollout: target.rollout })) {
return;

@@ -1275,3 +1270,3 @@ }

module.exports = JSON.parse('{"name":"@devcycle/nodejs-server-sdk","version":"1.0.5","description":"The DevCycle NodeJS Server SDK used for feature management.","main":"dist/main.js","types":"types.d.ts","files":["dist","README.md","types.d.ts"],"scripts":{"clean":"rimraf dist","test":"jest --runInBand","tsc":"tsc","build":"yarn clean && webpack","lint":"eslint --ext .js,.ts"},"license":"MIT","devDependencies":{"@babel/plugin-transform-runtime":"^7.15.0","@babel/preset-env":"^7.15.6","@types/jest":"^27.0.2","@types/uuid":"^8.3.1","babel-jest":"^27.2.1","eslint":"^7.22.0","jest":"^27.2.1","rimraf":"^3.0.2","ts-jest":"^27.0.5","ts-loader":"^9.2.6","typescript":"^4.4.3","webpack":"^5.53.0","webpack-cli":"^4.8.0"},"dependencies":{"axios":"^0.24.0","lodash":"^4.17.21","md5":"^2.2.1","murmurhash":"^2.0.0","tslib":"^2.0.0","ua-parser-js":"^0.7.21","uuid":"^8.3.2"}}');
module.exports = JSON.parse('{"name":"@devcycle/nodejs-server-sdk","version":"1.0.6","description":"The DevCycle NodeJS Server SDK used for feature management.","main":"dist/main.js","types":"types.d.ts","files":["dist","README.md","types.d.ts"],"scripts":{"clean":"rimraf dist","test":"jest --runInBand","tsc":"tsc","build":"yarn clean && webpack","lint":"eslint --ext .js,.ts"},"license":"MIT","devDependencies":{"@babel/plugin-transform-runtime":"^7.15.0","@babel/preset-env":"^7.15.6","@types/jest":"^27.0.2","@types/uuid":"^8.3.1","babel-jest":"^27.2.1","eslint":"^7.22.0","jest":"^27.2.1","rimraf":"^3.0.2","ts-jest":"^27.0.5","ts-loader":"^9.2.6","typescript":"^4.4.3","webpack":"^5.53.0","webpack-cli":"^4.8.0"},"dependencies":{"axios":"^0.24.0","lodash":"^4.17.21","md5":"^2.2.1","murmurhash":"^2.0.0","tslib":"^2.0.0","ua-parser-js":"^0.7.21","uuid":"^8.3.2"}}');

@@ -1278,0 +1273,0 @@ /***/ })

{
"name": "@devcycle/nodejs-server-sdk",
"version": "1.0.5",
"version": "1.0.6",
"description": "The DevCycle NodeJS Server SDK used for feature management.",

@@ -5,0 +5,0 @@ "main": "dist/main.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