@kjots/stream-observable
Advanced tools
Comparing version 0.0.5 to 0.0.6
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const stream_to_observable_1 = __importDefault(require("stream-to-observable")); | ||
const stream_1 = require("stream"); | ||
const rxjs_1 = require("rxjs"); | ||
function streamObservable(stream) { | ||
return stream_to_observable_1.default(stream); | ||
return new rxjs_1.Observable((observer) => { | ||
const observerWritable = new stream_1.Writable({ | ||
objectMode: true, | ||
write(chunk, encoding, callback) { | ||
observer.next(chunk); | ||
callback(); | ||
}, | ||
final(callback) { | ||
observer.complete(); | ||
callback(); | ||
} | ||
}); | ||
stream | ||
.on('error', error => observer.error(error)) | ||
.pipe(observerWritable); | ||
return () => stream.unpipe(observerWritable); | ||
}); | ||
} | ||
exports.streamObservable = streamObservable; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@kjots/stream-observable", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Stream Observable", | ||
@@ -42,3 +42,2 @@ "main": "dist/index.js", | ||
"rimraf": "^2.6.3", | ||
"stream-array": "^1.1.2", | ||
"ts-node": "^8.0.3", | ||
@@ -49,6 +48,4 @@ "tslint": "^5.15.0", | ||
"dependencies": { | ||
"rxjs": "^6.4.0", | ||
"rxjs-compat": "^6.4.0", | ||
"stream-to-observable": "^0.2.0" | ||
"rxjs": "^6.4.0" | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
import streamToObservable from 'stream-to-observable'; | ||
import { Writable } from 'stream'; | ||
import { Observable } from 'rxjs'; | ||
import { Observable, Observer } from 'rxjs'; | ||
@@ -8,3 +8,25 @@ import ReadableStream = NodeJS.ReadableStream; | ||
export function streamObservable<T>(stream: ReadableStream): Observable<T> { | ||
return streamToObservable(stream); | ||
return new Observable((observer: Observer<T>) => { | ||
const observerWritable = new Writable({ | ||
objectMode: true, | ||
write(chunk: any, encoding: string, callback: () => void) { | ||
observer.next(chunk); | ||
callback(); | ||
}, | ||
final(callback: () => void) { | ||
observer.complete(); | ||
callback(); | ||
} | ||
}); | ||
stream | ||
.on('error', error => observer.error(error)) | ||
.pipe(observerWritable); | ||
return () => stream.unpipe(observerWritable); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
15087
1
11
50
- Removedrxjs-compat@^6.4.0
- Removedstream-to-observable@^0.2.0
- Removedany-observable@0.2.0(transitive)
- Removedrxjs-compat@6.6.7(transitive)
- Removedstream-to-observable@0.2.0(transitive)