New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

stower

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stower

Simple disk backed key/value store for node

latest
Source
npmnpm
Version
2.1.0
Version published
Weekly downloads
154
116.9%
Maintainers
1
Weekly downloads
 
Created
Source

stower

license Tests npm

Stower is a simple disk backed key/value store for node.

Why? because sometimes you just need to stow a few values, no database, no fuss. stower keeps your data in memory and writes it to disk as a readable JSON file in the background. It handles atomic saves, uses file locks to avoid conflicts, recovers from corrupt files, and stores everything in your systems cache folder (when no path provided).

Install

npm install stower

Usage

var stower = require('stower');

// persist (optional JSON file path)
stower.persist('./stow.json');

// enable debugging (console logs)
stower.debug = true;

// store some data
stower.set('token', { id: '123', key: 'abc' });

// retrieve it
var token = stower.get('token');

// check it exists
if (stower.exists('token')) {
    console.log('token exists');
}

// remove it
stower.remove('token');

// view all keys
console.log(stower.keys());

// view all values
console.log(stower.values());

// get the JSON file name and path
console.log(stower.filename);

// clear everything
stower.clear();

Properties

PropertyDescription
filenameReturns filename used so store data on disk
debugGet/set debug status (enables console logs)

Methods

MethodDescription
get(key)Retrieves a value by key, returns null if the key doesn't exist
set(key, value)Stores a value and schedules it to be saved to disk
remove(key)Deletes a key from the store and schedules the update to disk
exists(key, val)Checks if a key exists and optionally if it matches a given value using deep equality
keys()Returns an array of all stored keys
values()Returns an array of all stored values
clear()Deletes all stored data and schedules a save to disk
persist(filename)Loads previously saved values from disk and auto saves changes (optional filename)

Note: if persist() is not called, values only exist in memory.

Contributing

As always, pull requests are welcomed - but please ensure you provide a test where necesssary.

Tests

You can run the tests using npm test

Star

If you find this useful please star the repo, it helps us prioritise Open Source work.

History

For change-log, check releases.

License

MIT License © Orca Scan - a barcode app with simple barcode tracking APIs.

TODO

  • Add more Jasmine tests (PRs welcome)

Keywords

localStorage

FAQs

Package last updated on 07 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts