UNPKG

netscape-bookmark-parser

Version:

A TypeScript/JavaScript library for parsing browser bookmark files (HTML format) and manipulating them as structured data. Compatible with both Deno and Node.js runtimes.

29 lines (28 loc) 784 B
import { DOM as NWAPI } from "./nwsapi-types.js"; import { DOM as Sizzle } from "./sizzle-types.js"; let codeGenerationAllowed = null; export function getSelectorEngine() { if (codeGenerationAllowed === null) { try { new Function(""); codeGenerationAllowed = true; } catch (e) { codeGenerationAllowed = false; } } if (codeGenerationAllowed) { return NWAPI; } else { return Sizzle; } } /** * Explicitly disable querySelector/All code generation with the `Function` * constructor forcing the Sizzle engine. Enables those APIs on platforms * like Deno Deploy that don't allow code generation. */ export function disableCodeGeneration() { codeGenerationAllowed = false; }