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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ayscript

v1.1.0

Published

A compiler, for my AY language, built with Typescript and Nodejs

Readme

AY Language Compiler

Introduction

AY is a simple, custom programming language designed for experimentation and learning. This compiler translates AY programs into JavaScript, allowing you to run your AY code in any JavaScript environment.

Installation

Option 1: Install from npm (Recommended)

Install the AY compiler globally using npm:

npm install -g ayscript

Option 2: Install from source

Clone the repository:

git clone https://github.com/MikeyA-yo/ay-ts.git

Navigate to the project directory:

cd ay-ts

Install dependencies:

npm install

Build the project:

npx tsc

Usage

To compile and run an AY program:

Using the global installation

  1. Write your AY code in a file with the .ay extension (e.g., myprogram.ay).

  2. Compile the program:

    ayc myprogram.ay
  3. The compiler will generate a JavaScript file (e.g., myprogram.js).

  4. Run the generated JavaScript file using Node.js:

    node myprogram.js

Using the source installation

  1. Write your AY code in a file with the .ay extension (e.g., myprogram.ay).

  2. Compile the program:

    node dist/index.js myprogram.ay
  3. The compiler will generate a JavaScript file (e.g., myprogram.js).

  4. Run the generated JavaScript file using Node.js:

    node myprogram.js

Language Features

Variable Declaration

Variables are declared using the l keyword and are block-scoped:

l a = "hello";
l b = 42;

Functions

Functions are declared using the f keyword:

f add(a, b) {
    l c = a + b;
    return c;
}

Aliases with def Keyword

The def keyword allows you to create aliases for language constructs, making your code more readable:

// Create aliases for common keywords
def var -> l
def fn -> f
def brk -> break
def cnt -> continue

// Now use your custom aliases
var userName = "Alice"
fn greet(name) {
    return "Hello, " + name + "!"
}

var message = greet(userName)
print(message)

// Use in control flow
var counter = 0
while (counter < 10) {
    if (counter == 5) {
        brk  // Using the alias for break
    }
    counter++
}

Control Flow

If-Else

if (a == b) {
    return true;
} else if (c == b) {
    return "true";
} else {
    return false;
}

Loops

While Loop:

l i = 0;
while (i < 5) {
    print(i);
    i++;
}

For Loop:

for (l i = 0; i < 8; i++) {
    print(i);
}

Comments

Single-line comments:

// This is a single-line comment

Multi-line comments:

/*
This is a multi-line comment.
*/

Standard Library

The AY language includes a comprehensive standard library with the following functions:

Core Functions

  • print(...values) - Prints values to the console
  • input(prompt?) - Gets user input from terminal (synchronous, blocks execution)
  • coolPrint(msg) - Prints message with "[COOL PRINT]" prefix
  • fancyLog(msg) - Prints message with "✨ FANCY LOG:" prefix
  • stylishWarn(msg) - Prints warning with "⚠️ STYLISH WARNING:" prefix
  • errorPop(msg) - Prints error with "❌ ERROR POP:" prefix
  • errorlog(...msg) - Prints error messages to console
  • rand(min?, max?) - Returns random number (0-1 if no params, or between min-max)
  • randInt(min?, max?) - Returns random integer between min and max
  • round(num, precision?) - Rounds number to specified decimal places (default 0)

Math Functions

abs(x), floor(x), ceil(x), round(x), max(a, b), min(a, b)
sqrt(x), pow(x, y), log(x), exp(x)
sin(x), cos(x), tan(x), asin(x), acos(x), atan(x)
toRadians(x), toDegrees(x)

String Functions

len(s), upper(s), lower(s), trim(s)
split(s, delimiter), join(arr, delimiter)
reverse(s), replace(s, old, new), includes(s, substr)

Array Functions

push(arr, ...values), pop(arr), shift(arr), unshift(arr, ...values)
sort(arr), reverse(arr), slice(arr, start, end)
includes(arr, value), indexOf(arr, value)

File System Functions

readFile(path), writeFile(path, content), appendFile(path, content)

HTTP Functions

httpGet(url), httpPost(url, data)
awaitPromise(promise, onSuccess, onError)

Date/Time Functions

now(), sleep(ms)

Example Using Built-in Functions

// Math operations
l numbers = [5, 2, 8, 1, 9]
l maxNum = max(5, 10)  // 10
l rounded = round(3.7, 1) // 3.7 (rounded to 1 decimal place)

// String operations
l text = "Hello World"
l upperText = upper(text)        // "HELLO WORLD"
l textLength = len(text)         // 11
l words = split(text, " ")       // ["Hello", "World"]
l reversedText = reverse(text)   // "dlroW olleH"

// User input (synchronous)
l userName = input("Enter your name: ")
print("Hello, " + userName + "!")

l age = input("Enter your age: ")
l ageNum = parseInt(age)
if (ageNum >= 18) {
    print("You are an adult!")
} else {
    print("You are a minor!")
}

// Array operations
l fruits = ["apple", "banana"]
l moreFruits = push(fruits, "orange", "grape")  // ["apple", "banana", "orange", "grape"]
l sortedFruits = sort(moreFruits)               // ["apple", "banana", "grape", "orange"]
l firstTwo = slice(sortedFruits, 0, 2)          // ["apple", "banana"]
l hasApple = includes(sortedFruits, "apple")    // true

// Using def with built-ins
def log -> print
def length -> len
def ask -> input

log("Array length: " + length(sortedFruits))
l hobby = ask("What's your hobby? ")
log("Cool! You enjoy " + hobby)

// Math with new functions
l angle = 45
l radians = toRadians(angle)
l sineValue = sin(radians)
l randomBetween = randInt(1, 100)  // Random integer between 1-100
log("sin(45°) = " + sineValue)
log("Random number: " + randomBetween)

Example Program

// Define custom aliases for better readability
def var -> l
def fn -> f

// Variables and basic operations
var message = "Welcome to AY Language!"
var numbers = [3, 1, 4, 1, 5, 9]

// String operations
var upperMessage = upper(message)
print(upperMessage)

// Array operations
var sortedNumbers = sort(numbers)
var arrayLength = len(sortedNumbers)
print("Sorted array: " + sortedNumbers)
print("Length: " + arrayLength)

// Math operations
var randomValue = round(rand() * 100)
var maxValue = max(randomValue, 50)
print("Random value: " + randomValue)
print("Max of random and 50: " + maxValue)

// Functions with multiple parameters
fn calculate(a, b, c, d) {
    var sum = a + b + c + d
    var average = sum / 4
    return average
}

var result = calculate(10, 20, 30, 40)  // 25
print("Average: " + result)

// Control flow
var counter = 0
while (counter < 5) {
    if (counter == 3) {
        print("Halfway there!")
    }
    print("Counter: " + counter)
    counter++
}

// HTTP operations (async)
var promise = httpGet("https://api.github.com/users/octocat")
awaitPromise(promise, fn(data) {
    print("GitHub user data received!")
}, fn(error) {
    print("Error: " + error)
})

Extending the Language

To add new features to the AY language:

  1. Modify the parser in parser/ to recognize new syntax.
  2. Update the AST compiler in parser/astcompiler.ts to handle new AST nodes.
  3. (Optional) Add new functions to the standard library in functions/.

License

This project is licensed under the MIT License.