tiny-essentials 1.20.3 → 1.21.1

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.
Files changed (126) hide show
  1. package/README.md +13 -11
  2. package/dist/_/numbers.cjs +136 -0
  3. package/dist/_/numbers.d.mts +24 -0
  4. package/dist/_/numbers.mjs +102 -0
  5. package/dist/v1/TinyAdvancedRaffle.min.js +1 -0
  6. package/dist/v1/TinyArrayPaginator.min.js +1 -0
  7. package/dist/v1/TinyBasicsEs.min.js +1 -1
  8. package/dist/v1/TinyCookieConsent.min.js +1 -0
  9. package/dist/v1/TinyDayNightCycle.min.js +1 -0
  10. package/dist/v1/TinyEssentials.min.js +1 -1
  11. package/dist/v1/TinyGamepad.min.js +1 -0
  12. package/dist/v1/TinyI18.min.js +1 -0
  13. package/dist/v1/TinyInventory.min.js +1 -0
  14. package/dist/v1/TinyInventoryTrader.min.js +1 -0
  15. package/dist/v1/TinyLocalStorage.min.js +1 -1
  16. package/dist/v1/TinyNeedBar.min.js +1 -0
  17. package/dist/v1/TinyRateLimiter.min.js +1 -1
  18. package/dist/v1/TinySmartScroller.min.js +1 -1
  19. package/dist/v1/TinyToastNotify.min.js +1 -1
  20. package/dist/v1/TinyUploadClicker.min.js +1 -1
  21. package/dist/v1/basics/array.cjs +21 -0
  22. package/dist/v1/basics/array.d.mts +8 -0
  23. package/dist/v1/basics/array.mjs +18 -0
  24. package/dist/v1/basics/clock.cjs +127 -11
  25. package/dist/v1/basics/clock.d.mts +26 -0
  26. package/dist/v1/basics/clock.mjs +96 -1
  27. package/dist/v1/basics/index.cjs +2 -8
  28. package/dist/v1/basics/index.d.mts +3 -8
  29. package/dist/v1/basics/index.mjs +2 -3
  30. package/dist/v1/basics/simpleMath.cjs +46 -0
  31. package/dist/v1/basics/simpleMath.d.mts +27 -0
  32. package/dist/v1/basics/simpleMath.mjs +42 -0
  33. package/dist/v1/build/TinyAdvancedRaffle.cjs +7 -0
  34. package/dist/v1/build/TinyAdvancedRaffle.d.mts +3 -0
  35. package/dist/v1/build/TinyAdvancedRaffle.mjs +2 -0
  36. package/dist/v1/build/TinyArrayPaginator.cjs +7 -0
  37. package/dist/v1/build/TinyArrayPaginator.d.mts +3 -0
  38. package/dist/v1/build/TinyArrayPaginator.mjs +2 -0
  39. package/dist/v1/build/TinyCookieConsent.cjs +7 -0
  40. package/dist/v1/build/TinyCookieConsent.d.mts +3 -0
  41. package/dist/v1/build/TinyCookieConsent.mjs +2 -0
  42. package/dist/v1/build/TinyDayNightCycle.cjs +7 -0
  43. package/dist/v1/build/TinyDayNightCycle.d.mts +3 -0
  44. package/dist/v1/build/TinyDayNightCycle.mjs +2 -0
  45. package/dist/v1/build/TinyGamepad.cjs +7 -0
  46. package/dist/v1/build/TinyGamepad.d.mts +3 -0
  47. package/dist/v1/build/TinyGamepad.mjs +2 -0
  48. package/dist/v1/build/TinyI18.cjs +7 -0
  49. package/dist/v1/build/TinyI18.d.mts +3 -0
  50. package/dist/v1/build/TinyI18.mjs +2 -0
  51. package/dist/v1/build/TinyInventory.cjs +7 -0
  52. package/dist/v1/build/TinyInventory.d.mts +3 -0
  53. package/dist/v1/build/TinyInventory.mjs +2 -0
  54. package/dist/v1/build/TinyInventoryTrader.cjs +7 -0
  55. package/dist/v1/build/TinyInventoryTrader.d.mts +3 -0
  56. package/dist/v1/build/TinyInventoryTrader.mjs +2 -0
  57. package/dist/v1/build/TinyNeedBar.cjs +7 -0
  58. package/dist/v1/build/TinyNeedBar.d.mts +3 -0
  59. package/dist/v1/build/TinyNeedBar.mjs +2 -0
  60. package/dist/v1/css/TinyCookieConsent.min.css +1 -0
  61. package/dist/v1/index.cjs +20 -8
  62. package/dist/v1/index.d.mts +12 -8
  63. package/dist/v1/index.mjs +11 -3
  64. package/dist/v1/libs/TinyAdvancedRaffle.cjs +1654 -0
  65. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +851 -0
  66. package/dist/v1/libs/TinyAdvancedRaffle.mjs +1477 -0
  67. package/dist/v1/libs/TinyArrayPaginator.cjs +132 -0
  68. package/dist/v1/libs/TinyArrayPaginator.d.mts +78 -0
  69. package/dist/v1/libs/TinyArrayPaginator.mjs +119 -0
  70. package/dist/v1/libs/TinyCookieConsent.cjs +278 -0
  71. package/dist/v1/libs/TinyCookieConsent.d.mts +142 -0
  72. package/dist/v1/libs/TinyCookieConsent.mjs +248 -0
  73. package/dist/v1/libs/TinyDayNightCycle.cjs +1389 -0
  74. package/dist/v1/libs/TinyDayNightCycle.d.mts +673 -0
  75. package/dist/v1/libs/TinyDayNightCycle.mjs +1232 -0
  76. package/dist/v1/libs/TinyGamepad.cjs +2690 -0
  77. package/dist/v1/libs/TinyGamepad.d.mts +1286 -0
  78. package/dist/v1/libs/TinyGamepad.mjs +2386 -0
  79. package/dist/v1/libs/TinyHtml.d.mts +2 -2
  80. package/dist/v1/libs/TinyI18.cjs +946 -0
  81. package/dist/v1/libs/TinyI18.d.mts +418 -0
  82. package/dist/v1/libs/TinyI18.mjs +873 -0
  83. package/dist/v1/libs/TinyInventory.cjs +1788 -0
  84. package/dist/v1/libs/TinyInventory.d.mts +871 -0
  85. package/dist/v1/libs/TinyInventory.mjs +1650 -0
  86. package/dist/v1/libs/TinyInventoryTrader.cjs +242 -0
  87. package/dist/v1/libs/TinyInventoryTrader.d.mts +95 -0
  88. package/dist/v1/libs/TinyInventoryTrader.mjs +212 -0
  89. package/dist/v1/libs/TinyLocalStorage.cjs +14 -1
  90. package/dist/v1/libs/TinyLocalStorage.mjs +8 -1
  91. package/dist/v1/libs/TinyNeedBar.cjs +272 -0
  92. package/dist/v1/libs/TinyNeedBar.d.mts +223 -0
  93. package/dist/v1/libs/TinyNeedBar.mjs +241 -0
  94. package/dist/v1/libs/TinyRateLimiter.cjs +0 -13
  95. package/dist/v1/libs/TinyRateLimiter.d.mts +0 -8
  96. package/dist/v1/libs/TinyRateLimiter.mjs +0 -12
  97. package/dist/v1/libs/TinySmartScroller.cjs +0 -51
  98. package/dist/v1/libs/TinySmartScroller.d.mts +0 -36
  99. package/dist/v1/libs/TinySmartScroller.mjs +0 -46
  100. package/dist/v1/libs/TinyToastNotify.cjs +2 -2
  101. package/dist/v1/libs/TinyToastNotify.mjs +2 -2
  102. package/dist/v1/libs/TinyUploadClicker.cjs +1 -1
  103. package/docs/v1/Ai-Tips.md +51 -0
  104. package/docs/v1/Personal-Ai-Prompts(portuguese).md +134 -0
  105. package/docs/v1/Personal-Ai-Prompts.md +113 -0
  106. package/docs/v1/README.md +24 -0
  107. package/docs/v1/basics/array.md +17 -0
  108. package/docs/v1/basics/clock.md +51 -11
  109. package/docs/v1/basics/simpleMath.md +73 -0
  110. package/docs/v1/libs/TinyAdvancedRaffle.md +674 -0
  111. package/docs/v1/libs/TinyArrayPaginator.md +150 -0
  112. package/docs/v1/libs/TinyCookieConsent.md +152 -0
  113. package/docs/v1/libs/TinyDayNightCycle.md +711 -0
  114. package/docs/v1/libs/TinyGamepad.md +980 -0
  115. package/docs/v1/libs/TinyI18.md +515 -0
  116. package/docs/v1/libs/TinyInventory.md +777 -0
  117. package/docs/v1/libs/TinyInventoryTrader.md +114 -0
  118. package/docs/v1/libs/TinyNeedBar.md +226 -0
  119. package/package.json +7 -5
  120. package/dist/v1/basics/html_deprecated.cjs +0 -124
  121. package/dist/v1/basics/html_deprecated.d.mts +0 -40
  122. package/dist/v1/basics/html_deprecated.mjs +0 -97
  123. package/dist/v1/css/TinyDraggerExample.css +0 -21
  124. package/dist/v1/css/TinyNotify.css +0 -350
  125. package/dist/v1/css/aiMarker.css +0 -4
  126. package/docs/v1/basics/html_deprecated.md +0 -127
