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%22Optional%20title%22?q=function&page=2410&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 28783 results for "function"(1980ms)

val_wdRvdd0aOOmain.tsx3 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function isPrime(num) {
6 if (num <= 1) return false;
7 for (let i = 2; i <= Math.sqrt(num); i++) {
11}
12
13function findLowestThreeDigitPrime() {
14 for (let num = 100; num < 1000; num++) {
15 if (isPrime(num)) {

val_E1oovKNSVpmain.tsx2 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function fibonacci() { let a = 0, b = 1; while (b < 1000) { let temp = b; b = a + b; a = temp; } return b;}
6
7fibonacci();

val_6ob0t5Fmjmmain.tsx3 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function isPrime(num) {
6 if (num <= 1) return false;
7 for (let i = 2; i <= Math.sqrt(num); i++) {
11}
12
13function findLowestThreeDigitPrime() {
14 for (let num = 100; num < 1000; num++) {
15 if (isPrime(num)) {

val_T3Axgfc7n3main.tsx2 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function fibonacci() {
6 let a = 0, b = 1;
7 let lowestThreeDigit = 0;

val_dO1pTtU7X9main.tsx3 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function isPrime(num) {
6 if (num <= 1) return false;
7 for (let i = 2; i <= Math.sqrt(num); i++) {
11}
12
13function findLowestThreeDigitPrime() {
14 for (let num = 100; num < 1000; num++) {
15 if (isPrime(num)) {

val_Qj8c8xTIqvmain.tsx2 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function findLowestThreeDigitFibonacci() {
6 let a = 0, b = 1;
7 let lowestThreeDigit = null;

val_S1NNtqMDtfmain.tsx3 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function isPrime(num) {
6 if (num <= 1) return false;
7 for (let i = 2; i <= Math.sqrt(num); i++) {
11}
12
13function findLowestThreeDigitPrime() {
14 for (let num = 100; num < 1000; num++) {
15 if (isPrime(num)) {

val_9Vk5LnFz7tmain.tsx2 matches

@dhvanil•Updated 7 months ago
1
2 export default async function handler(req) {
3 try {
4 const result = await (async () => {
5 function fibonacci() {
6 let a = 0, b = 1;
7 while (b < 1000) {

openaiDefinermain.tsx7 matches

@willthereader•Updated 7 months ago
3const openai = new OpenAI();
4
5export default async function(req: Request): Promise<Response> {
6 log.info("Request received:", req.method, req.url);
7
35}
36
37export async function parseRequest(req: Request): Promise<{ selection: string; followUp: string; context: string[] }> {
38 const body = await req.text();
39 log.debug("Request body:", body);
51}
52
53export function prepareMessages(selection: string, followUp: string, context: string[]): Array<Object> {
54 const contextString = context.length > 0 ? `Consider the following context: ${context.join(", ")}. ` : "";
55 const messages = [
82}
83
84export function streamResponse(stream: ReadableStream): Response {
85 const encoder = new TextEncoder();
86
108}
109
110export function handleError(error: Error): Response {
111 log.error("Error occurred:", error);
112
123}
124
125export function handleCorsPreflightRequest(): Response {
126 return new Response(null, {
127 headers: {
142const currentLogLevel = logLevels.INFO; // Adjust this to change logging level
143
144function formatMessage(level: string, message: string, ...args: any[]): string {
145 const timestamp = new Date().toISOString();
146 return `${timestamp} [${level}] ${message} ${args.join(" ")}`;

multilingualchatroommain.tsx9 matches

@daisuke•Updated 7 months ago
109};
110
111function Banner({ message, isVisible, language }) {
112 if (!isVisible) return null;
113 return <div className="banner">{message[language] || message.en}</div>;
114}
115
116function UserList({ users, t }) {
117 return (
118 <div className="user-list">
129}
130
131function Sidebar({ users, language, handleLanguageChange, roomUrl, copyToClipboard, copied, t }) {
132 return (
133 <div className="sidebar">
165}
166
167function TypingIndicator({ typingUsers, t }) {
168 if (typingUsers.length === 0) return null;
169
180}
181
182function App() {
183 const [messages, setMessages] = useState([]);
184 const [inputMessage, setInputMessage] = useState("");
506}
507
508function client() {
509 createRoot(document.getElementById("root")).render(<App />);
510}
511if (typeof document !== "undefined") { client(); }
512
513export default async function server(request: Request): Promise<Response> {
514 const url = new URL(request.url);
515 const { blob } = await import("https://esm.town/v/std/blob");
524 const TIME_WINDOW = 60 * 1000; // 1 minute
525
526 async function checkRateLimit() {
527 const now = Date.now();
528 const rateLimit = await blob.getJSON(RATE_LIMIT_KEY) || { count: 0, timestamp: now };
539 }
540
541 async function translateText(text: string, targetLanguage: string, sourceLanguage: string): Promise<string> {
542 const cacheKey = `${KEY}_translation_${sourceLanguage}_${targetLanguage}_${text}`;
543 const cachedTranslation = await blob.getJSON(cacheKey);

getFileEmail4 file matches

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

tuna8 file matches

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