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.
- Support Typescript
- Support loop entry point
- Support main entry point
- Support functional or export syntax
$ npm install --save-dev bedo
$ yarn add --dev bedo
$ pnpm add --save-dev bedo
$ bun add --dev bedo
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.
#!/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
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
#!/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
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
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.
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
andsetup
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 |
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
andtick
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 overrideframe
value
- Callback Parameter:
Parameters | Type | Description |
---|---|---|
count |
number |
will cache count of each execution ticks |
Under GPLv3 for Open Source by Wonize Group.