npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tcl

v3.1.0

Published

Node.js Tcl binding

Downloads

71

Readme

node-tcl

npm version build codecov

Provides Node.js bindings to execute Tcl commands using a native Tcl Interpreter. Also includes the ability to define new commands in the Tcl intepretor that will invoke a specified JavaScript function.

Dependencies

  • Tcl development files (e.g. sudo apt-get install tcl-dev or sudo yum install tcl-devel)

The build process will look for tclConfig.sh to identify Tcl include directory and linker flags. If you are using a Tcl version older than 8.5 or want to link to a specific Tcl installation use the TCLCONFIG environment variable to override the default behaviour (e.g. export TCLCONFIG=/path/to/tclConfig.sh).

This version has been updated to use node-addon-api and so should be compatible with future versions of node.js. Unfortunately, it may not build properly on very old node.js versions.

Optional Dependencies

  • Tcl thread support (To enable async commands outside the main event loop)
  • C++ compiler with support for c++11 features (To enable async command queues outside the main event loop)

Installation

$ npm install --save tcl

Usage

var tcl = require( 'tcl' );
var Tcl = require( 'tcl' ).Tcl;
var tcl = new Tcl();

$( cmd ), cmdSync( cmd ), evalSync( cmd )

Execute a Tcl command synchronously and returns a Result.

Parameters

| Name | Type | Description | |------|--------|--------------------| | cmd | String | Command to execute |

Example

tcl.$( 'info version' );

$.(tcl-command)( ... )

Execute a Tcl command using injected helper methods and returns a Result.

Example

tcl.$.info( 'tclversion' );
tcl.$.set( 'x', 10 );
tcl.$.expr( 22, '/', '7.0' );

load( module )

Load a Tcl module and refresh injected helper methods.

Example

tcl.load( 'libfoo.so' );
tcl.$.foo();

source( file )

Source a Tcl script file and refresh injected helper methods.

Example

tcl.source( '/path/to/multiply.tcl' );
tcl.$.multiply( 2, 3 );

cmd( cmd, callback ), eval( cmd, callback )

Execute a Tcl command asynchronously using a new worker thread (A new Tcl interpreter instance will be created for each call).

Parameters

| Name | Type | Description | |----------|--------|--------------------| | cmd | String | Command to execute | | callback | Callback | Callback method to handle the response |

Example

tcl.cmd( 'info tclversion', function ( err, result ) {
	if ( err ) {
		return console.log( err );
	}

	console.log( result.data() );
} );

tcl.eval( 'info commands', function ( err, result ) {
	if ( err ) {
		return console.log( err );
	}

	console.log( result.toArray() );
} );

queue( cmd, callback )

Execute a Tcl command asynchronously using a shared worker thread. A new Tcl interpreter instance will be created for the worker thread but will be shared between calls.

Parameters

| Name | Type | Description | |----------|--------|--------------------| | cmd | String | Command to execute | | callback | Callback | Callback method to handle the response |

Example

tcl.queue( 'set x 1' );
tcl.queue( 'incr x', function ( err, result ) {
	if ( err ) {
		return console.log( err );
	}

	console.log( result.data() ); // 2
} );

proc( cmd, callback )

Instructs the Tcl interpreter to create a new command: cmd. When this new command is encountered at any time during the life of the interpreter, the specified callback will be invoked with whatever parameters were supplied to cmd. There is currently not a command for deleting commands from the interpreter.

Parameters

| Name | Type | Description | |----------|--------|---------------------------| | cmd | String | New Tcl command to create | | callback | Callback | Callback method to handle the command |

Example

tcl.proc( 'newTclCmd', function ( arg1, arg2 ) {
	console.log( 'Got', arg1, arg2 ); // Got some arguments
} );

tcl.cmdSync( 'newTclCmd some arguments' );

API Documentation

JSDoc generated API documentation can be found at http://nukedzn.github.io/node-tcl/docs/.

Contributing

Contributions are welcome through GitHub pull requests (using fork & pull model).