-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CloseEvent } from "./close.js" | ||
import { ErrorEvent } from "./error.js" | ||
|
||
export namespace Events { | ||
|
||
export function clone(event: Event) { | ||
if (event instanceof MessageEvent) { | ||
const { data, cancelable } = event | ||
return new MessageEvent(event.type, { data, cancelable }) | ||
} | ||
|
||
if (event instanceof CloseEvent) { | ||
const { code, reason, wasClean, cancelable } = event | ||
return new CloseEvent(event.type, { code, reason, wasClean, cancelable }) | ||
} | ||
|
||
if (event instanceof ErrorEvent) { | ||
const { error, message, cancelable } = event | ||
return new ErrorEvent(event.type, { error, message, cancelable }) | ||
} | ||
|
||
const { cancelable } = event | ||
return new Event(event.type, { cancelable }) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters