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/$%7Burl%7D?q=function&page=1985&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 30093 results for "function"(11284ms)

hn_notifierutils.ts4 matches

@charmaine•Updated 2 months ago
5export const HN_API_URL = "https://hn.algolia.com/api/v1/items";
6
7export function countAllChildren(item: HNAPIResponse): number {
8 const stack: HNAPIResponse[] = [item];
9 let count = 0;
21}
22
23export async function getHNItem(id: number) {
24 return await betterFetch<HNAPIResponse>(
25 `${HN_API_URL}/${id}`,
27}
28
29export async function getHNCommentStoryTitle(storyId: number): Promise<{
30 data: { storyTitle: string } | null;
31 error: {
47}
48
49export async function createDBItem(id: number, data: HNAPIResponse): Promise<DBItem> {
50 const comments = countAllChildren(data);
51

hn_notifierqueries.ts5 matches

@charmaine•Updated 2 months ago
9 * @returns {Promise<DBItem[]>} The inserted item
10 */
11export async function follow(item: DBItem): Promise<DBItem> {
12 const { id, comments, title, type } = item;
13 const res = await sqlite.execute({
23 * @returns {Promise<void>}
24 */
25export async function unfollow(id: number): Promise<void> {
26 await sqlite.execute({
27 sql: `DELETE FROM ${tableName} WHERE id = ?`,
35 * @returns {Promise<DBItem[]>} The matching item(s)
36 */
37export async function getItem(id: number): Promise<DBItem | undefined> {
38 const res = await sqlite.execute({
39 sql: `SELECT * FROM ${tableName} WHERE id = ?`,
47 * @returns {Promise<DBItem[]>} Array of all items
48 */
49export async function getAllItems(): Promise<DBItem[]> {
50 const res = await sqlite.execute(`SELECT * FROM ${tableName}`);
51 return sqliteRowsToObject<DBItem>(res);
57 * @returns {Promise<DBItem[]>} The updated item
58 */
59export async function updateCommentCount(item: DBItem): Promise<DBItem[]> {
60 const { id, comments } = item;
61 const res = await sqlite.execute({

hn_notifiermigrations.ts1 match

@charmaine•Updated 2 months ago
9)`;
10
11export async function createTables() {
12 await sqlite.batch([schema]);
13}

hn_notifierItemContext.tsx4 matches

@charmaine•Updated 2 months ago
16 isLoading: false,
17 saveUrl: async () => {
18 throw new Error("saveUrl function not implemented");
19 },
20 unfollowUrl: async () => {
21 throw new Error("unfollowUrl function not implemented");
22 },
23 fetchUrls: async () => {
24 throw new Error("fetchUrls function not implemented");
25 },
26});
34 const [isLoading, setIsLoading] = useState<boolean>(false);
35
36 // Function to fetch URLs that can be called from components
37 const fetchUrls = async (): Promise<void> => {
38 setIsLoading(true);

hn_notifierInput.tsx1 match

@charmaine•Updated 2 months ago
37 }
38
39 // Save the URL using the context function
40 console.log("saving:", id);
41 await saveUrl(id);

hn_notifierApp.tsx1 match

@charmaine•Updated 2 months ago
5import ListSection from "https://esm.town/v/nbbaier/hn_notifier/frontend/components/ListSection.tsx";
6
7export function App() {
8 return (
9 <ItemsProvider>

roughVizPlaygroundmain.tsx8 matches

@dcm31•Updated 2 months ago
1export default async function handler(request) {
2 return new Response(
3 `
444
445 <script>
446 // Helper function to generate CSV data for line chart
447 function generateCsvData() {
448 const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
449 let csvString = 'month,value1,value2\\n';
460
461 // Initialize charts
462 document.addEventListener('DOMContentLoaded', function() {
463 // Get current settings
464 const getSettings = () => {
480 // Update display values
481 ['roughness', 'bowing', 'fill-weight', 'stroke-width', 'inner-stroke-width'].forEach(id => {
482 document.getElementById(id).addEventListener('input', function() {
483 document.getElementById(\`\${id}-value\`).textContent = this.value;
484 });
486
487 // Apply settings button
488 document.getElementById('apply-settings').addEventListener('click', function() {
489 // Clear existing charts
490 document.querySelectorAll('.chart-container > div:first-of-type').forEach(chart => {
500 });
501
502 function createCharts(settings) {
503 if (typeof roughViz === 'undefined') {
504 console.error('roughViz library is not loaded');
639 }
640
641 function updateCodeExamples(settings) {
642 const codeExamples = document.querySelectorAll('.code-example pre');
643

vsmarketplaceRSSmain.tsx1 match

@ewired•Updated 2 months ago
44}
45
46export default async function server(request: Request): Promise<Response> {
47 const url = new URL(request.url);
48 const pathParts = url.pathname.split("/").filter(Boolean);

dazzlingCoffeeTigermain.tsx2 matches

@ajax•Updated 2 months ago
2import { generateText } from "npm:ai";
3
4export default async function(req: Request): Promise<Response> {
5 if (req.method !== "POST") {
6 return Response.json({ message: "This function only accepts POST requests." }, { status: 400 });
7 }
8 try {

growingGoldHippopotamusmain.tsx1 match

@ajax•Updated 2 months ago
1"I'm sorry, but I need a specific toolDescription in order to generate the required TypeScript code. Could you please provide the toolDescription so I can create the cloud function for you?"
tuna

tuna9 file matches

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