Skip to content

Commit

Permalink
Allow for stream.PassThrough streams (#35)
Browse files Browse the repository at this point in the history
From e.g. isomorphic-unfetch response body
  • Loading branch information
kasbah authored Apr 4, 2020
1 parent ce860ea commit 3f31e08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const fs = require('fs');
const stream = require('stream');
const sizeOf = require('image-size');
const sharp = require('sharp');
const validator = require('validator');
Expand Down Expand Up @@ -86,7 +87,7 @@ module.exports = async (source, options) => {
switch (typeof source) {
case 'object':
let response;
if (source instanceof fs.ReadStream) {
if (source instanceof fs.ReadStream || source instanceof stream.PassThrough) {
response = await fromReadStream(source, percentage, width, height, responseType, jpegOptions);
} else if (source instanceof Buffer) {
response = await fromBuffer(source, percentage, width, height, responseType, jpegOptions);
Expand Down

0 comments on commit 3f31e08

Please sign in to comment.