0.0.1 • Published 6 years ago
create-proxy v0.0.1
create-proxy
a tool to add proxies to object, useful for trapping methods in object
Install
yarn add create-proxy
npm i create-proxy -S
Usage
import createProxy from 'create-proxy'
const target = {
a () {},
b () {},
c: 1
}
const pTarget = createProxy(target, {
a: {
apply (target, thisArg, args) {
target.apply(thisArg, args)
console.log('proxy:a')
}
},
b: {
apply (target, thisArg, args) {
target.apply(thisArg, args)
console.log('proxy:b')
}
}
})
p.a() // proxy:a
p.b() // proxy:b
p.c // 1
Example
- vuex-router-histroy trap router's methods(push、replace、go、back、forward) and create history log
0.0.1
6 years ago