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

hackernews-api-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hackernews-api-ts - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

108

dist/HackerNews.d.ts

@@ -9,32 +9,58 @@ declare enum HackerNewsStoryTypes {

}
/** Unique ID of a Hacker News item */
declare type HackerNewsItemId = number;
/** Unique ID of a Hacker News user, alphanumeric */
declare type HackerNewsUserId = string;
/** Hacker News category */
declare type HackerNewsStoryType = HackerNewsStoryTypes;
declare type HackerNewsType = "job" | "story" | "comment" | "poll" | "pollopt";
/** Possible type of a Hacker News item */
declare type HackerNewsItemType = "job" | "story" | "comment" | "poll" | "pollopt";
export interface HackerNewsItem {
/** The item's unique id. */
id: HackerNewsItemId;
/** true if the item is deleted. */
deleted: boolean;
type: HackerNewsType;
/** The type of item. One of "job", "story", "comment", "poll", or "pollopt". */
type: HackerNewsItemType;
/** The username of the item's author. */
by: HackerNewsUserId;
/** Creation date of the item, in Unix Time. */
time: number;
/** The comment, story or poll text. HTML. */
text: string;
/** true if the item is dead. */
dead: boolean;
parent: HackerNewsItemId | null;
poll: HackerNewsItemId | null;
/** The comment's parent: either another comment or the relevant story. */
parent: HackerNewsItemId | undefined;
/** The pollopt's associated poll. */
poll: HackerNewsItemId | undefined;
/** The IDs of the item's comments, in ranked display order. */
kids: HackerNewsItemId[];
/** The URL of the story. */
url: string;
/** The story's score, or the votes for a pollopt. */
score: number;
/** The title of the story, poll or job. HTML. */
title: string;
/** A list of related pollopts, in display order. */
parts: HackerNewsItemId[];
descendants: number | null;
/** In the case of stories or polls, the total comment count. */
descendants: number | undefined;
}
export interface HackerNewsUser {
/** The user's unique username. Case-sensitive. Required. */
id: HackerNewsUserId;
/** Delay in minutes between a comment's creation and its visibility to other users. */
delay: number;
/** Creation date of the user, in Unix Time. */
created: number;
/** The user's karma. */
karma: number;
/** The user's optional self-description. HTML. */
about: string;
/** List of the user's stories, polls and comments. */
submitted: number;
}
export default abstract class HackerNews {
/** Categories of Hacker news Stories */
static readonly TYPES: HackerNewsStoryType[];

@@ -49,3 +75,3 @@ static readonly TYPE_TOP: HackerNewsStoryType;

* Get item by item ID
* @param item ID of item. If item doesn't exist, null is returned.
* @param item Promise which resolves with the ID of item. If item doesn't exist, it resolves with null.
*/

@@ -55,3 +81,3 @@ static getItem(item: HackerNewsItemId): Promise<HackerNewsItem | null>;

* Get user by user ID
* @param item ID of user. If user doesn't exist, null is returned.
* @param item Promise which resolves with the user object. If user doesn't exist, it resolves with null.
*/

@@ -61,3 +87,3 @@ static getUser(userId: HackerNewsUserId): Promise<HackerNewsUser | null>;

* Get ID of the latest item posted on HN
* @returns ID of the newst item
* @returns Promise which resolves with the ID of the latest item posted on HN
*/

@@ -67,3 +93,3 @@ static getMaxItemId(): Promise<HackerNewsItemId>;

* Get the latest item posted on HN
* @returns Latest item posted on HN
* @returns Promise which resolves with the latest item posted on HN
*/

@@ -73,31 +99,73 @@ static getMaxItem(): Promise<HackerNewsItem>;

* Get IDs of new stories
* @returns Array of IDs up to 500 new stories
* @returns Promise which resolves with an array of IDs up to 500 new stories
*/
static getNewStoryIDs(): Promise<HackerNewsItemId[]>;
/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
static getNewStories(offset?: number, amount?: number): Promise<HackerNewsItem[]>;
/**
* Get IDs of top stories
* @returns Array of IDs up to 500 top stories
* @returns Promise which resolves with an array of IDs up to 500 top stories
*/
static getTopStoryIDs(): Promise<HackerNewsItemId[]>;
/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
static getTopStories(offset?: number, amount?: number): Promise<HackerNewsItem[]>;
/**
* Get IDs of best stories
* @returns Array of IDs up to 500 best stories
* @returns Promise which resolves with an array of IDs up to 500 best stories
*/
static getBestStoryIDs(): Promise<HackerNewsItemId[]>;
/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
static getBestStories(offset?: number, amount?: number): Promise<HackerNewsItem[]>;
/**
* Get IDs of "Ask HN" stories
* @returns Array of IDs up to 200 newest Ask HN stories
* @returns Promise which resolves with an array of IDs up to 200 newest Ask HN stories
*/
static getAskStories(): Promise<HackerNewsItemId[]>;
static getAskStoryIds(): Promise<HackerNewsItemId[]>;
/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
static getAskStories(offset?: number, amount?: number): Promise<HackerNewsItem[]>;
/**
* Get IDs of "Show HN" stories
* @returns Array of IDs up to 200 newest Show HN stories
* @returns Promise which resolves with an array of IDs up to 200 newest Show HN stories
*/
static getShowStories(): Promise<HackerNewsItemId[]>;
static getShowStoryIds(): Promise<HackerNewsItemId[]>;
/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
static getShowStories(offset?: number, amount?: number): Promise<HackerNewsItem[]>;
/**
* Get IDs of "Job" stories
* @returns Array of IDs up to 200 newest Job stories
* @returns Promise which resolves with an array of IDs up to 200 newest Job stories
*/
static getJobStories(): Promise<HackerNewsItemId[]>;
static getJobStoryIds(): Promise<HackerNewsItemId[]>;
/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
static getJobStories(offset?: number, amount?: number): Promise<HackerNewsItem[]>;
/**
* Get IDs of recently updated items and stories

@@ -113,3 +181,3 @@ * @returns object with 2 arrays, one with updared story IDs, one with updated user IDs

* @param type Any of "top" | "new" | "best" | "ask" | "show" | "job"
* @returns Array of IDs
* @returns Promise which resolves with an array of IDs
*/

@@ -124,4 +192,4 @@ static getStoryIds(type: HackerNewsStoryType): Promise<HackerNewsItemId[]>;

*/
static getStories(type: HackerNewsStoryType, offset?: number, amount?: number): Promise<HackerNewsItem[]>;
static getStories(type: HackerNewsStoryType, offset: number | undefined, amount: number): Promise<HackerNewsItem[]>;
}
export {};

