UNPKG

benchmark-meter

Version:

benchmark-meter is a straightforward benchmarking tool designed for measuring the performance of algorithms

31 lines (30 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigHandler = void 0; const exceptions_1 = require("../exceptions"); const config_1 = require("./config"); class ConfigHandler { static parse(options) { if (typeof options === 'object') { ConfigHandler.validateType(options); ConfigHandler.validateValue(options); return { repeat: options.repeat ?? config_1.defaultConfig.repeat, }; } else { return config_1.defaultConfig; } } static validateType({ repeat }) { if (repeat !== undefined && typeof repeat !== 'number') { throw new TypeError(`repeat must be a number. Received: ${typeof repeat}`); } } static validateValue({ repeat }) { if (repeat !== undefined && repeat < 1) { throw new exceptions_1.InvalidValueException('repeat must be bigger than 0'); } } } exports.ConfigHandler = ConfigHandler;