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=1393&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 18516 results for "function"(2857ms)

squishyformmain.tsx14 matches

@yawnxyz•Updated 6 months ago
39 let currentHistoryIndex = -1;
40
41 function updateStore(newData, source) {
42 const currentData = $parsedResult.get();
43 if (JSON.stringify(newData) !== JSON.stringify(currentData)) {
75
76
77 function undo() {
78 if (currentHistoryIndex > 0) {
79 currentHistoryIndex--;
83 }
84
85 function redo() {
86 if (currentHistoryIndex < history.length - 1) {
87 currentHistoryIndex++;
105 });
106
107 function debounce(func, delay) {
108 return function() {
109 const context = this;
110 const args = arguments;
118 inputText.addEventListener('input', debouncedSubmit);
119
120 function startTimer() {
121 startTime = Date.now();
122 stopTimer(); // Ensure any existing timer is stopped
124 }
125
126 function stopTimer() {
127 clearInterval(timerInterval);
128 timerInterval = null; // Clear the interval reference
132 }
133
134 function updateTimer() {
135 const elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2);
136 timerDisplay.textContent = elapsedTime + 's llama3-groq-8b-8192';
137 }
138
139 async function submitForm() {
140 const input = inputText.value.trim();
141 const system = systemText.value.trim();
209 let isEditorFocused = false;
210
211 function updateResultText(data) {
212 const existingMonacoEditor = result.querySelector('#monaco-editor');
213
220
221 require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.30.1/min/vs' }});
222 require(['vs/editor/editor.main'], function() {
223 editor = monaco.editor.create(editorContainer, {
224 value: JSON.stringify(data, null, 2),
289 }
290
291 function updateTable(data) {
292 if (!result.querySelector('#resultTable')) {
293 const table = document.createElement('table');
359 }
360
361 function createEmptyRow() {
362 const row = document.createElement('tr');
363 const keyCell = document.createElement('td');
379 }
380
381 function createEditableInput(value, key, type) {
382 const input = document.createElement('input');
383 input.type = 'text';

qrCodeWebhookmain.tsx5 matches

@d17e•Updated 6 months ago
7}
8
9function generateQrSVGPaths(
10 qrData: boolean[][],
11 penWidth: number,
20 const overlap = true;
21
22 function createPath(
23 startX: number,
24 startY: number,
30 }
31
32 function visitRow(visited: boolean[][], y: number, startX: number, endX: number) {
33 for (let x = startX; x <= endX; x++) {
34 visited[y][x] = true;
36 }
37
38 function visitColumn(visited: boolean[][], x: number, startY: number, endY: number) {
39 for (let y = startY; y <= endY; y++) {
40 visited[y][x] = true;
113}
114
115export default async function(request: Request): Promise<Response> {
116 if (request.method !== "POST" && request.method !== "GET") {
117 return new Response("Method Not Allowed", { status: 405 });

webdavServermain.tsx1 match

@pomdtr•Updated 6 months ago
7};
8
9export function serveVals(
10 req: Request,
11 options?: WebdavOptions,

publicKeyPem_examplemain.tsx2 matches

@vladimyr•Updated 6 months ago
50console.log(rsaPublicKeyPem);
51
52function parsePem(pem: string) {
53 pem = pem.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "");
54 return base64pad.baseDecode(pem);
55}
56
57function wrap(input: string, columns = 64) {
58 const reLines = new RegExp(`.{${columns}}`, "g");
59 return input.replace(reLines, (line) => line + "\n");

avidPeachBoamain.tsx3 matches

@vladimyr•Updated 6 months ago
49console.log(publicKeyPem);
50
51function pkiFromPkcs1(pkcs1: ArrayBuffer) {
52 return new pki.PublicKeyInfo({
53 // algorithm: publicKeyInfo.algorithm,
60}
61
62function parsePem(pem: string) {
63 pem = pem.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "");
64 return base64pad.baseDecode(pem);
65}
66
67function wrap(input: string, columns = 64) {
68 const reLines = new RegExp(`.{${columns}}`, "g");
69 return input.replace(reLines, (line) => line + "\r\n");

simpletextmain.tsx1 match

@nbbaier•Updated 6 months ago
84};
85
86export default async function(req: Request): Promise<Response> {
87 const url = new URL(req.url);
88 const pageKeys = (await blob.list()).filter(e => e.key.split("/")[0] === nameSpacePrefix).map(e => e.key);

uniswapV3Positionmain.tsx19 matches

@midnightlightning•Updated 6 months ago
15 * the rate limit more time to reset.
16 */
17async function retryOnRateLimit<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
18 for (let i = 0; i < maxRetries; i++) {
19 try {
32
33/**
34 * This is the main function that looks up information about a Uniswap V3 position.
35 * Given a position ID in the URL, it fetches all the details about that position
36 * including what tokens are involved, their current prices, and whether the position
37 * is currently active.
38 */
39export default async function(req: Request): Promise<Response> {
40 // Get the target token ID from URL path
41 const firstPath = req.url.split("/")[3];
61 address: "0xc36442b4a4522e871399cd717abdd847ab11fe88",
62 abi: parseAbi([
63 "function positions(uint256 tokenId) external view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)",
64 ]),
65 functionName: "positions",
66 args: [tokenId],
67 }));
90 // Fetch info about the two tokens in the position
91 const erc20ABI = parseAbi([
92 "function name() view returns (string)",
93 "function symbol() view returns (string)",
94 "function decimals() view returns (uint8)",
95 ]);
96
102 address: token0,
103 abi: erc20ABI,
104 functionName: "name",
105 },
106 {
107 address: token0,
108 abi: erc20ABI,
109 functionName: "symbol",
110 },
111 {
112 address: token0,
113 abi: erc20ABI,
114 functionName: "decimals",
115 },
116 {
117 address: token1,
118 abi: erc20ABI,
119 functionName: "name",
120 },
121 {
122 address: token1,
123 abi: erc20ABI,
124 functionName: "symbol",
125 },
126 {
127 address: token1,
128 abi: erc20ABI,
129 functionName: "decimals",
130 },
131 ],
147 address: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
148 abi: parseAbi([
149 "function getPool(address tokenA, address tokenB, uint24 fee) external view returns (address)",
150 ]),
151 functionName: "getPool",
152 args: [token0, token1, fee],
153 }));
164 address: poolAddress,
165 abi: parseAbi([
166 "function slot0() external view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)",
167 ]),
168 functionName: "slot0",
169 }));
170 } catch (err) {
211 * to be precise but not so many that it becomes hard to read
212 */
213 function formatPrice(price: BigNumber) {
214 return price.toPrecision(20);
215 }

inventiveAmethystSheepmain.tsx2 matches

@temptemp•Updated 6 months ago
1export default async function(req: Request): Promise<Response> {
2 // Define your .ts file URLs
3 const urls = [
32 };
33
34 // Call the function to concatenate files
35 const concatenatedData = await concatenateFiles();
36

PhoenixProxymain.tsx1 match

@cephalization•Updated 6 months ago
3const HOSTED_PHOENIX_BASE_URL = "https://llamatrace.com";
4// const HOSTED_PHOENIX_BASE_URL = "https://app.phoenix.arize.com";
5export default async function(req: Request) {
6 if (req.method === "OPTIONS") {
7 return new Response(null, {

preciseAquamarineReptilemain.tsx6 matches

@stevekrouse•Updated 6 months ago
6import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
7
8function App() {
9 const [prompt, setPrompt] = useState("hello llamapalooza");
10 const [code, setCode] = useState("");
21
22 useEffect(() => {
23 function handleKeyDown(e: KeyboardEvent) {
24 if (e.key === "ArrowLeft" && currentIndex > 0) {
25 setCurrentIndex(i => i - 1);
39 }, [currentIndex, history]);
40
41 async function handleSubmit(e: React.FormEvent) {
42 e.preventDefault();
43 setLoading(true);
131}
132
133function client() {
134 createRoot(document.getElementById("root")!).render(<App />);
135}
139}
140
141function extractCodeFromFence(text: string): string {
142 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
143 return htmlMatch ? htmlMatch[1].trim() : text;
144}
145
146export default async function server(req: Request): Promise<Response> {
147 if (req.method === "POST") {
148 const client = new Cerebras();

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