Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.hasRoot = opts.root !== undefined;
opts.width = opts.width || 300;
opts.root = opts.root || document.body;
opts.align = opts.align || 'left'; // Can be 'left' or 'right'
opts.opacity = opts.opacity || 1.0;
opts.barMode = opts.barMode || 'offset'; // Can be 'none', 'above', 'offset', or 'overlay'
opts.panelMode = opts.panelMode || 'inner';
opts.pollRateMS = opts.pollRateMS || 100;
opts.open = opts.open || false;
// Set theme global from opts
let chosenTheme = opts.theme;
if(opts.theme === undefined) chosenTheme = themes.dark;
if(isstring(opts.theme)) {
if(themes[opts.theme] === undefined) {
console.error(`There is no theme preset with the name '${opts.theme}'! Defaulting to dark theme.`);
chosenTheme = themes.dark;
}
else chosenTheme = themes[opts.theme];
}
theme.Set(chosenTheme);
this._ConstructElements();
this._LoadStyles();
this.componentManager = new ComponentManager();
this.loadedComponents = [];
// Begin component update loop
transformValue(value, options) {
if (isPlainObject(value) || isArray(value)) { // ?
for (let objKey in value) {
value[objKey] = this.transformValue(value[objKey], options);
}
} else if (isString(value)) {
// replace params here
let regex = /\{\{(\w+)\}\}/g;
let matched;
let replaceItems = [];
do {
matched = regex.exec(value);
if (matched) {
let macro = matched[0];
let macroKey = matched[1];
let macroValue = this.getMacroKeyValue(macroKey, options);
if (typeof macroValue !== "undefined") {
replaceItems.push({ key: macroKey, value: macroValue })
}
}
} while (matched);
if (replaceItems.length > 0) {
return formatted.map((val) => {
// Only if this is a string (not a nested array, which would have already been padded)
if (isString(val) && val.length < maxLength) {
// Depending on symbol position, pad after symbol or at index 0
return padAfterSymbol ?
val.replace(opts.symbol, opts.symbol + (new Array(maxLength - val.length + 1).join(' '))) :
(new Array(maxLength - val.length + 1).join(' ')) + val;
}
return val;
});
}
function checkCurrencyFormat(format) {
// Format should be a string, in which case `value` ('%v') must be present
if (isString(format) && format.match('%v')) {
// Create and return positive, negative and zero formats
return {
pos: format,
neg: format.replace('-', '').replace('%v', '-%v'),
zero: format
};
}
// Otherwise, assume format was fine
return format;
}
return "BLC_ROBOTS";
}
else if (matchURL(href, excludedKeywords))
{
return "BLC_KEYWORD";
}
else if (includedKeywords.length>0 && !matchURL(href, includedKeywords))
{
return "BLC_KEYWORD";
}
else
{
const filterResult = includeLink(link);
// Undocumented support for strings (from `SiteChecker`)
if (isString(filterResult) && filterResult in reasons)
{
return filterResult;
}
else if (!filterResult)
{
return "BLC_CUSTOM";
}
else
{
// Not excluded
}
}
}
function propString(prop, options) {
if (isString(prop)) {
return inspect(String(prop), { quoteStyle: 'double' });
}
if (isNumber(prop)) {
return `{${inspect(Number(prop))}}`;
}
if (isBoolean(prop)) {
return `{${inspect(booleanValue(prop))}}`;
}
if (isCallable(prop)) {
return `{${inspect(prop)}}`;
}
if (typeof prop === 'object') {
if (options.verbose) {
return `{${inspect(prop)}}`;
}
const hasHTTPProtocol = url => isString(url) && url.startsWith('http')