# event-shadow

> DOM EventListener Proxy

Latest version **1.0.27** (published 2019-07-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install event-shadow
pnpm add event-shadow
yarn add event-shadow
bun add event-shadow
```

## 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.27 |
| Published | 2019-07-15 |
| First published | 2019-04-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 112.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Maintainers | vsiren |

## Links

- npm: https://www.npmjs.com/package/event-shadow
- Repository: https://github.com/freezestanley/EventProxy
- Homepage: https://github.com/freezestanley/EventProxy#readme
- Issues: https://github.com/freezestanley/EventProxy/issues
- npm.io page: https://npm.io/package/event-shadow

## Recent versions

- 1.0.27 (latest) — 2019-07-15
- 1.0.26 — 2019-06-24
- 1.0.25 — 2019-06-20
- 1.0.24 — 2019-06-18
- 1.0.23 — 2019-06-17
- 1.0.22 — 2019-06-17
- 1.0.21 — 2019-06-17
- 1.0.19 — 2019-06-17
- 1.0.18 — 2019-06-17
- 1.0.17 — 2019-05-23
- 1.0.16 — 2019-05-20
- 1.0.15 — 2019-05-20
- 1.0.14 — 2019-05-14
- 1.0.13 — 2019-04-30
- 1.0.12 — 2019-04-30
- … 7 more at https://npm.io/package/event-shadow/versions

## README

# ProxyEvent
## Install
```
npm i event-shadow
```

## use
```
import { ProxyEvent } from 'event-shadow'
const proxyEvent = new ProxyEvent()
proxyEvent.addAfterGuard = function (ev) {
  // do something....
}
```
## Info
```
new ProxyEvent(options)
```
> options
+ beforeGuard | 全局event前守卫  | 每次都会触发
+ afterGuard  | 全局event后守卫  | 每次都会触发
+ node        | 被代理元素 默认 HTMLElement.prototype

> Event
+ onBeforeGuard | 全局event前守卫
+ onAfterGuard | 全局event后守卫

> 被代理的元素 new ProxyEvent({node: [document]})

> Add Methods
+ getEventListenerList(type)  | type 事件类型
+ firstGuard(type, callback)  | type 时间类型  | callback 回调函数事件在所有事件之前执行 只会执行一次
+ addBeforeGuard(callback)  | callback 回调函数事件在所有事件之前执行  | 每次都会触发
+ addAfterGuard(callback)  | callback 回调函数事件在所有事件之前执行  | 每次都会触发

> noShadow
```
new ProxyEvent({node: [document]})
document.addEventListener('click', function (e) { }, {noShadow: true})
document.removeEventListener('click', function (e) { }, {noShadow: true})

```
noShadow 开启影子模式 则firstGuard、 addBeforeGuard、 addAfterGuard、 onBeforeGuard、 onAfterGuard 将不会触发

## taskQuene
```
import { taskQuene } from 'event-shadow'
const list = [function (evt, next) {
  console.log('this is 1')
  console.log(evt)
  console.log(this)
  next()
}, function (evt, next) {
  console.log('this is 2')
  console.log(evt)
  console.log(this)
  next()
}]
const param = {value: '123'}
const obj = {name: 'obj'}
const a = taskQuene(list, param, obj)
a()

// this is 1
// {value: "123"}
// {name: "obj"}
// this is 2
// {value: "123"}
// {name: "obj"}
```
> taskQuene
+ taskQuene | event = [] callback list, param 参数, argthis

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