Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

groupBy.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = groupBy;
  6. var _groupByLimit = require('./groupByLimit');
  7. var _groupByLimit2 = _interopRequireDefault(_groupByLimit);
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * Returns a new object, where each value corresponds to an array of items, from
  11. * `coll`, that returned the corresponding key. That is, the keys of the object
  12. * correspond to the values passed to the `iteratee` callback.
  13. *
  14. * Note: Since this function applies the `iteratee` to each item in parallel,
  15. * there is no guarantee that the `iteratee` functions will complete in order.
  16. * However, the values for each key in the `result` will be in the same order as
  17. * the original `coll`. For Objects, the values will roughly be in the order of
  18. * the original Objects' keys (but this can vary across JavaScript engines).
  19. *
  20. * @name groupBy
  21. * @static
  22. * @memberOf module:Collections
  23. * @method
  24. * @category Collection
  25. * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
  26. * @param {AsyncFunction} iteratee - An async function to apply to each item in
  27. * `coll`.
  28. * The iteratee should complete with a `key` to group the value under.
  29. * Invoked with (value, callback).
  30. * @param {Function} [callback] - A callback which is called when all `iteratee`
  31. * functions have finished, or an error occurs. Result is an `Object` whoses
  32. * properties are arrays of values which returned the corresponding key.
  33. * @returns {Promise} a promise, if no callback is passed
  34. * @example
  35. *
  36. * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
  37. * db.findById(userId, function(err, user) {
  38. * if (err) return callback(err);
  39. * return callback(null, user.age);
  40. * });
  41. * }, function(err, result) {
  42. * // result is object containing the userIds grouped by age
  43. * // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
  44. * });
  45. */
  46. function groupBy(coll, iteratee, callback) {
  47. return (0, _groupByLimit2.default)(coll, Infinity, iteratee, callback);
  48. }
  49. module.exports = exports['default'];