@8ms/helpers 2.4.0 → 2.4.3

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.
@@ -1,6 +1,9 @@
1
1
  //#region src/lodash/chunk.d.ts
2
2
  declare const chunk: <T>(array: T[], size: number) => T[][];
3
3
  //#endregion
4
+ //#region src/lodash/findKey.d.ts
5
+ declare const findKey: <T extends object>(object: T | null | undefined, predicate?: any) => string | undefined;
6
+ //#endregion
4
7
  //#region src/lodash/flatten.d.ts
5
8
  declare const flatten: <T>(array: T[][]) => T[];
6
9
  //#endregion
@@ -42,4 +45,4 @@ declare const uniq: (arr: any[]) => any[];
42
45
  //#region src/lodash/uniqBy.d.ts
43
46
  declare const uniqBy: <T>(collection: T[], iteratee: ((item: T) => unknown) | string) => T[];
44
47
  //#endregion
45
- export { chunk, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
48
+ export { chunk, findKey, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
@@ -5,6 +5,35 @@ const chunk = (array, size) => {
5
5
  return result;
6
6
  };
7
7
  //#endregion
8
+ //#region src/lodash/findKey.ts
9
+ const findKey = (object, predicate) => {
10
+ if (object == null) return;
11
+ const iteratee = getBaseIteratee(predicate);
12
+ let result;
13
+ for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) {
14
+ const value = object[key];
15
+ if (iteratee(value, key, object)) {
16
+ result = key;
17
+ break;
18
+ }
19
+ }
20
+ return result;
21
+ };
22
+ const getBaseIteratee = (value) => {
23
+ if (typeof value === "function") return value;
24
+ if (value == null) return (val) => val;
25
+ if (typeof value === "object") return (obj) => baseMatches(obj, value);
26
+ return (obj) => obj[value];
27
+ };
28
+ const baseMatches = (object, source) => {
29
+ if (object === source) return true;
30
+ if (object == null || source == null) return false;
31
+ for (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) {
32
+ if (object[key] !== source[key]) return false;
33
+ }
34
+ return true;
35
+ };
36
+ //#endregion
8
37
  //#region src/lodash/flatten.ts
9
38
  const flatten = (array) => [].concat(...array);
10
39
  //#endregion
@@ -160,4 +189,4 @@ const uniqBy = (collection, iteratee) => {
160
189
  });
161
190
  };
162
191
  //#endregion
163
- export { chunk, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
192
+ export { chunk, findKey, flatten, isDate, isEmpty, isEqual, isFunction, 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.4.0",
4
+ "version": "2.4.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -16,6 +16,7 @@
16
16
  "node": "24"
17
17
  },
18
18
  "dependencies": {
19
+ "fs-extra": "^11.0.0",
19
20
  "ky": "^2.0.0",
20
21
  "luxon": "^3.7.2",
21
22
  "zod": "^4.3.6"
@@ -44,7 +45,6 @@
44
45
  "@prisma/adapter-planetscale": "^7.0.0",
45
46
  "@prisma/client": "^7.0.0",
46
47
  "drizzle-orm": "*",
47
- "fs-extra": "^11.0.0",
48
48
  "googleapis-common": "^8.0.0",
49
49
  "next": "^16.0.0",
50
50
  "react": "^19.0.0",