Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
properties = properties.map(property => {
if (typeof property === 'string') { // simple index
return { key: property, value: true };
} else if (typeof property === 'function') { // computed index
let key = fnName(property);
if (!key) throw new Error('Invalid index definition: computed index function cannot be anonymous. Use a named function or set the displayName function property.');
return { key, value: property };
} else {
throw new Error('Invalid index definition');
}
});
return properties;
export function runValidators(value, validators) {
let failedValidators;
for (const validator of validators) {
if (!validator(value)) {
if (!failedValidators) {
failedValidators = [];
}
failedValidators.push(fnName(validator));
}
}
return failedValidators;
}
let name = type => typeof type === 'string'
? type : type.displayName || fnName(type) || ''