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/$%7Bart_info.art.src%7D?q=function&page=2679&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 29176 results for "function"(1841ms)

dailyDadJokemain.tsx1 match

@tomasholub•Updated 1 year ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

prism_feature_notificationsmain.tsx3 matches

@stevekrouse•Updated 1 year ago
5const confidenceThreshold = 0.8;
6
7function randomlyPickFeature(featuresAboveConfidenceThreshold) {
8 return featuresAboveConfidenceThreshold[Math.floor(Math.random() * featuresAboveConfidenceThreshold.length)];
9}
10
11function getFeatureLink(feature) {
12 const { index } = feature;
13 return `https://thesephist--prism-start-app.modal.run/f/${modelName}/${index}?layout=2`;
14}
15
16export default async function(interval: Interval) {
17 const response = await fetch(dictionaryUrl);
18 const { features } = await response.json();

jwkToDidKey_testsmain.tsx1 match

@vladimyr•Updated 1 year ago
218if (jwk.y) console.assert(jwk.y === resolvedJwk.y);
219
220async function resolveDid(did: string) {
221 const data = await ky.get(`https://dev.uniresolver.io/1.0/identifiers/${did}`).json();
222 return data.verificationMethod.at(0).publicKeyJwk;

jwkToDidKeymain.tsx2 matches

@vladimyr•Updated 1 year ago
17};
18
19export function jwkToMultibase(jwk: JWK) {
20 if (jwk.kty === "OKP") {
21 const bytes = base64url.baseDecode(jwk.x);
32}
33
34export function jwkToDidKey(jwk: JWK) {
35 const keyMultibase = jwkToMultibase(jwk);
36 return `did:key:${keyMultibase}`;

libecmain.tsx3 matches

@vladimyr•Updated 1 year ago
5import { secp256k1 } from "npm:@noble/curves/secp256k1";
6
7export function decompressPoint(bytes: Uint8Array, curve: string) {
8 if (curve === "P-256") {
9 const point = p256.ProjectivePoint.fromHex(bytes);
17}
18
19function pointToBytes<T>(point: ProjPointType<T>, Fp: IField<T>) {
20 const x = Fp.toBytes(point.x);
21 const y = Fp.toBytes(point.y);
24
25// @see: https://stackoverflow.com/questions/17171542/algorithm-for-elliptic-curve-point-compression
26export function compressPoint({ x, y }: { x: Uint8Array; y: Uint8Array }) {
27 const compressed = new Uint8Array(x.length + 1);
28 compressed[0] = 2 + (y.at(-1) & 1);

counterscaleWeeklyReportmain.tsx2 matches

@benvinegar•Updated 1 year ago
5
6// borrowed from: https://github.com/benvinegar/counterscale/blob/main/app/analytics/query.ts#L24
7function accumulateCountsFromRowResult(
8 counts,
9 row: {
22}
23
24export default async function(interval: Interval) {
25 // you need to declare these two environment variables:
26

roseDragonmain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function uploadTo0x0(data, name) {
4 const blob = new Blob([data]);
5 const formData = new FormData();

claudemain.tsx1 match

@yawnxyz•Updated 1 year ago
11};
12
13export async function prompt(
14 text,
15 { mode = "text", model = "opus", max_tokens = 1024, messages = [] } = {},

viewSourcemain.tsx1 match

@crif•Updated 1 year ago
3import { escape } from "npm:html-sloppy-escaper";
4
5export default async function viewSource(req: Request) {
6 const pathname = new URL(req.url).pathname;
7 const html = await fetchText(

telemetrymain.tsx18 matches

@saolsen•Updated 1 year ago
218];
219
220async function migrate() {
221 await std_sqlite.execute(`
222 create table if not exists tracing_schema (
369}
370
371export async function init(
372 url: string | URL,
373): Promise<void> {
394}
395
396export function tracer(): Tracer {
397 return otelTrace.getTracer("val.town");
398}
399
400export function attribute(name: string, value: string): void {
401 otelTrace.getActiveSpan()?.setAttribute(name, value);
402}
403
404export function event(name: string, attrs: Record<string, string>): void {
405 otelTrace.getActiveSpan()?.addEvent(name, attrs);
406}
407
408export function trace<
409 // deno-lint-ignore no-explicit-any
410 F extends (...args: any[]) => any,
428}
429
430export async function traceAsync<
431 // deno-lint-ignore no-explicit-any
432 F extends (...args: any[]) => any,
454}
455
456export function traced<
457 // deno-lint-ignore no-explicit-any
458 F extends (...args: any[]) => any,
459>(name: string, f: F) {
460 return async function (
461 ...args: Parameters<F>
462 ): Promise<Awaited<ReturnType<F>>> {
470 * be tied together.
471 */
472export async function fetch(
473 input: string | URL,
474 init?: RequestInit,
511}
512
513async function tracedExecute(statement: InStatement): Promise<ResultSet> {
514 return await tracer().startActiveSpan(
515 `sqlite:execute`,
544}
545
546async function tracedBatch(
547 statements: InStatement[],
548 mode?: TransactionMode,
603 * Takes an http handler and returns a new handler that
604 * traces the request.
605 * @returns {Function} A new handler that traces the request.
606 */
607export function tracedHandler(
608 handler: (req: Request) => Promise<Response>,
609): (req: Request) => Promise<Response> {
610 async function _tracedHandler(req: Request): Promise<Response> {
611 let active_context = null;
612 const prop_header = req.headers.get("b3");
930
931 const render_spans: SelectSpan[] = [];
932 function push_span(span_id: string) {
933 const span = spans_by_id.get(span_id)!;
934 render_spans.push(span);
1069
1070 const render_spans: SelectSpan[] = [];
1071 function push_span(span_id: string) {
1072 const span = spans_by_id.get(span_id)!;
1073 render_spans.push(span);
1246});
1247
1248export async function traceViewer(req: Request): Promise<Response> {
1249 await migrate();
1250 return await app.fetch(req);
tuna

tuna9 file matches

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