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/?q=function&page=793&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 8406 results for "function"(731ms)

lucia_adapter_basemain.tsx3 matches

@stevekrouse•Updated 8 months ago
127}
128
129function transformIntoDatabaseSession(raw: SessionSchema): DatabaseSession {
130 const { id, user_id: userId, expires_at: expiresAtUnix, ...attributes } = raw;
131 return {
137}
138
139function transformIntoDatabaseUser(raw: UserSchema): DatabaseUser {
140 const { id, ...attributes } = raw;
141 return {
145}
146
147function escapeName(val: string): string {
148 return "`" + val + "`";
149}

pgliteCountermain.tsx1 match

@maxm•Updated 8 months ago
18})();
19
20export default async function(req: Request): Promise<Response> {
21 await init;
22 await pg.query(`

resyBotREADME.md1 match

@stevekrouse•Updated 8 months ago
11import { email } from "https://esm.town/v/std/email?v=13";
12
13export default async function (interval: Interval) {
14 const bookingInfo = await resyBot( {
15 slug: 'amaro-bar',

switchbotmain.tsx2 matches

@stevekrouse•Updated 8 months ago
18const ValTownOfficeDeviceId = "CD6F3A810848";
19
20async function switchbotRequest(path, args) {
21 const token = Deno.env.get("SWITCHBOT_TOKEN");
22 const secret = Deno.env.get("SWITCHBOT_KEY");
42}
43
44function botPress(device) {
45 return switchbotRequest(`v1.1/devices/${device}/commands`, {
46 method: "POST",

switchbotmain.tsx2 matches

@stevekrouse•Updated 8 months ago
18const ValTownOfficeDeviceId = "CD6F3A810848";
19
20async function switchbotRequest(path, args) {
21 const token = Deno.env.get("SWITCHBOT_TOKEN");
22 const secret = Deno.env.get("SWITCHBOT_KEY");
42}
43
44function botPress(device) {
45 return switchbotRequest(`v1.1/devices/${device}/commands`, {
46 method: "POST",

whenfilmedmain.tsx7 matches

@tmcw•Updated 9 months ago
13}
14
15async function fetchRandomMovies() {
16 const currentYear = new Date().getFullYear()
17 const movies = []
35}
36
37function generateQuizHTML(movies, uuid) {
38 const currentYear = new Date().getFullYear()
39 return `
52 </style>
53 <script>
54 function updateInputs(index, value) {
55 document.getElementById('guess' + index).value = value;
56 document.getElementById('guessInput' + index).value = value;
91}
92
93function calculateScore(movies, guesses) {
94 return movies.reduce((score, movie, index) => {
95 const actualYear = new Date(movie.release_date).getFullYear()
102}
103
104function generateResultsHTML(movies, guesses, score) {
105 return `
106 <html>
152}
153
154function generateAllGuessesHTML(allGuesses) {
155 return `
156 <html>
198}
199
200export default async function main(req: Request): Promise<Response> {
201 const { author, name } = extractValInfo(import.meta.url)
202 const guessesKey = `${author}.${name}.guesses`

hardwarebingomain.tsx1 match

@stevekrouse•Updated 9 months ago
97if (typeof document !== "undefined") { createRoot(document.getElementById("root")).render(<App />); }
98
99export default async function(req: Request): Promise<Response> {
100 return new Response(
101 renderToString(

emailmain.tsx1 match

@std•Updated 9 months ago
12 * The email address(es) to send the email to. Only available to Val Town Pro subscribers.
13 * Can be a single string, IAddress object, or an array of strings/IAddress objects.
14 * @default the email of the logged user calling this function.
15 */
16 to?: (IAddress | string)[] | IAddress | string;

azureCheetahmain.tsx14 matches

@tmcw•Updated 9 months ago
16import { renderToString } from "npm:react-dom/server";
17
18export default function(
19 { tempValsParentFolderId }: { tempValsParentFolderId: string },
20) {
38 the simplest way to achieve the goal, though you can add some inline comments to explain your
39 reasoning (not for every line, but for major groups of lines). Don't use any environment variables
40 unless strictly necessary, for example use APIs that don't require a key, prefer internal function
41 imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
42 functions where possible. Unless specified, don't add error handling,
43 make sure that errors bubble up to the caller.
44 Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
51 \`\`\`
52 There should be no comments like "more content here", it should be complete and directly runnable.
53 The val should create a "export default async function main" which is the main function that gets
54 executed on every HTTP request.
55 `.replace("\n", " ");
56
57 // Your response should start with \`\`\`ts and end with \`\`\`.
58 // The val should create a "export default async function main() {" which
59 // is the main function that gets executed, without any arguments. Don't return a Response object,
60 // just return a plain Javascript object, array, or string.
61
98 const writer = writable.getWriter();
99 const textEncoder = new TextEncoder();
100 function write(text) {
101 writer.write(textEncoder.encode(text));
102 }
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 }
281 (() => {
282 const scrollingElement = document.getElementById("conversation-container");
283 const callback = function (mutationsList, observer) {
284 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
285 };
390 window.setCodeMirrorContent({ doc: '', old: ''});
391 let fullStr = "";
392 window.addToken = function(str) {
393 fullStr += str;
394 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "").replace(/^ts\\n/, '');
429 },
430 );
431 (async function() {
432 try {
433 await sleep(300);

VALLErunmain.tsx14 matches

@tmcw•Updated 9 months ago
16import { renderToString } from "npm:react-dom/server";
17
18export default function(
19 { tempValsParentFolderId }: { tempValsParentFolderId: string },
20) {
38 the simplest way to achieve the goal, though you can add some inline comments to explain your
39 reasoning (not for every line, but for major groups of lines). Don't use any environment variables
40 unless strictly necessary, for example use APIs that don't require a key, prefer internal function
41 imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
42 functions where possible. Unless specified, don't add error handling,
43 make sure that errors bubble up to the caller.
44 Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
51 \`\`\`
52 There should be no comments like "more content here", it should be complete and directly runnable.
53 The val should create a "export default async function main" which is the main function that gets
54 executed on every HTTP request.
55 `.replace("\n", " ");
56
57 // Your response should start with \`\`\`ts and end with \`\`\`.
58 // The val should create a "export default async function main() {" which
59 // is the main function that gets executed, without any arguments. Don't return a Response object,
60 // just return a plain Javascript object, array, or string.
61
98 const writer = writable.getWriter();
99 const textEncoder = new TextEncoder();
100 function write(text) {
101 writer.write(textEncoder.encode(text));
102 }
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 }
281 (() => {
282 const scrollingElement = document.getElementById("conversation-container");
283 const callback = function (mutationsList, observer) {
284 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
285 };
390 window.setCodeMirrorContent({ doc: '', old: ''});
391 let fullStr = "";
392 window.addToken = function(str) {
393 fullStr += str;
394 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "").replace(/^ts\\n/, '');
429 },
430 );
431 (async function() {
432 try {
433 await sleep(300);

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago