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.11 to 1.0.12

.npmignore

31

index.js

@@ -134,1 +134,32 @@ const https = require('https');

}
//ask show or job top number of stories
exports.numbOfAskShowOrJobStories = function (asj, numberOfArticles, callback) {
if (asj && typeof asj != "string") {
throw new Error("The paramter must be a string and be one of the following ask, show or job");
}
if (numberOfArticles && typeof numberOfArticles != 'number') {
throw new Error("The second paramter must be a number");
}
callback = callback || () => {};
return new Promise((resolve, reject) => {
https.get('https://hacker-news.firebaseio.com/v0/' + asj +'stories.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);
});
});
}

2

package.json
{
"name": "hack-news",
"version": "1.0.11",
"version": "1.0.12",
"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",

@@ -87,4 +87,15 @@ ## Installation

hn.askShowOrJobStories('show').then(asj => {console.log(asj);});
//If you wanted the Top Ten Ask, Show, Job you ca use the numbOfAskShowOrJobStories method like so.
hn.numbOfAskShowOrJobStories('show', 10, (asj, error) => {
if (error) {
console.log(error);
}
console.log(asj);
});
//Using Promises
hn.numbOfAskShowOrJobStories('job', 10).then(asj => {console.log(asj);});
```
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