npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-persist-manager

v1.0.8

Published

Asyncronous Node.js storage manager in type script

Downloads

8,985

Readme

NodeStorageManager and NodeStorage

npm version npm downloads Node.js CI


NodeStorage is a lightweight, file-based storage management system for Node.js, built on top of node-persist. It allows for easy and intuitive handling of persistent key-value storage directly within your Node.js applications. This system is ideal for small to medium-sized projects requiring simple data persistence without the overhead of a database system.

Features

  • Simple and intuitive API for data storage and retrieval.
  • Asynchronous data handling.
  • Customizable storage directories for isolated storage contexts.
  • Built-in logging capabilities for monitoring storage initialization and operations.
  • Comprehensive test suite using Jest to ensure reliability and performance.
  • Detailed documentation with JSDoc for better developer experience.

Getting Started

Prerequisites

  • Node.js installed on your machine.
  • Basic knowledge of TypeScript and Node.js.

Installation

To get started with NodeStorage in your package

npm install node-persist-manager

Usage

Initializing NodeStorageManager:

Create an instance of NodeStorageManager to manage your storage instances.

import { NodeStorageManager, NodeStorage } from 'node-persist-manager';
const storageManager = new NodeStorageManager({
  dir: 'path/to/storage/directory', // Optional: Customize the storage directory.
  logging: true, // Optional: Enable logging.
});

Creating a Storage Instance:

Use the manager to create a new storage context.

const myStorage = await storageManager.createStorage('myStorageName');

Using the Storage:

Set a value:

await myStorage.set('myKey', 'myValue');

Get a value:

const value = await myStorage.get('myKey');
console.log(value); // Outputs: 'myValue'

Remove a value:

await myStorage.remove('myKey');

Clear the storage:

await myStorage.clear();

API Reference

NodeStorageManager methods:

  • async createStorage(storageName: string): Promise<NodeStorage>

  • async removeStorage(storageName: string): Promise<boolean>

  • async logStorage(): Promise<void>

  • async getStorageNames(): Promise<NodeStorageName[]>

  • async logStorage(): Promise<void>

NodeStorage methods:

  • async set<T = any>(key: NodeStorageKey, value: T): Promise<void>

  • async get<T = any>(key: NodeStorageKey, defaultValue?: T): Promise<T>

  • async remove(key: NodeStorageKey): Promise<void>

  • async clear(): Promise<void>

  • async logStorage(): Promise<void>

Contributing

Contributions to NodeStorage are welcome.

License

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

Acknowledgments

Thanks to node-persist for providing the underlying storage mechanism.