Skip to main content
Home

Core package for @stash-it ecosystem, containing interfaces and types for main class, adapters and plugins (and some other things).

This package works with Node.js, BrowsersIt is unknown whether this package works with Cloudflare Workers, Deno, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.5.0)

@stash-it/core

logo-stash-it-color-dark 2x

Set of interfaces and types for @stash-it, for main class, adapters and plugins (and some other things).

The main ones you'll be interested in are:

  • StashItAdapter - base class used to create your own adapters
  • StashItPlugin type to create your own plugins

See usage for examples.

Installation

npm

npx jsr add @stash-it/core

deno

deno add @stash-it/core

yarn

yarn dlx jsr add @stash-it/core

pnpm

pnpm dlx jsr add @stash-it/core

bun

bunx jsr add @stash-it/core

Usage

StashItAdapter

import { StashItAdapter } from "@stash-it/core";

// Your adapter class should extend from the base abstract class.
class MyAdapter extends StashItAdapter {
  // Your implementation here.
}

The base class contains two methods, that you should implement if your adapter requires establishing a connection and/or disconnecting from a storage.

For instance:

import { StashItAdapter } from "@stash-it/core";

// Your adapter class should extend from the base abstract class.
class MyAdapter extends StashItAdapter {
  override async connect(): Promise<void> {
    // Depending on the storage, it can look different.
    // For example:
    this.#database.connect();
  }

  override async disconnect(): Promise<void> {
    this.#database.connect();
  }
}

StashItPlugin

import { type StashItPlugin } from "@stash-it/core";

// Your plugin can be a function that returns StashItPlugin:
const myPlugin = (someArgsIfNeedBe): StashItPlugin => {
  // Your implementation here.
};

// It can also be an object, depends on what your plugin needs:
const myPlugin2: StashItPlugin = {
  // Your implementation here.
};

License

MIT

Contribution

Feel free to open an issue or a pull request.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@stash-it/core

Import symbol

import * as core from "@stash-it/core";
or

Import directly with a jsr specifier

import * as core from "jsr:@stash-it/core";

Add Package

pnpm i jsr:@stash-it/core
or (using pnpm 10.8 or older)
pnpm dlx jsr add @stash-it/core

Import symbol

import * as core from "@stash-it/core";

Add Package

yarn add jsr:@stash-it/core
or (using Yarn 4.8 or older)
yarn dlx jsr add @stash-it/core

Import symbol

import * as core from "@stash-it/core";

Add Package

vlt install jsr:@stash-it/core

Import symbol

import * as core from "@stash-it/core";

Add Package

npx jsr add @stash-it/core

Import symbol

import * as core from "@stash-it/core";

Add Package

bunx jsr add @stash-it/core

Import symbol

import * as core from "@stash-it/core";