@metascraper/helpers 5.49.21 → 5.49.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.js +4 -4
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@metascraper/helpers",
|
|
3
3
|
"description": "Collection of helper functions used by metascraper",
|
|
4
4
|
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-helpers",
|
|
5
|
-
"version": "5.49.
|
|
5
|
+
"version": "5.49.23",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "74f58f4db8e6cb26e441f1e731012e3bf8be6bd2"
|
|
69
69
|
}
|
package/src/index.js
CHANGED
|
@@ -374,10 +374,11 @@ const jsonld = memoizeOne(
|
|
|
374
374
|
const el = $(element)
|
|
375
375
|
const text = $(el).contents().text()
|
|
376
376
|
const json = parseJSON(text)
|
|
377
|
-
if (!json) return
|
|
377
|
+
if (!json) return false
|
|
378
378
|
const { '@graph': graph, ...props } = json
|
|
379
|
-
|
|
380
|
-
|
|
379
|
+
return Array.isArray(graph)
|
|
380
|
+
? graph.map(item => ({ ...props, ...item }))
|
|
381
|
+
: props
|
|
381
382
|
})
|
|
382
383
|
.get()
|
|
383
384
|
.filter(Boolean),
|
|
@@ -387,7 +388,6 @@ const jsonld = memoizeOne(
|
|
|
387
388
|
const $jsonld = propName => $ => {
|
|
388
389
|
const collection = jsonld($)
|
|
389
390
|
let value
|
|
390
|
-
|
|
391
391
|
collection.find(item => {
|
|
392
392
|
value = get(item, propName)
|
|
393
393
|
return !isEmpty(value) || isNumber(value) || isBoolean(value)
|