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

@cyberdevs/boiler.js

v1.4.6

Published

A more extended and advanced Node.js emulator, with boilerplate code.

Downloads

29

Readme

Boiler.js - The extensive Node.js Emulator

Boiler.js is an advanced system and it is not recommended to be used by inexperienced developers. To learn Boiler.js, it is recommended to learn ModuleJS first.

This file covers:

  • Installing Boiler.js

  • Creating a project

  • Building a project

  • Creating a library/module

Installation

Installing Boiler.js is as easy as installing npm. To install Boiler.js, execute:

$ npm install -g @cyberdevs/boiler.js 
(you might need to use sudo to install it on macOS and Linux)

You have successfully Installed Boiler.js!

Creating a Project

To create a new project, execute:

$ boiler new <project_name> mjs

This will create a new project with the ModuleJS base. (es6 and commonjs will be added later)

Doing this will also create the main.mjs file. This file is the 'Codepoint', meaning that it is going to be executed when the program is launched.

The file's contents should look like this:

import * as Boiler from './.boiler/index.mjs';
import logger from './.boiler/index.mjs';

export class Main extends Boiler.Application {
    /** @param {string[]} args `command-line` arguments for the file */ constructor(args) { super(); this.app = {}; this.app.args = args; };
    /** 
     * @desc Main method to execute
     * @returns {number} The exit code for the application */ run() { 
        logger.print('Hello, World!');
        return 0;
    };
}; 

This is the default application. When launched, it will print out 'Hello, World!' and exit with code 0. The run() method returns an exit code, which is the status code for the application. It will be returned as the 'errorlevel' or 'exit code'.

To extend the functionality of the application, write code under the run() method. You can even add more methods to the application with:

//...
/** @param {string} file to check existence of */ checkFileExistence(file) {
    logger.print('Checking file existence of: ' + file);
    return fs.existsSync(file); //The existence of the file is returned by this function.
}; 

Building a Project

Now that you created your first Boiler Project, it is time to run it. The build procedure in Boiler is quite different to other languages.

When built, a project does not need to be rebuilt after being modified. The build procedure takes ~4.8 seconds on an average computer.

To built a project, execute:

$ boiler build

This command will build the project, making it ready to be launched. After building your project, run it with boiler run and add some parameters to it.

For example: boiler run hello will parse [ 'hello' ] to the Boiler::Application.cli.args object.

Creating a library/module

A library or module is a boiler project that compiles into a module. To create a library/module, run:

$ boiler new <project_name> mjs

This will create your project in the current directory. After this, go into the main.mjs file. It should look like this:

import * as Boiler from './.boiler/index.mjs';
import logger from './.boiler/index.mjs';

export class Main extends Boiler.Application {
    /** @param {string[]} args `command-line` arguments for the file */ constructor(args) { super(); this.app = {}; this.app.args = args; };
    /** 
     * @desc Main method to execute
     * @returns {number} The exit code for the application */ run() { 
        logger.print('Hello, World!');
        return 0;
    };
}

Delete the Main class completely. This will leave you with:

import * as Boiler from './.boiler/index.mjs';
import logger from './.boiler/index.mjs';

Then, you should use the following boilerplate code:

export const isModule = true; // this is required for your application to be recognized as a module.
export class BoilerCommand extends Boiler.InterfaceCommand {
    name = 'your_subcommand_name' // this name will be used when starting your interface. (CANNOT INCLUDE SPACE)
                                  // Example: boiler testcommandname
    desc = 'This is an example interface for boiler.' // add a description to your command.
    /* OPTIONAL */ help() {}; // enter the method to execute when showHelp is 'true' and no arguments are provided
    /* OPTIONAL */ showHelp = true; // set this value to 'true' if your command requires arguments.
    /* OPTIONAL */ isParameter = false; // set this value to 'true' if your command should be treated like a parameter
    run() {}; // enter the main method to execute, this is run when the interface is launched successfully.
};

That's it! Now import it using boiler import. NOTE: values that are marked as 'OPTIONAL' aren't needed to be initilized.

Example interface:

import * as Boiler from './.boiler/index.mjs';
import logger from './.boiler/index.mjs';

export const isModule = true;
export class NumberMultiplier extends Boiler.InterfaceCommand {
    name = 'multiply';
    desc = 'Multiplies a number by 10.';
    isParameter = false;
    showHelp = true; //show help if there are less than 1 argument provided to the application
    help() {
        console.log('example usage:' + 
        '\nboiler multiply 20');
        console.log('this command multiplies a number by 10.');
    }; //help command (triggered if showHelp is enabled)
    /** 
     * @param {string[]} args arguments parsed into the application
    */
    run(args) {
        let number = parseInt(args[0]); //the number as an integer
        let calculation = number * 10;
        logger.print('The result is: ' + calculation);
    }
};

License MIT

Boiler.js is recommended for use with Command-line interface applications (CLI) and modules that are not packaged. (Discord.js bots, REST listeners and other client-side apps)

Libraries Used