Back
Version 1
12/12/2023
import { api } from "https://esm.town/v/pomdtr/api";
export async function getReverseDependencies(valUrlOrSlug: string) {
// clean the url or slug
const initialSlug = valUrlOrSlug.includes("/v/")
? valUrlOrSlug.split("/v/")[1]
: valUrlOrSlug;
// we leave the trailing quote off, in case its imported with a "?v=X" version string
// this does leave open the possibility of capturing vals that have this val as a
// prefix like (bob/getData and bob/getData). Search also returns vals where the
// search appears in the readme. We'll filter all these out later.
const searchString = ` from "https://esm.town/v/${initialSlug}`;
const { data } = await api(`/v1/search/vals?query=${encodeURI(searchString)}&offset=0&limit=100`);
console.log(data);
}
Updated: March 2, 2024