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

psl.js

v1.0.3

Published

Simple implementation of the Predictive Sequence Learning (PSL) algorithm, used for machine learning and enactive computing. This implementation is primarily intended for educational purposes, not large scale ML tasks.

Downloads

21

Readme

psl.js

JavaScript implementation of Predictive Sequence Learning.

Examples

A simple Hello world instanciation of psl.js is available here.

You may also check out the more elaborated example where psl.js is used to predict your actions in a little maze game.

Usage

psl.js can be used in the browser or standalone, using node.js.

Browser uage

Download psl.js from GitHub or linke directly to the CDN:

<script src="https://cdn.rawgit.com/billingo/psl.js/b7b7ab72/psl.js"></script>

Now, Psl can be instanciated, trained, and executed like this:

$(function() {
	var psl = new Psl(); // Instantiate the Psl library
	var s = 'PSL Hello World Hello World';
	psl.train({s:s});
	
	function run() {
		$('H1').append(psl.predict($('H1').text()));
		setTimeout(run,200);
	};

	setTimeout(run,200);
});

Please note that this example depends on jQuery. psl.js itself is however independent of external libraries. Like psl.js, jQuery can be linked directly from the CDN.

Standalone usage

First, make sure you have node.js installed. psl.js is available in the Node Package Manager (npm). Assuming that you have npm installed, simply do:

npm install psl.js

Alternatively, you may also download psl.js from GitHub and link manually.

Now, you make create a simple little Hello World like this:

var Psl = require('psl.js').Psl; // Require the Psl class from psl.js
var psl = new Psl();             // Instantiate Psl

var s = 'PSL Hello World Hello World'; // Define a source string
var h = 'P';                     // Initiate the history

process.stdout.write(h);         // Write history to console

psl.train(s);                    // Run training

function run() {
	var c = psl.predict(h);  // Predict the next character in the sequence
	process.stdout.write(c); // Print predicted character to console
	h += c;                  // Append history
	setTimeout(run,200);     // Callback
};

setTimeout(run,200);         // Initiate callback

Have fun! @billingo