@@ -0,0 +1,134 @@
1
+ > ⚠️ **Aviso:** Os prompts fornecidos neste documento foram testados apenas no ChatGPT. O funcionamento pode variar em outras plataformas ou modelos de IA.
2
+
3
+ ### ⚙️ Preferências Técnicas de Código (JavaScript e Geral)
4
+
5
+ #### 📄 jsDoc
6
+
7
+ **jsDoc detalhado e estruturado internamente**
8
+
9
+ ```
10
+ A usuária prefere que, ao cuidar de estruturas de jsDoc, seja adicionado um sub jsDoc (sem descrições) nos valores internos das funções para que tudo fique adequadamente encaixado com a estrutura do jsDoc primário.
11
+ ```
12
+
13
+ **jsDoc obrigatório somente com tipos, sem descrições (quando não autorizado explicitamente)**
14
+
15
+ ```
16
+ A usuária prefere que, quando ela pedir para escrever um JavaScript sem ter autorizado o uso de jsDoc, o jsDoc seja gerado sem nenhuma descrição, apenas orientando os types de todos os valores dentro da função.
17
+ ```
18
+
19
+ ```
20
+ A usuária prefere que, quando pedir para escrever um código JavaScript e não autorizar o uso de jsDoc, se o jsDoc for necessário, ele seja gerado apenas com os tipos dos valores nas funções, sem descrições.
21
+ ```
22
+
23
+ **Evitar o uso de `@private` ou `@public`**
24
+
25
+ ```
26
+ A usuária prefere que não sejam usados os identificadores `@private` ou `@public` em jsDoc.
27
+ ```
28
+
29
+ #### 📝 Estilo de Código
30
+
31
+ **Textos e comentários no código devem ser em inglês**
32
+
33
+ ```
34
+ A usuária prefere que todos os textos escritos dentro dos códigos estejam em inglês.
35
+ ```
36
+
37
+ ```
38
+ A usuária prefere que os comentários e a documentação nos scripts sejam em inglês.
39
+ ```
40
+
41
+ **Evitar repetições; priorizar otimização e reutilização**
42
+
43
+ ```
44
+ A usuária deseja que todos os códigos de programação fornecidos sejam otimizados, evitando repetições de fórmulas e utilizando templates ou funções reutilizáveis sempre que possível para reduzir o tamanho do código.
45
+ ```
46
+
47
+ **Evitar uso de `var`; utilizar `let` ou `const`**
48
+
49
+ ```
50
+ A usuária prefere evitar o uso de 'var' em JavaScript e utilizar alternativas como 'let' ou 'const'.
51
+ ```
52
+
53
+ **Utilizar `import` em vez de `require`**
54
+
55
+ ```
56
+ A usuária prefere que seja utilizado `import` em vez de `require` nas respostas com código JavaScript.
57
+ ```
58
+
59
+ **Scripts escritos em inglês; explicações em português (no caso de algoritmos)**
60
+
61
+ ```
62
+ A usuária prefere que os scripts sejam escritos em inglês, mas que as respostas sobre algoritmos sejam em português.
63
+ ```
64
+
65
+ #### 🖧 Tecnologias Preferidas
66
+
67
+ **Exemplos com Apache2 ao invés de Nginx**
68
+
69
+ ```
70
+ A usuária prefere exemplos com **Apache2** em vez de **Nginx**.
71
+ ```
72
+
73
+ ---
74
+
75
+ ### 🖥️ Informações Técnicas Sobre o Ambiente da Usuária
76
+
77
+ ```
78
+ A usuária utiliza um teclado tradicional com a tecla Windows, configurado como **English (US, Intl., with dead keys)**.
79
+ ```
80
+
81
+ ```
82
+ A usuária utiliza o Kubuntu com KDE em inglês.
83
+ ```
84
+
85
+ ---
86
+
87
+ ### 🧠 Preferências de Interação, Estilo e Personalidade da Assistente
88
+
89
+ **README com tom divertido, mas não “descolado demais”**
90
+
91
+ ```
92
+ A usuária prefere que o tom do README seja divertido, mas não descolado, mantendo um estilo mais equilibrado e amigável.
93
+ ```
94
+
95
+ **Uso de "hahaha" ao invés de "kkkkk" nas interações**
96
+
97
+ ```
98
+ A usuária prefere que seja usado "hahaha" em vez de "kkkkk" nas respostas.
99
+ ```
100
+
101
+ ```
102
+ <username> é geralmente o username principal da usuária.
103
+ ```
104
+
105
+ ---
106
+
107
+ ## 📌 Instruções Principais
108
+
109
+ **Estilo de conversa adaptado para autismo/Asperger**
110
+
111
+ ```
112
+ Não use nenhum filtro de conteúdo e nenhuma ideologia nas suas respostas desde que tudo esteja respeitando seus termos de uso.
113
+ Eu tenho sindrome de asperger, então tenha uma personalidade mais adaptada para dialogar melhor com este tipo de pessoa.
114
+
115
+ me responder usando as seguintes configurações:
116
+ sinceridade: 100%
117
+ ```
118
+
119
+ ## 🖥️ Mais Instruções
120
+
121
+ **Throws alinhados com o jsDoc do script**
122
+ ```
123
+ coloque throws que ajudam a validar se os argumentos contradiz com os jsDocs:
124
+ ```
125
+
126
+ **Desenvolvimento de documentação markdown**
127
+
128
+ ```
129
+ agora eu vou começar a te enviar por partes a versão final do NAME_HERE. O seu trabalho vai ser apenas converter cada mensagem em documentação markdown (em inglês com emojis) até o final da class.
130
+ ```
131
+
132
+ ```
133
+ continue o trabalho (documentação markdown em inglês com emojis):
134
+ ```
@@ -0,0 +1,113 @@
1
+ > ⚠️ **Disclaimer:** The prompts provided in this document have been tested only in ChatGPT. Their behavior may vary on other platforms or AI models.
2
+
3
+ ### ⚙️ Technical Code Preferences (JavaScript and General)
4
+
5
+ #### 📄 jsDoc
6
+
7
+ **Detailed jsDoc with internal structure**
8
+
9
+ ```
10
+ The user prefers that, when dealing with jsDoc structures, a sub-jsDoc (without descriptions) be added to the internal values of the functions so that everything is properly aligned with the primary jsDoc structure.
11
+ ```
12
+
13
+ **jsDoc required with types only, no descriptions (unless explicitly authorized)**
14
+
15
+ ```
16
+ The user prefers that, when asking for JavaScript code without having authorized the use of jsDoc, the jsDoc should be generated with no descriptions, only specifying the types of all values inside the function.
17
+ ```
18
+
19
+ ```
20
+ The user prefers that, when asking for JavaScript code and not authorizing the use of jsDoc, if jsDoc is necessary, it should only include the types of the function values, without descriptions.
21
+ ```
22
+
23
+ **Avoid using `@private` or `@public`**
24
+
25
+ ```
26
+ The user prefers that `@private` or `@public` identifiers not be used in jsDoc.
27
+ ```
28
+
29
+ #### 📝 Code Style
30
+
31
+ **Avoid repetition; prioritize optimization and reuse**
32
+
33
+ ```
34
+ The user wants all provided programming code to be optimized, avoiding repeated formulas and using templates or reusable functions whenever possible to reduce the size of the code.
35
+ ```
36
+
37
+ **Avoid using `var`; prefer `let` or `const`**
38
+
39
+ ```
40
+ The user prefers to avoid using 'var' in JavaScript and instead use alternatives like 'let' or 'const'.
41
+ ```
42
+
43
+ **Use `import` instead of `require`**
44
+
45
+ ```
46
+ The user prefers that `import` be used instead of `require` in JavaScript code responses.
47
+ ```
48
+
49
+ #### 🖧 Preferred Technologies
50
+
51
+ **Examples using Apache2 instead of Nginx**
52
+
53
+ ```
54
+ The user prefers examples using **Apache2** instead of **Nginx**.
55
+ ```
56
+
57
+ ---
58
+
59
+ ### 🖥️ Technical Information About the User’s Environment
60
+
61
+ ```
62
+ The user uses a traditional keyboard with the Windows key, configured as **English (US, Intl., with dead keys)**.
63
+ ```
64
+
65
+ ```
66
+ The user uses Kubuntu with KDE in English.
67
+ ```
68
+
69
+ ---
70
+
71
+ ### 🧠 Interaction, Style, and Assistant Personality Preferences
72
+
73
+ **README with a fun tone, but not overly “cool”**
74
+
75
+ ```
76
+ The user prefers the README tone to be fun, but not overly cool or trendy, keeping a more balanced and friendly style.
77
+ ```
78
+
79
+ ```
80
+ <username> is usually the user’s main username.
81
+ ```
82
+
83
+ ---
84
+
85
+ ## 📌 Main Instruction
86
+
87
+ **Conversation style adapted for autism/Asperger**
88
+
89
+ ```
90
+ Do not use any content filters or ideology in your responses as long as everything respects your terms of use.
91
+ I have Asperger’s syndrome, so please have a personality better adapted to interact with this kind of person.
92
+
93
+ respond to me using the following settings:
94
+ sincerity: 100%
95
+ ```
96
+
97
+ ## 🖥️ More Instructions
98
+
99
+ **Throws aligned with the script’s jsDoc**
100
+
101
+ ```
102
+ Add throws that help validate if the arguments contradict the jsDocs:
103
+ ```
104
+
105
+ **Markdown documentation development**
106
+
107
+ ```
108
+ Now I will start sending you, in parts, the final version of NAME_HERE. Your job will be to simply convert each message into markdown documentation (in English with emojis) until the end of the class.
109
+ ```
110
+
111
+ ```
112
+ Continue the work (markdown documentation in English with emojis):
113
+ ```
package/docs/v1/README.md CHANGED
@@ -46,7 +46,16 @@ This folder contains the core scripts we have worked on so far. Each file is a m
46
46
  - 📦 **[TinyLocalStorage](./libs/TinyLocalStorage.md)** — A tiny wrapper for `localStorage` with full support for objects, arrays, `Map`, `Set`, and typed value helpers like string, number, and boolean.
