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

level-gc

v1.0.4

Published

Garbage collection for levelup

Downloads

23

Readme

level-gc

Garbage Collection for leveldb (levelup).

NPM

david-dm david-dm

Scan through your level instance and cull records based on custom logic.

var util = require("util")

var level = require("level")
var db = level("/tmp/mydb")
var lts = level("/tmp/long-term-storage")

var gc = require("level-gc")

// Create a GC filter to delete all records starting with 'temp'
var re = /^temp/
var scanner = gc(db, function (record) {
  // Return `true` for records you want removed.
  return re.exec(record.key)
}, lts)

scanner.run(function (err, start, end, scanned, culled) {
  /* ... */
})

scanner.on("finish", function (start, end, scanned, culled) { /* ... */ })

API

gc(db, filterFn [, lts])

  • db: A levelup-compatible instance. (e.g. levelup or any compliant wrapper such as level-sublevel or level-version)
  • filterFn: A function that accepts a levelup record and returns true for anything to be removed by the gc process. filterFn({key: key, value: value, ...})
  • (optional) lts: A long-term storage instance of the same type as the original db.

Returns an object that will let you trigger Garbage Collection runs.

If you provide the optional lts long term storage instance, as records are deleted they will be put into the lts instance.

Each run your function will be turned into a stream.Transform instance via through2-filter so you can stuff onto this and it will be available for each record in a single gc run for more complex filters.

.run([callback])

Execute the gc scan. Callback is callback(err, start, end, scanned, culled).

Events

  • finish: function (start, end, scanned, culled)

LICENSE

MIT