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 🙏

© 2025 – Pkg Stats / Ryan Hefner

scryer

v0.7.0

Published

Scryer Prolog, a modern Prolog implementation written mostly in Rust.

Readme

scryer

This is a Typescript package that embeds Scryer Prolog.

Experimental, API will change. Currently it's (roughly) based on trealla-js's API.

npm install scryer
import { init, Prolog } from "scryer";

await init();

const kb1 = `
:- use_module(library(format)).
:- use_module(library(clpz)).
:- use_module(library(lists)).

sudoku(Rows) :-
length(Rows, 9), maplist(same_length(Rows), Rows),
append(Rows, Vs), Vs ins 1..9,
maplist(all_distinct, Rows),
transpose(Rows, Columns),
maplist(all_distinct, Columns),
Rows = [As,Bs,Cs,Ds,Es,Fs,Gs,Hs,Is],
blocks(As, Bs, Cs),
blocks(Ds, Es, Fs),
blocks(Gs, Hs, Is).

blocks([], [], []).
blocks([N1,N2,N3|Ns1], [N4,N5,N6|Ns2], [N7,N8,N9|Ns3]) :-
all_distinct([N1,N2,N3,N4,N5,N6,N7,N8,N9]),
blocks(Ns1, Ns2, Ns3).
`;

const kb2 = `
problem(1, [[_,_,_,_,_,_,_,_,_],
			[_,_,_,_,_,3,_,8,5],
			[_,_,1,_,2,_,_,_,_],
			[_,_,_,5,_,7,_,_,_],
			[_,_,4,_,_,_,1,_,_],
			[_,9,_,_,_,_,_,_,_],
			[5,_,_,_,_,_,_,7,3],
			[_,_,2,_,1,_,_,_,_],
			[_,_,_,_,4,_,_,_,9]]).
`;

const pl = new Prolog();
pl.consultText(kb1);
pl.consultText(kb2);

const query = pl.query(
	"problem(1, Rows), sudoku(Rows), maplist(portray_clause, Rows).",
);
for (const answer of query) {
	console.log(answer.bindings);
}

For browsers, you can use esm.sh or other CDNs to import it directly:

<script type="module">
	import { init, Prolog } from "https://esm.sh/scryer"; // ideally add version info to the URL, e.g. [email protected]
	await init();
	// query stuff
</script>

Usage

Binding variables

const answer = pl.queryOnce("X is Y * 2.", { bind: { Y: 21 } });
console.log(answer.bindings); // { X: 42, Y: 21 }

Template strings

The prolog string template literal is an easy way to escape terms. Each ${value} will be interpreted as a Prolog term.

import { prolog, Variable } from "scryer";
const answer = pl.queryOnce(
	prolog`atom_chars(${new Variable("X")}, ${"Hello!"}).`,
);
console.log(answer.bindings); // { X: Atom('Hello!') }

Events

Prolog instances are subclasses of EventTarget and emit the following events:

  • "ready" -- fired when a query finishes and the interpreter is ready to execute a new query

Development

After cloning the repository, make sure to initialize the submodules:

git submodule update --init --recursive

Alternatively, you can do this directly during the clone:

git clone --recurse-submodules -j8 <repository-url>

make sure to have wasm-pack installed.

Once the submodules are in place and wasm-pack is installed, run the following commands:

npm install
npm run compile    # Installs the WASM package of Scryer Prolog and other dependencies
npm run build      # Transpiles TypeScript code