-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export {getStreamAsArray} from './array.js'; | ||
export {getStreamAsArrayBuffer} from './array-buffer.js'; | ||
export {getStreamAsBuffer} from './buffer.js'; | ||
export {getStreamAsString as default} from './string.js'; | ||
export {MaxBufferError} from './contents.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
export {getStreamAsArray} from './array.js'; | ||
export {getStreamAsArrayBuffer} from './array-buffer.js'; | ||
export {getStreamAsBuffer} from './buffer.js'; | ||
export {getStreamAsString as default} from './string.js'; | ||
export {MaxBufferError} from './contents.js'; | ||
import {on} from 'node:events'; | ||
import {finished} from 'node:stream/promises'; | ||
import {nodeImports} from './stream.js'; | ||
|
||
Object.assign(nodeImports, {on, finished}); | ||
|
||
export { | ||
default, | ||
getStreamAsArray, | ||
getStreamAsArrayBuffer, | ||
getStreamAsBuffer, | ||
MaxBufferError, | ||
} from './exports.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {execFile} from 'node:child_process'; | ||
import {dirname} from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
import {promisify} from 'node:util'; | ||
import test from 'ava'; | ||
import {fixtureString} from './fixtures/index.js'; | ||
|
||
const pExecFile = promisify(execFile); | ||
const cwd = dirname(fileURLToPath(import.meta.url)); | ||
const nodeStreamFixture = './fixtures/node-stream.js'; | ||
const webStreamFixture = './fixtures/web-stream.js'; | ||
const iterableFixture = './fixtures/iterable.js'; | ||
const nodeConditions = []; | ||
const browserConditions = ['--conditions=browser']; | ||
|
||
const testEntrypoint = async (t, fixture, conditions, expectedOutput = fixtureString) => { | ||
const {stdout, stderr} = await pExecFile('node', [...conditions, fixture], {cwd}); | ||
t.is(stderr, ''); | ||
t.is(stdout, expectedOutput); | ||
}; | ||
|
||
test('Node entrypoint works with Node streams', testEntrypoint, nodeStreamFixture, nodeConditions, `${fixtureString}${fixtureString}`); | ||
test('Browser entrypoint works with Node streams', testEntrypoint, nodeStreamFixture, browserConditions); | ||
test('Node entrypoint works with web streams', testEntrypoint, webStreamFixture, nodeConditions); | ||
test('Browser entrypoint works with web streams', testEntrypoint, webStreamFixture, browserConditions); | ||
test('Node entrypoint works with async iterables', testEntrypoint, iterableFixture, nodeConditions); | ||
test('Browser entrypoint works with async iterables', testEntrypoint, iterableFixture, browserConditions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import process from 'node:process'; | ||
import getStream from 'get-stream'; | ||
import {createStream} from '../helpers/index.js'; | ||
import {fixtureString} from './index.js'; | ||
|
||
const generator = async function * () { | ||
yield fixtureString; | ||
}; | ||
|
||
const stream = createStream(generator); | ||
process.stdout.write(await getStream(stream)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import process from 'node:process'; | ||
import getStream from 'get-stream'; | ||
import {createStream} from '../helpers/index.js'; | ||
import {fixtureString} from './index.js'; | ||
|
||
const stream = createStream([fixtureString]); | ||
const [output, secondOutput] = await Promise.all([getStream(stream), getStream(stream)]); | ||
process.stdout.write(`${output}${secondOutput}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import process from 'node:process'; | ||
import getStream from 'get-stream'; | ||
import {readableStreamFrom} from '../helpers/index.js'; | ||
import {fixtureString} from './index.js'; | ||
|
||
const stream = readableStreamFrom([fixtureString]); | ||
process.stdout.write(await getStream(stream)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters