reposy
v1.2.1
Published
Repository
Downloads
22
Readme
Repository
Repository.
Usage
Prepare
Import types
/**
* @template {unknown} T
*
* @typedef {import('reposy').IRepository<T>} IRepository
*/
Create repository
import {
RepositoryFactory,
ArrayedRepository,
ModeledRepository,
KeyedRepository,
ObjectedRepository
} from 'reposy';
const repositoryFactory = new RepositoryFactory({
Arrayed: ArrayedRepository,
Modeled: ModeledRepository,
Keyed: KeyedRepository,
Objected: ObjectedRepository
});
/** @type {Record<PropertyKey, unknown>} */
const object = {};
const repository = repositoryFactory.createObjected(object);
Commands
Get
const data = await repository.set('key');
Set
await repository.set('key', 'data');
Has
const has = await repository.has('key');
Remove
await repository.remove('key');
Clear
await repository.clear();