Add isStream
This commit is contained in:
2
test/isStream/isStream.js
Normal file
2
test/isStream/isStream.js
Normal file
@ -0,0 +1,2 @@
|
||||
const isStream = val => val !== null && typeof val === 'object' && typeof val.pipe === 'function';
|
||||
module.exports = isStream;
|
||||
13
test/isStream/isStream.test.js
Normal file
13
test/isStream/isStream.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const expect = require('expect');
|
||||
const isStream = require('./isStream.js');
|
||||
const fs = require('fs');
|
||||
|
||||
test('isStream is a Function', () => {
|
||||
expect(isStream).toBeInstanceOf(Function);
|
||||
});
|
||||
test('isStream returns true for streams', () => {
|
||||
expect(isStream(fs.createReadStream('isStream.js'))).toBeTruthy();
|
||||
});
|
||||
test('isStream returns false for non-streams', () => {
|
||||
expect(isStream({})).toBeFalsy();
|
||||
});
|
||||
Reference in New Issue
Block a user