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

bplus

v0.0.1

Published

Node.js bindings for a bplus C libarary

Downloads

2

Readme

Node.js bindings for a bplus C libarary Build Status

** Danger zone! Possible unicorns and rainbows! **

Both database engine and node.js bindings are in development now, use carefully.

Installation

npm install bplus

Usage

var bplus = require('bplus');


var db = bplus.create().open('/tmp/1.bp');

db.set('key', 'value', function(err) {
  db.get('key', function(err, value) {
    console.log('voila! Key is in database: %s', value);
    db.close();
  });
});

API

Basics

db = bplus.create()

Returns instance of database wrapper.

db.open(filename)

Associates database with file until .close() will be called.

db.close()

Closes database.

db.set('key', 'value', [callback])

Stores key/value pair in database. Both key and value arguments may be instances of Buffer. If write will fail, callback will receive err as the first argument.

Note: If key is already in database - previous value will be unconditionally overwritten.

db.get('key', [callback])

Searches database for key and invokes callback with it's value (or error). key may be a Buffer or a String.

Note: Callback will also receive ref as third argument, see MVCC part below for details.

db.remove('key', [callback])

Removes key from database or invokes callback with error if operation has failed (callback will be called anyway upon completion).

db.compact([callback])

Runs compaction on database. Will significantly reduce database size and increase speed of lookup and insertion.

Note: For big databases may take some time (~ 30 sec for a database with 1000000 records).

MVCC

db.update('key', 'value', filter, [callback])

Same as .set(), but if key is already in database - filter(previousValue, currentValue) will be called. Value will be replaced only if return value of filter is not false.

db.removev('key', [filter], [callback]);

Same as .remove(), but filter is called before removing actual value. Should be used to ensure that only specific value will be removed.

db.getPrevious(ref, [callback])

Returns previous value of key. callback will receive three arguments (as in .get()).

Note: That after compaction

Streaming

db.getRange('start', 'end', [filter])

Returns a promise object that'll emit message event for each key/value pair found in specified range. end will be emitted on stream finish.

var promise = db.getRange('start', 'end');

promise.on('message', function(key, value, ref) {
  // see `.get()` for details
});

promise.on('end', function() {
  // Ended
});

filter can be passed to load values only of specific keys. Value won't be loaded (and emitted in message event) only if filter returned false for it.

db.getRange('start', 'end', function(key) {
  return key.toString() === 'somekey';
});

db.bulk(keyValues, [callback])

Inserts multiple key/values in one atomic operation.

var kvs = [
  {
    key: 'a',
    value: 'a'
  },
  {
    key: 'b',
    value: 'b'
  }
];
db.bulk(kvs, function(err) {
  // .. your code ..
});

db.bulkUpdate(keyValues, filter, [callback])

Same as .bulk, but with filter as in .update().

LICENSE

This software is licensed under the MIT License.

Copyright Fedor Indutny, 2012.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.