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

tcl

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcl - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

src/asynctask.cpp

12

lib/result.js

@@ -9,5 +9,5 @@

* @param {string} data - raw response data
* @param {object} interp - Tcl interpreter binding
* @param {object} binding - Tcl interpreter binding
*/
var Result = function ( data, interp ) {
var Result = function ( data, binding ) {

@@ -19,3 +19,3 @@ // update internals

this._interp = interp;
this._binding = binding;

@@ -47,3 +47,3 @@ };

// sanity checks
if (! this._interp ) {
if (! this._binding ) {
return null;

@@ -54,3 +54,3 @@ }

if ( str && str.length > 0 ) {
return this._interp.toArray( str );
return this._binding.toArray( str );
}

@@ -60,3 +60,3 @@

this._result.raw.length > 0 ) {
return this._interp.toArray( this._result.raw );
return this._binding.toArray( this._result.raw );
}

@@ -63,0 +63,0 @@

@@ -15,3 +15,3 @@

// tcl interpreter binding
this._interp = new binding.TclInterp();
this._binding = new binding.TclBinding();

@@ -24,5 +24,2 @@ // intialise internals

Tcl.prototype.load = function () { };
/**

@@ -39,7 +36,9 @@ * Execute a Tcl command using the Tcl Interpreter binding. This is an

this._interp.cmd( cmd, function ( err, data ) {
var self = this;
this._binding.cmd( cmd, function ( err, data ) {
var result = null;
if (! err ) {
result = new Result( data, this._interp );
result = new Result( data, self._binding );
}

@@ -57,2 +56,11 @@

/**
* Alias for {@link Tcl#cmd}
*
* @method
* @see Tcl#cmd
*/
Tcl.prototype.eval = Tcl.prototype.cmd;
/**
* Execute a Tcl command synchronously using the Tcl Interpreter binding.

@@ -69,3 +77,3 @@ * This will use a shared Tcl Interpreter and can share data between two

try {
return new Result( this._interp.cmdSync( cmd ), this._interp );
return new Result( this._binding.cmdSync( cmd ), this._binding );
} catch ( e ) {

@@ -79,2 +87,39 @@ return e;

/**
* Alias for {@link Tcl#cmdSync}
*
* @method
* @see Tcl#cmdSync
*/
Tcl.prototype.evalSync = Tcl.prototype.cmdSync;
/**
* Add a Tcl command to the asynchronous processing queue. Each command
* added will be executed using a single worker thread outside of the
* main event loop. Each command shares the same worker thread and the
* Tcl interpreter instance and will share states.
*
* @param {string} cmd - command to execute
* @param {Tcl~cmdCallback} callback - callback method to handle
* the response
*/
Tcl.prototype.queue = function ( cmd, callback ) {
this._binding.queue( cmd, function ( err, data ) {
var result = null;
if (! err ) {
result = new Result( data, this._binding );
}
if ( callback ) {
callback( err, result );
}
} );
};
/**
* Returns the Tcl Interpreter version

@@ -87,3 +132,3 @@ *

if (! this._version ) {
this._version = this._interp.cmdSync( 'info tclversion' );
this._version = this._binding.cmdSync( 'info tclversion' );
}

@@ -90,0 +135,0 @@

{
"name": "tcl",
"version": "1.1.1",
"version": "1.2.0",
"description": "Node.js Tcl binding",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -26,9 +26,10 @@ node-tcl

You can execute any Tcl command that is supported by the Tcl shell (```tchsh```)
and you can even load native Tcl modeles (```load module.so```), source scripts
You can execute any Tcl command supported by the Tcl shell (```tchsh```) and you
can even load native Tcl modeles (```load module.so```), source scripts
(```source filename.tcl```) and source Tcl libraries (```package require name```).
**Note :** Only 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.
**Note :** Asynchronous commands (```cmd``` and ```eval```) are executed usng a
dedicated worker thread using a new Tcl Interpreter instance and comes with the
overhead of creating and destroying a Tcl Interpreter for each call. But these
executions are parallel and useful for batched tasks.

@@ -39,5 +40,10 @@

// synchronous commands
console.log( tcl.version() );
console.log( tcl.cmdSync( 'info tclversion' ) );
console.log( tcl.evalSync( 'info tclversion' ) );
// asynchronous commands (parallelly executed in decated threads)
tcl.cmd( 'info tclversion', function ( err, result ) {

@@ -47,5 +53,13 @@ console.log( result.data() );

tcl.cmd( 'info commands', function ( err, result ) {
tcl.eval( 'info commands', function ( err, result ) {
console.log( result.toArray() );
} );
// queued asynchronous commands (executed in a shared thread)
tcl.queue( 'set x 0' );
tcl.queue( 'incr $x', function ( err, result ) {
console.log( result );
} );
```

@@ -52,0 +66,0 @@

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

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