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

amalgamatic

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amalgamatic - npm Package Compare versions

Comparing version 6.0.3 to 6.0.4

4

CHANGELOG.md
## [**6.0.4**](https://github.com/ucsf-ckm/amalgamatic/issues?milestone=12&state=closed)
- [**#64**](https://github.com/ucsf-ckm/amalgamatic/issues/64) Call main callback with data and error, not one or the other
- [**#63**](https://github.com/ucsf-ckm/amalgamatic/issues/63) plugin callbacks may be executed after main callback if one plugin callback returns an error
## [**6.0.3**](https://github.com/ucsf-ckm/amalgamatic/issues?milestone=11&state=closed)

@@ -3,0 +7,0 @@ - [**#59**](https://github.com/ucsf-ckm/amalgamatic/issues/59) Add io.js to Travis

19

index.js

@@ -8,2 +8,4 @@ var async = require('async');

var lastError;
var requestedCollections;

@@ -27,3 +29,4 @@ if (! query.collections || ! query.collections instanceof Array) {

return process.nextTick(function () {
done(new Error('Collection "' + collection + '" does not exist'));
lastError = new Error('Collection "' + collection + '" does not exist');
done();
});

@@ -42,2 +45,6 @@ }

if (err) {
lastError = err;
}
if (pluginCallback) {

@@ -51,3 +58,3 @@ if (err) {

done(err);
done();
});

@@ -60,8 +67,4 @@ };

var wrappedCallback = function (err) {
if (err) {
callback(err);
} else {
callback(null, results);
}
var wrappedCallback = function () {
callback(lastError, results);
};

@@ -68,0 +71,0 @@

@@ -8,3 +8,3 @@ {

},
"version": "6.0.3",
"version": "6.0.4",
"dependencies": {

@@ -11,0 +11,0 @@ "async": "^0.9.0",

/*jshint expr: true*/
var amalgamatic = require('../index.js');
var pluginTestDouble = {
search: function (query, callback) {
if (query.searchTerm === 'error') {
callback(new Error('There was an error! Oh noes!'));
} else if (query.searchTerm === 'options') {
callback(null, query);
} else {
callback(null, {data: [
{name: 'Result 1', url: 'http://example.com/1'},
{name: 'Result 2', url: 'http://example.com/2'}
]});
}
}
};
amalgamatic.add('plugin', pluginTestDouble);
var Code = require('code');

@@ -30,4 +11,29 @@

var it = lab.test;
var beforeEach = lab.beforeEach;
describe('exports', function () {
var amalgamatic;
beforeEach(function (done) {
amalgamatic = require('../index.js');
var pluginTestDouble = {
search: function (query, callback) {
if (query.searchTerm === 'error') {
callback(new Error('There was an error! Oh noes!'));
} else if (query.searchTerm === 'options') {
callback(null, query);
} else {
callback(null, {data: [
{name: 'Result 1', url: 'http://example.com/1'},
{name: 'Result 2', url: 'http://example.com/2'}
]});
}
}
};
amalgamatic.add('plugin', pluginTestDouble);
done();
});
it('should have a search property', function (done) {

@@ -65,10 +71,2 @@ expect(typeof amalgamatic.search).to.equal('function');

it('returns multiple collections if specified', function (done) {
amalgamatic.search({searchTerm: 'medicine', collections: ['plugin', 'fhqwhgads']}, function (err, results) {
expect(results).to.be.not.ok;
expect(err).to.be.ok;
done();
});
});
it('returns all collections if no collection specified', function (done) {

@@ -166,3 +164,40 @@ amalgamatic.search({searchTerm: 'medicine'}, function (err, results) {

});
it('should execute callbacks for all plugins even if one had an error', function (done) {
var runCount = 0;
var pluginCallback = function () {
runCount = runCount + 1;
};
var anotherPlugin = {
search: function (query, callback) {
setTimeout(callback, 100);
}
};
amalgamatic.add('anotherPlugin', anotherPlugin);
amalgamatic.search({searchTerm: 'error', pluginCallback: pluginCallback}, function () {
expect(runCount).to.equal(2);
done();
});
});
it('should execute main callback with error and data', function (done) {
var anotherPlugin = {
search: function (query, callback) {
callback(null, {data: [{name: 'fhqwhgads', url: 'http://example.com/1'}]});
}
};
amalgamatic.add('anotherPlugin', anotherPlugin);
amalgamatic.search({searchTerm: 'error'}, function (err, result) {
expect(err).to.deep.equal(new Error('There was an error! Oh noes!'));
expect(result).to.deep.equal([{data: [{name: 'fhqwhgads', url: 'http://example.com/1'}], name: 'anotherPlugin'}]);
done();
});
});
});
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