https://github.com/kaelzhang/tapable-proxy
The pseudo tapable based on Proxy
https://github.com/kaelzhang/tapable-proxy
fake hooks proxy tapable
Last synced: 2 months ago
JSON representation
The pseudo tapable based on Proxy
- Host: GitHub
- URL: https://github.com/kaelzhang/tapable-proxy
- Owner: kaelzhang
- License: other
- Created: 2019-05-21T13:58:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T13:17:59.000Z (almost 6 years ago)
- Last Synced: 2025-03-25T13:16:19.377Z (3 months ago)
- Topics: fake, hooks, proxy, tapable
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/kaelzhang/tapable-proxy)
[](https://codecov.io/gh/kaelzhang/tapable-proxy)# tapable-proxy
The pseudo tapable based on [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). `tapable-proxy` could create fake hooks which can be tapped even before the creation of real hooks.
## Install
```sh
$ npm i tapable-proxy
```## Usage
```js
const {
create,
APPLY_TAPS,
SET_HOOKS
} = require('tapable-proxy')// Create a fake hook proxy
const hooks = create()hooks.afterEmit.tap('MyPlugin', compilation => {
// ...
})// Apply all taps to webpack compiler hooks
hooks[APPLY_TAPS](compiler.hooks)// Proxy the follow-up taps to compiler hooks
hooks[SET_HOOKS](compiler.hooks)
```### hooks\[APPLY_TAPS](realHooks, clean)
- **realHooks** `{[string]: Tapable}` the real [tapable](https://www.npmjs.com/package/tapable) hooks
- **clean?** `boolean=true` If `true`, the tapped handlers will be maintained after applied. Defaults to `true`### hooks\[SET_HOOKS](realHooks)
Set the underlying hooks of the proxy as `realHooks`, and after that follop-up taps will directly tap into `realHooks`.
## License
[MIT](LICENSE)