Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@agoric/store

Package Overview
Dependencies
Maintainers
0
Versions
2646
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/store - npm Package Compare versions

Comparing version 0.9.3-dev-09e90ee.0 to 0.9.3-dev-0a07188.0

2

exported.js

@@ -1,1 +0,1 @@

import './src/types.js';
// Dummy file for .d.ts twin to declare ambients
{
"name": "@agoric/store",
"version": "0.9.3-dev-09e90ee.0+09e90ee",
"version": "0.9.3-dev-0a07188.0+0a07188",
"description": "Wrapper for JavaScript map",

@@ -8,3 +8,3 @@ "type": "module",

"engines": {
"node": ">=14.15.0"
"node": "^18.12 || ^20.9"
},

@@ -34,12 +34,11 @@ "scripts": {

"dependencies": {
"@agoric/assert": "0.6.1-dev-09e90ee.0+09e90ee",
"@endo/exo": "^1.1.0",
"@endo/marshal": "^1.1.0",
"@endo/pass-style": "^1.1.0",
"@endo/patterns": "^1.1.0"
"@endo/errors": "^1.2.8",
"@endo/exo": "^1.5.7",
"@endo/marshal": "^1.6.2",
"@endo/pass-style": "^1.4.7",
"@endo/patterns": "^1.4.7"
},
"devDependencies": {
"@agoric/time": "0.3.3-dev-09e90ee.0+09e90ee",
"@endo/init": "^1.0.2",
"@endo/ses-ava": "^1.1.0",
"@endo/init": "^1.1.7",
"@endo/ses-ava": "^1.2.8",
"ava": "^5.3.0"

@@ -57,3 +56,3 @@ },

"files": [
"test/**/test-*.js"
"test/**/*.test.*"
],

@@ -66,5 +65,5 @@ "require": [

"typeCoverage": {
"atLeast": 85.52
"atLeast": 89.53
},
"gitHead": "09e90eeb90153b39018afe6309ebdcafa02b07b2"
"gitHead": "0a07188a9db63f72e2b960924628e00c4d44e7eb"
}

@@ -25,34 +25,4 @@ # TODO REWRITE

# 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.
Be aware that both `@agoric/base-zone` and this package `@agoric/store` will move from the agoric-sdk repository to the endo repository and likely renamed `@endo/zone` and `@endo/store`. At that time, we will first deprecate the versions here, then replace them with deprecated stubs that reexport from their new home. We hope to eventually remove even these stubs, depending on the compat cost at that time.

@@ -0,1 +1,16 @@

/**
* @import {MustMatch} from '@agoric/internal';
*/
import { mustMatch as typelessMustMatch } from '@endo/patterns';
export { makeScalarWeakSetStore } from './stores/scalarWeakSetStore.js';
export { makeScalarSetStore } from './stores/scalarSetStore.js';
export { makeScalarWeakMapStore } from './stores/scalarWeakMapStore.js';
export { makeScalarMapStore } from './stores/scalarMapStore.js';
export { provideLazy } from './stores/store-utils.js';
// /////////////////////// Deprecated Re-exports ///////////////////////////////
// Importers should import directly from the packages shown below
export {

@@ -44,5 +59,11 @@ isKey,

matches,
mustMatch,
isCopySet,
isCopyMap,
} from '@endo/patterns';
// XXX @agoric/store should not depend on @agoric/internal
// TODO move to Endo
/** @type {MustMatch} */
export const mustMatch = typelessMustMatch;
export {

@@ -55,9 +76,2 @@ initEmpty,

export { makeScalarWeakSetStore } from './stores/scalarWeakSetStore.js';
export { makeScalarSetStore } from './stores/scalarSetStore.js';
export { makeScalarWeakMapStore } from './stores/scalarWeakMapStore.js';
export { makeScalarMapStore } from './stores/scalarMapStore.js';
export { provideLazy, isCopyMap, isCopySet } from './stores/store-utils.js';
// /////////////////////// Deprecated Legacy ///////////////////////////////////

@@ -67,1 +81,3 @@

export { makeLegacyWeakMap } from './legacy/legacyWeakMap.js';
// eslint-disable-next-line import/export
export * from './types.js';

@@ -1,4 +0,5 @@

import { q, Fail } from '@agoric/assert';
/** @import {LegacyMap, LegacyWeakMap} from '../types.js'; */
import '../types.js';
// TODO, once migrated to endo, import from @endo/errors instead
import { Fail, q } from '@endo/errors';

@@ -5,0 +6,0 @@ /**

@@ -1,4 +0,6 @@

import { q, Fail } from '@agoric/assert';
import '../types.js';
/** @import {LegacyWeakMap} from '../types.js'; */
// TODO, once migrated to endo, import from @endo/errors instead
import { Fail, q } from '@endo/errors';
/**

@@ -5,0 +7,0 @@ * See doccomment in the closely related `legacyMap.js` module.

@@ -0,1 +1,2 @@

import { q } from '@endo/errors';
import {

@@ -18,3 +19,7 @@ Far,

const { quote: q } = assert;
/**
* @import {Passable} from '@endo/pass-style';
* @import {Key, Pattern} from '@endo/patterns';
* @import {MapStore, MapStoreMethods, StoreOptions} from '../types.js';
*/

@@ -29,3 +34,3 @@ /**

* @param {string} [tag]
* @returns {MapStore<K, V>}
* @returns {MapStoreMethods<K, V>}
*/

@@ -132,7 +137,5 @@ export const makeMapStoreMethods = (

*
* @template {Key} K
* @template {Passable} V
* @param {string} [tag] - the column name for the key
* @param {StoreOptions} [options]
* @returns {MapStore<K, V>}
* @returns {MapStore<any, any>}
*/

@@ -139,0 +142,0 @@ export const makeScalarMapStore = (

@@ -0,1 +1,2 @@

import { q } from '@endo/errors';
import { Far, filterIterable } from '@endo/pass-style';

@@ -13,6 +14,9 @@ import { compareRank } from '@endo/marshal';

const { quote: q } = assert;
/**
* @import {Key, Pattern} from '@endo/patterns';
* @import {SetStore, SetStoreMethods, StoreOptions} from '../types.js';
*/
/**
* @template K
* @template {Key} K
* @param {Set<K>} jsset

@@ -22,3 +26,3 @@ * @param {(k: K) => void} assertKeyOkToAdd

* @param {string} [keyName]
* @returns {SetStore<K>}
* @returns {SetStoreMethods<K>}
*/

@@ -25,0 +29,0 @@ export const makeSetStoreMethods = (

@@ -0,9 +1,19 @@

import { q, Fail } from '@endo/errors';
import { Far, assertPassable, passStyleOf } from '@endo/pass-style';
import { getCopyMapEntries, mustMatch, assertPattern } from '@endo/patterns';
import { isCopyMap } from './store-utils.js';
import {
getCopyMapEntries,
mustMatch,
assertPattern,
isCopyMap,
} from '@endo/patterns';
const { quote: q, Fail } = assert;
/**
* @import {Key} from '@endo/patterns';
* @import {Passable, RemotableObject} from '@endo/pass-style';
* @import {WeakMapStore, StoreOptions} from '../types.js';
*/
/**
* @template K,V
* @template {Key} K
* @template {Passable} V
* @param {WeakMap<K & object, V>} jsmap

@@ -63,2 +73,3 @@ * @param {(k: K, v: V) => void} assertKVOkToAdd

if (Object.isFrozen(entries) && isCopyMap(entries)) {
// @ts-expect-error XXX
entries = getCopyMapEntries(entries);

@@ -94,3 +105,3 @@ } else {

* @param {StoreOptions} [options]
* @returns {WeakMapStore<K, V>}
* @returns {RemotableObject & WeakMapStore<K, V>}
*/

@@ -97,0 +108,0 @@ export const makeScalarWeakMapStore = (

@@ -0,9 +1,17 @@

import { q, Fail } from '@endo/errors';
import { Far, passStyleOf } from '@endo/pass-style';
import { getCopySetKeys, mustMatch, assertPattern } from '@endo/patterns';
import { isCopySet } from './store-utils.js';
import {
getCopySetKeys,
mustMatch,
assertPattern,
isCopySet,
} from '@endo/patterns';
const { quote: q, Fail } = assert;
/**
* @import {Key} from '@endo/patterns';
* @import {StoreOptions, WeakSetStore, WeakSetStoreMethods} from '@agoric/store';
*/
/**
* @template K
* @template {Key} K
* @param {WeakSet<K & object>} jsset

@@ -13,3 +21,3 @@ * @param {(k: K) => void} assertKeyOkToAdd

* @param {string} [keyName]
* @returns {WeakSetStore<K>}
* @returns {WeakSetStoreMethods<K>}
*/

@@ -48,2 +56,3 @@ export const makeWeakSetStoreMethods = (

if (Object.isFrozen(keys) && isCopySet(keys)) {
// @ts-expect-error XXX
keys = getCopySetKeys(keys);

@@ -50,0 +59,0 @@ } else {

@@ -0,8 +1,12 @@

import { Fail, q } from '@endo/errors';
import { Far } from '@endo/marshal';
import { M, matches } from '@endo/patterns';
/** @typedef {import('@endo/marshal').RankCompare} RankCompare */
/**
* @import {RankCompare} from '@endo/marshal';
* @import {MapStore, WeakMapStore} from '../types.js';
* @import {Passable} from '@endo/pass-style';
* @import {Key} from '@endo/patterns';
*/
const { Fail, quote: q } = assert;
// TODO: Undate `@endo/patterns` to export the original, and delete the

@@ -15,3 +19,3 @@ // reimplementation here.

*
* @param {Passable} s
* @param {unknown} s
* @returns {s is CopySet}

@@ -28,3 +32,3 @@ */

*
* @param {Passable} m
* @param {unknown} m
* @returns {m is CopyMap}

@@ -35,3 +39,4 @@ */

/**
* @template K,V
* @template {Key} K
* @template {Passable} V
* @typedef {object} CurrentKeysKit

@@ -44,3 +49,4 @@ * @property {(k: K, v?: V) => void} assertUpdateOnAdd

/**
* @template K,V
* @template {Key} K
* @template {Passable} V
* @param {() => Iterable<K>} getRawKeys

@@ -120,3 +126,4 @@ * @param {(k: K) => boolean} checkHas

*
* @template K,V
* @template {Key} K
* @template {Passable} V
* @param {WeakMapStore<K, V>} mapStore

@@ -146,4 +153,4 @@ * @param {K} key

*
* @template K
* @template V
* @template {Key} K
* @template {Passable} V
* @param {WeakMapStore<K, V>} store

@@ -198,4 +205,4 @@ */

/**
* @template K
* @template V
* @template {Key} K
* @template {Passable} V
* @typedef {ReturnType<typeof makeAtomicProvider<K, V>>} AtomicProvider<K, V>

@@ -205,3 +212,4 @@ */

/**
* @template K, V
* @template {Key} K
* @template {Passable} V
* @param {MapStore<K, V[]>} mapStore

@@ -208,0 +216,0 @@ * @param {K} key

@@ -1,20 +0,13 @@

/// <reference types="ses"/>
/// <reference types="ses" />
// Ensure this is a module.
export {};
/**
* Note TODO https://github.com/endojs/endo/issues/1488
*
* @typedef {import('@endo/pass-style').Passable} Passable
* @import {Passable, RemotableObject} from '@endo/pass-style'
* @import {CopySet, CopyMap, Pattern} from '@endo/patterns'
* @import {Key} from '@endo/patterns'
*/
/** @typedef {import('@endo/pass-style').CopyTagged} CopyTagged */
/** @typedef {import('@endo/patterns').Pattern} Pattern */
/** @typedef {import('@endo/patterns').Key} Key */
/**
* @template {Key} [K=Key]
* @typedef {import('@endo/patterns').CopySet<K>} CopySet
*/
/**
* @template {Key} [K=Key]
* @template {Passable} [V=Passable]
* @typedef {import('@endo/patterns').CopyMap<K, V>} CopyMap
*/

@@ -59,5 +52,6 @@ /**

// TODO use Key for K
/**
* @template {Key & object} [K=Key]
* @typedef {object} WeakSetStore
* @template K
* @typedef {object} WeakSetStoreMethods
* @property {(key: K) => boolean} has Check if a key exists. The key can be any

@@ -71,8 +65,13 @@ * JavaScript value, though the answer will always be false for keys that

* @property {(key: K) => void} delete Remove the key. Throws if not found.
* @property {(keys: CopySet<K> | Iterable<K>) => void} addAll
* @property {(keys: CopySet<any> | Iterable<K>) => void} addAll
*/
/**
* @template K
* @typedef {RemotableObject & WeakSetStoreMethods<K>} WeakSetStore
*/
// TODO use Key for K
/**
* @template {Key} [K=Key]
* @typedef {object} SetStore
* @template K
* @typedef {object} SetStoreMethods
* @property {(key: K) => boolean} has Check if a key exists. The key can be any

@@ -86,13 +85,19 @@ * JavaScript value, though the answer will always be false for keys that

* @property {(key: K) => void} delete Remove the key. Throws if not found.
* @property {(keys: CopySet<K> | Iterable<K>) => void} addAll
* @property {(keys: CopySet<any> | Iterable<K>) => void} addAll
* @property {(keyPatt?: Pattern) => Iterable<K>} keys
* @property {(keyPatt?: Pattern) => Iterable<K>} values
* @property {(keyPatt?: Pattern) => CopySet<K>} snapshot
* @property {(keyPatt?: Pattern) => CopySet<any>} snapshot
* @property {(keyPatt?: Pattern) => number} getSize
* @property {(keyPatt?: Pattern) => void} clear
*/
/**
* @template K
* @typedef {RemotableObject & SetStoreMethods<K>} SetStore
*/
// TODO use Key for K
// TODO use Passable for V
/**
* @template {Key & object} [K=Key]
* @template {Passable} [V=Passable]
* @template K
* @template V
* @typedef {object} WeakMapStore

@@ -109,9 +114,11 @@ * @property {(key: K) => boolean} has Check if a key exists. The key can be any

* @property {(key: K) => void} delete Remove the key. Throws if not found.
* @property {(entries: CopyMap<K, V> | Iterable<[K, V]>) => void} addAll
* @property {(entries: CopyMap<any, any> | Iterable<[K, V]>) => void} addAll
*/
// TODO use Key for K
// TODO use Passable for V
/**
* @template {Key} [K=Key]
* @template {Passable} [V=Passable]
* @typedef {object} MapStore
* @template K
* @template V
* @typedef {object} MapStoreMethods
* @property {(key: K) => boolean} has Check if a key exists. The key can be any

@@ -127,10 +134,18 @@ * JavaScript value, though the answer will always be false for keys that

* @property {(key: K) => void} delete Remove the key. Throws if not found.
* @property {(entries: CopyMap<K, V> | Iterable<[K, V]>) => void} addAll
* @property {(entries: CopyMap<any, Passable> | Iterable<[K, V]>) => void} addAll
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<K>} keys
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<V>} values
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<[K, V]>} entries
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => CopyMap<K, V>} snapshot
* @property {(
* keyPatt?: Pattern,
* valuePatt?: Pattern,
* ) => CopyMap<any, Passable>} snapshot
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => number} getSize
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => void} clear
*/
/**
* @template [K=any]
* @template [V=any]
* @typedef {RemotableObject & MapStoreMethods<K, V>} MapStore
*/

@@ -137,0 +152,0 @@ // ///////////////////////// Deprecated Legacy /////////////////////////////////

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc