@metascraper/helpers
Advanced tools
Comparing version 5.4.6 to 5.4.7
@@ -6,2 +6,10 @@ # Change Log | ||
## [5.4.7](https://github.com/microlinkhq/metascraper/tree/master/packages/metascraper-helpers/compare/v5.4.6...v5.4.7) (2019-06-20) | ||
**Note:** Version bump only for package @metascraper/helpers | ||
## [5.4.6](https://github.com/microlinkhq/metascraper/tree/master/packages/metascraper-helpers/compare/v5.4.5...v5.4.6) (2019-06-19) | ||
@@ -8,0 +16,0 @@ |
45
index.js
@@ -19,3 +19,4 @@ 'use strict' | ||
toLower, | ||
trim | ||
trim, | ||
invoke | ||
} = require('lodash') | ||
@@ -240,2 +241,36 @@ | ||
const image = url | ||
const logo = url | ||
const video = (value, opts) => { | ||
const urlValue = url(value, opts) | ||
return isVideoUrl(urlValue) && urlValue | ||
} | ||
const audio = (value, opts) => { | ||
const urlValue = url(value, opts) | ||
return isAudioUrl(urlValue) && urlValue | ||
} | ||
const validator = { | ||
date, | ||
audio, | ||
author, | ||
video, | ||
title, | ||
publisher, | ||
image, | ||
logo, | ||
url, | ||
description, | ||
lang | ||
} | ||
const createValidator = fn => ({ from, to = from }) => async args => { | ||
const data = await fn(args) | ||
const value = get(data, from) | ||
return invoke(validator, to, value) | ||
} | ||
module.exports = { | ||
@@ -269,3 +304,9 @@ $filter, | ||
titleize, | ||
url | ||
url, | ||
image, | ||
logo, | ||
audio, | ||
video, | ||
validator, | ||
createValidator | ||
} |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://nicedoc.io/microlinkhq/metascraper/packages/metascraper-helpers", | ||
"version": "5.4.6", | ||
"version": "5.4.7", | ||
"main": "index.js", | ||
@@ -42,2 +42,3 @@ "repository": { | ||
"cheerio": "latest", | ||
"coveralls": "latest", | ||
"mocha": "latest", | ||
@@ -56,2 +57,3 @@ "nyc": "latest", | ||
"scripts": { | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"test": "NODE_PATH=.. TZ=UTC NODE_ENV=test nyc mocha test" | ||
@@ -65,3 +67,3 @@ }, | ||
}, | ||
"gitHead": "ef95e3cda9739b2add317bbea9c68087acc79ab3" | ||
"gitHead": "d60b4799f23dd72b096bbf8a2635c324ce14c60a" | ||
} |
15329
247
7