New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts2py

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts2py

A library to create interfaces from TypeScript to Python3

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
176
Maintainers
0
Weekly downloads
 
Created
Source

ts2py

A library to create interfaces from TypeScript to Python3

Installation

npm i ts2py

Usage

// Import factory function
import { makePythonInterface } from "ts2py";

// Create the interface
const {call, cleanup} = makePythonInterface({
    // Supply an array of custom function definitions, note the argument (*)
    processFunctions: [
        `process_func = lambda line: 'Hello at ' + line`
    ]
});

// Use the interface
async function main() {
    for(let i = 0; i < 100; ++i) {
        // Call your function from the interface: 
        // - process_func is the name of the function inside Python3 script
        // - new Date().toISOString() will be passd as `line` to the Python function
        // - as for now, arguments must be JSON.stringify()'able!
        const result = await call('process_func', new Date().toISOString());

        // Use the results
        console.log(i, result);
    }
}

// Do not forget to cleanup to not leave your node process stuck at exit
main().then(cleanup);

Keywords

FAQs

Package last updated on 29 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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