wrap-hook

0.0.4 • Public • Published

wrap-hook

Install

npm i -S wrap-hook

How to use

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!
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!

Readme

Keywords

Package Sidebar

Install

npm i wrap-hook

Weekly Downloads

2

Version

0.0.4

License

MIT

Unpacked Size

10.4 kB

Total Files

7

Last publish

Collaborators

  • huangzhenjie