Skip to content

Commit

Permalink
fix: drop readable stream (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau committed Feb 16, 2022
1 parent f5588d4 commit 3e36ccc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 0 additions & 2 deletions build-fixup
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs",
"browser": {
"readable-stream": false,
"stream": false,
"./utils/data.js": "./utils/data.browser.js",
"./utils/collection.node.js": "./utils/collection.browser.js"
Expand All @@ -20,7 +19,6 @@ cat >dist/mjs/package.json <<!EOF
{
"type": "module",
"browser": {
"readable-stream": false,
"stream": false,
"./utils/data.js": "./utils/data.browser.js",
"./utils/collection.node.js": "./utils/collection.browser.js"
Expand Down
9 changes: 0 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
},
"types": "dist/types/index.d.ts",
"browser": {
"readable-stream": false,
"stream": false,
"./src/utils/data.ts": "./src/utils/data.browser.ts",
"./dist/cjs/utils/data.js": "./dist/cjs/utils/data.browser.js",
Expand Down Expand Up @@ -79,14 +78,6 @@
"web-streams-polyfill": "^3.1.0",
"ws": "^8.5.0"
},
"peerDependencies": {
"readable-stream": "^3.6.0"
},
"peerDependenciesMeta": {
"readable-stream": {
"optional": true
}
},
"devDependencies": {
"@babel/cli": "^7.17.0",
"@babel/core": "^7.14.6",
Expand Down
10 changes: 4 additions & 6 deletions src/utils/stream.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Readable as NodeReadableNative, ReadableOptions as NodeReadableOptions } from 'stream'
import { isStrictlyObject } from './type'
import { ReadableStream } from 'web-streams-polyfill/dist/ponyfill.js'
import { Readable as NodeReadableStream } from 'readable-stream'

import { Readable } from '../types'

const NodeReadable = NodeReadableNative || NodeReadableStream || class {}
const NodeReadable = NodeReadableNative || class {}

/**
* Validates if passed object is either browser's ReadableStream
Expand Down Expand Up @@ -134,8 +133,7 @@ class NodeReadableWrapper extends NodeReadable {
* Because it uses forked web-streams-polyfill that is outdated.
*
* **Warning!**
* If you want to use this function in browser you have to install readable-stream package and with your bundler
* polyfill `process` and `buffer` packages!
* If you want to use this function in browser you have to polyfill `stream` package with your bundler.
*
* @author https://github.com/gwicke
* @licence Apache License 2.0 https://github.com/gwicke/node-web-streams/blob/master/LICENSE
Expand All @@ -146,9 +144,9 @@ export function readableWebToNode(
webStream: ReadableStream<unknown>,
options?: NodeReadableOptions,
): NodeReadableNative {
if (!NodeReadableStream && !NodeReadableNative) {
if (!NodeReadableNative) {
throw new Error(
"The Node's Readable is not available! If you are running this in browser you have to install readable-stream package and polyfill process and buffer!",
"The Node's Readable is not available! If you are running this in browser you have to polyfill 'stream' package!",
)
}

Expand Down

0 comments on commit 3e36ccc

Please sign in to comment.