Skip to content

Commit

Permalink
perf: memoize isMediaUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 17, 2024
1 parent 095c93a commit a6205f3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/metascraper-helpers/index.js
Expand Up @@ -209,8 +209,10 @@ const isMediaTypeUrl = (url, type, { ext, ...opts } = {}) =>
const isMediaTypeExtension = (url, type, ext) =>
eq(type, get(EXTENSIONS, ext || extension(url)))

const isMediaUrl = (url, opts) =>
isImageUrl(url, opts) || isVideoUrl(url, opts) || isAudioUrl(url, opts)
const isMediaUrl = memoizeOne(
(url, opts) =>
isImageUrl(url, opts) || isVideoUrl(url, opts) || isAudioUrl(url, opts)
)

const isVideoUrl = (url, opts) => isMediaTypeUrl(url, VIDEO, opts)

Expand Down

0 comments on commit a6205f3

Please sign in to comment.