update readme

This commit is contained in:
Rowan 2025-05-25 12:58:19 -05:00
parent ed6f17bcb2
commit 6bb7e2ffe5

View file

@ -24,12 +24,12 @@ class Recipient {
registerDeserialize(Recipient, Recipient.deserialize) registerDeserialize(Recipient, Recipient.deserialize)
} }
private readonly email: string
readonly displayName: string readonly displayName: string
private readonly email: string
constructor(email: string, displayName: string) { constructor(displayName: string, email: string,) {
this.email = email
this.displayName = displayName this.displayName = displayName
this.email = email
} }
static serialize<T>(serializer: ISerializer<T>, recipient: Recipient) { static serialize<T>(serializer: ISerializer<T>, recipient: Recipient) {
@ -109,23 +109,22 @@ const message = new Message(bob, [alice, alicesMom], 'i hope this email finds yo
const messageSerial = toString(message) const messageSerial = toString(message)
console.log(messageSerial) console.log(messageSerial)
// {"from":"bob@security.lol<Bob>","to":["alice@balloon.party<Alice>","alice.mom@malware.zip<Alice's Mom>"],"text":"i hope this email finds you before i do"} // {"from":"Bob<bob@security.lol>","to":["Alice<alice@balloon.party>","Alice's Mom<alice.mom@malware.zip>"],"text":"i hope this email finds you before i do"}
const messageDecereal = fromString(messageSerial, Message) const messageDecereal = fromString(messageSerial, Message)
console.log(messageDecereal) console.log(messageDecereal)
/* /*
Message { Message {
from: Recipient { email: 'bob@security.lol', displayName: 'Bob' }, from: Recipient { displayName: 'Bob', email: 'bob@security.lol' },
to: [ to: [
Recipient { email: 'alice@balloon.party', displayName: 'Alice' }, Recipient { displayName: 'Alice', email: 'alice@balloon.party' },
Recipient { Recipient {
email: 'alice.mom@malware.zip', displayName: "Alice's Mom",
displayName: "Alice's Mom" email: 'alice.mom@malware.zip'
} }
], ],
text: 'i hope this email finds you before i do' text: 'i hope this email finds you before i do'
} }
*/ */
``` ```