Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options.prefixUrl += '/';
}
} else {
options.prefixUrl = defaults ? defaults.prefixUrl : '';
}
// `options.hooks`
if (is.undefined(options.hooks)) {
options.hooks = {};
}
if (is.object(options.hooks)) {
for (const event of knownHookEvents) {
if (Reflect.has(options.hooks, event)) {
if (!is.array(options.hooks[event])) {
throw new TypeError(`Parameter \`${event}\` must be an Array, not ${is(options.hooks[event])}`);
}
} else {
options.hooks[event] = [];
}
}
} else {
throw new TypeError(`Parameter \`hooks\` must be an Object, not ${is(options.hooks)}`);
}
if (defaults) {
for (const event of knownHookEvents) {
if (!(Reflect.has(options.hooks, event) && is.undefined(options.hooks[event]))) {
// @ts-ignore Union type array is not assignable to union array type
options.hooks[event] = [
...defaults.hooks[event],
...options.hooks[event]!
message: (value, label) => {
// We do not include type in this label as we do for other messages, because it would be redundant.
const label_ = label?.slice(this.type.length + 1);
return `Expected ${label_ || 'argument'} to be of type \`${this.type}\` but received type \`${is(value)}\``;
},
validator: value => (is as any)[x](value)
if (is.undefined(options.hooks)) {
options.hooks = {};
}
if (is.object(options.hooks)) {
for (const event of knownHookEvents) {
if (Reflect.has(options.hooks, event)) {
if (!is.array(options.hooks[event])) {
throw new TypeError(`Parameter \`${event}\` must be an Array, not ${is(options.hooks[event])}`);
}
} else {
options.hooks[event] = [];
}
}
} else {
throw new TypeError(`Parameter \`hooks\` must be an Object, not ${is(options.hooks)}`);
}
if (defaults) {
for (const event of knownHookEvents) {
if (!(Reflect.has(options.hooks, event) && is.undefined(options.hooks[event]))) {
// @ts-ignore Union type array is not assignable to union array type
options.hooks[event] = [
...defaults.hooks[event],
...options.hooks[event]!
];
}
}
}
// `options.timeout`
if (is.number(options.timeout)) {