# @joktec/utils

> JokTec - Utilities

Latest version **0.1.5** (published 2026-06-27) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2026-06-27 |
| First published | 2025-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 273.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | JokTec |
| Maintainers | joktec_dev |
| Keywords | utils |

## Links

- npm: https://www.npmjs.com/package/@joktec/utils
- npm.io page: https://npm.io/package/@joktec/utils

## Dependencies (9)

- [slug](https://npm.io/package/slug.md) ^11.0.1
- [uuid](https://npm.io/package/uuid.md) ^14.0.1
- [dayjs](https://npm.io/package/dayjs.md) ^1.11.21
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.18.1
- [bcryptjs](https://npm.io/package/bcryptjs.md) ^3.0.3
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [class-validator](https://npm.io/package/class-validator.md) ^0.15.1
- [class-transformer](https://npm.io/package/class-transformer.md) ^0.5.1

## Recent versions

- 0.1.5 (latest) — 2026-06-27
- 0.1.4 — 2026-06-24
- 0.1.3 — 2025-07-01
- 0.1.2 — 2025-06-25
- 0.1.1 — 2025-03-23
- 0.1.0 — 2025-03-20

## README

# @joktec/utils

Low-level utility package used by JokTec framework packages and applications.

`@joktec/utils` is intentionally dependency-light. It provides reusable helpers, HTTP constants, validation decorators, and selected `class-transformer` / `class-validator` exports so higher-level packages can share the same utility layer.

## Install

```bash
yarn add @joktec/utils
```

## Public Surface

- HTTP constants:
  - `HttpMethod`
  - `HttpStatus`
  - `HttpRequestHeader`
  - `HttpContentType`
- conversion helpers:
  - numeric, boolean, array, object, class, URL, and string conversion utilities
- generator helpers:
  - random values, IDs, tokens, and string generation helpers
- validation helpers:
  - runtime checks and validator utilities
- decorators:
  - `Is2DArray`
  - `IsTypes`
- re-exports:
  - `class-transformer`
  - `class-validator`
  - `validateSync`

## Basic Usage

```ts
import { HttpStatus, isEmpty, joinUrl, toArray, toBool } from '@joktec/utils';

const endpoint = joinUrl('https://api.example.com', 'v1', 'users');
const enabled = toBool(process.env.FEATURE_ENABLED, false);
const values = toArray('admin');

if (isEmpty(values)) {
  throw new Error(`Expected at least one role. HTTP ${HttpStatus.BAD_REQUEST}`);
}
```

## Config Validation Usage

JokTec config classes commonly use validators from this package:

```ts
import { IsBoolean, IsOptional, IsString, toBool } from '@joktec/utils';

export class ExampleConfig {
  @IsString()
  name!: string;

  @IsOptional()
  @IsBoolean()
  debug?: boolean;

  constructor(props: ExampleConfig) {
    Object.assign(this, {
      ...props,
      debug: toBool(props.debug, false),
    });
  }
}
```

## Design Guidelines

- Keep this package free of framework, database, broker, adapter, and app dependencies.
- Prefer small deterministic helpers over stateful services.
- Use helpers here only when they are broadly reusable across packages.
- Avoid placing business-domain behavior in this package.
- Keep validation decorators generic and independent from any specific application model.

## Repository Layout

- `src/constants`: HTTP constants.
- `src/helpers`: conversion, generation, encryption, validation, and runtime helper functions.
- `src/validators`: class-validator decorators.
- `src/index.ts`: public package export boundary.

## Development

```bash
yarn lint --scope @joktec/utils
yarn build --scope @joktec/utils
yarn test --scope @joktec/utils
```

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