map.js 310 B

12345
  1. export default function map(values, mapper) {
  2. if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
  3. if (typeof mapper !== "function") throw new TypeError("mapper is not a function");
  4. return Array.from(values, (value, index) => mapper(value, index, values));
  5. }