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=82&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 20212 results for "function"(2065ms)

untitled-7712queries.ts7 matches

@mayree•Updated 2 days ago
37
38// User queries
39export async function getUsers(): Promise<User[]> {
40 const result = await sqlite.execute(`SELECT * FROM ${USERS_TABLE} ORDER BY created_at DESC`);
41 return result.rows as User[];
42}
43
44export async function getUserByUsername(username: string): Promise<User | null> {
45 const result = await sqlite.execute(
46 `SELECT * FROM ${USERS_TABLE} WHERE username = ?`,
50}
51
52export async function createUser(username: string): Promise<User> {
53 const result = await sqlite.execute(
54 `INSERT INTO ${USERS_TABLE} (username) VALUES (?) RETURNING *`,
59
60// Job queries
61export async function getJobs(): Promise<Job[]> {
62 const result = await sqlite.execute(`SELECT * FROM ${JOBS_TABLE} ORDER BY created_at DESC`);
63 return result.rows as Job[];
64}
65
66export async function createJob(job: JobInput): Promise<Job> {
67 const result = await sqlite.execute(
68 `INSERT INTO ${JOBS_TABLE} (title, company, description, location, contact_email, posted_by)
74
75// Message queries
76export async function getMessages(limit: number = 50): Promise<Message[]> {
77 const result = await sqlite.execute(
78 `SELECT * FROM ${MESSAGES_TABLE} ORDER BY created_at DESC LIMIT ?`,
82}
83
84export async function createMessage(content: string, username: string): Promise<Message> {
85 const result = await sqlite.execute(
86 `INSERT INTO ${MESSAGES_TABLE} (content, username) VALUES (?, ?) RETURNING *`,

untitled-7712migrations.ts1 match

@mayree•Updated 2 days ago
6const MESSAGES_TABLE = "job_board_messages";
7
8export async function initDatabase() {
9 // Create users table
10 await sqlite.execute(`

pass-genpassword-generator.ts17 matches

@dooooogie•Updated 2 days ago
1export default async function (req: Request) {
2 // Fetch a password from dinopass.com on the server side to avoid CORS issues
3 let dinoPassword = "";
130 ]);
131
132 // Function to check if a string is a known word
133 function isKnownWord(word) {
134 return allWords.has(word.toLowerCase());
135 }
136
137 // Function to check if a string ends with a known adjective ending in 'y'
138 function endsWithAdjectiveY(str) {
139 str = str.toLowerCase();
140 return wordDictionary.adjectivesY.some(adj => str.endsWith(adj));
141 }
142
143 // Function to check if a string contains a color word
144 function containsColorWord(str) {
145 str = str.toLowerCase();
146 return wordDictionary.colors.some(color => str.includes(color));
147 }
148
149 // Function to check if a string contains an animal word
150 function containsAnimalWord(str) {
151 str = str.toLowerCase();
152 return wordDictionary.animals.some(animal => str.includes(animal));
153 }
154
155 // Function to extract whole words from dinopass response
156 function extractWords(password) {
157 // Remove any numbers or special characters
158 const cleanPassword = password.replace(/[^a-zA-Z]/g, '').toLowerCase();
232 }
233
234 // Function to capitalize first letter
235 function capitalize(word) {
236 return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
237 }
238
239 // Function to generate password
240 async function generatePassword() {
241 try {
242 // Show loading state
271 }
272
273 // Function to copy password to clipboard
274 function copyToClipboard() {
275 const passwordField = document.getElementById('passwordField');
276 if (!passwordField.value) return;

pass-genREADME.md1 match

@dooooogie•Updated 2 days ago
9- Extracts whole words from the dinopass response
10- Capitalizes the first letter of each word
11- Modern UI with a copy-to-clipboard function
12- Responsive design that works on all devices
13

untitled-2444index.ts14 matches

@all•Updated 2 days ago
47
48// Set up the form submission handler
49function setupFormHandling(
50 tokenizer: Tokenizer,
51 scriptEditor: ScriptEditor,
264
265// Set up the token counter
266function setupTokenCounter(tokenizer: Tokenizer) {
267 const textArea = document.getElementById("text") as HTMLTextAreaElement;
268 const tokenCount = document.getElementById("tokenCount") as HTMLSpanElement;
296
297// Set up template selector
298function setupTemplateSelector(templateManager: TemplateManager) {
299 const templateSelect = document.getElementById("templateSelect") as HTMLSelectElement;
300 const instructionsTextarea = document.getElementById("instructions") as HTMLTextAreaElement;
314
315// Set up advanced options
316function setupAdvancedOptions(openAIConnector: OpenAIConnector, debugConsole: DebugConsole) {
317 const advancedOptionsBtn = document.getElementById("advancedOptionsBtn") as HTMLButtonElement;
318 const advancedOptions = document.getElementById("advancedOptions") as HTMLDivElement;
417
418// Set up result actions (copy, download, compare)
419function setupResultActions(scriptEditor: ScriptEditor, textFormatter: TextFormatter) {
420 const copyBtn = document.getElementById("copyBtn") as HTMLButtonElement;
421 const downloadBtn = document.getElementById("downloadBtn") as HTMLButtonElement;
604
605// Set up history modal
606function setupHistoryModal(historyManager: HistoryManager, scriptEditor: ScriptEditor) {
607 const historyBtn = document.getElementById("historyBtn") as HTMLButtonElement;
608 const historyModal = document.getElementById("historyModal") as HTMLDivElement;
674
675// Set up utility buttons (load sample, clear)
676function setupUtilityButtons(scriptEditor: ScriptEditor) {
677 const loadSampleBtn = document.getElementById("loadSampleBtn") as HTMLButtonElement;
678 const clearBtn = document.getElementById("clearBtn") as HTMLButtonElement;
704
705// Set up script type detection
706function setupScriptTypeDetection(tokenizer: Tokenizer) {
707 const textArea = document.getElementById("text") as HTMLTextAreaElement;
708 const scriptTypeDetected = document.getElementById("scriptTypeDetected") as HTMLSpanElement;
757/**
758 * Create a prompt based on script type
759 * This is a duplicate of the server-side function to enable direct API calls
760 */
761function createPromptForScriptType(
762 chunk: string,
763 instructions: string,
859
860// Set up word counter
861function setupWordCounter(textFormatter: TextFormatter) {
862 const textArea = document.getElementById("text") as HTMLTextAreaElement;
863 const wordCount = document.getElementById("wordCount") as HTMLSpanElement;
879
880// Set up share modal
881function setupShareModal() {
882 const shareModal = document.getElementById("shareModal") as HTMLDivElement;
883 const closeShareBtn = document.getElementById("closeShareBtn") as HTMLButtonElement;
955
956// Set up feedback modal
957function setupFeedbackModal() {
958 const feedbackModal = document.getElementById("feedbackModal") as HTMLDivElement;
959 const closeFeedbackBtn = document.getElementById("closeFeedbackBtn") as HTMLButtonElement;
1023
1024// Set up export/import settings
1025function setupExportImportSettings() {
1026 const exportSettingsBtn = document.getElementById("exportSettingsBtn") as HTMLButtonElement;
1027 const importSettingsBtn = document.getElementById("importSettingsBtn") as HTMLButtonElement;

Afolabismain.tsx7 matches

@vawogbemi•Updated 2 days ago
42import { Drawer } from "https://esm.sh/vaul?deps=react@18.2.0,react-dom@18.2.0";
43
44function SideDrawer({ trigger, title, content, initialOpen = false }: {
45 trigger: React.JSX.Element;
46 title: string;
74}
75
76function BottomDrawer({ trigger, title, content, initialOpen = false }: {
77 trigger: React.JSX.Element;
78 title: string;
279};
280
281function ProductCard(
282 { db, cart, product, activeProductId, setActiveProductId }: {
283 db: any;
439}
440
441function ProductCarousel({ children }: { children: React.ReactNode }) {
442 const [emblaRef, emblaApi] = useEmblaCarousel({
443 axis: "x",
470 const scrollResult = emblaApi.scrollTo(emblaApi.selectedScrollSnap() + Math.sign(delta));
471
472 if (scrollResult && typeof scrollResult.then === "function") {
473 scrollResult.then(() => {
474 isScrollingRef.current = false;
1092
1093// Client-side rendering
1094function client() {
1095 const root = document.getElementById("root");
1096 if (root) {
1111const app = new Hono();
1112
1113// Server-side rendering function
1114const renderPage = () => {
1115 const content = renderToString(

createInteractionForm.tsx1 match

@charmaine•Updated 2 days ago
7}
8
9export default function InteractionForm({ onSubmit }: InteractionFormProps) {
10 const [formData, setFormData] = useState<Omit<Interaction, 'contact_id'>>({
11 type: 'call' as InteractionType,

createContactDetail.tsx1 match

@charmaine•Updated 2 days ago
11}
12
13export default function ContactDetail({
14 contact,
15 onEdit,

createContactForm.tsx1 match

@charmaine•Updated 2 days ago
8}
9
10export default function ContactForm({ contact, onSubmit }: ContactFormProps) {
11 const [formData, setFormData] = useState<Contact>({
12 id: contact?.id,

createContactList.tsx1 match

@charmaine•Updated 2 days ago
9}
10
11export default function ContactList({
12 contacts,
13 selectedContactId,

getFileEmail4 file matches

@shouser•Updated 3 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
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.