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

vertical-client

v1.0.2

Published

super levelDB client

Downloads

3

Readme

vertical-client(just beta now!)

levelDB distributed.Server and Client!

#install npm install vertical-client

vertical-server & vertical-client

#use(must install vertical-server) *click here to konw vertical-server ##base example

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	return vcdb.put('a','aaa');
})
.then((res)=>{
	console.log(res);
	return vcdb.get('a');
})
.then((res)=>{
	console.log(res);
	return vcdb.del('a');
})
.then((res)=>{
	console.log(res);
})
.catch((err)=>{
	console.log(err);
});

level & destroy & repair

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var location = './mydb';
vc.startVerticalClient();
vc.level(location)
.then((res)=>{
	return vc.repair(location);
})
.then((res)=>{
	return vc.destroy(location);
})
.then((res)=>{
	vc.stopVerticalClient();
})

open & close

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var location = './mydb';
var vcdb = null;
vc.startVerticalClient();
vc.level(location)
.then((res)=>{
	vcdb = res;
	return vcdb.open();
})
.then((res)=>{
	vcdb = res;
	return vcdb.close();
});

put & get & del

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	return vcdb.put('a','aaa');
})
.then((res)=>{
	console.log(res);
	return vcdb.get('a');
})
.then((res)=>{
	console.log(res);
	return vcdb.del('a');
})
.then((res)=>{
	console.log(res);
})
.catch((err)=>{
	console.log(err);
});
### batch

```node
var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	var ops = [
	    { type: 'del', key: 'father' }
	  , { type: 'put', key: 'name', value: 'Yuri Irsenovich Kim' }
	  , { type: 'put', key: 'dob', value: '16 February 1941' }
	  , { type: 'put', key: 'spouse', value: 'Kim Young-sook' }
	  , { type: 'put', key: 'occupation', value: 'Clown' }
	]

	return vcdb.batch(ops);
})
.then((res)=>{
	return vcdb.batch()
	  .del('father')
	  .put('name', 'Yuri Irsenovich Kim')
	  .put('dob', '16 February 1941')
	  .put('spouse', 'Kim Young-sook')
	  .put('occupation', 'Clown')
	  .write();
})
.then((res)=>{
	console.log(res);
})
.catch((err)=>{
	console.log(err);
});

isOpen & isClosed

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	return vcdb.isOpen();
})
.then((res)=>{
	console.log(res);
	return vcdb.isClosed();
})
.then((res)=>{
	console.log(res);
})
.catch((err)=>{
	console.log(err);
});

createReadStream & createKeyStream & createValueStream

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	//var option = {'gt':'a'};
	vcdb.createReadStream()
	  .on('data', function (data) {
	    console.log(data.key, '=', data.value)
	  })
	  .on('error', function (err) {
	    console.log('Oh my!', err)
	  })
	  .on('close', function () {
	    console.log('Stream closed')
	  })
	  .on('end', function () {
	    console.log('Stream ended')
	  });
	 vcdb.createKeyStream()
	  .on('data', function (data) {
	    console.log('key=', data.value)
	  })
	  .on('error', function (err) {
	    console.log('Oh my!', err)
	  })
	  .on('close', function () {
	    console.log('Stream closed')
	  })
	  .on('end', function () {
	    console.log('Stream ended')
	  });
	 vcdb.createValueStream()
	  .on('data', function (data) {
	    console.log('value=', data.value)
	  })
	  .on('error', function (err) {
	    console.log('Oh my!', err)
	  })
	  .on('close', function () {
	    console.log('Stream closed')
	  })
	  .on('end', function () {
	    console.log('Stream ended')
	  });
})
.then((res)=>{
	console.log(res);
})
.catch((err)=>{
	console.log(err);
});

Additionally, you can supply an options object as the first parameter to createReadStream() with the following options:

  • 'gt' (greater than), 'gte' (greater than or equal) define the lower bound of the range to be streamed. Only records where the key is greater than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the records streamed will be the same.

  • 'lt' (less than), 'lte' (less than or equal) define the higher bound of the range to be streamed. Only key/value pairs where the key is less than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the records streamed will be the same.

  • 'start', 'end' legacy ranges - instead use 'gte', 'lte'

  • 'reverse' (boolean, default: false): a boolean, set true and the stream output will be reversed. Beware that due to the way LevelDB works, a reverse seek will be slower than a forward seek.

  • 'keys' (boolean, default: true): whether the 'data' event should contain keys. If set to true and 'values' set to false then 'data' events will simply be keys, rather than objects with a 'key' property. Used internally by the createKeyStream() method.

  • 'values' (boolean, default: true): whether the 'data' event should contain values. If set to true and 'keys' set to false then 'data' events will simply be values, rather than objects with a 'value' property. Used internally by the createValueStream() method.

  • 'limit' (number, default: -1): limit the number of results collected by this stream. This number represents a maximum number of results and may not be reached if you get to the end of the data first. A value of -1 means there is no limit. When reverse=true the highest keys will be returned instead of the lowest keys.

  • 'fillCache' (boolean, default: false): whether LevelDB's LRU-cache should be filled with data read.

  • 'keyEncoding' / 'valueEncoding' (string): the encoding applied to each read piece of data.

approximateSize

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	var start ='a';
	var end ='z';
	return vcdb.approximateSize(start,end);
})
.then((res)=>{
	console.log(res);
})
.catch((err)=>{
	console.log(err);
});

getProperty

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	return vcdb.getProperty('leveldb.num-files-at-level3');
})
.then((res)=>{
	console.log(res);
})
.catch((err)=>{
	console.log(err);
});
  • 'leveldb.num-files-at-levelN': returns the number of files at level N, where N is an integer representing a valid level (e.g. "0").

  • 'leveldb.stats': returns a multi-line string describing statistics about LevelDB's internal operation.

  • 'leveldb.sstables': returns a multi-line string describing all of the sstables that make up contents of the current database.

Event

var VerticalClient = require('vertical-client').VerticalClient;
var vc = new VerticalClient({host:'127.0.0.1',port:5234,timeout:3000,auth:"password"});
var vcdb = null;
vc.startVerticalClient();
vc.level('./mydb')
.then((res)=>{
	vcdb = res;
	return vcdb.on('put',(key,value)=>{
		console.log(key,value);
	});
})
.catch((err)=>{
	console.log(err);
});
  • db.emit('put', key, value) emitted when a new value is 'put'
  • db.emit('del', key) emitted when a value is deleted
  • db.emit('batch', ary) emitted when a batch operation has executed
  • db.emit('ready') emitted when the database has opened ('open' is synonym)
  • db.emit('closed') emitted when the database has closed
  • db.emit('opening') emitted when the database is opening
  • db.emit('closing') emitted when the database is closing