Skip to content

Commit

Permalink
feat: use getStreamAsArrayBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
younggglcy committed Dec 14, 2023
1 parent 5b7ab3f commit b7c59ea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 0 additions & 3 deletions lib/buffer.js

This file was deleted.

6 changes: 2 additions & 4 deletions lib/stream.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {createReadStream, readFileSync} from 'node:fs';
import {setTimeout} from 'node:timers/promises';
import {isStream} from 'is-stream';
import getStream, {getStreamAsBuffer} from 'get-stream';
import getStream, {getStreamAsArrayBuffer} from 'get-stream';
import mergeStreams from '@sindresorhus/merge-streams';
import {bufferToUint8Array} from './buffer.js';

export const validateInputOptions = ({input, inputFile}) => {
if (input !== undefined && inputFile !== undefined) {
Expand Down Expand Up @@ -76,8 +75,7 @@ const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
}

if (encoding === 'buffer') {
const streamBufferPromise = getStreamAsBuffer(stream, {maxBuffer});
return streamBufferPromise.then(value => bufferToUint8Array(value));
return getStreamAsArrayBuffer(stream, {maxBuffer}).then((arrayBuffer) => new Uint8Array(arrayBuffer));

Check failure on line 78 in lib/stream.js

View workflow job for this annotation

GitHub Actions / Node.js 20 on ubuntu-latest

Unexpected parentheses around single function argument.

Check failure on line 78 in lib/stream.js

View workflow job for this annotation

GitHub Actions / Node.js 20 on macos-latest

Unexpected parentheses around single function argument.

Check failure on line 78 in lib/stream.js

View workflow job for this annotation

GitHub Actions / Node.js 20 on windows-latest

Unexpected parentheses around single function argument.

Check failure on line 78 in lib/stream.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

Unexpected parentheses around single function argument.

Check failure on line 78 in lib/stream.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

Unexpected parentheses around single function argument.

Check failure on line 78 in lib/stream.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

Unexpected parentheses around single function argument.
}

return applyEncoding(stream, maxBuffer, encoding);
Expand Down

0 comments on commit b7c59ea

Please sign in to comment.