mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
refactor(calls): refactor of call architecture
This commit is contained in:
1 parent
92b687b130
commit
36d1e993bd
21 files changed
+361
-185
No files matched your search
@@ -3,3 +3,18 @@ export const getSource = (): number => (global as any).source;
|
||||
|
||||
// Will clean string of any character that isn't 0-9, or a-z
|
||||
export const clean = (input: string): string => (input ? input.replace(/[^0-9a-z]/gi, '') : input);
|
||||
|
||||
type onNetTypedCB<T> = (data: T) => void;
|
||||
|
||||
// Simple generic wrapper around onNet for type safety
|
||||
export const onNetTyped = <T = any>(eventName: string, cb: onNetTypedCB<T>) => onNet(eventName, cb);
|
||||
|
||||
// Simple generic wrapper around emitNet, except that we switch src and first arg if on server.
|
||||
// source is defined using the third arg
|
||||
export const emitNetTyped = <T = any>(eventName: string, data: T, src?: number) => {
|
||||
if (src) {
|
||||
return emitNet(eventName, src, data);
|
||||
}
|
||||
|
||||
emitNet(eventName, data);
|
||||
};
|
||||
Reference in new issue
Block a user