@alextheman/utility 1.19.1 → 1.20.0

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.
package/dist/index.cjs CHANGED
@@ -118,9 +118,16 @@ var convertFileToBase64_default = convertFileToBase64;
118
118
 
119
119
  // src/functions/fillArray.ts
120
120
  function fillArray(callback, length = 1) {
121
- return new Array(length).fill(null).map((_, index) => {
121
+ const outputArray = new Array(length).fill(null).map((_, index) => {
122
122
  return callback(index);
123
123
  });
124
+ const isAsync = outputArray.some((item) => {
125
+ return item instanceof Promise;
126
+ });
127
+ if (isAsync) {
128
+ return Promise.all(outputArray);
129
+ }
130
+ return outputArray;
124
131
  }
125
132
  var fillArray_default = fillArray;
126
133
 
package/dist/index.d.cts CHANGED
@@ -6,8 +6,11 @@ declare function appendSemicolon(stringToAppendTo: string): string;
6
6
 
7
7
  declare function convertFileToBase64(file: File): Promise<string>;
8
8
 
9
- declare function fillArray<T>(callback: (index: number) => T, length?: number): T[];
9
+ declare function fillArray<T>(callback: (index: number) => T | Promise<T>, length?: number): T[] | Promise<T[]>;
10
10
 
11
+ /**
12
+ * @deprecated The functionality of fillArrayAsync has been combined with fillArray, so fillArray should now be used instead.
13
+ */
11
14
  declare function fillArrayAsync<T>(callback: (index: number) => Promise<T>, length?: number): Promise<T[]>;
12
15
 
13
16
  declare function formatDateAndTime(inputDate: Date): string;
package/dist/index.d.ts CHANGED
@@ -6,8 +6,11 @@ declare function appendSemicolon(stringToAppendTo: string): string;
6
6
 
7
7
  declare function convertFileToBase64(file: File): Promise<string>;
8
8
 
9
- declare function fillArray<T>(callback: (index: number) => T, length?: number): T[];
9
+ declare function fillArray<T>(callback: (index: number) => T | Promise<T>, length?: number): T[] | Promise<T[]>;
10
10
 
11
+ /**
12
+ * @deprecated The functionality of fillArrayAsync has been combined with fillArray, so fillArray should now be used instead.
13
+ */
11
14
  declare function fillArrayAsync<T>(callback: (index: number) => Promise<T>, length?: number): Promise<T[]>;
12
15
 
13
16
  declare function formatDateAndTime(inputDate: Date): string;
package/dist/index.js CHANGED
@@ -64,9 +64,16 @@ var convertFileToBase64_default = convertFileToBase64;
64
64
 
65
65
  // src/functions/fillArray.ts
66
66
  function fillArray(callback, length = 1) {
67
- return new Array(length).fill(null).map((_, index) => {
67
+ const outputArray = new Array(length).fill(null).map((_, index) => {
68
68
  return callback(index);
69
69
  });
70
+ const isAsync = outputArray.some((item) => {
71
+ return item instanceof Promise;
72
+ });
73
+ if (isAsync) {
74
+ return Promise.all(outputArray);
75
+ }
76
+ return outputArray;
70
77
  }
71
78
  var fillArray_default = fillArray;
72
79
 
package/package.json CHANGED
@@ -1,34 +1,45 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "1.19.1",
3
+ "version": "1.20.0",
4
+ "description": "Helpful utility functions",
5
+ "license": "ISC",
6
+ "author": "alextheman",
7
+ "type": "module",
4
8
  "main": "dist/index.cjs",
5
9
  "module": "dist/index.js",
6
10
  "types": "dist/index.d.ts",
7
- "type": "module",
8
11
  "files": [
9
12
  "dist"
10
13
  ],
11
14
  "scripts": {
12
- "test": "vitest run",
13
- "test-watch": "vitest",
14
- "format": "prettier --write --parser typescript 'src/**/*.ts' 'tests/**/*.test.ts' && eslint --fix --suppress-all 'src/**/*.ts' 'tests/**/*.ts' && rm -f eslint-suppressions.json",
15
- "lint": "tsc --noEmit && eslint 'src/**/*.ts' 'tests/**/*.ts' && prettier --check --parser typescript 'src/**/*.ts' 'tests/**/*.ts'",
16
- "prepare": "husky",
17
15
  "build": "tsup",
18
- "update-dependencies": "bash -c 'npx npm-check-updates -u \"$@\" && npm install' --",
19
16
  "change-major": "npm version major -m \"Change version number to v%s\"",
20
17
  "change-minor": "npm version minor -m \"Change version number to v%s\"",
21
- "change-patch": "npm version patch -m \"Change version number to v%s\""
18
+ "change-patch": "npm version patch -m \"Change version number to v%s\"",
19
+ "format": "npm run format-prettier && npm run format-eslint",
20
+ "format-eslint": "eslint --fix --suppress-all \"package.json\" \"src/**/*.ts\" \"tests/**/*.ts\" && rm -f eslint-suppressions.json",
21
+ "format-prettier": "npm run format-prettier-typescript && npm run format-prettier-javascript",
22
+ "format-prettier-javascript": "prettier --write \"./**/*.js\"",
23
+ "format-prettier-typescript": "prettier --write --parser typescript \"./**/*.ts\"",
24
+ "lint": "npm run lint-tsc && npm run lint-eslint && npm run lint-prettier",
25
+ "lint-eslint": "eslint \"package.json\" \"src/**/*.ts\" \"tests/**/*.ts\"",
26
+ "lint-prettier": "npm run lint-prettier-typescript && npm run lint-prettier-javascript",
27
+ "lint-prettier-javascript": "prettier --check \"./**/*.js\"",
28
+ "lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
29
+ "lint-tsc": "tsc --noEmit",
30
+ "prepare": "husky",
31
+ "test": "vitest run",
32
+ "test-watch": "vitest",
33
+ "update-dependencies": "bash -c 'npx npm-check-updates -u \"$@\" && npm install' --"
34
+ },
35
+ "dependencies": {
36
+ "zod": "^4.1.11"
22
37
  },
23
- "keywords": [],
24
- "author": "",
25
- "license": "ISC",
26
- "description": "",
27
38
  "devDependencies": {
28
- "@alextheman/eslint-plugin": "^1.14.1",
29
- "@eslint/js": "^9.36.0",
30
- "@types/node": "^24.5.2",
31
- "eslint": "^9.36.0",
39
+ "@alextheman/eslint-plugin": "^1.14.2",
40
+ "@eslint/js": "^9.37.0",
41
+ "@types/node": "^24.6.2",
42
+ "eslint": "^9.37.0",
32
43
  "eslint-import-resolver-typescript": "^4.4.4",
33
44
  "eslint-plugin-import": "^2.32.0",
34
45
  "globals": "^16.4.0",
@@ -36,12 +47,9 @@
36
47
  "jsdom": "^27.0.0",
37
48
  "prettier": "^3.6.2",
38
49
  "tsup": "^8.5.0",
39
- "typescript": "^5.9.2",
40
- "typescript-eslint": "^8.44.0",
50
+ "typescript": "^5.9.3",
51
+ "typescript-eslint": "^8.45.0",
41
52
  "vite-tsconfig-paths": "^5.1.4",
42
53
  "vitest": "^3.2.4"
43
- },
44
- "dependencies": {
45
- "zod": "^4.1.9"
46
54
  }
47
55
  }