diff --git a/package.json b/package.json index a39a47a..8ecd8d2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "files": [ "persists.js" ], - "version": "0.4.10", + "version": "0.4.11", "dependencies" : { "daveutils": "*" } diff --git a/persists.js b/persists.js index f0ad811..cb3fe53 100644 --- a/persists.js +++ b/persists.js @@ -1,4 +1,4 @@ -var myProductName = "persists", myVersion = "0.4.10"; +var myProductName = "persists", myVersion = "0.4.11"; /* The MIT License (MIT) Copyright (c) 2014-2019 Dave Winer @@ -42,22 +42,27 @@ const currentSavedObjectVersion = 1; function nowString () { return (new Date ().toLocaleString ()); } +function copyObject (source, dest) { //9/15/19 by DW + for (var x in source) { + dest [x] = source [x]; + } + } function createSharedObject (nameobject, initialObjectValues, myConfig, callback) { var flchanged = false; var theSharedObject = new Object (), objMetadata = new Object (); var ctSecsSinceLastCheck = 0; //set up theSharedObject if (initialObjectValues !== undefined) { - utils.copyScalars (initialObjectValues, theSharedObject); + copyObject (initialObjectValues, theSharedObject); } //set up objMetadata - utils.copyScalars (defaultObjectMetadata, objMetadata); + copyObject (defaultObjectMetadata, objMetadata); objMetadata.whenCreated = nowString (); //set up config var config = new Object (); - utils.copyScalars (defaultConfig, config); + copyObject (defaultConfig, config); if (myConfig !== undefined) { - utils.copyScalars (myConfig, config); + copyObject (myConfig, config); } console.log ("persists: config == " + utils.jsonStringify (config)); var f = config.persistsPath + nameobject + ".json"; diff --git a/readme.md b/readme.md index 403218f..4017a57 100644 --- a/readme.md +++ b/readme.md @@ -32,13 +32,13 @@ Why is this possible now? ### A simple app -
const persists = require ("../persists.js");
-const initialStats = {
+
const persists = require ("persists");
+const inititalStats = {
 	counter: 0
 	};
-persists ("stats", initialStats, undefined, function (stats) {
+persists ("stats", inititalStats, undefined, function (stats) {
 	setInterval (function () {
-		console.log (stats.counter++);
+		stats.counter++;
 		}, 1000);
 	});
 
@@ -81,6 +81,10 @@ These are the possible values that configure persists via the third parameter. ### Changes +#### 9/14/19 by DW + +When we copy from the xxx struct into the sharedObject, we only were copying scalars. Changed it so it copies objects and arrays too. + #### 9/8/19 by DW Change in the format that shared objects are saved on disk.