@8ms/helpers 2.3.8 → 2.3.9

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,7 +1,6 @@
1
+ import { set } from "../lodash/index.mjs";
1
2
  import { defaultTo } from "../util/index.mjs";
2
3
  import { isServer } from "../environment/index.mjs";
3
- import isArray from "lodash/isArray";
4
- import set from "lodash/set";
5
4
 
6
5
  //#region src/_class/BaseClass.ts
7
6
  var BaseClass = class {
@@ -9,7 +8,7 @@ var BaseClass = class {
9
8
  * Shortcut to set a value to an array and return the instance.
10
9
  */
11
10
  _setArray = (fields, input) => {
12
- if (isArray(input)) set(this, fields, input);
11
+ if (Array.isArray(input)) set(this, fields, input);
13
12
  else set(this, fields, [input]);
14
13
  return this;
15
14
  };
@@ -25,7 +24,7 @@ var BaseClass = class {
25
24
  */
26
25
  _push = (fields, input) => {
27
26
  let temp = this._get(fields, []);
28
- if (isArray(input)) temp = temp.concat(input);
27
+ if (Array.isArray(input)) temp = temp.concat(input);
29
28
  else temp = temp.push(input);
30
29
  set(this, fields, temp);
31
30
  return this;
@@ -1,5 +1,3 @@
1
- import isArray from "lodash/isArray";
2
-
3
1
  //#region src/array/array.ts
4
2
  /**
5
3
  * Shorthand to check if an array or string contains a needle.
@@ -8,7 +6,7 @@ const contains = (haystack, needle) => -1 !== haystack.indexOf(needle);
8
6
  /**
9
7
  * Convert an array into an array or return if already an array.
10
8
  */
11
- const getArray = (input) => isArray(input) ? input : [input];
9
+ const getArray = (input) => Array.isArray(input) ? input : [input];
12
10
 
13
11
  //#endregion
14
12
  export { contains, getArray };
@@ -5,7 +5,6 @@ import { n as isResponse200, t as getConfig } from "../../../server-Dbl5Ic6I.mjs
5
5
  import { getBrotliCompressed, getBrotliDecompressed, getGzipCompressed, getGzipDecompressed } from "../../../util/server/index.mjs";
6
6
  import { z } from "zod/v4";
7
7
  import axios from "axios";
8
- import cloneDeep from "lodash/cloneDeep";
9
8
 
10
9
  //#region src/aws/s3/server/AwsS3Namespace.ts
11
10
  var AwsS3Namespace = class extends BaseNamespace {
@@ -189,7 +188,7 @@ var AwsS3Namespace = class extends BaseNamespace {
189
188
  };
190
189
  readFile = async (bucket, key, options = {}) => {
191
190
  await this.ensureInit();
192
- let response = cloneDeep(readFileDefault);
191
+ let response = structuredClone(readFileDefault);
193
192
  const today = getToday();
194
193
  getToday(true);
195
194
  try {
@@ -1,6 +1,5 @@
1
1
  import { BaseClass, BaseNamespace } from "../../../_class/index.mjs";
2
2
  import { t as getConfig } from "../../../server-Dbl5Ic6I.mjs";
3
- import uniq from "lodash/uniq";
4
3
 
5
4
  //#region src/aws/ses/server/AwsSesNamespace.ts
6
5
  var AwsSesNamespace = class extends BaseNamespace {
@@ -250,7 +249,7 @@ var SimpleEmail = class extends BaseClass {
250
249
  let response = this[field].filter((recipient) => recipient && null !== recipient);
251
250
  response = response.map((recipient) => recipient.toLowerCase().trim());
252
251
  response = response.filter((recipient) => "" !== recipient);
253
- response = uniq(response);
252
+ response = [...new Set(response)];
254
253
  return response;
255
254
  };
256
255
  };
@@ -1,11 +1,9 @@
1
- import isBoolean from "lodash/isBoolean";
2
-
3
1
  //#region src/boolean/boolean.ts
4
2
  /**
5
3
  * Convert an input from a variety of forms into boolean.
6
4
  */
7
5
  const getBoolean = (input, defaultValue = false) => {
8
- if (isBoolean(input)) return input;
6
+ if ("boolean" === typeof input) return input;
9
7
  else if ("string" === typeof input) return "true" === input || "1" === input || "yes" === input || "y" === input;
10
8
  else if ("number" === typeof input) return 1 === input;
11
9
  return defaultValue;
@@ -0,0 +1,19 @@
1
+ //#region src/lodash/set.d.ts
2
+ declare const set: <T extends object>(obj: T, path: string | string[], value: unknown) => T;
3
+ //#endregion
4
+ //#region src/lodash/trim.d.ts
5
+ declare const trim: (str: string, chars?: string) => string;
6
+ //#endregion
7
+ //#region src/lodash/isDate.d.ts
8
+ declare const isDate: (value: unknown) => value is Date;
9
+ //#endregion
10
+ //#region src/lodash/isObject.d.ts
11
+ declare const isObject: (value: unknown) => value is object;
12
+ //#endregion
13
+ //#region src/lodash/merge.d.ts
14
+ declare const merge: <T extends object>(target: T, ...sources: any[]) => T;
15
+ //#endregion
16
+ //#region src/lodash/unescape.d.ts
17
+ declare const unescape: (str: string) => string;
18
+ //#endregion
19
+ export { isDate, isObject, merge, set, trim, unescape };
@@ -0,0 +1,73 @@
1
+ //#region src/lodash/set.ts
2
+ const set = (obj, path, value) => {
3
+ if (obj == null) return obj;
4
+ const keys = Array.isArray(path) ? path : path.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
5
+ let current = obj;
6
+ for (let i = 0; i < keys.length - 1; i++) {
7
+ const key = keys[i];
8
+ const nextKey = keys[i + 1];
9
+ const nextIsIndex = /^\d+$/.test(nextKey);
10
+ if (current[key] == null || typeof current[key] !== "object") current[key] = nextIsIndex ? [] : {};
11
+ current = current[key];
12
+ }
13
+ current[keys[keys.length - 1]] = value;
14
+ return obj;
15
+ };
16
+
17
+ //#endregion
18
+ //#region src/lodash/trim.ts
19
+ const trim = (str, chars) => {
20
+ if (!chars) return str.trim();
21
+ const escaped = chars.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
22
+ const pattern = new RegExp(`^[${escaped}]+|[${escaped}]+$`, "g");
23
+ return str.replace(pattern, "");
24
+ };
25
+
26
+ //#endregion
27
+ //#region src/lodash/isDate.ts
28
+ const isDate = (value) => {
29
+ return value instanceof Date && !isNaN(value.getTime());
30
+ };
31
+
32
+ //#endregion
33
+ //#region src/lodash/isObject.ts
34
+ const isObject = (value) => {
35
+ const type = typeof value;
36
+ return value != null && (type === "object" || type === "function");
37
+ };
38
+
39
+ //#endregion
40
+ //#region src/lodash/merge.ts
41
+ const merge = (target, ...sources) => {
42
+ for (const source of sources) {
43
+ if (source == null) continue;
44
+ for (const key of Object.keys(source)) {
45
+ const sourceVal = source[key];
46
+ const targetVal = target[key];
47
+ if (Array.isArray(sourceVal) && Array.isArray(targetVal)) {
48
+ const merged = [...targetVal];
49
+ for (let i = 0; i < sourceVal.length; i++) if (sourceVal[i] != null && typeof sourceVal[i] === "object") merged[i] = merge(targetVal[i] ?? {}, sourceVal[i]);
50
+ else merged[i] = sourceVal[i];
51
+ target[key] = merged;
52
+ } else if (sourceVal != null && typeof sourceVal === "object" && !Array.isArray(sourceVal) && !(sourceVal instanceof Date)) target[key] = merge(targetVal != null && typeof targetVal === "object" ? targetVal : {}, sourceVal);
53
+ else if (sourceVal !== void 0) target[key] = sourceVal;
54
+ }
55
+ }
56
+ return target;
57
+ };
58
+
59
+ //#endregion
60
+ //#region src/lodash/unescape.ts
61
+ const unescape = (str) => {
62
+ const htmlEntities = {
63
+ "&amp;": "&",
64
+ "&lt;": "<",
65
+ "&gt;": ">",
66
+ "&quot;": "\"",
67
+ "&#39;": "'"
68
+ };
69
+ return str.replace(/&(?:amp|lt|gt|quot|#39);/g, (match) => htmlEntities[match]);
70
+ };
71
+
72
+ //#endregion
73
+ export { isDate, isObject, merge, set, trim, unescape };
@@ -5,7 +5,7 @@
5
5
  */
6
6
  const replaceKeys = (instance, getNewKey) => {
7
7
  let response = instance;
8
- if (Array.isArray(instance)) {
8
+ if (Array.Array.isArray(instance)) {
9
9
  response = [];
10
10
  for (let i = 0; i < instance.length; i++) response[i] = replaceKeys(instance[i], getNewKey);
11
11
  } else if ("object" === typeof instance) {
@@ -1,5 +1,4 @@
1
1
  import { t as getDecimal$1 } from "../getDecimal-DRv1J8WD.mjs";
2
- import isArray from "lodash/isArray";
3
2
 
4
3
  //#region src/prisma/getDecimal.ts
5
4
  /**
@@ -7,7 +6,7 @@ import isArray from "lodash/isArray";
7
6
  */
8
7
  const getDecimal = (input, dp = 2) => {
9
8
  let numberString = "";
10
- if (isArray(input?.d)) numberString = input.absoluteValue();
9
+ if (Array.isArray(input?.d)) numberString = input.absoluteValue();
11
10
  else numberString = input.toString();
12
11
  return getDecimal$1(numberString, dp);
13
12
  };
@@ -1,9 +1,5 @@
1
+ import { isDate, isObject, trim, unescape } from "../lodash/index.mjs";
1
2
  import { getYmdString } from "../date/index.mjs";
2
- import isArray from "lodash/isArray";
3
- import isObject from "lodash/isObject";
4
- import isDate from "lodash/isDate";
5
- import _unescape from "lodash/unescape";
6
- import trim from "lodash/trim";
7
3
 
8
4
  //#region src/string/reservedWords.ts
9
5
  const reservedWords = [
@@ -51,7 +47,7 @@ const getString = (input) => {
51
47
  let string = "";
52
48
  if ("string" === typeof input) string = input;
53
49
  else if ("number" === typeof input) string = input.toString();
54
- else if (isObject(input) || isArray(input)) string = JSON.stringify(input);
50
+ else if (isObject(input) || Array.isArray(input)) string = JSON.stringify(input);
55
51
  else if (isDate(input)) string = getYmdString(input);
56
52
  return string;
57
53
  };
@@ -139,7 +135,7 @@ const getUnescaped = (input) => {
139
135
  let el = document.createElement("textarea");
140
136
  el.innerHTML = response;
141
137
  response = el.value;
142
- } else response = _unescape(response);
138
+ } else response = unescape(response);
143
139
  return response;
144
140
  };
145
141
 
@@ -2,7 +2,6 @@ import { BaseNamespace } from "../../_class/index.mjs";
2
2
  import "../../api-BlYy5Efh.mjs";
3
3
  import { post } from "../../axios/index.mjs";
4
4
  import { onePasswordClient } from "../../onePassword/server/index.mjs";
5
- import isArray from "lodash/isArray";
6
5
 
7
6
  //#region src/upTimeRobot/server/UpTimeRobotNamespace.ts
8
7
  /**
@@ -21,9 +20,9 @@ var UpTimeRobotNamespace = class extends BaseNamespace {
21
20
  let finalParams = {};
22
21
  if (void 0 !== props) {
23
22
  finalParams = { ...props };
24
- if (void 0 !== props.monitors && isArray(props.monitors)) finalParams["monitors"] = props.monitors.join("-");
25
- if (void 0 !== props.statuses && isArray(props.statuses)) finalParams["statuses"] = props.statuses.join("-");
26
- if (void 0 !== props.types && isArray(props.types)) finalParams["types"] = props.types.join("-");
23
+ if (void 0 !== props.monitors && Array.isArray(props.monitors)) finalParams["monitors"] = props.monitors.join("-");
24
+ if (void 0 !== props.statuses && Array.isArray(props.statuses)) finalParams["statuses"] = props.statuses.join("-");
25
+ if (void 0 !== props.types && Array.isArray(props.types)) finalParams["types"] = props.types.join("-");
27
26
  }
28
27
  const apiResponse = await post(`https://api.uptimerobot.com/v2/getMonitors?api_key=${this.config.apiKey}`, finalParams);
29
28
  if (apiResponse.isSuccess()) response = apiResponse.getBody();
@@ -1,5 +1,5 @@
1
+ import { merge } from "../lodash/index.mjs";
1
2
  import { isDevelopment, isLocalhost, isProduction, isStaging } from "../environment/index.mjs";
2
- import merge from "lodash/merge";
3
3
 
4
4
  //#region src/url/url.ts
5
5
  /**
@@ -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<any>;
43
43
  //#endregion
44
44
  //#region src/util/sleep.d.ts
45
45
  declare const sleep: (seconds: number) => Promise<void>;
@@ -1,5 +1,5 @@
1
+ import { isObject } from "../lodash/index.mjs";
1
2
  import { getArray } from "../array/index.mjs";
2
- import isObject from "lodash/isObject";
3
3
  import { chunk, flatten } from "lodash";
4
4
 
5
5
  //#region src/util/defaultTo.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.3.8",
4
+ "version": "2.3.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -17,7 +17,6 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "axios": "^1.13.5",
20
- "lodash": "^4.17.23",
21
20
  "luxon": "^3.7.2",
22
21
  "zod": "^4.3.6"
23
22
  },
@@ -171,7 +170,6 @@
171
170
  "@types/crypto-js": "^4.2.2",
172
171
  "@types/fs-extra": "11.0.4",
173
172
  "@types/jest": "30.0.0",
174
- "@types/lodash": "^4.17.23",
175
173
  "@types/luxon": "3.7.1",
176
174
  "@types/node": "^24.10.13",
177
175
  "@types/react": "^19.2.14",
@@ -237,6 +235,7 @@
237
235
  "./inngest": "./dist/inngest/index.mjs",
238
236
  "./json": "./dist/json/index.mjs",
239
237
  "./littleWarden/server": "./dist/littleWarden/server/index.mjs",
238
+ "./lodash": "./dist/lodash/index.mjs",
240
239
  "./lumar/api/server": "./dist/lumar/api/server/index.mjs",
241
240
  "./lumar/graphql/server": "./dist/lumar/graphql/server/index.mjs",
242
241
  "./myTarget/server": "./dist/myTarget/server/index.mjs",