Comparing version 2.2.13 to 2.2.14
@@ -12,42 +12,30 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
function setValueByPath(obj, path, value) { | ||
const parts = path.split('.'); | ||
const lastPart = parts.pop(); | ||
const target = parts.reduce((acc, part) => { | ||
var _a; | ||
const match = part.match(/(\w+)\[(\d+)\]/); | ||
if (match) { | ||
const [, key, index] = match; | ||
if (!acc[key]) { | ||
acc[key] = []; | ||
} | ||
return (_a = acc[key][index]) !== null && _a !== void 0 ? _a : (acc[key][index] = {}); | ||
} | ||
else { | ||
if (!acc[part]) { | ||
acc[part] = {}; | ||
} | ||
return acc[part]; | ||
} | ||
}, obj); | ||
if (lastPart !== undefined) { | ||
target[lastPart] = value; | ||
} | ||
} | ||
const opSet = (doc, update) => { | ||
for (const key in update) { | ||
if (update.hasOwnProperty(key)) { | ||
if (key.includes('[') && key.includes(']')) { | ||
const parts = key.split(/[\[\].]+/).filter(Boolean); | ||
let target = doc; | ||
while (parts.length > 1) { | ||
const part = parts.shift(); | ||
if (part !== undefined) { | ||
if (!target[part]) { | ||
target[part] = isNaN(Number(parts[0])) ? {} : []; | ||
} | ||
target = target[part]; | ||
} | ||
} | ||
const lastPart = parts[0]; | ||
if (lastPart !== undefined) { | ||
target[lastPart] = update[key]; | ||
} | ||
} | ||
else if (typeof update[key] === 'object' && !Array.isArray(update[key])) { | ||
const parts = key.split('.'); | ||
let target = doc; | ||
while (parts.length > 1) { | ||
const part = parts.shift(); | ||
if (part !== undefined) { | ||
if (!target[part]) { | ||
target[part] = {}; | ||
} | ||
target = target[part]; | ||
} | ||
} | ||
const lastPart = parts[0]; | ||
if (lastPart !== undefined) { | ||
target[lastPart] = { ...target[lastPart], ...update[key] }; | ||
} | ||
} | ||
else { | ||
doc[key] = update[key]; | ||
} | ||
setValueByPath(doc, key, update[key]); | ||
} | ||
@@ -54,0 +42,0 @@ } |
{ | ||
"name": "verse.db", | ||
"version": "2.2.13", | ||
"version": "2.2.14", | ||
"description": "verse.db isn't just a database, it's your universal data bridge. Designed for unmatched flexibility, security, and performance, verse.db empowers you to manage your data with ease.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
933958
96
12127