UNPKG

legal-markdown-js

Version:

Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version

95 lines 3.15 kB
/** * Browser shims for Node.js modules * * These are minimal implementations to satisfy imports * in browser environments. Most functionality is stubbed * since file system operations don't apply in browsers. */ // fs module shim const createBrowserUnsupportedError = (api) => { return new Error(`${api} is not available in browser builds. ` + `This operation requires Node.js filesystem access. ` + `If your document uses @import or file-based processing, resolve those files before running in the browser.`); }; const throwBrowserUnsupported = (api) => { throw createBrowserUnsupportedError(api); }; export const existsSync = (..._args) => throwBrowserUnsupported('fs.existsSync'); export const readFileSync = (..._args) => throwBrowserUnsupported('fs.readFileSync'); export const writeFileSync = (..._args) => throwBrowserUnsupported('fs.writeFileSync'); export const mkdirSync = (..._args) => throwBrowserUnsupported('fs.mkdirSync'); export const readdirSync = (..._args) => throwBrowserUnsupported('fs.readdirSync'); export const statSync = (..._args) => throwBrowserUnsupported('fs.statSync'); export const copyFileSync = (..._args) => throwBrowserUnsupported('fs.copyFileSync'); export const unlinkSync = (..._args) => throwBrowserUnsupported('fs.unlinkSync'); export const renameSync = (..._args) => throwBrowserUnsupported('fs.renameSync'); const realpathSyncWithNative = ((..._args) => { return throwBrowserUnsupported('fs.realpathSync'); }); realpathSyncWithNative.native = (..._args) => { return throwBrowserUnsupported('fs.realpathSync.native'); }; export const realpathSync = realpathSyncWithNative; // fs/promises shim export const readFile = async (..._args) => { return throwBrowserUnsupported('fs/promises.readFile'); }; export const writeFile = async (..._args) => { return throwBrowserUnsupported('fs/promises.writeFile'); }; export const mkdir = async (..._args) => { return throwBrowserUnsupported('fs/promises.mkdir'); }; export const readdir = async (..._args) => { return throwBrowserUnsupported('fs/promises.readdir'); }; export const stat = async (..._args) => { return throwBrowserUnsupported('fs/promises.stat'); }; export const copyFile = async (..._args) => { return throwBrowserUnsupported('fs/promises.copyFile'); }; export const unlink = async (..._args) => { return throwBrowserUnsupported('fs/promises.unlink'); }; export const rename = async (..._args) => { return throwBrowserUnsupported('fs/promises.rename'); }; export const realpath = async (..._args) => { return throwBrowserUnsupported('fs/promises.realpath'); }; export const promises = { readFile, writeFile, mkdir, readdir, stat, copyFile, unlink, rename, realpath, }; // Default export export default { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, copyFileSync, unlinkSync, renameSync, realpathSync, readFile, writeFile, mkdir, readdir, stat, copyFile, unlink, rename, realpath, promises, }; //# sourceMappingURL=browser-shims.js.map