# @simulacron/tools

> Helper functions.

Latest version **1.0.2** (published 2023-08-01) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @simulacron/tools
pnpm add @simulacron/tools
yarn add @simulacron/tools
bun add @simulacron/tools
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-08-01 |
| First published | 2023-08-01 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andy Chentsov |
| Maintainers | andyduke |
| Keywords | tools, debounce, throttle |

## Links

- npm: https://www.npmjs.com/package/@simulacron/tools
- Repository: https://github.com/andyduke/lit-widget
- Homepage: https://github.com/andyduke/lit-widget/packages/tools#readme
- Issues: https://github.com/andyduke/lit-widget/issues
- npm.io page: https://npm.io/package/@simulacron/tools

## Recent versions

- 1.0.2 (latest) — 2023-08-01
- 1.0.1 — 2023-08-01
- 1.0.0 — 2023-08-01

## README

# A set of helper functions.

## debounce & throttle

### debounce

Debounce the execution of the function.

You can specify the value in milliseconds as a number or in string format with the suffix `'<delay>ms'`, supported suffixes: ms - milliseconds, s - seconds, m - minutes.

This can be handy for events such as key presses or "input" in input fields.

```js
debounce(
  inputChanged(event) {
  // ...
  },
  '300ms'
);
```

### throttle

Throttle the execution of the function.

You can specify the value in milliseconds as a number or in string format with the suffix `'<delay>ms'`, supported suffixes: ms - milliseconds, s - seconds, m - minutes.

This can be handy for "resize" or "scroll" events.

```js
throttle(
  resizeChanged(event) {
    // ...
  },
  '500ms'
);
```

### duration

Duration converter from human-readable form to milliseconds.

Converts a string like `'<delay>ms'` to milliseconds.
Supported suffixes: ms - milliseconds, s - seconds, m - minutes.

If a numeric value is passed, it is returned unchanged.

```js
const delayInMilliseconds = duration('500ms');
```

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