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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vmo-store

v0.0.2

Published

storage proxy

Downloads

177

Readme

VmoStore

forcha VmoStore is a local cache management class designed for convenient data management, storage, and retrieval in a browser environment. It is engineered to include version control, namespace isolation, and configurable storage capacity limits, making it suitable for various caching scenarios.

Features

  • Supports caching of multiple data types.
  • Configurable data structure specifications and expiration times.
  • Storage namespaces and version management.
  • Optional data encryption support.
  • Capacity-limited storage management and cache cleaning.

Installation

npm i vmo-store

Usage Instructions

Create Instance

const vmoStore = new VmoStore({
  namespace: 'myApp', // Namespace
  prefix: 'APP', // Prefix alias
  version: 1, // Version
  cryptoKey: 'yourCryptoKeyHere', // Encryption key. If empty, cache encryption will not be enabled
  dataProps: {
    user: {
      type: String, // Data type supports multiple types [String, Array, Number]
      storge: 'localStorage', // Specify localStorage
      default: '111', // Default value
      expireTime: '1d' // Expiration time of 1 day,
      /**
       * Expiration time can be set in 3 ways:
       * 1. Numeric value: In milliseconds added from the time of writing or updating + expireTime
       * 2. Character type: s for seconds, m for minutes, h for hours, d for days; converted to milliseconds before adding from the time of writing or updating + expireTime
       * 3. Fixed date format "YYYY-MM-DD HH:mm:ss" for fixed expiration
       */
    },
    settings: {
      type: [Object, Array], // Data type
      default: () => ({}), // For reference types, use a function form to return the default value
      storge: 'sessionStorage' // Specify sessionStorage as the cache
    }
  }, // Store data declaration
  capacity: {
    localStorage: 5000, // LocalStorage limit
    sessionStorage: 3000 // SessionStorage limit
  },
  cacheInitCleanupMode: 'self' // Cache cleanup mode on initialization, options are 'all': clear all except self or 'self': clear only caches with the same namespace and prefix alias except for different versions
})

TypeScript

const vmoStore = new VmoStore<{user:string,settings:Record<string,any>|any[]}>({
   namespace: 'myApp', // Namespace
  prefix: 'APP', // Prefix alias
  version: 1, // Version
  cryptoKey: 'yourCryptoKeyHere', // Encryption key. If empty, cache encryption will not be enabled
  dataProps: {
    user: {
      type: String, // Data type supports multiple types [String, Array, Number]
      storge: 'localStorage', // Specify localStorage
      default: '111', // Default value
      expireTime: '1d' // Expiration time of 1 day,
      /**
       * Expiration time can be set in 3 ways:
       * 1. Numeric value: In milliseconds added from the time of writing or updating + expireTime
       * 2. Character type: s for seconds, m for minutes, h for hours, d for days; converted to milliseconds before adding from the time of writing or updating + expireTime
       * 3. Fixed date format "YYYY-MM-DD HH:mm:ss" for fixed expiration
       */
    },
    settings: {
      type: [Object, Array], // Data type
      default: () => ({}), // For reference types, use a function form to return the default value
      storge: 'sessionStorage' // Specify sessionStorage as the cache
    }
  }, // Store data declaration
  capacity: {
    localStorage: 5000, // LocalStorage limit
    sessionStorage: 3000 // SessionStorage limit
  },
  cacheInitCleanupMode: 'self' // Cache cleanup mode on initialization, options are 'all': clear all except self or 'self': clear only caches with the same namespace and prefix alias except for different versions
})

Set Data

vmoStore.setData('user', 'John Doe')

Get Data

const user = vmoStore.getData('user')

Clear Data

// Clear data by property
vmoStore.clearData('user')

// Clear all cache data
vmoStore.clear('localStorage')

Update Property Definition

vmoStore.updateProp({
  newProp: { type: Number, default: 0, storge: 'localStorage' }
})

Get Cache Properties

const props = vmoStore.getProps()

Get Namespace

const namespace = vmoStore.getNameSpace()

Storage Capacity

const capacity = vmoStore.getCapacity()

Method Details

  • constructor(config: StoreParams): Initializes a VmoStore instance. The config object is used to configure namespace, version, encryption key, data properties, storage capacities, and cache cleaning mode.

  • setData(prop: string, value: any): Sets cache data.

  • getData(prop: string): Retrieves cache data.

  • clear(type?: ‘localStorage’ | ‘sessionStorage’): Clears the specified type of storage; if unspecified, clears all storage.

  • clearData(prop: string | string[]): Clears specified cache data.

  • removeProp(prop: string | string[]): Removes cache declaration and data.

  • updateProp(props: DataProps): Updates cache property definitions.

  • getCapacity(): Gets current storage capacity usage and limits.

  • getProps(key?: string): Retrieves cache property definitions.

  • getNameSpace(): Retrieves namespace definition.

Error Handling

VmoStore may throw errors in certain scenarios, such as when storage capacity is exceeded or property types mismatch. Ensure sufficient storage space is configured for large data volumes.

Notes

  • If using data encryption, ensure the encryption key length is adequate and keep it secure.
  • When storage capacity limits are set, data writing might fail due to exceeding limits.
  • Ensure data source security when using eval to avoid security vulnerabilities.