# @mappable/map

> Map anything and everything in the same way. A `map` function built for the [Pipeline Operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator).

Latest version **0.0.2** (published 2018-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mappable/map
pnpm add @mappable/map
yarn add @mappable/map
bun add @mappable/map
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2018-07-05 |
| First published | 2018-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 157.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Pete Gleeson |
| Maintainers | petegleeson |

## Links

- npm: https://www.npmjs.com/package/@mappable/map
- npm.io page: https://npm.io/package/@mappable/map

## Recent versions

- 0.0.2 (latest) — 2018-07-05
- 0.0.1 — 2018-07-05

## README

# mappable

Map anything and everything in the same way. A `map` function built for the [Pipeline Operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator).

**Experimental: use this at your own risk ☢️**

## Installation

```
yarn add @mappable/map
```

## Usage

Here are examples of mapping Javascript language types.

```js
import map from '@mappable/map';

// mapping an array
[1, 2, 3] |> map(i => i + 1) |> map(i => i * 2);

// mapping a Promise
Promise.resolve(1) |> map(i => i + 1);

// mapping an object
{ value: 1 } |> map(i => i + 1);

// mapping a function
(x => x + 2) |> map(i => i + 1);
```

Here is an example of how you can map your own types.

```js
import map from "@mappable/map";

// your own type
const tree = {
  value: 1,
  children: [{ value: 2, children: [] }, { value: 3, children: [] }]
};

// describe how to map your type
const treeMapper = fn => tree => {
  const { value, children } = tree;
  return {
    value: fn(value),
    children: children |> map(treeMapper(fn))
  };
};

// new tree with all values incremented
tree |> map(i => i + 1, treeFunctor);
```

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