8000 GitHub - jardimdanificado/potpiper: promise based interoperability for nodejs, works with anything that supports stdin and stdout.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jardimdanificado/potpiper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

You MUST print anything in the end of the called command, else it will freeze the process. The session automatically queues commands if it is busy when receiving it.

Importing the Library

import { PipeSession } from 'potpiper';

Initializing a Session

To start a session, you can create an instance of PipeSession:

const session = new PipeSession(execPath, args);
  • execPath: The path to the executable.
  • args : Arguments.

Sending Commands

You can send commands to the process and receive the results using the send method:

const result = await session.send("your message here");

You can also use the pass method, it ignores all prints, it only returns the last one:

//only the result of "line three" will be returned
const result = await session.pass("line one\n line two\n line three");

Closing the Session

Don't forget to close the session when you're done:

session.close();

Example

Here's a simple example of how to use potpiper with lua:

import { PipeSession } from 'potpiper';

const lua = new PipeSession('luajit');

(async () => {
  const result = await lua.send('your message here');
  console.log(result);
  lua.close();
})();

Also check examples/

TODO

  • documentation.
  • more examples.
  • better code commenting.

License

This project is licensed under the GNU General Public License version 3 (GPL-3.0).

  • You are free to use, modify, and distribute this software.
  • Any derivative work based on this software must also be released under the GPLv3.
  • This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  • You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

By using this software, you agree to comply with the terms of the GNU General Public License version 3.

About

promise based interoperability for nodejs, works with anything that supports stdin and stdout.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0