UNPKG

@alynva/outline-pdf-cjs

Version:

Add outline to outline-less pdf. Works in node and does not have any dependency on other programming languages.

26 lines (25 loc) 885 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._errorMessages = exports.rejectIfPathExistsFactory = void 0; /** * @description It returns a rejected promise if the provided path corresponds to a file or directory, * otherwise it returns a void fulfilled promise. */ function rejectIfPathExistsFactory(fs) { return async function rejectIfPathExists(path) { const pathExist = await fs.promises .access(path) .then(() => true) .catch(() => false); if (pathExist) throw Error(exports._errorMessages.pathExist(path)); else return undefined; }; } exports.rejectIfPathExistsFactory = rejectIfPathExistsFactory; exports._errorMessages = { pathExist: (path) => ` There is already a file or directory for the provided path "${path}". `.trim(), };