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

bedo

v0.0.4

Published

(bedo) Script Runner with Entry Points

Downloads

7

Readme

BANNER

Entry Point Script File Executor

version MIT License

The bedo is a script file executor that allows defining entry points in various ways and supports TypeScript. It offers features such as the ability to define loop and main entry points with options for clear screen, limit counts, and delay execution.

Features

  • Support Typescript
  • Support loop entry point
  • Support main entry point
  • Support functional or export syntax

Installation

npm Yarn pnpm bun deno

npm :

$ npm install --save-dev bedo

yarn :

$ yarn add --dev bedo

pnpm :

$ pnpm add --save-dev bedo

Bun :

$ bun add --dev bedo

Usage

Bedo accepts entry points in several ways: by defining them directly in the script file or by exporting functions. It supports defining both main and loop entry points.

Defining Entry Points (single-executable):

#!/usr/bin/env -S npx bedox
import { main, loop } from 'bedo';

main((...args: unknown[]) => {
  console.log('main - example', args);
});

loop((count: number) => {
    console.log('loop - example', count);
}, { limit: 10 });

Then, To make the script file executable:

$ sudo chmod +x ./SCRIPT_FILE.ts

Next, you can run it with:

$ ./SCRIPT_FILE.ts

or pass the flag arguments to it:

$ ./SCRIPT_FILE.ts --help

Defining Entry Points

import { main, loop } from 'bedo';

main((...args) => {
  console.log('main - example', args);
});

loop(
  (count) => {
    console.log('loop - example', count);
  },
  { limit: 10 },
);

Then, to execute the script file, you can follow one of deno/bun/node (or ts-node/tsx if TypeScript) or bedox itself:

$ bedox ./SCRIPT_FILE.ts

Exporting Entry Points (single-executable):

#!/usr/bin/env -S npx bedo
export default function main(...args: unknown[]) {
  console.log('main - example', args);
}

export const LOOP_LIMIT = 10;
export function loop(count: number) {
  console.log('loop - example ', count);
}

Make the script file executable:

$ sudo chmod +x ./SCRIPT_FILE.ts

Next, run the script:

$ ./SCRIPT_FILE.ts

or pass the flag arguments:

$ ./SCRIPT_FILE.ts --help

Exporting Entry Points:

export default function main(...args) {
  console.log('main - example', args);
}

export const LOOP_LIMIT = 10;
export function loop(count) {
  console.log('loop - example ', count);
}

Then, to execute the script file, you should run it using the bedo command:

$ bedo ./SCRIPT_FILE.ts

API Documentation

Bedo provides the following entry points:

  • main: To execute once in the entire life of the script execution.
  • loop: To execute at every duration or frame per second until the limit count is reached.

Main Entry

To execute once in the entire life of the script execution. There are two ways to declare the Main Entry Point: export default or functional.

[!NOTE] Aliases: main, init and setup in functional mode

  • Functional Mode:

| Options | Type | Default value | Description | | -------------- | ---------- | ------------- | --------------------------------------------------------------- | | clear_screen | boolean? | false | clear the terminal before executing the main entry point once |

  • Callback Parameter:

| Parameters | Type | Description | | ---------- | ----------- | -------------------------------------------- | | ...args | unknown[] | will pass process.argv.slice(2) or similar |

Loop Entry

To execute at every duration or frame per second (frame / 1000) until the limit count is reached. There are two ways to declare the Loop Entry Point: export loop or functional.

[!NOTE] Aliases: loop, update and tick in functional mode

  • Functional Mode:

| Options | Type | Default value | Description | | -------------- | ---------- | ----------------- | -------------------------------------------------- | | clear_screen | boolean? | false | clear screen before each execution of loop entry | | duration | number? | - | delay between each execution of loop entry. | | frame | number? | 30 | how many frame per seconds can run. | | limit | number? | Number.Infinity | define limit to how many loop can be run |

  • Exporting Mode:

| Options | Type | Default value | Description | | ------------------- | ---------- | ----------------- | -------------------------------------------------- | | LOOP_CLEAR_SCREEN | boolean? | false | clear screen before each execution of loop entry | | LOOP_DURATION | number? | - | delay between each execution of loop entry. | | LOOP_FRAME | number? | 30 | how many frame per seconds can run. | | LOOP_LIMIT | number? | Number.Infinity | define limit to how many loop can be run |

![NOTE] if use duration, it's override frame value

  • Callback Parameter:

| Parameters | Type | Description | | ---------- | -------- | ------------------------------------------ | | count | number | will cache count of each execution ticks |

LICENSE

Under GPLv3 for Open Source by Wonize Group.