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

@plaindb/log

v0.0.2

Published

A lightweight package that transforms any key-value database into an indexed, log-structured database.

Downloads

3

Readme

Log

npm pipeline license downloads

Gitlab Twitter Discord

A lightweight package that transforms any key-value database into an indexed, log-structured database. This wrapper allows you to perform array-like operations—such as push, pop, shift, and splice—on your data, treating the database as an ordered list of entries where each entry comes with a unique sequence number. Ideal for scenarios where the order of data entries matters, this package is versatile enough to integrate into various projects requiring structured, indexed data storage.

Features

  • Lightweight and fast
  • Key encoding using 'lexint'
  • Built-in iterator for easy data manipulation
  • Asynchronous API
  • Supports common array operations like push, pop, shift, and splice

Installation

Install the package with:

npm install @plaindb/log

Usage

First, import the Log library.

import Log from '@plaindb/log'

or

const Log = require('@plaindb/log')

Initialize

const logDB = new Log(dbInstance)
await logDB.start()

Or use the static start method:

const logDB = await Log.start(dbInstance)

Append Data

await logDB.append({ key: 'value' })

Push Data

await logDB.push({ anotherKey: 'anotherValue' })

Shift Data

const shiftedValue = await logDB.shift()

Pop Data

const poppedValue = await logDB.pop()

Get Data by Sequence

const value = await logDB.get(sequence)

List Data

const list = await logDB.list({ limit: 10, reverse: true })

Iterate Through Data

const iter = logDB.iterator({ gt: 10 })
for await (const item of iter) {
  console.log(item)
}

Splice Data

await logDB.splice(5, 2, { newItemKey: 'newValue' })

Documentation

API

Class: Log

Constructor: new Log(db)

  • db: The database instance to be used.

Static Methods:

  • static start(...args): Asynchronously initialize the log DB.

Instance Methods:

  • append(value): Appends a value to the log.
  • push(value): Appends a value to the log.
  • shift(): Removes and returns the first value.
  • pop(): Removes and returns the last value.
  • get(seq): Retrieves a value by its sequence.
  • list(opts): List the logs based on options.
  • iterator(opts): Returns an async iterator for log items.
  • splice(start, delCount, ...items): Similar to Array.prototype.splice but for the log.

Tests

In order to run the test suite, simply clone the repository and install its dependencies:

git clone https://gitlab.com/frenware/framework/plaindb/log.git
cd log
npm install

To run the tests:

npm test

Contributing

Thank you! Please see our contributing guidelines for details.

Donations

If you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!

Bitcoin (BTC):

1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF

Monero (XMR):

46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ

License

@plaindb/log is MIT licensed.