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=773&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"(428ms)

oldfashionedmain.tsx9 matches

@tmcw•Updated 1 year ago
23const { styleRoute, StyleTag } = styleSystem();
24
25function MaterialsList() {
26 const c = useContext(RequestContext);
27 const mats = getMaterialIds(c);
76}
77
78function RecipesList() {
79 const c = useContext(RequestContext);
80 const s = c?.req.param("slug");
131} as const;
132
133function Units() {
134 const requestContext = useContext(RequestContext);
135 let unit = getCookie(requestContext!, "units") || "";
162});
163
164function getTitle(recipe: Recipe | undefined): string {
165 if (!recipe) {
166 return "Old Fashioned";
169}
170
171function parseUnit(unit: string | undefined): Fmt {
172 if (unit === "CL" || unit === "Ml" || unit === "Oz") {
173 return unit;
176}
177
178function WelcomeMessage() {
179 return (
180 <plank id="recipe-detail" hx-swap-oob="true">
203}
204
205function RecipeDetail() {
206 const c = useContext(RequestContext);
207 const s = c?.req.param("slug") || "";
257}
258
259function IngredientDisplay({ ingredient, unit }: {
260 ingredient: Ingredient;
261 unit: keyof typeof units;
292}
293
294function Index() {
295 const requestContext = useContext(RequestContext);
296 const s = requestContext?.req.param("slug") || "";

styleSystemmain.tsx2 matches

@tmcw•Updated 1 year ago
3import { Context } from "npm:hono@3.8.1";
4
5export function styleSystem() {
6 function StyleTag() {
7 return (
8 <style

getMaterialsmain.tsx1 match

@tmcw•Updated 1 year ago
3import { Context } from "npm:hono@3.8.1";
4
5export function getMaterials(c: Context | null) {
6 const ids = getMaterialIds(c);
7 return Object.values(materials).filter((mat) => ids.has(mat.id));

getMaterialIdsmain.tsx1 match

@tmcw•Updated 1 year ago
2import { Context } from "npm:hono@3.8.1";
3
4export function getMaterialIds(c: Context | null) {
5 if (!c) return new Set();
6 try {

sortmain.tsx1 match

@tmcw•Updated 1 year ago
2import { Recipe } from "https://esm.town/v/tmcw/Recipe";
3
4export function sort(recipes: Map<string, Recipe>, materials: Material[]) {
5 const have = new Set(materials.map((m) => m.name));
6

getCookiemain.tsx1 match

@tmcw•Updated 1 year ago
5
6/** Get a cookie from the request or optionally from inflight */
7export function getCookie(c: Context, key: string): string | undefined {
8 const inflight = getInflight(c);
9 if (inflight.has(key)) {

setCookiemain.tsx1 match

@tmcw•Updated 1 year ago
5
6/** Set a cookie and keep track of it inflight */
7export function setCookie(c: Context, key: string, value: string) {
8 const inflight = getInflight(c);
9 inflight.set(key, value);

getInflightmain.tsx1 match

@tmcw•Updated 1 year ago
2import { Context } from "npm:hono@3.8.1";
3
4export function getInflight(c: Context) {
5 return InflightCookies.get(c) || new Map();
6}

formatFloatmain.tsx1 match

@tmcw•Updated 1 year ago
24
25// TODO: refactor
26export function formatFloat(a: number) {
27 const intPart = Math.floor(a);
28 const remainder = Math.floor((a - intPart) * 100);

testingmain.tsx5 matches

@tmcw•Updated 1 year ago
3
4const stream = test.createStream({ objectMode: true });
5stream.on("data", function(row) {
6 console.log(JSON.stringify(row));
7});
8
9test("timing test", function(t) {
10 t.plan(2);
11
12 t.equal(typeof Date.now, "function");
13 var start = Date.now();
14
15 setTimeout(function() {
16 t.equal(Date.now() - start, 100);
17 }, 100);
19
20export const testing = new Promise(resolve => {
21 stream.on("end", function(row) {
22 resolve("ok");
23 });

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago