Skip to content

Commit 76408d8

Browse files
committed
Merge branch 'docs/readme-and-jsdoc'
* docs/readme-and-jsdoc: refinalized docs and readme update tagline update readme update docs finalize jsdocs update docs add script to replace incorrect links update docs build and add documentation.md adding jsdoc2md and updating scripts reordered functions update jsdocs updating jsdoc for module
2 parents 24e736a + acb0246 commit 76408d8

8 files changed

Lines changed: 2047 additions & 202 deletions

File tree

README.md

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h3 align="center" >
22
<div>
33
<a href="https://github.com/nickesc/steploop"><img alt="Source: Github" src="https://img.shields.io/badge/source-github-brightgreen?style=for-the-badge&logo=github&labelColor=%23505050"></a>
4-
<a href="https://github.com/nickesc/steploop/actions/workflows/node.js.yml"><img alt="Tests: github.com/nickesc/steploop/actions/workflows/node.js.yml" src="https://img.shields.io/github/actions/workflow/status/nickesc/steploop/steploop-ts-tests.yml?logo=github&label=tests&logoColor=white&style=for-the-badge&labelColor=%23505050"></a>
4+
<a href="https://github.com/nickesc/steploop/actions/workflows/steploop-ts-tests.yml"><img alt="Tests: github.com/nickesc/steploop/actions/workflows/steploop-ts-tests.yml" src="https://img.shields.io/github/actions/workflow/status/nickesc/steploop/steploop-ts-tests.yml?logo=github&label=tests&logoColor=white&style=for-the-badge&labelColor=%23505050"></a>
55
<br>
66
<a href="https://www.npmjs.com/package/steploop"><img alt="NPM: npmjs.com/package/steploop" src="https://img.shields.io/npm/v/steploop?style=for-the-badge&logo=npm&logoColor=white&label=npm&color=%23C12127&labelColor=%23505050"></a>
77
</div>
@@ -17,43 +17,83 @@
1717
by <a href="https://nickesc.github.io">N. Escobar</a> / <a href="https://github.com/nickesc">nickesc</a>
1818
</h6>
1919
<h6 align="center">
20-
a fully-featured main-loop written in TypeScript
20+
a foundation for building loops that<br>
21+
execute at a consistent, specified rate
2122
</h6>
2223
</h3>
2324

2425
<br>
2526

2627
## About `steploop`
2728

28-
`steploop` is a fully-featured main-loop written in TypeScript (and JS) with no additional dependencies. `steploop` provides a strong base to build a loop that runs once-per-frame. Inspired by game engine main-loops like Godot's [MainLoop](https://docs.godotengine.org/en/stable/classes/class_mainloop.html) or Unity's [Update() loop](https://docs.unity3d.com/Manual/execution-order.html).
29+
`steploop` is a fully-featured main-loop written in TypeScript with no additional dependencies. It provides a strong foundation for building loops that execute at a consistent, specified rate, inspired by game engine main-loops like Godot's [`MainLoop`](https://docs.godotengine.org/en/stable/classes/class_mainloop.html) or Unity's [`Update()` loop](https://docs.unity3d.com/Manual/execution-order.html).
2930

30-
> // TODO
31+
`steploop` provides a structured lifecycle with methods that can be overridden to implement custom behavior.
3132

32-
### Install
33+
The `StepLoop` class manages the timing and execution flow, supporting both fixed-step updates via [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout) and smoother, display-synchronized updates using [`window.requestAnimationFrame()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame).
34+
35+
## Install
3336

3437
Install `steploop` via NPM:
3538

3639
```sh
37-
$ npm i steploop ## not published yet
40+
npm i steploop # NOT PUBLISHED
41+
```
42+
43+
Import the `StepLoop` class in your TypeScript or JavaScript file:
44+
45+
```ts
46+
import { StepLoop } from "steploop";
3847
```
3948

40-
### Basic Usage
49+
> [!NOTE]
50+
> `steploop` should be imported as an ES6 module.
4151
42-
##### Import:
52+
## Basic Usage
4353

44-
Import the library in your code:
54+
To define a new loop, extend the `StepLoop` class and override its methods to implement custom behavior.
4555

46-
```js
56+
```ts
4757
import { StepLoop } from "steploop";
58+
59+
class App extends StepLoop {
60+
override initial(): void {
61+
console.log("Loop starting");
62+
}
63+
64+
override step(): void {
65+
console.log(`Executing step: ${this.get_step()}`);
66+
}
67+
68+
override final(): void {
69+
console.log("Loop finished");
70+
}
71+
}
72+
73+
// Create a new loop that runs at 60 steps-per-second for 100 steps
74+
const app = new App(60, 100);
75+
app.start();
4876
```
49-
> `steploop` must be imported as an ES6 module.
5077

51-
##### Usage:
52-
> // TODO
78+
## Lifecycle
79+
80+
The `StepLoop` class executes in three distinct stages, with hooks that can be overridden to add custom logic:
81+
82+
1. **Initialization:** Runs once at the beginning of the loop
83+
- `initial()`: Runs once at the beginning of the loop.
84+
2. **Looping:** The core of the loop, which repeatedly executes the following sequence:
85+
- `background()`: Runs asynchronously at the beginning of each step.
86+
- `before()`: Runs before the main `step()` method.
87+
- `step()`: The main update function for your loop.
88+
- `after()`: Runs after the `step()` method.
89+
3. **Termination:** Runs once when the loop ends, either by reaching the end of its lifespan or being manually stopped
90+
- `final()`: Runs once when the loop ends.
91+
92+
The loop can run indefinitely or for a set number of steps, and its execution can be precisely controlled, allowing it to be paused, resumed, and dynamically modified at runtime.
5393

54-
## Documentation
94+
## Reference
5595

56-
> // TODO
96+
For full documentation of the module and its methods, please see the [Documentation](/docs/documentation.md) page.
5797

5898
## License
5999

0 commit comments

Comments
 (0)