oldfashionedmain.tsx9 matches
23const { styleRoute, StyleTag } = styleSystem();
2425function MaterialsList() {
26const c = useContext(RequestContext);
27const mats = getMaterialIds(c);
76}
7778function RecipesList() {
79const c = useContext(RequestContext);
80const s = c?.req.param("slug");
131} as const;
132133function Units() {
134const requestContext = useContext(RequestContext);
135let unit = getCookie(requestContext!, "units") || "";
162});
163164function getTitle(recipe: Recipe | undefined): string {
165if (!recipe) {
166return "Old Fashioned";
169}
170171function parseUnit(unit: string | undefined): Fmt {
172if (unit === "CL" || unit === "Ml" || unit === "Oz") {
173return unit;
176}
177178function WelcomeMessage() {
179return (
180<plank id="recipe-detail" hx-swap-oob="true">
203}
204205function RecipeDetail() {
206const c = useContext(RequestContext);
207const s = c?.req.param("slug") || "";
257}
258259function IngredientDisplay({ ingredient, unit }: {
260ingredient: Ingredient;
261unit: keyof typeof units;
292}
293294function Index() {
295const requestContext = useContext(RequestContext);
296const s = requestContext?.req.param("slug") || "";
styleSystemmain.tsx2 matches
3import { Context } from "npm:hono@3.8.1";
45export function styleSystem() {
6function StyleTag() {
7return (
8<style
getMaterialsmain.tsx1 match
3import { Context } from "npm:hono@3.8.1";
45export function getMaterials(c: Context | null) {
6const ids = getMaterialIds(c);
7return Object.values(materials).filter((mat) => ids.has(mat.id));
getMaterialIdsmain.tsx1 match
2import { Context } from "npm:hono@3.8.1";
34export function getMaterialIds(c: Context | null) {
5if (!c) return new Set();
6try {
2import { Recipe } from "https://esm.town/v/tmcw/Recipe";
34export function sort(recipes: Map<string, Recipe>, materials: Material[]) {
5const have = new Set(materials.map((m) => m.name));
6
56/** Get a cookie from the request or optionally from inflight */
7export function getCookie(c: Context, key: string): string | undefined {
8const inflight = getInflight(c);
9if (inflight.has(key)) {
56/** Set a cookie and keep track of it inflight */
7export function setCookie(c: Context, key: string, value: string) {
8const inflight = getInflight(c);
9inflight.set(key, value);
getInflightmain.tsx1 match
2import { Context } from "npm:hono@3.8.1";
34export function getInflight(c: Context) {
5return InflightCookies.get(c) || new Map();
6}
formatFloatmain.tsx1 match
2425// TODO: refactor
26export function formatFloat(a: number) {
27const intPart = Math.floor(a);
28const remainder = Math.floor((a - intPart) * 100);
34const stream = test.createStream({ objectMode: true });
5stream.on("data", function(row) {
6console.log(JSON.stringify(row));
7});
89test("timing test", function(t) {
10t.plan(2);
1112t.equal(typeof Date.now, "function");
13var start = Date.now();
1415setTimeout(function() {
16t.equal(Date.now() - start, 100);
17}, 100);
1920export const testing = new Promise(resolve => {
21stream.on("end", function(row) {
22resolve("ok");
23});