# @hyperjump/pact

> Higher order functions for iterators and async iterators

Latest version **1.4.0** (published 2025-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hyperjump/pact
pnpm add @hyperjump/pact
yarn add @hyperjump/pact
bun add @hyperjump/pact
```

## Health

**Score 50/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2025-03-11 |
| First published | 2019-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 28.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jason Desrosiers |
| Maintainers | jason.desrosiers |
| Keywords | Hyperjump, Promise, higher order functions, iterator, async iterator, generator, async generator, async |

## Links

- npm: https://www.npmjs.com/package/@hyperjump/pact
- Repository: https://github.com/hyperjump-io/pact
- Homepage: https://github.com/hyperjump-io/pact#readme
- Issues: https://github.com/hyperjump-io/pact/issues
- Funding: https://github.com/sponsors/jdesrosiers
- npm.io page: https://npm.io/package/@hyperjump/pact

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.4.0 (latest) — 2025-03-11
- 1.3.0 — 2023-12-06
- 1.2.0 — 2023-06-23
- 1.1.0 — 2023-06-21
- 1.0.0 — 2023-05-11
- 0.2.5 — 2022-12-03
- 0.2.4 — 2022-08-15
- 0.2.3 — 2022-04-30
- 0.2.2 — 2022-04-30
- 0.2.1 — 2022-01-23
- 0.2.0 — 2021-09-06
- 0.1.2 — 2020-04-28
- 0.1.1 — 2020-04-26
- 0.1.0 — 2019-08-14

## README

# Hyperjump Pact

Hyperjump Pact is a utility library that provides higher order functions for
working with iterators and async iterators.

## Installation
Designed for node.js (ES Modules, TypeScript) and browsers.

```bash
npm install @hyperjump/pact --save
```

## Usage

```javascript
import { pipe, range, map, filter, reduce } from "@hyperjump/pact";


const result = pipe(
  range(1, 10),
  filter((n) => n % 2 === 0),
  map((n) => n * 2),
  reduce((sum, n) => sum + n, 0)
);
console.log(result);
```

```javascript
import { pipe, asyncMap, asyncFilter, asyncReduce } from "@hyperjump/pact";
// You can alternatively import the async functions without the prefix
// import { pipe, map, filter, reduce } from "@hyperjump/pact/async";


const asyncSequence = async function* () {
  yield 1;
  yield 2;
  yield 3;
  yield 4;
  yield 5;
};

for await (const value of asyncSequence()) {
  console.log(value);
}

const result = await pipe(
  asyncSequence(),
  asyncFilter((n) => n % 2 === 0),
  asyncMap((n) => n * 2),
  asyncReduce((sum, n) => sum + n, 0)
);
console.log(result);
```

## API

https://pact.hyperjump.io

## Contributing

### Tests

Run the tests

```bash
npm test
```

Run the tests with a continuous test runner

```bash
npm test -- --watch
```

[hyperjump]: https://github.com/hyperjump-io/browser
[jref]: https://github.com/hyperjump-io/browser/blob/master/src/json-reference/README.md

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