@react-hive/honey-utils 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 React Hive
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 React Hive
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/README.md ADDED
File without changes
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Filters out `null`, `undefined`, and other falsy values from an array,
3
+ * returning a typed array of only truthy `Item` values.
4
+ *
5
+ * Useful when working with optional or nullable items that need to be sanitized.
6
+ *
7
+ * @template T - The type of the items in the array.
8
+ *
9
+ * @param array - An array of items that may include `null`, `undefined`, or falsy values.
10
+ *
11
+ * @returns A new array containing only truthy `Item` values.
12
+ */
13
+ export declare const boolFilter: <T>(array: (T | false | null | undefined)[]) => T[];
@@ -0,0 +1,14 @@
1
+ export declare const noop: () => void;
2
+ /**
3
+ * Invokes the given input if it is a function, passing the provided arguments.
4
+ * Otherwise, returns the input as-is.
5
+ *
6
+ * @template Args - Tuple of argument types to pass to the function.
7
+ * @template Result - Return type of the function or the value.
8
+ *
9
+ * @param input - A function to invoke with `args`, or a direct value of type `Result`.
10
+ * @param args - Arguments to pass if `input` is a function.
11
+ *
12
+ * @returns The result of invoking the function, or the original value if it's not a function.
13
+ */
14
+ export declare const invokeIfFunction: <Args extends any[], Result>(input: ((...args: Args) => Result) | Result, ...args: Args) => Result;
@@ -0,0 +1,11 @@
1
+ export declare const isString: (value: unknown) => value is string;
2
+ export declare const isObject: (value: unknown) => value is object;
3
+ export declare const isFunction: (value: unknown) => value is Function;
4
+ /**
5
+ * Checks if a value is null or undefined.
6
+ *
7
+ * @param value - The value to check.
8
+ *
9
+ * @returns `true` if the value is `null` or `undefined`, otherwise `false`.
10
+ */
11
+ export declare const isNil: (value: unknown) => value is null | undefined;
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ (()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{assert:()=>u,boolFilter:()=>n,hashString:()=>r,invokeIfFunction:()=>l,isFunction:()=>c,isNil:()=>s,isObject:()=>f,isString:()=>a,noop:()=>i,toKebabCase:()=>o});const o=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),r=e=>{let t=5381;for(let o=0;o<e.length;o++)t=33*t^e.charCodeAt(o);return(t>>>0).toString(36)},n=e=>e.filter(Boolean),i=()=>{},l=(e,...t)=>"function"==typeof e?e(...t):e,a=e=>"string"==typeof e,f=e=>"object"==typeof e,c=e=>"function"==typeof e,s=e=>null==e;function u(e,t){if(!e)throw new Error(t)}module.exports=t})();
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,mLCLhD,MAAMC,EAAeC,GAC1BA,EAAIC,QAAQ,qBAAsB,SAASC,cA0BhCC,EAAcH,IACzB,IAAII,EAAO,KAEX,IAAK,IAAIC,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC9BD,EAAe,GAAPA,EAAaJ,EAAIO,WAAWF,GAGtC,OAAQD,IAAS,GAAGI,SAAS,KCtBlBC,EAAiBC,GAC5BA,EAAMC,OAAOC,SCbFC,EAAO,OAcPC,EAAmB,CAC9BC,KACGC,IAC0B,mBAAVD,EAAwBA,KAAuCC,GAAQD,ECjB/EE,EAAYnB,GAAqD,iBAAVA,EAEvDoB,EAAYpB,GAAqD,iBAAVA,EAEvDqB,EAAcrB,GAAoC,mBAAVA,EASxCsB,EAAStB,GACpBA,QCTK,SAASuB,EAAOC,EAAgBC,GACrC,IAAKD,EACH,MAAM,IAAIE,MAAMD,EAEpB,C","sources":["webpack://@react-hive/honey-utils/webpack/bootstrap","webpack://@react-hive/honey-utils/webpack/runtime/define property getters","webpack://@react-hive/honey-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-utils/webpack/runtime/make namespace object","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export const toKebabCase = (str: string): string =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param str - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (str: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < str.length; i++) {\n hash = (hash * 33) ^ str.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","/**\n * Filters out `null`, `undefined`, and other falsy values from an array,\n * returning a typed array of only truthy `Item` values.\n *\n * Useful when working with optional or nullable items that need to be sanitized.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - An array of items that may include `null`, `undefined`, or falsy values.\n *\n * @returns A new array containing only truthy `Item` values.\n */\nexport const boolFilter = <T>(array: (T | false | null | undefined)[]): T[] =>\n array.filter(Boolean) as T[];\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends any[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n","export * from './string';\nexport * from './array';\nexport * from './function';\nexport * from './guards';\n\nexport function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","toKebabCase","str","replace","toLowerCase","hashString","hash","i","length","charCodeAt","toString","boolFilter","array","filter","Boolean","noop","invokeIfFunction","input","args","isString","isObject","isFunction","isNil","assert","condition","message","Error"],"sourceRoot":""}
@@ -0,0 +1,5 @@
1
+ export * from './string';
2
+ export * from './array';
3
+ export * from './function';
4
+ export * from './guards';
5
+ export declare function assert(condition: any, message: string): asserts condition;
@@ -0,0 +1,230 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ var __webpack_modules__ = ({
4
+
5
+ /***/ "./src/array.ts":
6
+ /*!**********************!*\
7
+ !*** ./src/array.ts ***!
8
+ \**********************/
9
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
10
+
11
+ __webpack_require__.r(__webpack_exports__);
12
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13
+ /* harmony export */ boolFilter: () => (/* binding */ boolFilter)
14
+ /* harmony export */ });
15
+ /**
16
+ * Filters out `null`, `undefined`, and other falsy values from an array,
17
+ * returning a typed array of only truthy `Item` values.
18
+ *
19
+ * Useful when working with optional or nullable items that need to be sanitized.
20
+ *
21
+ * @template T - The type of the items in the array.
22
+ *
23
+ * @param array - An array of items that may include `null`, `undefined`, or falsy values.
24
+ *
25
+ * @returns A new array containing only truthy `Item` values.
26
+ */
27
+ const boolFilter = (array) => array.filter(Boolean);
28
+
29
+
30
+ /***/ }),
31
+
32
+ /***/ "./src/function.ts":
33
+ /*!*************************!*\
34
+ !*** ./src/function.ts ***!
35
+ \*************************/
36
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
37
+
38
+ __webpack_require__.r(__webpack_exports__);
39
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
40
+ /* harmony export */ invokeIfFunction: () => (/* binding */ invokeIfFunction),
41
+ /* harmony export */ noop: () => (/* binding */ noop)
42
+ /* harmony export */ });
43
+ const noop = () => { };
44
+ /**
45
+ * Invokes the given input if it is a function, passing the provided arguments.
46
+ * Otherwise, returns the input as-is.
47
+ *
48
+ * @template Args - Tuple of argument types to pass to the function.
49
+ * @template Result - Return type of the function or the value.
50
+ *
51
+ * @param input - A function to invoke with `args`, or a direct value of type `Result`.
52
+ * @param args - Arguments to pass if `input` is a function.
53
+ *
54
+ * @returns The result of invoking the function, or the original value if it's not a function.
55
+ */
56
+ const invokeIfFunction = (input, ...args) => (typeof input === 'function' ? input(...args) : input);
57
+
58
+
59
+ /***/ }),
60
+
61
+ /***/ "./src/guards.ts":
62
+ /*!***********************!*\
63
+ !*** ./src/guards.ts ***!
64
+ \***********************/
65
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
66
+
67
+ __webpack_require__.r(__webpack_exports__);
68
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
69
+ /* harmony export */ isFunction: () => (/* binding */ isFunction),
70
+ /* harmony export */ isNil: () => (/* binding */ isNil),
71
+ /* harmony export */ isObject: () => (/* binding */ isObject),
72
+ /* harmony export */ isString: () => (/* binding */ isString)
73
+ /* harmony export */ });
74
+ const isString = (value) => typeof value === 'string';
75
+ const isObject = (value) => typeof value === 'object';
76
+ const isFunction = (value) => typeof value === 'function';
77
+ /**
78
+ * Checks if a value is null or undefined.
79
+ *
80
+ * @param value - The value to check.
81
+ *
82
+ * @returns `true` if the value is `null` or `undefined`, otherwise `false`.
83
+ */
84
+ const isNil = (value) => value === undefined || value === null;
85
+
86
+
87
+ /***/ }),
88
+
89
+ /***/ "./src/string.ts":
90
+ /*!***********************!*\
91
+ !*** ./src/string.ts ***!
92
+ \***********************/
93
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
94
+
95
+ __webpack_require__.r(__webpack_exports__);
96
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
97
+ /* harmony export */ hashString: () => (/* binding */ hashString),
98
+ /* harmony export */ toKebabCase: () => (/* binding */ toKebabCase)
99
+ /* harmony export */ });
100
+ const toKebabCase = (str) => str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
101
+ /**
102
+ * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.
103
+ *
104
+ * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm
105
+ * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,
106
+ * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.
107
+ *
108
+ * Useful for:
109
+ * - Generating stable class names in CSS-in-JS libraries.
110
+ * - Producing consistent cache keys.
111
+ * - Quick and lightweight hashing needs where cryptographic security is not required.
112
+ *
113
+ * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.
114
+ *
115
+ * @param str - The input string to hash.
116
+ *
117
+ * @returns A short, base-36 encoded hash string.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * const className = hashString('background-color: red;');
122
+ * // → 'e4k1z0x'
123
+ * ```
124
+ */
125
+ const hashString = (str) => {
126
+ let hash = 5381;
127
+ for (let i = 0; i < str.length; i++) {
128
+ hash = (hash * 33) ^ str.charCodeAt(i);
129
+ }
130
+ return (hash >>> 0).toString(36);
131
+ };
132
+
133
+
134
+ /***/ })
135
+
136
+ /******/ });
137
+ /************************************************************************/
138
+ /******/ // The module cache
139
+ /******/ var __webpack_module_cache__ = {};
140
+ /******/
141
+ /******/ // The require function
142
+ /******/ function __webpack_require__(moduleId) {
143
+ /******/ // Check if module is in cache
144
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
145
+ /******/ if (cachedModule !== undefined) {
146
+ /******/ return cachedModule.exports;
147
+ /******/ }
148
+ /******/ // Create a new module (and put it into the cache)
149
+ /******/ var module = __webpack_module_cache__[moduleId] = {
150
+ /******/ // no module.id needed
151
+ /******/ // no module.loaded needed
152
+ /******/ exports: {}
153
+ /******/ };
154
+ /******/
155
+ /******/ // Execute the module function
156
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
157
+ /******/
158
+ /******/ // Return the exports of the module
159
+ /******/ return module.exports;
160
+ /******/ }
161
+ /******/
162
+ /************************************************************************/
163
+ /******/ /* webpack/runtime/define property getters */
164
+ /******/ (() => {
165
+ /******/ // define getter functions for harmony exports
166
+ /******/ __webpack_require__.d = (exports, definition) => {
167
+ /******/ for(var key in definition) {
168
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
169
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
170
+ /******/ }
171
+ /******/ }
172
+ /******/ };
173
+ /******/ })();
174
+ /******/
175
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
176
+ /******/ (() => {
177
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
178
+ /******/ })();
179
+ /******/
180
+ /******/ /* webpack/runtime/make namespace object */
181
+ /******/ (() => {
182
+ /******/ // define __esModule on exports
183
+ /******/ __webpack_require__.r = (exports) => {
184
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
185
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
186
+ /******/ }
187
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
188
+ /******/ };
189
+ /******/ })();
190
+ /******/
191
+ /************************************************************************/
192
+ var __webpack_exports__ = {};
193
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
194
+ (() => {
195
+ /*!**********************!*\
196
+ !*** ./src/index.ts ***!
197
+ \**********************/
198
+ __webpack_require__.r(__webpack_exports__);
199
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
200
+ /* harmony export */ assert: () => (/* binding */ assert),
201
+ /* harmony export */ boolFilter: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.boolFilter),
202
+ /* harmony export */ hashString: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_0__.hashString),
203
+ /* harmony export */ invokeIfFunction: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_2__.invokeIfFunction),
204
+ /* harmony export */ isFunction: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_3__.isFunction),
205
+ /* harmony export */ isNil: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_3__.isNil),
206
+ /* harmony export */ isObject: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_3__.isObject),
207
+ /* harmony export */ isString: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_3__.isString),
208
+ /* harmony export */ noop: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_2__.noop),
209
+ /* harmony export */ toKebabCase: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_0__.toKebabCase)
210
+ /* harmony export */ });
211
+ /* harmony import */ var _string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./string */ "./src/string.ts");
212
+ /* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./array */ "./src/array.ts");
213
+ /* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./function */ "./src/function.ts");
214
+ /* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./guards */ "./src/guards.ts");
215
+
216
+
217
+
218
+
219
+ function assert(condition, message) {
220
+ if (!condition) {
221
+ throw new Error(message);
222
+ }
223
+ }
224
+
225
+ })();
226
+
227
+ module.exports = __webpack_exports__;
228
+ /******/ })()
229
+ ;
230
+ //# sourceMappingURL=index.dev.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.dev.cjs","mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACI,MAAM,UAAU,GAAG,CAAI,KAAuC,EAAO,EAAE,CAC5E,KAAK,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;;;;;;;;;;;;;;;;ACbxB,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAE7B;;;;;;;;;;;GAWG;AACI,MAAM,gBAAgB,GAAG,CAC9B,KAA2C,EAC3C,GAAG,IAAU,EACL,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAmC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;;;;;;;;;;;;;;;;;;ACjB5F,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;AAEhF,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;AAEhF,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC;AAE1E;;;;;;GAMG;AACI,MAAM,KAAK,GAAG,CAAC,KAAc,EAA6B,EAAE,CACjE,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;;;;;;;;;;;;;;;;ACdjC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE,CACjD,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE;IAChD,IAAI,IAAI,GAAG,IAAI,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC;;;;;;;UCnCF;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;;;;;;;;;;;;;;;;;;;;;;;ACNyB;AACD;AACG;AACF;AAElB,SAAS,MAAM,CAAC,SAAc,EAAE,OAAe;IACpD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC","sources":["webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/webpack/bootstrap","webpack://@react-hive/honey-utils/webpack/runtime/define property getters","webpack://@react-hive/honey-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-utils/webpack/runtime/make namespace object","webpack://@react-hive/honey-utils/./src/index.ts"],"sourcesContent":["/**\n * Filters out `null`, `undefined`, and other falsy values from an array,\n * returning a typed array of only truthy `Item` values.\n *\n * Useful when working with optional or nullable items that need to be sanitized.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - An array of items that may include `null`, `undefined`, or falsy values.\n *\n * @returns A new array containing only truthy `Item` values.\n */\nexport const boolFilter = <T>(array: (T | false | null | undefined)[]): T[] =>\n array.filter(Boolean) as T[];\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends any[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n","export const toKebabCase = (str: string): string =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param str - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (str: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < str.length; i++) {\n hash = (hash * 33) ^ str.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './string';\nexport * from './array';\nexport * from './function';\nexport * from './guards';\n\nexport function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n"],"names":[],"sourceRoot":""}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ const t=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),o=t=>{let o=5381;for(let e=0;e<t.length;e++)o=33*o^t.charCodeAt(e);return(o>>>0).toString(36)},e=t=>t.filter(Boolean),n=()=>{},r=(t,...o)=>"function"==typeof t?t(...o):t,f=t=>"string"==typeof t,l=t=>"object"==typeof t,c=t=>"function"==typeof t,i=t=>null==t;function p(t,o){if(!t)throw new Error(o)}export{p as assert,e as boolFilter,o as hashString,r as invokeIfFunction,c as isFunction,i as isNil,l as isObject,f as isString,n as noop,t as toKebabCase};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","mappings":"AAAO,MAAMA,EAAeC,GAC1BA,EAAIC,QAAQ,qBAAsB,SAASC,cA0BhCC,EAAcH,IACzB,IAAII,EAAO,KAEX,IAAK,IAAIC,EAAI,EAAGA,EAAIL,EAAIM,OAAQD,IAC9BD,EAAe,GAAPA,EAAaJ,EAAIO,WAAWF,GAGtC,OAAQD,IAAS,GAAGI,SAAS,KCtBlBC,EAAiBC,GAC5BA,EAAMC,OAAOC,SCbFC,EAAO,OAcPC,EAAmB,CAC9BC,KACGC,IAC0B,mBAAVD,EAAwBA,KAAuCC,GAAQD,ECjB/EE,EAAYC,GAAqD,iBAAVA,EAEvDC,EAAYD,GAAqD,iBAAVA,EAEvDE,EAAcF,GAAoC,mBAAVA,EASxCG,EAASH,GACpBA,QCTK,SAASI,EAAOC,EAAgBC,GACrC,IAAKD,EACH,MAAM,IAAIE,MAAMD,EAEpB,Q","sources":["webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/index.ts"],"sourcesContent":["export const toKebabCase = (str: string): string =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param str - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (str: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < str.length; i++) {\n hash = (hash * 33) ^ str.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","/**\n * Filters out `null`, `undefined`, and other falsy values from an array,\n * returning a typed array of only truthy `Item` values.\n *\n * Useful when working with optional or nullable items that need to be sanitized.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - An array of items that may include `null`, `undefined`, or falsy values.\n *\n * @returns A new array containing only truthy `Item` values.\n */\nexport const boolFilter = <T>(array: (T | false | null | undefined)[]): T[] =>\n array.filter(Boolean) as T[];\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends any[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n","export * from './string';\nexport * from './array';\nexport * from './function';\nexport * from './guards';\n\nexport function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n"],"names":["toKebabCase","str","replace","toLowerCase","hashString","hash","i","length","charCodeAt","toString","boolFilter","array","filter","Boolean","noop","invokeIfFunction","input","args","isString","value","isObject","isFunction","isNil","assert","condition","message","Error"],"sourceRoot":""}
@@ -0,0 +1,26 @@
1
+ export declare const toKebabCase: (str: string) => string;
2
+ /**
3
+ * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.
4
+ *
5
+ * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm
6
+ * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,
7
+ * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.
8
+ *
9
+ * Useful for:
10
+ * - Generating stable class names in CSS-in-JS libraries.
11
+ * - Producing consistent cache keys.
12
+ * - Quick and lightweight hashing needs where cryptographic security is not required.
13
+ *
14
+ * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.
15
+ *
16
+ * @param str - The input string to hash.
17
+ *
18
+ * @returns A short, base-36 encoded hash string.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const className = hashString('background-color: red;');
23
+ * // → 'e4k1z0x'
24
+ * ```
25
+ */
26
+ export declare const hashString: (str: string) => string;
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@react-hive/honey-utils",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "keywords": [
6
+ "utils",
7
+ "typescript"
8
+ ],
9
+ "homepage": "https://github.com/React-Hive/honey-utils",
10
+ "bugs": {
11
+ "url": "https://github.com/React-Hive/honey-utils/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+ssh://git@github.com/React-Hive/honey-utils.git"
16
+ },
17
+ "author": "Mykhailo Aliinyk <m.aliynik@gmail.com>",
18
+ "license": "MIT",
19
+ "scripts": {
20
+ "build": "webpack --config webpack.config.mjs",
21
+ "test": "jest --collect-coverage"
22
+ },
23
+ "type": "module",
24
+ "main": "dist/index.cjs",
25
+ "module": "dist/index.mjs",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ "import": "./dist/index.mjs",
29
+ "require": "./dist/index.cjs"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "!dist/**/__mocks__",
34
+ "!dist/**/__tests__",
35
+ "!dist/**/jest*"
36
+ ],
37
+ "devDependencies": {
38
+ "@eslint/js": "9.31.0",
39
+ "@mdx-js/loader": "3.1.0",
40
+ "@types/jest": "29.5.14",
41
+ "@types/node": "22.16.5",
42
+ "copy-webpack-plugin": "13.0.0",
43
+ "eslint": "9.31.0",
44
+ "eslint-plugin-react": "7.37.5",
45
+ "html-webpack-plugin": "5.6.3",
46
+ "jest": "29.7.0",
47
+ "prettier": "3.6.2",
48
+ "ts-jest": "29.4.0",
49
+ "ts-loader": "9.5.2",
50
+ "typescript": "5.8.3",
51
+ "typescript-eslint": "8.37.0",
52
+ "webpack": "5.100.2",
53
+ "webpack-cli": "6.0.1"
54
+ },
55
+ "jest": {
56
+ "preset": "ts-jest",
57
+ "testMatch": [
58
+ "**/src/**/__tests__/**/*.spec.ts?(x)"
59
+ ]
60
+ }
61
+ }