(state, force = false)
| 977 | function commandEventKey(sessionID, messageID) { |
| 978 | return `${sessionID || "no-session"}:event:${messageID || "no-message"}`; |
| 979 | } |
| 980 | function markHandled(sessionID, name, args) { |
| 981 | const key = commandKey(sessionID, name, args); |
| 982 | const previous = handledCommands.get(key); |
| 983 | const pending = previous && now() - previous.time < COMMAND_DEDUPE_MS ? previous.pending + 1 : 1; |
| 984 | handledCommands.set(key, { time: now(), pending }); |
| 985 | for (const [entryKey, entry] of handledCommands.entries()) |
| 986 | if (now() - entry.time > COMMAND_DEDUPE_MS) |
| 987 | handledCommands.delete(entryKey); |
| 988 | for (const [entryKey, time] of handledCommandEvents.entries()) |
| 989 | if (now() - time > COMMAND_DEDUPE_MS) |
| 990 | handledCommandEvents.delete(entryKey); |
| 991 | } |
| 992 | function consumeHandled(sessionID, name, args) { |
| 993 | const key = commandKey(sessionID, name, args); |
no test coverage detected