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

test-level

v0.0.3

Published

Create temporary levelup databases with unique names

Readme

test-level

Create temporary levelup databases, with unique names generated by tmpgen. Can remove directory on test end, db.close or before process exit (on node >= 0.12.11). Does not include levelup, leveldown or memdown - so you get to choose the versions. API unstable, expect breaking changes.

npm status Travis build status AppVeyor build status Dependency status

example

npm i levelup leveldown level-sublevel test-level

const disk = require('test-level')('my-module/*', { wrap: 'sublevel' })

const db1 = disk()
const db2 = disk()

// /tmp/my-module/1454283677055
// /tmp/my-module/1454283677055.001
console.log(db1.location, db2.location)

const sub = db1.sublevel('beep')

see also

Differences from level-test:

  • In level-test, opts.clean removes the directory before opening the db, in test-level it removes the directory after you're done
  • No browser support as of yet
  • Does not fallback to memdown if leveldown failed to load
  • Does not include memdown, leveldown or levelup

usage

npm i levelup leveldown memdown level-sublevel test-level existent

const level = require('test-level')
    , existent = require('existent')

// Create a levelup+memdown factory, with node-hat as
// name generator (see `npm docs tmpgen` for details)
const mem = level({ mem: true, valueEncoding: 'utf8', gen: 'hat' })

// Same as
const mem2 = level({ db: require('memdown'), gen: 'hat' })
const mem3 = level({ db: 'memdown', gen: 'hat' })

// Create a db and override the valueEncoding (or
// any other levelup option) of the factory
const db1 = mem({ valueEncoding: 'json' })

// Create a levelup+leveldown factory. Each db gets a unique temporary
// directory with the default monotonic-timestamp name generator and is
// wrapped with level-sublevel.
const diskA = level({ wrap: ['sublevel'] })
const db2 = diskA()
const sub = db2.sublevel('beep')

// Same, at custom tmp location, with wrapper options
const diskB = level('my-module/*', {
  wrap: [ ['sublevel', { valueEncoding: 'json' }] ]
})

const db3 = diskB()

// Remove created dbs before process exit (ignored if mem is true)
const diskC = level('beep-*', { clean: true })

// Create db in a subdirectory
const db4 = diskC('special-name')

;[db1, db2, db3, db4].forEach((db, i) => {
  console.log('db %d', i+1, existent.sync(db.location), db.location)
})

process.on('exit', function(){
  console.log('\nExiting\n')
  ;[db1, db2, db3, db4].forEach((db, i) => {
    // db4 is removed
    console.log('db %d', i+1, existent.sync(db.location), db.location)
  })
})

Output:

db 1 false 8a2fe3f361ff5365dd956da54fcca014
db 2 true /tmp/test-level/1454283677010
db 3 true /tmp/my-module/1454283677055
db 4 true /tmp/beep-1454283677058/special-name

Exiting

db 1 false 8a2fe3f361ff5365dd956da54fcca014
db 2 true /tmp/test-level/1454283677010
db 3 true /tmp/my-module/1454283677055
db 4 false /tmp/beep-1454283677058/special-name

tape test helper

[todo: write docs or move that stuff to another module]

api

main(arg[,opts])

...

install

With npm do:

npm install test-level

license

MIT © Vincent Weevers