# gxz

> 🦋 Function Composer with deep typing.

Latest version **2.0.1** (published 2022-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install gxz
pnpm add gxz
yarn add gxz
bun add gxz
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2022-06-01 |
| First published | 2022-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | tylim |
| Keywords | function, compose, typescript |

## Links

- npm: https://www.npmjs.com/package/gxz
- Repository: https://github.com/tylim88/gxz
- Homepage: https://github.com/tylim88/gxz#readme
- Issues: https://github.com/tylim88/gxz/issues
- npm.io page: https://npm.io/package/gxz

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2022-06-01
- 0.0.0-beta.2 (beta) — 2022-02-06
- 2.0.0 — 2022-06-01
- 1.0.7 — 2022-05-25
- 1.0.6 — 2022-02-09
- 1.0.5 — 2022-02-09
- 1.0.4 — 2022-02-09
- 1.0.3 — 2022-02-09
- 1.0.2 — 2022-02-08
- 1.0.1 — 2022-02-07
- 0.0.0-beta.1 — 2022-02-06

## README

# gxz

[![npm](https://img.shields.io/npm/v/gxz)](https://www.npmjs.com/package/gxz) [![GitHub](https://img.shields.io/github/license/tylim88/gxz?color=blue)](https://github.com/tylim88/gxz/blob/master/LICENSE) [![dependencies](https://img.shields.io/badge/dynamic/json?color=brightgreen&label=dependencies&query=%24.dependencies.count&url=https%3A%2F%2Fapi.npmutil.com%2Fpackage%2Fgxz)](https://www.npmjs.com/package/gxz?activeTab=dependencies) [![circleci](https://circleci.com/gh/tylim88/gxz.svg?style=shield)](https://app.circleci.com/pipelines/github/tylim88/gxz) [![codecov](https://codecov.io/gh/tylim88/gxz/branch/master/graph/badge.svg?token=IUUC7E1RTW)](https://codecov.io/gh/tylim88/gxz)

🦋 Function Composer with deep typing.

## Installation

```bash
npm i gxz
```

## 🎵 Usage

This composer guarantee the return type of `n` callback match the parameter type of `n+1` callback.

Every callback should only have one parameter, ts will warn you if you have more than one or 0 parameters.

```ts
import gxz from 'gxz'

const a = (arg: number) => {
	return arg === 1 ? 'hello' : 'world'
}

const b = (arg: string) => {
	return arg === 'hello'
}

const c = (arg: boolean) => {
	return arg ? 100 : 0
}

const composed = gxz(a, b) // type of `composed` is (arg:number) => boolean

composed(1) // true
composed(2) // false

// type checking
composed('a') // Argument of type 'string' is not assignable to parameter of type 'number'.
gxz(a, c) // Argument of type '(arg: number) => "hello" | "world"' is not assignable to parameter of type '"return type does not match the next argument type"'.
gxz(a) // Argument of type '(arg: number) => "hello" | "world"' is not assignable to parameter of type '"need at least 2 functions"'.
```

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