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

l5

v1.5.0

Published

low level lisp like language (L5)

Readme

l5

low level lisp like language (L5)

subset of web assembly s-expression text format, goal: be self-hosting.

what does this do?

currently can parse it's own source code and build a ast in memory, without relying on javascript for parsing!

> node codec.js ./l5.wat
(module (global $free (mut i32) (i32.const 16)) (global $root (mut i32) (i32.const 0)) (memory $memory 10) (func $claim (param $length i32) (result i32) (local $_free i32) (set_local $_free (get_global $free)) (set_global $free (i32.add (get_global $free) (get_local $length))) (get_local $_free)) (func $cons (export "cons") (param $head i32) (param $tail i32) (result i32) (i32.store (get_global $free) (i32.const 3)) (i32.store (i32.add (get_global $free) (i32.const 4)) (get_local $head)) (i32.store (i32.add (get_global $free) (i32.const 8)) (get_local $tail)) (call $claim (i32.const 12))) (func $is_string (export "is_string") (param $str i32) (result i32) (i32.eq (i32.and (i32.load (get_local $str)) (i32.const 7)) (i32.const 4))) (func $is_cons (export "is_cons") (param $cons i32) (result i32) (i32.lt_u (i32.and (i32.load (get_local $cons)) (i32.const 7)) (i32.const 4))) (func $head (export "head") (param $list i32) (result i32) (i32.load (i32.add (get_local $list) (i32.const 4)))) (func $tail (export "tail") (param $list i32) (result i32) (i32.load (i32.add (get_local $list) (i32.const 8)))) (func $set_head (export "set_head") (param $list i32) (param $value i32) (result i32) (i32.store (i32.add (get_local $list) (i32.const 4)) (get_local $value)) (get_local $list)) (func $set_tail (export "set_tail") (param $list i32) (param $value i32) (result i32) (i32.store (i32.add (get_local $list) (i32.const 8)) (get_local $value)) (get_local $value)) (func $string (export "string") (param $length i32) (result i32) (i32.store (get_global $free) (i32.or (i32.const 4) (i32.shl (get_local $length) (i32.const 8)))) (call $claim (i32.add (get_local $length) (i32.const 4)))) (func $string_length (export "string_length") (param $str i32) (result i32) (i32.shr_u (i32.load (get_local $str)) (i32.const 8))) (func $last (export "last") (param $list i32) (result i32) (if (call $tail (get_local $list)) (return (call $last (call $tail (get_local $list))))) (return (get_local $list))) (func $append (export "append") (param $list i32) (param $value i32) (result i32) (call $set_tail (call $last (get_local $list)) (call $cons (get_local $value) (i32.const 0)))) (export "memory" (memory $memory)))

I am learning a lot about using pointers. If it was a javascript implementation, I'd just use [] and [].push() to create the data structure, but we have to do everything via pointers and lists (that's why it's called LisP!)

so, the trick was building the nested structure in reverse. the last item you parsed points back to the previous.

(a b c) becomes c->b->a->0 and when you hit the ) you reverse the list. but it's more interesting when you consider nested lists (a b c (d e)) becomes (e->d->(c->b->a->0)) remember that lisp cells have to pointers. to make a straight list, the head points to a value, and the tail points to the rest of the list. when head points to a list, that is a nested list.

The so d points to a cell that has the first level list (in reverse) as it's head. when we hit the first ) (at the second level) we reverse the 2nd level list, and are left holding the first cell, which points to the first level list (the rest of the tree). this section is now fully parsed, so we attach a cell that points to the tail of the reversed 2nd level list, then we hit the end of that, we reverse the first list and now we have the ast.

The neat thing about this is it's fully functional and super terse too! I just spent way more characters describing it in engilsh that it took to implemented even considering wat's verboseness (buried deep in the parsing code)

Pretty sure this is how god parses lisp.

data structures

lisp is lists. a list is conses, or strings. a cons is 3 i32 words (12 bytes) the first word is a tag. if the lowest nyble (4 bits) in the tag is <= 3 it's a cons. 3 means the cons is two pointers (to other values)

(not implemented yet: 0 means a pair of i32 values instead of pointers 1 means a i32 value and then a pointer 2 means a pointer then a i32 value. )

a pointer can point at a cons or a string. a string has a tag like a pointer, but the lowest byte is 4.

in strings, the top 3 bytes in the tag is the length of the string. the body of the string follows, length bytes long, starting 4 bytes after the pointer.

(the higher bits in the nibble are not yet used, but they will probably be used for garbage collection)

api

cons (a, b) => pointer

create a cons with a and b as cells. (both are i32 pointers)

is_cons (c) => 0 || 1

returns 1 if c is a cons

is_string (s) => 0 || 1

return 1 if s is a string

string_length (s) => number (javascript)

returns the length of the string.

head (c) => pointer

return the value at the head of the cons c.

tail (c) => value

return the value at the tail of the cons c

set_head (c, v) => c

sets the value at the head of the cons c to v, c is returned.

set_tail (c, v) => v

sets the value at the tail of the cons c to v v is returned.

write (string) => string (pointer)

pass a string from javascript land into wasm land. returns pointer to s

read (s) => string (javascript string)

extracts a string from wasm land to javascript land, takes a pointer returned by write (or extracted from a cons) throws if s is not a string.

parse (s) => l

parse a string into an ast

License

MIT