Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Bart_info.art.src%7D?q=function&page=2487&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 28085 results for "function"(2610ms)

VALLEmain.tsx8 matches

@pomdtr•Updated 10 months ago
27the simplest way to achieve the goal, though you can add some inline comments to explain your
28reasoning (not for every line, but for major groups of lines). Don't use any environment variables
29unless strictly necessary, for example use APIs that don't require a key, prefer internal function
30imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
31functions where possible. Unless specified, don't add error handling,
32make sure that errors bubble up to the caller.
33There should be no comments like "more content here", it should be complete and directly runnable.
35
36// Your response should start with \`\`\`ts and end with \`\`\`.
37// The val should create a "export default async function main() {" which
38// is the main function that gets executed, without any arguments. Don't return a Response object,
39// just return a plain Javascript object, array, or string.
40
68 const writer = writable.getWriter();
69 const textEncoder = new TextEncoder();
70 function write(text) {
71 writer.write(textEncoder.encode(text));
72 }
115 </div>
116 <script>
117 function openTab(tab) {
118 const tabButtonCode = document.getElementById("tab-button-code");
119 const tabButtonPreview = document.getElementById("tab-button-preview");
139 (() => {
140 const scrollingElement = document.getElementById("conversation-container");
141 const callback = function (mutationsList, observer) {
142 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
143 };
213 document.getElementById("code-textarea").value = "";
214 let fullStr = "";
215 window.addToken = function(str) {
216 fullStr += str;
217 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
5// The CSS will add the weird and fun styling parts.
6
7export default async function wordleGame() {
8 const html = `
9 <!DOCTYPE html>
4 */
5
6export default async function(wordleGame(req: Request): Promise<Response> {
7 const html = `
8<!DOCTYPE html>
72 const input = document.getElementById('guess-input');
73
74 function createBoard() {
75 for (let i = 0; i < 30; i++) {
76 const cell = document.createElement('div');
80 }
81
82 function makeGuess() {
83 const guess = input.value.toLowerCase();
84 if (guess.length !== 5) return alert("Guess should be 5 letters!");
53`;
54
55export default async function(req: Request): Promise<Response> {
56 const html = `<html>
57 <head>
117 let currentRow = 0;
118
119 function inputKey(key) {
120 if (currentGuess.length < 5) {
121 currentGuess += key;
124 }
125
126 function deleteKey() {
127 currentGuess = currentGuess.slice(0, -1);
128 updateBoard();
129 }
130
131 function submitGuess() {
132 if (currentGuess.length === 5) {
133 const rowTiles = [...document.querySelectorAll('.row')][currentRow].children;
151 }
152
153 function updateBoard() {
154 const rowTiles = [...document.querySelectorAll('.row')][currentRow].children;
155 for (let i = 0; i < 5; i++) {
104 });
105
106 function handleKeyPress(letter) {
107 if (currentCol < 5) {
108 const cell = gridElement.children[currentRow * 5 + currentCol];
112 }
113
114 function handleSubmit() {
115 if (currentCol === 5) {
116 const guess = [];
134 }
135
136 function handleBackspace() {
137 if (currentCol > 0) {
138 currentCol--;
1export default async function(req: Request): Promise<Response> {
2 const html = `
3 <!DOCTYPE html>
57 let attempts = 0;
58
59 function submitWord() {
60 const input = document.getElementById('word-input').value.toUpperCase();
61 if (input.length !== 5) {
7 */
8
9export default async function(req: Request): Promise<Response> {
10 const htmlContent = `
11<!DOCTYPE html>
85 document.addEventListener('keydown', handleKeydown);
86
87 function handleKeydown(event) {
88 const key = event.key.toUpperCase();
89 if (key >= 'A' && key <= 'Z' && currentCol < 5) {
98 }
99
100 function checkGuess() {
101 const guess = [];
102 for (let i = 0; i < 5; i++) {
125 }
126
127 function markCell(i, color) {
128 document.getElementById(\`cell-\${currentRow}-\${i}\`).classList.add(color);
129 }
130
131 function showMessage(message, color) {
132 const messageElem = document.getElementById("message");
133 messageElem.innerText = message;
136 }
137
138 function restartGame() {
139 window.location.reload();
140 }
1// This val will respond with a fun "Hello World" HTML page with crazy CSS styling
2
3export default async function(req: Request): Promise<Response> {
4 // CSS styles for the HTML page
5 const cssStyles = `
1// This val will respond with a colorful "Hello World" HTML page with fun CSS
2
3export default async function(req: Request): Promise<Response> {
4 // CSS styles for the Hello World message
5 const cssStyles = `

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.