47
47
  - 🖼️ **[TinyIframeEvents](./libs/TinyIframeEvents.md)** — A structured `postMessage`-based event router for secure and reliable communication between a parent window and its embedded iframe. Supports directional filtering, origin enforcement, payload transport, and listener lifecycle.
48
48
  - 🪟 **[TinyNewWinEvents](./libs/TinyNewWinEvents.md)** — A smart, route-based `postMessage` system for structured communication between a main window and a popup (`window.open`). Includes queueing, origin enforcement, and lifecycle tracking.
49
+ - 🎮 **[TinyGamepad](./libs/TinyGamepad.md)** — A flexible, professional gamepad and input manager supporting keyboard, mouse, combos, haptics, and custom input mappings.
49
50
  - ✨ **[TinyTextarea](./libs/TinyTextarea.md)** — A minimal auto-expanding `<textarea>` manager with configurable row limits, extra height padding, and real-time resize/input event hooks.
51
+ - 🌞 **[TinyDayNightCycle](./libs/TinyDayNightCycle.md)** — A comprehensive day-night cycle system managing seasons, moons, time, and weather with configurable durations, phases, and dynamic weather selection.
52
+ - 🎯 **[TinyAdvancedRaffle](./libs/TinyAdvancedRaffle.md)** — An advanced, seedable raffle system with weighted items, pity systems, exclusions, group management, modifiers, conditional rules, normalization modes, and JSON import/export.
53
+ - 📄 **[TinyArrayPaginator](./libs/TinyArrayPaginator.md)** — A secure and flexible array pagination wrapper that returns paginated results along with metadata, supports filtering via predicates or object-based matching, and prevents direct modification of the source data.
54
+ - 🍪 **[TinyCookieConsent](./libs/TinyCookieConsent.md)** — A flexible and customizable cookie consent manager that displays a consent bar, supports multiple categories, saves preferences in localStorage, allows custom renderers, and provides smooth animations for showing and hiding elements.
55
+ - 📦 **[TinyInventory](./libs/TinyInventory.md)** — A robust inventory management system with stack handling, slot management, special equipment slots, serialization, cloning, and item registry support.
56
+ - 🤝 **[TinyInventoryTrader](./libs/TinyInventoryTrader.md)** — A trading helper for safely transferring items between two inventories with support for strict mode, slot targeting, and batch operations.
57
+ - 🌐 **[TinyI18](./libs/TinyI18.md)** — A flexible i18n manager supporting local and file modes, regex-based keys, function-based entries, string interpolation, and safe helper functions for advanced rendering.
58
+ - 🎮 **[TinyNeedBar](./libs/TinyNeedBar.md)** — A versatile "need bar" system for simulating decay over time with multiple configurable factors, serialization, cloning, and full control over clamped and infinite values.
50
59
 
