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

javathon

v1.1.4

Published

A project to run mixed JavaScript and Python code

Downloads

139

Readme

Javathon

Javathon is a lightweight, powerful tool that enables developers to seamlessly execute Python and JavaScript code blocks together in a single file. By using a simple .jt file format, Javathon eliminates the need for switching between environments, making it perfect for projects that require the strengths of both languages.

Whether you’re building web applications, analyzing data, or exploring automation, Javathon makes it easier to combine the power of JavaScript and Python effortlessly.


Key Features

  • 🛠 Run Mixed Code: Write and execute Python and JavaScript in a single file.
  • Asynchronous Execution: Smoothly handles mixed-language execution with shared contexts.
  • 📦 Simple CLI Tool: Easy to install, configure, and use from anywhere on your system.

Installation

Prerequisites

  1. Ensure you have Node.js installed on your system.
  2. (Optional) Have Python installed and added to your system's PATH for Python support.

Install Javathon Globally

Use npm to install Javathon globally:

npm install -g javathon  

Getting Started

1. Create a .jt File

Write your code in a .jt file, separating Python and JavaScript code blocks.

example.jt

// JavaScript Section
console.log("Hello from JavaScript!");

<%
// Python Section
print("Hello from Python!")
%>

2. Run the .jt File

Execute your file using the javathon command:

javathon example.jt  

3. View the Output

The example above produces:

Hello from JavaScript!
Hello from Python!

Writing .jt Files

.jt files allow you to switch between Python and JavaScript seamlessly. Use the following syntax:

  • JavaScript Code: Write as plain JavaScript directly in the file.
  • Python Code: Wrap Python code in <% ... %> blocks.

Example:

// JavaScript Block
const name = "Javathon User";
console.log("Hi, " + name + "!");

<%
// Python Block
name = "Javathon User"
print(f"Hello from Python, {name}!")
%>

Advanced Example

Here’s a practical example with loops and variable sharing:

example.jt

// JavaScript Section: Define a shared variable
let numbers = [1, 2, 3];
console.log("Processing numbers in JavaScript:", numbers);

<%
// Python Section: Process the same numbers
print("Processing numbers in Python:")
for number in [1, 2, 3]:
    print(f"  -> {number}")
%>

// Back to JavaScript
console.log("Done processing numbers!");

Output:

Processing numbers in JavaScript: [1, 2, 3]
Processing numbers in Python:
  -> 1
  -> 2
  -> 3
Done processing numbers!

Development

Want to contribute or test Javathon locally? Follow these steps:

  1. Clone the repository:

    git clone https://github.com/Skosanalindo061/Javathon  
    cd javathon  
  2. Install dependencies:

    npm install  
  3. Run the tool locally:

    node src/index.js example.jt  

Troubleshooting

Common Issues

  1. Python Not Found:

  2. File Syntax Errors:

    • Ensure .jt files use valid syntax for both languages.
  3. Dependencies Missing:

    • Reinstall Javathon:
      npm install -g javathon  

Roadmap

Here’s what’s next for Javathon:

  • 🌐 Add support for more languages (e.g., Ruby, PHP).
  • 🛠 Improve error handling and debugging tools.
  • 🚀 Enhance .jt syntax with better context sharing between languages.

Contributing

Contributions are welcome! Submit issues or pull requests on GitHub.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Author

Created with passion by Lindokuhle Skosana.
Feel free to reach out with feedback, suggestions, or questions.


Quick Example

javathon example.jt  

Output:

Hello from JavaScript!
Hello from Python!

Javathon: Where Python meets JavaScript. Happy coding!

Creator

Javathon was created and is actively maintained by Lindokuhle Skosana.