Skip to content

Commit

Permalink
fix: JSON.stringify a JS Map always return {} (#201)
Browse files Browse the repository at this point in the history
* fix: JSON.stringify a JS Map always return `{}`

* fix: correct type

* fix: change remain `Map` to `Record`
  • Loading branch information
avxit authored May 18, 2021
1 parent a7d06d2 commit 3ead90f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/ion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum PeerState {
export interface Peer {
uid: string;
sid: string;
info: Map<string, any>;
info: Record<string, any>;
}

export interface PeerEvent {
Expand Down Expand Up @@ -55,7 +55,7 @@ export interface Stream {
export interface Message {
from: string;
to: string;
data: Map<string, any>;
data: Record<string, any>;
}

export class IonConnector {
Expand Down Expand Up @@ -135,7 +135,7 @@ export class IonConnector {
return this._sfu;
}

async join(sid: string, uid: string, info: Map<string, any>, token: string | undefined): Promise<JoinResult> {
async join(sid: string, uid: string, info: Record<string, any>, token: string | undefined): Promise<JoinResult> {
this._sid = sid;
this._uid = uid;
return this._biz.join(sid, uid, info, token);
Expand All @@ -145,7 +145,7 @@ export class IonConnector {
return this._biz.leave(uid);
}

async message(from: string, to: string, data: Map<string, any>): Promise<void> {
async message(from: string, to: string, data: Record<string, any>): Promise<void> {
return this._biz.sendMessage(from, to, data);
}

Expand Down
4 changes: 2 additions & 2 deletions src/signal/biz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class BizClient extends EventEmitter {
});
}

async join(sid: string, uid: string, info: Map<string, any>, token: string | undefined): Promise<JoinResult> {
async join(sid: string, uid: string, info: Record<string, any>, token: string | undefined): Promise<JoinResult> {
const request = new biz.SignalRequest();
const join = new biz.Join();
join.setToken(token || '');
Expand Down Expand Up @@ -141,7 +141,7 @@ export class BizClient extends EventEmitter {
});
}

async sendMessage(from: string, to: string, data: Map<string, any>) {
async sendMessage(from: string, to: string, data: Record<string, any>) {
const request = new biz.SignalRequest();
const message = new ion.Message();
message.setFrom(from);
Expand Down

0 comments on commit 3ead90f

Please sign in to comment.