Created
July 1, 2020 20:21
-
-
Save guillaumewuip/28da4ef66f174cf0c79d142c5317b82f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function addSignature(signature: string) { | |
return (text: Text) => { | |
const $text = MessageUnion.Text.iso.unwrap(text); // get private type | |
const $newText = { | |
…$text, | |
text: `${$message.text} - ${signature}`, | |
}; | |
return MessageUnion.Text.iso.wrap($newText); // get opaque type | |
}; | |
} | |
// Iso even offers shortcuts, the same result can be achieved like so: | |
export const addSignature = (signature: string) => MessageUnion.Text.iso.modify( | |
($text) => ({ ...$text, text: `${$text.text} - ${signature}` }) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment