Skip to content

Commit 09f5f2c

Browse files
authored
Merge pull request #199 from Warchino/fix/improve-remove-callback-index-validation
Fix index validation when removing callback
2 parents a24f7d7 + 016d58e commit 09f5f2c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/decoder/ReferenceTracker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ export class ReferenceTracker {
149149
}
150150

151151
removeCallback(refId: number, field: string | number, callback: Function) {
152-
const index = this.callbacks?.[refId]?.[field]?.indexOf(callback);
153-
if (index !== -1) {
152+
const index: number | undefined = this.callbacks?.[refId]?.[field]?.indexOf(callback);
153+
if (index !== undefined && index !== -1) {
154154
spliceOne(this.callbacks[refId][field], index);
155155
}
156156
}

0 commit comments

Comments
 (0)