A typed HTTP client built on the Fetch API with automatic retries, timeouts, request/response interceptors, and a [data, error] tuple return style that eliminates try/catch at the call site.
import request from "@utils/request";| import { z } from "astro/zod"; | |
| export function formDataToObject( | |
| formData: FormData, | |
| ): Record<string, FormDataEntryValue | FormDataEntryValue[]> { | |
| const obj = Object.create(null) as Record<string, FormDataEntryValue | FormDataEntryValue[]>; | |
| for (const [key, value] of formData.entries()) { | |
| if (Object.hasOwn(obj, key)) { | |
| const currentValue = obj[key]; |
| <script lang="ts"> | |
| import InputError from './InputError.svelte'; | |
| import { actions, type ActionReturnType } from 'astro:actions'; | |
| const { result }: { | |
| result: ActionReturnType<typeof actions.getGreeting> | |
| } = $props(); | |
| let name = $state(result?.data?.fields.name || ''); | |
| let surname = $state(result?.data?.fields.surname || ''); |
| function _init() | |
| offsetx=240 | |
| offsety=135 | |
| x=0+offsetx | |
| y=0+offsety | |
| radius=50 | |
| theta=0 | |
| end |
| // Faster | |
| function html() { | |
| const base = arguments[0]; | |
| if (!arguments[1]) return base[0]; | |
| let html = base[0]; | |
| for (let i = 1; i < arguments.length; i++) { | |
| html += arguments[i]; | |
| if (base[i]) html += base[i]; | |
| } | |
| return html; |
| .content-grid { | |
| --padding: 1rem; | |
| --content-max-width: 700px; | |
| --breakout-max-width: 900px; | |
| justify-items: center; | |
| display: grid; | |
| grid-auto-flow: row; | |
| } | |
| .content-grid > * { | |
| box-sizing: border-box; |
| function random(from = 0, to = 1) { | |
| return Math.random() * (to - from) + from; | |
| } | |
| export default random; |
| # Load version control information | |
| autoload -Uz vcs_info | |
| precmd() { vcs_info } | |
| precmd_functions+=( precmd_vcs_info ) | |
| # Format the vcs_info_msg_0_ variable | |
| zstyle ':vcs_info:git:*' formats ' · %b' | |
| # Set up the prompt (with git branch name) | |
| setopt PROMPT_SUBST |
| import fs from 'fs'; | |
| import { IncomingForm } from 'formidable'; | |
| import csvParser from 'csv-parser'; | |
| export default async (req, res) => { | |
| const data = await new Promise((resolve, reject) => { | |
| const form = new IncomingForm() | |
| form.parse(req, (err, fields, files) => { | |
| if (err) return reject(err); |
| import React, { createContext, useContext, useState } from "react"; | |
| const Context = createContext({}); | |
| export function AuthContextProvider({ children }) { | |
| const [ auth, setAuth ] = useState(null); | |
| return ( | |
| <Context.Provider value={ { auth, setAuth } }> | |
| { children } |