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=1806&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 18163 results for "function"(2038ms)

albhedmain.tsx4 matches

@marcuse•Updated 1 year ago
1export function albhed(text, reverse) {
2 const englishSet = "abcdefghijklmnopqrstuvwxyz";
3 const albhedSet = "ypltavkrezgmshubxncdijfqow";
4 function translate(text, from, to) {
5 return [...text]
6 .map((c) => {
10 .join("");
11 }
12 function englishToAlbhed(text) {
13 return translate(
14 translate(text, englishSet.toUpperCase(), albhedSet.toUpperCase()),
17 );
18 }
19 function albhedToEnglish(text) {
20 return translate(
21 translate(text, albhedSet.toUpperCase(), englishSet.toUpperCase()),

ListenTomain.tsx1 match

@zzz•Updated 1 year ago
3
4// https://api.val.town/v1/express/zzz.ListenTo?val=stevekrouse.whatIsValTown
5export async function ListenTo(req, res) {
6 const { val = "zzz.demoOpenAIGPT4Summary" } = req.query;
7 const url = `https://api.val.town/v1/run/${val.replace("@", "")}`

Tokenizermain.tsx3 matches

@zzz•Updated 1 year ago
28 }
29 }
30 async function loadModel(modelName: Model) {
31 if (!_init) {
32 // Initialize the wasm via discussion in https://github.com/dqbd/tiktoken/issues/22
42 return await load((registry as Registry)[models[modelName]]);
43 }
44 async function buildEncoder(modelName: Model) {
45 const model = await loadModel(modelName);
46 return new Tiktoken(model.bpe_ranks, model.special_tokens, model.pat_str);
47 }
48 async function tokenize(text: string, modelName?: Model) {
49 modelName = modelName ?? "gpt-3.5-turbo";
50 const encoder = await buildEncoder(modelName);

pipemain.tsx1 match

@adamgonda•Updated 1 year ago
1export function pipe<T>(seed: T) {
2 return (...ops: Array<(state: T) => T>) =>
3 ops.reduce((state, action) => action(state), seed);

moveSnakemain.tsx1 match

@adamgonda•Updated 1 year ago
1import { moveBody } from "https://esm.town/v/adamgonda/moveBody";
2
3export function moveSnake(state) {
4 const { snake } = state;
5 return {

postHogAPICapturemain.tsx1 match

@ianvph•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function postHogAPICapture({ key, event, properties, distinct_id }: {
4 key: string;
5 event: string;

fetchJSONmain.tsx1 match

@dvergin•Updated 1 year ago
3export let fetchJSON = async (url: string, options?: any) => {
4 //url must return a JSON in string form
5 //this function parses that string into a javascript object
6 let f = await fetch(url, {
7 ...options,

myApimain.tsx1 match

@ollypolly•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

statemain.tsx2 matches

@abc3354•Updated 1 year ago
3// not working yet, didn't manage to affect dynamic value to @me.__state
4
5export const state = function (
6 id: string,
7 defaultValue: { [key: string]: any }
18 return [
19 __state[id],
20 function (newState) {
21 const newStore = {
22 ...__state,

docFeedbackFormREADME.md2 matches

@timlin•Updated 1 year ago
22
23```js
24function updateFeedback(ref) {
25 let feedback = [...document.getElementsByTagName('a')].find(e => e.innerText == 'Feedback')
26 feedback.setAttribute('href', "https://stevekrouse-docfeedbackform.web.val.run/?ref=" + ref)
30```
31
32Finally, you may be wondering why I queue up feedback in `@stevekrouse.docsFeedback`, a private JSON val, and then process it via [`@stevekrouse.formFeedbackAlert`](https://www.val.town/v/stevekrouse.formFeedbackAlert) instead of sending it along to Discord directly in this val. I [tried that originally](https://www.val.town/v/stevekrouse.docFeedbackForm?v=61) but it felt too slow to wait for the API call to Discord before returning the "Thanks for your feedback" message. This is where the `context.waitUntil` method (that Cloudflare workers and Vercel Edge Functions support) would really come in handy – those allow you to return a Response, and then continue to compute. Currently Val Town requires you to stop all compute with the returning of your Response, so the only way to compute afterwards is to queue it up for another val to take over, and that's what I'm doing here.
33
34

getFileEmail4 file matches

@shouser•Updated 1 week 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": "*",