validate_algorithms.js 388 B

1234567891011
  1. const validateAlgorithms = (option, algorithms) => {
  2. if (algorithms !== undefined &&
  3. (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {
  4. throw new TypeError(`"${option}" option must be an array of strings`);
  5. }
  6. if (!algorithms) {
  7. return undefined;
  8. }
  9. return new Set(algorithms);
  10. };
  11. export default validateAlgorithms;