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

muffin-js

v1.1.2

Published

The transpiler and runtime for Muffin.

Downloads

5

Readme

🧁 Muffin

MuffinJS is a node.js library that lets you compile and run Muffin scripts on your machine.

Set up and compile

npm i -g muffin-js
muffin entry_point.js

Use it with Node.JS

WARNING: You need to provide "prompt", "confirm" and "localStorage" objects for it to work properly. This is the one that comes with the bundle:

/* to download the libraries: 
npm i [email protected] [email protected]
*/
const readline = require('readline-sync');
const chalk = require('chalk'); /* NEEDS [email protected] */
const fs = require('fs');
const prompt = ((data) => readline.question(chalk.green(data.toUpperCase()) + chalk.green('\n\nINPUT> ')));
const confirm = ((...rest) => { console.clear(); console.log(...rest.map(e => chalk.green(e.toString()toUpperCase()))); readline.question(chalk.green('\nPRESS ENTER> ')); return true; });
const localStorage = ({
    getItem: ((name = '') => fs.existsSync('./storage/' + name + '.txt') ? JSON.parse(fs.readFileSync('storage/' + name + '.txt', 'utf8')) : undefined),
    setItem: ((name = '', value = '') => fs.writeFileSync('./storage/' + name + '.txt', JSON.stringif(value)),
    clear: (() => { fs.rmdirSync('./storage', { recursive: true }); fs.mkdirSync('./storage'); })
});

You can compile the code with the script below but you will need to install the mentioned dependencies!

const muffin = require('muffin');
const my_code = `print "Your code goes here..."`;
// Outputs javascript code! Run it right away btw!
const output = muffin(my_code);
/*
Run it! However, Remember: EVAL IS EVIL!
You also need to include "prompt", "confirm" and "localStorage".
or, Use the specified code above!
*/
eval(output);

Documentation

This is the more updated documentation, It's better than the in-script documentation.

Parser

The parser basically seperates the text line-by-line, HOWEVER, THE PARSER DOES NOT COUNT LINES THAT HAVE A SEMICOLON AT THE END A NEWLINE! Example:

print "This is " + ;
    "Not a new line!!!"

Comments

A comment:

# Hello! This is a comment!

# Multiline comments...
# Technically exist!

Including other scripts

Including an external file:

link ./path/to/file.muffin

Adding an internal library:

link muffin.<library>

Example (1.1 only):

link gui.muffin
execute muffin.gui.menu [ "prompt", "Hello world!" ],;
[ "print 'Hey there!'", "Hi!" ],;
[ "print 'See you later!'", "Goodbye!" ]

Input/Output

Show a notice to the user:

print <javascript syntax>

Example:

print "Hello " + "World!"

Ask the user for input:

prompt <variable name> <javascript syntax>

Example:

prompt hello_word_2000 "Hello, Whats your name?"

Quitting

When you want to quit your job:

# Yea, It's just that.
exit

Variables

Create a variable anyways (saved to disk too):

var <name> <javascript syntax>

Create a variable only if it doesn't exist even on disk (life saver):

cvar <name> <javascript syntax>

Loops/Conditions/Functions

Yes, We have a ton of alternates!

Functions:

sector <name>
    # how to get arguments?
    print "First argument: " + input[0]
    # yep!
    <code with fixed indent>

function <name>
    <code with fixed indent>

# calling a function!
execute <name> <arguments separated by ",">
# now for when you need js:
_ <javascript syntax for the name> <arguments separated by ",">

Conditions:

if <javascript syntax>
    <code with fixed indent>
elif <javascript syntax>
    <code with fixed indent>
elseif <javascript syntax>
    <code with fixed indent>
else_if <javascript syntax>
    <code with fixed indent>
else
    <code with fixed indent>

Loops:

for <javascript syntax>
    <code with fixed indent>
while <javascript syntax>
    <code with fixed indent>

Anything else unlisted:

pop <condition or loop or function name> <javascript syntax>
    <code with fixed indent>

Erasing all data

For when you need it.

purge

[Old] documentation

This doesn't go into your actual code.

docs confirm