@agoric/store
Advanced tools
Comparing version 0.2.3-dev.2 to 0.3.0
@@ -6,2 +6,19 @@ # Change Log | ||
# [0.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/store@0.2.3-dev.2...@agoric/store@0.3.0) (2020-10-11) | ||
### Bug Fixes | ||
* improve API to punt serialization to the backing store ([fbfc0e7](https://github.com/Agoric/agoric-sdk/commit/fbfc0e75e910bc2fd36f0d60eac3929735d3fe68)) | ||
* update @agoric/store types and imports ([9e3493a](https://github.com/Agoric/agoric-sdk/commit/9e3493ad4d8c0a6a9230ad6a4c22a3254a867115)) | ||
### Features | ||
* **store:** implement external store machinery ([df4f550](https://github.com/Agoric/agoric-sdk/commit/df4f550270894c75fe25f252ee5db66d4c77e8db)) | ||
## [0.2.3-dev.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/store@0.2.3-dev.1...@agoric/store@0.2.3-dev.2) (2020-09-18) | ||
@@ -8,0 +25,0 @@ |
{ | ||
"name": "@agoric/store", | ||
"version": "0.2.3-dev.2", | ||
"version": "0.3.0", | ||
"description": "Wrapper for JavaScript map", | ||
"main": "src/store.js", | ||
"main": "src/index.js", | ||
"engines": { | ||
@@ -11,3 +11,3 @@ "node": ">=11.0" | ||
"build": "exit 0", | ||
"test": "exit 0", | ||
"test": "ava", | ||
"lint-fix": "yarn lint --fix", | ||
@@ -34,5 +34,6 @@ "lint-check": "yarn lint", | ||
"dependencies": { | ||
"@agoric/assert": "^0.0.11-dev.2" | ||
"@agoric/assert": "^0.0.11" | ||
}, | ||
"devDependencies": { | ||
"@agoric/install-ses": "^0.3.2", | ||
"ava": "^3.12.1", | ||
@@ -54,2 +55,5 @@ "esm": "^3.2.25", | ||
}, | ||
"globals": { | ||
"harden": "readonly" | ||
}, | ||
"rules": { | ||
@@ -101,3 +105,3 @@ "implicit-arrow-linebreak": "off", | ||
}, | ||
"gitHead": "433cc17e06b38df2e3b9034d5e2ab8f7e33f239d" | ||
"gitHead": "f30f9c002959e5f358b6458315057141c29605e8" | ||
} |
@@ -21,2 +21,36 @@ # Store | ||
See @agoric/weak-store for the wrapper around JavaScript's WeakMap abstraction. | ||
See `makeWeakStore` for the wrapper around JavaScript's WeakMap abstraction. | ||
# External Store | ||
An External Store is defined by its maker function, and provides abstractions | ||
that are compatible with large, synchronous secondary storage that can be paged | ||
in and out of local memory. | ||
```js | ||
import { makeExternalStore } from '@agoric/store'; | ||
// Here is us defining an instance store for 'hello' objects. | ||
const estore = makeExternalStore((msg = 'Hello') => ({ | ||
hello(nickname) { | ||
return `${msg}, ${nickname}!`; | ||
}, | ||
})); | ||
const h = estore.makeInstance('Hi'); | ||
h.hello('friend') === 'Hi, friend!'; | ||
const wm = estore.makeWeakMap('Hello object'); | ||
wm.init(h, 'data'); | ||
// ... time passes and h is paged out and reloaded. | ||
wm.get(h) === 'data'; | ||
wm.set(h, 'new-data'); | ||
// ... time passes and h is paged out and reloaded. | ||
map.delete(h); | ||
``` | ||
Note that when you import and use the `makeExternalStore` function, the platform | ||
you are running on may rewrite your code to use a more scalable implementation | ||
of that function. If it is not rewritten, then `makeExternalStore` will use | ||
`makeMemoryExternalStore`, a full-featured, though in-memory-only | ||
implementation. If you don't desire rewriting, then use | ||
`makeMemoryExternalStore` directly. |
// Copyright (C) 2019 Agoric, under Apache license 2.0 | ||
/* global harden */ | ||
// @ts-check | ||
@@ -9,16 +8,2 @@ | ||
/** | ||
* @template K,V | ||
* @typedef {Object} Store - A safety wrapper around a Map | ||
* @property {(key: K) => boolean} has - Check if a key exists | ||
* @property {(key: K, value: V) => void} init - Initialize the key only if it doesn't already exist | ||
* @property {(key: K) => V} get - Return a value for the key. Throws | ||
* if not found. | ||
* @property {(key: K, value: V) => void} set - Set the key. Throws if not found. | ||
* @property {(key: K) => void} delete - Remove the key. Throws if not found. | ||
* @property {() => K[]} keys - Return an array of keys | ||
* @property {() => V[]} values - Return an array of values | ||
* @property {() => [K, V][]} entries - Return an array of entries | ||
*/ | ||
/** | ||
* Distinguishes between adding a new key (init) and updating or | ||
@@ -33,3 +18,3 @@ * referencing a key (get, set, delete). | ||
*/ | ||
function makeStore(keyName = 'key') { | ||
export function makeStore(keyName = 'key') { | ||
const store = new Map(); | ||
@@ -64,2 +49,1 @@ const assertKeyDoesNotExist = key => | ||
harden(makeStore); | ||
export default makeStore; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
29998
12
299
56
4
1
Updated@agoric/assert@^0.0.11