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=1601&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 19423 results for "function"(2943ms)

31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
83 const writer = writable.getWriter();
84 const textEncoder = new TextEncoder();
85 function write(text) {
86 writer.write(textEncoder.encode(text));
87 }
132 (() => {
133 const scrollingElement = document.getElementById("conversation-container");
134 const callback = function (mutationsList, observer) {
135 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
136 };
174 </div>
175 <script>
176 function updateValName(valName) {
177 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
178 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
182 document.getElementById('open-link').href = previewUrl;
183 }
184 function saveVal() {
185 if (window.codeMirrorEditor) {
186 document.getElementById("save-icon").classList.remove("hidden");
202 return false;
203 })
204 function openTab(tab) {
205 const tabButtonCode = document.getElementById("tab-button-code");
206 const tabButtonPreview = document.getElementById("tab-button-preview");
222 }
223 }
224 function toggleTab() {
225 openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
226 }
343 window.setCodeMirrorContent({ doc: '', old: ''});
344 let fullStr = "";
345 window.addToken = function(str) {
346 fullStr += str;
347 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
83 const writer = writable.getWriter();
84 const textEncoder = new TextEncoder();
85 function write(text) {
86 writer.write(textEncoder.encode(text));
87 }
134 (() => {
135 const scrollingElement = document.getElementById("conversation-container");
136 const callback = function (mutationsList, observer) {
137 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
138 };
207 window.setCodeMirrorContent({ doc: '', old: ''});
208 let fullStr = "";
209 window.addToken = function(str) {
210 fullStr += str;
211 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
83 const writer = writable.getWriter();
84 const textEncoder = new TextEncoder();
85 function write(text) {
86 writer.write(textEncoder.encode(text));
87 }
132 (() => {
133 const scrollingElement = document.getElementById("conversation-container");
134 const callback = function (mutationsList, observer) {
135 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
136 };
227 window.setCodeMirrorContent({ doc: '', old: ''});
228 let fullStr = "";
229 window.addToken = function(str) {
230 fullStr += str;
231 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
77 const writer = writable.getWriter();
78 const textEncoder = new TextEncoder();
79 function write(text) {
80 writer.write(textEncoder.encode(text));
81 }
140 </div>
141 <script>
142 function updateValName(valName) {
143 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
144 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
148 document.getElementById('open-link').href = previewUrl;
149 }
150 function saveVal() {
151 if (window.codeMirrorEditor) {
152 document.getElementById("save-icon").classList.remove("hidden");
168 return false;
169 })
170 function openTab(tab) {
171 const tabButtonCode = document.getElementById("tab-button-code");
172 const tabButtonPreview = document.getElementById("tab-button-preview");
188 }
189 }
190 function toggleTab() {
191 openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
192 }
246 (() => {
247 const scrollingElement = document.getElementById("conversation-container");
248 const callback = function (mutationsList, observer) {
249 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
250 };
319 window.setCodeMirrorContent({ doc: '', old: ''});
320 let fullStr = "";
321 window.addToken = function(str) {
322 fullStr += str;
323 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
82 const writer = writable.getWriter();
83 const textEncoder = new TextEncoder();
84 function write(text) {
85 writer.write(textEncoder.encode(text));
86 }
131 (() => {
132 const scrollingElement = document.getElementById("conversation-container");
133 const callback = function (mutationsList, observer) {
134 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
135 };
161 </div>
162 <script>
163 function updateValName(valName) {
164 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
165 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
169 document.getElementById('open-link').href = previewUrl;
170 }
171 function saveVal() {
172 if (window.codeMirrorEditor) {
173 document.getElementById("save-icon").classList.remove("hidden");
189 return false;
190 });
191 function openTab(tab) {
192 const tabButtonCode = document.getElementById("tab-button-code");
193 const tabButtonPreview = document.getElementById("tab-button-preview");
209 }
210 }
211 function toggleTab() {
212 openTab(document.getElementById("tab-panel-code").classList.contains("hidden") ? "code" : "preview");
213 }
330 window.setCodeMirrorContent({ doc: '', old: ''});
331 let fullStr = "";
332 window.addToken = function(str) {
333 fullStr += str;
334 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main() {" which
39is the main function that gets executed, without any arguments. Don't return a Response object,
40just return a plain Javascript object, array, or string.
41`.replace("\n", " ");
42
43// Your response should start with \`\`\`ts and end with \`\`\`.
44// The val should create a "export default async function main() {" which
45// is the main function that gets executed, without any arguments. Don't return a Response object,
46// just return a plain Javascript object, array, or string.
47
84 const writer = writable.getWriter();
85 const textEncoder = new TextEncoder();
86 function write(text) {
87 writer.write(textEncoder.encode(text));
88 }
152 </div>
153 <script>
154 function updateValName(valName) {
155 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
156 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
160 document.getElementById('open-link').href = previewUrl;
161 }
162 function saveVal() {
163 if (window.codeMirrorEditor) {
164 document.getElementById("save-icon").classList.remove("hidden");
180 return false;
181 })
182 function openTab(tab) {
183 const tabButtonCode = document.getElementById("tab-button-code");
184 const tabButtonPreview = document.getElementById("tab-button-preview");
200 }
201 }
202 function toggleTab() {
203 openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
204 }
258 (() => {
259 const scrollingElement = document.getElementById("conversation-container");
260 const callback = function (mutationsList, observer) {
261 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
262 };
331 window.setCodeMirrorContent({ doc: '', old: ''});
332 let fullStr = "";
333 window.addToken = function(str) {
334 fullStr += str;
335 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
83 const writer = writable.getWriter();
84 const textEncoder = new TextEncoder();
85 function write(text) {
86 writer.write(textEncoder.encode(text));
87 }
150 </div>
151 <script>
152 function updateValName(valName) {
153 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
154 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
158 document.getElementById('open-link').href = previewUrl;
159 }
160 function saveVal() {
161 if (window.codeMirrorEditor) {
162 document.getElementById("save-icon").classList.remove("hidden");
178 return false;
179 })
180 function openTab(tab) {
181 const tabButtonCode = document.getElementById("tab-button-code");
182 const tabButtonPreview = document.getElementById("tab-button-preview");
198 }
199 }
200 function toggleTab() {
201 openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
202 }
256 (() => {
257 const scrollingElement = document.getElementById("conversation-container");
258 const callback = function (mutationsList, observer) {
259 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
260 };
329 window.setCodeMirrorContent({ doc: '', old: ''});
330 let fullStr = "";
331 window.addToken = function(str) {
332 fullStr += str;
333 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
2// This val will respond with a HTML page styled with fun CSS
3
4export default async function main(): Promise<Response> {
5 const htmlContent = `
6 <!DOCTYPE html>
1// This val will respond with a HTML page styled with fun CSS
2
3export default async function main(): Promise<Response> {
4 const htmlContent = `
5 <!DOCTYPE html>
1// This val will respond with a fun HTML page with crazy fonts and gradients
2
3export default async function main(): Promise<Response> {
4 const htmlContent = `
5 <!DOCTYPE html>

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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.