Skip to content
Permalink
Browse files

v0.4.11

  • Loading branch information...
scripting committed Sep 16, 2019
1 parent cb732db commit 54895bcb87e922b3c6f5276efe4bab540a1c3a17
Showing with 19 additions and 10 deletions.
  1. +1 −1 package.json
  2. +10 −5 persists.js
  3. +8 −4 readme.md
@@ -11,7 +11,7 @@
"files": [
"persists.js"
],
"version": "0.4.10",
"version": "0.4.11",
"dependencies" : {
"daveutils": "*"
}
@@ -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";
@@ -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>
@@ -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.

0 comments on commit 54895bc

Please sign in to comment.
You can’t perform that action at this time.