@8ms/helpers 2.3.10 → 2.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -30,4 +30,7 @@ declare const unescape: (str: string) => string;
30
30
  //#region src/lodash/uniq.d.ts
31
31
  declare const uniq: (arr: any[]) => any[];
32
32
  //#endregion
33
- export { isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq };
33
+ //#region src/lodash/uniqBy.d.ts
34
+ declare const uniqBy: <T>(collection: T[], iteratee: ((item: T) => unknown) | string) => T[];
35
+ //#endregion
36
+ export { isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
@@ -141,4 +141,20 @@ const unescape = (str) => {
141
141
  const uniq = (arr) => [...new Set(arr)];
142
142
 
143
143
  //#endregion
144
- export { isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq };
144
+ //#region src/lodash/uniqBy.ts
145
+ const uniqBy = (collection, iteratee) => {
146
+ const seen = /* @__PURE__ */ new Set();
147
+ const getValue = (item) => {
148
+ if (typeof iteratee === "function") return iteratee(item);
149
+ return iteratee.split(".").reduce((acc, part) => acc?.[part], item);
150
+ };
151
+ return collection.filter((item) => {
152
+ const key = getValue(item);
153
+ if (seen.has(key)) return false;
154
+ seen.add(key);
155
+ return true;
156
+ });
157
+ };
158
+
159
+ //#endregion
160
+ export { isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.3.10",
4
+ "version": "2.3.11",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"