nhb-toolbox 4.10.17 → 4.10.18
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/cjs/dom/utils.js +7 -0
- package/dist/cjs/utils/index.js +7 -7
- package/dist/dts/dom/utils.d.ts.map +1 -1
- package/dist/dts/utils/index.d.ts +2 -2
- package/dist/dts/utils/index.d.ts.map +1 -1
- package/dist/esm/dom/utils.js +7 -0
- package/dist/esm/utils/index.js +4 -4
- package/package.json +1 -1
package/dist/cjs/dom/utils.js
CHANGED
|
@@ -67,5 +67,12 @@ async function copyToClipboard(text) {
|
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
69
|
console.error('Failed to copy text:', error);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
const textArea = document.querySelector('textarea[style*="fixed"]');
|
|
74
|
+
if (textArea) {
|
|
75
|
+
document.body.removeChild(textArea);
|
|
76
|
+
}
|
|
70
77
|
}
|
|
71
78
|
}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseJSON = exports.
|
|
3
|
+
exports.parseJSON = exports.convertArrayToString = exports.isDeepEqual = void 0;
|
|
4
|
+
exports.debounceAction = debounceAction;
|
|
5
|
+
exports.throttleAction = throttleAction;
|
|
4
6
|
exports.getInstanceMethodNames = getInstanceMethodNames;
|
|
5
7
|
exports.getStaticMethodNames = getStaticMethodNames;
|
|
6
8
|
exports.countInstanceMethods = countInstanceMethods;
|
|
@@ -74,7 +76,7 @@ exports.convertArrayToString = convertArrayToString;
|
|
|
74
76
|
*
|
|
75
77
|
* debouncedSearch('laptop'); // Executes after 300ms of inactivity.
|
|
76
78
|
*/
|
|
77
|
-
|
|
79
|
+
function debounceAction(callback, delay = 300) {
|
|
78
80
|
let timeoutId = undefined;
|
|
79
81
|
return (...args) => {
|
|
80
82
|
// Clear the previous timeout
|
|
@@ -84,8 +86,7 @@ const debounceAction = (callback, delay = 300) => {
|
|
|
84
86
|
callback(...args);
|
|
85
87
|
}, delay);
|
|
86
88
|
};
|
|
87
|
-
}
|
|
88
|
-
exports.debounceAction = debounceAction;
|
|
89
|
+
}
|
|
89
90
|
/**
|
|
90
91
|
* * A generic throttle function that ensures a callback is executed at most once per specified interval.
|
|
91
92
|
*
|
|
@@ -100,7 +101,7 @@ exports.debounceAction = debounceAction;
|
|
|
100
101
|
*
|
|
101
102
|
* window.addEventListener('resize', throttledResize);
|
|
102
103
|
*/
|
|
103
|
-
|
|
104
|
+
function throttleAction(callback, delay = 150) {
|
|
104
105
|
let lastCall = 0;
|
|
105
106
|
return (...args) => {
|
|
106
107
|
const now = Date.now();
|
|
@@ -109,8 +110,7 @@ const throttleAction = (callback, delay = 150) => {
|
|
|
109
110
|
callback(...args);
|
|
110
111
|
}
|
|
111
112
|
};
|
|
112
|
-
}
|
|
113
|
-
exports.throttleAction = throttleAction;
|
|
113
|
+
}
|
|
114
114
|
/**
|
|
115
115
|
* * Retrieves the names of all instance methods defined directly on a class prototype.
|
|
116
116
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/dom/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAI,QAQ9D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,cAA2B,QAuBlE;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/dom/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAI,QAQ9D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,cAA2B,QAuBlE;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCjE"}
|
|
@@ -29,7 +29,7 @@ export declare const convertArrayToString: <T>(array: T[], separator?: string) =
|
|
|
29
29
|
*
|
|
30
30
|
* debouncedSearch('laptop'); // Executes after 300ms of inactivity.
|
|
31
31
|
*/
|
|
32
|
-
export declare
|
|
32
|
+
export declare function debounceAction<T extends VoidFunction>(callback: T, delay?: number): DelayedFn<T>;
|
|
33
33
|
/**
|
|
34
34
|
* * A generic throttle function that ensures a callback is executed at most once per specified interval.
|
|
35
35
|
*
|
|
@@ -44,7 +44,7 @@ export declare const debounceAction: <T extends VoidFunction>(callback: T, delay
|
|
|
44
44
|
*
|
|
45
45
|
* window.addEventListener('resize', throttledResize);
|
|
46
46
|
*/
|
|
47
|
-
export declare
|
|
47
|
+
export declare function throttleAction<T extends VoidFunction>(callback: T, delay?: number): ThrottledFn<T>;
|
|
48
48
|
/**
|
|
49
49
|
* * Retrieves the names of all instance methods defined directly on a class prototype.
|
|
50
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,UAAU,CAAC;AAElB;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAG,OA6B3C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAC9B,CAAC,EAAE,cACC,MAAM,KACf,MAKF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","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C,CAoClE"}
|
package/dist/esm/dom/utils.js
CHANGED
|
@@ -62,5 +62,12 @@ export async function copyToClipboard(text) {
|
|
|
62
62
|
}
|
|
63
63
|
catch (error) {
|
|
64
64
|
console.error('Failed to copy text:', error);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
const textArea = document.querySelector('textarea[style*="fixed"]');
|
|
69
|
+
if (textArea) {
|
|
70
|
+
document.body.removeChild(textArea);
|
|
71
|
+
}
|
|
65
72
|
}
|
|
66
73
|
}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -63,7 +63,7 @@ export const convertArrayToString = (array, separator = ',') => {
|
|
|
63
63
|
*
|
|
64
64
|
* debouncedSearch('laptop'); // Executes after 300ms of inactivity.
|
|
65
65
|
*/
|
|
66
|
-
export
|
|
66
|
+
export function debounceAction(callback, delay = 300) {
|
|
67
67
|
let timeoutId = undefined;
|
|
68
68
|
return (...args) => {
|
|
69
69
|
// Clear the previous timeout
|
|
@@ -73,7 +73,7 @@ export const debounceAction = (callback, delay = 300) => {
|
|
|
73
73
|
callback(...args);
|
|
74
74
|
}, delay);
|
|
75
75
|
};
|
|
76
|
-
}
|
|
76
|
+
}
|
|
77
77
|
/**
|
|
78
78
|
* * A generic throttle function that ensures a callback is executed at most once per specified interval.
|
|
79
79
|
*
|
|
@@ -88,7 +88,7 @@ export const debounceAction = (callback, delay = 300) => {
|
|
|
88
88
|
*
|
|
89
89
|
* window.addEventListener('resize', throttledResize);
|
|
90
90
|
*/
|
|
91
|
-
export
|
|
91
|
+
export function throttleAction(callback, delay = 150) {
|
|
92
92
|
let lastCall = 0;
|
|
93
93
|
return (...args) => {
|
|
94
94
|
const now = Date.now();
|
|
@@ -97,7 +97,7 @@ export const throttleAction = (callback, delay = 150) => {
|
|
|
97
97
|
callback(...args);
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
}
|
|
100
|
+
}
|
|
101
101
|
/**
|
|
102
102
|
* * Retrieves the names of all instance methods defined directly on a class prototype.
|
|
103
103
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.18",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|