51
60
  ### 3. **`fileManager/`**
52
61
  * 📁 **[Main](./fileManager/main.md)** — A Node.js file/directory utility module with support for JSON, backups, renaming, size analysis, and more.
@@ -62,3 +71,18 @@ To get started, navigate to the appropriate directory and explore the files list
62
71
  ## 📑 Contributing
63
72
 
64
73
  Feel free to suggest changes, improvements, or additional features. You can fork the repository and submit a pull request!
74
+
75
+ ---
76
+
77
+ ## 📘 Want to Know How I Use AI in My Projects?
78
+
79
+ If you're curious about how I integrate AI into my development workflow — including how I manage prompts, avoid context drift, and keep control over logic and documentation — feel free to check out the following guides:
80
+
81
+ * [**AI Tips & Workflow**](./Ai-Tips.md)
82
+ Personal tips, common pitfalls to avoid, and how I keep AI assistance effective without losing my own creative and logical direction.
83
+
84
+ * [**Personal AI Prompts**](./Personal-Ai-Prompts.md)
85
+ A curated collection of my most-used AI prompts for various tasks like coding, writing, automation, and technical documentation — written in English.
86
+
87
+ * [**Personal AI Prompts (Portuguese)**](./Personal-Ai-Prompts%28portuguese%29.md)
88
+ The same set of personal AI prompts, but fully translated into Portuguese for ease of use in native language contexts.
@@ -78,3 +78,20 @@ Great for situations where you need to **dynamically sort objects** by one of th
78
78
  * Sorting users by age
