validate_algorithms.js 356 B

12345678910
  1. export function 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. }