Implicit timestamp when declare()ing values
This commit is contained in:
1 parent
e2fb00c38a
commit
340016813c
1 file changed
+18
-12
+18
-12
@@ -141,23 +141,18 @@ function declare(path, timestamps, values) {
|
|||||||
if (!timestamps)
|
if (!timestamps)
|
||||||
timestamps = {};
|
timestamps = {};
|
||||||
|
|
||||||
|
if (!values)
|
||||||
|
values = {};
|
||||||
|
|
||||||
let parsedPath = common.parsePath(path);
|
let parsedPath = common.parsePath(path);
|
||||||
|
|
||||||
let declaration = [parsedPath, 1];
|
let declaration = [parsedPath, 1];
|
||||||
|
|
||||||
let attrs = {};
|
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) {
|
||||||
for (let attrName in values)
|
if (!timestamps[attrName])
|
||||||
|
timestamps[attrName] = 1;
|
||||||
|
|
||||||
if (attrName === "path")
|
if (attrName === "path")
|
||||||
declaration[3] = values.path;
|
declaration[3] = values.path;
|
||||||
else {
|
else {
|
||||||
@@ -168,6 +163,17 @@ function declare(path, timestamps, values) {
|
|||||||
else
|
else
|
||||||
declaration[4][attrName] = values[attrName];
|
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);
|
sandbox.declarations.push(declaration);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user