@8ms/helpers 2.3.10 → 2.3.12

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
@@ -1,3 +1,9 @@
1
+ //#region src/lodash/chunk.d.ts
2
+ declare const chunk: <T>(array: T[], size: number) => T[][];
3
+ //#endregion
4
+ //#region src/lodash/flatten.d.ts
5
+ declare const flatten: <T>(array: T[][]) => T[];
6
+ //#endregion
1
7
  //#region src/lodash/set.d.ts
2
8
  declare const set: <T extends object>(obj: T, path: string | string[], value: unknown) => T;
3
9
  //#endregion
@@ -30,4 +36,7 @@ declare const unescape: (str: string) => string;
30
36
  //#region src/lodash/uniq.d.ts
31
37
  declare const uniq: (arr: any[]) => any[];
32
38
  //#endregion
33
- export { isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq };
39
+ //#region src/lodash/uniqBy.d.ts
40
+ declare const uniqBy: <T>(collection: T[], iteratee: ((item: T) => unknown) | string) => T[];
41
+ //#endregion
42
+ export { chunk, flatten, isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
@@ -1,3 +1,15 @@
1
+ //#region src/lodash/chunk.ts
2
+ const chunk = (array, size) => {
3
+ const result = [];
4
+ for (let i = 0; i < array.length; i += size) result.push(array.slice(i, i + size));
5
+ return result;
6
+ };
7
+
8
+ //#endregion
9
+ //#region src/lodash/flatten.ts
10
+ const flatten = (array) => [].concat(...array);
11
+
12
+ //#endregion
1
13
  //#region src/lodash/set.ts
2
14
  const set = (obj, path, value) => {
3
15
  if (obj == null) return obj;
@@ -141,4 +153,20 @@ const unescape = (str) => {
141
153
  const uniq = (arr) => [...new Set(arr)];
142
154
 
143
155
  //#endregion
144
- export { isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq };
156
+ //#region src/lodash/uniqBy.ts
157
+ const uniqBy = (collection, iteratee) => {
158
+ const seen = /* @__PURE__ */ new Set();
159
+ const getValue = (item) => {
160
+ if (typeof iteratee === "function") return iteratee(item);
161
+ return iteratee.split(".").reduce((acc, part) => acc?.[part], item);
162
+ };
163
+ return collection.filter((item) => {
164
+ const key = getValue(item);
165
+ if (seen.has(key)) return false;
166
+ seen.add(key);
167
+ return true;
168
+ });
169
+ };
170
+
171
+ //#endregion
172
+ export { chunk, flatten, isDate, isEmpty, isEqual, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
@@ -39,7 +39,7 @@ declare const isUndefined: (instance: any, keys: any | any[]) => boolean;
39
39
  * Chunk a queue of promises into controlled chunks to prevent overloading.
40
40
  * https://stackoverflow.com/a/53964407
41
41
  */
42
- declare const promiseChunks: (promises: Promise<any>[], size: number, sleepSeconds?: number, callbackFunction?: Function) => Promise<any>;
42
+ declare const promiseChunks: (promises: Promise<any>[], size: number, sleepSeconds?: number, callbackFunction?: Function) => Promise<unknown[]>;
43
43
  //#endregion
44
44
  //#region src/util/sleep.d.ts
45
45
  declare const sleep: (seconds: number) => Promise<void>;
@@ -1,6 +1,5 @@
1
- import { isObject } from "../lodash/index.mjs";
1
+ import { chunk, flatten, isObject } from "../lodash/index.mjs";
2
2
  import { getArray } from "../array/index.mjs";
3
- import { chunk, flatten } from "lodash";
4
3
 
5
4
  //#region src/util/defaultTo.ts
6
5
  /**
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.12",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"