Comparing version 1.0.2 to 1.1.0
'use strict'; | ||
/** | ||
* Tcl module with native Tcl Interpreter binding | ||
* @module tcl | ||
*/ | ||
module.exports = require( './lib/tcl' ); | ||
@@ -9,2 +9,3 @@ | ||
* Tcl Interpreter bridge | ||
* | ||
* @constructor | ||
@@ -27,4 +28,6 @@ */ | ||
/** | ||
* Execute a Tcl command using the Tcl Interpreter | ||
* binding | ||
* Execute a Tcl command using the Tcl Interpreter binding. This is an | ||
* asynchronous call and a new Tcl Interpreter instance is used for | ||
* each execution. | ||
* | ||
* @param {string} cmd - command to execute | ||
@@ -36,15 +39,35 @@ * @param {Tcl~cmdCallback} callback - callback method to handle | ||
var err = null; | ||
var result = null; | ||
this._interp.cmd( cmd, function ( err, data ) { | ||
var result = null; | ||
if (! err ) { | ||
result = new Result( data, this._interp ); | ||
} | ||
if ( callback ) { | ||
callback( err, result ); | ||
} | ||
} ); | ||
}; | ||
/** | ||
* Execute a Tcl command synchronously using the Tcl Interpreter binding. | ||
* This will use a shared Tcl Interpreter and can share data between two | ||
* executions (e.g. global variable, loaded libraries etc.) | ||
* | ||
* @param {string} cmd - Command to execute | ||
* @return {(Result|Error)} Result object containing response data | ||
* or Error object containing error data | ||
*/ | ||
Tcl.prototype.cmdSync = function ( cmd ) { | ||
try { | ||
result = new Result( this._interp.cmd( cmd ), this._interp ); | ||
return new Result( this._interp.cmdSync( cmd ), this._interp ); | ||
} catch ( e ) { | ||
err = e; | ||
return e; | ||
} | ||
if ( callback ) { | ||
callback( err, result ); | ||
} | ||
}; | ||
@@ -55,2 +78,3 @@ | ||
* Returns the Tcl Interpreter version | ||
* | ||
* @return {string} Tcl version | ||
@@ -61,3 +85,3 @@ */ | ||
if (! this._version ) { | ||
this._version = this._interp.cmd( 'info tclversion' ); | ||
this._version = this._interp.cmdSync( 'info tclversion' ); | ||
} | ||
@@ -70,6 +94,8 @@ | ||
// jsdoc definitions | ||
/** | ||
* Error first callback method to return error and response data after executing | ||
* a Tcl command | ||
* a Tcl command asynchronously | ||
* | ||
* @callback Tcl~cmdCallback | ||
@@ -81,3 +107,2 @@ * @param {(Error|null)} err - JavaScript Error object with error details upon error or null | ||
var tcl = new Tcl(); | ||
@@ -87,6 +112,7 @@ | ||
/** | ||
* Tcl module representing a @type {Tcl} instance | ||
* @module tcl | ||
* Exports tcl module | ||
* | ||
* @type {Tcl} | ||
*/ | ||
module.exports = tcl; | ||
{ | ||
"name": "tcl", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Node.js Tcl binding", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,3 +15,3 @@ node-tcl | ||
**Prerequisites : ** You will need to have ```tcl-dev``` packages installed on | ||
**Prerequisites :** You will need to have ```tcl-dev``` packages installed on | ||
your system (e.g. ```sudo apt-get install tcl-dev```) for the Node.js native addon | ||
@@ -31,3 +31,7 @@ to link to. | ||
**Note :** Only the synchronous commands preserve states from one call to another. | ||
Asynchronous commands are executed in a separate thread using a new Tcl Interpreter | ||
instance for each call. | ||
``` js | ||
@@ -37,2 +41,3 @@ var tcl = require( 'tcl' ); | ||
console.log( tcl.version() ); | ||
console.log( tcl.cmdSync( 'info tclversion' ) ); | ||
@@ -39,0 +44,0 @@ tcl.cmd( 'info tclversion', function ( err, result ) { |
Sorry, the diff of this file is not supported yet
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
279724
14
133
60