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=2146&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 30771 results for "function"(10757ms)

static_reactindex.tsx2 matches

@jxnblk•Updated 3 months ago
3export type Middleware = (req: DataRequest, res: Response, callback: NextCallback) => Promise<Response>;
4
5export function render<T>(...args: Middleware[]) {
6 const middleware: Middleware[] = args.slice().filter(Boolean);
7
8 return async function handler(request: Request): Promise<Response> {
9
10 let res: Response = new Response();

static_reactreact-render.tsx1 match

@jxnblk•Updated 3 months ago
5
6export const reactRender = (Component: React.ComponentType) => {
7 return async function (req: DataRequest, res: Response): Promise<Response> {
8 const html = renderToStaticMarkup(<Component />);
9 const headers = res.headers;

typeanythingmapmain.tsx10 matches

@danny•Updated 3 months ago
3import React, { useEffect, useReducer, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function downloadGeoJSON(geojson, filename) {
6 const blob = new Blob([JSON.stringify(geojson, null, 2)], { type: "application/json" });
7 const url = URL.createObjectURL(blob);
17}
18
19function validateGeoJSON(geojson) {
20 try {
21 // Basic GeoJSON validation
39}
40
41function mapReducer(state, action) {
42 switch (action.type) {
43 case "SET_GEOJSON":
50}
51
52function MapComponent({ geojson }) {
53 const mapRef = useRef(null);
54 const mapInstanceRef = useRef(null);
56 useEffect(() => {
57 // Dynamically import Leaflet only in the browser
58 async function initMap() {
59 if (typeof window === "undefined" || !mapRef.current) return;
60
104 initMap();
105
106 // Cleanup function
107 return () => {
108 if (mapInstanceRef.current) {
116}
117
118function App() {
119 const [input, setInput] = useState("");
120 const [state, dispatch] = useReducer(mapReducer, { geojson: null, error: null });
135 ];
136
137 async function handleSubmit(query) {
138 // If query is an event, prevent default and get query from input
139 if (typeof query === "object" && query.preventDefault) {
351}
352
353function client() {
354 // Add custom CSS for dark mode Leaflet popup
355 const style = document.createElement("style");
370if (typeof document !== "undefined") { client(); }
371
372export default async function server(request: Request): Promise<Response> {
373 if (request.method === "POST") {
374 try {

project_updates_webhookmigrations.ts1 match

@shouser•Updated 3 months ago
4export const projectStatesTableName = "project_creation_project_states";
5
6export async function createTables() {
7 await sqlite.batch([
8 `CREATE TABLE IF NOT EXISTS ${subscriptionsTableName} (

project_updates_webhookwebhookService.ts1 match

@shouser•Updated 3 months ago
1export async function sendWebhookNotification(url: string, data: any) {
2 try {
3 const response = await fetch(url, {

project_updates_webhookqueries.ts4 matches

@shouser•Updated 3 months ago
10await createTables();
11
12export async function getWebhooks(limit = WEBHOOK_LIMIT): Promise<Webhook[]> {
13 const webhooks = await sqlite.execute(
14 `SELECT * FROM ${subscriptionsTableName}
20}
21
22export async function insertWebhook(projectId: string, webhookUrl: string, event: string) {
23 await sqlite.execute(
24 `INSERT INTO ${subscriptionsTableName} (projectId, webhookUrl, event)
28}
29
30export async function getProjectState(projectId: string) {
31 const result = await sqlite.execute(
32 `SELECT * FROM ${projectStatesTableName}
47}
48
49export async function updateProjectState(projectId: string, files: any[]) {
50 await sqlite.execute(
51 `INSERT OR REPLACE INTO ${projectStatesTableName} (projectId, files, lastUpdated)

todaysGrindmain.tsx1 match

@kamalnrf•Updated 3 months ago
12}
13
14export default async function(req: Request): Promise<Response> {
15 const headers = {
16 Authorization: `Bearer ${NOTION_API_KEY}`,
dotcom

dotcomapp.tsx17 matches

@jxnblk•Updated 3 months ago
25const cx = (...cn) => cn.filter(Boolean).join(" ");
26
27export function App(props) {
28 const cookies: AppCookies = parseCookies(props.cookie || null);
29 const initColorIndex = cookies.color || 0;
61// TODO: 404
62
63function Head(props) {
64 const { post } = props.data;
65 let params = "";
106const S = () => <>{" "}</>;
107
108function Nav() {
109 return (
110 <>
126}
127
128function Header({ cycleColor }: {
129 cycleColor: () => void;
130}) {
154}
155
156function Footer(props) {
157 return (
158 <footer className="container mb2 mt2">
184}
185
186function Home(props) {
187 return (
188 <div className="container space-children">
231}
232
233function Unknown(props) {
234 return (
235 <div className="container">
239}
240
241function NovanticaPromoHero() {
242 return (
243 <section className="promo">
255}
256
257function NovanticaPromoFooter() {
258 return (
259 <section className="promo mt2 mb2">
279const timestamp = (date: Date | string) => new Date(date).toLocaleDateString("en-US", { timeZone: "UTC" });
280
281function PostHeader({ post, primary }: { post: PostData; primary?: boolean }) {
282 const Element = primary ? "h1" : "h3";
283 return (
297}
298
299function PostList({ posts }) {
300 return (
301 <>
320}
321
322function RecentPosts({ data }) {
323 const recent = (data?.posts || [])
324 .filter(p => !p.draft)
337}
338
339function Blog({ data }) {
340 const posts = data.posts.filter(p => !p.draft);
341 return (
354}
355
356function Post({ data }) {
357 const { post } = data;
358 return (
381};
382
383export const routes: Record<Route, React.FunctionComponent> = {
384 [Route.Home]: Home,
385 [Route.Blog]: Blog,
388};
389
390export function setCookie(key: string, value: string) {
391 fetch("/", {
392 method: "POST",
395}
396
397function parseCookies(cookies: string) {
398 return (cookies || "").split(";").reduce((acc, n) => {
399 const [key, value] = n.split("=").map(s => s.trim());

vtClaudemain.http.tsx1 match

@maxm•Updated 3 months ago
359);
360
361export default async function(req: Request): Promise<Response> {
362 const url = new URL(req.url);
363 const path = url.pathname;
dotcom

dotcomhttp.tsx2 matches

@jxnblk•Updated 3 months ago
43};
44
45async function getInitialProps(req: DataRequest, res: Response, next): Promise<Response> {
46 let params: Params = {};
47 let route: Route = Route.Home;
79}
80
81async function cacheHeaders(req: DataRequest, res: Response, next): Promise<Response> {
82 res.headers.set("Cache-Control", "max-age=31536000");
83 return next();
tuna

tuna9 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.