Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

object.js 537B

12345678910111213141516
  1. import getLength from './_getLength.js';
  2. // Converts lists into objects. Pass either a single array of `[key, value]`
  3. // pairs, or two parallel arrays of the same length -- one of keys, and one of
  4. // the corresponding values. Passing by pairs is the reverse of `_.pairs`.
  5. export default function object(list, values) {
  6. var result = {};
  7. for (var i = 0, length = getLength(list); i < length; i++) {
  8. if (values) {
  9. result[list[i]] = values[i];
  10. } else {
  11. result[list[i][0]] = list[i][1];
  12. }
  13. }
  14. return result;
  15. }