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/$%7Bsuccess?q=function&page=2358&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 27609 results for "function"(1825ms)

OpenAImain.tsx1 match

@arthrodโ€ขUpdated 8 months ago
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.

valWallmain.tsx7 matches

@iamseeleyโ€ขUpdated 8 months ago
35});
36
37async function generateGraph(username) {
38 console.log(`Fetching contributions for ${username}`);
39 try {
56}
57
58async function fetchContributions(username) {
59 const contributionMap = {};
60 const valsUrl = `https://api.val.town/v1/alias/${username}/vals`;
90}
91
92async function fetchValVersions(valId, contributionMap, creationDate) {
93 const versionsUrl = `https://api.val.town/v1/vals/${valId}/versions`;
94 try {
119}
120
121function generateContributionGraph(contributionData) {
122 const dates = Object.keys(contributionData).sort();
123 if (dates.length === 0) {
166}
167
168function generateMonthLabels(weeks) {
169 const months = [];
170 weeks.forEach(week => {
186}
187
188function getContributionLevel(count) {
189 if (count === 0) return 0;
190 if (count < 3) return 1;
194}
195
196function getContributionColor(level) {
197 const colors = ['#ebedf0', '#9be9a8', '#40c463', '#30a14e', '#216e39'];
198 return colors[level];

spacexcalendarmain.tsx1 match

@moeโ€ขUpdated 8 months ago
3import moment from "npm:moment-timezone"
4
5export default async function(req: Request): Promise<Response> {
6 const data = await spacexCalendar()
7 // return Response.json(data)

spacexapimain.tsx11 matches

@moeโ€ขUpdated 8 months ago
1import cheerio from "npm:cheerio@1.0.0-rc.12"
2
3export default async function(req: Request): Promise<Response> {
4 const data = await getLaunches()
5 return Response.json(data)
6}
7
8export async function getLaunches() {
9 var y10to19 = await loadPage(
10 "https://en.wikipedia.org/wiki/List_of_Falcon_9_and_Falcon_Heavy_launches_(2010%E2%80%932019)",
29}
30
31async function loadPage(url) {
32 const response = await fetch(url)
33 const body = await response.text()
36}
37
38function getRows($, h2Selector, tableSelector, parseFunc) {
39 var launchesH2 = $(h2Selector).parent()
40 var launchesTable = launchesH2.nextAll(tableSelector)
41
42 var rows = launchesTable.find("tr")
43 rows = rows.filter(function(i, el) {
44 if ($(this).find("th").length > 2) return false // hide header
45 // if ($(this).find("td").first().attr("colspan") == 6) return false // hide year rows
51}
52
53function parseFutureRows(rows, $) {
54 var launches = []
55 var launch: any = {}
56 rows.each(function(i, el) {
57 $(this).find("br").replaceWith(" ")
58 var children = $(this).children()
82 return launches
83}
84function parsePastRows(rows, $) {
85 var launches = []
86 var launch: any = {}
87 rows.each(function(i, el) {
88 $(this).find("br").replaceWith(" ")
89 var children = $(this).children()
115}
116
117function getPayloadIcon(text) {
118 if (text.toLowerCase().includes("starlink")) return "๐Ÿ›ฐ"
119 if (text.toLowerCase().includes("gps")) return "๐Ÿ“"
127}
128
129function removeReferences(string) {
130 return string.replace(/\[\d+\]/g, "").replace(/\n$/g, "").replace(/\u00A0/g, " ")
131}

extremePlumCariboumain.tsx4 matches

@ejfoxโ€ขUpdated 8 months ago
5import { marked } from "https://esm.sh/marked";
6
7function App() {
8 const [vals, setVals] = useState([]);
9 const [error, setError] = useState(null);
119}
120
121async function fetchEmojiForName(name) {
122 try {
123 const response = await fetch(`/emoji/${encodeURIComponent(name)}`);
133}
134
135function client() {
136 createRoot(document.getElementById("root")).render(<App />);
137}
139if (typeof document !== "undefined") { client(); }
140
141async function server(request: Request): Promise<Response> {
142 const url = new URL(request.url);
143 const { pathname } = url;

allvalsindexmain.tsx5 matches

@ejfoxโ€ขUpdated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5// Function to get a random emoji
6function getRandomEmoji() {
7 const emojis = ['๐Ÿ˜€', '๐Ÿ˜Ž', '๐Ÿค–', '๐Ÿ‘ป', '๐Ÿš€', '๐ŸŒˆ', '๐Ÿ•', '๐ŸŽ‰', '๐Ÿ’ก', '๐Ÿ”ฅ', '๐ŸŒŸ', '๐Ÿฆ„'];
8 return emojis[Math.floor(Math.random() * emojis.length)];
9}
10
11function App() {
12 const [vals, setVals] = useState([]);
13 const [error, setError] = useState(null);
79}
80
81function client() {
82 createRoot(document.getElementById("root")).render(<App />);
83}
85if (typeof document !== "undefined") { client(); }
86
87async function server(request: Request): Promise<Response> {
88 const { pathname } = new URL(request.url);
89

combinedEmeraldTunamain.tsx1 match

@jmpailhonโ€ขUpdated 8 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

favouriteYellowShrewmain.tsx1 match

@jmpailhonโ€ขUpdated 8 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

btcPriceAlertmain.tsx1 match

@jmpailhonโ€ขUpdated 8 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

deliberateLavenderMongoosemain.tsx1 match

@ubykโ€ขUpdated 8 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

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.