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

percy

Package Overview
Dependencies
Maintainers
2
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

percy - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

test/index.js

4

package.json
{
"name": "percy",
"version": "1.0.1",
"version": "2.0.0",
"description": "a persistence layer",

@@ -12,3 +12,3 @@ "main": "percy.js",

"dependencies": {
"kgo": "^0.1.1"
"kgo": "^1.0.0"
},

@@ -15,0 +15,0 @@ "devDependencies": {

var kgo = require('kgo'),
arrayProto = [];
function get(key, callback) {
var entityKey = this.createKey(key);
function get(id, callback) {
var percy = this;
this.connector(function(error, bucket){
if(error){
return callback(error);
}
kgo
('bucket', this.connector)
('entityKey', this.createKey.bind(this, id, null))
(['entityKey', 'bucket'], function(entityKey, bucket){
bucket.get(entityKey, function(error, result){

@@ -19,3 +19,4 @@ // Error code 13 is No such keys

});
});
})
.on('error', callback);
}

@@ -49,5 +50,4 @@

function set(key, data, callback) {
var percy = this,
entityKey = this.createKey(key);
function set(id, data, callback) {
var percy = this;

@@ -59,3 +59,4 @@ kgo

})
(['bucket', 'model'], function(bucket, model){
('entityKey', ['model'], this.createKey.bind(this, id))
(['entityKey', 'bucket', 'model'], function(entityKey, bucket, model){
bucket.set(entityKey, model, function(error, result){

@@ -67,11 +68,8 @@ if(error){

});
}).errors({
bucket: callback,
model: callback
});
})
.on('error', callback);
}
function add(key, data, callback){
var percy = this,
entityKey = this.createKey(key);
function add(data, callback){
var percy = this;

@@ -83,18 +81,13 @@ kgo

})
(['bucket', 'model'], function(bucket, model){
('entityKey', ['model'], this.createKey.bind(this, null))
(['entityKey', 'bucket', 'model'], function(entityKey, bucket, model){
bucket.add(entityKey, model, function(error, result){
if(error){
return callback(error);
}
callback(null, model);
callback(error, error ? null : model);
});
}).errors({
bucket: callback,
model: callback
});
})
.on('error', callback);
}
function replace(key, data, callback){
var percy = this,
entityKey = this.createKey(key);
function replace(id, data, callback){
var percy = this;

@@ -106,19 +99,15 @@ kgo

})
(['bucket', 'model'], function(bucket, model){
('entityKey', ['model'], this.createKey.bind(this, id))
(['entityKey', 'bucket', 'model'], function(entityKey, bucket, model){
bucket.replace(entityKey, model, function(error, result){
if(error){
return callback(error);
}
callback(null, model);
callback(error, error ? null : model);
});
}).errors({
bucket: callback,
model: callback
});
})
.on('error', callback);
}
function update(key, data, callback){
function update(id, data, callback){
var percy = this;
this.get(key, function(error, model){
this.get(id, function(error, model){
if(error){

@@ -134,26 +123,23 @@ return callback(error);

}
percy.replace(key, model, callback);
percy.replace(id, model, callback);
});
}
function remove(key, callback){
var entityKey = this.createKey(key);
this.connector(function(error, bucket){
if(error){
return callback(error);
}
function remove(id, callback){
kgo
('bucket', this.connector)
('entityKey', this.createKey.bind(this, id, null))
(['entityKey', 'bucket'], function(entityKey, bucket){
bucket.remove(entityKey, function(error, result){
if(error){
return callback(error);
}
callback(null);
callback(error);
});
});
})
.on('error', callback);
}
function touch(key, options, callback){
var entityKey = this.createKey(key);
this.connector(function(error, bucket){
function touch(id, options, callback){
kgo
('bucket', this.connector)
('entityKey', this.createKey.bind(this, id, null))
(['entityKey', 'bucket'], function(entityKey, bucket){
if(error){

@@ -163,7 +149,8 @@ return callback(error);

bucket.touch(entityKey, options, callback);
});
})
.on('error', callback);
}
function exists(key, callback){
this.touch(key, null, function(error){
function exists(id, callback){
this.touch(id, null, function(error){
var exists = true;

@@ -181,10 +168,22 @@ if(error){

function createKey(key){
if(!Array.isArray(key)){
key = [key];
function createKey(id, data, callback){
var percy = this;
if(id == null){
if(data && 'id' in data){
return callback("object already has an ID");
}
percy.createId(function(error, id){
data.id = id;
callback(null, percy.entityType + ':' + id);
});
}
key.unshift(this.entityType);
return key.join(':');
callback(null, percy.entityType + ':' + id);
}
function createId(callback){
throw new Error("Not Implemented");
}
function getView(viewName, callback){

@@ -197,3 +196,3 @@ var percy = this;

}
callback(null, bucket.view(percy.designName, viewName));
callback(null, bucket.view(percy.entityType, viewName));
});

@@ -219,3 +218,2 @@ }

this.entityType = entityType;
this.designName = entityType;
this.connector = connector;

@@ -234,2 +232,3 @@ this.validator = validator;

Percy.prototype.createKey = createKey;
Percy.prototype.createId = createId;
Percy.prototype.getView = getView;

@@ -236,0 +235,0 @@ Percy.prototype.getMulti = getMulti;

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