unleash-client
Advanced tools
Comparing version 3.3.4 to 3.3.5
# Changelog | ||
# 3.3.5 | ||
- Fix typo (#174) | ||
- fix: varant should support all context fields (#178) | ||
- Update @types/node to the latest version 🚀 (#175) | ||
- Merge pull request #176 from aBMania/patch-1 | ||
- fix typo in readme | ||
- fix: license year and company | ||
# 3.3.4 | ||
@@ -4,0 +13,0 @@ |
@@ -1,1 +0,1 @@ | ||
{ "name": "unleash-client-node", "version": "3.3.4", "sdkVersion": "unleash-client-node:3.3.4" } | ||
{ "name": "unleash-client-node", "version": "3.3.5", "sdkVersion": "unleash-client-node:3.3.5" } |
import { Context } from './context'; | ||
export declare type FallbackFunction = (name: string, context: Context) => boolean; | ||
export declare function createFallbackFunction(name: string, context: Context, fallback?: FallbackFunction | boolean): Function; | ||
export declare function resolveContextValue(context: Context, field: string): string | number | import("./context").Propeties | undefined; | ||
//# sourceMappingURL=helpers.d.ts.map |
@@ -15,2 +15,14 @@ "use strict"; | ||
exports.createFallbackFunction = createFallbackFunction; | ||
function resolveContextValue(context, field) { | ||
if (context[field]) { | ||
return context[field]; | ||
} | ||
else if (context.properties && context.properties[field]) { | ||
return context.properties[field]; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
exports.resolveContextValue = resolveContextValue; | ||
//# sourceMappingURL=helpers.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function resolveContextValue(context, field) { | ||
if (context[field]) { | ||
return context[field]; | ||
} | ||
else if (context.properties && context.properties[field]) { | ||
return context.properties[field]; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
var helpers_1 = require("../helpers"); | ||
var Strategy = /** @class */ (function () { | ||
@@ -22,3 +12,3 @@ function Strategy(name, returnValue) { | ||
var field = constraint.contextName; | ||
var contextValue = resolveContextValue(context, field); | ||
var contextValue = helpers_1.resolveContextValue(context, field); | ||
var isIn = constraint.values.some(function (val) { return val.trim() === contextValue; }); | ||
@@ -25,0 +15,0 @@ return constraint.operator === Operator.IN ? isIn : !isIn; |
@@ -143,5 +143,6 @@ "use strict"; | ||
Unleash.prototype.getVariant = function (name, context, fallbackVariant) { | ||
var enhancedContext = Object.assign({}, this.staticContext, context); | ||
var result; | ||
if (this.client !== undefined) { | ||
result = this.client.getVariant(name, context, fallbackVariant); | ||
result = this.client.getVariant(name, enhancedContext, fallbackVariant); | ||
} | ||
@@ -148,0 +149,0 @@ else { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var util_1 = require("./strategy/util"); | ||
var helpers_1 = require("./helpers"); | ||
var PayloadType; | ||
@@ -29,3 +30,5 @@ (function (PayloadType) { | ||
function overrideMatchesContext(context) { | ||
return function (o) { return o.values.some(function (value) { return value === context[o.contextName]; }); }; | ||
return function (o) { | ||
return o.values.some(function (value) { return value === helpers_1.resolveContextValue(context, o.contextName); }); | ||
}; | ||
} | ||
@@ -48,7 +51,7 @@ function findOverride(feature, context) { | ||
var counter = 0; | ||
var variant = feature.variants.find(function (variant) { | ||
if (variant.weight === 0) { | ||
var variant = feature.variants.find(function (v) { | ||
if (v.weight === 0) { | ||
return; | ||
} | ||
counter += variant.weight; | ||
counter += v.weight; | ||
if (counter < target) { | ||
@@ -58,3 +61,3 @@ return; | ||
else { | ||
return variant; | ||
return v; | ||
} | ||
@@ -61,0 +64,0 @@ }); |
{ | ||
"name": "unleash-client", | ||
"version": "3.3.4", | ||
"version": "3.3.5", | ||
"description": "Unleash Client for Node", | ||
@@ -48,3 +48,3 @@ "license": "Apache-2.0", | ||
"@types/nock": "^11.1.0", | ||
"@types/node": "^13.7.4", | ||
"@types/node": "^14.0.1", | ||
"@types/request": "^2.48.4", | ||
@@ -51,0 +51,0 @@ "@unleash/client-specification": "^3.3.0", |
@@ -11,3 +11,3 @@ # Unleash Client SDK for Node.js | ||
Unleash Client SDK for Node.js. It is compatible with the | ||
[Unlesah-hosted.com SaaS offering](https://www.unleash-hosted.com/) and | ||
[Unleash-hosted.com SaaS offering](https://www.unleash-hosted.com/) and | ||
[Unleash Open-Source](https://github.com/finn-no/unleash). | ||
@@ -14,0 +14,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152058
1872