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

sharedb

Package Overview
Dependencies
Maintainers
5
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sharedb - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

12

lib/backend.js

@@ -207,7 +207,13 @@ var async = require('async');

// it doesn't, it defaults to the current version).
Backend.prototype.submit = function(agent, index, id, op, options, callback) {
Backend.prototype.submit = function(agent, index, id, op, options, originalCallback) {
var backend = this;
var request = new SubmitRequest(this, agent, index, id, op, options);
var callback = function(error, ops) {
backend.emit('submitRequestEnd', error, request);
originalCallback(error, ops);
};
var err = ot.checkOp(op);
if (err) return callback(err);
var request = new SubmitRequest(this, agent, index, id, op, options);
var backend = this;
backend.trigger(backend.MIDDLEWARE_ACTIONS.submit, agent, request, function(err) {

@@ -214,0 +220,0 @@ if (err) return callback(err);

{
"name": "sharedb",
"version": "1.6.0",
"version": "1.7.0",
"description": "JSON OT database backend",

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

@@ -631,2 +631,12 @@ _This README is for `sharedb@1.x`. For `sharedb@1.x-beta`, see [the 1.x-beta branch](https://github.com/share/sharedb/tree/1.x-beta). To upgrade, see [the upgrade guide](https://github.com/share/sharedb/wiki/Upgrading-to-sharedb@1.0.0-from-1.0.0-beta)._

#### `on`
```javascript
backend.on('submitRequestEnd', callback): void;
```
A submit request is about to return to the client. This is called whether the request was a success or a failure.
* `callback` _Function_: callback for handling the event: `function (error, request): void;`
### Class: `ShareDB.Agent`

@@ -633,0 +643,0 @@

@@ -103,3 +103,43 @@ var Backend = require('../lib/backend');

});
describe('submitRequestEnd', function() {
it('emits after write', function(done) {
var afterWriteCalled = false;
backend.use(backend.MIDDLEWARE_ACTIONS.afterWrite, function(request, next) {
afterWriteCalled = true;
next();
});
backend.on('submitRequestEnd', function(error, request) {
expect(error).not.to.be.ok;
expect(request).to.be.ok;
expect(afterWriteCalled).to.be.true;
done();
});
var op = {op: {p: ['publicationYear'], oi: 1949}};
backend.submit(null, 'books', '1984', op, null, function(error) {
if (error) done(error);
});
});
it('emits after an error is raised in the middleware', function(done) {
backend.use(backend.MIDDLEWARE_ACTIONS.submit, function(request, next) {
next(new Error());
});
backend.on('submitRequestEnd', function(error, request) {
expect(error).to.be.ok;
expect(request).to.be.ok;
done();
});
var op = {op: {p: ['publicationYear'], oi: 1949}};
backend.submit(null, 'books', '1984', op, null, function() {
// Swallow the error
});
});
});
});
});
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