Skip to content

Commit

Permalink
v0.4.11
Browse files Browse the repository at this point in the history
  • Loading branch information
scripting committed Sep 16, 2019
1 parent cb732db commit 54895bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,7 +11,7 @@
"files": [
"persists.js"
],
"version": "0.4.10",
"version": "0.4.11",
"dependencies" : {
"daveutils": "*"
}
Expand Down
15 changes: 10 additions & 5 deletions 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
Expand Down Expand Up @@ -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";
Expand Down
12 changes: 8 additions & 4 deletions readme.md
Expand Up @@ -32,13 +32,13 @@ Why is this possible now?

### A simple app

<pre>const persists = require ("../persists.js");
const initialStats = {
<pre>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);
});
</pre>
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 54895bc

Please sign in to comment.