# @blackglory/store-js

> ```sh npm install --save @blackglory/store-js # or yarn add @blackglory/store-js ```

Latest version **0.18.4** (published 2026-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @blackglory/store-js
pnpm add @blackglory/store-js
yarn add @blackglory/store-js
bun add @blackglory/store-js
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.18.4 |
| Published | 2026-09-20 |
| First published | 2020-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 10 |
| Unpacked size | 30.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/@blackglory/store-js
- Repository: https://github.com/BlackGlory/store-js
- Homepage: https://github.com/BlackGlory/store-js#readme
- Issues: https://github.com/BlackGlory/store-js/issues
- npm.io page: https://npm.io/package/@blackglory/store-js

## Dependencies (10)

- [ws](https://npm.io/package/ws.md) ^8.21.0
- [justypes](https://npm.io/package/justypes.md) ^4.5.0
- [delight-rpc](https://npm.io/package/delight-rpc.md) ^7.0.0
- [extra-abort](https://npm.io/package/extra-abort.md) ^0.5.1
- [extra-websocket](https://npm.io/package/extra-websocket.md) ^0.5.3
- [@blackglory/errors](https://npm.io/package/@blackglory/errors.md) ^3.1.0
- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.4.0
- [extra-native-websocket](https://npm.io/package/extra-native-websocket.md) ^0.5.2
- [@delight-rpc/extra-websocket](https://npm.io/package/@delight-rpc/extra-websocket.md) ^0.7.8
- [@delight-rpc/extra-native-websocket](https://npm.io/package/@delight-rpc/extra-native-websocket.md) ^0.6.6

## Recent versions

- 0.18.4 (latest) — 2026-09-20
- 0.18.3 — 2026-05-24
- 0.18.2 — 2026-05-24
- 0.18.1 — 2025-11-25
- 0.18.0 — 2025-11-21
- 0.17.1 — 2025-07-22
- 0.17.0 — 2025-05-29
- 0.16.1 — 2023-06-11
- 0.16.0 — 2023-03-28
- 0.15.1 — 2023-03-11
- 0.15.0 — 2023-02-08
- 0.14.1 — 2023-01-30
- 0.14.0 — 2023-01-30
- 0.13.0 — 2022-11-13
- 0.12.2 — 2022-10-31
- … 67 more at https://npm.io/package/@blackglory/store-js/versions

## README

# store-js
## Install
```sh
npm install --save @blackglory/store-js
# or
yarn add @blackglory/store-js
```

## API
### StoreClient
```ts
interface IStoreClientOptions {
  server: string

  basicAuth?: {
    username: string
    password: string
  }
  timeout?: number
  retryIntervalForReconnection?: number
}

interface IStoreClientRequestOptions {
  signal?: AbortSignal
  timeout?: number | false
}

interface INamespaceStats {
  items: number
}

interface IItem {
  value: JSONValue
  revision: string
}

class IncorrectRevision extends CustomError {}

class StoreClient {
  static create(options: IStoreClientOptions): Promise<StoreClient>

  close(): Promise<void>

  getNamespaceStats(
    namespace: string
  , signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<INamespaceStats>

  getAllNamespaces(
    signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<string[]>

  getAllItemIds(
    namespace: string
  , signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<string[]>

  clearItemsByNamespace(
    namespace: string
  , signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<void>

  hasItem(
    namespace: string
  , itemId: string
  , signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<boolean>

  getItem(
    namespace: string
  , itemId: string
  , signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<IItem | null>

  /**
   * @throws {IncorrectRevision}
   * 在提供revision参数的情况下, 如果目标项目的revision值不等于参数, 或项目不存在, 则抛出此错误.
   */
  setItem(
    namespace: string
  , itemId: string
  , value: JSONValue
  , revision?: string | null
  , signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<string>

  /**
   * @throws {IncorrectRevision}
   * 在提供revision参数的情况下, 如果目标项目的revision值不等于参数, 或项目不存在, 则抛出此错误.
   */
  removeItem(
    namespace: string
  , itemId: string
  , revision?: string
  , signalOrOptions?: AbortSignal | IStoreClientRequestOptions
  ): Promise<void>
}
```

---
_Source: https://npm.io/package/@blackglory/store-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
