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=1744&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 19200 results for "function"(1848ms)

notion_paperpile_detail_fillermain.tsx2 matches

@nerdymomocat•Updated 1 year ago
3import { fetch } from "npm:cross-fetch";
4
5export default async function(interval: Interval) {
6 const NOTION_API_KEY = process.env.NOTION_API_KEY;
7 const PAPERPILE_DB_ID = "DB_ID_GOES_HERE";
60 )
61 }`,
62 ).then((r) => r.json()).catch(function() {
63 console.log("Promise Rejected");
64 });

git_syncmain.tsx5 matches

@saolsen•Updated 1 year ago
40};
41
42async function valtown(path: string): Promise<[number, object | null]> {
43 const req = await fetch(path, {
44 headers: {
54}
55
56async function git(
57 args: string[],
58 env: { [key: string]: string } = {},
67
68// Get all the vals for the user.
69async function getVals(me: User): Promise<Val[]> {
70 const vals = [];
71 let next_page:
84
85// Write every version of the val to a file and commit it (unless there's no changes).
86async function syncVals(vals: Val[]) {
87 for (let i = 0; i < vals.length; i++) {
88 const val = vals[i];
130}
131
132export default async function main() {
133 // check for api key
134 const api_key = Deno.env.get("valtown");

placemarkGlobeMonitormain.tsx1 match

@tmcw•Updated 1 year ago
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
2
3export default async function(interval: Interval) {
4 const versions = await fetch("https://www.figma.com/api/plugins/1323092380415927575/versions").then(r => r.json());
5 const { install_count, like_count, view_count } = versions.meta.plugin;

DiscordNotifiermain.tsx1 match

@glommer•Updated 1 year ago
1import { getThreadsActivity } from "https://esm.town/v/glommer/getThreadsActivity";
2
3export default async function(interval: Interval) {
4 const guild = Deno.env.get("DISCORD_GUILD_ID");
5 const token = Deno.env.get("DISCORD_IKU_BOT_TOKEN");

sendMsgToSlackmain.tsx1 match

@glommer•Updated 1 year ago
1export async function slackPost(token, channel, text) {
2 const resp = await fetch(
3 `https://slack.com/api/chat.postMessage`,

p5_sketchmain.tsx2 matches

@saolsen•Updated 1 year ago
1import type * as p5 from "npm:@types/p5";
2
3export function setup() {
4 createCanvas(400, 400);
5}
6
7export function draw() {
8 if (mouseIsPressed) {
9 fill("red");

p5main.tsx3 matches

@saolsen•Updated 1 year ago
1export function sketch(module: string): (req: Request) => Response {
2 return function(req: Request): Response {
3 return new Response(
4 `
40}
41
42export default async function(req: Request): Promise<Response> {
43 return new Response(
44 `

p5README.md4 matches

@saolsen•Updated 1 year ago
10```
11
12* Export any "global" p5 functions. These are functions like `setup` and `draw` that p5 will call.
13
14* Set the val type to http and default export the result of `sketch`, passing in `import.meta.url`.
19import type * as p5 from "npm:@types/p5";
20
21export function setup() {
22 createCanvas(400, 400);
23}
24
25export function draw() {
26 if (mouseIsPressed) {
27 fill(0);
37
38## How it works
39The sketch function returns an http handler that sets up a basic page with p5.js added. It then imports your module from the browser and wires up all the exports so p5.js can see them. All the code in your val will run in the browser (except for the default `sketch` export) so you can't call any Deno functions, environment variables, or other server side apis.
40
41

wabt_importmain.tsx1 match

@saolsen•Updated 1 year ago
17const importObject = {};
18WebAssembly.instantiate(module.toBinary({}).buffer, importObject).then(
19 function (res) {
20 console.log(res.instance.exports.add(5, 3));
21 }

miniWidgetmain.tsx3 matches

@wilt•Updated 1 year ago
4import { tinyLogomark } from "https://esm.town/v/wilt/tinyLogomark";
5
6export async function miniWidget(request: Request): Promise<Response> {
7 switch (new URL(request.url).pathname) {
8 case "/":
119 event.waitUntil(renderWidget(event.widget));
120})
121async function renderWidget(widget) {
122 console.log(widget);
123 if (!widget) return;
134 event.waitUntil(updateWidgets());
135});
136async function updateWidgets() {
137 const widget = await self.widgets.getByTag("simplepwa");
138 renderWidget(widget);

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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": "*",