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

dazzl

v0.3.0

Published

The Dazzl compiler - compiles .daz files to JavaScript

Readme

Dazzl

A programming language that compiles to JavaScript. Dazzl takes inspiration from Elixir, Haskell, and Ruby to offer a concise, expressive syntax while targeting the JavaScript runtime.

Quick Start

npm install -g dazzl
dazzl myfile.daz
node myfile.js

Development

git clone https://github.com/yourusername/dazzl.git
cd dazzl
npm install
npm test        # compile examples/test.daz and run it

Language Features

Variables

Bare assignment compiles to const by default:

name = "Dazzl"
x = 42

Use let for mutable bindings:

let counter = 0

Basic Types

# Strings
greeting = "Hello"
name = 'World'

# Numbers
count = 42
pi = 3.14

# Booleans
active = true
disabled = false

# Nil (alias for null)
empty = nil
also_null = null
not_defined = undefined

# Symbols (like Ruby/Elixir atoms)
status = :active
state = :pending

Strings and Interpolation

Double-quoted strings support interpolation with #{}:

name = "World"
"Hello #{name}!"              # "Hello World!"
"2 + 2 = #{2 + 2}"            # "2 + 2 = 4"
"Caps: #{String.upcase(name)}" # "Caps: WORLD"

Multiline strings are supported:

message = "Line 1
Line 2
Line 3"

Single-quoted strings are literal (no interpolation):

'Hello #{name}'  # "Hello #{name}" (literal)

Escape sequences: \\, \", \n, \t, \#

Arrays

empty = []
numbers = [1, 2, 3, 4, 5]
mixed = ["hello", 42, true, nil]

Objects

Three styles that can be mixed:

# Colon style (JS-like)
{ name: "Alice", age: 30 }

# Hash rocket style (Ruby/Elixir-like)
{ name => "Alice", age => 30 }

# Shorthand style (ES6-like)
name = "Alice"
age = 30
{ name, age }  # { name: "Alice", age: 30 }

# Mixed
{ name, city: "NYC", active => true }

Operators

# Arithmetic
x + y        # addition
x - y        # subtraction
x * y        # multiplication
x / y        # division
x // y       # integer division (Math.floor)
x % y        # modulo
x ** y       # exponentiation (right-associative)

# Unary
-x           # negation
+x           # unary plus

# Comparison (== and != compile to === and !==)
x == y
x != y
x < y
x <= y
x > y
x >= y

Nil Checking

Comparisons with nil/null/undefined use loose equality to catch both null and undefined:

x == nil     # true if x is null OR undefined
x != nil     # true if x is neither

Functions

Four equivalent styles:

# Haskell-style
add x, y = x + y

# Math-style
add(x, y) = x + y

# Arrow-style
add: x, y -> x + y

# Arrow-style with parens
add: (x, y) -> x + y

Block bodies with implicit returns:

clamp: (val, min, max) -> {
  if val < min { return min }
  if val > max { return max }
  val   # implicit return
}

Control Flow

# If/else (parentheses optional)
if x > 0 {
  console.log("positive")
} else {
  console.log("non-positive")
}

# Unless (negated if)
unless x == 0 {
  console.log("not zero")
}

# Postfix conditionals
console.log("yes") if ready
console.log("no") unless valid

# Conditional expressions (like ternary)
sign = if x > 0 then "positive" else "negative"
grade = if score > 90 "A" else if score > 80 "B" else "C"

Pipe Operator

Passes the left side as the first argument:

# These are equivalent:
console.log(add(result, 5))
result |> add(5) |> console.log

# Great with String module
"  HELLO  " |> String.trim |> String.downcase |> String.capitalize

Ranges

r = [1..10]
Range.to_list(r)      # [1, 2, 3, ..., 10]
Range.size(r)         # 10
Range.member(r, 5)    # true

Comments

// JS-style comment
# Ruby-style comment
x = 42  // inline comment

Standard Library

Modules are auto-imported when used.

Kernel Functions

Called directly (no module prefix):

# Math
abs(-5)           # 5
div(10, 3)        # 3
rem(10, 3)        # 1
max(1, 2, 3)      # 3
min(1, 2, 3)      # 1

# Type checking
is_integer(42)    # true
is_float(3.14)    # true
is_binary("hi")   # true (strings)
is_boolean(true)  # true
is_sym(:ok)       # true
is_list([1, 2])   # true
is_range([1..5])  # true

# Utilities
length("hello")   # 5
to_string(42)     # "42"
inspect(:ok)      # ":ok"

String Module

String.first("hello")           # "h"
String.last("hello")            # "o"
String.at("hello", -1)          # "o"
String.capitalize("hELLO")      # "Hello"
String.upcase("hello")          # "HELLO"
String.downcase("HELLO")        # "hello"
String.reverse("hello")         # "olleh"
String.trim("  hi  ")           # "hi"
String.contains("hello", "ell") # true
String.starts_with("hello", "he") # true
String.ends_with("hello", "lo")   # true
String.pad_leading("42", 5, "0")  # "00042"
String.duplicate("na", 4)         # "nananana"
String.split("a,b,c", ",")        # ["a", "b", "c"]
String.replace("hello", "l", "L") # "heLlo"

Integer Module

Integer.is_even(42)          # true
Integer.is_odd(7)            # true
Integer.digits(1234)         # [1, 2, 3, 4]
Integer.digits(255, 16)      # [15, 15]
Integer.undigits([1, 2, 3])  # 123
Integer.gcd(12, 8)           # 4
Integer.floor_div(10, 3)     # 3
Integer.mod(-5, 3)           # 1 (Euclidean)
Integer.pow(2, 10)           # 1024
Integer.to_string(255, 16)   # "ff"

How It Works

Dazzl compiles .daz files to .js files. Runtime modules are automatically:

  1. Detected by analyzing your code
  2. Imported at the top of the output
  3. Copied to .dazzl_modules/ next to your output file

Project Structure

src/
  cli.js              # CLI entry point
  compiler.js         # Orchestrates parsing and codegen
  dazscript.pegjs     # PEG grammar (Peggy)
  codegen.js          # AST to JavaScript generator
  modules/
    kernel.js         # Kernel functions
    range.js          # Range module
    integer.js        # Integer module
    str.js            # String module
examples/
  test.daz            # Feature showcase

License

ISC