Merge remote-tracking branch 'refs/remotes/origin/master' into test

This commit is contained in:
syuilo
2017-02-08 14:40:44 +09:00
7 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2.0.0 / 2017-02-08
------------------
* **[BREAKING CHANGE] Renamed: Plugins: Method `summary` is now `summarize`**
* Some refactors
1.6.1 / 2017-02-06
------------------
* Fix the incorrect type definition

View File

@ -30,7 +30,7 @@ summaly(url[, opts])
``` typescript
interface IPlugin {
test: (url: URL.Url) => boolean;
summary: (url: URL.Url) => Promise<ISummary>;
summarize: (url: URL.Url) => Promise<Summary>;
}
```

View File

@ -1,6 +1,6 @@
{
"name": "summaly",
"version": "1.6.1",
"version": "2.0.0",
"description": "Get web page's summary",
"author": "syuilo <i@syuilo.com>",
"license": "MIT",

View File

@ -60,7 +60,7 @@ export default async (url: string, options?: Options): Promise<Result> => {
const match = plugins.filter(plugin => plugin.test(_url))[0];
// Get summary
const summary = await (match ? match.summary : general)(_url);
const summary = await (match ? match.summarize : general)(_url);
return Object.assign(summary, {
url: actualUrl

View File

@ -3,7 +3,7 @@ import Summary from './summary';
interface IPlugin {
test: (url: URL.Url) => boolean;
summary: (url: URL.Url) => Promise<Summary>;
summarize: (url: URL.Url) => Promise<Summary>;
}
export default IPlugin;

View File

@ -21,7 +21,7 @@ export function test(url: URL.Url) {
url.hostname === 'www.amazon.au'
};
export async function summary(url: URL.Url) {
export async function summarize(url: URL.Url) {
const res = await client.fetch(url.href);
const $ = res.$;

View File

@ -9,7 +9,7 @@ export function test(url: URL.Url) {
return /\.wikipedia\.org$/.test(url.hostname);
};
export function summary(url: URL.Url) {
export function summarize(url: URL.Url) {
return new Promise((res, rej) => {
const lang = url.host.split('.')[0];
const title = url.pathname.split('/')[2];