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=727&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 7308 results for "function"(723ms)

submitPRmain.tsx1 match

@nbbaier•Updated 1 year ago
2type PR = Parameters<typeof Octokit["rest"]["pulls"]["create"]>;
3
4export async function submitPR(ghToken: string, ...pr: PR) {
5 return new Octokit({ auth: ghToken }).rest.pulls.create(pr);
6}

submitPRREADME.md1 match

@nbbaier•Updated 1 year ago
20## Parameters
21
22The function takes two parameters: your gh access token and an object that's identical to the object submitted to the gh API. See [GH's documentation](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request) for more info!
23
24

valToGHREADME.md2 matches

@nbbaier•Updated 1 year ago
1# valToGH
2
3A utility function for programmatically updating a GitHub repository with code retrieved from a Val.
4
5**NOTE**: This function currently does not change the contents of a file if it is already present. I will however be adding that functionality.
6
7## Usage

untitled_indigoWrenmain.tsx1 match

@tmcw•Updated 1 year ago
1import { delay } from "https://deno.land/std/async/delay.ts";
2
3async function write(text: string) {
4 const textEncoder = new TextEncoder();
5 const data = textEncoder.encode(text);

sqliteDumpREADME.md4 matches

@nbbaier•Updated 1 year ago
1# SQLite Dump Util
2
3A utility function that generates SQL statements to dump the data and schema of tables in a SQLite database.
4
5## Usage
25```
26
27## Function Signature
28
29```typescript
30function sqliteDump(tables?: string[], callback?: ((result: string) => string | void | Promise<void>) | undefined): Promise<string | void>
31```
32
34
35- `tables`: (Optional) Array of table names to include in the dump. If not provided, all tables will be included.
36- `callback`: (Optional) An (potentially async) callback function to process the dump result. The callback receives the dump string as its argument.
37

dbToAPImain.tsx1 match

@nbbaier•Updated 1 year ago
6
7// TODO: implement options
8export async function createServer(db, options: Options & { auth?: { username: string; password: string } } = {}) {
9 const app = new Hono();
10

updateValByIDmain.tsx1 match

@nbbaier•Updated 1 year ago
11}
12
13export function updateValByID({ token, valId, code, name, readme, privacy }: UpdateValArgs): Promise<any> {
14 const body: Record<string, unknown> = {
15 token,

updateValByNamemain.tsx1 match

@nbbaier•Updated 1 year ago
7}
8
9export function updateValByName({ token, code, name }: UpdateValArgs): Promise<any> {
10 const body: Record<string, unknown> = {
11 token,

fetchPaginatedDataREADME.md1 match

@nbbaier•Updated 1 year ago
1# Fetch Paginated Data
2
3This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with `next` and there to be a `data` property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:

paginatedResponseREADME.md2 matches

@nbbaier•Updated 1 year ago
1# Return a paginated response
2
3A helper function to take an array and return a paginated response. This is useful when defining one's own folders for [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:
8const data = [...]
9
10export default async function(req: Request): Promise<Response> {
11 return paginatedResponse(req, data);
12}

getFileEmail4 file matches

@shouser•Updated 5 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago