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

ltest

v2.1.2

Published

test function for leveldb testing

Readme

ltest Build Status

A test function that:

  • Sets up a fresh temporary levelup instance.
  • Calls back with t, db and createReadStream.
  • Closes db and removes files when a test ends via t.end().
  • Adds tests to make sure db is opened, closed and removed properly.
  • Supports multiple levelup backends via level-test, which also has built in support for MemDOWN. Default is leveldown.
  • Supports any test framework that has a test function and t.end and t.ok methods.

Extracted from the test code in level-ttl and made more generic.

Install

$ npm install ltest --save

Usage

var tape = require('tape')
var test = require('ltest')(tape)
test('put and stream', function (t, db, createReadStream) {
  db.put('foo', 'bar', function (err) {
    t.ok(!err, 'no put error')
    var count = 0
    createReadStream()
      .on('data', function (data) {
        t.equal(data.key, 'foo')
        t.equal(data.value, 'bar')
        ++count
      })
      .on('end', function () {
        t.equal(count, 1)
        t.end() // <-- will close the db and delete files
      })
  })
})
TAP version 13
# put and stream
ok 1 no error on open()
ok 2 valid db object
ok 3 no put error
ok 4 should be equal
ok 5 should be equal
ok 6 should be equal
ok 7 no error on close()
ok 8 db removed

1..8
# tests 8
# pass  8

# ok

Api

ltest([options, ]testFn)

Returns a test function of the form function (desc[, opts], cb) where desc is the test description, opts is an optional options object passed to underlying db and cb is a callback of the form function (t, db, createReadStream).

options object is optional and is passed on to levelup and to level-test. Use this to define things like 'keyEncoding' or other settings for levelup.

Set options.mem to true if you want an in memory db.

testFn is the test function that should be used. Use any framework you like as long as it's a function and supports t.end and t.ok methods.

var ltest = require('ltest')(require('tape'))

or

var ltest = require('ltest')(require('tap').test)

License

MIT