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=1342&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 18324 results for "function"(1221ms)

shirtGenScriptmain.tsx1 match

@stevekrouse•Updated 5 months ago
1export default async function server(request: Request): Promise<Response> {
2 if (request.method !== "POST") {
3 return new Response("Method Not Allowed", { status: 405 });

shirtGenScriptmain.tsx1 match

@stevekrouse•Updated 5 months ago
1export default async function server(request: Request): Promise<Response> {
2 if (request.method !== "POST") {
3 return new Response("Method Not Allowed", { status: 405 });

shirtGenScriptmain.tsx1 match

@torlanco•Updated 5 months ago
1export default async function server(request: Request): Promise<Response> {
2 if (request.method !== "POST") {
3 return new Response("Method Not Allowed", { status: 405 });

deftRedRoadrunnermain.tsx1 match

@jierui•Updated 5 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

sqlitemain.tsx7 matches

@alexandreph•Updated 5 months ago
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
49}
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
64}
65
66function createResError(body: string) {
67 try {
68 const e = zLibsqlError.parse(JSON.parse(body));
85}
86
87function normalizeStatement(statement: InStatement, args?: InArgs) {
88 if (Array.isArray(statement)) {
89 // for the case of an array of arrays
107}
108
109function upgradeResultSet(results: ImpoverishedResultSet): ResultSet {
110 return {
111 ...results,
116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119 sqlRow: Array<unknown>,
120 columns: Array<string>,

handleDiscordNewUsermain.tsx2 matches

@buttondown•Updated 5 months ago
15}
16
17async function detectTechnologies(email_address: string): Promise<ShovelResponse> {
18 const domain = email_address.split("@")[1];
19
40// # New Val Town User (on Clerk) -> Val Town Discord notification
41// Translates one kind of webhook (Clerk) into another (Discord)
42export async function handleDiscordNewUser(req: Request): Promise<Response> {
43 // check custom auth secret sent from clerk
44 if (req.headers.get("auth") !== Deno.env.get("clerkNonSensitive"))

giftSuggestionAppmain.tsx4 matches

@trollishka•Updated 5 months ago
9}
10
11function App() {
12 const [age, setAge] = useState<string[]>([]);
13 const [budget, setBudget] = useState<string[]>([]);
201}
202
203function client() {
204 createRoot(document.getElementById("root")).render(<App />);
205}
209}
210
211async function searchProduct(query: string): Promise<{ imageUrl: string; productUrl: string } | null> {
212 try {
213 // Using a more realistic product image placeholder
225}
226
227export default async function server(req: Request): Promise<Response> {
228 if (req.method === "POST") {
229 const url = new URL(req.url);

sanguineCyanMastodonREADME.md11 matches

@mikehiggins•Updated 5 months ago
22stopwords: Contains a list of common stop words and web-specific terms to filter out during text analysis.
23synonyms: Dictionary mapping common words to their synonyms for highlighting in TF-IDF analysis.
24Functions
25The primary functions perform specific text analysis tasks, as detailed in the following sections.
26
27Function Documentation
28Each function's purpose, parameters, and output are described below, along with notes on how they are used within the application.
29
30analyseSentiment(text)
72
73url (string): URL to fetch and clean content from. Returns: Cleaned text string or an error message.
74Usage: This function powers the URL input functionality.
75Core Functionalities
76Text Analysis Form (HTML)
77The form on the main page allows users to submit either raw text or a URL. The client-side JavaScript processes the form submission and, if needed, triggers a URL fetch to obtain content.
91
92Integration Tests: Ensure calculateTFIDF, calculateWordFrequency, and fetchUrlContent produce consistent outputs.
93Client-Side Testing: Regularly test URL fetching functionality to ensure robustness, particularly with dynamic sites.
94Error Handling
95
96Maintain try/catch blocks in asynchronous functions like fetchUrlContent to capture network issues.
97Update error messages to be user-friendly and provide feedback if inputs are invalid or exceed size limits.
98Data Sanitization
115Multilingual Support
116
117Extend stop words, sentiment analysis, and cleaning functions to support languages beyond English.
118
119The Radical Text Analyser code primarily uses the following APIs:
1232. External Content Fetching API (via fetch)
124 * Purpose: Retrieves HTML content from external URLs when users input a URL for analysis.
125 * Usage: The fetchUrlContent function uses fetch to make a GET request to the user-provided URL, which allows the application to process content from web pages.
126 * Error Handling: Includes logic to check response status and handle various network errors.
1273. Google Fonts API
132 * Usage: Loaded in the HTML <head> section with <script src="https://cdnjs.cloudflare.com/ajax/libs/jqcloud/1.0.4/jqcloud-1.0.4.min.js"></script> and <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqcloud/1.0.4/jqcloud.min.css">
133
134 The TF-IDF analysis in this code is performed without using an external library. Instead, it’s implemented directly in the `calculateTFIDF` function. Here’s how it works:
135
1361. **Tokenization and Filtering**: The text is split into words and phrases, excluding stopwords and web-specific terms.

twitterAlertmain.tsx1 match

@samwho•Updated 5 months ago
4const query = "\"samwho.dev\" -is:retweet -from:samwhoo";
5
6export async function twitterAlert({ lastRunAt }: Interval) {
7 // search
8 const since = lastRunAt ? Math.floor(lastRunAt.getTime() / 1000) : 0;

scraper_templateREADME.md1 match

@rickyfarm•Updated 5 months ago
133. Adjust the if statement to detect changes and update your blob
14
154. Craft a message to be sent with `sendNotification()` function

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 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.