# wrap-hook

> wrap 'before' and 'after' funcitons.'before' can stop original function from executing.

Latest version **0.0.4** (published 2019-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install wrap-hook
pnpm add wrap-hook
yarn add wrap-hook
bun add wrap-hook
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2019-06-24 |
| First published | 2019-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | JaysonHwang |
| Maintainers | huangzhenjie |
| Keywords | wrap, hook, callback |

## Links

- npm: https://www.npmjs.com/package/wrap-hook
- Repository: https://github.com/JaysonHwang/wrap-hook
- Issues: https://github.com/JaysonHwang/wrap-hook/issues
- npm.io page: https://npm.io/package/wrap-hook

## Dependencies (2)

- [chai](https://npm.io/package/chai.md) ^3.5.0
- [npm-run-all](https://npm.io/package/npm-run-all.md) ^2.1.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2019-06-24
- 0.0.3 — 2019-06-18
- 0.0.2 — 2019-06-18

## README

# wrap-hook

## Install

`npm i -S wrap-hook`


## How to use

```js
import wraphook from 'wrap-hook'

const TRUSY_BEFORE = () => true;
const AFTER_CALL = ()=>{ console.log('after is called!')}

const wrapped = wraphook({ before: TRUSY_BEFORE, after: AFTER_CALL });
wrapped((callback) => {
  console.log('write business code here.')
  callback();
});
// write business code here.
// after is called!
```

```js
import wraphook from 'wrap-hook'

const FALSY_BEFORE = () => false;
const AFTER_CALL = ()=>{ console.log('after is called!')}

const wrapped = wraphook({ before: FALSY_BEFORE, after: AFTER_CALL });
wrapped((callback) => {
  console.log('write business code here.')
  callback();
});
// no log!
```

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