How to use the defaults.bufferSize function in defaults

To help you get started, we’ve selected a few defaults examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rapid7 / le_node / src / node_modules / logger.js View on Github external
this[$levels] = levelUtil.normalize(opts);

		for (const lvlName of this.levels) {
			if (lvlName in this)
				throw new BadOptionsError(opts, text.levelConflict(lvlName));

			Object.defineProperty(this, lvlName, {
				enumerable: true,
				writable: false,
				value() {
					this.log.apply(this, [lvlName, ...arguments]);
				}
			});
		}

		const bufferSizeConfig = opts.bufferSize || defaults.bufferSize;

		this.ringBuffer = new RingBuffer(bufferSizeConfig);

		// Other permanent options

		this[$token] = opts.token;

		// Editable options

		const secure = opts.secure === undefined ? defaults.secure : opts.secure;

		this.bufferSize                 = bufferSizeConfig;
		this.port                       = opts.port || (secure ? defaults.portSecure : defaults.port);
		this.flatten                    = opts.flatten;
		this.flattenArrays              = 'flattenArrays' in opts ? opts.flattenArrays : opts.flatten;
		this.json                       = opts.json;