From d0ec1db1640d08c288dd8b8e8e4a70812da1b72e Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 8 Feb 2017 22:05:18 +0900 Subject: [PATCH] Refactor --- src/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3ded869..f502114 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,6 +37,11 @@ type Result = Summary & { url: string; }; +const defaultOptions = { + followRedirects: true, + plugins: null +} as Options; + /** * Summarize an web page * @param {string} url URL of web page you want to summarize @@ -44,10 +49,7 @@ type Result = Summary & { * @return {Promise} Promised summary */ export default async (url: string, options?: Options): Promise => { - const opts = Object.assign({ - followRedirects: true, - plugins: null - }, options) as Options; + const opts = Object.assign(defaultOptions, options); const plugins = builtinPlugins.concat(opts.plugins || []);