object-action-recorder
v1.0.0
Published
Object action recorder by Proxy.
Downloads
4
Readme
object-action-recorder
Object action recorder by Proxy.
install
yarn add object-action-recorder
usage
import ObjectActionRecorder from "object-action-recorder";
// <script src="./node_modules/object-action-recorder/object-action-recorder.min.js"></script>
const recorder = new ObjectActionRecorder<CanvasRenderingContext2D>()
let ctx = document.createElement('canvas').getContext('2d')
ctx = new Proxy(ctx, recorder)
ctx.fillStyle = 'green'
ctx.fillRect(10, 10, 150, 100)
console.info(recorder.actions)
/*
(2) [{…}, {…}]
0:
name: "fillStyle"
target: CanvasRenderingContext2D {canvas: canvas, globalAlpha: 1, globalCompositeOperation: "source-over", filter: "none", imageSmoothingEnabled: true, …}
type: "set"
value: "green"
__proto__: Object
1:
args: (4) [10, 10, 150, 100]
name: "fillRect"
target: CanvasRenderingContext2D {canvas: canvas, globalAlpha: 1, globalCompositeOperation: "source-over", filter: "none", imageSmoothingEnabled: true, …}
type: "method"
__proto__: Object
*/