ReadableStream.getReader(): readers and stream locking
getReader() returns a reader and locks the stream. Reading is asynchronous; releaseLock() releases the lock without canceling the stream.
CKTIS / JavaScript
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
getReader() returns a reader and locks the stream. Reading is asynchronous; releaseLock() releases the lock without canceling the stream.
pipeThrough() routes stream data to a supplied pair’s writable side and immediately returns its readable side. It supports chaining transformations with backpressure propagation; it does not return a completion promise.
pipeTo() transfers chunks to a WritableStream, respects backpressure, and returns a promise for completion.
Request represents a request for Fetch. Its constructor prepares the URL, method, headers, and optional body without sending anything. The body is a stream: reading it affects whether it can be reused.
requestAnimationFrame requests a one-shot callback during a rendering update. It lets you animate using elapsed time rather than assuming a fixed number of frames per second.
requestIdleCallback schedules nonurgent work during browser idle periods. Its callback receives an estimated time budget, but must split work and yield control itself.
ResizeObserver reports element sizes even when the window does not resize. It lets a component respond to available space without repeatedly polling the DOM.
The disconnect() method stops observing every element registered with one ResizeObserver instance. It does not destroy the observer: observe() can start observation again.
ResizeObserverEntry describes one element in a ResizeObserver notification. Its target property identifies the element, while contentRect provides its dimensions. Learn the distinction between an HTML content box and an SVG bounding box.
ResizeObserver.observe registers an element for asynchronous size notifications. The box option selects the observed area.
The unobserve(target) method removes one element from a ResizeObserver's observations while leaving its other targets unchanged.
Response represents a Fetch API response: its status, headers, and body. The body is read asynchronously.
The response.blob() method reads the entire response body and returns a Promise<Blob> containing its bytes.
The static Response.json() method creates a response containing JSON data. Do not confuse it with response.json(), which reads a response body.
Response.ok is a read-only Boolean property indicating whether the response status is in the inclusive range 200–299.
Response.status exposes a response’s numeric status code. Distinguish the HTTP status, the ok property, and rejection of the fetch() promise.
Response.text() reads the entire response body and returns a Promise containing text decoded as UTF-8.
Selection represents document selection. Learn rangeCount and how to attach a range using addRange.
Selection.getRangeAt(0) returns the Range object associated with the document selection, not a copy.
Selection.removeAllRanges() empties the document selection without deleting text or nodes. The method takes no arguments and returns undefined.
sessionStorage stores string key-value pairs for an origin and a tab session. It suits temporary state such as a form draft, but accessing storage or writing to it can fail.
setInterval() schedules repeated function calls with a requested delay in milliseconds. Its returned identifier lets you stop the timer with clearInterval(); exact execution timing is not guaranteed.
setTimeout schedules a function to run once without blocking the current code. The delay does not guarantee an exact execution time, and the returned identifier lets you cancel the pending invocation.
ShadowRoot represents the root of a Shadow DOM tree associated with a host element. It provides access to a component's internal structure. The open and closed modes differ in access through host.shadowRoot, but neither creates a security boundary.