# ts-powertypes

> Collection of typescript types

Latest version **0.0.5** (published 2023-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-powertypes
pnpm add ts-powertypes
yarn add ts-powertypes
bun add ts-powertypes
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2023-04-12 |
| First published | 2023-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Teun Mooij |
| Maintainers | teunmooij |
| Keywords | typescript, ts, tools, utils, utility, types |

## Links

- npm: https://www.npmjs.com/package/ts-powertypes
- Repository: https://github.com/teunmooij/ts-tools
- Homepage: https://github.com/teunmooij/ts-tools/#readme
- Issues: https://github.com/teunmooij/ts-tools/issues
- npm.io page: https://npm.io/package/ts-powertypes

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 0.0.5 (latest) — 2023-04-12
- 0.0.4 — 2023-04-10
- 0.0.3 — 2023-04-10
- 0.0.2 — 2023-04-09
- 0.0.1 — 2023-04-08

## README

[![author](https://img.shields.io/badge/author-Teun%20Mooij-blue)](https://www.linkedin.com/in/teunmooij/)
[![snyk](https://snyk.io/test/github/teunmooij/ts-tools/badge.svg)](https://snyk.io/test/github/teunmooij/ts-tools)
[![downloads](https://img.shields.io/npm/dt/ts-powertypes?color=blue)](https://www.npmjs.com/package/ts-powertypes)
[![npm version](https://badge.fury.io/js/ts-powertypes.svg)](https://www.npmjs.com/package/ts-powertypes)
[![license](https://img.shields.io/npm/l/ts-powertypes?color=blue)](https://img.shields.io/npm/l/ts-powertypes)

# ts-powertypes

Collection of typescript types

This package is work in progress and semantic versioning is not yet guaranteed. If you use this package, please make sure to set explcit version number in your package json.

## Install

```shell
npm install ts-powertypes
```

## Usage

```ts
import type { Flatten } from 'ts-powertypes';

type Book = {
  title: string;
  chapters: {
    title: string;
    content: Record<string, string>;
  }[];
};

type FlatBook = Flatten<Book>;
/*
{
  title: string;
  [x: `chapters.${number}.title`]: string;
  [x: `chapters.${number}.content.${string}]: string;
}
*/
```

## Api

### Object types

- `Primitive` union of all primitive typescript types
- `Key` union of primitive types that can be used as object keys

- `ElementType` gets the type of the elements of an Array, Map or Record

- `KeyOf` union of the keys of an object
- `ValueOf` union of the value types of an object
- `ObjectKeys` strong type for the return type of `Object.keys()`
- `ObjectValues` strong type for the return type of `Object.values()`
- `ObjectEntries` strong type for the return type of `Object.entries()`

- `Split` splits a string constant on a given separator
- `Join` joins a string constant on a given separator

- `Flatten` flattens an object structure
- `ObjectPaths` union of all key paths of an object
- `ValuesAtPath` value type of an object at a given patch

- `IsAny` evaluates to `true` if the given type is `any`, else `false`

## Version history

See [changelog](./CHANGELOG.md)

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