# in-out-type

> TypeScript function I/O utility types

Latest version **0.0.9** (published 2021-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install in-out-type
pnpm add in-out-type
yarn add in-out-type
bun add in-out-type
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2021-05-10 |
| First published | 2021-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Winton Welsh |
| Maintainers | winton |

## Links

- npm: https://www.npmjs.com/package/in-out-type
- Repository: https://github.com/artificial-page/in-out-type
- Homepage: https://github.com/artificial-page/in-out-type#readme
- Issues: https://github.com/artificial-page/in-out-type/issues
- npm.io page: https://npm.io/package/in-out-type

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) 1.14.1

## Recent versions

- 0.0.9 (latest) — 2021-05-10
- 0.0.8 — 2021-05-10
- 0.0.7 — 2021-05-10
- 0.0.6 — 2021-05-10
- 0.0.5 — 2021-05-10

## README

# 🧼 In/Out Type

TypeScript function I/O utility types

## ⚙️ Install

```bash
npm install in-out-type
```

## ⛲ Purpose

Function I/O types eliminate the need to split out arguments and return values to external interfaces.

This removes one level of obscurity from both the function implementation and the function type references.

## 👻 Types

| Type | Description |
| :--- | :--- |
| `InType<T>` | Given a function type, get the type of the first argument |
| `OutType<T>` | Given a function type, get the return type |

## 📽️ Example

Here we create a function that combines two other function's outputs:

```typescript
import { InType, OutType } from "in-out-type"

async function helloHi({
  hello,
  hi
}: InType<typeof helloWord> &
  InType<typeof hiUniverse>
): Promise<
  OutType<typeof helloWord> &
  OutType<typeof hiUniverse>
> {
  return Object.assign(
    helloWorld({ hello }),
    await hiUniverse({ hi }),
  )
}

function helloWorld(
  { hello }: { hello: boolean }
): { world: boolean } {
  if (hello) {
    return { world: true }
  }
}

async function hiUniverse(
  { hi }: { hi: boolean }
): Promise<{ universe: boolean }> {
  if (hi) {
    return { universe: true }
  }
}
```

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