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=791&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 8331 results for "function"(818ms)

fuchsiaSnipemain.tsx1 match

@tmcw•Updated 10 months ago
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("http://worldtimeapi.org/api/timezone/America/New_York")
3 const timeData = await response.json()

zwjEmojimain.tsx1 match

@stevekrouse•Updated 10 months ago
3const EMOJI_DATA_URL = "https://unicode.org/Public/emoji/15.1/emoji-zwj-sequences.txt";
4
5export async function getCompoundEmojis(): Promise<string[]> {
6 const data = await fetchText(EMOJI_DATA_URL);
7 let result: string[] = [];

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"}});

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago