@william-callao/antonella-hooks 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.
@@ -0,0 +1,5 @@
1
+ declare function useDebouncedValue<T>(value: T, delayMs?: number): T;
2
+
3
+ declare function usePrevious<T>(value: T): T | undefined;
4
+
5
+ export { useDebouncedValue, usePrevious };
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ useDebouncedValue: () => useDebouncedValue,
24
+ usePrevious: () => usePrevious
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/useDebouncedValue.ts
29
+ var import_react = require("react");
30
+ function useDebouncedValue(value, delayMs = 300) {
31
+ const [debounced, setDebounced] = (0, import_react.useState)(value);
32
+ (0, import_react.useEffect)(() => {
33
+ const id = setTimeout(() => setDebounced(value), delayMs);
34
+ return () => clearTimeout(id);
35
+ }, [value, delayMs]);
36
+ return debounced;
37
+ }
38
+
39
+ // src/usePrevious.ts
40
+ var import_react2 = require("react");
41
+ function usePrevious(value) {
42
+ const ref = (0, import_react2.useRef)(void 0);
43
+ (0, import_react2.useEffect)(() => {
44
+ ref.current = value;
45
+ }, [value]);
46
+ return ref.current;
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ useDebouncedValue,
51
+ usePrevious
52
+ });
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@william-callao/antonella-hooks",
3
+ "version": "1.0.0",
4
+ "description": "Hooks compartidos de Antonella.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "react-native": "dist/index.js",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "peerDependencies": {
16
+ "react": ">=19.0.0"
17
+ },
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "typecheck": "tsc --noEmit"
21
+ }
22
+ }