mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-05-08 23:27:26 +09:00
Refactor
This commit is contained in:
parent
aa5384ad62
commit
d0ec1db164
10
src/index.ts
10
src/index.ts
@ -37,6 +37,11 @@ type Result = Summary & {
|
|||||||
url: string;
|
url: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const defaultOptions = {
|
||||||
|
followRedirects: true,
|
||||||
|
plugins: null
|
||||||
|
} as Options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summarize an web page
|
* Summarize an web page
|
||||||
* @param {string} url URL of web page you want to summarize
|
* @param {string} url URL of web page you want to summarize
|
||||||
@ -44,10 +49,7 @@ type Result = Summary & {
|
|||||||
* @return {Promise<Result>} Promised summary
|
* @return {Promise<Result>} Promised summary
|
||||||
*/
|
*/
|
||||||
export default async (url: string, options?: Options): Promise<Result> => {
|
export default async (url: string, options?: Options): Promise<Result> => {
|
||||||
const opts = Object.assign({
|
const opts = Object.assign(defaultOptions, options);
|
||||||
followRedirects: true,
|
|
||||||
plugins: null
|
|
||||||
}, options) as Options;
|
|
||||||
|
|
||||||
const plugins = builtinPlugins.concat(opts.plugins || []);
|
const plugins = builtinPlugins.concat(opts.plugins || []);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user