New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-rollout

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-rollout - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

54

index.js

@@ -69,8 +69,14 @@ var crypto = require('crypto')

var output
var percentage
for (var modName in modifiers) {
percentage = percentages[i++]
// Redis stringifies everything, so ranges must be reified
if (typeof percentage === 'string') {
percentage = JSON.parse(percentage)
}
// in the circumstance that the key is not found, default to original value
if (percentages[i] === null) {
percentages[i] = normalizePercentageRange(modifiers[modName].percentage)
if (percentage === null) {
percentage = normalizePercentageRange(modifiers[modName].percentage)
}
if (isPercentageInRange(likely, percentages[i])) {
if (isPercentageInRange(likely, percentage)) {
if (!modifiers[modName].condition) {

@@ -92,3 +98,2 @@ modifiers[modName].condition = defaultCondition

}
i++
}

@@ -106,3 +111,3 @@ if (deferreds.length) {

if (resultValue) {
return resultPromise.handlerModifier
return deferreds[i].handlerModifier
}

@@ -119,6 +124,8 @@ }

Rollout.prototype.update = function (key, modifierPercentages) {
var persistKeys = [], modName, p
var persistKeys = []
var modName
var percentage
for (modName in modifierPercentages) {
p = normalizePercentageRange(modifierPercentages[modName])
persistKeys.push(key + ':' + modName, JSON.stringify(p))
percentage = normalizePercentageRange(modifierPercentages[modName])
persistKeys.push(key + ':' + modName, JSON.stringify(percentage))
}

@@ -129,5 +136,7 @@ return setRedisKeys(this.client, persistKeys)

Rollout.prototype.modifiers = function (handlerName) {
var modifiers = this._handlers[handlerName]
var keys = []
var modNames = []
for (var modName in this._handlers[handlerName]) {
var modName
for (modName in modifiers) {
keys.push(handlerName + ':' + modName)

@@ -137,8 +146,19 @@ modNames.push(modName)

return getRedisKeys(this.client, keys)
.then(function (values) {
var modifiers = {}
values.forEach(function (val, i) {
modifiers[modNames[i]] = JSON.parse(val)
})
return modifiers
.then(function (percentages) {
var modPercentages = {}
var i = 0
var percentage
for (modName in modifiers) {
percentage = percentages[i++]
// Redis stringifies everything, so ranges must be reified
if (typeof percentage === 'string') {
percentage = JSON.parse(percentage)
}
// in the circumstance that the key is not found, default to original value
if (percentage === null) {
percentage = normalizePercentageRange(modifiers[modName].percentage)
}
modPercentages[modName] = percentage
}
return modPercentages
})

@@ -176,6 +196,2 @@ }

function isPercentageInRange(val, range) {
// Redis stringifies everything, so ranges must be reified
if (typeof range === 'string') {
range = JSON.parse(range)
}
if (range && typeof range === 'object') {

@@ -182,0 +198,0 @@ return val > range.min && val <= range.max

{
"name": "node-rollout",
"version": "1.0.0",
"version": "1.0.1",
"description": "feature rollout management",

@@ -5,0 +5,0 @@ "author": "Ali Faiz & Dustin Diaz",

@@ -357,2 +357,5 @@ var chai = require('chai')

return subject.handler('super_secret', {
none: {
percentage: 0
},
id: {

@@ -359,0 +362,0 @@ // give feature to 49% of users

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