Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-observable

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-observable - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

40

lib/index.js

@@ -18,2 +18,4 @@ var Http = require('http');

var req = Client.request(options, function(res) {
//Send the status and message first.
observer.onNext({statusCode: res.statusCode, statusMessage: res.statusMessage});

@@ -39,2 +41,38 @@ res.on('data', function(chunk) {

module.exports = HttpObservable;
function Response(source) {
this.source = source;
}
Response.prototype.status = function () {
return this.source.first();
};
// Response.prototype.headers = function () {
// //return this.source.first();
// };
Response.prototype.body = function () {
return this.source.skip(1);
}
function init(opts) {
var source = new HttpObservable(opts);
var published = source.publish();
return {
get: function () {
opts.method = 'GET';
published.connect();
return new Response(published);
},
post: function () {
opts.method = 'POST';
published.connect();
return new Response(published);
},
request: function () {
published.connect();
return new Response(published);
}
}
}
module.exports = init;

2

package.json
{
"name": "http-observable",
"version": "0.0.3",
"version": "0.1.0",
"description": "Node.js http module binding using the Reactive Extensions for JavaScript (RxJS) Observable to handle stream http response",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -11,3 +11,3 @@ # http-observable

- SSL validations
- Socket and connect timeout implementations
- Socket and connect timeout implementations

@@ -35,4 +35,5 @@ ## Install

new HttpObservable(options)
.subscribe(
var response = HttpObservable(options).request();
response.body().subscribe(
function onNext(chunk) {

@@ -39,0 +40,0 @@ //Write the data chunk to response stream (Or process the data)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc