# @emotionagency/utils

> Useful utilities from the emotion-agency

Latest version **2.0.2** (published 2026-04-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @emotionagency/utils
pnpm add @emotionagency/utils
yarn add @emotionagency/utils
bun add @emotionagency/utils
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2026-04-01 |
| First published | 2020-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | emotion-agency |
| Maintainers | lkosteckyi |
| Keywords | js, utilities, javascript, typescript, requestAnimationFrame, resize, raf, clamp, lerp, damp, modulo, math, ssr |

## Links

- npm: https://www.npmjs.com/package/@emotionagency/utils
- Repository: https://github.com/letmewin22/utilities
- Homepage: https://github.com/letmewin22/utilities#readme
- Issues: https://github.com/letmewin22/utilities/issues
- npm.io page: https://npm.io/package/@emotionagency/utils

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.2 (latest) — 2026-04-01
- 2.0.1 — 2025-04-18
- 2.0.0 — 2025-04-17
- 1.1.17 — 2025-04-11
- 1.1.16 — 2024-08-08
- 1.1.15 — 2024-08-08
- 1.1.14 — 2024-02-16
- 1.1.13 — 2024-02-16
- 1.1.12 — 2024-02-16
- 1.1.11 — 2024-02-15
- 1.1.10 — 2023-12-01
- 1.1.9 — 2023-12-01
- 1.1.8 — 2023-12-01
- 1.1.7 — 2023-12-01
- 1.1.6 — 2023-11-23
- … 21 more at https://npm.io/package/@emotionagency/utils/versions

## README

Useful utilities from the emotion-agency

# Installation

`npm i @emotionagency/utils`

or

`yarn add @emotionagency/utils`

# Usage

## Raf
Custom wrapper around standard API of requestAnimationFrame to optimize performance

```js
import {raf} from '@emotionagency/utils'

// subscribe
raf.on((time, deltaTime) => {
  // time - current timestamp
  // deltaTime - time since last frame
})

// unsubscribe
raf.off(fn)

```

## Resize
Custom wrapper around standard API of resize event with debounce function to optimize performance

```js
import {resize} from '@emotionagency/utils'

// subscribe
resize.on(fn)

// unsubscribe
resize.off(fn)

```

## Lerp
Standard lerp (linear interpolation) function

```js
import {lerp} from '@emotionagency/utils'

lerp(start, end, interpolation)
```

## Clamp
Standard clamp function

```js
import {clamp} from '@emotionagency/utils'

clamp(value, min, max)
```

## Damp
Frame-rate independent damping using exponential decay. Useful for smooth animations that behave consistently regardless of frame rate.

```js
import {damp} from '@emotionagency/utils'

damp(current, target, lambda, deltaTime)
// lambda - damping strength (higher = faster)
// deltaTime - time since last frame
```

## Modulo
Proper modulo function that handles negative numbers correctly. Unlike the `%` operator, always returns a value in the range `[0, divisor)`.

```js
import {modulo} from '@emotionagency/utils'

modulo(5, 3)   // 2
modulo(-1, 3)  // 2  (% would return -1)
```

## CreateNewElement
A function that creates a new DOM-element with the ability to immediately assign the necessary classes to it

```js
import {createNewElement} from '@emotionagency/utils'

createNewElement(tag, classes)
```

## Delay
A function that creates a Promise with delay

```js
import {delayPromise} from '@emotionagency/utils'

const delayFunc = async () => {
  await delayPromise(1000)
  // logic
}
```

## Keys Generator
A function that generates a random string by length
```js
import {keysGenerator} from '@emotionagency/utils'

const randomKey = keysGenerator(10)
```

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