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

escript

v0.1.5

Published

A C-like scripting language, built upon Typescript

Downloads

69

Readme

Overview

Escript is a straightforward scripting language designed to extend TypeScript with a more C-like syntax, enhancing the developer experience. It aims to simplify scripting and provide a more intuitive syntax for common programming tasks.

This CLI tool allows you to compile Escript code to TypeScript and optionally transpile it to JavaScript. You can also execute the resulting JavaScript code directly from the command line.

Example

Here's a simple Escript file, showcasing its syntax:

// app.es
interface Car {
    string make;
};

Car myCar = {
    make: "Chevrolet"
};

// output: Chevrolet
log myCar.make;

class Vehicle {
    private string make;
    private string model;

    public constructor(string make, string model) {
        this.make = make;
        this.model = model;
    }

    public string displayInfo() {
        return this.make + " " + this.model;
    }

    protected void updateModel(string newModel) {
        this.model = newModel;
    }
}

Vehicle myCar2 = new Vehicle("Ford", "Mustang");
// output: Ford Mustang
log myCar2.displayInfo();

CLI Features

  • Compile Escript to TypeScript: Converts Escript code into TypeScript.
  • Transpile TypeScript to JavaScript: Converts TypeScript code into JavaScript using the TypeScript compiler (tsc).
  • Execute JavaScript: Run the final JavaScript output directly from the command line.
  • Interactive Help: Provides help and usage instructions directly via CLI.

Installation

You can install Escript CLI globally using npm or yarn:

npm install -g escript
# or
yarn global add escript

Usage

Basic Command

To compile an Escript file, use the following command:

npx esc -i <input-path> -o <output-path>
  • -i, --input <file>: Path to the input Escript file.
  • -o, --output <file>: Path to the output JavaScript or TypeScript file.

Optional Flags

  • -t, --transpile: Transpile the resulting TypeScript code to JavaScript. If this flag is used, the output path should be for a TypeScript file (.ts), and the final output will be a JavaScript file (.js).
  • -r, --run: Run the final JavaScript file after transpilation. This option requires that the -t flag is also set.

Examples

Compile Escript to TypeScript:

npx esc -i myscript.es -o output.ts

This command converts myscript.es to TypeScript and saves it as output.ts.

Compile and Transpile to JavaScript:

npx esc -i myscript.es -o output.ts -t

This command converts myscript.es to TypeScript and then transpiles output.ts to JavaScript, saving it as output.js.

Compile, Transpile, and Run:

npx esc -i myscript.es -o output.ts -t -r

This command performs the full workflow: compiles myscript.es to TypeScript, transpiles it to JavaScript, and then runs output.js.

Commands

start

Get started using the Escript CLI tool with the following command:

npx esc start

This command displays a welcome message and basic usage instructions.

Configuration

TypeScript Compilation

The CLI uses the TypeScript compiler (tsc) to transpile TypeScript code to JavaScript. Ensure that tsc is installed and accessible from your environment. You can install it globally via npm:

npm install -g typescript