@metascraper/helpers 5.45.28 → 5.46.0-beta.0

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/index.js +7 -2
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const memoizeOne = require('memoize-one').default || require('memoize-one')
4
+ const debug = require('debug-logfmt')('metascraper:find-rule')
4
5
  const condenseWhitespace = require('condense-whitespace')
5
6
  const { getExtension: mimeExtension } = require('mime')
6
7
  const capitalize = require('microsoft-capitalize')
@@ -420,14 +421,18 @@ const validator = {
420
421
 
421
422
  const truthyTest = () => true
422
423
 
423
- const findRule = async (rules, args) => {
424
+ const findRule = async (rules, args, propName) => {
424
425
  let index = 0
425
426
  let value
426
427
 
427
428
  do {
428
429
  const rule = rules[index++]
429
430
  const test = rule.test || truthyTest
430
- if (test(args)) value = await rule(args)
431
+ if (test(args)) {
432
+ const duration = debug.duration()
433
+ value = await rule(args)
434
+ duration(`${rule.pkgName}:${propName}:${index - 1}:${has(value)}`)
435
+ }
431
436
  } while (!has(value) && index < rules.length)
432
437
 
433
438
  return value
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.45.28",
5
+ "version": "5.46.0-beta.0",
6
6
  "main": "index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "a3ca157491003cd78000a3c5c6d1bf038937b1c7"
66
+ "gitHead": "3fc0da7c1c5c45d4f1b59e49eedd9e649c8e645c"
67
67
  }