From 13e44f9f832861ab1e53175da73d16ed882e36aa Mon Sep 17 00:00:00 2001 From: Dominik Szczepaniak Date: Sat, 25 May 2019 19:02:10 +0200 Subject: [PATCH 1/3] Simplify find function. Remove redundant variable and spreading to this variable. --- src/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 4b47a5e..d4ae353 100644 --- a/src/index.js +++ b/src/index.js @@ -6,9 +6,7 @@ module.exports = { throw new Error('text is not a string (passed argument)'); } - const result = []; - const docs = text.match(GOOGLE_DOCS_REGEXP); - result.push(...docs); + const result = text.match(GOOGLE_DOCS_REGEXP); return result; } }; From f609aeb682d2326aea11a540f4c8e990655e3b85 Mon Sep 17 00:00:00 2001 From: Dominik Szczepaniak Date: Sun, 26 May 2019 18:23:38 +0200 Subject: [PATCH 2/3] Return empty array if there are no result. --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 9b7a09f..b880f0d 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,7 @@ module.exports = { throw new Error('text is not a string (passed argument)'); } - const result = text.match(GOOGLE_DOCS_REGEXP); + const result = text.match(GOOGLE_DOCS_REGEXP) || []; return result; } }; From 42f125c499351c874b431ff2d8985f7430a1bb94 Mon Sep 17 00:00:00 2001 From: Dominik Szczepaniak Date: Mon, 8 Jul 2019 20:32:40 +0200 Subject: [PATCH 3/3] Simplify returned result. --- src/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index b880f0d..e2950fc 100644 --- a/src/index.js +++ b/src/index.js @@ -5,8 +5,7 @@ module.exports = { if (typeof text !== 'string') { throw new Error('text is not a string (passed argument)'); } - - const result = text.match(GOOGLE_DOCS_REGEXP) || []; - return result; + + return text.match(GOOGLE_DOCS_REGEXP) || []; } };