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=1706&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 17949 results for "function"(1189ms)

myApimain.tsx1 match

@rolling_coaster•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

pingHttpmain.tsx1 match

@robin•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function pingHttp(url: string) {
4 try {
5 const res = await fetch(url);

md5main.tsx23 matches

@tr3ntg•Updated 1 year ago
1export function md5(input) {
2 /*
3 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
16 var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
17 /*
18 * These are the functions you'll usually want to call
19 * They take string arguments and return either hex or base-64 encoded strings
20 */
21 function hex_md5(s) {
22 return binl2hex(core_md5(str2binl(s), s.length * chrsz));
23 }
24 function b64_md5(s) {
25 return binl2b64(core_md5(str2binl(s), s.length * chrsz));
26 }
27 function str_md5(s) {
28 return binl2str(core_md5(str2binl(s), s.length * chrsz));
29 }
30 function hex_hmac_md5(key, data) {
31 return binl2hex(core_hmac_md5(key, data));
32 }
33 function b64_hmac_md5(key, data) {
34 return binl2b64(core_hmac_md5(key, data));
35 }
36 function str_hmac_md5(key, data) {
37 return binl2str(core_hmac_md5(key, data));
38 }
40 * Perform a simple self-test to see if the VM is working
41 */
42 function md5_vm_test() {
43 return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
44 }
46 * Calculate the MD5 of an array of little-endian words, and a bit length
47 */
48 function core_md5(x, len) {
49 /* append padding */
50 x[len >> 5] |= 0x80 << ((len) % 32);
131 }
132 /*
133 * These functions implement the four basic operations the algorithm uses.
134 */
135 function md5_cmn(q, a, b, x, s, t) {
136 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
137 }
138 function md5_ff(a, b, c, d, x, s, t) {
139 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
140 }
141 function md5_gg(a, b, c, d, x, s, t) {
142 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
143 }
144 function md5_hh(a, b, c, d, x, s, t) {
145 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
146 }
147 function md5_ii(a, b, c, d, x, s, t) {
148 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
149 }
151 * Calculate the HMAC-MD5, of a key and some data
152 */
153 function core_hmac_md5(key, data) {
154 var bkey = str2binl(key);
155 if (bkey.length > 16)
167 * to work around bugs in some JS interpreters.
168 */
169 function safe_add(x, y) {
170 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
171 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
175 * Bitwise rotate a 32-bit number to the left.
176 */
177 function bit_rol(num, cnt) {
178 return (num << cnt) | (num >>> (32 - cnt));
179 }
182 * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
183 */
184 function str2binl(str) {
185 var bin = Array();
186 var mask = (1 << chrsz) - 1;
192 * Convert an array of little-endian words to a string
193 */
194 function binl2str(bin) {
195 var str = "";
196 var mask = (1 << chrsz) - 1;
202 * Convert an array of little-endian words to a hex string.
203 */
204 function binl2hex(binarray) {
205 var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
206 var str = "";
214 * Convert an array of little-endian words to a base-64 string
215 */
216 function binl2b64(binarray) {
217 var tab =
218 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

addCommentmain.tsx1 match

@vez•Updated 1 year ago
3import { commentsDB } from "https://esm.town/v/vez/commentsDB";
4
5export async function addComment(str) {
6 commentsDB.push(str);
7 await set("commentsDB", commentsDB);

commentsmain.tsx1 match

@andreterron•Updated 1 year ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4export function comments({ token, since, until, offset, limit, relationship }: {
5 token: string;
6 since?: Date;

dallemailmain.tsx1 match

@andreterron•Updated 1 year ago
4import { dalleImageUrl } from "https://esm.town/v/andreterron/dalleImageUrl";
5
6export async function dallemail(email) {
7 let imageUrl = await dalleImageUrl(email.text);
8 return email2({

actuallyItsXBotmain.tsx1 match

@andreterron•Updated 1 year ago
4import { refreshActuallyBotToken } from "https://esm.town/v/andreterron/refreshActuallyBotToken";
5
6export async function actuallyItsXBot() {
7 const token = await refreshActuallyBotToken();
8 //

feedGeneratormain.tsx2 matches

@lukas•Updated 1 year ago
29 cursor?: string;
30}
31export async function feedGenerator({ feed, serviceDID, publisherDID, hostname }: {
32 serviceDID?: string;
33 publisherDID: string;
57 return [q.toString()];
58 };
59 return async function (req: express.Request, res: express.Response) {
60 const serviceDid = serviceDID ?? `did:web:${hostname}`;
61 const didCache = new resolver.MemoryCache();

myApimain.tsx1 match

@bcrummy•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

chatSampleFunctionMultiplemain.tsx7 matches

@webup•Updated 1 year ago
2import { chat } from "https://esm.town/v/webup/chat";
3
4export const chatSampleFunctionMultiple = (async () => {
5 // Helper function to call and print assistant response
6 const callAssistant = async (messages) => {
7 const response = await chat(messages, {
8 functions: schemasWeather,
9 });
10 typeof response === "object"
18 role: "system",
19 content:
20 "Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous.",
21 },
22 { role: "user", content: "What's the weather like today" },
23 ];
24 let response = await callAssistant(messages);
25 // Once we provide the missing info, it will generate the appropriate function arguments
26 messages.push({ role: "assistant", content: response });
27 messages.push({ role: "user", content: "I'm in Glasgow, Scotland." });
28 response = await callAssistant(messages);
29 // By prompting it differently, we can get it to target the other function we've told
30 messages.length = 1;
31 messages.push({
35 });
36 response = await callAssistant(messages);
37 // Let's provide the num of days, and model will generate the call to the other function
38 messages.push({ role: "assistant", content: response });
39 messages.push({ role: "user", content: "5 days" });

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",