From c2bb2d9787257d1948ce90f24348539cff173eb4 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Thu, 4 Mar 2021 20:44:23 -0600 Subject: [PATCH] Move matchesWholeWord into mathing file --- helpers/build-video-list.js | 5 +---- helpers/matching.js | 6 ++++++ helpers/related.js | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 helpers/matching.js diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js index 893a8fe..b1f16ce 100644 --- a/helpers/build-video-list.js +++ b/helpers/build-video-list.js @@ -2,12 +2,9 @@ import slugify from 'slugify' import axios from 'axios' +import { matchesWholeWord } from './matching.js' import { byTimeThenNull } from './sort-list.js' import { getVideoEndpoint } from './app-derived.js' - -export function matchesWholeWord (needle, haystack) { - return new RegExp('\\b' + needle + '\\b').test(haystack) -} import parseDate from './parse-date' const videoFeaturesApp = function (app, video) { diff --git a/helpers/matching.js b/helpers/matching.js new file mode 100644 index 0000000..0ad101c --- /dev/null +++ b/helpers/matching.js @@ -0,0 +1,6 @@ + +// Match whole word +export function matchesWholeWord (needle, haystack) { + return new RegExp('\\b' + needle + '\\b').test(haystack) +} + diff --git a/helpers/related.js b/helpers/related.js index 98eb8f8..819550a 100644 --- a/helpers/related.js +++ b/helpers/related.js @@ -1,10 +1,6 @@ // import { allVideoAppsListSet } from '~/helpers/get-list.js' // import videoList from '~/static/video-list.json' -export function matchesWholeWord (needle, haystack) { - return new RegExp('\\b' + needle + '\\b').test(haystack) -} - export function appsRelatedToVideo ( video, allVideoAppsListSet ) { // console.log('allVideoAppsListSet', allVideoAppsListSet.length)