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

prism-lang

v0.1.6

Published

Prism Programming Language Transpiler

Downloads

844

Readme

Human Written

Prism

Prism is a small, expressive language designed to transpile into TypeScript or JavaScript. It supports functions, classes, control flow, imports, typed variables, arrays, objects, and error handling.

npm downloads

Status

Prism is a work in progress. The syntax below is based on the current tokenizer and AST structure.

Features

  • Typed variables and function signatures
  • Mutable and immutable bindings
  • Functions and methods
  • Classes with public and private members
  • Conditionals
  • Pattern matching
  • while and for loops
  • Arrays and objects
  • Imports
  • new expressions
  • try / catch and throw
  • Unary, binary, compound, and nullish operators

Installation

npm install
npm run build

CLI

Prism includes a command-line tool.

To use it, first use:

npm link
prism compile file.prism
prism run file.prism
prism check file.prism

Options

--js        Emit plain JavaScript instead of typed output
--ast       Print the AST as JSON
--out <file> Write output to a file
--help      Show help

Basic Syntax

Variables

Use mut for mutable variables and final for immutable variables.

final name: string = "Prism"
mut count: int = 0

Type annotations are optional when the compiler can infer them.

mut value = 10

Functions

fn greet(name: string): string {
  return "Hello, " + name
}

Functions can also return nothing:

fn logMessage(message: string): void {
  print(message)
}

Conditionals

if count > 10 {
  print("high")
} else {
  print("low")
}

While Loops

while count < 10 {
  count += 1
}

For Loops

for item in items {
  print(item)
}

Match Statements

match status {
  "ok" => print("success")
  "error" => print("failed")
  default => print("unknown")
}

Functions and Calls

fn add(a: int, b: int): int {
  return a + b
}

print(add(2, 3))

Classes

Prism supports classes with public and private members.

class User {
  pub name: string
  priv token: string

  pub fn getName(): string {
    return this.name
  }

  priv fn setToken(token: string): void {
    this.token = token
  }
}

Creating Instances

mut user = new User("Alice")

Imports

use fs
use { readFile, writeFile } from "fs"
use path from "path"

Arrays

mut numbers = [1, 2, 3]
print(numbers[0])

Objects

mut person = {
  name: "Alice",
  age: 12
}

Operators

Prism supports:

  • Arithmetic: +, -, *, /
  • Comparison: ==, !=, >, <, >=, <=
  • Logical: !, &&, ||
  • Nullish: ??
  • Assignment: =, +=, -=, *=, /=
  • Arrow syntax: ->, =>

Literals

true
false
null
"hello"
123
12.5

Types

Prism currently recognizes these types:

  • string
  • int
  • float
  • bool
  • void
  • any

Error Handling

try {
  riskyCall()
} catch err {
  print(err)
}

Throw an error:

throw "Something went wrong"

AST Overview

The parser produces an AST with nodes such as:

  • Program
  • VariableDeclaration
  • FunctionDeclaration
  • ClassDeclaration
  • MethodDeclaration
  • CallExpression
  • MethodCall
  • NewExpression
  • IfStatement
  • MatchStatement
  • WhileStatement
  • ForStatement
  • TryCatchStatement
  • ReturnStatement
  • Assignment
  • CompoundAssignment
  • ArrayExpression
  • ObjectExpression

Example Program

use { readFile } from "fs"

final appName: string = "Prism"
mut counter: int = 0

fn increment(value: int): int {
  return value + 1
}

while counter < 3 {
  counter += 1
}

if counter == 3 {
  print(appName)
} else {
  print("not ready")
}

Project Structure

A typical Prism project may include:

src/
  lexer.ts
  parser.ts
  index.ts
  cli.ts
examples/
  example.prism

Notes

  • Prism is transpiled, not interpreted directly.
  • The exact syntax may evolve as the language grows.
  • Some built-in function names such as print may depend on your runtime or transpiler output.

License

MIT