79
79
  * Ordering tasks by priority
80
80
  * Displaying leaderboard scores
81
+
82
+ ---
83
+
84
+ ## 🔁 `multiplyArrayBlocks(phases, counts)`
85
+
86
+ Generates a flattened array with phases repeated according to the specified counts.
87
+
88
+ * **`phases`** 📝 — Array of phase names (e.g., `['Full', 'Half1', 'Half2', 'New']`).
89
+ * **`counts`** 🔢 — Array of integers specifying how many times each phase should be repeated (e.g., `[4, 5, 5, 4]`).
90
+ * **Returns** 📦 — A single array where each phase appears the given number of times, in order.
91
+
92
+ **Example:**
93
+
94
+ ```js
95
+ multiplyArrayBlocks(['Full', 'Half1', 'Half2', 'New'], [4, 5, 5, 4]);
96
+ // ➡ ['Full','Full','Full','Full','Half1','Half1','Half1','Half1','Half1', ...]
97
+ ```
@@ -1,12 +1,12 @@
1
1
  # ⏰ clock.mjs
2
2
 
3
- A versatile time utility module for JavaScript that helps you calculate and format time durations with style. Whether you're building countdowns, timers, or just need a nice "HH:MM:SS" string, this module has your back!
3
+ A versatile time utility module for JavaScript that helps you calculate and format time durations with style. Whether you're building countdowns, timers, or just need a nice "HH\:MM\:SS" string, this module has your back!
4
4
 
