New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

user-stream

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

user-stream - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

64

lib/user-stream.js

@@ -64,3 +64,2 @@ var oauth = require('oauth'),

//required params for lib
params.delimited = 'length';
params.stall_warnings = 'true';

@@ -86,3 +85,3 @@

request.on('response', function(response) {
// Any response code greater then 200 from steam API is an error

@@ -95,16 +94,14 @@ if(response.statusCode > 200) {

var buffer = '',
next_data_length = 0,
end = '\r\n';
//emit connected event
stream.emit('connected');
//set chunk encoding
response.setEncoding('utf8');
var data = '';
response.on('data', function(chunk) {
//is heartbeat?
if (chunk == end) {
data += chunk.toString('utf8');
//is heartbeat?
if (data == '\r\n') {
stream.emit('heartbeat');

@@ -114,40 +111,17 @@ return;

//check whether new incomming data set
if (!buffer.length) {
//get length of incomming data
var line_end_pos = chunk.indexOf(end);
next_data_length = parseInt(chunk.slice(0, line_end_pos));
//slice data length string from chunk
chunk = chunk.slice(line_end_pos+end.length);
}
if (buffer.length != next_data_length) {
//data set recieved
//first remove end and append to buffer
buffer+= chunk.slice(0, chunk.indexOf(end));
//parse json
var parsed = false;
try {
//try parse & emit
buffer = JSON.parse(buffer);
parsed = true;
} catch(e) {
stream.emit('garbage', buffer);
var index, json;
while((index = data.indexOf('\r\n')) > -1) {
json = data.slice(0, index);
data = data.slice(index + 2);
if(json.length > 0) {
try {
stream.emit('data', JSON.parse(json));
} catch(e) {
stream.emit('garbage', data);
}
}
//don't emit into "try" and emit only if data formatted
if (parsed) {
stream.emit('data', buffer);
}
//clean buffer
buffer = '';
} else {
//append to buffer
buffer+=chunk;
}
});
});
response.on('error', function(error) {

@@ -154,0 +128,0 @@

{
"name": "user-stream",
"version": "0.0.7",
"version": "0.0.8",
"description": "Simple twitter user stream client. Only one dependency (oauth).",

@@ -5,0 +5,0 @@ "keywords": ["twitter","streaming"],

user-stream
=============
### Version: 0.0.6 ###
[![NPM module](https://badge.fury.io/js/user-stream.png)](https://badge.fury.io/js/user-stream)
Simple Node.js Twitter (API 1.1) user stream client (https://dev.twitter.com/docs/streaming-apis/streams/user)
[![NPM](https://nodei.co/npm/user-stream.png?stars&downloads)](https://nodei.co/npm/user-stream/)
Install

@@ -8,0 +10,0 @@ -------

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