MuffinJS
raw JSON → 1.1.2 verified Fri May 01 auth: no javascript maintenance
MuffinJS v1.1.2 is a transpiler and runtime for the Muffin scripting language, designed to compile and execute Muffin scripts on Node.js. It offers a simple alternative to JavaScript with custom syntax for variables, loops, conditions, and functions, and supports including external scripts and libraries. Unlike general-purpose languages, it focuses on ease of use with automatic disk persistence for variables and built-in I/O abstraction. Release cadence is low; the project appears in maintenance mode with limited recent updates.
Common errors
error ReferenceError: prompt is not defined ↓
cause The compiled Muffin script calls prompt, but the global prompt object has not been defined.
fix
Define prompt as shown in the README before calling eval(output).
error TypeError: localStorage.getItem is not a function ↓
cause localStorage object is missing or incorrectly implemented.
fix
Implement localStorage with getItem, setItem, and clear methods as specified.
error SyntaxError: Unexpected identifier ↓
cause Using semicolons in Muffin scripts causes parser to treat next line as continuation, leading to invalid generated JavaScript.
fix
Avoid semicolons in Muffin source code.
Warnings
gotcha prompt, confirm, and localStorage objects must be defined globally before using eval(output) or running compiled code. ↓
fix Inject these objects as shown in the README before calling eval().
gotcha The parser treats lines ending with semicolon as continuation lines, not newlines. ↓
fix Do not use semicolons inside Muffin scripts to avoid unexpected line merging.
deprecated Package uses chalk@4.0.0 which is outdated; newer versions may break due to ESM conversion. ↓
fix Pin chalk to version 4.0.0 when using the provided prompt/confirm implementation.
gotcha The README contains typos such as 'Stringif' instead of 'stringify' and 'toUpperCase()' incorrect chaining, causing runtime errors if copied verbatim. ↓
fix Review the provided code and fix syntax errors before use.
gotcha eval() is used to execute compiled output, which is a security risk if input is untrusted. ↓
fix Avoid using eval() with untrusted Muffin scripts; consider sandboxing or pre-compiling.
Install
npm install muffin-js yarn add muffin-js pnpm add muffin-js Imports
- default wrong
import muffin from 'muffin';correctconst muffin = require('muffin'); - prompt wrong
// Missing prompt object will cause ReferenceError at runtimecorrectconst prompt = (data) => readline.question(chalk.green(data.toUpperCase()) + chalk.green('\n\nINPUT> ')); - confirm wrong
// Missing confirm will crash when scripts call confirmcorrectconst confirm = (...rest) => { console.clear(); console.log(...rest.map(e => chalk.green(e.toString().toUpperCase()))); readline.question(chalk.green('\nPRESS ENTER> ')); return true; }; - localStorage wrong
// Missing localStorage or incorrect method signatures cause runtime errorscorrectconst localStorage = { getItem: (name) => { ... }, setItem: (name, value) => { ... }, clear: () => { ... } };
Quickstart
// Install globally or locally: npm i muffin-js
// Create a Muffin script file: hello.muffin
// Write: print "Hello, Muffin!"
// Compile and run: muffin hello.muffin
// Alternatively, use programmatically:
const muffin = require('muffin');
const my_code = 'print "Hello, World!"';
const output = muffin(my_code);
eval(output); // EVAL IS EVIL - ensure prompt, confirm, localStorage are defined