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/image-url.jpg%20%22Optional%20title%22?q=function&page=2328&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 28554 results for "function"(2935ms)

prosperousMaroonSpidermain.tsx1 match

@fkhan14•Updated 6 months ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

sapientLavenderHerringmain.tsx1 match

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

imggenpromain.tsx5 matches

@andiebuk•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [prompt, setPrompt] = useState("");
7 const [imageData, setImageData] = useState("");
83}
84
85function client() {
86 createRoot(document.getElementById("root")).render(<App />);
87}
91}
92
93// Utility function to validate and adjust image dimensions
94function validateImageDimensions(width: number, height: number): {
95 width: number,
96 height: number,
135}
136
137export default async function server(request: Request): Promise<Response> {
138 const url = new URL(request.url);
139 const imagePrompt = url.searchParams.get('image');

cronIntervalLoggermain.tsx1 match

@dunnmary•Updated 6 months ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

valSessionREADME.md1 match

@maxm•Updated 6 months ago
25);
26
27function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string {
28 const lines = b64.match(/.{1,64}/g) || [];
29 return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`;

cfetchmain.tsx1 match

@temptemp•Updated 6 months ago
3const uuid = "1fd98a05-4959-42bc4-2f83-2c487c1cde6d";
4const build = `https://${uuid}.cloudflarepreviews.com/?url=`;
5export async function cfetch(input: string | URL, requestInit?: RequestInit) {
6 return fetch(`${build}${encodeURIComponent(input.toString())}`, {
7 ...requestInit,

Storyweavermain.tsx7 matches

@aioe0x417a•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function LoadingSpinner() {
6 return (
7 <div className="loading-spinner">
12}
13
14function cleanText(text: string) {
15 return text
16 .replace(/\*+/g, '')
19}
20
21function App() {
22 const [storyParts, setStoryParts] = useState({
23 title: null,
133}
134
135function client() {
136 createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139
140// Utility function to implement timeout
141async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
142 let timeoutHandle: number;
143 const timeoutPromise = new Promise<never>((_, reject) => {
152}
153
154export default async function server(request: Request): Promise<Response> {
155 if (request.method === 'POST' && new URL(request.url).pathname === '/generate-story') {
156 const formData = await request.formData();

blob_adminmain.tsx8 matches

@emilo•Updated 6 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

MathFlashCard_RetroEditionmain.tsx5 matches

@qkiii•Updated 6 months ago
4import confetti from "https://esm.sh/canvas-confetti";
5
6function generateProblem(config) {
7 const operations = [];
8 if (config.addition) operations.push('+');
54}
55
56function MathFlashcards() {
57 const MAX_STREAK = 5; // Number of segments in streak bar
58 const SUPER_STREAK_THRESHOLD = 5; // Threshold for special animations
383}
384
385function App() {
386 return React.createElement("div", { className: "app" }, React.createElement(MathFlashcards, null));
387}
388
389function client() {
390 createRoot(document.getElementById("root")).render(React.createElement(App, null));
391}
392if (typeof document !== "undefined") { client(); }
393
394export default async function server(request: Request): Promise<Response> {
395 return new Response(
396 `

katakanaWordApimain.tsx1 match

@jdan•Updated 6 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(request: Request): Promise<Response> {
4 try {
5 const openai = new OpenAI();

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.