rx-hotkeys 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ export function createMockFn() {
2
+ const fn = (...args) => {
3
+ fn.calledCount++;
4
+ fn.calls.push(args);
5
+ fn.lastArgs = args;
6
+ };
7
+ fn.calledCount = 0;
8
+ fn.calls = [];
9
+ fn.lastArgs = [];
10
+ fn.mockClear = () => {
11
+ fn.calledCount = 0;
12
+ fn.calls = [];
13
+ fn.lastArgs = [];
14
+ };
15
+ return fn;
16
+ }
17
+ /**
18
+ * Dispatches a KeyboardEvent to the document (JSDOM).
19
+ * @param key - The key value, e.g., "a", "Escape", "ArrowUp"
20
+ * @param modifiers - Optional modifier keys
21
+ */
22
+ export function dispatchKeyEvent(key, modifiers = {}) {
23
+ const event = new KeyboardEvent("keydown", {
24
+ key,
25
+ bubbles: true,
26
+ cancelable: true,
27
+ ...modifiers,
28
+ });
29
+ document.dispatchEvent(event);
30
+ return event;
31
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "rx-hotkeys",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "tsc",
7
+ "prepublishOnly": "npm run build",
8
+ "pretest": "npm run build",
9
+ "test": "node --test './dist/**/*.test.js'"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "default": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "keywords": ["rxjs", "hotkeys", "hotkey", "key"],
18
+ "author": "Colin Cheng <zbinlin@outlook.com>",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/zbinlin/rx-hotkeys.git"
22
+ },
23
+ "files": [
24
+ "./dist/",
25
+ "README.md"
26
+ ],
27
+ "license": "MIT",
28
+ "description": "Advanced Keyboard Shortcut Management library using rxjs",
29
+ "packageManager": "npm@10.9.1+sha512.c89530d37c4baa38afd43e76a077a84b9aa63840b986426584fd5c5a54ab0a0b21bb1595c851042b733784b0b43706d36a494b4d8ae1a086a762cb8d3f95942a",
30
+ "devDependencies": {
31
+ "@types/jsdom": "^21.1.7",
32
+ "@types/node": "^22.15.19",
33
+ "jsdom": "^26.1.0",
34
+ "typescript": "^5.8.3"
35
+ },
36
+ "dependencies": {
37
+ "rxjs": "^7.8.2"
38
+ }
39
+ }