HEX
Server: Apache/2.4.18 (Ubuntu)
System: Linux ubuntu 7.0.5-x86_64-linode173 #1 SMP PREEMPT_DYNAMIC Fri May 8 10:12:05 EDT 2026 x86_64
User: root (0)
PHP: 7.2.28-1+ubuntu16.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //opt/code/node_modules/webpack/lib/OptionsDefaulter.js
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";

function getProperty(obj, name) {
	name = name.split(".");
	for(var i = 0; i < name.length - 1; i++) {
		obj = obj[name[i]];
		if(typeof obj !== "object" || !obj) return;
	}
	return obj[name.pop()];
}

function setProperty(obj, name, value) {
	name = name.split(".");
	for(var i = 0; i < name.length - 1; i++) {
		if(typeof obj[name[i]] !== "object" && typeof obj[name[i]] !== "undefined") return;
		if(!obj[name[i]]) obj[name[i]] = {};
		obj = obj[name[i]];
	}
	obj[name.pop()] = value;
}

class OptionsDefaulter {
	constructor() {
		this.defaults = {};
		this.config = {};
	}

	process(options) {
		for(let name in this.defaults) {
			switch(this.config[name]) {
				case undefined:
					if(getProperty(options, name) === undefined)
						setProperty(options, name, this.defaults[name]);
					break;
				case "call":
					setProperty(options, name, this.defaults[name].call(this, getProperty(options, name), options), options);
					break;
				case "make":
					if(getProperty(options, name) === undefined)
						setProperty(options, name, this.defaults[name].call(this, options), options);
					break;
				case "append":
					{
						let oldValue = getProperty(options, name);
						if(!Array.isArray(oldValue)) oldValue = [];
						oldValue.push.apply(oldValue, this.defaults[name]);
						setProperty(options, name, oldValue);
						break;
					}
				default:
					throw new Error("OptionsDefaulter cannot process " + this.config[name]);
			}
		}
	}

	set(name, config, def) {
		if(arguments.length === 3) {
			this.defaults[name] = def;
			this.config[name] = config;
		} else {
			this.defaults[name] = config;
			delete this.config[name];
		}
	}
}

module.exports = OptionsDefaulter;