@metascraper/helpers 5.49.21 → 5.49.24

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +6 -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.21",
5
+ "version": "5.49.24",
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": "b49f1cd9aa131c2ba5abe8aa55f5a33b0afdabca"
68
+ "gitHead": "4498fc7634a83a772379ab474f66abf4de1d1fa7"
69
69
  }
package/src/index.js CHANGED
@@ -374,10 +374,13 @@ 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 undefined
377
+ if (!json) return false
378
378
  const { '@graph': graph, ...props } = json
379
- if (!graph) return json
380
- return graph.map(item => ({ ...props, ...item }))
379
+ return Array.isArray(graph)
380
+ ? graph.map(item => ({ ...props, ...item }))
381
+ : graph
382
+ ? props
383
+ : json
381
384
  })
382
385
  .get()
383
386
  .filter(Boolean),
@@ -387,7 +390,6 @@ const jsonld = memoizeOne(
387
390
  const $jsonld = propName => $ => {
388
391
  const collection = jsonld($)
389
392
  let value
390
-
391
393
  collection.find(item => {
392
394
  value = get(item, propName)
393
395
  return !isEmpty(value) || isNumber(value) || isBoolean(value)