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

worsen

v0.0.5-beta.3

Published

A simple lock-and-release eventually-consistent DB to be consumed by multi-threaded applications in node.

Downloads

20

Readme

worsen - a persistence store for quick prototyping

A simple lock-and-release eventually-consistent DB to be consumed by multi-threaded applications in node.

Installation

npm i worsen

npm version

About

  • The database constructed as a utility for quick consumption by nodejs prototypes. It is not intended to be used in production.

  • It has been tested for multiple concurrent writes and reads on 8 cores, but it is not guaranteed to be safe for production use.

  • It can be used for maintaining queues and other data structures that are not expected to be updated frequently.

  • The store will backup the cache to a file before every write. The backup file is named <store-name>.cache.db.

Known Issues

  • There might be a case where lockfile cleanup fails. This is handled if retries exceed a certain number. The store removes itself from locked state. This though clears the locked state might not be able to recover the data if the thread which was previous holding the lock crashed. This is a known issue and will be fixed in the next release. This case has been completely avoided by having a poll rate over 10_000ms for our tests.

Usage:

const store = new PersistentStore<boolean>( // generic over T
  'persistent-store-test'// name for logs and file in db_dir
  {
    // boolean-> defaults to process.env.DEBUG_PERSISTENCE === 'true'
    is_debug: false 

    // optional-> defaults to  join(__dirname, 'db')
    db_dir: "." 
    }
)
store.init(
  // polling interval in ms
  5_000, 
  // optional array of seed data
  // type-> { uid:string, data:T }[] 
  // where T is generic over PersistentStore<T>
  // only updates the db if the db is empty
  [
	{
		uid: 'AppInit',
		data: true,
	},
])
// read from store - synchronous read.
const returned_value:bool = store.read('AppInit')
// write from store
await store.write('AppErrors', false)
// get the current state copy. 
// Copies memory.
// Can cause potential leaks if not
// used correctly. (like in loops)
await store.get_hashmap_state()

CLI

npm i -g worsen
  • Default Init

> init [db_dir] [name] # defaults to init ./db_dir worsen
worsen >
  • Init

> init ./db_dir data # change db location and/or name
data > 
  • List

worsen > list
{
  "key1": "value1",
  "key2": "value2",
  "key3": "value3",
}
  • Keys

worsen > keys # list keys of db after init
key1
key2
key3
  • Get Value

worsen > get key1 # get key value
value1
worsen > exit