html-get 2.24.11 → 2.26.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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "html-get",
3
3
  "description": "Get the HTML from any website, fine-tuned for correction & speed",
4
4
  "homepage": "https://nicedoc.com/microlinkhq/html-get",
5
- "version": "2.24.11",
5
+ "version": "2.26.0",
6
6
  "types": "index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "bin": {
@@ -26,6 +26,7 @@ const domains = [
26
26
  [['domainWithoutSuffix', 'github']],
27
27
  [['domainWithoutSuffix', 'gitlab']],
28
28
  [['domainWithoutSuffix', 'google']],
29
+ [['domainWithoutSuffix', 'houzz']],
29
30
  [['domainWithoutSuffix', 'huffingtonpost']],
30
31
  [['domainWithoutSuffix', 'imdb']],
31
32
  [['domainWithoutSuffix', 'imgur']],
@@ -233,6 +233,12 @@
233
233
  "giphy"
234
234
  ]
235
235
  ],
236
+ [
237
+ [
238
+ "domainWithoutSuffix",
239
+ "houzz"
240
+ ]
241
+ ],
236
242
  [
237
243
  [
238
244
  "domainWithoutSuffix",
package/src/index.js CHANGED
@@ -244,21 +244,29 @@ const defaultGetTemporalFile = (input, ext) => {
244
244
  return { path: filepath }
245
245
  }
246
246
 
247
- // use execFileSync (no shell) to resolve the binary path: faster than execSync
248
- // and free of any interpolation surface.
247
+ // Resolve a binary path once and cache it: html-get owns the pandoc/mutool
248
+ // lookup, so both the internal runners and the exposed accessors share a single
249
+ // `which` per binary for the whole process. execFileSync (no shell) is faster
250
+ // than execSync and free of any interpolation surface.
251
+ const whichCache = new Map()
249
252
  const whichSync = bin => {
250
- try {
251
- return execFileSync('which', [bin], {
252
- stdio: ['pipe', 'pipe', 'ignore']
253
- })
254
- .toString()
255
- .trim()
256
- } catch (_) {}
253
+ if (!whichCache.has(bin)) {
254
+ let resolved
255
+ try {
256
+ resolved = execFileSync('which', [bin], {
257
+ stdio: ['pipe', 'pipe', 'ignore']
258
+ })
259
+ .toString()
260
+ .trim()
261
+ } catch (_) {}
262
+ whichCache.set(bin, resolved)
263
+ }
264
+ return whichCache.get(bin)
257
265
  }
258
266
 
259
- // probe the binary once, not per request: the default runners are wired as
260
- // default parameters (evaluated on every call), so memoizeOne keeps the probe
261
- // (`which` and, for pandoc, `--list-input-formats`) from re-spawning each time.
267
+ // The default runners are wired as default parameters (evaluated on every
268
+ // call), so memoizeOne builds each runner once instead of re-running the pandoc
269
+ // `--list-input-formats` probe and rebuilding the closure per request.
262
270
  const defaultMutool = memoizeOne(() => {
263
271
  const mutoolPath = whichSync('mutool')
264
272
  if (!mutoolPath) return
@@ -420,3 +428,10 @@ module.exports.isFetchMode = isFetchMode
420
428
  module.exports.getContent = getContent
421
429
  module.exports.defaultMutool = defaultMutool
422
430
  module.exports.defaultPandoc = defaultPandoc
431
+
432
+ // html-get already resolves pandoc/mutool for office and PDF conversion; expose
433
+ // the cached paths so a consumer (e.g. the microlink api markdown pipeline)
434
+ // reuses them instead of running its own `which`. Each returns undefined when
435
+ // the binary is not installed. Lazy: nothing runs until first call.
436
+ module.exports.getPandocPath = () => whichSync('pandoc')
437
+ module.exports.getMutoolPath = () => whichSync('mutool')