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

perseverant

v4.0.0

Published

An asynchronous, persistent, localForage inspired, filesystem based storage solution for NodeJS.

Downloads

6

Readme

Perseverant Build Status Coverage Status License: ISC

An asynchronous, persistent, localForage inspired, filesystem based storage solution for NodeJS.

Concept

Each key will be stored as regular file with optionally encrypted serialized data.

By default, everything is kept super simple so whatever value will be saved as JSON.

It is possible to create a new instance with a different name, folder, encryption or serialization.

API

Following the meta description of the API.

const perseverant = require('perseverant');
// or import perseverant from 'perseverant';

// by default, the name of the storage is 'global' but
// it is highly suggested to use your own project name instead
const storage = perseverant.createInstance('my-project'):Perseverant

// or ...
const storage = perseverant.createInstance({
  name,       // by default 'global'
  folder,     // by default $HOME/.config/perseverant
  serializer, // by default JSON
  password,   // if provided, it's used to encrypt
  salt        // if there is a password is used as salt
              // by default it's perseverant
}):Perseverant

// retrieve a key (read key file)
storage.getItem(
  key
  [,callback(value || null)]
):Promise<value || null>

// store a key (write key file)
storage.setItem(
  key,
  value
  [, callback(value)]
):Promise<value>

// remove a key (unlink key file)
storage.removeItem(
  key
  [, callback]
):Promise

// clear all keys for the named storage (rm -rf folder and its files)
// WARNING: if you call this on global name, it'll clean it all
storage.clear([callback]):Promise

// returns the length of keys, from 0 to N
storage.length([callback(length)]):Promise<length>

// returns all keys
storage.keys([callback(keys[])]):Promise<keys[]>

Things to consider

This project is not a database replacement, neither a secure way to store credentials, passwords, or any relevant data if you do not provide at least a password.

// insecure!
const storage = require('perseverant');

// secure \o/
const storage = require('perseverant').createInstance({
  name: process.env.APP_NAME,
  password: process.env.APP_SECRET
});

By default, everything is indeed stored as plain JSON, and in a location any other software can reach.

The goal of this project is to provide, specially to NodeJS CLI, a way to persist data in any kind of device.

Technically speaking

  • each key is converted into its base64 or encrypted counterpart, and its value stored via JSON.stringify
  • if you provide your own serializer, you can also store recursive data or buffers and binaries, currently not supported in core (to keep it simple)