js-draw
Version:
Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript.
16 lines (15 loc) • 358 B
JavaScript
import InputMapper from './InputMapper.mjs';
/**
* An `InputMapper` that applies a function to all events it receives.
*
* Useful for automated testing.
*/
export default class FunctionMapper extends InputMapper {
constructor(fn) {
super();
this.fn = fn;
}
onEvent(event) {
return this.emit(this.fn(event));
}
}