Skip to content

Commit

Permalink
fix: update typings
Browse files Browse the repository at this point in the history
  • Loading branch information
z0al committed Mar 10, 2019
1 parent bb28ce1 commit a07cb80
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import * as sx from 'saxes';

export interface Item {
// Feed ?
type?: string;
version?: string;

attrs: Map<string, string>;
meta: Map<string, Item | Item[]>;
ns: string;
value?: string;

// Normalized
id?: string;
title?: string;
summary?: string;
content?: string;
image?: string;
published?: string;
updated?: string;
}

export interface ParserOptions {
normalize?: boolean;
}

declare abstract class Parser {
options: ParserOptions;
constructor(opt?: ParserOptions);

/**
* Get the current parsed feed data.
*
* @returns {Item}
* @memberof Parser
*/
feed(): Item;

/**
* Iterates over avaiable items
*
* @returns {IterableIterator<Item>}
* @memberof Parser
* @abstract
*/

items(): IterableIterator<Item>;
/**
* Write text to stream.
*
* @param {string} chunk
* @returns {Parser}
* @memberof Parser
*/
write(chunk: string): Parser;

/**
* Close the current stream.
*
* @membthis.write
* @abstract
*/
close(): void;
}

/**
* A Robust RSS/Atom Parser
*
* @class RSSParser
* @extends {Parser}
*/
declare class RSSParser extends Parser {
constructor(options?: ParserOptions);

/**
* @override
*/
feed(): Item;

/**
* @override
*/
items(): IterableIterator<Item>;

/**
* @override
*/
write(chunk: string): this;

/**
* @override
*/
close(): void;
}

export interface ParserResult {
feed: Item;
items: Item[];
}

/**
* A simple promise interface for the parsing RSS/Atom feeds.
*
* @param {string} text
* @returns {Promise<ParserResult>}
*/
declare function parse(text: string): Promise<ParserResult>;

export { parse, RSSParser };

0 comments on commit a07cb80

Please sign in to comment.