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

sophist

v1.1.0

Published

A (maintained) Sophia binding.

Downloads

3

Readme

sophist

A (maintained) Sophia binding.

Build Status

API

var db = new Sophist(path);

Create a db instance at path.

db.open([options], [fn]) / db.openSync([options])

Open the database, optionally with the given options.

Options:

  • createIfMissing: boolean, default true
  • readOnly: boolean, default false
  • pageSize: number, default 2048
  • mergeWatermark: number, default 100000
yield db.open({ createIfMissing: false });
db.open(function (err) { /* ... */ });
db.openSync();

db.close([fn]) / db.closeSync()

Close the database.

yield db.close();
db.close(function (err) { /* ... */ });
db.closeSync();

db.set(key, value, [fn]) / db.setSync(key, value)

Set key to value in the database.

yield db.set('foo', 'bar');
db.set('foo', 'bar', function (err) { /* ... */ });
db.setSync('foo', 'bar');

db.get(key, [fn]) / db.getSync(key)

Get the value of key.

var value = yield db.get('foo');
db.get('foo', function (err, value) { /* ... */ });
var value = db.getSync('foo');

db.delete(key, [fn]) / db.deleteSync(key)

Delete key from the database.

var value = yield db.delete('foo');
db.delete('foo', function (err) { /* ... */ });
var value = db.deleteSync('foo');

var iterator = db.iterator([options])

Create an iterator.

NOTE: Sophia does not support writes while an iterator is open.

Options:

  • reverse: boolean, default false
  • start: string, default null
  • end: string, default null
  • gte: boolean, default false
  • lte: boolean, default false
iterator.next([fn])

Get the next key/value pair from the iterator.

Upon reaching the last key, nulls will be provided.

var arr = yield iterator.next(); // [key, value]
iterator.next(function (err, key, value) { /* ... */ });
iterator.end([fn])

End the iterator.

yield iterator.end();
iterator.end(function (err) { /* ... */ });

var transaction = db.transaction()

Create a Sophia transaction.

During a transaction, all writes (set and delete) are posponed until transaction#commit() is called. Transaction writes may be reverted by calling transaction#rollback().

Unlike Sophia's raw C API, values set by transaction#set() and transaction#get() are not able to be retreived by sophist#get().

Sophia does not support nested or multiple transactions, so doing so will cause an error to be thrown.

var transaction = db.transaction();
var transaction2 = db.transaction(); // throws
transaction.set(key, value)

Push a set operation into the transaction.

yield db.set('foo', 'bar');
var transaction = db.transaction();
transaction.set('foo', 'baz');
var val = yield db.get('foo'); // bar
yield transaction.commit();
var val = yield db.get('foo'); // baz
transaction.delete(key)

Push a delete operation into the transaction.

yield db.set('foo', 'bar');
var transaction = db.transaction();
transaction.delete('foo');
var val = yield db.get('foo'); // bar
yield transaction.commit();
var val = yield db.get('foo'); // null
transaction.commit([fn])

Commit the operations stored by the transaction.

var transaction = db.transaction();
// ...
yield transaction.commit();
transaction.commit(function (err) { /* ... */ });
transaction.rollback([fn])

Rollback/revert the operations stored by the transaction.

var transaction = db.transaction();
// ...
yield transaction.rollback();
transaction.rollback(function (err) { /* ... */ });

License

MIT