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/image-url.jpg%20%22Image%20title%22?q=function&page=58&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 19302 results for "function"(843ms)

Towniestyles.css2 matches

@pomdtr•Updated 5 days ago
160 transition-property: background-color;
161 transition-duration: 400ms;
162 transition-timing-function: linear;
163}
164
769 transition-property: color, background-color, border-color, opacity;
770 transition-duration: 200ms;
771 transition-timing-function: ease-in-out;
772}
773

TowniesoundEffects.ts3 matches

@pomdtr•Updated 5 days ago
1/**
2 * Sound effects utility functions for the application
3 */
4
7 * @returns A Promise that resolves when the sound has started playing
8 */
9export function playBellSound(): Promise<void> {
10 return new Promise((resolve) => {
11 try {
69 * @returns A Promise that resolves when the sound has started playing
70 */
71export function playSimpleNotification(): Promise<void> {
72 return new Promise((resolve) => {
73 try {

Townieschema.tsx2 matches

@pomdtr•Updated 5 days ago
22}
23
24async function createTables() {
25 // archive a table
26 // await sqlite.execute(
68}
69
70async function deleteTables() {
71 await sqlite.execute(`DROP TABLE IF EXISTS ${USAGE_TABLE}`);
72 await sqlite.execute(`DROP TABLE IF EXISTS ${INFERENCE_CALLS_TABLE}`);

TownieRequireAuthRoute.tsx1 match

@pomdtr•Updated 5 days ago
7import { useAuth } from "../hooks/useAuth.tsx";
8
9export function RequireAuthRoute () {
10 const location = useLocation();
11 const { isAuthenticated } = useAuth();

Townierequests.ts5 matches

@pomdtr•Updated 5 days ago
29}
30
31export function renderRequests(data: RequestRow[], pagination: PaginationData, baseUrl: string): string {
32 // Calculate totals
33 const totalRequests = pagination.totalItems;
39 // Client-side script for collapsible rows
40 const script = `
41 // Function to toggle inference details
42 function toggleInferenceDetails(usageId) {
43 const detailsElement = document.getElementById('inference-' + usageId);
44
153
154 // Add click event listeners to all collapsible rows
155 document.addEventListener('DOMContentLoaded', function() {
156 document.querySelectorAll('.collapsible').forEach(row => {
157 row.addEventListener('click', function() {
158 const usageId = this.getAttribute('data-id');
159 toggleInferenceDetails(usageId);

Townierequests.ts4 matches

@pomdtr•Updated 5 days ago
6 * Get paginated usage requests
7 */
8export async function getRequests(url: URL) {
9 const { page, pageSize } = getPaginationParams(url);
10
35 * Get a single request by ID
36 */
37export async function getRequestById(id: string) {
38 const result = await sqlite.execute(`
39 SELECT * FROM ${USAGE_TABLE}
51 * Get inference calls for a specific usage request
52 */
53export async function getInferenceCallsForRequest(usageId: string) {
54 const result = await sqlite.execute(`
55 SELECT
75 * Calculate totals from inference calls for a request
76 */
77export async function getInferenceTotalsForRequest(usageId: string) {
78 const calls = await getInferenceCallsForRequest(usageId);
79

Towniequeries.tsx6 matches

@pomdtr•Updated 5 days ago
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
9export async function getUser(bearerToken: string) {
10 if (userIdCache[bearerToken]) return userIdCache[bearerToken];
11
16}
17
18async function last24Hours(userId: string) {
19 const usage = await sqlite.execute(
20 `SELECT
40 "devto": 100, // hardcoded limit of $100 per day for dev.to, billed later
41};
42export async function overLimit(bearerToken: string) {
43 const user = await getUser(bearerToken);
44 const last24HourUsage = await last24Hours(user.id);
49}
50
51export async function insertInferenceCall({
52 usage_id,
53 input_tokens,
103}
104
105export async function startTrackingUsage({
106 bearerToken,
107 val_id,
145}
146
147export async function finishTrackingUsage({
148 rowid,
149 input_tokens,

TownieProjectsRoute.tsx3 matches

@pomdtr•Updated 5 days ago
4import { Loading } from "./Loading.tsx";
5
6export function ProjectsRoute () {
7 const projects = useProjects();
8
42}
43
44function ProjectCard ({
45 user,
46 project,
81}
82
83function Privacy ({ privacy }: {
84 privacy: "public"|"unlisted"|"private";
85}) {

TowniePreview.tsx1 match

@pomdtr•Updated 5 days ago
10}
11
12export function Preview({ projectFiles, messages, running }: PreviewProps) {
13 const [selectedEndpointIndex, setSelectedEndpointIndex] = useState<number>(0);
14 const [customPath, setCustomPath] = useState<string>("/");

TowniePreviewFrame.tsx4 matches

@pomdtr•Updated 5 days ago
9}
10
11export function PreviewFrame(props: PreviewProps) {
12 const previewKey = useRef<string>("new-chat");
13 const [count, setCount] = useState<number>(0);
73const TSRE = /\/$/;
74
75function URLInput({ url, pathname, setPathname }) {
76 const prefix = url.replace(TSRE, "");
77 return (
90}
91
92function PreviewSelect({ index, setIndex, files }) {
93 return (
94 <div>
116}
117
118function usePreviewURL({ files }) {
119 const [index, setIndex] = useState<number>(0);
120 const htmlVals = files?.filter(file => file.links?.endpoint !== undefined);

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
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.