Comparing version 1.0.1 to 1.0.2
@@ -35,4 +35,6 @@ // Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var Pengine, request, s, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
var Pengine, events, request, s, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -43,3 +45,7 @@ request = require('request'); | ||
Pengine = (function() { | ||
events = require('events'); | ||
Pengine = (function(superClass) { | ||
extend(Pengine, superClass); | ||
Pengine.ids = []; | ||
@@ -78,5 +84,5 @@ | ||
if (error) { | ||
return typeof _this.onError === "function" ? _this.onError({ | ||
return _this.emit('error', { | ||
data: "Failed to connect to " + _this.server + ": " + error | ||
}) : void 0; | ||
}); | ||
} | ||
@@ -88,11 +94,2 @@ return _this._processResponse(response); | ||
Pengine.prototype.on = function(event, f) { | ||
event = s(event).capitalize().s; | ||
if (event !== "Error" && event !== "Success" && event !== "Prompt" && event !== "Failure" && event !== "Stop" && event !== "Output" && event !== "Debug" && event !== "Abort" && event !== "Destroy" && event !== "Create") { | ||
console.log("Warning: event \"" + event + "\" has no suppported functionality"); | ||
} | ||
this["on" + event] = f; | ||
return this; | ||
}; | ||
Pengine.optionsToList = function(options) { | ||
@@ -112,3 +109,2 @@ var key, value; | ||
Pengine.prototype._processResponse = function(obj) { | ||
var ref; | ||
switch (obj.event) { | ||
@@ -122,10 +118,6 @@ case 'create': | ||
obj.code = "too_many_pengines"; | ||
if (typeof this.onError === "function") { | ||
this.onError(obj); | ||
} | ||
this.emit('error', obj); | ||
return console.error(obj.data); | ||
} else { | ||
if (typeof this.onCreate === "function") { | ||
this.onCreate(obj); | ||
} | ||
this.emit('create', obj); | ||
if (obj.answer != null) { | ||
@@ -137,7 +129,7 @@ return this._processResponse(obj.answer); | ||
case 'stop': | ||
return typeof this.onStop === "function" ? this.onStop(obj) : void 0; | ||
return this.emit('stop', obj); | ||
case 'success': | ||
return typeof this.onSuccess === "function" ? this.onSuccess(obj) : void 0; | ||
return this.emit('success', obj); | ||
case 'failure': | ||
return typeof this.onFailure === "function" ? this.onFailure(obj) : void 0; | ||
return this.emit('failure', obj); | ||
case 'error': | ||
@@ -147,22 +139,16 @@ if (obj.code === "existence_error" && obj.arg1 === "pengine" && obj.arg2 === this.id) { | ||
} | ||
if (typeof this.onError === "function") { | ||
this.onError(obj); | ||
} | ||
return (ref = this.onError) != null ? ref : console.error(obj.data); | ||
this.emit('error', obj); | ||
return console.error(obj.data); | ||
case 'output': | ||
if (typeof this.onOutput === "function") { | ||
this.onOutput(obj); | ||
} | ||
this.emit('output', obj); | ||
return this._pullResponse(obj.id); | ||
case 'debug': | ||
if (typeof this.onDebug === "function") { | ||
this.onDebug(obj); | ||
} | ||
this.emit('debug', obj); | ||
console.log("[debug]: " + obj.data); | ||
return this._pullResponse(obj.id); | ||
case 'prompt': | ||
return typeof this.onPrompt === "function" ? this.onPrompt(obj) : void 0; | ||
return this.emit('prompt', obj); | ||
case 'abort': | ||
this.aborted = true; | ||
return typeof this.onAbort === "function" ? this.onAbort(obj) : void 0; | ||
return this.emit('abort', obj); | ||
case 'destroy': | ||
@@ -173,3 +159,3 @@ this._unregister(); | ||
} | ||
return typeof this.onDestroy === "function" ? this.onDestroy(obj) : void 0; | ||
return this.emit('destroy', obj); | ||
case 'died': | ||
@@ -180,5 +166,3 @@ this._unregister; | ||
obj.code = "died"; | ||
if (typeof this.onError === "function") { | ||
this.onError(obj); | ||
} | ||
this.emit('error', obj); | ||
return console.error(obj.data); | ||
@@ -196,3 +180,2 @@ } | ||
Pengine.prototype._processPullResponse = function(obj) { | ||
console.log(obj); | ||
if (obj.event !== 'died') { | ||
@@ -401,3 +384,3 @@ return this._processResponse(obj); | ||
})(); | ||
})(events.EventEmitter); | ||
@@ -404,0 +387,0 @@ module.exports = (function(options) { |
{ | ||
"name": "pengines", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "The Node version of pengines.js - communicating with prolog engines", | ||
@@ -5,0 +5,0 @@ "main": "lib/pengines", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31078
349