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

async-box

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-box - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

dist/async-box.bare.min.js

26

build.js
var webpack = require("webpack");
var Promise = require("bluebird");
webpack({
var configs = [{
entry: './lib/main.js',

@@ -20,8 +21,19 @@ output: {

]
}, function(err, stats) {
if (!err) {
console.log(stats.toString());
} else {
console.log(err);
}
}];
Promise.map(configs, function(config) {
return new Promise(function(resolve, reject) {
webpack(config, function(err, stats) {
if (!err) {
resolve(stats);
} else {
reject(err);
}
});
});
}).all().then(function(results) {
results.forEach(function(result) {
console.log(results.toString());
});
});

@@ -1,97 +0,105 @@

module.exports = (function() {
var Promise = require('bluebird');
var EventEmitter = require('wolfy87-eventemitter');
(function() {
var root = this;
var publish = function(Promise, EventEmitter) {
var AsyncBox = function() {
var asyncHandlers = new Map();
var syncHandlers = new Map();
var AsyncBox = function() {
var asyncHandlers = new Map();
var syncHandlers = new Map();
var checkHandlerIsNew = function(type) {
var handlerInstalled = asyncHandlers.has(type) || syncHandlers.has(type);
if (handlerInstalled) {
throw new Error('Handler for ' + type + ' request is already set');
}
};
var checkHandlerIsNew = function(type) {
var handlerInstalled = asyncHandlers.has(type) || syncHandlers.has(type);
if (handlerInstalled) {
throw new Error('Handler for ' + type + ' request is already set');
}
};
var getRequestHandler = function(type, map) {
var handler = map.get(type);
if (handler) {
return handler;
}
throw new Error('No handler found for ' + type + ' request');
};
var getRequestHandler = function(type, map) {
var handler = map.get(type);
if (handler) {
return handler;
}
throw new Error('No handler found for ' + type + ' request');
};
var respondAsync = function(type, handler) {
asyncHandlers.set(type, handler);
};
var respondAsync = function(type, handler) {
asyncHandlers.set(type, handler);
};
var respondSync = function(type, handler) {
syncHandlers.set(type, handler);
};
var respondSync = function(type, handler) {
syncHandlers.set(type, handler);
};
var requestAsync = function(type, handler, args) {
return new Promise(function(resolve) {
resolve(handler.apply(null, args.slice(1)));
});
};
var requestAsync = function(type, handler, args) {
return new Promise(function(resolve) {
resolve(handler.apply(null, args.slice(1)));
});
};
var requestSync = function(type, handler, args) {
return handler.apply(null, args.slice(1));
};
var requestSync = function(type, handler, args) {
return handler.apply(null, args.slice(1));
};
EventEmitter(this);
EventEmitter(this);
this.respondAsync = function(type, handler) {
checkHandlerIsNew(type);
respondAsync(type, handler);
};
this.respondAsync = function(type, handler) {
checkHandlerIsNew(type);
respondAsync(type, handler);
};
this.respondSync = function(type, handler) {
checkHandlerIsNew(type);
respondSync(type, handler);
};
this.respondSync = function(type, handler) {
checkHandlerIsNew(type);
respondSync(type, handler);
};
this.requestAsync = function(type) {
var handler = getRequestHandler(type, asyncHandlers);
var args = new Array(arguments.length);
for (var i = 0; i < arguments.length; ++i) {
args[i] = arguments[i];
}
return requestAsync(type, handler, args);
};
this.requestAsync = function(type) {
var handler = getRequestHandler(type, asyncHandlers);
var args = new Array(arguments.length);
for (var i = 0; i < arguments.length; ++i) {
args[i] = arguments[i];
}
return requestAsync(type, handler, args);
};
this.requestSync = function(type) {
var handler = getRequestHandler(type, syncHandlers);
var args = new Array(arguments.length);
for (var i = 0; i < arguments.length; ++i) {
args[i] = arguments[i];
}
return requestSync(type, handler, args);
};
this.requestSync = function(type) {
var handler = getRequestHandler(type, syncHandlers);
var args = new Array(arguments.length);
for (var i = 0; i < arguments.length; ++i) {
args[i] = arguments[i];
}
return requestSync(type, handler, args);
};
this.requestAllAsync = function(array) {
return Promise.map(array, function(requestArgs) {
var type = requestArgs[0];
var handler = getRequestHandler(type, asyncHandlers);
return requestAsync(type, handler, requestArgs);
}).all();
};
this.requestAllAsync = function(array) {
return Promise.map(array, function(requestArgs) {
var type = requestArgs[0];
var handler = getRequestHandler(type, asyncHandlers);
return requestAsync(type, handler, requestArgs);
}).all();
this.requestAllSync = function(array) {
return array.map(function(requestArgs) {
var type = requestArgs[0];
var handler = getRequestHandler(type, syncHandlers);
return requestSync(type, handler, requestArgs);
});
};
};
this.requestAllSync = function(array) {
return array.map(function(requestArgs) {
var type = requestArgs[0];
var handler = getRequestHandler(type, syncHandlers);
return requestSync(type, handler, requestArgs);
});
};
AsyncBox.prototype = Object.create(EventEmitter.prototype);
return AsyncBox;
};
AsyncBox.prototype = Object.create(EventEmitter.prototype);
if (typeof root.define === 'function' && root.define.amd) {
root.define('async-box', [
'bluebird',
'wolfy87-eventemitter'
], function(Promise, EventEmitter) {
return publish(Promise, EventEmitter);
});
if (typeof window !== 'undefined') {
window.AsyncBox = AsyncBox;
window.Promise = Promise;
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = publish(require('bluebird'), require('wolfy87-eventemitter'));
}
return AsyncBox;
})();
{
"name": "async-box",
"version": "0.3.0",
"version": "0.4.0",
"description": "Your main application object with promise async api API",

@@ -15,3 +15,3 @@ "author": {

"test": "node spec/node-runner",
"browser-build": "node build.js"
"build": "node build.js"
},

@@ -18,0 +18,0 @@ "keywords": [

@@ -1,2 +0,2 @@

# AsyncBox
# AsyncBox [![npm version](https://badge.fury.io/js/async-box.svg)](https://badge.fury.io/js/async-box)

@@ -3,0 +3,0 @@ AsyncBox is a library for your main `application` object, it supports Sync and Async APIs

@@ -110,3 +110,4 @@ /**

htmlReporter.initialize();
env.execute();
// do not exec specs right ahead
// env.execute();
};

@@ -113,0 +114,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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