Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Latest commit

 

History

History
97 lines (63 loc) · 3.73 KB

File metadata and controls

97 lines (63 loc) · 3.73 KB

level-js

An abstract-leveldown compliant store on top of IndexedDB, which is in turn implemented on top of LevelDB which brings this whole shebang full circle.

level badge npm npm next Travis npm JavaScript Style Guide

Background

Here are the goals of level-js:

  • Store large amounts of data in modern browsers
  • Pass the full abstract-leveldown test suite
  • Support Buffer values (in all target environments)
  • Support all key types of IndexedDB Second Edition, including binary keys (depends on environment)
  • Support all value types of the structured clone algorithm (depends on environment) except for null and undefined
  • Be as fast as possible
  • Sync with multilevel over either ASCII or binary transports.

Being abstract-leveldown compliant means you can use many of the Level modules on top of this library. For some demos of it working, see @brycebaril's presentation Path of the NodeBases Jedi.

Example

This assumes use of version 3.0.0-rc1. The next release will have an upgrade guide. Until then, please see the changelog.

var levelup = require('levelup')
var leveljs = require('level-js')
var db = levelup(leveljs('bigdata'))

db.put('hello', Buffer.from('world'), function (err) {
  if (err) throw err

  db.get('hello', function (err, value) {
    if (err) throw err

    console.log(value.toString()) // 'world'
  })
})

Browser Support

Sauce Test Status

Install

npm install level-js       # Stable
npm install level-js@next  # Bleeding edge

Not to be confused with leveljs.

This library is best used with browserify.

API

db = leveljs(location[, options])

Returns a new leveljs instance. location is the string name of the IDBDatabase to be opened, as well as the object store within that database. The database name will be prefixed with options.prefix.

options

The optional options argument may contain:

  • prefix (string, default: 'level-js-'): Prefix for IDBDatabase name.
  • version (string | number, default: 1): The version to open the database with.

See IDBFactory#open for more details.

Running Tests

git clone git@github.com:Level/level-js.git
cd level-js
npm install
npm test

It will print out a URL to open in a browser of choice.

Big Thanks

Cross-browser Testing Platform and Open Source ♥ Provided by Sauce Labs.

Sauce Labs logo

License

MIT © 2012-present Max Ogden and Contributors.