logo hsb.horse
← Back to tag index

Tags

#typescript

Blog posts, snippets, and glossary entries related to "typescript", gathered in one place.

Entries 46
  1. Blog
    TypeScript Monorepo Best Practices for 2026

    A practical TypeScript monorepo guide for 2026. Compare pnpm + Turborepo vs pnpm + Biome, when to use Project References, and when each setup makes sense.

  2. Glossary
    Biome

    Biome is a Rust-based formatter and linter for JavaScript and TypeScript that unifies code formatting and static analysis.

  3. Snippets
    Dynamic Import Caching

    Lightweight TypeScript implementation for caching dynamic imports. Handle multiple imports to the same path with a single Promise.

  4. Snippets
    File System API Permission Check

    Function to check and request permissions for browser File System API. Supports both read-only and read-write modes.

  5. Snippets
    Merging Uint8Arrays

    A TypeScript function to merge multiple Uint8Arrays into one. Useful for combining binary data.

  6. Snippets
    Node.js File Check

    Promise-based function to check if a path is a file in Node.js. Returns false on error.

  7. Snippets
    React useSelection Hook

    Custom React hook for managing multi-item selection state. Type-safe handling of select all, partial selection, and individual selection.

  8. Snippets
    SHA256 Synchronous Implementation (Without WebCrypto API)

    A pure JavaScript SHA256 implementation without using the WebCrypto API. For environments where the crypto object is unavailable, such as some Web Workers implementations.

  9. Snippets
    Splitting Text with TransformStream

    A TypeScript example using ReadableStream and TransformStream to split long text into chunks of specified size.

  10. Snippets
    TypeScript Array Utilities

    Collection of type-safe utility functions for common array operations in TypeScript development. Empty array generation, chunking, null filtering, and shuffling.

  11. Snippets
    TypeScript p-limit Implementation

    TypeScript reimplementation of p-limit for controlling Promise concurrency. Achieve concurrency control without adding dependencies.

  12. Snippets
    TypeScript yocto-queue Implementation

    TypeScript reimplementation of lightweight queue yocto-queue. Provides basic operations: enqueue, dequeue, iterator.

  13. Snippets
    Build-time Message ID Hash Store

    A TypeScript function that hashes and shortens message IDs and contexts at build time. Useful when a target platform restricts allowed translation keys.

  14. Snippets
    Bulk Import with Fallback from Pairwise COPY to Individual Inserts

    First attempt bulk import for large relational data, then fall back to individual inserts for rows that violate schema constraints. Balances speed and success rate.

  15. Snippets
    Cache-First, Live-Fetch Orchestration Pattern

    Orchestration combining a fast path from cache and a slow path from remote. Measures cache hit/miss, fetch latency, and final outcome as metrics, delegating side effects outward.

  16. Snippets
    Clone a Native UI Element to Inherit Styles

    A lightweight pattern that maintains visual consistency by cloning existing host app buttons with cloneNode, then replacing only the icon and text. No need to fight obfuscated CSS.

  17. Snippets
    Entity-Embedded Cooldown Warning Suppression

    A pattern that embeds repeated warning suppression logic within the quota entity itself. Properly controls frequent warnings like rate limit notices and billing alerts.

  18. Snippets
    Idempotent DOM Observer Setup via dataset

    A simple pattern using data attributes to prevent duplicate MutationObserver registrations. No global registry needed, highly portable.

  19. Snippets
    Layered DOM Observation Strategy

    A pattern for progressively switching to narrower observers once the app is ready. Broadly reusable in SPA content scripts and third-party DOM integrations.

  20. Snippets
    Property Extractor Helper Function

    Generate a function that extracts only specified properties from an object. Consolidate type-safe property extraction into one line for nested mapBy and array transformations.

  21. Snippets
    Two-Phase Repository Walk with Byte Budget

    Split processing into path/size scan → structure analysis → read only needed chunks → parse to make memory limits controllable even for large repositories.

  22. Snippets
    Worker Pool with Sub-batches and Per-sub-batch Timeout

    A pattern that splits large datasets into small sub-batches sent to workers, reducing memory pressure while setting timeouts per batch for early anomaly detection.

  23. Blog
    Encrypting a Byte Stream in the Browser with Web Crypto

    Web Crypto gives you strong primitives but no stream interface. This post shows how to encrypt ReadableStream<Uint8Array> using the encryption subpath of @hsblabs/web-stream-extras — covering file encryption, per-stream key management, and pipeline composition.

  24. Blog
    I Got Tired of Rewriting the Same Web Streams Boilerplate

    Why I packaged my recurring ReadableStream<Uint8Array> utilities into @hsblabs/web-stream-extras — covering the three patterns I kept rewriting, the ByteTransformStream base, and stream encryption via Web Crypto.

  25. Blog
    Releasing @hsblabs/web-stream-extras

    A small TypeScript utility library for working with ReadableStream<Uint8Array> in browsers and Node.js — covering byte conversion helpers, transform streams, and stream encryption via the Web Crypto API.

  26. Snippets
    Image Extension Regex

    JavaScript/TypeScript regex pattern to detect image formats from filenames. Supports png, webp, jpg, jpeg, avif, gif.

  27. Blog
    Implementing a Development-Only Live Editor in Astro Projects

    How to implement a browser-based editor limited to development mode in Astro. Using Vite middleware and React to make development content management comfortable without affecting production builds at all.

  28. Snippets
    Implementing a Lightweight Result Type in TypeScript

    An error handling pattern without try-catch. Type-safe error handling with a Result type that separates data and error.

  29. Snippets
    Lazy-Initialized Object

    A TypeScript pattern using getters to generate values only on first access. Lightweight lazy evaluation compared to memory caching.

  30. Snippets
    Polyfill for crypto.randomUUID

    A polyfill implementation of the crypto.randomUUID function. While all browsers now support this, it serves as a useful reference for understanding how UUID v4 works.

  31. Snippets
    Time-Based Semantic Version Generation

    A TypeScript function that automatically generates version numbers from build timestamps. Useful when version limits exist, such as in Chrome extensions.

  32. Snippets
    TypeScript Non-null Assertion

    TypeScript type guard functions to eliminate undefined and null. Ensures both runtime errors and type safety.

  33. Snippets
    Uint32Array Helper Functions

    A concise TypeScript wrapper for `new Uint32Array` calls. Supports all constructor overloads with type-safe overload definitions.

  34. Snippets
    Uint8Array Helper Functions

    A TypeScript wrapper to simplify new Uint8Array calls. Supports arrays, ArrayBuffers, and length-based initialization patterns.

  35. Blog
    Implementing CRC32 hashing in TypeScript

    Steps to implement the CRC32 hashing algorithm in TypeScript. Organizes speed-up techniques using lookup tables and actual usage examples.

  36. Blog
    Line-Oriented Text Splitting with TransformStream: LineSplitTransform

    A TransformStream implementation that splits binary stream data into lines. Useful for incremental processing of log files and text streams.

  37. Blog
    A TypeScript Utility Function to Convert Values into ReadableStream

    A utility function that converts strings, objects, and more into ReadableStream. A way to handle streams as arbitrary types without going through Blob.

  38. Blog
    Implementing CIDR range IP address determination with TypeScript

    For environments where external modules such as CloudFront Function cannot be used, we have implemented our own IP address determination within the CIDR range. Organized the implementation of class syntax using bitwise operations.

  39. Blog
    Reimplementing generate-project-summary.py with Bun + TypeScript

    A Bun + TypeScript rewrite of a Python project-summary script. Covers the path to a portable executable for feeding whole repositories into an LLM.

  40. Blog
    TypeScript Implementation for Sorting Media Files by Resolution

    A concise TypeScript implementation for sorting videos or images by resolution (width × height). Useful for ordering Twitter media variants.

  41. Blog
    Generate Lotto 6 and Lotto 7 Numbers in TypeScript

    A TypeScript implementation that generates Lotto 6 and Lotto 7 numbers with the Mersenne Twister. A practical example of a pseudorandom number generator.

  42. Blog
    Requesting an IAM-Protected API Gateway from TypeScript

    How to send a TypeScript request from local development to an API Gateway protected by IAM authentication using SigV4 from the AWS SDK for JavaScript.

  43. Blog
    TypeScript implementation to generate images from HTMLVideoElement

    A TypeScript implementation that uses Canvas and VideoElement to extract the current frame of a video as an image. Organized the method of generating blobs based on promises.

  44. Blog
    My First Vite Plugin Implementation: Automatically Generate Build Metadata

    How to plug custom logic into the Vite build lifecycle with the Vite Plugin API. Learn through a plugin that generates time-based semantic version metadata.

  45. Blog
    TypeScript implementation of steganography using variant selectors

    A TypeScript implementation of a steganography method that leverages Unicode's variant selector to embed hidden, invisible strings into text.

  46. Blog
    TypeScript Implementation to Extract Size Information from Twitter Video URLs

    A TypeScript implementation that extracts resolution information from Twitter (X) video URLs with a regular expression. A quick summary of the URL pattern and how to read the size.