JSPM

@nodesandbox/async-storage

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q43293F
  • License MIT

A TypeScript service for managing asynchronous storage using AsyncLocalStorage.

Package Exports

  • @nodesandbox/async-storage
  • @nodesandbox/async-storage/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nodesandbox/async-storage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@nodesandbox/async-storage

A TypeScript service for managing asynchronous storage using AsyncLocalStorage.

Installation

You can install the package via npm:

npm install @nodesandbox/async-storage

Usage

Here is an example of how to use the AsyncStorageService:

import { AsyncStorageService } from '@nodesandbox/async-storage';

const storage = AsyncStorageService.getInstance();

storage.run(() => {
  storage.set('key', 'value');
  console.log(storage.get('key')); // Output: value
});

API

AsyncStorageService

  • getInstance(): AsyncStorageService: Returns the singleton instance of AsyncStorageService.

  • set(key: string, value: any): void: Sets a value in the asynchronous storage.

  • get(key: string): any: Retrieves a value from the asynchronous storage.

  • run(callback: () => void, initialValue?: Map<string, any>): void: Runs a callback function with a new storage context.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

See CONTRIBUTING.md for contribution guidelines.