Dashboard sipadu mbip
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021
  1. 'use strict';
  2. var nestedValue = require('../helpers/nestedValue');
  3. module.exports = function keyBy(key) {
  4. var collection = {};
  5. if (typeof key === 'function') {
  6. this.items.forEach(function (item) {
  7. collection[key(item)] = item;
  8. });
  9. } else {
  10. this.items.forEach(function (item) {
  11. var keyValue = nestedValue(item, key);
  12. collection[keyValue || ''] = item;
  13. });
  14. }
  15. return new this.constructor(collection);
  16. };