Implicit timestamp when declare()ing values
This commit is contained in:
1 parent
e2fb00c38a
commit
340016813c
1 file changed
+28
-22
+28
-22
@@ -141,33 +141,39 @@ function declare(path, timestamps, values) {
|
||||
if (!timestamps)
|
||||
timestamps = {};
|
||||
|
||||
if (!values)
|
||||
values = {};
|
||||
|
||||
let parsedPath = common.parsePath(path);
|
||||
|
||||
let declaration = [parsedPath, 1];
|
||||
|
||||
let attrs = {};
|
||||
if (timestamps)
|
||||
for (let attrName in timestamps)
|
||||
if (attrName === "path")
|
||||
declaration[1] = timestamps.path;
|
||||
else {
|
||||
attrs[attrName] = 1;
|
||||
declaration[2] = declaration[2] || {};
|
||||
declaration[2][attrName] = timestamps[attrName];
|
||||
}
|
||||
|
||||
if (values)
|
||||
for (let attrName in values)
|
||||
if (attrName === "path")
|
||||
declaration[3] = values.path;
|
||||
else {
|
||||
attrs[attrName] = 1;
|
||||
declaration[4] = declaration[4] || {};
|
||||
if (attrName === "value" && !Array.isArray(values.value))
|
||||
declaration[4].value = [values.value];
|
||||
else
|
||||
declaration[4][attrName] = values[attrName];
|
||||
}
|
||||
for (let attrName in values) {
|
||||
if (!timestamps[attrName])
|
||||
timestamps[attrName] = 1;
|
||||
|
||||
if (attrName === "path")
|
||||
declaration[3] = values.path;
|
||||
else {
|
||||
attrs[attrName] = 1;
|
||||
declaration[4] = declaration[4] || {};
|
||||
if (attrName === "value" && !Array.isArray(values.value))
|
||||
declaration[4].value = [values.value];
|
||||
else
|
||||
declaration[4][attrName] = values[attrName];
|
||||
}
|
||||
}
|
||||
|
||||
for (let attrName in timestamps) {
|
||||
if (attrName === "path")
|
||||
declaration[1] = timestamps.path;
|
||||
else {
|
||||
attrs[attrName] = 1;
|
||||
declaration[2] = declaration[2] || {};
|
||||
declaration[2][attrName] = timestamps[attrName];
|
||||
}
|
||||
}
|
||||
|
||||
sandbox.declarations.push(declaration);
|
||||
|
||||
|
||||
Reference in new issue
Block a user