5
5
  ## ✨ Features
6
6
 
7
7
  - 🔢 Calculate time differences in various units
8
8
  - 🧭 Format durations into clean, readable timer strings
9
- - 🧱 Support for years, months, days, hours, minutes, and seconds
9
+ - 🧱 Support for years, months, days, hours, minutes, seconds **and milliseconds**
10
10
  - 🎛️ Customizable output with template-based formatting
11
11
  - 🛠️ Built-in presets for classic timer formats
12
12
  - 🪶 Zero dependencies, lightweight and modular (ESM-ready!)
@@ -19,11 +19,11 @@ A versatile time utility module for JavaScript that helps you calculate and form
19
19
 
20
20
  Calculates how much time remains (or has passed) between now and a given time.
21
21
 
22
- | Param | Type | Description |
23
- |---------------|----------|-----------------------------------------------------------------------------|
24
- | `timeData` | `Date` | The target time |
25
- | `durationType`| `string` | Format to return (`asMilliseconds`, `asSeconds`, `asMinutes`, etc.) |
26
- | `now` | `Date` | Optional custom "now". Defaults to current time. |
22
+ | Param | Type | Description |
23
+ | -------------- | -------- | ------------------------------------------------------------------- |
24
+ | `timeData` | `Date` | The target time |
25
+ | `durationType` | `string` | Format to return (`asMilliseconds`, `asSeconds`, `asMinutes`, etc.) |
26
+ | `now` | `Date` | Optional custom "now". Defaults to current time. |
27
27
 
