Search

Results include substring matches and semantically similar vals. Learn more
easrng avatar
generateOnce
@easrng
An interactive, runnable TypeScript val by easrng
Script
import { blob } from "https://esm.town/v/std/blob";
import { ValTownBlobNotFoundError } from "https://esm.town/v/std/ValTownBlobNotFoundError";
export async function generateOnce<S>(fn: () => S | PromiseLike<S>, key): Promise<S> {
let value: any = await blob.getJSON(key);
if (value) return value;
thecybergenius avatar
loanCalculatorApp
@thecybergenius
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function LoanCalculator() {
const [principal, setPrincipal] = useState('');
</div>
function App() {
return <LoanCalculator />;
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
dhvanil avatar
val_Qj8c8xTIqv
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
export default async function handler(req) {
try {
const result = await (async () => {
function findLowestThreeDigitFibonacci() {
let a = 0, b = 1;
let lowestThreeDigit = null;
todepond avatar
labLogin
@todepond
An interactive, runnable TypeScript val by todepond
HTTP
import { email } from "https://esm.town/v/std/email";
import { sqlite } from "https://esm.town/v/std/sqlite";
export default async function(req: Request): Promise<Response> {
const body = await req.json();
let { username, password } = body;
tmalaher avatar
greet
@tmalaher
An interactive, runnable TypeScript val by tmalaher
Script
export function greet(name: string) {
name = name || "world";
return "Hello, " + name + "!";
ritz avatar
hnFollowPollJob
@ritz
An interactive, runnable TypeScript val by ritz
Script
import { hackerNewsAuthors } from "https://esm.town/v/ritz/hackerNewsAuthors";
import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
export async function hnFollowPollJob({ lastRunAt }) {
let posts = await hnLatestPosts({
authors: hackerNewsAuthors,
Maranatha avatar
jobBoardAndChatApp
@Maranatha
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function JobBoard() {
const [jobs, setJobs] = useState([]);
fetchMessages();
async function fetchJobs() {
try {
console.error('Failed to fetch jobs', error);
async function fetchMessages() {
try {
console.error('Failed to fetch messages', error);
async function submitJob(e) {
e.preventDefault();
console.error('Failed to submit job', error);
async function sendMessage(e) {
e.preventDefault();
</div>
function client() {
createRoot(document.getElementById("root")).render(<JobBoard />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
tfayyaz avatar
react_http
@tfayyaz
An interactive, runnable TypeScript val by tfayyaz
Script
export default (component: Function, url: string) =>
function(req: Request) {
return new Response(
`<html>
riagersappe avatar
versatileBrownClownfish
@riagersappe
// Fetches a random joke.
Email
// Fetches a random joke.
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
dhvanil avatar
val_iHF6nZHjLM
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function findLowestThreeDigitFibonacci() {
let fib = [0, 1];
let nextFib = 1;
ingenieroariel avatar
bounds
@ingenieroariel
// View at https://ingenieroariel-bounds.express.val.run?country=UG
Express (deprecated)
import { countries } from "https://esm.town/v/ingenieroariel/countries";
// View at https://ingenieroariel-bounds.express.val.run?country=UG
export async function bounds(req: express.Request, res: express.Response) {
const selected_country =
countries[req.query.country];
seep avatar
subaru
@seep
An API for mysubaru.com to enable remote start and stop. Requires env vars (val.town secrets) named: SUBARU_USERNAME, SUBARU_PASSWORD, SUBARU_DEVICEID, SUBARU_VEHICLEKEY, SUBARU_PIN . The username, password, and PIN should match your mysubaru.com credentials. The device ID and vehicle key can be found by inspecting the request body of a login network request at mysubaru.com.
Script
type ServiceResponse = { id: string; success: boolean };
export async function login() {
const body = new URLSearchParams({
assert(resp.status == 200, `unexpected login response status: ${resp.status}`);
export async function status(id: string): Promise<ServiceResponse> {
const body = new URLSearchParams({
return await parseServiceResponse(res);
export async function start(overrides?: Record<string, string>): Promise<ServiceResponse> {
const opts = Object.assign({
return await parseServiceResponse(res);
export async function stop(overrides?: Record<string, string>): Promise<ServiceResponse> {
const opts = Object.assign({
return await parseServiceResponse(res);
async function parseServiceResponse(res: Response): Promise<ServiceResponse> {
assert(res.status == 200, `unexpected service response status: ${res.status}`);
stevekrouse avatar
githubemail
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Email
export default async function (email: Email) {
console.log(email)
apitman avatar
decentauthhandler
@apitman
An interactive, runnable TypeScript val by apitman
HTTP
sql: `DELETE FROM kv WHERE key GLOB ? || '*'`,
args: [keyPrefix],
export default function decentauthhandler(callback: (req: Request) => Response | Promise<Response>, prefix: string) {
return async (req: Request): Promise<Response> => {
const kvStore = new ValKv();
movienerd avatar
powerfulLimeGuppy
@movienerd
* This clicker game allows users to earn virtual money by clicking. * It includes an upgrade system where users can purchase multiple auto-clickers and dime-smithers. * Each upgrade adds to the overall effect, increasing earnings per second. * Upgrades are hidden until they are unlocked for the first time. * The game state is stored client-side using localStorage for persistence. * React is used for the UI, and setInterval for the auto-upgrade functionality.
HTTP
* The game state is stored client-side using localStorage for persistence.
* React is used for the UI, and setInterval for the auto-upgrade functionality.
/** @jsxImportSource https://esm.sh/react */
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [money, setMoney] = useState(() => {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
async function server(request: Request): Promise<Response> {
return new Response(