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

object.js 581B

1234567891011121314151617181920
  1. define(['./_getLength'], function (_getLength) {
  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. 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. }
  16. return object;
  17. });