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

censeo

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

censeo - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

69

lib/server.js
(function() {
var Promise = require("bluebird");
var self = this;
var serverRequire;
var serverRequire, pogoWrappers;
serverRequire = function(path) {

@@ -11,2 +11,5 @@ if (path[0] === ".") {

};
pogoWrappers = function() {
return "\n //TODO it would be nice if we could just get these from pogo\n var gen1_promisify = function(fn) {\n return new Promise(function(onFulfilled, onRejected) {\n fn(function(error, result) {\n if (error) {\n onRejected(error);\n } else {\n onFulfilled(result);\n }\n });\n });\n };\n\n var gen2_asyncFor = function(test, incr, loop) {\n return new Promise(function(success, failure) {\n function testAndLoop(loopResult) {\n Promise.resolve(test()).then(function(testResult) {\n if (testResult) {\n Promise.resolve(loop()).then(incrTestAndLoop, failure);\n } else {\n success(loopResult);\n }\n }, failure);\n }\n function incrTestAndLoop(loopResult) {\n Promise.resolve(incr()).then(function() {\n testAndLoop(loopResult);\n }, failure);\n }\n testAndLoop();\n });\n };";
};
module.exports = function(port) {

@@ -33,11 +36,17 @@ var self = this;

runWithPromise = function(options) {
options.context.Promise = require("bluebird");
options.context.gen1_promisify = function(callback) {
var self = this;
return callback(function(error, result) {
return emitResult(options, result);
return convertErrorToEmit(options, function() {
var func, context, runFunc, gen3_asyncResult, result;
return new Promise(function(gen2_onFulfilled) {
func = options.func;
context = options.context;
context.Promise = require("bluebird");
context.process = process;
context.require = require;
context.serverRequire = serverRequire;
runFunc = Function("context", "callback", "\n for (var property in context) {\n eval ('var '+property+'= context.'+property);\n }\n\n " + pogoWrappers() + "\n\n return (" + func + ")();\n ");
gen2_onFulfilled(Promise.resolve(runFunc(context)).then(function(gen3_asyncResult) {
result = gen3_asyncResult;
return emitResult(options, result);
}));
});
};
return convertErrorToEmit(options, function() {
return exec(options.context, options.func);
});

@@ -70,15 +79,19 @@ };

socket.on("runTask", function(options) {
var context, runFunc, result;
context = options.context;
context.Promise = require("bluebird");
context.process = process;
context.require = require;
context.serverRequire = serverRequire;
runFunc = Function("context", "\n for (var property in context) {\n eval ('var '+property+'= context.'+property);\n }\n\n // in a task we just need to swallow root level promises that complete\n var gen1_promisify = function(fn) {\n return new Promise(function(onFulfilled, onRejected) {\n fn(function(error, result) {\n if (error) {\n onRejected(error);\n } else {\n onFulfilled(result);\n }\n });\n });\n };\n\n return (" + options.func + ")();\n ");
result = runFunc(context);
tasks.push({
id: options.id,
stop: result.stop
var context, runFunc, gen4_asyncResult, result;
return new Promise(function(gen2_onFulfilled) {
context = options.context;
context.Promise = require("bluebird");
context.process = process;
context.require = require;
context.serverRequire = serverRequire;
runFunc = Function("context", "\n for (var property in context) {\n eval ('var '+property+'= context.'+property);\n }\n\n " + pogoWrappers() + "\n\n return (" + options.func + ")();\n ");
gen2_onFulfilled(Promise.resolve(runFunc(context)).then(function(gen4_asyncResult) {
result = gen4_asyncResult;
tasks.push({
id: options.id,
stop: result.stop
});
return socket.emit("running:" + options.id, result);
}));
});
return socket.emit("running:" + options.id, result);
});

@@ -99,14 +112,14 @@ socket.on("run", function(options) {

runningTask = function() {
var gen3_results, gen4_items, gen5_i, task;
gen3_results = [];
gen4_items = tasks;
for (gen5_i = 0; gen5_i < gen4_items.length; ++gen5_i) {
task = gen4_items[gen5_i];
var gen5_results, gen6_items, gen7_i, task;
gen5_results = [];
gen6_items = tasks;
for (gen7_i = 0; gen7_i < gen6_items.length; ++gen7_i) {
task = gen6_items[gen7_i];
(function(task) {
if (task.id === options.id) {
return gen3_results.push(task);
return gen5_results.push(task);
}
})(task);
}
return gen3_results;
return gen5_results;
}()[0];

@@ -113,0 +126,0 @@ if (runningTask) {

{
"name": "censeo",
"version": "0.4.1",
"version": "0.4.2",
"description": "Run arbitrary JavaScript or PogoScript on a server",

@@ -5,0 +5,0 @@ "author": "Derek Ekins <derek@spathi.com>",

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