# infinite-chain

> I'm going to chain forever, I'm going to learn how to fly

Latest version **0.1.1** (published 2022-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install infinite-chain
pnpm add infinite-chain
yarn add infinite-chain
bun add infinite-chain
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-06-25 |
| First published | 2022-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rob Molloy |
| Maintainers | romolo.co.uk |

## Links

- npm: https://www.npmjs.com/package/infinite-chain
- npm.io page: https://npm.io/package/infinite-chain

## Recent versions

- 0.1.1 (latest) — 2022-06-25

## README

# infinite-chain

I'm going to chain forever, I'm going to learn how to fly

```js
import { spreadChain } from "infinite-chain";

const chainFn = () => ({
  ...spreadChain("where", (numbers) => ({
    numbers,
    getNumbers: () => ["get", ...numbers],
    getMore: () => ({
      ...spreadChain("where", (differentNumbers) => ({
        getDifferentNumbers: () => ({ numbers, differentNumbers }),
        ...spreadChain("who", (people) => ({
          showEverything: () => ({ people, numbers, differentNumbers }),
        })),
      })),
    }),
  })),
});

it("a chain function collects and returns value", () => {
  const response = chainFn()
    .where(1, 2)
    .where(3, 4)
    .where(5, 6)
    .where(7, 8).numbers;

  expect(response).toEqual([
    [1, 2],
    [3, 4],
    [5, 6],
    [7, 8],
  ]);
});

it("a chain function collects and returns value that's edited in the return of a function", () => {
  const response = chainFn()
    .where(1, 2)
    .where(3, 4)
    .where(5, 6)
    .where(7, 8)
    .getNumbers();

  expect(response).toEqual(["get", [1, 2], [3, 4], [5, 6], [7, 8]]);
});

it.only("a chain function that goes all over the shop", () => {
  const response = chainFn()
    .where(11, 43)
    .where(55, 61)
    .getMore()
    .where(5, 5, 4)
    .where(5, 5, 4)
    .who("silad", "issie")
    .who("roblad", "silad", "roblad", "mattlad")
    .who("jakelad")
    .showEverything();

  console.log(response);

  expect(response).toEqual({
    people: [
      ["silad", "issie"],
      ["roblad", "silad", "roblad", "mattlad"],
      ["jakelad"],
    ],
    numbers: [
      [11, 43],
      [55, 61],
    ],
    differentNumbers: [
      [5, 5, 4],
      [5, 5, 4],
    ],
  });
});
```

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