# motor-loop

> Motor loop is a typescript library that runs a game loop continuously. Notably, it adapts to frameRate to ensure your game always runs smoothly when the monitor refresh rate goes above or below 60hz.

Latest version **1.0.24** (published 2024-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install motor-loop
pnpm add motor-loop
yarn add motor-loop
bun add motor-loop
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.24 |
| Published | 2024-06-09 |
| First published | 2024-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14.0.0 |
| Dependencies | 2 |
| Unpacked size | 30.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jack Le Hamster |
| Maintainers | vincentlequang |
| Keywords | bun, bunjs, typescript, template, npm, np, publish, git |

## Links

- npm: https://www.npmjs.com/package/motor-loop
- Repository: https://github.com/jacklehamster/motor-loop
- Homepage: https://jacklehamster.github.io/motor-loop/
- Issues: https://github.com/jacklehamster/motor-loop/issues
- npm.io page: https://npm.io/package/motor-loop

## Dependencies (2)

- [bun-pool](https://npm.io/package/bun-pool.md) ^1.0.9
- [fixed-framerate-loop](https://npm.io/package/fixed-framerate-loop.md) ^1.0.11

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.24 (latest) — 2024-06-09
- 1.0.23 — 2024-03-08
- 1.0.22 — 2024-03-03
- 1.0.21 — 2024-03-03
- 1.0.20 — 2024-03-03
- 1.0.19 — 2024-02-29
- 1.0.18 — 2024-02-28
- 1.0.17 — 2024-02-24
- 1.0.16 — 2024-02-14
- 1.0.15 — 2024-02-10
- 1.0.14 — 2024-02-09
- 1.0.13 — 2024-02-09
- 1.0.12 — 2024-02-09
- 1.0.11 — 2024-02-09
- 1.0.10 — 2024-02-09
- … 9 more at https://npm.io/package/motor-loop/versions

## README

# motor-loop

[![npm version](https://badge.fury.io/js/motor-loop.svg)](https://www.npmjs.com/package/motor-loop)

Motor loop is a typescript library that runs a game loop continuously.

Notably, it adapts to frameRate to ensure your game always runs smoothly when the monitor refresh rate goes above or below 60hz.

It's also used to schedule updates.

## Usage

```es6
  const motor = new Motor();

  //  This will cause your refresh method to be called continously at the frameRate specified
  motor.loop({
    refresh: (updatePayload) {
      //  execute continously
      doSomethingWith(updatePayload.data);
    }
  }, data, frameRate);
  
  //  You can also schedule an update. The update will only be executed one time
  motor.scheduleUpdate({
    refresh: (updatePayload) {
      //  update something
    }
  });
```

![](https://jacklehamster.github.io/motor-loop/icon.png)
## Install bun

https://bun.sh/

```bash
curl -fsSL https://bun.sh/install | bash
```

## Commands

- **start**: "bun run index.ts",
- **bundle**: "bun run bundler/bundler.ts",
- **list**: "bun run samples/list-scripts.tsx",
- **example**: "cd example && bun start && cd ..",
- **fileSample**: "bun run samples/file.tsx && cat samples/data/test.json",
- **httpSample**: "bun run samples/server.tsx"

## Run example

[https://jacklehamster.github.io/motor-loop/example/](https://jacklehamster.github.io/motor-loop/example/)

## Github Source

[https://github.com/jacklehamster/motor-loop/](https://github.com/jacklehamster/motor-loop/)

---
_Source: https://npm.io/package/motor-loop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
