feiyu02
2025-10-20 eb4111e0fd7110e5aa6a00608da2da9af21a3035
src/utils/expand/expand.js
@@ -24,3 +24,24 @@
  }
  return fmt;
};
Array.prototype.lastCount = function (size) {
  const l = this.length;
  const s = size > this.length ? 0 : this.length - size;
  return this.slice(s, l);
};
Array.prototype.groupBy = function (func) {
  const groups = {};
  this.forEach((item) => {
    const key = func(item);
    if (!groups[key]) {
      groups[key] = [];
    }
    groups[key].push(item);
  });
  return Object.keys(groups).map((key) => ({
    key,
    values: groups[key]
  }));
};