# babel-plugin-drop-hof

> Transforms higher-order function calls such as `map`, `filter`, and `reduce` to loops.

Latest version **1.0.1** (published 2017-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-drop-hof
pnpm add babel-plugin-drop-hof
yarn add babel-plugin-drop-hof
bun add babel-plugin-drop-hof
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-09-29 |
| First published | 2017-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Simon Zhang |
| Maintainers | yehzhang |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-drop-hof
- Repository: https://github.com/yehzhang/babel-plugin-drop-hof
- Homepage: https://github.com/yehzhang/babel-plugin-drop-hof#readme
- Issues: https://github.com/yehzhang/babel-plugin-drop-hof/issues
- npm.io page: https://npm.io/package/babel-plugin-drop-hof

## Dependencies (3)

- [babel-core](https://npm.io/package/babel-core.md) ^6.26.0
- [babel-types](https://npm.io/package/babel-types.md) ^6.26.0
- [babel-template](https://npm.io/package/babel-template.md) ^6.26.0

## Recent versions

- 1.0.1 (latest) — 2017-09-29
- 1.0.0 — 2017-09-29

## README

# babel-plugin-drop-hof
> Transforms higher-order function calls to loops.

Currently supported higher-order functions are: `forEach`, `map`, `filter`, `every`, `some`, and `reduce`.

## Example
**In**
```javascript
var result = array.map(function (x) {
  return x * 2;
});
```

**Out**
```javascript
var _a = array;
var _i = 0;

var _f = function _f(x) {
  return x * 2;
};

var _r = [];

for (; _i < _a.length; _i++) {
  var _e = _a[_i];

  var _z;

  _z = _f(_e, _i, _a);

  _r.push(_z);
}

var result = _r;
```

Some corner cases are handled properly:

**In**
```javascript
isValid() && array.map(function (x) {
  return x * 2;
});

while (array.map(function (x) {
  return x * 2;
}));
```

**Out**
```javascript
// **Same as input**
```

## Installation
```sh
npm install --save babel-plugin-drop-hof
```

## Usage
### Via `.babelrc`

**.babelrc**

```json
{
  "plugins": ["babel-plugin-drop-hof"]
}
```

### Via CLI

```sh
babel --plugins babel-plugin-drop-hof script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
  plugins: ["babel-plugin-drop-hof"]
});
```

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