Giter Club home page Giter Club logo

level-namespace's Introduction

#DEPRECATED

Yo! level-sublevel is much more capable than this, so use that instead!

level-namespacebuild status

namespaces for levelup

Usage/demo

var namespace = require('level-namespace');
namespace(db);

var namespace = db.namespace('example');

// most of the levelup-methods are supported
namespace.put('foo', 'bar', function(err) {
    if (err) throw err;

    namespace.get('foo', function(err, value) {
        assert.equal(value, 'bar');
    });

    db.get('example:foo', function(err, value) {
        assert.equal(value, 'bar');
    });
});

db.batch([
        { type: 'put', key: 'foo', value: 'baz' },
        { type: 'put', key: 'example:foo', value: 'bar' },
        { type: 'put', key: 'example:hello', value: 'world' },
        { type: 'put', key: 'example;hello', value: 'worldz' }
    ], function() {
        // will print
        // 'bar' and then 'world' to process.stdout
        namespace.valueStream().pipe(process.stdout)
        // namespace also support valueStream, readStream & writeStream also
    }
)

Licence

MIT

level-namespace's People

Contributors

kesla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

level-namespace's Issues

":" is not an ideal namespace seperator

: is readable, but the problem is that it sorts in the middle of the ascii chars.

'~!@#$%^&*(){`1234567890[]\',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz"<>PYFGCRL+|AOEUIDHTNS_:QJKXBMWVZ"\t\n '
.split('').sort().join('')

gives:

'\t\n !""#$%&\'()*+,-./0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|~'

so, if say, you have a namespace 'foo', but you insert keys 'foo1' and 'fooey' and then did
readStream({start: 'foo', end: 'foo~'})

You would get foo1, the entire foo: namespace, fooey etc.

I havn't 100% figured this stuff out, but if you separate namespaces with an early character '\x00' is the earliest possibe, '!' is the first printable char, \t earliest non printable,

then you'll get namespaces sorting correctly.

foo!bar
foo1
fooey

etc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.