Skip to content

Commit eab823b

Browse files
committed
fix Map deserialisation and sync handler
1 parent e824272 commit eab823b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/init-child.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export default function initChild(this: IPOS) {
55
const promise = new Promise(res => resolve = res)
66

77
this.messaging?.listenForType('sync', message => {
8-
if (!message.fields) return
9-
Object.entries(message.fields)
8+
if (!message.fields || !(message.fields instanceof Map)) return
9+
Array.from(message.fields.entries())
1010
.map(([key, value]: [string, any]) => {
1111
this.createStealthy(key, value)
1212
})
@@ -17,7 +17,7 @@ export default function initChild(this: IPOS) {
1717
this.messaging?.send('register')
1818

1919
if (this.messaging)
20-
this.mountListeners(this.messaging)
20+
this.mountListeners(this.messaging)
2121

2222
return promise
2323
}

src/messaging.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ export type iposMessagingMessage = {
77
protocol: 'ipos',
88
type: iposMessagingType,
99

10-
fields?: string,
10+
fields?: string | Map<string, any>, // serialised, de-serialised
1111

1212
do?: string,
1313
on?: string,
14-
with?: Array<any>,
14+
with?: Array<string> | Array<any>,
1515

1616
key?: string,
17-
value: any,
17+
value: string | any,
1818
} & { [k: string]: string }
1919

2020
const mustHaveSendError = new Error(`Process must have a \`.send()\` method.`)

src/serialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function serialize(value: any): any | void {
1717
} else if (value instanceof Map) {
1818
return {
1919
$$iposType: 'Map',
20-
data: Object.fromEntries(
20+
data: new Map(
2121
Array.from(value.entries())
2222
.map(([key, value]) => [key, serialize(value)])
2323
)

0 commit comments

Comments
 (0)