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

@launchdarkly/js-server-sdk-common

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@launchdarkly/js-server-sdk-common - npm Package Compare versions

Comparing version 2.6.0 to 2.6.1

7

CHANGELOG.md

@@ -11,2 +11,9 @@ # Changelog

## [2.6.1](https://github.com/launchdarkly/js-core/compare/js-server-sdk-common-v2.6.0...js-server-sdk-common-v2.6.1) (2024-09-05)
### Bug Fixes
* Correctly handle null values in JSON variations. ([#569](https://github.com/launchdarkly/js-core/issues/569)) ([907d08b](https://github.com/launchdarkly/js-core/commit/907d08b730ce9745c1b221f2f539f7c56c3a0234)), closes [#568](https://github.com/launchdarkly/js-core/issues/568)
## [2.6.0](https://github.com/launchdarkly/js-core/compare/js-server-sdk-common-v2.5.0...js-server-sdk-common-v2.6.0) (2024-09-03)

@@ -13,0 +20,0 @@

@@ -16,2 +16,14 @@ import { VersionedData } from '../api/interfaces';

}
/**
* Performs deep removal of null values.
*
* Does not remove null values from arrays.
*
* Note: This is a non-recursive implementation for performance and to avoid
* potential stack overflows.
*
* @param target The target to remove null values from.
* @param excludeKeys A list of top-level keys to exclude from null removal.
*/
export declare function nullReplacer(target: any, excludeKeys?: string[]): void;
export interface DeleteData extends Omit<VersionedData, 'key'> {

@@ -18,0 +30,0 @@ path: string;

55

dist/store/serialization.js

@@ -5,3 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeSegment = exports.serializeSegment = exports.deserializeFlag = exports.serializeFlag = exports.deserializeDelete = exports.deserializePatch = exports.deserializePoll = exports.deserializeAll = exports.processSegment = exports.processFlag = exports.replacer = exports.reviver = void 0;
exports.deserializeSegment = exports.serializeSegment = exports.deserializeFlag = exports.serializeFlag = exports.deserializeDelete = exports.deserializePatch = exports.deserializePoll = exports.deserializeAll = exports.processSegment = exports.processFlag = exports.replacer = exports.nullReplacer = void 0;
/* eslint-disable no-param-reassign */

@@ -13,13 +13,42 @@ const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");

/**
* @internal
* Performs deep removal of null values.
*
* Does not remove null values from arrays.
*
* Note: This is a non-recursive implementation for performance and to avoid
* potential stack overflows.
*
* @param target The target to remove null values from.
* @param excludeKeys A list of top-level keys to exclude from null removal.
*/
function reviver(key, value) {
// Whenever a null is included we want to remove the field.
// In this way validation checks do not have to consider null, only undefined.
if (value === null) {
return undefined;
function nullReplacer(target, excludeKeys) {
const stack = [];
if (target === null || target === undefined) {
return;
}
return value;
const filteredEntries = Object.entries(target).filter(([key, _value]) => !(excludeKeys === null || excludeKeys === void 0 ? void 0 : excludeKeys.includes(key)));
stack.push(...filteredEntries.map(([key, value]) => ({
key,
value,
parent: target,
})));
while (stack.length) {
const item = stack.pop();
// Do not remove items from arrays.
if (item.value === null && !Array.isArray(item.parent)) {
delete item.parent[item.key];
}
else if (typeof item.value === 'object' && item.value !== null) {
// Add all the children to the stack. This includes array children.
// The items in the array could themselves be objects which need nulls
// removed from them.
stack.push(...Object.entries(item.value).map(([key, value]) => ({
key,
value,
parent: item.value,
})));
}
}
}
exports.reviver = reviver;
exports.nullReplacer = nullReplacer;
/**

@@ -44,2 +73,6 @@ * For use when serializing flags/segments. This will ensure local types

}
// Allow null/undefined values to pass through without modification.
if (value === null || value === undefined) {
return value;
}
if (value.generated_includedSet) {

@@ -82,2 +115,3 @@ value.included = [...value.generated_includedSet];

var _a;
nullReplacer(flag, ['variations']);
if (flag.fallthrough && flag.fallthrough.rollout) {

@@ -108,2 +142,3 @@ const rollout = flag.fallthrough.rollout;

var _a, _b, _c, _d, _e;
nullReplacer(segment);
if (((_a = segment === null || segment === void 0 ? void 0 : segment.included) === null || _a === void 0 ? void 0 : _a.length) && segment.included.length > TARGET_LIST_ARRAY_CUTOFF) {

@@ -159,3 +194,3 @@ segment.generated_includedSet = new Set(segment.included);

try {
return JSON.parse(data, reviver);
return JSON.parse(data);
}

@@ -162,0 +197,0 @@ catch (_a) {

2

package.json
{
"name": "@launchdarkly/js-server-sdk-common",
"version": "2.6.0",
"version": "2.6.1",
"type": "commonjs",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is not supported yet

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