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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@glubs9/jamb

v1.1.6

Published

A command line javascript preprocessor for an amb-like function in javascript

Downloads

7

Readme

Jamb

A command line javascript preprocessor for an amb-like function in javascript

Installation

(you need to have node and npm to be installed)
npm install -g "@glubs9/jamb" (sudo needed on linux)

Usage

to use the functions described later on you need to import them using the function,                 
const {[function names separated by commas]} = require("@glubs9/jamb");             

and then to allow for it to work properly, you need to compile your file with the jamb command line tool
with this command "jamb [file_Name] [out_file_name]" and then you can run out_file with node like normal.

basic explanation

This package attempts to describe a function (and some utility helper functions) akin to the classic amb function in scheme.
I would recommend an understanding of logic programming and amb before using this library but don't let me stop you!.
The way I have defined amb is that it takes two arguments, the first being the name of the variable and the second being an iterable.
The variable is then set to the first item in the iterator. The file then continue from there but if it fails (using the function fail()) the interpreter will restart from amb with the variable being set to the next item in the iterator. it then continues again in much the same fashion as before.
if the iterator runs out of items it then fails itself!
I would recommend looking at test.js to see how this is used as a text explanation won't get you all the way there (note: test.js require("index.js") which is the amb function library local file, using jamb in your own code please require("@glubs9/jamb")).
also importantly the amb call MUST end with a semi colon.

other functions

I have also attempted to define other functions that are helpful in coding with amb.
assert([bool]) takes a boolean and fails if that bools is false.
natural_numbers() is a generator that yields every natural number (useful for clp).
range(low,high) is a generator that yields every integer between low (inclusive) and high (exclusive).
prefixes(array) is a generator that generates all the prefixes of the array passed to it (similar to prologs append).
suffixes(array) is a generator that generates all the suffixes of the array passed to it (similar to prologs append).
permutations(array) is a (not yet working) generator that generates all the permutations of the array passed to it.

important notes

amb works by inserting a closure from the call to the end of the scope. I am bad at programming so I defined the end of scope as when I find an unmatched curly bracket. This means amb won't work sometimes when you think it will. Importantly amb within a function does not retain it's ambigiousness once the function returns (it will return properly though don't worry). If you want this property to be retained, please pass a continuation to the function in order for it to work.
something really fun is that the assert function is logically pure and the amb function is not. This kinda half solves a problem with prolog in that logical purity is not enforced and logical purity and impurity is mixed without any complaining on the part of prolog. (this assume functional purity within assert).