From ec763e1cb7dca873caf4afbc0dfde047b51753d3 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 17 十月 2025 17:26:54 +0800
Subject: [PATCH] 2025.10.17
---
src/utils/expand/expand.js | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/utils/expand/expand.js b/src/utils/expand/expand.js
index 6495211..cda8235 100644
--- a/src/utils/expand/expand.js
+++ b/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]
+ }));
+};
--
Gitblit v1.9.3