https://github.com/blackglory/store-js
🌲 The JavaScript SDK for Store
https://github.com/blackglory/store-js
browser esm library nodejs npm-package typescript
Last synced: 3 months ago
JSON representation
🌲 The JavaScript SDK for Store
- Host: GitHub
- URL: https://github.com/blackglory/store-js
- Owner: BlackGlory
- License: mit
- Created: 2020-12-01T10:36:29.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-06-11T06:45:01.000Z (about 3 years ago)
- Last Synced: 2025-02-04T09:47:53.976Z (over 1 year ago)
- Topics: browser, esm, library, nodejs, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@blackglory/store-js
- Size: 1.33 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# store-js
## Install
```sh
npm install --save @blackglory/store-js
# or
yarn add @blackglory/store-js
```
## API
### StoreClient
```ts
interface IStoreClientOptions {
server: string
timeout?: number
retryIntervalForReconnection?: number
}
interface INamespaceStats {
items: number
}
interface IItem {
value: JSONValue
revision: string
}
class IncorrectRevision extends CustomError {}
class StoreClient {
static create(options: IStoreClientOptions): Promise
close(): Promise
getNamespaceStats(
namespace: string
, signal?: AbortSignal
): Promise
getAllNamespaces(signal?: AbortSignal): Promise
getAllItemIds(namespace: string, signal?: AbortSignal): Promise
clearItemsByNamespace(namespace: string, signal?: AbortSignal): Promise
hasItem(
namespace: string
, itemId: string
, signal?: AbortSignal
): Promise
getItem(
namespace: string
, itemId: string
, signal?: AbortSignal
): Promise
/**
* @throws {IncorrectRevision}
* 在提供revision参数的情况下, 如果目标项目的revision值不等于参数, 或项目不存在, 则抛出此错误.
*/
setItem(
namespace: string
, itemId: string
, value: JSONValue
, revision?: string | null
, signal?: AbortSignal
): Promise
/**
* @throws {IncorrectRevision}
* 在提供revision参数的情况下, 如果目标项目的revision值不等于参数, 或项目不存在, 则抛出此错误.
*/
removeItem(
namespace: string
, itemId: string
, revision?: string
, signal?: AbortSignal
): Promise
}
```