| 185 | } |
| 186 | |
| 187 | function extractResult(opts) { |
| 188 | const { type, extractor, fallback = true } = opts; |
| 189 | |
| 190 | const result = select({ ...opts, extractionOpts: extractor[type] }); |
| 191 | |
| 192 | // If custom parser succeeds, return the result |
| 193 | if (result) { |
| 194 | return result; |
| 195 | } |
| 196 | |
| 197 | // If nothing matches the selector, and fallback is enabled, |
| 198 | // run the Generic extraction |
| 199 | if (fallback) return GenericExtractor[type](opts); |
| 200 | |
| 201 | return null; |
| 202 | } |
| 203 | |
| 204 | const RootExtractor = { |
| 205 | extract(extractor = GenericExtractor, opts) { |