A primitive json-file-based key-value storage
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Brave Orange


Brave Orange is a very primitive, compact, and simple interface for storing json-data permanently on the harddrive. Data is stored as a JSON-string in a .json-file. On instantiation the data is loaded into memory and parsed to a JSON object, which can be accessed through the interface descriped below. On manipulation through the interface, the object is stringified and written to the harddrive. Simple as pie.

Brave Orange are only intended to be used for small experimental projects where one needs a simple - although persistant - key-value storage db, but where utilizing a real key-value storage db like MongoDB, Redis e.g. are overkill and unnecessary.


  • Bad I/O performance
  • Useless examples
  • No testsuite
  • ... but simplicity!


Instantiation and configuration (Brave Orange is a singleton)

var BraveOrange = require('brave-orange/index'),
    bo = new BraveOrange({
        path: './put-my-data-here'


bo.set('myvalue', 42);

bo.set('myobject', {
    magic_number: 42

bo.set('valuewithcallback', { with: 'callback' }, function() {
    // Brave Orange is now done updating the .json-file on the harddrive


bo.get('myvalue', function(value) {
    console.log(value); // e.g. 42

bo.get('myobject', function(value) {
    console.log(value); // e.g. { magic_number: 42 }
}, this); // with context!


The methods in the interface is callback-based. Whenever a method takes context as the last argument, the given callback will be called from the given context.

The constructor takes a json-object with configuration data. Currently you only have the option of telling Brave Orange where to put the persistant data on the harddrive. If the path is not given './data' is default destination.


The set methods takes two required and one optional arguments. The key, the value, and a callback to be executed when the persistant file has been updated (note that you can access the data using the get method, before the data has been written to the harddrive).

set(key, value, [callback], [context])

The get method fetches the value corresponding to the key and executes the callback with the value as the first argument.

get(key, callback, [context])

The flush method is provided in the interface as well, but currently you should not have any need of using this. Calling the flush method will make the brave orange instance write the current object stored in memory to the persistant file. The flush method is called by the set method when setting a value.

flush([callback], [context])


Brave Orange is currently not available as an npm-mobule. But it will be soon.

Brave Orange, WTF?

1: A project for fun. 2: Name from Online Generator