ephrem
Version:
Ephrem is a light-weight API wrapper for API.Bible, built using NodeJS and Typescript. Ephrem validates bible references and fetches scripture text corresponding to the references.
42 lines • 1.2 kB
JavaScript
import envPaths from "env-paths";
import fs from "node:fs";
const PROJECT_NAME = "ephrem";
const ephremPaths = envPaths(PROJECT_NAME);
const createDataDir = async () => {
try {
await fs.promises.mkdir(ephremPaths.data, { recursive: true });
} catch (error) {
if (error instanceof Error && "code" in error && error.code === "EEXIST") {
console.log("Ephrem Data Directory already exists.");
} else {
console.error("Error creating Ephrem Data Directory:", error);
}
}
};
const removePunctuation = (input) => input.replace(/\p{P}/gu, "");
const normalizeBookName = (bookName) => removePunctuation(bookName).toLowerCase();
class BaseEphremError extends Error {
/**
* A record containing additional context information about the error.
* @type {Record<string, unknown>}
*/
context;
/**
* Creates an instance of BaseEphremError.
* @param message The error message to show to the user.
*/
constructor(message) {
super(message);
this.name = "BaseEphremError";
this.context = {};
}
}
export {
BaseEphremError,
PROJECT_NAME,
createDataDir,
ephremPaths,
normalizeBookName,
removePunctuation
};
//# sourceMappingURL=utils.js.map