Socket
Socket
Sign inDemoInstall

hack-news

Package Overview
Dependencies
0
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.9 to 1.0.10

108

index.js

@@ -9,14 +9,21 @@ const https = require('https');

}
https.get('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty', (res) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
});
callback(stories.splice(0, numberOfArticles));
callback = callback || () => {};
return new Promise((resolve, reject) => {
https.get('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty', (res) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
});
resolve(stories.splice(0, numberOfArticles));
callback(stories.splice(0, numberOfArticles));
});
}).on('error', (e) => {
reject(e);
callback(e);
});
}).on('error', (e) => {
callback(e);
});

@@ -28,15 +35,20 @@ }

https.get('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty', (res) => {
callback = callback || () => {};
return new Promise((resolve, reject) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
https.get('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty', (res) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
});
resolve(stories);
callback(stories);
});
callback(stories);
}).on('error', (e) => {
reject(e);
callback(e);
});
}).on('error', (e) => {
callback(e);
});

@@ -51,14 +63,21 @@ }

}
https.get('https://hacker-news.firebaseio.cm/v0/newstories.json?print=pretty', (res) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
});
callback(stories.splice(0, numberOfArticles));
callback = callback || () => {};
return new Promise((resolve, reject) => {
https.get('https://hacker-news.firebaseio.com/v0/newstories.json?print=pretty', (res) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
});
resolve(stories.splice(0, numberOfArticles));
callback(stories.splice(0, numberOfArticles));
});
}).on('error', (e) => {
reject(e);
callback(e);
});
}).on('error', (e) => {
callback(e);
});

@@ -70,16 +89,21 @@ }

https.get('https://hacker-news.firebaseio.com/v0/newstories.json?print=pretty', (res) => {
callback = callback || () => {};
return new Promise((resolve, reject) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
https.get('https://hacker-news.firebaseio.com/v0/newstories.json?print=pretty', (res) => {
res.on('data', (d) => {
const stories = JSON.parse(d, (key, value) => {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value;
});
resolve(stories);
callback(stories);
});
callback(stories);
}).on('error', (e) => {
reject(e);
callback(e);
});
}).on('error', (e) => {
callback(e);
});
}
{
"name": "hack-news",
"version": "1.0.9",
"version": "1.0.10",
"description": "A simple library of methods to help you interact with the Hacker News API. There's more on the way.",

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

@@ -9,2 +9,3 @@ ## Installation

####Top Stories
The examples below shows how to access the IDs of the top stories on Hacker News.

@@ -24,2 +25,5 @@

//Using Promises
hn.allTopStories().then(stories => {console.log(stories);});
/*Returns an array of article ids in the amount of your choice.

@@ -34,3 +38,7 @@ So if you wanted the top ten stories on Hacker News it would look like this.*/

});
//Using Promises
hn.numberOfTopStories(10).then(numberOfStories => {console.log(numberOfStories);});
```
####New Stories
The examples below shows how to access the IDs of the new stories on Hacker News.

@@ -42,3 +50,2 @@

//Returns an array of all the article ids for the new stories on hacker news
hn.allNewStories( (allTheStories, error) => {

@@ -51,5 +58,7 @@ if (error) {

//Using Promises
hn.allNewStories().then(stories => {console.log(stories);});
/*Returns an array of article ids in the amount of your choice.
So if you wanted the top ten newest stories on Hacker News it would look like this.*/
hn.numberOfNewStories(10, (numOfStories, error) => {

@@ -61,3 +70,6 @@ if (error) {

});
//Using Promises
hn.numberOfNewStories(10).then(numberOfStories => {console.log(numberOfStories);});
```
This is it for now but stay tuned I will be adding a lot more.
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc