Return to top
ran
homeranuiranutsarticlesdoc editor
English
  • 简体中文
  • English
  • 日本語
  • Español
  • Português
  • 한국어
  • Deutsch
  • فارسی
  • Overview
  • API reference (all 454 exports)
  • Choosing a utility
  • Utility Functions
    • Functional Programming
      • debounce - Debounce function
      • throttle - Throttle function
      • once / singleFlight - Run exactly once
      • QuestQueue - Concurrency-limited queue
      • withTimeout / deferred - Promise primitives
      • noop - No-op function
      • compose - Compose middleware
    • String Processing
      • md5 - MD5 hash function
      • randomString / getRandomString - Generate random string
      • clearBr - Remove spaces and line breaks
      • clearStr - Remove leading/trailing spaces
      • truncate - Shorten with an ellipsis
      • strParse - Parse string to object
      • toString - Convert to string
      • transformText - ArrayBuffer to text
      • checkEncoding - Detect encoding
      • getMatchingSentences - Extract sentences
      • isString - Check if string
      • detectLanguage - Detect text language
      • resolveLocale - Pick the active locale
      • segmentByRanges - Offsets & highlights
    • Object Processing
      • merge / mergeExports - Merge objects
      • isEqual - Deep comparison
      • cloneDeep - Deep clone
      • querystring - Object to query string
      • filterObj - Filter object
      • formatJson - Format JSON
    • Number Processing
      • range / clamp / lerp / remap / smoothstep - Interpolation & remapping
      • mathjs - Precise calculation
      • perToNum - Percentage to number
      • transformNumber - Format number
      • addNumSym - Add sign to number
      • parseChineseNumber - Human-written numbers
    • Color Processing
      • hexToRgb - Hex to RGB
      • rgbToHex - RGB to hex
      • randomColor - Generate random color
      • Color - Color classes & conversions
      • hexToAlpha / rgbaToRgb - Alpha helpers
      • blendScreen / luma / cosinePalette - Shader-math blend helpers
    • Time Processing
      • formatDuration / formatRelative - Format time
      • parseVttTimestamp / parseVttCueTiming - WebVTT subtitle timing
      • formatDate - Format a date
      • performanceTime - High precision timestamp
    • Device Detection
      • isMobile - Check mobile device
      • isWeiXin - Check WeChat browser
      • isClient - Check client environment
      • isSafari - Check Safari browser
      • currentDevice - Get device type
      • watchMediaQuery - Watch a media query
    • DOM Manipulation
      • addClassToElement - Add class
      • removeClassToElement - Remove class
      • createDocumentFragment - Create fragment
      • escapeHtml - Escape HTML
      • Chain - Chainable DOM
      • create - Create DOM element
      • EventManager / createDoubleTapDetector - Scoped listeners & double-tap
      • adoptStyles - Shadow DOM CSS
      • computePlacement - Floating panel flip/shift
      • setFontSize2html - Flexible rem scaling
    • Storage
      • localStorage helpers - Safe storage
      • createStore - Prefixed JSON storage
      • WebDB - IndexedDB wrapper
      • createHandoff - Hand a file across pages
      • readFileAs* - Read File / Blob
      • zip - Read & rewrite ZIP archives
    • URL/Query
      • getAllQueryString - Extract query
      • queryFlag / isInIframe - Boolean flags & embedding
      • encodeUrl - Encode URL safely
      • appendUrl - Append query params
      • createLocalePath - i18n URL maths
    • Cookie
      • getCookie - Get cookie
      • getCookieByName - Get cookie by regex
    • Image Processing
      • convertImageToBase64 - Image to Base64
      • isImageSize - Validate image size
      • getImage / cutRound / opacity - Canvas image ops
    • Media
      • AudioRecorder - Record to a Blob
      • createSpeechRecognizer - Speech to text
    • Performance
      • getPerformance - Get performance metrics
      • getFrame - Calculate frame rate
      • getPixelRatio - Get resolution ratio
    • Network
      • imageRequest - Test network latency
      • networkSpeed - Test network speed
      • connection - Get network info
      • getStatus / status - HTTP status code lookup
      • prefetch - Warm the cache when idle
      • WorkerClient - Worker request/response
      • paginateText - Paginate text into pages
    • Browser
      • getWindow - Get window size
      • report - Telemetry beacons
      • handleConsole - Instrumentation hooks
      • createObjectURL / requestUrlToBuffer - Create object URL
    • Script Loading
      • scriptOnLoad - Dynamic script loading
      • loadScript - Single script, de-duplicated
    • Error Handling
      • handleConsole - Intercept console
      • handleError - Global error handling
      • handleFetchHook - Intercept fetch
    • Others
      • TOTP - One-time password generator
      • createSignal - Create reactive signal
      • setMime / MimeType - Set MIME type
      • getExtensions - Get extensions
      • SyncHook - Sync event hook
      • durationHandler - Delayed execution
      • task - Statistical execution time
  • File Operations
    • writeFile - Write to file
    • readFile - Read file
    • readDir - Read directory
    • watchFile - Watch file changes
    • queryFileInfo - Query file info
    • appendFile - Append to file
  • MIME Type
    • getMime - Get MIME type
  • Canvas & Animation
    • Canvas 2D geometry - Paths & gradients
    • tween - Easing functions
  • i18n
    • Internationalisation engine
  • 2D Rendering (visual)
    • Rendering engine
  • Virtual DOM (vnode)
    • Virtual DOM
  • Streaming (stream)
    • Streaming model responses
  • Conversation (conversation)
    • Event log to nodes
  • Service Worker (sw)
    • Caching & precache
  • Node Server
    • HTTP server & router
  • Bridge (postMessage)
    • Cross-context messaging

handleFetchHook / handleXhrHook

See Instrumentation hooks: both instrument network traffic and return a restore function.

Previous pagehandleError - Global error handlingNext pageTOTP - One-time password generator