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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fishbrain

v2.0.2

Published

Fish Brain ===

Readme

Fish Brain

A pure javascript in-memory database with support to save into file system.
This database is designed only for SMALL quantities of data (say 20mb = 2,621,440 characters).
Database files are just JSON files.

Install

npm i -S fishbrain

Instance

const Fishbrain = require('fishbrain')

To create a small fish with memory-only database (will forget everything when restart)

const smallFish = new Fishbrain('memory')

To create a big fish with file-system database (will persist)

const bigFish = new FishBrain('path_to_your_dbfile')

Your dbfile can be anything, no extension required and inside its just a plain JSON text file.

To keep a low memory footprint you can pass an optional shallow value when creating your brain

const bigFish = new FishBrain('path_to_your_dbfile', false)

your DB in filesystem will still have all data, but your copy in memory will only have reserved values

Create and Update

set(object)

If no _id is provided in the object when setting the record, a new record will be created and a new id will be returned.
If an existing _id is provided, it will replace matching keys and insert new ones.
If an un-existing _id is provided, it will create a new record with that _id.
If the existing record has value _protected, it will not be updated.

Read

get(query[, projection])  

When calling get with a query object, will return all items that match.
When calling get with an empty object, will return all items in the database.
When setting a projection, only the specified fields will be returned.

Delete

del(query)

When called with no query or empty query, will return with no action done. When called with a query object, all items matching that query will be removed from the DB

flush

flush()

Will delete all records from DB

Reserved keys

_id is used to create or update records
_ttl is used to set a time to live (see examples)
_protected is used to protect a value from being updated, but you still can delete it

Examples

const Fishbrain = require('fishbrain')
const fish = new Fishbrain('memory')

const id = fish.set({mykey: 'my value'})
const row1 = fish.get({_id: id})
// row1 = [{_id:<some uuid>, mykey: 'my value'}]

fish.set({_id: id, otherValue: 'yay'})
const row2 = fish.get({_id: id})
// row2 = [{_id:<some uuid>, mykey: 'my value', otherValue: 'yay'}]

fish.set({_id:'customText', bar:'foo'})
const row3 = fish.get({_id: `customText`})
// row3 = [{_id:'customText', bar:'foo'}]

const allRows = fish.get({})
// allRows = [
// 	{_id:<some uuid>, mykey: 'my value', otherValue: 'yay'},
// 	{_id:'customText', bar:'foo'}
// ]

const allRowsProjected = fish.get({},['bar'])
// allRowsProjected = [
// 	{bar: undefined},
// 	{bar: 'foo'}
// ]

const threeSecondsFromNow = new Date().getTime() / 1000 + 3
const dory = fish.set({
  _ttl: threeSecondsFromNow,
  nemo: 'P. Sherman 42 Wallaby Way, Sydney'
})
const result = fish.get({_id: dory},['nemo'])
// result = [{nemo: 'P. Sherman 42 Wallaby Way, Sydney'}]

setTimeout(() => {
  const result2 = fish.get({_id: dory},['nemo'])
  // result2 = []
},5000)

fish.del({bar:'foo'}) // all records with bar: 'foo' gone
fish.flush() // all gone