# @kakasoo/proto-typescript

> Utility types and implementations based on JavaScript prototypes.

Latest version **1.28.8** (published 2025-02-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install @kakasoo/proto-typescript
pnpm add @kakasoo/proto-typescript
yarn add @kakasoo/proto-typescript
bun add @kakasoo/proto-typescript
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.28.8 |
| Published | 2025-02-01 |
| First published | 2023-12-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 163 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kakasoo |
| Maintainers | kakasoo |
| Keywords | type-safe, prototype, utility-types, iterable/iterator, ES6 |

## Links

- npm: https://www.npmjs.com/package/@kakasoo/proto-typescript
- npm.io page: https://npm.io/package/@kakasoo/proto-typescript

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.28.8 (latest) — 2025-02-01
- 1.28.7 — 2024-07-21
- 1.28.6 — 2024-07-21
- 1.28.5 — 2024-07-21
- 1.28.4 — 2024-07-21
- 1.28.3 — 2024-07-21
- 1.28.2 — 2024-07-21
- 1.28.1 — 2024-03-10
- 1.28.0 — 2024-03-10
- 1.27.3 — 2024-02-04
- 1.27.2 — 2024-02-01
- 1.27.1 — 2024-01-31
- 1.27.0 — 2024-01-20
- 1.26.5 — 2024-01-18
- 1.26.4 — 2024-01-07
- … 46 more at https://npm.io/package/@kakasoo/proto-typescript/versions

## README

# proto-typescript

Utility types and implementations based on JavaScript prototypes.
I plan to share the features that are officially available from 2.0.0.

# TypedClass

## prototype methods

```ts
new TypedArray([1, 2, 3] as const).unshift(4 as const); // TypedArray<[4, 1, 2, 3]>
```

```ts
new TypedArray([1, 2, 3] as const).join(','); // TypedString<'1,2,3'>
```

The return result of 'TypeClass' returns one of the instances of TypeClass again. Therefore, those who know the grammar of JavaScript can use it immediately.

## `refined` methods

```ts
/**
 * error case
 */
new TypedArray<'1-3'>([1, 2, 3]).refine([1, 2, 3] as const).join('-');
new TypedArray<'1-3'>([]).refine([1, 2, 3] as const).join('-');
new TypedArray<'1-3'>().refine([1, 2, 3, 4] as const).join('-');
new TypedArray<'1-3'>().refine([0, 1, 2, 3] as const).join('-');

/**
 * right case
 */
new TypedArray<'1-3'>().refine([2, 3] as const).join('-');
```

`TypedArray`, `TypedNumber` has the `refine` method, which serves to further narrow down the generic type received as a factor. This helps reduce developer mistakes, but it should be careful because it cannot guarantee actual runtime behavior.

> In the future, improvements will be made at the type level.

## toPrimitive method

```ts
new TypedString('abcdef').toPrimitive(); // 'abcdef'
```

You can change it to the primitive type of JavaScript.

```ts
const arr = [...new TypedArray([1, 2, 3, 4, 5] as const)]; // (1 | 2 | 3 | 4 | 5)[]
```

`Iterable/Iterator` is supported.

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