pax_global_header00006660000000000000000000000064136460521660014523gustar00rootroot0000000000000052 comment=a3625cb4181c4bcdf09884e677d4320c641b8724 stream-browserify-3.0.0/000077500000000000000000000000001364605216600152075ustar00rootroot00000000000000stream-browserify-3.0.0/.airtap.yml000066400000000000000000000006521364605216600172730ustar00rootroot00000000000000sauce_connect: true loopback: airtap.local browsers: - name: chrome version: latest - name: firefox # extended support releases 52, 60, 68 version: [52, 60, 68, latest] - name: safari version: 9..latest - name: iphone version: latest - name: ie version: 9..latest - name: microsoftedge version: 13..latest browserify: - plugin: ./test/use-stream.js - require: tape expose: tape stream-browserify-3.0.0/.github/000077500000000000000000000000001364605216600165475ustar00rootroot00000000000000stream-browserify-3.0.0/.github/FUNDING.yml000066400000000000000000000012211364605216600203600ustar00rootroot00000000000000# These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/stream-browserify community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] stream-browserify-3.0.0/.gitignore000066400000000000000000000000151364605216600171730ustar00rootroot00000000000000node_modules stream-browserify-3.0.0/.npmrc000066400000000000000000000000231364605216600163220ustar00rootroot00000000000000package-lock=false stream-browserify-3.0.0/.travis.yml000066400000000000000000000010421364605216600173150ustar00rootroot00000000000000os: linux dist: bionic language: node_js jobs: include: - name: Run browser tests with airtap node_js: stable script: npm run test:browsers addons: sauce_connect: true hosts: - airtap.local - name: Test on stable Node.js node_js: stable - name: Test on Node.js 12.x node_js: 12 - name: Test on Node.js 10.x node_js: 10 - name: Test on Node.js 8.x node_js: 8 - name: Test on Node.js 6.x node_js: 6 - name: Test on Node.js 4.x node_js: 4 stream-browserify-3.0.0/CHANGELOG.md000066400000000000000000000005031364605216600170160ustar00rootroot00000000000000# stream-browserify change log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## 3.0.0 * Upgrade to `readable-stream` 3. For breaking changes, see the [readable-stream notes](https://github.com/nodejs/readable-stream#version-3xx). stream-browserify-3.0.0/LICENSE000066400000000000000000000020521364605216600162130ustar00rootroot00000000000000MIT License Copyright (c) James Halliday Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. stream-browserify-3.0.0/index.js000066400000000000000000000074101364605216600166560ustar00rootroot00000000000000// Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. module.exports = Stream; var EE = require('events').EventEmitter; var inherits = require('inherits'); inherits(Stream, EE); Stream.Readable = require('readable-stream/lib/_stream_readable.js'); Stream.Writable = require('readable-stream/lib/_stream_writable.js'); Stream.Duplex = require('readable-stream/lib/_stream_duplex.js'); Stream.Transform = require('readable-stream/lib/_stream_transform.js'); Stream.PassThrough = require('readable-stream/lib/_stream_passthrough.js'); Stream.finished = require('readable-stream/lib/internal/streams/end-of-stream.js') Stream.pipeline = require('readable-stream/lib/internal/streams/pipeline.js') // Backwards-compat with node 0.4.x Stream.Stream = Stream; // old-style streams. Note that the pipe method (the only relevant // part of this class) is overridden in the Readable class. function Stream() { EE.call(this); } Stream.prototype.pipe = function(dest, options) { var source = this; function ondata(chunk) { if (dest.writable) { if (false === dest.write(chunk) && source.pause) { source.pause(); } } } source.on('data', ondata); function ondrain() { if (source.readable && source.resume) { source.resume(); } } dest.on('drain', ondrain); // If the 'end' option is not supplied, dest.end() will be called when // source gets the 'end' or 'close' events. Only dest.end() once. if (!dest._isStdio && (!options || options.end !== false)) { source.on('end', onend); source.on('close', onclose); } var didOnEnd = false; function onend() { if (didOnEnd) return; didOnEnd = true; dest.end(); } function onclose() { if (didOnEnd) return; didOnEnd = true; if (typeof dest.destroy === 'function') dest.destroy(); } // don't leave dangling pipes when there are errors. function onerror(er) { cleanup(); if (EE.listenerCount(this, 'error') === 0) { throw er; // Unhandled stream error in pipe. } } source.on('error', onerror); dest.on('error', onerror); // remove all the event listeners that were added. function cleanup() { source.removeListener('data', ondata); dest.removeListener('drain', ondrain); source.removeListener('end', onend); source.removeListener('close', onclose); source.removeListener('error', onerror); dest.removeListener('error', onerror); source.removeListener('end', cleanup); source.removeListener('close', cleanup); dest.removeListener('close', cleanup); } source.on('end', cleanup); source.on('close', cleanup); dest.on('close', cleanup); dest.emit('pipe', source); // Allow for unix-like usage: A.pipe(B).pipe(C) return dest; }; stream-browserify-3.0.0/package.json000066400000000000000000000022701364605216600174760ustar00rootroot00000000000000{ "name": "stream-browserify", "version": "3.0.0", "description": "the stream module from node core for browsers", "main": "index.js", "dependencies": { "inherits": "~2.0.4", "readable-stream": "^3.5.0" }, "devDependencies": { "airtap": "^1.0.2", "safe-buffer": "^5.1.2", "tape": "^4.13.0", "through": "^2.3.8" }, "scripts": { "test": "node test", "test:browsers": "airtap -- test/index.js" }, "repository": { "type": "git", "url": "git://github.com/browserify/stream-browserify.git" }, "homepage": "https://github.com/browserify/stream-browserify", "keywords": [ "stream", "browser", "browserify" ], "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "license": "MIT", "testling": { "files": "test/*.js", "browsers": [ "ie/8..latest", "firefox/3.5", "firefox/10", "firefox/nightly", "chrome/10", "chrome/latest", "chrome/canary", "opera/12..latest", "opera/next", "safari/5.1..latest", "ipad/6.0..latest", "iphone/6.0..latest", "android-browser/4.2..latest" ] } } stream-browserify-3.0.0/readme.markdown000066400000000000000000000022171364605216600202120ustar00rootroot00000000000000# stream-browserify the stream module from node core, for browsers! This module uses [`readable-stream`](https://github.com/nodejs/readable-stream), with additions for compatibility with npm packages that use old Node.js stream APIs. [![build status](https://secure.travis-ci.org/browserify/stream-browserify.svg?branch=master)](http://travis-ci.org/browserify/stream-browserify) ## Install You usually do not have to install `stream-browserify` yourself! If your code runs in Node.js, `stream` is built in, or `readable-stream` can be used. If your code runs in the browser, bundlers like [browserify](https://github.com/browserify/browserify) also include the `stream-browserify` module. But if none of those apply, with [npm](https://npmjs.org) do: ```bash npm install stream-browserify ``` ## API Consult the node core [documentation on streams](http://nodejs.org/docs/latest/api/stream.html). ## Browser Support Cross-browser testing generously provided by [Sauce Labs](https://saucelabs.com). [![Sauce Test Status](https://saucelabs.com/browser-matrix/stream-browserify.svg)](https://saucelabs.com/u/stream-browserify) ## License [MIT](./LICENSE) stream-browserify-3.0.0/security.md000066400000000000000000000004461364605216600174040ustar00rootroot00000000000000# Security Policy ## Supported Versions Only the latest major version is supported at any given time. ## Reporting a Vulnerability To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. stream-browserify-3.0.0/test/000077500000000000000000000000001364605216600161665ustar00rootroot00000000000000stream-browserify-3.0.0/test/buf.js000066400000000000000000000014041364605216600172770ustar00rootroot00000000000000var path = require('path'); var test = require('tape'); var Buffer = require('safe-buffer').Buffer; var Writable = require('..').Writable; var inherits = require('inherits'); inherits(TestWritable, Writable); function TestWritable(opt) { if (!(this instanceof TestWritable)) return new TestWritable(opt); Writable.call(this, opt); this._written = []; } TestWritable.prototype._write = function(chunk, encoding, cb) { this._written.push(chunk); cb(); }; var buf = Buffer.from([ 88 ]); test('.writable writing ArrayBuffer', function(t) { var writable = new TestWritable(); writable.write(buf); writable.end(); t.equal(writable._written.length, 1); t.equal(writable._written[0].toString(), 'X') t.end() }); stream-browserify-3.0.0/test/index.js000066400000000000000000000000511364605216600176270ustar00rootroot00000000000000require('./buf'); require('./pipeline'); stream-browserify-3.0.0/test/pipeline.js000066400000000000000000000017531364605216600203370ustar00rootroot00000000000000var test = require('tape'); var pipeline = require('..').pipeline; var stream = require('..'); var Buffer = require('safe-buffer').Buffer; test('supports pipeline', function(t) { t.plan(4); var readable = new stream.Readable({ read: function () { this.push(Buffer.from('chunk', 'ascii')); } }); var transform1 = new stream.Transform({ transform: function (chunk, enc, cb) { cb(new Error('fail')); } }); var transform2 = new stream.PassThrough(); transform2.on('close', function () { t.pass('transform2.close called'); }); var writable = new stream.Writable({ write: function (chunk, enc, cb) { cb(); } }); writable.on('close', function () { t.pass('writable.close called'); }); pipeline( readable, transform1, transform2, writable, function(err) { t.ok(err); t.equal(err.message, 'fail'); }); }); stream-browserify-3.0.0/test/use-stream.js000066400000000000000000000003301364605216600206050ustar00rootroot00000000000000// browserify plugin to swap out the `stream` builtin node shim with the stream-browserify version in this repo. module.exports = function (b) { b._mdeps.options.modules.stream = require.resolve('../index.js'); };