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=1599&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 18955 results for "function"(1294ms)

exampleQuestionAnsweringmain.tsx1 match

@iamseeley•Updated 10 months ago
1import Pipeline from "https://esm.town/v/iamseeley/pipeline";
2
3export async function questionAnsweringHandler(req) {
4 if (req.method === "GET") {
5 return new Response(`

exampleSummarizationmain.tsx1 match

@iamseeley•Updated 10 months ago
1import Pipeline from "https://esm.town/v/iamseeley/pipeline";
2
3export async function summarizationHandler(req) {
4 if (req.method === "GET") {
5 return new Response(`

exampleTextGenerationmain.tsx1 match

@iamseeley•Updated 10 months ago
1import Pipeline from "https://esm.town/v/iamseeley/pipeline";
2
3export default async function handler(req) {
4 if (req.method === "GET") {
5 return new Response(`

exampleTextClassificationmain.tsx1 match

@iamseeley•Updated 10 months ago
1import Pipeline from "https://esm.town/v/iamseeley/pipeline";
2
3export default async function handler(req) {
4 if (req.method === "GET") {
5 return new Response(`

hfApiGatewaymain.tsx1 match

@iamseeley•Updated 10 months ago
12};
13
14export async function handler(req) {
15 const url = new URL(req.url);
16 const task = url.searchParams.get("task") || "feature-extraction";

email_authmain.tsx8 matches

@pomdtr•Updated 10 months ago
15};
16
17async function createSessionTable(sessionTableName: string) {
18 await sqlite.execute(`CREATE TABLE ${sessionTableName} (
19 id TEXT NOT NULL PRIMARY KEY,
24}
25
26async function createCodeTable(tableName: string) {
27 await sqlite.execute(`CREATE TABLE ${tableName} (
28 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
33}
34
35async function generateEmailVerificationCode(tableName, email: string): Promise<string> {
36 try {
37 await sqlite.execute({ sql: `DELETE FROM ${tableName} WHERE email = ?`, args: [email] });
53}
54
55async function createSession(tableName: string, valSlug: string, email: string): Promise<Session> {
56 try {
57 const expiresAt = new Date();
78}
79
80async function getSession(tableName: string, sessionID: string, valSlug: string): Promise<Session> {
81 try {
82 const { rows, columns } = await sqlite.execute({
105};
106
107async function getEmailVerificationCode(tableName: string, email: string) {
108 try {
109 const { rows, columns } = await sqlite.execute({
169</html>`;
170
171export function redirect(location: string): Response {
172 return new Response(null, {
173 headers: {
188const cookieName = "auth_session";
189
190export function emailAuth(
191 next: Handler,
192 options?: PasswordAuthOptions,

verifyTokenmain.tsx2 matches

@pomdtr•Updated 10 months ago
1async function fetchUser(token: string): Promise<{ id: string }> {
2 const resp = await fetch("https://api.val.town/v1/me", {
3 headers: {
13}
14
15export async function verifyToken(token: string) {
16 try {
17 const [currentUser, requestUser] = await Promise.all([fetchUser(Deno.env.get("valtown")), fetchUser(token)]);

vtApiTypesmain.tsx8 matches

@neverstew•Updated 10 months ago
501 parameters: {
502 query?: {
503 /** @description The args query parameter can provide arguments to the given val. The parameter needs to be a JSON-encoded array, in which each item in the array is passed to the val as a function parameter. */
504 args?: string;
505 };
536 };
537 };
538 /** @description Provide arguments to the given val function by including a post body with your request. */
539 requestBody?: {
540 content: {
566 * @description Runs `@{username}.{val_name}` as an Express handler.
567 *
568 * `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
569 *
570 * Unlike the other two APIs, the Express API is specified via subdomain and runs at `https://{username}-{val_name}.express.val.run`.
580 get: {
581 responses: {
582 /** @description Function executed successfully */
583 200: {
584 content: {
604 * @description Runs `@{username}.{val_name}` as an Express handler.
605 *
606 * `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
607 *
608 * ### Unauthenticated
622 };
623 responses: {
624 /** @description Function executed successfully */
625 200: {
626 content: {
817 /**
818 * @description The JavaScript or TypeScript expression to be evaluated.
819 * This should be a single expression, like a single function
820 * call, assignment operation, or calculation. If you need
821 * to execute multiple expressions, wrap them in a function.
822 */
823 expression: string;

add_to_habitify_from_todoist_w_aimain.tsx14 matches

@nerdymomocat•Updated 10 months ago
58});
59
60function getHabitifyAreaName(section_id) {
61 if (!section_id) {
62 return ["undefined", ""];
75}
76
77function convertDateObject(due) {
78 function convertToISOWithOffset(datetimeStr, timezoneStr) {
79 const date = new Date(datetimeStr);
80 const [, sign, hours, minutes] = timezoneStr.match(
105 return date_as_string;
106}
107async function getCommentsForTask(taskId) {
108 try {
109 const comments = await todoistapi.getComments({ taskId });
115}
116
117async function resizeAndConvertImage(imageBuffer) {
118 try {
119 const image = await Jimp.read(imageBuffer);
133}
134
135async function downloadImage(url) {
136 try {
137 const response = await fetch(url, {
154}
155
156async function createZodSchema(habitKeys, specialPrompt) {
157 const transformDate = (date) => {
158 if (!date.includes("T")) {
259 return z.object({ habits: habitsListSchema });
260}
261function createPrompt(habitKeys_str, specialPrompt) {
262 let prompt =
263 "You are processing content into a list of habit objects. Based on the options of habits, infer appropriate values for the fields:\n";
287 return prompt;
288}
289async function process_text(habits_list, text, specialPrompt) {
290 // console.log(habits_list);
291 const habitKeys = Object.keys(habits_list);
309}
310
311async function addLog(habit_id, unit_type, value, target_date) {
312 const url = `https://api.habitify.me/logs/${habit_id}`;
313 const headers = {
337 }
338}
339async function addTextNote(habit_id, created, content) {
340 const url = `https://api.habitify.me/notes/${habit_id}`;
341 const headers = {
365}
366
367async function addImageNote(habit_id, created_at, imageBuffer) {
368 const url = `https://api.habitify.me/notes/addImageNote/${habit_id}?created_at=${encodeURIComponent(created_at)}`;
369 const headers = {
390}
391
392async function get_habitify_database()
393{
394 const habits_list = await blob.getJSON("habitify_database");
454}
455
456export default async function(interval: Interval) {
457 const habits_list = await get_habitify_database();
458 var tasks = await todoistapi.getTasks({

dateme_sqlitemain.tsx3 matches

@vawogbemi•Updated 10 months ago
4import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
5
6export function createTable() {
7 return sqlite.execute(`
8 CREATE TABLE IF NOT EXISTS DateMeDocs (
33 (:Id, :Name, :Profile, :Gender, :Age, :Contact, :LastUpdated, :InterestedIn, :Location, :Style, :LocationFlexibility, :Community, :Contact, :LastUpdated, :WorkEmail, :TrustFund, :SixFive, :BlueEyes)`;
34
35export default async function() {
36 let docs = await getDocs();
37 return Response.json(docs);
38}
39
40export async function setupDatabase() {
41 await createTable();
42 const docs = await fetchJSON(thisWebURL());

getFileEmail4 file matches

@shouser•Updated 2 weeks 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
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",