21 // seconds
22 ttl?: number;
23} = {}, _fetch = fetch): Promise<Lock> {
24 if (!id) {
25 id = mainReference(({ userHandle, valName }) =>
48 const release = async () =>
49 !isExpired() &&
50 void _fetch(
51 `https://dlock.univalent.net/lock/${id}/release?${
52 searchParams({ lease: _lease })
57 throw new Error("lock is expired");
58 }
59 return _fetch(
60 `https://dlock.univalent.net/lock/${id}/aquire?${
61 searchParams({ lease: _lease, ttl })
72 const acquire = async (max = Date.now() + ttl * 1000): Promise<Lock> => {
73 try {
74 const lockRes = await _fetch(
75 `https://dlock.univalent.net/lock/${id}/aquire?${
76 searchParams({ lease: _lease, ttl })
117 else {
118 // the code might reach here in "no time",
119 // in case _fetch threw an error synchronously (e.g. network error)
120 // so we debounce to a max of 5 attempts (ttl * 1000 is the max time for retries)
121 await sleep(throttleMs);
24 import * as Plot from "https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.9/+esm";
25 import {debounce} from "https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm";
26 const ranks = await (await fetch('https://api.val.town/v1/run/tmcw.big_stories_ranks')).json();
27
28 let allDates = new Set();
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export const privateAPIAuthenticated = fetchJSON(
5 "https://api.val.town/v1/run/stevekrouse.example3",
6 {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export const myIP = () =>
4 fetchJSON("https://api.ipify.org?format=json");
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const fetchText = async (url: string): Promise<string | null> => {
4 try {
5 const response = await fetch(url);
6 if (!response.ok) {
7 throw new Error(`HTTP error! Status: ${response.status}`);
10 }
11 catch (error) {
12 console.error("Failed to fetch feeds:", error);
13 return null;
14 }
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function keriatShemaReminser() {
5 const city = "IL-Jerusalem";
6 const { times } = await (
7 await fetch(
8 `https://www.hebcal.com/zmanim?cfg=json&city=${city}&date=${today}`
9 )
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// GitHub events
4export let githubEvents = fetch("https://lookup.icxk.top");
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const getStatusCode = async (url: string, options?: any) => {
4 let f = await fetch(url, { redirect: "follow", ...(options || {}) });
5 return f.text;
6};
22 document.getElementById("message-input").value = '';
23 const ul = document.getElementById("inbox");
24 const data = await fetch("https://api.val.town/v1/eval/@darrinm.sendChatMessage('" + message + "','"+ sender + "')")
25 .then(res => res.json())
26 .then(res => res.data)
1import { fetchHtmlDom } from "https://esm.town/v/aeaton/fetchHtmlDom";
2
3export async function kpunkShows() {
4 const url = "https://kpunk.libsyn.com/";
5 const dom = await fetchHtmlDom(url);
6 const items = dom.querySelectorAll(".leftnav a[href^='/webpage']");
7 const regex = /^\/webpage\/\d{4}\/\d{2}$/;