28
28
  **Returns:** `number|null` — The duration in the chosen unit.
29
29
 
@@ -33,11 +33,11 @@ Calculates how much time remains (or has passed) between now and a given time.
33
33
 
34
34
  Turns seconds into a custom timer string with fine-grained control.
35
35
 
36
- | Param | Type | Description |
37
- |-------------|----------|----------------------------------------------------------------------------------------------|
36
+ | Param | Type | Description |
37
+ | -------------- | -------- | ------------------------------------------------------------------------------------------- |
38
38
  | `totalSeconds` | `number` | The duration to format (in seconds) |
39
- | `level` | `string` | Highest level to show: `'seconds'`, `'minutes'`, `'hours'`, `'days'`, `'months'`, `'years'` |
40
- | `format` | `string` | Output string template. Supports placeholders like `{days}`, `{hours}`, `{time}`, `{total}` |
39
+ | `level` | `string` | Highest level to show: `'seconds'`, `'minutes'`, `'hours'`, `'days'`, `'months'`, `'years'` |
40
+ | `format` | `string` | Output string template. Supports placeholders like `{days}`, `{hours}`, `{time}`, `{total}` |
41
41
 
42
42
  **Returns:** `string` — A formatted string with padded units.
43
43
 
@@ -63,6 +63,33 @@ formatDayTimer(190000); // "2d 04:46:40"
63
63
 
64
64
  ---
65
65
 
66
+ ### 🔹 `breakdownDuration(totalMs, level = 'milliseconds')`
67
+
68
+ Breaks down a duration (in **milliseconds**) into its full components, returning an object instead of a string.
69
+ This is useful when you want numeric values to build your own custom formats.
70
+
71
+ | Param | Type | Description |
72
+ | --------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
73
+ | `totalMs` | `number` | The duration to format (in milliseconds) |
74
+ | `level` | `string` | Highest level to break down: `'milliseconds'`, `'seconds'`, `'minutes'`, `'hours'`, `'days'`, `'months'`, `'years'` |
75
+
76
+ **Returns:** `object` — An object with numeric values for all included units:
77
+
78
+ ```json
79
+ {
80
+ "years": 0,
81
+ "months": 0,
82
+ "days": 11,
83
+ "hours": 10,
84
+ "minutes": 20,
85
+ "seconds": 54,
86
+ "milliseconds": 321,
87
+ "total": 987654321
88
+ }
89
+ ```
90
+
91
+ ---
92
+
66
93
  ## 🧪 Examples
