@agoric/swing-store-simple
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.3.7](https://github.com/Agoric/agoric-sdk/compare/@agoric/swing-store-simple@0.3.6...@agoric/swing-store-simple@0.3.7) (2021-05-05) | ||
**Note:** Version bump only for package @agoric/swing-store-simple | ||
## [0.3.6](https://github.com/Agoric/agoric-sdk/compare/@agoric/swing-store-simple@0.3.5...@agoric/swing-store-simple@0.3.6) (2021-04-07) | ||
@@ -8,0 +16,0 @@ |
{ | ||
"name": "@agoric/swing-store-simple", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Persistent storage for SwingSet, based on a Map, optionally backed by a simple JSON file", | ||
@@ -49,3 +49,3 @@ "parsers": { | ||
}, | ||
"gitHead": "85ed9a1591cdc9cc31b1a126cf136a75161850ac" | ||
"gitHead": "05fed590d4240c9cdf77aab865cc35d94c881fa8" | ||
} |
@@ -0,1 +1,2 @@ | ||
// @ts-check | ||
import fs from 'fs'; | ||
@@ -147,12 +148,11 @@ import path from 'path'; | ||
* | ||
* @param {string} dirPath Path to a directory in which database files may be kept, or | ||
* @param {string} [dirPath] Path to a directory in which database files may be kept, or | ||
* null. | ||
* @param {boolean} [forceReset] If true, initialize the database to an empty state | ||
* | ||
* returns an object: { | ||
* storage, // a storage API object to load and store data | ||
* commit, // a function to commit changes made since the last commit | ||
* close // a function to shutdown the store, abandoning any uncommitted | ||
* // changes | ||
* } | ||
* @returns {{ | ||
* storage: SwingStore, // a storage API object to load and store data | ||
* commit: () => void, // commit changes made since the last commit | ||
* close: () => void, // shutdown the store, abandoning any uncommitted changes | ||
* }} | ||
*/ | ||
@@ -182,2 +182,3 @@ function makeSwingStore(dirPath, forceReset = false) { | ||
while (line) { | ||
// @ts-ignore JSON.parse can take a Buffer | ||
const [key, value] = JSON.parse(line); | ||
@@ -279,8 +280,10 @@ storage.set(key, value); | ||
* | ||
* @returns {Array<[string, string]>} an array representing all the current state in `storage`, one | ||
* @returns {Record<string, string>} an array representing all the current state in `storage`, one | ||
* element of the form [key, value] per key/value pair. | ||
*/ | ||
export function getAllState(storage) { | ||
/** @type { Record<string, string> } */ | ||
const stuff = {}; | ||
for (const key of Array.from(storage.getKeys('', ''))) { | ||
// @ts-ignore get(key) of key from getKeys() is not undefined | ||
stuff[key] = storage.get(key); | ||
@@ -287,0 +290,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30348
369