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=782&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 8230 results for "function"(509ms)

tealBadgermain.tsx1 match

@stevekrouse•Updated 10 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2export default async function(req: Request): Promise<Response> {
3 const openai = new OpenAI();
4 const stream = await openai.chat.completions.create({

openAIStreamingExamplemain.tsx1 match

@stevekrouse•Updated 10 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 const openai = new OpenAI();
5 const stream = await openai.chat.completions.create({

robPikeIOmain.tsx1 match

@stevekrouse•Updated 10 months ago
1export default async function(req: Request): Promise<Response> {
2 return new Response(
3 new ReadableStream({

purpleGrousemain.tsx1 match

@stevekrouse•Updated 10 months ago
1export default async function(req: Request): Promise<Response> {
2 const { readable, writable } = new TransformStream();
3 const writer = writable.getWriter();

multiplayerCirclesmain.tsx6 matches

@maxm•Updated 10 months ago
37// });
38
39function parseResultSet<T>(row: ResultSet): T[] {
40 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
41}
51};
52
53function diffCircles(array1: Circle[], array2: Circle[]): Circle[] {
54 const changes: Circle[] = [];
55
74
75 const drag = (() => {
76 function dragstarted() {
77 d3.select(this).attr("stroke", "black");
78 }
79
80 function dragged(event, d) {
81 d3.select(this).raise().attr("cx", d.x = event.x).attr("cy", d.y = event.y);
82 }
83
84 function dragended() {
85 const x = d3.select(this).attr("cx");
86 const y = d3.select(this).attr("cy");
105 .call(drag)
106 .on("click", clicked);
107 function clicked(event, d) {
108 if (event.defaultPrevented) return; // dragged
109

reportBodySizemain.tsx1 match

@maxm•Updated 10 months ago
1export default async function(req: Request): Promise<Response> {
2 if (req.method !== "POST") {
3 return new Response("Method not allowed", { status: 405 });

valwriter_react_clientsidemain.tsx3 matches

@stevekrouse•Updated 10 months ago
34});
35
36export function App() {
37 const example = examples[Math.floor(Math.random() * examples.length)];
38 const description = /* c.req.query("description") || */ example.user;
92 user: "website that shows the current time",
93 content: `/** @jsxImportSource npm:react */
94export default function() {
95 return <h1>{new Date().toLocaleTimeString()}</h1>;
96}`,
108];
109
110export async function compile(description: string) {
111 const messages = [
112 {

jamesWebbImageProxymain.tsx1 match

@maxm•Updated 10 months ago
1export default async function(req: Request) {
2 const body = (await fetch("https://live.staticflickr.com/65535/53782948438_9b85e57a6c_o_d.png")).body
3 return new Response(body, {headers: {"Content-Type": "image/png"}});

valTownChatGPTmain.tsx3 matches

@maxm•Updated 10 months ago
13
14const clientCode = () => {
15 document.getElementById("input").addEventListener("submit", async function(event) {
16 event.preventDefault();
17
45 + `&assistantId=${input.getAttribute("data-assistant-id")}`,
46 );
47 eventSource.onmessage = function(event) {
48 console.log(event);
49 responseDiv.innerText += JSON.parse(event.data);
50 };
51
52 eventSource.onerror = function() {
53 eventSource.close();
54 };

chatGPTmain.tsx3 matches

@stevekrouse•Updated 10 months ago
9
10const clientCode = () => {
11 document.getElementById("input").addEventListener("submit", function(event) {
12 event.preventDefault();
13
33 + `&assistantId=${input.getAttribute("data-assistant-id")}`,
34 );
35 eventSource.onmessage = function(event) {
36 console.log(event);
37 responseDiv.innerText += JSON.parse(event.data);
38 };
39
40 eventSource.onerror = function() {
41 eventSource.close();
42 };

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago