ts-simple-interpreter
v1.0.3
Published
A simple TypeScript interpreter. It can execute TS code text as input and return a console result of the code.
Downloads
6
Maintainers
Readme
🚀 Quick start
- Install the package to your project
npm install ts-simple-interpreter
- Import the
executeTS
method to js/ts component
The return value will be the output of the executed result, similar to the output you would see in the console:import { executeTS } from 'ts-simple-interpreter'
const result = executeTS('your TypeScript code here'); console.log(result); // This will log the output of the executed code
Example Usage
Here’s a simple example demonstrating how to use the executeTS
method:
import { executeTS } from 'ts-simple-interpreter';
const tsCode = `
const add = (a: number, b: number): number => {
return a + b;
};
add(2, 3);
`;
const result = executeTS(tsCode);
console.log(result); // Expected output: 5