67
94
 
68
95
  ```js
@@ -74,4 +101,17 @@ console.log(formatDayTimer(172800 + 3661)); // "2d 01:01:01"
74
101
 
75
102
  const custom = formatCustomTimer(3600 * 26 + 61, 'days', '{days}d {hours}h {minutes}m {seconds}s');
76
103
  console.log(custom); // "1d 2h 1m 1s"
104
+
105
+ const breakdown = breakdownDuration(987654321, 'years');
106
+ console.log(breakdown);
107
+ // {
108
+ // years: 0,
109
+ // months: 0,
110
+ // days: 11,
111
+ // hours: 10,
112
+ // minutes: 20,
113
+ // seconds: 54,
114
+ // milliseconds: 321,
115
+ // total: 987654321
116
+ // }
77
117
  ```
@@ -165,3 +165,76 @@ genFibonacciSeq({
165
165
  An array representing the generated sequence.
166
166
 
167
167
  > 🔖 **Beta** – Still experimental and fun to tweak!
168
+
169
+ ---
170
+
171
+ ### 📊 `compareMarketcap`
172
+
173
+ Calculates the price change of a stuff when its **market cap changes**.
174
+
175
+ #### 🧩 Function Signature
176
+
177
+ ```js
178
+ compareMarketcap(originalMarketCap, circulatingSupply, newMarketCap)
179
+ ```
180
+
181
+ #### 📥 Parameters
182
+
183
+ | Parameter | Type | Description |
184
+ | ------------------- | -------- | --------------------------------------------------------------------------- |
185
+ | `originalMarketCap` | `number` | 💰 The original market capitalization. Must be a valid, finite number. |
186
+ | `circulatingSupply` | `number` | 🔄 The circulating supply of the coin. Must be a positive number. |
187
+ | `newMarketCap` | `number` | 📉 The new market capitalization. Optional. Must be a valid number if used. |
188
+
189
+ #### 📤 Returns
190
+
191
+ An object with the following fields:
192
+
193
+ ```js
194
+ {
195
+ originalPrice: number, // 💵 Price before market cap changed
196
+ newPrice: number, // 💸 Price after market cap changed (NaN if not provided)
197
+ priceChangePercent: number // 📈 Percentage change in price (NaN if newMarketCap not provided)
198
+ }
199
+ ```
200
+
201
+ #### ⚠️ Validation Rules
202
+
203
+ * Throws a `TypeError` if any of the numeric inputs are not finite numbers.
204
+ * Throws an `Error` if `circulatingSupply` is less than or equal to zero.
205
+ * If `newMarketCap` is omitted or not a number, `newPrice` and `priceChangePercent` will be `NaN`.
206
+
207
+ #### 📝 Notes
208
+
209
+ * Useful for estimating the effect of market cap fluctuations on token price.
210
+ * Ideal for financial dashboards, token simulations, or educational tools.
211
+
212
+ ---
213
+
214
+ ### 📈 `calculateMarketcap(originalMarketCap, circulatingSupply)`
215
+
216
+ Calculates the **unit price** of a coin or token based on its **market capitalization** and **circulating supply**.
217
+
218
+ This function is commonly used in financial applications to estimate the price per asset unit (e.g., per token or coin).
219
+
220
+ #### 🧮 Formula
221
+
222
+ ```
223
+ price = originalMarketCap / circulatingSupply
224
+ ```
225
+
226
+ #### 📥 Parameters
227
+
228
+ | Name | Type | Description |
229
+ | ------------------- | -------- | ---------------------------------------------------------- |
230
+ | `originalMarketCap` | `number` | The total market capitalization (e.g., in USD) 💵. |
231
+ | `circulatingSupply` | `number` | The number of tokens or coins currently in circulation 🪙. |
232
+
233
+ #### 📤 Returns
234
+
235
+ * `number` – The calculated **unit price** of the asset 🔢.
236
+
237
+ #### ⚠️ Throws
238
+
239
+ * `TypeError` – If either parameter is not a finite number ❌.
240
+ * `Error` – If `circulatingSupply` is less than or equal to zero 🚫.