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=748&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 7804 results for "function"(536ms)

evalCodemain.tsx2 matches

@tmcw•Updated 3 months ago
1import safeJsonValue from "npm:safe-json-value";
2
3export async function evalCode(
4 code: string,
5): Promise<{ error: { message: string; name: string; stack: string } } | any> {
43}
44
45function getMainExport(
46 mod: any,
47): { ok: true; value: any } | { ok: false; error: Error } {

widemain.tsx1 match

@tmcw•Updated 3 months ago
74}
75
76export default async function(req: Request): Promise<Response> {
77 // Use your Val Town API Token to create a session
78 const wide = new Wide(await ValSession.new(Deno.env.get("valtown")));

thankfulTurquoiseParrotREADME.md1 match

@tmcw•Updated 3 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}-----`;

thankfulTurquoiseParrotmain.tsx2 matches

@tmcw•Updated 3 months ago
20`;
21
22async function newSession(valTownToken: string) {
23 const privateKeyPem = `
24-----BEGIN PRIVATE KEY-----
38}
39
40function validate(token: string) {
41 const decoded = jwt.verify(token, publicKeyPem, { algorithms: ["RS256"] }) as
42 & Awaited<

valSessionREADME.md1 match

@tmcw•Updated 3 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}-----`;

valSessionmain.tsx2 matches

@tmcw•Updated 3 months ago
20`;
21
22async function newSession(valTownToken: string) {
23 const privateKeyPem = `
24-----BEGIN PRIVATE KEY-----
38}
39
40function validate(token: string) {
41 const decoded = jwt.verify(token, publicKeyPem, { algorithms: ["RS256"] }) as
42 & Awaited<

gitHubSyncmain.tsx4 matches

@tmcw•Updated 3 months ago
277});
278
279function Style() {
280 return (
281 <style>
294}
295
296function Logout() {
297 return (
298 <form action="/logout" method="post">
318
319/**
320 * This function can be used on its own
321 * to commit multiple files to a GitHub repo
322 */
323export async function commitFiles({
324 token,
325 owner,

tldraw_computer_examplemain.tsx1 match

@tmcw•Updated 3 months ago
64};
65
66export default async function(req: Request): Promise<Response> {
67 if (req.method === "GET") {
68 // handle a GET request

proudJadeSeahorsemain.tsx2 matches

@tmcw•Updated 3 months ago
8 .join(" OR ") + " " + excludes;
9
10function relevant(t: Tweet) {
11 if (keywords.some(k => t.full_text?.includes(k))) return true;
12 return t.entities.urls?.some(u => keywords.some(k => u.expanded_url?.includes(k)));
17const isProd = true;
18
19export async function twitterAlert({ lastRunAt }: Interval) {
20 // search
21 const since = isProd

sqlitemain.tsx7 matches

@tmcw•Updated 3 months ago
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
49}
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
64}
65
66function createResError(body: string) {
67 try {
68 const e = zLibsqlError.parse(JSON.parse(body));
85}
86
87function normalizeStatement(statement: InStatement, args?: InArgs) {
88 if (Array.isArray(statement)) {
89 // for the case of an array of arrays
107}
108
109function upgradeResultSet(results: ImpoverishedResultSet): ResultSet {
110 return {
111 ...results,
116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119 sqlRow: Array<unknown>,
120 columns: Array<string>,

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago