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

variable-store-manager

v1.0.7

Published

A simple module for managing and persisting variables, for global state mangment

Downloads

5

Readme


runme: id: 01HKJ15Q269A02S5053WC87Z8T version: v2.0

Variable Store Manager Library Overview The Variable Store Manager is a Node.js library that provides a flexible and dynamic way to manage variables and data in a file-based storage system. This library utilizes a Proxy object to intercept and handle various operations on the stored variables, allowing for functionalities such as getting, editing, adding, and deleting data.

Installation To use the Variable Store Manager in your project, you can install it using npm:

npm install variable-store-manager

Variable Store Manager Library Overview The Variable Store Manager is a Node.js library that provides a flexible and dynamic way to manage variables and data in a file-based storage system. This library utilizes a Proxy object to intercept and handle various operations on the stored variables, allowing for functionalities such as getting, editing, adding, and deleting data.

Installation To use the Variable Store Manager in your project, you can install it using npm:

bash Copy code npm install variable-store-manager Usage To use the Variable Store Manager in your Node.js application, follow these steps:

Import the library:

const VariableStoreManager = require('variable-store-manager');

Create an instance of the VariableStoreManager:

const variableStore = new VariableStoreManager();

Use the provided methods to interact with the stored variables:

// Get all variables
const allVariables = variableStore.getVariables();

// Add new data
variableStore.addData('newVariable', 'new value');

// Edit existing data
variableStore.editData('existingVariable', 'updated value');

// Delete data
variableStore.deleteData('variableToDelete');

API constructor(options: object) Creates a new instance of the VariableStoreManager.

options.fileName (optional): Specifies the name of the file used for storage. Default is 'storage.json'. getVariables(): object Returns an object containing all variables currently stored.

editVariable(oldName: string, newName: string): void Renames an existing variable from oldName to newName.

watchFileChanges(): void Starts watching changes to the storage file and reloads data when changes occur.

saveStoreData(): void Saves the current state of the storage to the file.

updateAllWatchers(): void Closes all file watchers and restarts watching for changes.

getData(path: string): any Retrieves data at the specified path in the storage.

addData(path: string, newData: any): void Adds new data at the specified path in the storage.

editData(path: string, newData: any): void Edits existing data at the specified path in the storage.

deleteData(path: string): void Deletes data at the specified path in the storage.

resolvePath(path: string): any Helper function to resolve paths in the storage and retrieve the corresponding data.

Proxy Behavior The library uses a Proxy to intercept and handle various operations on the stored variables. This includes getting, setting, and deleting variables. Additionally, functions such as getData, addData, editData, and deleteData are provided for more specific operations.

Variable Representation Variables can be of any type, including strings, numbers, objects, or functions. Functions are stored as strings and can be executed when retrieved.

File Storage The library persists data to a JSON file specified during instantiation. The file is created if it does not exist, and data is saved whenever changes occur.

Examples Here are some examples illustrating the usage of the Variable Store Manager:

const variableStore = new VariableStoreManager();

// Adding new data
variableStore.addData('name', 'John Doe');
variableStore.addData('age', 25);

// Retrieving variables
const allVariables = variableStore.getVariables();
console.log(allVariables);

// Editing data
variableStore.editData('age', 26);

// Deleting data
variableStore.deleteData('name');

// Saving changes to file
variableStore.saveStoreData();