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

@kitql/client

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kitql/client - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

60

index.js

@@ -74,14 +74,22 @@ 'use strict';

function extractKeyValue(str) {
if (str.startsWith('_$')) {
const [key, value] = str.substring(2).split('(');
if (str.includes('[]$add')) {
const [key, value] = str.split('[]$add');
return {
key,
value: value.substring(0, value.length - 1)
value: value ? extractKeyValue('_$PROPS' + value).value : -1
};
}
else if (str.includes('[]$add')) {
const [key, value] = str.split('[]$add');
else if (str.includes('[]$remove(')) {
const [key, value] = str.split('[]$remove(');
return { key, value: value.substring(0, value.length - 1) };
}
else if (str.includes('[]$filter(')) {
const [key, value] = str.split('[]$filter(');
return { key, value: value.substring(0, value.length - 1) };
}
else if (str.startsWith('_$')) {
const [key, value] = str.substring(2).split('(');
return {
key,
value: value ? extractKeyValue('_$PROPS' + value).value : -1
value: value.substring(0, value.length - 1)
};

@@ -114,2 +122,12 @@ }

}
else if (segment.includes('[]$remove')) {
const kvp = extractKeyValue(segment);
const kvpElement = extractKeyValue(kvp.value);
let newArray = obj[kvp.key];
newArray = newArray.filter((c) => {
return c[kvpElement.key].toString() !== kvpElement.value;
});
const ToRmvFound = newArray.length !== obj[kvp.key].length;
toReturn = { found: ToRmvFound, obj: { ...obj, [kvp.key]: newArray } };
}
else if (segment.includes('_$')) {

@@ -135,13 +153,27 @@ const kvp = extractKeyValue(segment);

}
else if (segment.endsWith('[]')) {
let propertyName = segment.substring(0, segment.length - 2);
if (obj[propertyName] !== undefined) {
else if (segment.includes('[]')) {
let [propertyName] = segment.split('[]');
if (obj && obj[propertyName] !== undefined) {
const kvp = segment.includes('[]$filter(') ? extractKeyValue(segment) : null;
const kvpElement = kvp ? extractKeyValue(kvp.value) : null;
let xPathNext = segments.slice(1).join('.');
obj[propertyName].forEach((arrayItem, i) => {
const result = objUpdate(toReturn.found, obj[propertyName][i], newData, xPathNext);
obj[propertyName][i] = result.obj;
toReturn.found = result.found;
if (toReturn.found) {
return;
if (kvpElement) {
if (obj[propertyName][i][kvpElement.key].toString() === kvpElement.value) {
const result = objUpdate(toReturn.found, obj[propertyName][i], newData, xPathNext);
obj[propertyName][i] = result.obj;
toReturn.found = result.found;
if (toReturn.found) {
return;
}
}
}
else {
const result = objUpdate(toReturn.found, obj[propertyName][i], newData, xPathNext);
obj[propertyName][i] = result.obj;
toReturn.found = result.found;
if (toReturn.found) {
return;
}
}
});

@@ -148,0 +180,0 @@ }

@@ -111,4 +111,4 @@ export declare type ClientSettings = {

} | null): number;
patch<D, V>(operationKey: string, store: RequestResult<D, V>, newData: Object, // To be fragments only?
patch<D, V>(operationKey: string, store: RequestResult<D, V>, newData: Object | null, // To be fragments only?
xPath?: string | null): RequestResult<D, V>;
}
{
"name": "@kitql/client",
"version": "0.2.0",
"version": "0.2.1",
"dependencies": {

@@ -5,0 +5,0 @@ "@kitql/helper": "0.1.5",

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