@zydon/common 2.5.42 → 2.5.43

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.
@@ -443,7 +443,7 @@ declare function paper({ theme, color, dropdown }: PaperProps): {
443
443
  wordWrap?: csstype.Property.WordWrap | readonly NonNullable<csstype.Property.WordWrap | undefined>[] | readonly csstype.Property.WordWrap[] | undefined;
444
444
  writingMode?: csstype.Property.WritingMode | readonly NonNullable<csstype.Property.WritingMode | undefined>[] | readonly csstype.Property.WritingMode[] | undefined;
445
445
  zIndex?: csstype.Property.ZIndex | readonly NonNullable<csstype.Property.ZIndex | undefined>[] | readonly ((string & {}) | csstype.Globals | "auto")[] | undefined;
446
- zoom?: csstype.Property.Zoom | readonly NonNullable<csstype.Property.Zoom | undefined>[] | readonly ("reset" | (string & {}) | csstype.Globals | "normal")[] | undefined;
446
+ zoom?: csstype.Property.Zoom | readonly NonNullable<csstype.Property.Zoom | undefined>[] | readonly ((string & {}) | csstype.Globals | "normal" | "reset")[] | undefined;
447
447
  all?: csstype.Globals | readonly NonNullable<csstype.Globals | undefined>[] | readonly csstype.Globals[] | undefined;
448
448
  animation?: csstype.Property.Animation<string & {}> | readonly NonNullable<csstype.Property.Animation<string & {}> | undefined>[] | readonly ((string & {}) | csstype.Globals | "normal" | "reverse" | "auto" | "none" | "both" | "alternate" | "alternate-reverse" | "backwards" | "forwards" | "infinite" | "paused" | "running" | "ease" | "ease-in" | "ease-in-out" | "ease-out" | "step-end" | "step-start" | "linear")[] | undefined;
449
449
  animationRange?: csstype.Property.AnimationRange<string | number> | readonly NonNullable<csstype.Property.AnimationRange<string | number> | undefined>[] | readonly (string | (string & {}))[] | undefined;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Executa imediatamente uma função e retorna seu resultado.
3
+ *
4
+ * Esta função utilitária é usada para avaliar expressões de forma "eager" (ansiosa),
5
+ * executando a função fornecida imediatamente e retornando seu valor. É útil em
6
+ * situações onde você quer forçar a execução imediata de uma função que poderia
7
+ * ser avaliada de forma lazy (preguiçosa).
8
+ *
9
+ * @template T - O tipo do valor retornado pela função
10
+ * @param fn - A função a ser executada imediatamente
11
+ * @returns O resultado da execução da função
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Execução imediata de uma computação
16
+ * const result = eager(() => {
17
+ * console.log('Executando agora!');
18
+ * return 42;
19
+ * }); // result = 42, e o console.log é executado imediatamente
20
+ *
21
+ * // Útil para inicialização de valores
22
+ * const config = eager(() => ({
23
+ * apiUrl: process.env.API_URL || 'http://localhost:3000',
24
+ * timeout: 5000
25
+ * }));
26
+ *
27
+ * // Forçar execução de side effects
28
+ * eager(() => {
29
+ * localStorage.setItem('initialized', 'true');
30
+ * return null;
31
+ * });
32
+ * ```
33
+ */
34
+ declare const eager: <T>(fn: () => T) => T;
35
+ /**
36
+ * Adia a execução de uma função para o próximo ciclo do event loop.
37
+ *
38
+ * Esta função utiliza setTimeout com delay 0 para agendar a execução da função
39
+ * fornecida para o próximo tick do event loop. É útil para quebrar operações
40
+ * síncronas longas ou para garantir que o DOM seja atualizado antes da execução.
41
+ *
42
+ * @template T - O tipo do valor retornado pela função
43
+ * @param fn - A função a ser executada de forma adiada
44
+ * @returns Uma Promise que resolve com o resultado da função
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Adiar execução para permitir atualização do DOM
49
+ * const updateUI = async () => {
50
+ * setLoading(true);
51
+ *
52
+ * const result = await defer(() => {
53
+ * return processLargeDataset(data);
54
+ * });
55
+ *
56
+ * setLoading(false);
57
+ * return result;
58
+ * };
59
+ *
60
+ * // Quebrar operação síncrona longa
61
+ * const processInChunks = async (items: any[]) => {
62
+ * for (let i = 0; i < items.length; i += 100) {
63
+ * const chunk = items.slice(i, i + 100);
64
+ * processChunk(chunk);
65
+ *
66
+ * // Permite que outras tarefas sejam executadas
67
+ * await defer(() => {});
68
+ * }
69
+ * };
70
+ * ```
71
+ */
72
+ declare const defer: <T>(fn: () => T) => Promise<T>;
73
+ /**
74
+ * Cria uma versão debounced de uma função que atrasa sua execução até que
75
+ * tenha passado um determinado tempo desde a última vez que foi invocada.
76
+ *
77
+ * Esta função é útil para limitar a frequência de execução de funções caras
78
+ * computacionalmente, como chamadas de API, validações ou atualizações de UI
79
+ * em resposta a eventos frequentes como digitação ou scroll.
80
+ *
81
+ * @template T - O tipo dos argumentos da função
82
+ * @template R - O tipo do valor retornado pela função
83
+ * @param fn - A função a ser debounced
84
+ * @param delay - O tempo em milissegundos para aguardar antes da execução
85
+ * @returns Uma versão debounced da função original
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Debounce para busca em tempo real
90
+ * const searchAPI = debounce(async (query: string) => {
91
+ * const results = await fetch(`/api/search?q=${query}`);
92
+ * return results.json();
93
+ * }, 300);
94
+ *
95
+ * // Uso em input de busca
96
+ * const handleSearchInput = (event: ChangeEvent<HTMLInputElement>) => {
97
+ * searchAPI(event.target.value);
98
+ * };
99
+ *
100
+ * // Debounce para redimensionamento de janela
101
+ * const handleResize = debounce(() => {
102
+ * console.log('Janela redimensionada:', window.innerWidth);
103
+ * updateLayout();
104
+ * }, 250);
105
+ *
106
+ * window.addEventListener('resize', handleResize);
107
+ *
108
+ * // Debounce para validação de formulário
109
+ * const validateField = debounce((value: string) => {
110
+ * if (value.length < 3) {
111
+ * setError('Mínimo 3 caracteres');
112
+ * } else {
113
+ * setError('');
114
+ * }
115
+ * }, 500);
116
+ * ```
117
+ */
118
+ declare const debounce: <T extends unknown[], R>(fn: (...args: T) => R, delay: number) => (...args: T) => void;
119
+
120
+ export { debounce, defer, eager };
@@ -0,0 +1,3 @@
1
+ var n=t=>t(),u=t=>new Promise((r,e)=>{setTimeout(()=>{try{r(t());}catch(o){e(o);}},0);}),T=(t,r)=>{let e=null;return (...o)=>{e&&clearTimeout(e),e=setTimeout(()=>{t(...o),e=null;},r);}};
2
+
3
+ export { T as debounce, u as defer, n as eager };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.5.42",
3
+ "version": "2.5.43",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,36 +0,0 @@
1
- /**
2
- * Executa imediatamente uma função e retorna seu resultado.
3
- *
4
- * Esta função utilitária é usada para avaliar expressões de forma "eager" (ansiosa),
5
- * executando a função fornecida imediatamente e retornando seu valor. É útil em
6
- * situações onde você quer forçar a execução imediata de uma função que poderia
7
- * ser avaliada de forma lazy (preguiçosa).
8
- *
9
- * @template T - O tipo do valor retornado pela função
10
- * @param fn - A função a ser executada imediatamente
11
- * @returns O resultado da execução da função
12
- *
13
- * @example
14
- * ```typescript
15
- * // Execução imediata de uma computação
16
- * const result = eager(() => {
17
- * console.log('Executando agora!');
18
- * return 42;
19
- * }); // result = 42, e o console.log é executado imediatamente
20
- *
21
- * // Útil para inicialização de valores
22
- * const config = eager(() => ({
23
- * apiUrl: process.env.API_URL || 'http://localhost:3000',
24
- * timeout: 5000
25
- * }));
26
- *
27
- * // Forçar execução de side effects
28
- * eager(() => {
29
- * localStorage.setItem('initialized', 'true');
30
- * return null;
31
- * });
32
- * ```
33
- */
34
- declare const eager: <T>(fn: () => T) => T;
35
-
36
- export { eager };
@@ -1,3 +0,0 @@
1
- var o=e=>e();
2
-
3
- export { o as eager };