-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from linkedconnections/development
Version 0.5.0
- Loading branch information
Showing
9 changed files
with
95 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var level = require('level'); | ||
|
||
var LevelStore = function (name) { | ||
this.name = name; | ||
this._store = level(name); | ||
}; | ||
|
||
LevelStore.prototype.get = function (key, cb) { | ||
this._store.get(key, function (error, object) { | ||
if (!error) { | ||
cb(null, JSON.parse(object)); | ||
} else { | ||
cb(error); | ||
} | ||
}); | ||
}; | ||
|
||
LevelStore.prototype.put = function (key, value, cb) { | ||
this._store.put(key, value, {valueEncoding: 'json'}, cb); | ||
}; | ||
|
||
module.exports = LevelStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var MemStore = function (name) { | ||
this.name = name; | ||
this._store = {}; | ||
}; | ||
|
||
MemStore.prototype.get = function (key, cb) { | ||
if (this._store[key]) { | ||
cb(null, this._store[key]); | ||
} else { | ||
cb(key + ' not found in store'); | ||
} | ||
}; | ||
|
||
MemStore.prototype.put = function (key, value, cb) { | ||
if (this._store[key]) { | ||
cb(key + ' already exists'); | ||
} else { | ||
this._store[key] = value; | ||
cb(); | ||
} | ||
}; | ||
|
||
module.exports = MemStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var MemStore = require('./MemStore'), | ||
LevelStore = require('./LevelStore'); | ||
|
||
module.exports = function (config, type) { | ||
if (type === 'MemStore') { | ||
return new MemStore(config); | ||
} else if (type === 'LevelStore') { | ||
return new LevelStore(config); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters