@react-hive/honey-utils 3.27.0 → 3.30.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-hive/honey-utils",
3
- "version": "3.27.0",
3
+ "version": "3.30.0",
4
4
  "description": "A lightweight TypeScript utility library providing a collection of helper functions for common programming tasks",
5
5
  "keywords": [
6
6
  "utils",
@@ -32,48 +32,31 @@
32
32
  "import": "./dist/index.mjs",
33
33
  "require": "./dist/index.cjs",
34
34
  "default": "./dist/index.mjs"
35
- },
36
- "./*": {
37
- "types": "./dist/*.d.ts",
38
- "import": "./dist/*.mjs",
39
- "require": "./dist/*.cjs"
40
35
  }
41
36
  },
42
37
  "files": [
43
38
  "dist",
44
39
  "!dist/**/__mocks__",
45
- "!dist/**/__tests__",
46
- "!dist/**/jest*"
40
+ "!dist/**/__tests__"
47
41
  ],
48
42
  "devDependencies": {
49
43
  "@eslint/js": "10.0.1",
50
44
  "@mdx-js/loader": "3.1.1",
51
- "@types/jest": "29.5.14",
52
- "@types/node": "22.19.1",
45
+ "@types/node": "22.19.17",
53
46
  "copy-webpack-plugin": "14.0.0",
54
- "eslint": "10.1.0",
47
+ "eslint": "10.2.1",
55
48
  "eslint-plugin-react": "7.37.5",
56
- "jest": "29.7.0",
57
- "prettier": "3.8.1",
58
- "ts-jest": "29.4.6",
59
- "ts-loader": "9.5.4",
60
- "typescript": "5.9.3",
61
- "typescript-eslint": "8.57.2",
62
- "webpack": "5.105.4",
49
+ "prettier": "3.8.3",
50
+ "ts-loader": "9.5.7",
51
+ "typescript": "6.0.3",
52
+ "typescript-eslint": "8.58.2",
53
+ "vitest": "4.1.4",
54
+ "webpack": "5.106.2",
63
55
  "webpack-cli": "7.0.2"
64
56
  },
65
- "jest": {
66
- "preset": "ts-jest",
67
- "testMatch": [
68
- "**/src/**/*.spec.ts"
69
- ],
70
- "moduleNameMapper": {
71
- "^~/(.*)$": "<rootDir>/src/$1"
72
- }
73
- },
74
57
  "scripts": {
75
58
  "clean": "rm -rf dist coverage",
76
59
  "build": "webpack --config webpack.config.mjs",
77
- "test": "jest --coverage"
60
+ "test": "vitest"
78
61
  }
79
62
  }
package/dist/array.d.ts DELETED
@@ -1,172 +0,0 @@
1
- /**
2
- * Checks if a value is an array.
3
- *
4
- * @param value - The value to check.
5
- *
6
- * @returns `true` if the value is an array; otherwise, `false`.
7
- */
8
- export declare const isArray: (value: unknown) => value is unknown[];
9
- /**
10
- * Checks if a value is an empty array.
11
- *
12
- * @param value - The value to check.
13
- *
14
- * @returns `true` if the value is an empty array; otherwise, `false`.
15
- */
16
- export declare const isEmptyArray: (value: unknown) => value is [];
17
- /**
18
- * Represents all falsy values.
19
- */
20
- type Falsy = false | null | undefined | 0 | '';
21
- /**
22
- * Removes all falsy values from an array.
23
- *
24
- * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.
25
- *
26
- * Useful for cleaning up arrays with optional, nullable, or conditionally included items.
27
- *
28
- * @template T - The type of the truthy items.
29
- *
30
- * @param array - An array possibly containing falsy values.
31
- *
32
- * @returns A new array containing only truthy values of type `T`.
33
- *
34
- * @example
35
- * ```ts
36
- * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]
37
- * ```
38
- */
39
- export declare const compact: <T>(array: (T | Falsy)[]) => T[];
40
- /**
41
- * Returns a new array with duplicate values removed.
42
- *
43
- * Uses Set for efficient duplicate removal while preserving the original order.
44
- *
45
- * @template T - The type of the items in the array.
46
- *
47
- * @param array - The input array that may contain duplicate values.
48
- *
49
- * @returns A new array with only unique values, maintaining the original order.
50
- *
51
- * @example
52
- * ```ts
53
- * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]
54
- * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']
55
- * ```
56
- */
57
- export declare const unique: <T>(array: T[]) => T[];
58
- /**
59
- * Splits an array into chunks of the specified size.
60
- *
61
- * Useful for pagination, batch processing, or creating grid layouts.
62
- *
63
- * @template T - The type of the items in the array.
64
- *
65
- * @param array - The input array to be chunked.
66
- * @param size - The size of each chunk. Must be greater than 0.
67
- *
68
- * @returns An array of chunks, where each chunk is an array of the specified size
69
- * (except possibly the last chunk, which may be smaller).
70
- *
71
- * @example
72
- * ```ts
73
- * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
74
- * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]
75
- * ```
76
- */
77
- export declare const chunk: <T>(array: T[], size: number) => T[][];
78
- /**
79
- * Returns an array containing elements that exist in all provided arrays.
80
- *
81
- * @template T - The type of the items in the arrays.
82
- *
83
- * @param arrays - Two or more arrays to find common elements from.
84
- *
85
- * @returns A new array containing only the elements that exist in all input arrays.
86
- *
87
- * @example
88
- * ```ts
89
- * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]
90
- * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']
91
- * ```
92
- */
93
- export declare const intersection: <T>(...arrays: T[][]) => T[];
94
- /**
95
- * Returns elements from the first array that don't exist in the second array.
96
- *
97
- * @template T - The type of the items in the arrays.
98
- *
99
- * @param array - The source array.
100
- * @param exclude - The array containing elements to exclude.
101
- *
102
- * @returns A new array with elements from the first array that don't exist in the second array.
103
- *
104
- * @example
105
- * ```ts
106
- * difference([1, 2, 3, 4], [2, 4]); // [1, 3]
107
- * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']
108
- * ```
109
- */
110
- export declare const difference: <T>(array: T[], exclude: T[]) => T[];
111
- type PipeFn = (arg: unknown) => unknown;
112
- type Pipe = {
113
- <A, B>(fn1: (a: A) => B): (a: A) => B;
114
- <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;
115
- <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;
116
- <A, B, C, D, E>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D, fn4: (d: D) => E): (a: A) => E;
117
- <A, B, C, D, E, F>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D, fn4: (d: D) => E, fn5: (e: E) => F): (a: A) => F;
118
- (...fns: PipeFn[]): (arg: unknown) => unknown;
119
- };
120
- /**
121
- * Composes multiple unary functions into a single function, applying them from left to right.
122
- *
123
- * Useful for building a data processing pipeline where the output of one function becomes the input of the next.
124
- *
125
- * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.
126
- *
127
- * @param fns - A list of unary functions to compose.
128
- *
129
- * @returns A new function that applies all functions from left to right.
130
- *
131
- * @example
132
- * ```ts
133
- * const add = (x: number) => x + 1;
134
- * const double = (x: number) => x * 2;
135
- * const toStr = (x: number) => `Result: ${x}`;
136
- *
137
- * const result = pipe(add, double, toStr)(2);
138
- * // => 'Result: 6'
139
- * ```
140
- */
141
- export declare const pipe: Pipe;
142
- type ComposeFn = (arg: unknown) => unknown;
143
- type Compose = {
144
- <A, R>(fn1: (a: A) => R): (a: A) => R;
145
- <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;
146
- <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;
147
- <A, B, C, D, R>(fn1: (d: D) => R, fn2: (c: C) => D, fn3: (b: B) => C, fn4: (a: A) => B): (a: A) => R;
148
- <A, B, C, D, E, R>(fn1: (e: E) => R, fn2: (d: D) => E, fn3: (c: C) => D, fn4: (b: B) => C, fn5: (a: A) => B): (a: A) => R;
149
- (...fns: ComposeFn[]): (arg: unknown) => unknown;
150
- };
151
- /**
152
- * Composes multiple unary functions into a single function, applying them from **right to left**.
153
- *
154
- * Often used for building functional pipelines where the innermost function runs first.
155
- * Types are inferred up to 5 chained functions for full type safety.
156
- *
157
- * @param fns - A list of unary functions to compose.
158
- *
159
- * @returns A new function that applies all functions from right to left.
160
- *
161
- * @example
162
- * ```ts
163
- * const add = (x: number) => x + 1;
164
- * const double = (x: number) => x * 2;
165
- * const toStr = (x: number) => `Result: ${x}`;
166
- *
167
- * const result = compose(toStr, double, add)(2);
168
- * // => 'Result: 6'
169
- * ```
170
- */
171
- export declare const compose: Compose;
172
- export {};