{"id":48885,"library":"path-source","title":"path-source","description":"Read files in Node.js or fetch URLs in browsers as standard WhatWG readable streams. Version 0.1.3 provides a unified API for streaming file I/O and HTTP responses. Designed for incremental data processing, it returns a ReadableStream reader with `read()` and `cancel()` methods. In Node, it wraps file streams; in browsers, it uses the Fetch API with streaming support when available, falling back to XMLHttpRequest. Lightweight and zero-dependency for the core feature, but requires `array-source` in older browsers. Part of a family of stream sources by Mike Bostock.","status":"active","version":"0.1.3","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/mbostock/path-source","tags":["javascript","fetch","stream","reader"],"install":[{"cmd":"npm install path-source","lang":"bash","label":"npm"},{"cmd":"yarn add path-source","lang":"bash","label":"yarn"},{"cmd":"pnpm add path-source","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is a function; CommonJS: const path = require('path-source')","wrong":"import { path } from 'path-source'","symbol":"path","correct":"import path from 'path-source'"}],"quickstart":{"code":"import path from 'path-source';\nimport process from 'process';\n\npath('README.md')\n  .then(async (source) => {\n    let result;\n    while (!(result = await source.read()).done) {\n      process.stdout.write(result.value);\n    }\n  })\n  .catch(err => console.error(err));","lang":"javascript","description":"Reads a file as a stream and writes chunks to stdout. Demonstrates async iteration and proper cleanup."},"warnings":[{"fix":"Ensure array-source is loaded when using in older browsers (or use polyfills).","message":"In browsers, path() returns a ReadableStream reader only if the browser supports streaming fetch. Otherwise it falls back to array-source which loads the entire resource into memory.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Treat value consistently as a Uint8Array; use TextDecoder if you need string output.","message":"The stream reader's read() method returns an object with value as Uint8Array (or Buffer). In Node, value is a Buffer; in browsers, it is a Uint8Array.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.1.3':19 'api':23,58 'array':80 'array-sourc':79 'avail':63 'back':65 'bostock':94 'browser':12,53,84 'cancel':44 'core':75 'data':34 'depend':72 'design':31 'fall':64 'famili':88 'featur':76 'fetch':9,57,96 'file':5,26,50 'http':29 'i/o':27 'increment':33 'javascript':95 'lightweight':68 'method':45 'mike':93 'node':47 'node.js':7 'older':83 'part':85 'path':2 'path-sourc':1 'process':35 'provid':20 'read':4,42 'readabl':16 'readablestream':39 'reader':40,98 'requir':78 'respons':30 'return':37 'sourc':3,81,91 'standard':14 'stream':17,25,51,60,90,97 'support':61 'unifi':22 'url':10 'use':55 'version':18 'whatwg':15 'wrap':49 'xmlhttprequest':67 'zero':71 'zero-depend':70","created_at":"2026-06-07T16:58:57.685079+00:00","updated_at":"2026-06-07T16:58:57.685079+00:00","problems":[{"fix":"Use `import path from 'path-source'` or `const path = require('path-source')`","cause":"Using named import instead of default import.","error":"TypeError: path is not a function"},{"fix":"Ensure you are calling path() which returns a promise resolving to a source object with .read() method.","cause":"Using the promise result incorrectly: may have chained improperly or used array-source directly.","error":"Uncaught TypeError: source.read is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mbostock/path-source","github":"ssh://git@github.com/mbostock/path-source","docs":null,"changelog":null,"pypi":null,"npm":"path-source","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}