UNPKG

nodecache.js

Version:

Simple, Intuitive in-memory cache with TTL support for Node.

36 lines (30 loc) 1.04 kB
/******************************************* * copyright: nodeCache.js @github.com/akashchouhan16 * author: @akashchouhan16 * ***************************************** */ const { error } = require("console") const CONSTANTS = require("./constants") let validator = (options = {}) => { let isModeValid = true let isPathValid = true const date = new Date().toLocaleString("en-US", this.formatOptions) //NOTE: options param is optionals, hence valid. if (!options || options == {}) return true let { mode, path } = options if (!mode || ["none", "std", "exp"].includes(mode)) { this.isModeValid = true } else { error(`[🍁 Err] ${date}: ${CONSTANTS.INVALID_MOD}`) this.isModeValid = false } if (!path || ["none", "console", "file"].includes(path)) { this.isPathValid = true } else { error(`[🍁 Err] ${date}: ${CONSTANTS.INVALID_PATH}`) this.isPathValid = false } return isModeValid && isPathValid } module.exports = validator