Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Get the value of the key
var value = args[key];
// Validity check to push only string, number and boolean values command line arguments
var validValue = is.string(value) || is.number(value) || is.boolean(value);
// Validity check
if (validValue && is.truthy(value)) {
// Check for custom handling keys
if (is.not.inArray(key, keysIgnored)) {
// Push the key
argsToSpawn.push(key);
// Push value for string and number values
if (is.string(value)) argsToSpawn.push(value);
else if (is.number(value)) argsToSpawn.push(value.toString());
}
// Check if should handle loop
else if (is.equal(key, '--loop')) {
self._configurations.loop = true;
}
}
});
export const equal = (name, value, schema) => ({
isValid: is.equal(value * 1, schema.equal * 1),
errorText: `${name} should equal to ${schema.equal * 1}.`
});
OmxManager.prototype.setDbusController = function setDbusController(controller) {
if (is.equal(controller, true)) this._dbusController = true;
else this._dbusController = false;
};
export const maxLength = (name, value, schema) => ({
isValid: is.equal(value.length, schema.maxLength) || is.under(value.length, schema.maxLength),
errorText: `${name}'s length should be equal or less than ${schema.maxLength}. Current: ${value.length}`
});
export function equalHandler(value, schema) {
const target = schema.equal * 1;
const isValid = is.equal(value * 1, target);
if (isValid) return;
const errorText = `${NAME_PLACEHOLDER} should equal to ${target}.`;
throwError(value, errorText);
}