Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const ow = require('ow');
const Task = require('./task');
function checkTask(t) {
return {
validator: t instanceof Task,
message: `Expected ${t} to be a Task object`
};
}
module.exports = {
checkTaskOrString: ow.any(ow.object.validate(checkTask), ow.string),
DependencyCycleError: class DependencyCycleError extends Error {
constructor(message, cyclePath) {
ow(message, ow.string);
ow(cyclePath, ow.array.ofType(ow.string));
super(message);
this.cyclePath = cyclePath;
this.name = 'DependencyCycleError';
}
},
StateError: class StateError extends Error {
constructor(message) {
ow(message, ow.string);
super(message);
this.name = 'StateError';
this.actionWrapper(async () => {
ow(voteorder, ow.any(ow_extend.isValidJson("voteorder"), ow_extend.fileExists("voteorder")));
return new SendVoteorderAction(this.context).doAction(await this.loadConfig(true), voteorder);
}),
);
args.push('--speed', options.speed);
}
if (typeof options.strip !== 'undefined') {
ow(options.strip, ow.boolean);
args.push('--strip');
}
if (typeof options.quality !== 'undefined') {
ow(options.quality, ow.array.length(2).ofType(ow.number.inRange(0, 1)));
const [min, max] = options.quality;
args.push('--quality', `${Math.round(min * 100)}-${Math.round(max * 100)}`);
}
if (typeof options.dithering !== 'undefined') {
ow(options.dithering, ow.any(ow.number.inRange(0, 1), ow.boolean.false));
if (typeof options.dithering === 'number') {
args.push(`--floyd=${options.dithering}`);
} else if (options.dithering === false) {
args.push('--ordered');
}
}
if (typeof options.posterize !== 'undefined') {
ow(options.posterize, ow.number);
args.push('--posterize', options.posterize);
}
if (typeof options.verbose !== 'undefined') {
ow(options.verbose, ow.boolean);
args.push('--verbose');