Add more valid

This commit is contained in:
Harvey committed 2021-12-10 11:05:44 +08:00
1 parent 5f45ad112f
commit d919471838
7 files changed
+31 -11

No files matched your search

+4
View File
@@ -1,3 +1,5 @@
import { errorHandle } from './utils';
export default class Hotkey {
constructor(art) {
this.keys = {};
@@ -55,6 +57,8 @@ export default class Hotkey {
}
add(key, event) {
errorHandle(typeof key === 'number', 'The Hotkey.add() first parameter is not a number');
errorHandle(typeof event === 'function', 'The Hotkey.add() second parameter is not a function');
if (this.keys[key]) {
this.keys[key].push(event);
} else {