Add a utility class that clones and adds a timestamp field (by default 'date') to any given object passed as argument
This commit is contained in:
parent
abba380f3f
commit
2fc3ba8308
|
@ -0,0 +1,13 @@
|
||||||
|
return {
|
||||||
|
timestamp: timestamp
|
||||||
|
};
|
||||||
|
|
||||||
|
function timestamp(o, field) {
|
||||||
|
var field = field || 'date';
|
||||||
|
var clone = {};
|
||||||
|
for(var key in o) {
|
||||||
|
clone[key] = o[key];
|
||||||
|
}
|
||||||
|
clone[field] = Date.now();
|
||||||
|
return clone;
|
||||||
|
}
|
Loading…
Reference in New Issue