Versions
- Open: VersionChanges from v18 to v19+1-1⦚ 15 unchanged lines ⦚/**
* @typedef {Function} privacyCallbackFilterFn* @param {"private" | "unlisted" | "public"} kind* @returns {boolean}⦚ 24 unchanged lines ⦚⦚ 15 unchanged lines ⦚/*** @callback privacyCallbackFilterFn* @param {"private" | "unlisted" | "public"} kind* @returns {boolean}⦚ 24 unchanged lines ⦚ - Open: VersionChanges from v17 to v18+1-0⦚ 18 unchanged lines ⦚* @param {"private" | "unlisted" | "public"} kind* @returns {boolean}/*** @param {string=} prefix - prefix of val names⦚ 21 unchanged lines ⦚⦚ 18 unchanged lines ⦚* @param {"private" | "unlisted" | "public"} kind* @returns {boolean}**//*** @param {string=} prefix - prefix of val names⦚ 21 unchanged lines ⦚
- Open: VersionChanges from v16 to v17+4-0⦚ 15 unchanged lines ⦚/**
* @param {string=} prefix - prefix of val names* @param {privacyCallbackFilterFn=} privacyCallbackFn* @returns {Promise<number>} - how many bytes used by those vals⦚ 19 unchanged lines ⦚⦚ 15 unchanged lines ⦚/*** @typedef {Function} privacyCallbackFilterFn* @param {"private" | "unlisted" | "public"} kind* @returns {boolean}/*** @param {string=} prefix - prefix of val names* @param {privacyCallbackFilterFn=} privacyCallbackFn* @returns {Promise<number>} - how many bytes used by those vals⦚ 19 unchanged lines ⦚ - Open: VersionChanges from v15 to v16+13-1⦚ 6 unchanged lines ⦚const add = (a, b) => (a + b);export const getAllUsedByBlobs = async (prefix = "") => {return (await blob.list(prefix)).map((item) => item.size).reduce(add, 0);};export const getAllUsedByVals = async (prefix = "", privacyCallbackFn = (_) => true) => {const myUserUUID = await getMyValTownUserUUID();⦚ 3 unchanged lines ⦚).map((item) => (item.code.length)).reduce(add, 0);};export const getAllUsed = async () => {return (await Promise.all([⦚ 5 unchanged lines ⦚⦚ 6 unchanged lines ⦚const add = (a, b) => (a + b);/*** @param {string=} prefix - prefix of blob keys* @returns {Promise<number>} - how many bytes used by those blobs**/export const getAllUsedByBlobs = async (prefix = "") => {return (await blob.list(prefix)).map((item) => item.size).reduce(add, 0);};/*** @param {string=} prefix - prefix of val names* @param {privacyCallbackFilterFn=} privacyCallbackFn* @returns {Promise<number>} - how many bytes used by those vals**/export const getAllUsedByVals = async (prefix = "", privacyCallbackFn = (_) => true) => {const myUserUUID = await getMyValTownUserUUID();⦚ 3 unchanged lines ⦚).map((item) => (item.code.length)).reduce(add, 0);};/*** @returns {Promise<number>}**/export const getAllUsed = async () => {return (await Promise.all([⦚ 5 unchanged lines ⦚
- Open: VersionChanges from v14 to v15+3-9⦚ 7 unchanged lines ⦚const add = (a, b) => (a + b);
const getAllUsedByBlobs = async (prefix = "") => {return (await blob.list(prefix)).map((item) => item.size).reduce(add, 0);};const getAllUsedByVals = async (prefix = "", privacyCallbackFn = (_) => true) => {const myUserUUID = await getMyValTownUserUUID();const allMyVals = await getAllValsOfUser(myUserUUID);return allMyVals.filter((item) => (privacyCallbackFn(item.privacy) && item.name.startsWith(prefix))).map((item) => (item.code.length)).reduce(add, 0);};const getAllUsed = async () => {return (await Promise.all([getAllUsedByBlobs(),getAllUsedByVals(),])).reduce(add, 0);};export const quota = {getAllUsedByBlobs,getAllUsedByVals,getAllUsed,};⦚ 7 unchanged lines ⦚const add = (a, b) => (a + b);export const getAllUsedByBlobs = async (prefix = "") => {return (await blob.list(prefix)).map((item) => item.size).reduce(add, 0);};export const getAllUsedByVals = async (prefix = "", privacyCallbackFn = (_) => true) => {const myUserUUID = await getMyValTownUserUUID();const allMyVals = await getAllValsOfUser(myUserUUID);return allMyVals.filter((item) => (privacyCallbackFn(item.privacy) && item.name.startsWith(prefix))).map((item) => (item.code.length)).reduce(add, 0);};export const getAllUsed = async () => {return (await Promise.all([getAllUsedByBlobs(),getAllUsedByVals(),])).reduce(add, 0);}; - Open: VersionChanges from v13 to v14+2-26// @ts-check jsimport { API_URL } from "https://esm.town/v/std/API_URL";const VALTOWN_API_URL = API_URL.concat("/v1");import { getMyValTownUserUUID } from "https://esm.town/v/zarutian/getMyValTownUserUUID";
import { blob } from "https://esm.town/v/std/blob";// const VALTOWN_API_URL = "https://api.val.town/v1";const getValsOfUser = async (ValTownUserUUID) => {const results = [];const saekja = async (url) => {(await (await fetch(url, {headers: {Authorization: `Bearer ${Deno.env.get("valtown")}`,Accept: "application/json",},})).json());return { data: [], links: { next: "l"} };};let done = false;let url = `${VALTOWN_API_URL}/users/${ValTownUserUUID}/valsoffset=0&limit=20`;while (!done) {const r = await saekja(url);done = (r.data.length == 0);url = r.links.next;r.data.forEach((item) => results.push(item));}return results;};////const add = (a, b) => (a + b);⦚ 4 unchanged lines ⦚const getAllUsedByVals = async (prefix = "", privacyCallbackFn = (_) => true) => {// @ts-check jsimport { API_URL } from "https://esm.town/v/std/API_URL";const VALTOWN_API_URL = API_URL.concat("/v1");import { getMyValTownUserUUID } from "https://esm.town/v/zarutian/getMyValTownUserUUID";import { getAllValsOfUser } from "https://esm.town/v/zarutian/getAllValsOfUser";import { blob } from "https://esm.town/v/std/blob";const add = (a, b) => (a + b);⦚ 4 unchanged lines ⦚const getAllUsedByVals = async (prefix = "", privacyCallbackFn = (_) => true) => {const myUserUUID = await getMyValTownUserUUID();const allMyVals = await getAllValsOfUser(myUserUUID);return allMyVals.filter((item) => (privacyCallbackFn(item.privacy) && item.name.startsWith(prefix))⦚ 15 unchanged lines ⦚ - Open: VersionChanges from v12 to v13+1-1// @ts-check jsimport { API_URL } from "https://esm.town/v/std/API_URL";const VALTOWN_API_URL = API_URL.concat("/v1");
import { blob } from "https://esm.town/v/std/blob";import { getMyValTownUserUUID } from "https://esm.town/v/zarutian/getMyValTownUserUUID";// const VALTOWN_API_URL = "https://api.val.town/v1";⦚ 50 unchanged lines ⦚// @ts-check jsimport { API_URL } from "https://esm.town/v/std/API_URL";const VALTOWN_API_URL = API_URL.concat("/v1");import { getMyValTownUserUUID } from "https://esm.town/v/zarutian/getMyValTownUserUUID";import { blob } from "https://esm.town/v/std/blob";// const VALTOWN_API_URL = "https://api.val.town/v1";⦚ 50 unchanged lines ⦚ - Open: VersionChanges from v11 to v12+1-1⦚ 18 unchanged lines ⦚};let done = false;
let url = `${VALTOWN_API_URL}/v1/users/${ValTownUserUUID}/valsoffset=0&limit=20`;while (!done) {const r = await saekja(url);⦚ 34 unchanged lines ⦚⦚ 18 unchanged lines ⦚};let done = false;let url = `${VALTOWN_API_URL}/users/${ValTownUserUUID}/valsoffset=0&limit=20`;while (!done) {const r = await saekja(url);⦚ 34 unchanged lines ⦚ - Open: Version+56-0// @ts-check jsimport { API_URL } from "https://esm.town/v/std/API_URL";const VALTOWN_API_URL = API_URL.concat("/v1");import { blob } from "https://esm.town/v/std/blob";import { getMyValTownUserUUID } from "https://esm.town/v/zarutian/getMyValTownUserUUID";// const VALTOWN_API_URL = "https://api.val.town/v1";const getValsOfUser = async (ValTownUserUUID) => {const results = [];const saekja = async (url) => {(await (await fetch(url, {headers: {Authorization: `Bearer ${Deno.env.get("valtown")}`,Accept: "application/json",},})).json());return { data: [], links: { next: "l"} };};let done = false;let url = `${VALTOWN_API_URL}/v1/users/${ValTownUserUUID}/valsoffset=0&limit=20`;while (!done) {const r = await saekja(url);done = (r.data.length == 0);url = r.links.next;r.data.forEach((item) => results.push(item));}return results;};////const add = (a, b) => (a + b);const getAllUsedByBlobs = async (prefix = "") => {return (await blob.list(prefix)).map((item) => item.size).reduce(add, 0);};
Updated: January 19, 2024