New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@agoric/store

Package Overview
Dependencies
Maintainers
5
Versions
2650
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.4.23 to 0.5.0

src/legacyMap.js

15

CHANGELOG.md

@@ -6,2 +6,17 @@ # Change Log

## [0.5.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/store@0.4.22...@agoric/store@0.5.0) (2021-08-14)
### ⚠ BREAKING CHANGES
* **swingset:** Convert RESM to NESM
### Code Refactoring
* **swingset:** Convert RESM to NESM ([bf7fd61](https://github.com/Agoric/agoric-sdk/commit/bf7fd6161a79e994c3bc48949e4ccb01b4048772))
### 0.26.10 (2021-07-28)
### [0.4.23](https://github.com/Agoric/agoric-sdk/compare/@agoric/store@0.4.22...@agoric/store@0.4.23) (2021-07-28)

@@ -8,0 +23,0 @@

24

package.json
{
"name": "@agoric/store",
"version": "0.4.23",
"version": "0.5.0",
"description": "Wrapper for JavaScript map",
"parsers": {
"js": "mjs"
},
"type": "module",
"main": "src/index.js",

@@ -36,10 +34,9 @@ "engines": {

"dependencies": {
"@agoric/assert": "^0.3.7",
"@agoric/marshal": "^0.4.20"
"@agoric/assert": "^0.3.8",
"@agoric/marshal": "^0.4.21"
},
"devDependencies": {
"@agoric/install-ses": "^0.5.21",
"@agoric/swingset-vat": "^0.19.0",
"ava": "^3.12.1",
"esm": "agoric-labs/esm#Agoric-built"
"@agoric/install-ses": "^0.5.22",
"@agoric/swingset-vat": "^0.20.0",
"ava": "^3.12.1"
},

@@ -53,3 +50,3 @@ "files": [

"extends": [
"@endo"
"@agoric"
]

@@ -71,8 +68,5 @@ },

],
"require": [
"esm"
],
"timeout": "2m"
},
"gitHead": "835ce6579a257107f363e29a234643679844cc0e"
"gitHead": "1e1b5328182b5f8ae2de0de42901f4698f4c3ed8"
}

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

# TODO REWRITE
# Store
A wrapper around JavaScript Map.
A wrapper around JavaScript Map.

@@ -5,0 +7,0 @@ Store adds some additional functionality on top of Map.

@@ -1,8 +0,9 @@

export { makeStore } from './store.js';
export { makeWeakStore } from './weak-store.js';
export { makeExternalStore } from './external/default.js';
export { makeMemoryExternalStore } from './external/memory.js';
export { makeHydrateExternalStoreMaker } from './external/hydrate.js';
// Backward compatibility.
export { makeStore as default } from './store.js';
export { makeScalarMap, makeScalarMap as makeStore } from './scalarMap.js';
export {
makeScalarWeakMap,
makeScalarWeakMap as makeWeakStore,
} from './scalarWeakMap.js';
// export default as well as makeLegacy* only for compatibility
// during the transition.
export { makeLegacyMap, makeLegacyMap as default } from './legacyMap.js';
export { makeLegacyWeakMap } from './legacyWeakMap.js';

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

// @ts-check
// eslint-disable-next-line spaced-comment

@@ -5,16 +7,29 @@ /// <reference types="ses"/>

/**
* @typedef {Record<string, Function>} ExternalInstance
* @typedef {Object} StoreOptions
*
* @property {boolean=} longLived Which way to optimize. True means that we
* expect this store to outlive most of its keys, in which
* case we internally may use a `WeakMap`. Otherwise we internally may
* use a `Map`.
* Defaults to true, so please mark short lived stores explicitly
*/
/**
* @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.
* @template {Structure} K
* @template {Passable} V
* @typedef {Object} Store
*
* @property {(key: any) => boolean} has
* Check if a key exists. The key can be any JavaScript value, though the
* answer will always be false for keys that cannot be found in this map
* @property {(key: K, value: V) => void} init
* Initialize the key only if it doesn't already exist. The key must
* be one allowed by this map. For example a scalarMap only allows
* primitives and remotables.
* @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

@@ -26,78 +41,46 @@ * @property {() => V[]} values - Return an array of values

/**
* @template K,V
* @typedef {Object} WeakStore - A safety wrapper around a WeakMap
* @property {(key: any) => 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: any) => 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.
* @template {Structure} K
* @template {Passable} V
* @typedef {Object} WeakStore
*
* @property {(key: K) => boolean} has
* Check if a key exists. The key can be any JavaScript value, though the
* answer will always be false for keys that cannot be found in this map
* @property {(key: K, value: V) => void} init
* Initialize the key only if it doesn't already exist. The key must
* be one allowed by this map. For example a scalarMap only allows
* primitives and remotables. For now, a scalarWeakMap allows remotables.
* @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.
*/
// ////////////////////////////////////////////////////////////////////
/**
* Distinguishes between adding a new key (init) and updating or
* referencing a key (get, set, delete).
*
* `init` is only allowed if the key does not already exist. `Get`,
* `set` and `delete` are only allowed if the key does already exist.
*
* @template K,V
* @callback MakeWeakStore
* @param {string} [keyName='key'] - the column name for the key
* @returns {WeakStore<K,V>}
*/
/**
* An external store for a given maker function.
* TODO: We should provide makers for other kinds of data structures.
* Weak sorted lists, weak priority queues, and many others.
* @typedef {Object} LegacyWeakMap
*
* @template {(...args: Array<any>) => ExternalInstance} M
* @typedef {Object} ExternalStore
* @property {M} makeInstance Create a fresh instance
* @property {MakeWeakStore<ReturnType<M>, any>} makeWeakStore Create an
* external weak store indexed by an instance
* @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.
*/
/**
* @typedef {Record<string, any>} HydrateData
*/
/**
* @typedef {[number, number]} HydrateKey
* @typedef {true} HydrateInit
* @typedef {Object} HydrateHook
* @property {(value: any) => HydrateKey} getKey
* @property {(key: HydrateKey) => any} load
* @property {(storeId: number) => void} drop
*/
/**
* An external store that decouples the closure data from the returned
* "representative" instance.
* @template K,V
* @callback MakeLegacyWeakMap
*
* @template {Array<any>} A
* @template {ExternalInstance} T
* @callback MakeHydrateExternalStore
* @param {string} instanceKind
* @param {(...args: A) => HydrateData} adaptArguments
* @param {(init?: HydrateInit) => (data: HydrateData) => T} makeHydrate
* @returns {ExternalStore<(...args: A) => T>}
* @param {string} [keyName='key'] - the column name for the key
* @returns {LegacyWeakMap}
*/
/**
* @typedef {Object} HydrateStore The store needed to save closed-over
* per-instance data
* @property {(id: number, data: HydrateData) => void} init
* @property {(id: number) => HydrateData} get
* @property {(id: number, data: HydrateData) => void} set
* @property {() => WeakStore<ExternalInstance, any>} makeWeakStore
*/
/**
* @typedef {Object} BackingStore This is the master store that reifies storeIds
* @property {(storeId: number, instanceKind: string) => HydrateStore} makeHydrateStore
* @property {(storeId: number) => HydrateStore} getHydrateStore
*/
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