Skip to main content
The @orion-js/helpers package provides a collection of utility functions and error classes to simplify common tasks in OrionJS applications.

Installation

Utility Functions

Sleep

Creates a Promise-based timeout for delaying execution.

Retries

Execute a function with automatic retries on failure.

Generate ID

Creates random IDs with configurable length and character set.

Generate UUID

Creates a standard UUID.

Hash Object

Creates a deterministic hash of an object.

Create Map

Creates a map from an array of objects using a key.

Create Map Array

Creates a map of arrays from an array of objects using a key.

Compose Middlewares

Composes multiple middleware functions into a single middleware function, similar to Koa’s middleware composition.

Error Classes

OrionError

Base error class for all Orion errors.

UserError

Error meant to be displayed to users.

PermissionsError

Error thrown when a user doesn’t have the required permissions.

Error Handling

All error classes provide helpful methods to access error information: