New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kad-memstore-thomas

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kad-memstore-thomas - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

32

index.js

@@ -8,2 +8,4 @@ /**

var ReadableStream = require('readable-stream');
var assert = require('assert');
var _ = require('lodash');

@@ -29,6 +31,11 @@ /**

KadMemStore.prototype.get = function(key, callback) {
assert(_.isString(key), 'key is not a valid string')
assert(_.isFunction(callback), 'callback is not a valid function')
var self = this;
setImmediate(function getItem() {
callback(null, self._store[key] || null);
setImmediate(function() {
if(self._store[key]) {
callback(null, self._store[key])
} else {
callback(new Error('Key not found'))
}
});

@@ -45,2 +52,5 @@ };

KadMemStore.prototype.put = function(key, value, callback) {
assert(_.isString(key), 'key is not a valid string')
assert(!callback || _.isFunction(callback), 'callback is not a valid function')
assert(_.isString(value), 'value is not a valid string')
this._store[key] = value;

@@ -59,7 +69,15 @@ if(callback) {

KadMemStore.prototype.del = function(key, callback) {
delete this._store[key];
if(callback) {
setImmediate(callback);
assert(_.isString(key), 'key is not a valid string')
assert(!callback || _.isFunction(callback), 'callback is not a valid function')
if(!callback) {
callback = function() {}
}
setImmediate(function() {
if(this._store[key]) {
delete this._store[key]
callback()
} else {
callback(new Error('Key not found'))
}
})
};

@@ -66,0 +84,0 @@

{
"name": "kad-memstore-thomas",
"version": "0.1.0",
"version": "0.2.0",
"description": "in-memory kad storage adapter for testing and simulation",

@@ -30,4 +30,5 @@ "main": "index.js",

"dependencies": {
"lodash": "^4.15.0",
"readable-stream": "^2.0.5"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc