Tags
#typescript
Blog posts, snippets, and glossary entries related to "typescript", gathered in one place.
- BlogTypeScript 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.
- GlossaryBiome
Biome is a Rust-based formatter and linter for JavaScript and TypeScript that unifies code formatting and static analysis.
- SnippetsDynamic Import Caching
Lightweight TypeScript implementation for caching dynamic imports. Handle multiple imports to the same path with a single Promise.
- SnippetsFile System API Permission Check
Function to check and request permissions for browser File System API. Supports both read-only and read-write modes.
- SnippetsMerging Uint8Arrays
A TypeScript function to merge multiple Uint8Arrays into one. Useful for combining binary data.
- SnippetsNode.js File Check
Promise-based function to check if a path is a file in Node.js. Returns false on error.
- SnippetsReact useSelection Hook
Custom React hook for managing multi-item selection state. Type-safe handling of select all, partial selection, and individual selection.
- SnippetsSHA256 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.
- SnippetsSplitting Text with TransformStream
A TypeScript example using ReadableStream and TransformStream to split long text into chunks of specified size.
- SnippetsTypeScript Array Utilities
Collection of type-safe utility functions for common array operations in TypeScript development. Empty array generation, chunking, null filtering, and shuffling.
- SnippetsTypeScript p-limit Implementation
TypeScript reimplementation of p-limit for controlling Promise concurrency. Achieve concurrency control without adding dependencies.
- SnippetsTypeScript yocto-queue Implementation
TypeScript reimplementation of lightweight queue yocto-queue. Provides basic operations: enqueue, dequeue, iterator.
- SnippetsBuild-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.
- SnippetsBulk 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.
- SnippetsCache-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.
- SnippetsClone 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.
- SnippetsEntity-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.
- SnippetsIdempotent DOM Observer Setup via dataset
A simple pattern using data attributes to prevent duplicate MutationObserver registrations. No global registry needed, highly portable.
- SnippetsLayered 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.
- SnippetsProperty 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.
- SnippetsTwo-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.
- SnippetsWorker 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.
- BlogEncrypting 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.
- BlogI 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.
- BlogReleasing @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.
- SnippetsImage Extension Regex
JavaScript/TypeScript regex pattern to detect image formats from filenames. Supports png, webp, jpg, jpeg, avif, gif.
- BlogImplementing 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.
- SnippetsImplementing 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.
- SnippetsLazy-Initialized Object
A TypeScript pattern using getters to generate values only on first access. Lightweight lazy evaluation compared to memory caching.
- SnippetsPolyfill 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.
- SnippetsTime-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.
- SnippetsTypeScript Non-null Assertion
TypeScript type guard functions to eliminate undefined and null. Ensures both runtime errors and type safety.
- SnippetsUint32Array Helper Functions
A concise TypeScript wrapper for `new Uint32Array` calls. Supports all constructor overloads with type-safe overload definitions.
- SnippetsUint8Array Helper Functions
A TypeScript wrapper to simplify new Uint8Array calls. Supports arrays, ArrayBuffers, and length-based initialization patterns.
- BlogImplementing CRC32 hashing in TypeScript
Steps to implement the CRC32 hashing algorithm in TypeScript. Organizes speed-up techniques using lookup tables and actual usage examples.
- BlogLine-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.
- BlogA 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.
- BlogImplementing 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.
- BlogReimplementing 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.
- BlogTypeScript 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.
- BlogGenerate 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.
- BlogRequesting 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.
- BlogTypeScript 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.
- BlogMy 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.
- BlogTypeScript 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.
- BlogTypeScript 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.
hsb.horse