1
2
3
4
5
6
7
8
9
10
11
import { set } from "https://esm.town/v/std/set?v=11";
import { chatMessages } from "https://esm.town/v/nimalu/chatMessages";
export let sendChatMessage = async (message: string, sender: string) => {
chatMessages.unshift({ message, sender });
if (chatMessages.length > 20) {
chatMessages.pop();
}
await set("chatMessages", chatMessages);
return chatMessages.map((a) => a);
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023