@@ -23,3 +23,3 @@ "use strict";

* Get item by item ID
* @param item ID of item. If item doesn't exist, null is returned.
* @param item Promise which resolves with the ID of item. If item doesn't exist, it resolves with null.
*/

@@ -33,3 +33,3 @@ HackerNews.getItem = function (item) {

* Get user by user ID
* @param item ID of user. If user doesn't exist, null is returned.
* @param item Promise which resolves with the user object. If user doesn't exist, it resolves with null.
*/

@@ -43,3 +43,3 @@ HackerNews.getUser = function (userId) {

* Get ID of the latest item posted on HN
* @returns ID of the newst item
* @returns Promise which resolves with the ID of the latest item posted on HN
*/

@@ -54,11 +54,12 @@ HackerNews.getMaxItemId = function () {

* Get the latest item posted on HN
* @returns Latest item posted on HN
* @returns Promise which resolves with the latest item posted on HN
*/
HackerNews.getMaxItem = function () {
var _this = this;
return this.getMaxItemId().then(function (itemId) { return _this.getItem(itemId); }); // Assume that this item exists
/** Assume that this item exists */
return this.getMaxItemId().then(function (itemId) { return _this.getItem(itemId); });
};
/**
* Get IDs of new stories
* @returns Array of IDs up to 500 new stories
* @returns Promise which resolves with an array of IDs up to 500 new stories
*/

@@ -70,4 +71,16 @@ HackerNews.getNewStoryIDs = function () {

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
HackerNews.getNewStories = function (offset, amount) {
if (offset === void 0) { offset = 0; }
if (amount === void 0) { amount = 10; }
return this.getStories(this.TYPE_NEW, offset, amount);
};
;
/**
* Get IDs of top stories
* @returns Array of IDs up to 500 top stories
* @returns Promise which resolves with an array of IDs up to 500 top stories
*/

@@ -79,4 +92,16 @@ HackerNews.getTopStoryIDs = function () {

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
HackerNews.getTopStories = function (offset, amount) {
if (offset === void 0) { offset = 0; }
if (amount === void 0) { amount = 10; }
return this.getStories(this.TYPE_TOP, offset, amount);
};
;
/**
* Get IDs of best stories
* @returns Array of IDs up to 500 best stories
* @returns Promise which resolves with an array of IDs up to 500 best stories
*/

@@ -88,6 +113,18 @@ HackerNews.getBestStoryIDs = function () {

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
HackerNews.getBestStories = function (offset, amount) {
if (offset === void 0) { offset = 0; }
if (amount === void 0) { amount = 10; }
return this.getStories(this.TYPE_BEST, offset, amount);
};
;
/**
* Get IDs of "Ask HN" stories
* @returns Array of IDs up to 200 newest Ask HN stories
* @returns Promise which resolves with an array of IDs up to 200 newest Ask HN stories
*/
HackerNews.getAskStories = function () {
HackerNews.getAskStoryIds = function () {
return this.getStoryIds(this.TYPE_ASK);

@@ -97,6 +134,18 @@ };

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
HackerNews.getAskStories = function (offset, amount) {
if (offset === void 0) { offset = 0; }
if (amount === void 0) { amount = 10; }
return this.getStories(this.TYPE_ASK, offset, amount);
};
;
/**
* Get IDs of "Show HN" stories
* @returns Array of IDs up to 200 newest Show HN stories
* @returns Promise which resolves with an array of IDs up to 200 newest Show HN stories
*/
HackerNews.getShowStories = function () {
HackerNews.getShowStoryIds = function () {
return this.getStoryIds(this.TYPE_SHOW);

@@ -106,6 +155,18 @@ };

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
HackerNews.getShowStories = function (offset, amount) {
if (offset === void 0) { offset = 0; }
if (amount === void 0) { amount = 10; }
return this.getStories(this.TYPE_SHOW, offset, amount);
};
;
/**
* Get IDs of "Job" stories
* @returns Array of IDs up to 200 newest Job stories
* @returns Promise which resolves with an array of IDs up to 200 newest Job stories
*/
HackerNews.getJobStories = function () {
HackerNews.getJobStoryIds = function () {
return this.getStoryIds(this.TYPE_JOB);

@@ -115,2 +176,14 @@ };

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
HackerNews.getJobStories = function (offset, amount) {
if (offset === void 0) { offset = 0; }
if (amount === void 0) { amount = 10; }
return this.getStories(this.TYPE_JOB, offset, amount);
};
;
/**
* Get IDs of recently updated items and stories

@@ -128,3 +201,3 @@ * @returns object with 2 arrays, one with updared story IDs, one with updated user IDs

* @param type Any of "top" | "new" | "best" | "ask" | "show" | "job"
* @returns Array of IDs
* @returns Promise which resolves with an array of IDs
*/

@@ -146,3 +219,2 @@ HackerNews.getStoryIds = function (type) {

if (offset === void 0) { offset = 0; }
if (amount === void 0) { amount = 0; }
return this.getStoryIds(type)

@@ -155,2 +227,3 @@ .then(function (storyIds) {

};
/** Categories of Hacker news Stories */
HackerNews.TYPES = Object.values(HackerNewsStoryTypes);

@@ -157,0 +230,0 @@ HackerNews.TYPE_TOP = HackerNewsStoryTypes.top;

4

package.json
{
"name": "hackernews-api-ts",
"version": "0.1.0",
"version": "0.2.0",
"description": "Hackernews v0 API wrapper in Typescript",
"main": "dist/HackerNews.js",
"scripts": {
"prepare": "tsc",
"build": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"

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

@@ -11,3 +11,3 @@ # Hacker News Typescript API

### Get newest stories
### Get 5 newest top stories

@@ -14,0 +14,0 @@ ```typescript

import HackerNews from '../HackerNews';
// Method 1
HackerNews.TYPES.forEach(type => {
HackerNews.getStories(type,0,1)
.then(stories => console.log(`Top ${type} story: ${stories[0].title}`));
});
HackerNews.getStories(type, 0, 1)
.then(stories => console.log(`Top ${type} story: ${stories[0].title}`));
});
// Method 2
async function getStories() {
console.log(`Top new story: ${(await HackerNews.getNewStories(0, 1))[0].title}`);
console.log(`Top top story: ${(await HackerNews.getTopStories(0, 1))[0].title}`);
console.log(`Top best story: ${(await HackerNews.getBestStories(0, 1))[0].title}`);
console.log(`Top show story: ${(await HackerNews.getShowStories(0, 1))[0].title}`);
console.log(`Top ask story: ${(await HackerNews.getAskStories(0, 1))[0].title}`);
console.log(`Top job story: ${(await HackerNews.getJobStories(0, 1))[0].title}`);
}
getStories();
import fetch from 'node-fetch';
enum HackerNewsStoryTypes { top = "top", new = "new", best = "best", ask = "ask", show = "show", job = "job" };
/** Unique ID of a Hacker News item */
type HackerNewsItemId = number;
/** Unique ID of a Hacker News user, alphanumeric */
type HackerNewsUserId = string;
/** Hacker News category */
type HackerNewsStoryType = HackerNewsStoryTypes;
type HackerNewsType = "job" | "story" | "comment" | "poll" | "pollopt";
/** Possible type of a Hacker News item */
type HackerNewsItemType = "job" | "story" | "comment" | "poll" | "pollopt";
const apiUrl = 'https://hacker-news.firebaseio.com/v0/';
export interface HackerNewsItem {
id: HackerNewsItemId, // The item's unique id.
deleted: boolean, // true if the item is deleted.
type: HackerNewsType, // The type of item. One of "job", "story", "comment", "poll", or "pollopt".
by: HackerNewsUserId, // The username of the item's author.
time: number, // Creation date of the item, in Unix Time.
text: string, // The comment, story or poll text. HTML.
dead: boolean, // true if the item is dead.
parent: HackerNewsItemId | null, // The comment's parent: either another comment or the relevant story.
poll: HackerNewsItemId | null, // The pollopt's associated poll.
kids: HackerNewsItemId[], // The IDs of the item's comments, in ranked display order.
url: string, // The URL of the story.
score: number, // The story's score, or the votes for a pollopt.
title: string, // The title of the story, poll or job. HTML.
parts: HackerNewsItemId[], // A list of related pollopts, in display order.
descendants: number | null, // In the case of stories or polls, the total comment count.
/** The item's unique id. */
id: HackerNewsItemId,
/** true if the item is deleted. */
deleted: boolean,
/** The type of item. One of "job", "story", "comment", "poll", or "pollopt". */
type: HackerNewsItemType,
/** The username of the item's author. */
by: HackerNewsUserId,
/** Creation date of the item, in Unix Time. */
time: number,
/** The comment, story or poll text. HTML. */
text: string,
/** true if the item is dead. */
dead: boolean,
/** The comment's parent: either another comment or the relevant story. */
parent: HackerNewsItemId | undefined,
/** The pollopt's associated poll. */
poll: HackerNewsItemId | undefined,
/** The IDs of the item's comments, in ranked display order. */
kids: HackerNewsItemId[],
/** The URL of the story. */
url: string,
/** The story's score, or the votes for a pollopt. */
score: number,
/** The title of the story, poll or job. HTML. */
title: string,
/** A list of related pollopts, in display order. */
parts: HackerNewsItemId[],
/** In the case of stories or polls, the total comment count. */
descendants: number | undefined,
}
export interface HackerNewsUser {
id: HackerNewsUserId, // The user's unique username. Case-sensitive. Required.
delay: number, // Delay in minutes between a comment's creation and its visibility to other users.
created: number, // Creation date of the user, in Unix Time.
karma: number, // The user's karma.
about: string, // The user's optional self-description. HTML.
submitted: number, // List of the user's stories, polls and comments.
/** The user's unique username. Case-sensitive. Required. */
id: HackerNewsUserId,
/** Delay in minutes between a comment's creation and its visibility to other users. */
delay: number,
/** Creation date of the user, in Unix Time. */
created: number,
/** The user's karma. */
karma: number,
/** The user's optional self-description. HTML. */
about: string,
/** List of the user's stories, polls and comments. */
submitted: number,
}
export default abstract class HackerNews {
/** Categories of Hacker news Stories */
public static readonly TYPES: HackerNewsStoryType[] = Object.values(HackerNewsStoryTypes);

@@ -52,3 +77,3 @@ public static readonly TYPE_TOP: HackerNewsStoryType = HackerNewsStoryTypes.top;

* Get item by item ID
* @param item ID of item. If item doesn't exist, null is returned.
* @param item Promise which resolves with the ID of item. If item doesn't exist, it resolves with null.
*/

@@ -63,3 +88,3 @@ public static getItem(item: HackerNewsItemId): Promise<HackerNewsItem | null> {

* Get user by user ID
* @param item ID of user. If user doesn't exist, null is returned.
* @param item Promise which resolves with the user object. If user doesn't exist, it resolves with null.
*/

@@ -74,3 +99,3 @@ public static getUser(userId: HackerNewsUserId): Promise<HackerNewsUser | null> {

* Get ID of the latest item posted on HN
* @returns ID of the newst item
* @returns Promise which resolves with the ID of the latest item posted on HN
*/

@@ -85,6 +110,7 @@ public static getMaxItemId(): Promise<HackerNewsItemId> {

* Get the latest item posted on HN
* @returns Latest item posted on HN
* @returns Promise which resolves with the latest item posted on HN
*/
public static getMaxItem(): Promise<HackerNewsItem> {
return this.getMaxItemId().then(itemId => this.getItem(itemId) as unknown as HackerNewsItem); // Assume that this item exists
/** Assume that this item exists */
return this.getMaxItemId().then(itemId => this.getItem(itemId) as unknown as HackerNewsItem);
}

@@ -94,3 +120,3 @@

* Get IDs of new stories
* @returns Array of IDs up to 500 new stories
* @returns Promise which resolves with an array of IDs up to 500 new stories
*/

@@ -102,4 +128,14 @@ public static getNewStoryIDs(): Promise<HackerNewsItemId[]> {

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
public static getNewStories(offset: number = 0, amount: number = 10): Promise<HackerNewsItem[]> {
return this.getStories(this.TYPE_NEW, offset, amount);
};
/**
* Get IDs of top stories
* @returns Array of IDs up to 500 top stories
* @returns Promise which resolves with an array of IDs up to 500 top stories
*/

@@ -111,4 +147,14 @@ public static getTopStoryIDs(): Promise<HackerNewsItemId[]> {

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
public static getTopStories(offset: number = 0, amount: number = 10): Promise<HackerNewsItem[]> {
return this.getStories(this.TYPE_TOP, offset, amount);
};
/**
* Get IDs of best stories
* @returns Array of IDs up to 500 best stories
* @returns Promise which resolves with an array of IDs up to 500 best stories
*/

@@ -120,6 +166,16 @@ public static getBestStoryIDs(): Promise<HackerNewsItemId[]> {

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
public static getBestStories(offset: number = 0, amount: number = 10): Promise<HackerNewsItem[]> {
return this.getStories(this.TYPE_BEST, offset, amount);
};
/**
* Get IDs of "Ask HN" stories
* @returns Array of IDs up to 200 newest Ask HN stories
* @returns Promise which resolves with an array of IDs up to 200 newest Ask HN stories
*/
public static getAskStories(): Promise<HackerNewsItemId[]> {
public static getAskStoryIds(): Promise<HackerNewsItemId[]> {
return this.getStoryIds(this.TYPE_ASK);

@@ -129,6 +185,16 @@ };

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
public static getAskStories(offset: number = 0, amount: number = 10): Promise<HackerNewsItem[]> {
return this.getStories(this.TYPE_ASK, offset, amount);
};
/**
* Get IDs of "Show HN" stories
* @returns Array of IDs up to 200 newest Show HN stories
* @returns Promise which resolves with an array of IDs up to 200 newest Show HN stories
*/
public static getShowStories(): Promise<HackerNewsItemId[]> {
public static getShowStoryIds(): Promise<HackerNewsItemId[]> {
return this.getStoryIds(this.TYPE_SHOW);

@@ -138,6 +204,16 @@ };

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
public static getShowStories(offset: number = 0, amount: number = 10): Promise<HackerNewsItem[]> {
return this.getStories(this.TYPE_SHOW, offset, amount);
};
/**
* Get IDs of "Job" stories
* @returns Array of IDs up to 200 newest Job stories
* @returns Promise which resolves with an array of IDs up to 200 newest Job stories
*/
public static getJobStories(): Promise<HackerNewsItemId[]> {
public static getJobStoryIds(): Promise<HackerNewsItemId[]> {
return this.getStoryIds(this.TYPE_JOB);

@@ -147,2 +223,12 @@ };

/**
* Get stories
* @param offset offset, with 0 being the newest story
* @param amount Default: 10, amount of stories to return from offset on.
* @returns Promise which resolves with an array of {@link HackerNewsItem}
*/
public static getJobStories(offset: number = 0, amount: number = 10): Promise<HackerNewsItem[]> {
return this.getStories(this.TYPE_JOB, offset, amount);
};
/**
* Get IDs of recently updated items and stories

@@ -160,3 +246,3 @@ * @returns object with 2 arrays, one with updared story IDs, one with updated user IDs

* @param type Any of "top" | "new" | "best" | "ask" | "show" | "job"
* @returns Array of IDs
* @returns Promise which resolves with an array of IDs
*/

@@ -176,3 +262,3 @@ public static getStoryIds(type: HackerNewsStoryType): Promise<HackerNewsItemId[]> {

*/
public static getStories(type: HackerNewsStoryType, offset: number = 0, amount: number = 0): Promise<HackerNewsItem[]> {
public static getStories(type: HackerNewsStoryType, offset: number = 0, amount: number): Promise<HackerNewsItem[]> {
return this.getStoryIds(type)

@@ -179,0 +265,0 @@ .then((storyIds: number[]) => {

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