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

@domql/state

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domql/state - npm Package Compare versions

Comparing version 2.5.53 to 2.5.56

26

dist/cjs/inherit.js

@@ -22,7 +22,8 @@ "use strict";

checkIfInherits: () => checkIfInherits,
createChangesByKey: () => createChangesByKey,
createInheritedState: () => createInheritedState,
createNestedObjectByKeyPath: () => createNestedObjectByKeyPath,
findInheritedState: () => findInheritedState,
getChildStateInKey: () => getChildStateInKey,
getParentStateInKey: () => getParentStateInKey,
getRootStateInKey: () => getRootStateInKey,
isState: () => isState

@@ -33,2 +34,9 @@ });

var import_ignore = require("./ignore");
const getRootStateInKey = (stateKey, parentState) => {
if (!stateKey.includes("~/"))
return;
const arr = stateKey.split("~/");
if (arr.length > 1)
return parentState.__root;
};
const getParentStateInKey = (stateKey, parentState) => {

@@ -71,7 +79,13 @@ if (!stateKey.includes("../"))

return;
const rootState = getRootStateInKey(stateKey, parent.state);
let parentState = parent.state;
const findGrandParentState = getParentStateInKey(stateKey, parent.state);
if (findGrandParentState) {
parentState = findGrandParentState;
stateKey = stateKey.replaceAll("../", "");
if (rootState) {
parentState = rootState;
stateKey = stateKey.replaceAll("~/", "");
} else {
const findGrandParentState = getParentStateInKey(stateKey, parent.state);
if (findGrandParentState) {
parentState = findGrandParentState;
stateKey = stateKey.replaceAll("../", "");
}
}

@@ -107,3 +121,3 @@ if (!parentState)

};
const createChangesByKey = (path, value) => {
const createNestedObjectByKeyPath = (path, value) => {
if (!path) {

@@ -110,0 +124,0 @@ return value || {};

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

state.push(value);
state.update(state.parse(), { overwrite: "replace", ...options });
state.update(state.parse(), { overwrite: true, ...options });
} else if ((0, import_utils.isObject)(state)) {

@@ -118,0 +118,0 @@ const key = Object.keys(state).length;

@@ -93,5 +93,6 @@ "use strict";

const passedValue = isStringState ? state.value : obj;
const findRootState = (0, import_inherit.getRootStateInKey)(stateKey, parent.state);
const findGrandParentState = (0, import_inherit.getParentStateInKey)(stateKey, parent.state);
const changesValue = (0, import_inherit.createChangesByKey)(stateKey, passedValue);
const targetParent = findGrandParentState || parent.state;
const changesValue = (0, import_inherit.createNestedObjectByKeyPath)(stateKey, passedValue);
const targetParent = findRootState || findGrandParentState || parent.state;
if (options.replace)

@@ -98,0 +99,0 @@ (0, import_utils.overwriteDeep)(targetParent, changesValue || value);

@@ -6,2 +6,8 @@ 'use strict'

export const getRootStateInKey = (stateKey, parentState) => {
if (!stateKey.includes('~/')) return
const arr = stateKey.split('~/')
if (arr.length > 1) return parentState.__root
}
export const getParentStateInKey = (stateKey, parentState) => {

@@ -43,7 +49,14 @@ if (!stateKey.includes('../')) return

const rootState = getRootStateInKey(stateKey, parent.state)
let parentState = parent.state
const findGrandParentState = getParentStateInKey(stateKey, parent.state)
if (findGrandParentState) {
parentState = findGrandParentState
stateKey = stateKey.replaceAll('../', '')
if (rootState) {
parentState = rootState
stateKey = stateKey.replaceAll('~/', '')
} else {
const findGrandParentState = getParentStateInKey(stateKey, parent.state)
if (findGrandParentState) {
parentState = findGrandParentState
stateKey = stateKey.replaceAll('../', '')
}
}

@@ -96,3 +109,3 @@

export const createChangesByKey = (path, value) => {
export const createNestedObjectByKeyPath = (path, value) => {
if (!path) {

@@ -99,0 +112,0 @@ return value || {}

@@ -91,3 +91,3 @@ 'use strict'

state.push(value)
state.update(state.parse(), { overwrite: 'replace', ...options })
state.update(state.parse(), { overwrite: true, ...options })
} else if (isObject(state)) {

@@ -94,0 +94,0 @@ const key = Object.keys(state).length

{
"name": "@domql/state",
"version": "2.5.53",
"version": "2.5.56",
"license": "MIT",

@@ -34,3 +34,3 @@ "type": "module",

},
"gitHead": "aafcffa2ebe3d9c2fb96bd3adcb05325b62e68ff"
"gitHead": "a832fd0b6d8c39f16e6c7b2b61ab6c3dccd1f539"
}

@@ -7,3 +7,3 @@ 'use strict'

import { deepMerge, merge, overwriteDeep, overwriteShallow } from '@domql/utils'
import { checkIfInherits, createChangesByKey, findInheritedState, getParentStateInKey } from './inherit'
import { checkIfInherits, createNestedObjectByKeyPath, findInheritedState, getParentStateInKey, getRootStateInKey } from './inherit'

@@ -82,6 +82,7 @@ const STATE_UPDATE_OPTIONS = {

const findRootState = getRootStateInKey(stateKey, parent.state)
const findGrandParentState = getParentStateInKey(stateKey, parent.state)
const changesValue = createChangesByKey(stateKey, passedValue)
const targetParent = findGrandParentState || parent.state
if (options.replace) overwriteDeep(targetParent, changesValue || value) // check with createChangesByKey
const changesValue = createNestedObjectByKeyPath(stateKey, passedValue)
const targetParent = findRootState || findGrandParentState || parent.state
if (options.replace) overwriteDeep(targetParent, changesValue || value) // check with createNestedObjectByKeyPath
targetParent.update(changesValue, {

@@ -88,0 +89,0 @@ execStateFunction: false,

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