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/$%7Bsuccess?q=function&page=1720&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 22554 results for "function"(2597ms)

energeticLimeStoatmain.tsx1 match

@edyi8•Updated 5 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",

balancedYellowMousemain.tsx1 match

@ozhao1323•Updated 5 months ago
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const SAMPLE_JOKE = {
6 "setup": "What do you call a group of disorganized cats?",

spotlessJadeBarracudamain.tsx1 match

@emmagershman•Updated 5 months ago
5
6// Fetches a random joke.
7function fetchRandomJoke() {
8 const SAMPLE_JOKE = {
9 "setup": "What do you call a group of disorganized cats?",

Joke_Generatormain.tsx1 match

@n3umaster•Updated 5 months ago
1import { email } from "https://esm.town/v/std/email?v=9";
2// Fetches a random joke.
3async function fetchRandomJoke() {
4 const response = await fetch(
5 "https://official-joke-api.appspot.com/random_joke",

responsibleFuchsiaImpalamain.tsx1 match

@nunnyu•Updated 5 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",

curiousMagentaFalconmain.tsx1 match

@emanneu•Updated 5 months ago
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const SAMPLE_JOKE = {
6 "setup": "What do you call a group of disorganized cats?",

dieselmain.tsx18 matches

@yawnxyz•Updated 5 months ago
10
11type DataFormat = 'object' | 'json' | 'yaml' | 'csv' | 'toml';
12type SelectorType = 'property' | 'index' | 'search' | 'dynamic' | 'append' | 'function';
13
14interface Selector {
40 selectors.push(this.parseAppend());
41 } else if (part.includes('(')) {
42 selectors.push(this.parseFunction(part));
43 } else {
44 // Handle top-level properties without a leading dot
112 }
113
114 private parseFunction(part: string): Selector {
115 const [funcName, argsString] = part.split('(');
116 const args = argsString.slice(0, -1).split(',').map(arg => arg.trim());
117 return { type: 'function', value: funcName, args };
118 }
119
128
129
130type FunctionHandler = (data: any, args: string[]) => any;
131
132const functions: Record<string, FunctionHandler> = {
133 length: (data) => Array.isArray(data) ? data.length : Object.keys(data).length,
134 keys: (data) => Object.keys(data),
145
146
147function applyFunction(funcName: string, data: any, args: string[] = []): any {
148 const func = functions[funcName];
149 if (!func) {
150 throw new Error(`Unknown function: ${funcName}`);
151 }
152
200
201 private async stringifyData(data: any, format: DataFormat): Promise<string> {
202 // Function to remove undefined values
203 const removeUndefined = (obj: any): any => {
204 if (Array.isArray(obj)) {
273
274
275 case 'function':
276 // If the function is 'length' and current is an array, apply it directly
277 if (selector.value === 'length' && Array.isArray(current)) {
278 return current.length;
279 }
280 // Otherwise, apply the function normally
281 current = applyFunction(selector.value as string, current, selector.args || []);
282 break;
283
336 result.push(this.traverseSelectorsForPut({}, remainingSelectors, value));
337 break;
338 case 'function':
339 throw new Error('Cannot put to a function selector');
340 }
341
383 case 'append':
384 return data;
385 case 'function':
386 throw new Error('Cannot delete from a function selector');
387 }
388

forbearingOrangeLemmingmain.tsx1 match

@c_lys•Updated 5 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",

dieselmain.tsx18 matches

@maxm•Updated 5 months ago
10
11type DataFormat = 'object' | 'json' | 'yaml' | 'csv' | 'toml';
12type SelectorType = 'property' | 'index' | 'search' | 'dynamic' | 'append' | 'function';
13
14interface Selector {
40 selectors.push(this.parseAppend());
41 } else if (part.includes('(')) {
42 selectors.push(this.parseFunction(part));
43 } else {
44 // Handle top-level properties without a leading dot
112 }
113
114 private parseFunction(part: string): Selector {
115 const [funcName, argsString] = part.split('(');
116 const args = argsString.slice(0, -1).split(',').map(arg => arg.trim());
117 return { type: 'function', value: funcName, args };
118 }
119
128
129
130type FunctionHandler = (data: any, args: string[]) => any;
131
132const functions: Record<string, FunctionHandler> = {
133 length: (data) => Array.isArray(data) ? data.length : Object.keys(data).length,
134 keys: (data) => Object.keys(data),
145
146
147function applyFunction(funcName: string, data: any, args: string[] = []): any {
148 const func = functions[funcName];
149 if (!func) {
150 throw new Error(`Unknown function: ${funcName}`);
151 }
152
200
201 private async stringifyData(data: any, format: DataFormat): Promise<string> {
202 // Function to remove undefined values
203 const removeUndefined = (obj: any): any => {
204 if (Array.isArray(obj)) {
273
274
275 case 'function':
276 // If the function is 'length' and current is an array, apply it directly
277 if (selector.value === 'length' && Array.isArray(current)) {
278 return current.length;
279 }
280 // Otherwise, apply the function normally
281 current = applyFunction(selector.value as string, current, selector.args || []);
282 break;
283
336 result.push(this.traverseSelectorsForPut({}, remainingSelectors, value));
337 break;
338 case 'function':
339 throw new Error('Cannot put to a function selector');
340 }
341
383 case 'append':
384 return data;
385 case 'function':
386 throw new Error('Cannot delete from a function selector');
387 }
388

dieselREADME.md2 matches

@maxm•Updated 5 months ago
9- **Multi-format Support**: Works with JSON, YAML, CSV, and TOML.
10- **Dynamic Selectors**: Use conditions to filter data dynamically.
11- **Function Support**: Built-in functions for data manipulation (e.g., length, sum, avg).
12- **Easy Integration**: Can be used in both Deno and Val Town environments.
13
17import Diesel from "https://esm.town/v/yawnxyz/diesel";
18
19async function main() {
20 const jsonData = `
21 {

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.