Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dyno

Package Overview
Dependencies
Maintainers
3
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dyno - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

index.js

@@ -7,3 +7,3 @@ var _ = require('underscore');

_(dyno).extend(dyno.config.dynamo);
_(dyno).extend(require('./lib/item'));
_(dyno).extend(_(require('./lib/item')).omit('_response'));
_(dyno).extend(require('./lib/query'));

@@ -10,0 +10,0 @@ _(dyno).extend(require('./lib/scan'));

@@ -31,3 +31,3 @@ var util = require('util');

};
config.dynamo.putItem(params, cb);
config.dynamo.putItem(params, items._response(config.dynamo.putItem, params, opts, cb));
};

@@ -49,1 +49,25 @@

};
items._response = function(func, params, opts, cb) {
var attempts = 0;
var retry = function() {
func.bind(config.dynamo)(params, handleResp);
};
var handleResp = function(err, resp) {
if(!opts.errors || !err) {
return cb(err, resp);
}
if (err.code = "ProvisionedThroughputExceededException") {
if(_.isNumber(opts.errors.throughput) && attempts <= opts.errors.throughput){
attempts++;
setTimeout(retry, 100 * attempts * attempts);
} else {
cb(err, resp);
}
}
}
return handleResp;
};
{
"name": "dyno",
"version": "0.3.0",
"version": "0.3.1",
"description": "Simple DynamoDB client",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -247,1 +247,35 @@ var test = require('tap').test;

test('teardown', s.teardown);
test('setup', s.setup());
test('setup table', s.setupTable);
test('put error, throughput', function(t) {
var items = require('../lib/item');
var types = require('../lib/types');
var config = require('../lib/config')();
var item = types.toDynamoTypes({id: 'yo', range: 5});
var params = {
TableName: config.table,
Item: item
};
var handleResp = items._response(
config.dynamo.putItem,
params,
{errors:{throughput:10}},
itemResp
);
// Send it a fake bad response.
handleResp({code:'ProvisionedThroughputExceededException'}, {})
function itemResp(err, resp) {
t.equal(err, null);
t.deepEqual(resp, {});
dyno.getItem(item, getItem);
}
function getItem(err, resp) {
t.equal(err, null);
t.deepEqual(resp, {Item:{id: 'yo', range: 5}});
t.end();
}
});
test('teardown', s.teardown);
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