Skip to content

Commit

Permalink
making changes to type declerations to pass build
Browse files Browse the repository at this point in the history
  • Loading branch information
apetta committed Jul 31, 2023
1 parent f154940 commit da7fa4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions packages/access-client/src/drivers/memory.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
/**
* @template T
* @typedef {import('./types').Driver<T>} Driver
*/

/**
* Driver implementation that stores data in memory."
*
* Usage:
*
* ```js
* import { MemoryDriver } from '@web3-storage/access/drivers/memory'
* ```
*
* @template {Record<string, any>} T
* @implements {Driver<T>}
*/
export class MemoryDriver {
/**
* @type {T}
* @type {T|undefined}
*/
#data;

constructor() {
this.#data = {};
this.#data = undefined;
}

async open() {}

async close() {}

async reset() {
this.#data = {};
this.#data = undefined;
}

/** @param {T} data */
Expand All @@ -27,6 +40,7 @@ export class MemoryDriver {

/** @returns {Promise<T|undefined>} */
async load() {
if (this.#data === undefined) return;
if (Object.keys(this.#data).length === 0) return;
return this.#data;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/access-client/src/stores/store-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { MemoryDriver } from "../drivers/memory.js";
* import { StoreMemory } from '@web3-storage/access/stores/store-memory'
* ```
*
* @extends {MemoryDriver<import('@web3-storage/access/src/types.js').AgentDataExport>}
* @extends {MemoryDriver<import('../types').AgentDataExport>}
*/
export class StoreMemory extends MemoryDriver {}

0 comments on commit da7fa4e

Please sign in to comment.