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

jellyfishdb

v0.1.8

Published

NoSQL database, based on file storage

Downloads

2

Readme

JellyfishDB

Embedded NoSQL "database", based on file storage.

License

MIT

Install

npm i jellyfishdb

Work schema

work schema

Example

//WARNING!!!
//if you use path library in jellyfishDB function (see function getFileSubdirFromKey in driver2)
//don't use:
//import * as path from 'path'
//use:
//import path from 'path'
import path from 'path'
import * as fs from 'fs-extra'
import {CreateDriver, EnumQuery, TExecResult} from 'jellyfishdb'

//in examples use property "key" in Person as primary key
export type TPerson = {key: string, login: string, email: string, country: string }
export type TPersonCache = {key: string, login: string, ddm: string }

const driver1StorageGir = path.join(__dirname, '../../test/data/driver1')
const driver2StorageGir = path.join(__dirname, '../../test/data/driver2')

fs.emptyDirSync(driver1StorageGir)
fs.emptyDirSync(driver2StorageGir)

const personList: TPerson[] = [
    { key: null, login: 'peter', email: '[email protected]', country: null },
    { key: null, login: 'anna', email: '[email protected]', country: 'France' },
    { key: null, login: 'helen', email: null, country: 'Spain' }
]

//minimal
const driver1 = CreateDriver<TPerson,TPersonCache>({
    getKeyFromPayload(payLoad) {
        return payLoad.key
    },
    setKeyToPayload(payLoad, keyDefault) {
        payLoad.key = keyDefault
        return payLoad.key
    }
})

//maximal
const driver2 = CreateDriver<TPerson,TPersonCache>({
    getKeyFromPayload(payLoad) {
        return payLoad.key
    },
    setKeyToPayload(payLoad, keyDefault) {
        payLoad.key = `psn-${keyDefault}`
        return payLoad.key
    },
    cache: {
        onDelete(stamp, cache) {
            const fnd = cache.find(f => f.key === stamp.payLoadStamp.data.key)
            if (fnd) {
                fnd.ddm = stamp.wrapStamp.wrap.ddm
            }
        },
        onShrink: (cache) => {
            let fndIdx = cache.findIndex(f => f.ddm)
            while (fndIdx >= 0) {
                cache.splice(fndIdx, 1)
                fndIdx = cache.findIndex(f => f.ddm)
            }
        },
        onInsert: (stamp, cache) => {
            cache.push({ login: stamp.payLoadStamp.data.login, key: stamp.payLoadStamp.data.key, ddm: stamp.wrapStamp.wrap.ddm })
        },
        onUpdate: (stamp, cache) => {
            const fnd = cache.find(f => f.key === stamp.payLoadStamp.data.key)
            if (fnd) {
                fnd.login = stamp.payLoadStamp.data.login
                fnd.ddm = stamp.wrapStamp.wrap.ddm
            } else {
                cache.push({ login: stamp.payLoadStamp.data.login, key: stamp.payLoadStamp.data.key, ddm: stamp.wrapStamp.wrap.ddm })
            }
        },
    },
    storage: {
        getFileNameFromKey(key, fileNameDefault) {
            return `prefix-${fileNameDefault}`
        },
        getFileSubdirFromKey(key) {
            const pathPart = key.substring(4, 7)
            return path.join(...pathPart)
        }
    }
})

driver1.connect({dir: driver1StorageGir, countWorker: 8}, error => {
    console.error(error)
})
driver2.connect({dir: driver2StorageGir, countWorker: 8}, error => {
    console.error(error)
})

const queueResult = [] as {driverIdx: number, personIdx: number, taskKey: string, result?: TExecResult<TPerson>}[]

//example - insert data
personList.forEach((person, personIdx) => {
    const taskKey1 = driver1.exec({kind: EnumQuery.insert, payLoad: person})
    const taskKey2 = driver2.exec({kind: EnumQuery.insert, payLoad: person})
    queueResult.push({driverIdx: 1, personIdx, taskKey: taskKey1})
    queueResult.push({driverIdx: 2, personIdx, taskKey: taskKey2})
})

const timer = setInterval(() => {
    queueResult.filter(f => !f.result).forEach(q => {
        const result = q.driverIdx === 1 ? driver1.result(q.taskKey) : q.driverIdx === 2 ? driver2.result(q.taskKey) : undefined
        if (result) {
            console.log(`driver${q.driverIdx}-result:`, result)
            q.result = result
        }
    })
    if (queueResult.some(f => !f.result)) {
        return
    }
    console.log('driver2-cache:', driver2.cache)
    console.log('app can be stopped...')
    clearInterval(timer)
}, 1000)