UNPKG

octavia-db

Version:

OctaviaDB - A lightweight, AES-encrypted NoSQL database for fast and secure local storage in Node.js.

31 lines (26 loc) 814 B
// Custom error class for OctaviaDB. class OctaviaError extends Error { constructor(message, options) { super(message) if (typeof options === "object" && !Array.isArray(options)) { Object.assign(this, options) } } } // Throws an error if the data is not an object or is an array. function isNotObjectThrowError(data) { if (typeof data !== "object" || Array.isArray(data)) { throw new OctaviaError("Datatype error. Object required.") } } // Throws an error if the data is not an array. function isNotArrayThrowError(data) { if (!Array.isArray(data)) { throw new OctaviaError("Datatype error. Array required.") } } module.exports = { isNotObjectThrowError, isNotArrayThrowError, OctaviaError }