@sharadox/web-library 0.4.1 → 0.5.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.
Files changed (279) hide show
  1. package/README.md +40 -28
  2. package/distribution/assert/never/index.d.ts +13 -0
  3. package/distribution/assert/never/index.d.ts.map +1 -0
  4. package/distribution/assert/never/index.js +15 -0
  5. package/distribution/assert/never/index.js.map +1 -0
  6. package/distribution/class-name/index.d.ts +6 -1
  7. package/distribution/class-name/index.d.ts.map +1 -1
  8. package/distribution/class-name/index.js +6 -1
  9. package/distribution/class-name/index.js.map +1 -1
  10. package/distribution/html/escape/index.d.ts +6 -1
  11. package/distribution/html/escape/index.d.ts.map +1 -1
  12. package/distribution/html/escape/index.js +7 -2
  13. package/distribution/html/escape/index.js.map +1 -1
  14. package/distribution/math/clamp/index.d.ts +6 -1
  15. package/distribution/math/clamp/index.d.ts.map +1 -1
  16. package/distribution/math/clamp/index.js +6 -1
  17. package/distribution/math/clamp/index.js.map +1 -1
  18. package/distribution/math/pseudo-random/index.d.ts +6 -1
  19. package/distribution/math/pseudo-random/index.d.ts.map +1 -1
  20. package/distribution/math/pseudo-random/index.js +6 -1
  21. package/distribution/math/pseudo-random/index.js.map +1 -1
  22. package/distribution/math/radians/index.d.ts +6 -1
  23. package/distribution/math/radians/index.d.ts.map +1 -1
  24. package/distribution/math/radians/index.js +6 -1
  25. package/distribution/math/radians/index.js.map +1 -1
  26. package/distribution/text/separate/index.d.ts +9 -0
  27. package/distribution/text/separate/index.d.ts.map +1 -0
  28. package/distribution/text/separate/index.js +11 -0
  29. package/distribution/text/separate/index.js.map +1 -0
  30. package/distribution/type-guard/is-boolean/index.d.ts +8 -0
  31. package/distribution/type-guard/is-boolean/index.d.ts.map +1 -0
  32. package/distribution/type-guard/is-boolean/index.js +10 -0
  33. package/distribution/type-guard/is-boolean/index.js.map +1 -0
  34. package/distribution/type-guard/is-defined/index.d.ts +8 -0
  35. package/distribution/type-guard/is-defined/index.d.ts.map +1 -0
  36. package/distribution/type-guard/is-defined/index.js +10 -0
  37. package/distribution/type-guard/is-defined/index.js.map +1 -0
  38. package/distribution/type-guard/is-non-empty-string/index.d.ts +8 -0
  39. package/distribution/type-guard/is-non-empty-string/index.d.ts.map +1 -0
  40. package/distribution/type-guard/is-non-empty-string/index.js +11 -0
  41. package/distribution/type-guard/is-non-empty-string/index.js.map +1 -0
  42. package/distribution/type-guard/is-number/index.d.ts +9 -0
  43. package/distribution/type-guard/is-number/index.d.ts.map +1 -0
  44. package/distribution/type-guard/is-number/index.js +11 -0
  45. package/distribution/type-guard/is-number/index.js.map +1 -0
  46. package/distribution/type-guard/is-record/index.d.ts +9 -0
  47. package/distribution/type-guard/is-record/index.d.ts.map +1 -0
  48. package/distribution/type-guard/is-record/index.js +14 -0
  49. package/distribution/type-guard/is-record/index.js.map +1 -0
  50. package/distribution/type-guard/is-string/index.d.ts +9 -0
  51. package/distribution/type-guard/is-string/index.d.ts.map +1 -0
  52. package/distribution/type-guard/is-string/index.js +11 -0
  53. package/distribution/type-guard/is-string/index.js.map +1 -0
  54. package/llms.txt +17 -0
  55. package/package.json +17 -45
  56. package/distribution/animation/count-up/index.d.ts +0 -6
  57. package/distribution/animation/count-up/index.d.ts.map +0 -1
  58. package/distribution/animation/count-up/index.js +0 -29
  59. package/distribution/animation/count-up/index.js.map +0 -1
  60. package/distribution/animation/in-view/index.d.ts +0 -3
  61. package/distribution/animation/in-view/index.d.ts.map +0 -1
  62. package/distribution/animation/in-view/index.js +0 -15
  63. package/distribution/animation/in-view/index.js.map +0 -1
  64. package/distribution/animation/marquee/index.d.ts +0 -9
  65. package/distribution/animation/marquee/index.d.ts.map +0 -1
  66. package/distribution/animation/marquee/index.js +0 -78
  67. package/distribution/animation/marquee/index.js.map +0 -1
  68. package/distribution/animation/marquee/type.d.ts +0 -5
  69. package/distribution/animation/marquee/type.d.ts.map +0 -1
  70. package/distribution/animation/marquee/type.js +0 -2
  71. package/distribution/animation/marquee/type.js.map +0 -1
  72. package/distribution/animation/reveal/index.d.ts +0 -4
  73. package/distribution/animation/reveal/index.d.ts.map +0 -1
  74. package/distribution/animation/reveal/index.js +0 -9
  75. package/distribution/animation/reveal/index.js.map +0 -1
  76. package/distribution/animation/reveal/type.d.ts +0 -14
  77. package/distribution/animation/reveal/type.d.ts.map +0 -1
  78. package/distribution/animation/reveal/type.js +0 -2
  79. package/distribution/animation/reveal/type.js.map +0 -1
  80. package/distribution/animation/scroll-word/index.d.ts +0 -4
  81. package/distribution/animation/scroll-word/index.d.ts.map +0 -1
  82. package/distribution/animation/scroll-word/index.js +0 -16
  83. package/distribution/animation/scroll-word/index.js.map +0 -1
  84. package/distribution/animation/scroll-word/type.d.ts +0 -11
  85. package/distribution/animation/scroll-word/type.d.ts.map +0 -1
  86. package/distribution/animation/scroll-word/type.js +0 -2
  87. package/distribution/animation/scroll-word/type.js.map +0 -1
  88. package/distribution/animation/scroll-word/word/index.d.ts +0 -4
  89. package/distribution/animation/scroll-word/word/index.d.ts.map +0 -1
  90. package/distribution/animation/scroll-word/word/index.js +0 -10
  91. package/distribution/animation/scroll-word/word/index.js.map +0 -1
  92. package/distribution/animation/scroll-word/word/type.d.ts +0 -14
  93. package/distribution/animation/scroll-word/word/type.d.ts.map +0 -1
  94. package/distribution/animation/scroll-word/word/type.js +0 -2
  95. package/distribution/animation/scroll-word/word/type.js.map +0 -1
  96. package/distribution/animation/smooth-scroll/index.d.ts +0 -4
  97. package/distribution/animation/smooth-scroll/index.d.ts.map +0 -1
  98. package/distribution/animation/smooth-scroll/index.js +0 -33
  99. package/distribution/animation/smooth-scroll/index.js.map +0 -1
  100. package/distribution/animation/smooth-scroll/type.d.ts +0 -7
  101. package/distribution/animation/smooth-scroll/type.d.ts.map +0 -1
  102. package/distribution/animation/smooth-scroll/type.js +0 -2
  103. package/distribution/animation/smooth-scroll/type.js.map +0 -1
  104. package/distribution/form/bot-check/index.d.ts +0 -4
  105. package/distribution/form/bot-check/index.d.ts.map +0 -1
  106. package/distribution/form/bot-check/index.js +0 -6
  107. package/distribution/form/bot-check/index.js.map +0 -1
  108. package/distribution/form/bot-check/type.d.ts +0 -11
  109. package/distribution/form/bot-check/type.d.ts.map +0 -1
  110. package/distribution/form/bot-check/type.js +0 -2
  111. package/distribution/form/bot-check/type.js.map +0 -1
  112. package/distribution/form/field/index.d.ts +0 -3
  113. package/distribution/form/field/index.d.ts.map +0 -1
  114. package/distribution/form/field/index.js +0 -7
  115. package/distribution/form/field/index.js.map +0 -1
  116. package/distribution/form/rate-limit/index.d.ts +0 -4
  117. package/distribution/form/rate-limit/index.d.ts.map +0 -1
  118. package/distribution/form/rate-limit/index.js +0 -14
  119. package/distribution/form/rate-limit/index.js.map +0 -1
  120. package/distribution/form/rate-limit/type.d.ts +0 -9
  121. package/distribution/form/rate-limit/type.d.ts.map +0 -1
  122. package/distribution/form/rate-limit/type.js +0 -2
  123. package/distribution/form/rate-limit/type.js.map +0 -1
  124. package/distribution/internationalization/locale/index.d.ts +0 -7
  125. package/distribution/internationalization/locale/index.d.ts.map +0 -1
  126. package/distribution/internationalization/locale/index.js +0 -17
  127. package/distribution/internationalization/locale/index.js.map +0 -1
  128. package/distribution/internationalization/locale/type.d.ts +0 -3
  129. package/distribution/internationalization/locale/type.d.ts.map +0 -1
  130. package/distribution/internationalization/locale/type.js +0 -2
  131. package/distribution/internationalization/locale/type.js.map +0 -1
  132. package/distribution/internationalization/locale-preference/index.d.ts +0 -5
  133. package/distribution/internationalization/locale-preference/index.d.ts.map +0 -1
  134. package/distribution/internationalization/locale-preference/index.js +0 -9
  135. package/distribution/internationalization/locale-preference/index.js.map +0 -1
  136. package/distribution/internationalization/locale-redirect/index.d.ts +0 -8
  137. package/distribution/internationalization/locale-redirect/index.d.ts.map +0 -1
  138. package/distribution/internationalization/locale-redirect/index.js +0 -24
  139. package/distribution/internationalization/locale-redirect/index.js.map +0 -1
  140. package/distribution/internationalization/locale-redirect/type.d.ts +0 -12
  141. package/distribution/internationalization/locale-redirect/type.d.ts.map +0 -1
  142. package/distribution/internationalization/locale-redirect/type.js +0 -2
  143. package/distribution/internationalization/locale-redirect/type.js.map +0 -1
  144. package/distribution/internationalization/translate/index.d.ts +0 -4
  145. package/distribution/internationalization/translate/index.d.ts.map +0 -1
  146. package/distribution/internationalization/translate/index.js +0 -5
  147. package/distribution/internationalization/translate/index.js.map +0 -1
  148. package/distribution/pointer/spotlight/index.d.ts +0 -3
  149. package/distribution/pointer/spotlight/index.d.ts.map +0 -1
  150. package/distribution/pointer/spotlight/index.js +0 -20
  151. package/distribution/pointer/spotlight/index.js.map +0 -1
  152. package/distribution/pointer/tilt/index.d.ts +0 -7
  153. package/distribution/pointer/tilt/index.d.ts.map +0 -1
  154. package/distribution/pointer/tilt/index.js +0 -34
  155. package/distribution/pointer/tilt/index.js.map +0 -1
  156. package/distribution/privacy/consent/index.d.ts +0 -22
  157. package/distribution/privacy/consent/index.d.ts.map +0 -1
  158. package/distribution/privacy/consent/index.js +0 -75
  159. package/distribution/privacy/consent/index.js.map +0 -1
  160. package/distribution/privacy/consent/type.d.ts +0 -35
  161. package/distribution/privacy/consent/type.d.ts.map +0 -1
  162. package/distribution/privacy/consent/type.js +0 -2
  163. package/distribution/privacy/consent/type.js.map +0 -1
  164. package/distribution/privacy/use-consent/index.d.ts +0 -5
  165. package/distribution/privacy/use-consent/index.d.ts.map +0 -1
  166. package/distribution/privacy/use-consent/index.js +0 -22
  167. package/distribution/privacy/use-consent/index.js.map +0 -1
  168. package/distribution/privacy/use-consent/type.d.ts +0 -10
  169. package/distribution/privacy/use-consent/type.d.ts.map +0 -1
  170. package/distribution/privacy/use-consent/type.js +0 -2
  171. package/distribution/privacy/use-consent/type.js.map +0 -1
  172. package/distribution/scroll/active-section/index.d.ts +0 -7
  173. package/distribution/scroll/active-section/index.d.ts.map +0 -1
  174. package/distribution/scroll/active-section/index.js +0 -49
  175. package/distribution/scroll/active-section/index.js.map +0 -1
  176. package/distribution/scroll/active-section/type.d.ts +0 -9
  177. package/distribution/scroll/active-section/type.d.ts.map +0 -1
  178. package/distribution/scroll/active-section/type.js +0 -2
  179. package/distribution/scroll/active-section/type.js.map +0 -1
  180. package/distribution/search-engine/robots/index.d.ts +0 -4
  181. package/distribution/search-engine/robots/index.d.ts.map +0 -1
  182. package/distribution/search-engine/robots/index.js +0 -7
  183. package/distribution/search-engine/robots/index.js.map +0 -1
  184. package/distribution/search-engine/robots/type.d.ts +0 -17
  185. package/distribution/search-engine/robots/type.d.ts.map +0 -1
  186. package/distribution/search-engine/robots/type.js +0 -2
  187. package/distribution/search-engine/robots/type.js.map +0 -1
  188. package/distribution/search-engine/sitemap/index.d.ts +0 -4
  189. package/distribution/search-engine/sitemap/index.d.ts.map +0 -1
  190. package/distribution/search-engine/sitemap/index.js +0 -12
  191. package/distribution/search-engine/sitemap/index.js.map +0 -1
  192. package/distribution/search-engine/sitemap/type.d.ts +0 -22
  193. package/distribution/search-engine/sitemap/type.d.ts.map +0 -1
  194. package/distribution/search-engine/sitemap/type.js +0 -2
  195. package/distribution/search-engine/sitemap/type.js.map +0 -1
  196. package/distribution/search-engine/structured-data/index.d.ts +0 -4
  197. package/distribution/search-engine/structured-data/index.d.ts.map +0 -1
  198. package/distribution/search-engine/structured-data/index.js +0 -6
  199. package/distribution/search-engine/structured-data/index.js.map +0 -1
  200. package/distribution/search-engine/structured-data/type.d.ts +0 -5
  201. package/distribution/search-engine/structured-data/type.d.ts.map +0 -1
  202. package/distribution/search-engine/structured-data/type.js +0 -2
  203. package/distribution/search-engine/structured-data/type.js.map +0 -1
  204. package/distribution/style/apply/index.d.ts +0 -11
  205. package/distribution/style/apply/index.d.ts.map +0 -1
  206. package/distribution/style/apply/index.js +0 -50
  207. package/distribution/style/apply/index.js.map +0 -1
  208. package/distribution/style/apply/type.d.ts +0 -12
  209. package/distribution/style/apply/type.d.ts.map +0 -1
  210. package/distribution/style/apply/type.js +0 -2
  211. package/distribution/style/apply/type.js.map +0 -1
  212. package/distribution/style/definition/index.d.ts +0 -14
  213. package/distribution/style/definition/index.d.ts.map +0 -1
  214. package/distribution/style/definition/index.js +0 -26
  215. package/distribution/style/definition/index.js.map +0 -1
  216. package/distribution/style/definition/type.d.ts +0 -29
  217. package/distribution/style/definition/type.d.ts.map +0 -1
  218. package/distribution/style/definition/type.js +0 -2
  219. package/distribution/style/definition/type.js.map +0 -1
  220. package/distribution/style/style-script/index.d.ts +0 -10
  221. package/distribution/style/style-script/index.d.ts.map +0 -1
  222. package/distribution/style/style-script/index.js +0 -16
  223. package/distribution/style/style-script/index.js.map +0 -1
  224. package/distribution/style/style-script/type.d.ts +0 -5
  225. package/distribution/style/style-script/type.d.ts.map +0 -1
  226. package/distribution/style/style-script/type.js +0 -2
  227. package/distribution/style/style-script/type.js.map +0 -1
  228. package/distribution/style/style-sheet/index.d.ts +0 -8
  229. package/distribution/style/style-sheet/index.d.ts.map +0 -1
  230. package/distribution/style/style-sheet/index.js +0 -25
  231. package/distribution/style/style-sheet/index.js.map +0 -1
  232. package/distribution/style/use-style/index.d.ts +0 -5
  233. package/distribution/style/use-style/index.d.ts.map +0 -1
  234. package/distribution/style/use-style/index.js +0 -37
  235. package/distribution/style/use-style/index.js.map +0 -1
  236. package/distribution/style/use-style/type.d.ts +0 -9
  237. package/distribution/style/use-style/type.d.ts.map +0 -1
  238. package/distribution/style/use-style/type.js +0 -2
  239. package/distribution/style/use-style/type.js.map +0 -1
  240. package/distribution/test/visual-snapshot/index.d.ts +0 -8
  241. package/distribution/test/visual-snapshot/index.d.ts.map +0 -1
  242. package/distribution/test/visual-snapshot/index.js +0 -20
  243. package/distribution/test/visual-snapshot/index.js.map +0 -1
  244. package/distribution/test/visual-snapshot/type.d.ts +0 -7
  245. package/distribution/test/visual-snapshot/type.d.ts.map +0 -1
  246. package/distribution/test/visual-snapshot/type.js +0 -2
  247. package/distribution/test/visual-snapshot/type.js.map +0 -1
  248. package/distribution/time/format-time/index.d.ts +0 -3
  249. package/distribution/time/format-time/index.d.ts.map +0 -1
  250. package/distribution/time/format-time/index.js +0 -5
  251. package/distribution/time/format-time/index.js.map +0 -1
  252. package/distribution/time/open-state/index.d.ts +0 -4
  253. package/distribution/time/open-state/index.d.ts.map +0 -1
  254. package/distribution/time/open-state/index.js +0 -11
  255. package/distribution/time/open-state/index.js.map +0 -1
  256. package/distribution/time/open-state/type.d.ts +0 -5
  257. package/distribution/time/open-state/type.d.ts.map +0 -1
  258. package/distribution/time/open-state/type.js +0 -2
  259. package/distribution/time/open-state/type.js.map +0 -1
  260. package/distribution/time/sun-time/index.d.ts +0 -4
  261. package/distribution/time/sun-time/index.d.ts.map +0 -1
  262. package/distribution/time/sun-time/index.js +0 -27
  263. package/distribution/time/sun-time/index.js.map +0 -1
  264. package/distribution/time/sun-time/type.d.ts +0 -6
  265. package/distribution/time/sun-time/type.d.ts.map +0 -1
  266. package/distribution/time/sun-time/type.js +0 -2
  267. package/distribution/time/sun-time/type.js.map +0 -1
  268. package/distribution/time/sun-today/index.d.ts +0 -4
  269. package/distribution/time/sun-today/index.d.ts.map +0 -1
  270. package/distribution/time/sun-today/index.js +0 -25
  271. package/distribution/time/sun-today/index.js.map +0 -1
  272. package/distribution/time/sun-today/type.d.ts +0 -9
  273. package/distribution/time/sun-today/type.d.ts.map +0 -1
  274. package/distribution/time/sun-today/type.js +0 -2
  275. package/distribution/time/sun-today/type.js.map +0 -1
  276. package/distribution/time/zone-minute/index.d.ts +0 -3
  277. package/distribution/time/zone-minute/index.d.ts.map +0 -1
  278. package/distribution/time/zone-minute/index.js +0 -13
  279. package/distribution/time/zone-minute/index.js.map +0 -1
package/README.md CHANGED
@@ -1,40 +1,52 @@
1
1
  # @sharadox/web-library
2
2
 
3
- Generic building blocks for web applications, arranged by topic. When a topic grows big enough it moves into its own library (for example `internationalization-web-library`).
3
+ The small, general utilities every Sharadox library and application imports, so even one-liners are written once: type guards, class names, HTML escaping, joining labels, math helpers and exhaustiveness checks. No dependencies.
4
+
5
+ Topic code lives in its own libraries. This package used to hold it up to version 0.4. Each topic's new home:
6
+
7
+ | Topic | Library |
8
+ | ----------------------------------------------------------------------- | -------------------------------------------- |
9
+ | Languages, translations, locale redirects and links | `@sharadox/internationalization-web-library` |
10
+ | Page metadata, sitemap, robots, manifest, structured data, share images | `@sharadox/metadata-web-library` |
11
+ | Styles (themes) | `@sharadox/style-web-library` |
12
+ | Cookie consent | `@sharadox/consent-web-library` |
13
+ | Reveal, scroll-lit words, in-view, count-up, marquee | `@sharadox/animation-web-library` |
14
+ | Smooth scrolling, active section | `@sharadox/scroll-web-library` |
15
+ | Spotlight, tilt, custom cursor | `@sharadox/pointer-web-library` |
16
+ | Bot checks, rate limit, contact forms | `@sharadox/form-web-library` |
17
+ | Time zones, opening hours, sunrise and sunset | `@sharadox/time-web-library` |
18
+ | Playwright helpers and shared test suites | `@sharadox/test-web-library` |
19
+
20
+ ## Install
4
21
 
5
22
  ```sh
6
23
  pnpm add @sharadox/web-library
7
24
  ```
8
25
 
9
- Import each piece by its path:
10
-
11
- | Topic | Pieces |
12
- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
13
- | `internationalization/` | `locale` (`isLocale`, `languageTag`, `openGraphLocale`, `Translated`), `translate`, `locale-redirect` (next.config redirects: remembered language, then Accept-Language), `locale-preference` (`rememberLocale`) |
14
- | `search-engine/` | `sitemap` (`localizedSitemap`), `robots`, `structured-data` (JSON-LD component) |
15
- | `animation/` | `reveal`, `scroll-word` (text that lights up word by word), `in-view`, `count-up`, `marquee` (endless strip you can also drag), `smooth-scroll` |
16
- | `style/` | `definition` (`resolveStyle`), `style-script` (`<StyleScript>` for `<head>`: every style's CSS variables and the no-flash script), `use-style` (picker hook), `apply`, `style-sheet` |
17
- | `scroll/` | `active-section` (which section is on screen, and how far through the page) |
18
- | `privacy/` | `consent` (cookie answers: kept when accepted or chosen, for this visit only when denied; `hasConsent`, `openConsent`), `use-consent` (hook) |
19
- | `pointer/` | `spotlight` (pointer position as CSS variables), `tilt` (3D tilt towards the pointer) |
20
- | `time/` | `zone-minute`, `format-time`, `sun-time` (sunrise and sunset), `sun-today` (React hook), `open-state` |
21
- | `form/` | `rate-limit`, `bot-check` (honeypot and fill time), `field` |
22
- | `html/` | `escape` |
23
- | `math/` | `radians`, `clamp`, `pseudo-random` |
24
- | `test/` | `visual-snapshot` (Playwright: frozen clock, settled reveals) |
25
- | — | `class-name` |
26
-
27
- ```tsx
28
- import { Reveal } from "@sharadox/web-library/animation/reveal";
29
- import { translate } from "@sharadox/web-library/internationalization/translate";
30
-
31
- <Reveal delay={0.1}>{translate({ en: "Hello", pt: "Olá" }, locale)}</Reveal>;
32
- ```
26
+ ## API
27
+
28
+ Import each utility by its path:
29
+
30
+ | Import | Export | Example |
31
+ | -------------------------------------------- | ------------------------------------------------- | ---------------------------------------------------- |
32
+ | `@sharadox/web-library/type-guard/is-string` | `isString(value)` | `isString("a") // true` |
33
+ | `…/type-guard/is-non-empty-string` | `isNonEmptyString(value)` | `isNonEmptyString("") // false` |
34
+ | `…/type-guard/is-number` | `isNumber(value)`: finite numbers only | `isNumber(NaN) // false` |
35
+ | `…/type-guard/is-boolean` | `isBoolean(value)` | `isBoolean(false) // true` |
36
+ | `…/type-guard/is-record` | `isRecord(value)`: plain objects only | `isRecord([]) // false` |
37
+ | `…/type-guard/is-defined` | `isDefined(value)`: not `null`/`undefined` | `[1, undefined].filter(isDefined) // [1]` |
38
+ | `…/class-name` | `classNames(...names)` | `classNames("a", false, "b") // "a b"` |
39
+ | `…/html/escape` | `escapeHtml(text)` | `escapeHtml("<b>") // "&lt;b&gt;"` |
40
+ | `…/text/separate` | `separate(separator, ...parts)` | `separate("•", "Contact", "Ana") // "Contact • Ana"` |
41
+ | `…/math/clamp` | `clamp(value, minimum, maximum)` | `clamp(5, 0, 1) // 1` |
42
+ | `…/math/radians` | `radians(degrees)` | `radians(180) // Math.PI` |
43
+ | `…/math/pseudo-random` | `pseudoRandom(seed)`: repeatable number in [0, 1) | `pseudoRandom(3) === pseudoRandom(3)` |
44
+ | `…/assert/never` | `assertNever(value)`: exhaustive `switch` checks | `default: return assertNever(kind)` |
33
45
 
34
- Styles are what other projects call themes: any number of dark and light styles, a default for each scheme, "system" or a fixed style as the default choice, and a manual choice remembered in browser storage.
46
+ ## Develop
35
47
 
36
- React components are client components (`"use client"`), accept `className`, and can be restyled per site. React (and, for `test/`, Playwright) are optional peer dependencies.
48
+ Every function is tested at 100% coverage (`pnpm test:unit`). `pnpm verify` runs formatting, lint, type-check, tests and the build. Branches follow `<feature>.development` → `development` → `index`, and releases are `v<version>` tags on `index`.
37
49
 
38
50
  ## Licence
39
51
 
40
- Licença Sharadox de Código Aberto, versão 0.1.0 — [português](LICENCA.md) (the binding text) · [English translation](LICENSE.md).
52
+ Licença Sharadox de Código Aberto, versão 0.1.0. See [português](LICENCA.md) (the binding text) and the [English translation](LICENSE.md).
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Marks code that can't be reached when every case of a union is handled: TypeScript reports an error if a case
3
+ * is added and forgotten, and calling it at run time throws.
4
+ *
5
+ * @example
6
+ * switch (kind) {
7
+ * case "a": return 1;
8
+ * case "b": return 2;
9
+ * default: return assertNever(kind);
10
+ * }
11
+ */
12
+ export declare function assertNever(value: never): never;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/assert/never/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Marks code that can't be reached when every case of a union is handled: TypeScript reports an error if a case
3
+ * is added and forgotten, and calling it at run time throws.
4
+ *
5
+ * @example
6
+ * switch (kind) {
7
+ * case "a": return 1;
8
+ * case "b": return 2;
9
+ * default: return assertNever(kind);
10
+ * }
11
+ */
12
+ export function assertNever(value) {
13
+ throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
14
+ }
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/assert/never/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC"}
@@ -1,3 +1,8 @@
1
- /** Joins the class names that are set, skipping false, null, undefined and empty strings. */
1
+ /**
2
+ * Joins the class names that are set, skipping `false`, `null`, `undefined` and empty strings.
3
+ *
4
+ * @example
5
+ * classNames("button", isActive && "active", undefined); // "button active" or "button"
6
+ */
2
7
  export declare function classNames(...names: (string | false | null | undefined)[]): string;
3
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/class-name/index.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAElF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/class-name/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAElF"}
@@ -1,4 +1,9 @@
1
- /** Joins the class names that are set, skipping false, null, undefined and empty strings. */
1
+ /**
2
+ * Joins the class names that are set, skipping `false`, `null`, `undefined` and empty strings.
3
+ *
4
+ * @example
5
+ * classNames("button", isActive && "active", undefined); // "button active" or "button"
6
+ */
2
7
  export function classNames(...names) {
3
8
  return names.filter(Boolean).join(" ");
4
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/class-name/index.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,GAAG,KAA4C;IACxE,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/class-name/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAA4C;IACxE,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
@@ -1,3 +1,8 @@
1
- /** Escapes text for safe use inside html (for example in email bodies). */
1
+ /**
2
+ * Escapes text for safe use inside HTML, for example user input in an email body.
3
+ *
4
+ * @example
5
+ * escapeHtml(`<b>"Tom" & 'Jerry'</b>`); // "&lt;b&gt;&quot;Tom&quot; &amp; &#39;Jerry&#39;&lt;/b&gt;"
6
+ */
2
7
  export declare function escapeHtml(text: string): string;
3
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/html/escape/index.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/html/escape/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}
@@ -1,6 +1,11 @@
1
1
  const ENTITIES = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
2
- /** Escapes text for safe use inside html (for example in email bodies). */
2
+ /**
3
+ * Escapes text for safe use inside HTML, for example user input in an email body.
4
+ *
5
+ * @example
6
+ * escapeHtml(`<b>"Tom" & 'Jerry'</b>`); // "&lt;b&gt;&quot;Tom&quot; &amp; &#39;Jerry&#39;&lt;/b&gt;"
7
+ */
3
8
  export function escapeHtml(text) {
4
- return text.replace(/[&<>"']/g, (character) => ENTITIES[character] ?? character);
9
+ return text.replace(/[&<>"']/g, (character) => ENTITIES[character]);
5
10
  }
6
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/html/escape/index.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAA2B,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAEjH,2EAA2E;AAC3E,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC;AACnF,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/html/escape/index.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAW,CAAC;AAElG;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAkC,CAAC,CAAC,CAAC;AAC/F,CAAC"}
@@ -1,3 +1,8 @@
1
- /** Keeps a value between a minimum and a maximum. */
1
+ /**
2
+ * Keeps a value between a minimum and a maximum.
3
+ *
4
+ * @example
5
+ * clamp(5, 0, 1); // 1
6
+ */
2
7
  export declare function clamp(value: number, minimum: number, maximum: number): number;
3
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/math/clamp/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/math/clamp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7E"}
@@ -1,4 +1,9 @@
1
- /** Keeps a value between a minimum and a maximum. */
1
+ /**
2
+ * Keeps a value between a minimum and a maximum.
3
+ *
4
+ * @example
5
+ * clamp(5, 0, 1); // 1
6
+ */
2
7
  export function clamp(value, minimum, maximum) {
3
8
  return Math.min(maximum, Math.max(minimum, value));
4
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/math/clamp/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,OAAe,EAAE,OAAe;IACnE,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/math/clamp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,OAAe,EAAE,OAAe;IACnE,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -1,3 +1,8 @@
1
- /** A deterministic number in [0, 1) for a seed: the same seed always gives the same value (stable renders). */
1
+ /**
2
+ * A deterministic number in [0, 1) for a seed: the same seed always gives the same value, so renders are stable.
3
+ *
4
+ * @example
5
+ * pseudoRandom(3) === pseudoRandom(3); // true
6
+ */
2
7
  export declare function pseudoRandom(seed: number): number;
3
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/math/pseudo-random/index.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/math/pseudo-random/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD"}
@@ -1,4 +1,9 @@
1
- /** A deterministic number in [0, 1) for a seed: the same seed always gives the same value (stable renders). */
1
+ /**
2
+ * A deterministic number in [0, 1) for a seed: the same seed always gives the same value, so renders are stable.
3
+ *
4
+ * @example
5
+ * pseudoRandom(3) === pseudoRandom(3); // true
6
+ */
2
7
  export function pseudoRandom(seed) {
3
8
  const value = Math.sin(seed * 12.9898) * 43758.5453;
4
9
  return value - Math.floor(value);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/math/pseudo-random/index.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,UAAU,CAAC;IACpD,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/math/pseudo-random/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,UAAU,CAAC;IACpD,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC"}
@@ -1,3 +1,8 @@
1
- /** Degrees to radians. */
1
+ /**
2
+ * Converts degrees to radians.
3
+ *
4
+ * @example
5
+ * radians(180); // Math.PI
6
+ */
2
7
  export declare function radians(degrees: number): number;
3
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/math/radians/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/math/radians/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/C"}
@@ -1,4 +1,9 @@
1
- /** Degrees to radians. */
1
+ /**
2
+ * Converts degrees to radians.
3
+ *
4
+ * @example
5
+ * radians(180); // Math.PI
6
+ */
2
7
  export function radians(degrees) {
3
8
  return (degrees * Math.PI) / 180;
4
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/math/radians/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/math/radians/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACnC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Joins the parts that are set with a separator surrounded by spaces, skipping `false`, `null`, `undefined` and empty
3
+ * strings. Brands keep their separator in one constant and pass it here.
4
+ *
5
+ * @example
6
+ * separate("•", "Contact", "Ana", undefined); // "Contact • Ana"
7
+ */
8
+ export declare function separate(separator: string, ...parts: (string | false | null | undefined)[]): string;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/text/separate/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAEnG"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Joins the parts that are set with a separator surrounded by spaces, skipping `false`, `null`, `undefined` and empty
3
+ * strings. Brands keep their separator in one constant and pass it here.
4
+ *
5
+ * @example
6
+ * separate("•", "Contact", "Ana", undefined); // "Contact • Ana"
7
+ */
8
+ export function separate(separator, ...parts) {
9
+ return parts.filter(Boolean).join(` ${separator} `);
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/text/separate/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAiB,EAAE,GAAG,KAA4C;IACzF,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Whether a value is `true` or `false`.
3
+ *
4
+ * @example
5
+ * isBoolean(false); // true
6
+ */
7
+ export declare function isBoolean(value: unknown): value is boolean;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/type-guard/is-boolean/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whether a value is `true` or `false`.
3
+ *
4
+ * @example
5
+ * isBoolean(false); // true
6
+ */
7
+ export function isBoolean(value) {
8
+ return typeof value === "boolean";
9
+ }
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/type-guard/is-boolean/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Whether a value is neither `undefined` nor `null`. Handy with `filter` to narrow arrays.
3
+ *
4
+ * @example
5
+ * [1, undefined, 2].filter(isDefined); // [1, 2] as number[]
6
+ */
7
+ export declare function isDefined<Value>(value: Value): value is NonNullable<Value>;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/type-guard/is-defined/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,WAAW,CAAC,KAAK,CAAC,CAE1E"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whether a value is neither `undefined` nor `null`. Handy with `filter` to narrow arrays.
3
+ *
4
+ * @example
5
+ * [1, undefined, 2].filter(isDefined); // [1, 2] as number[]
6
+ */
7
+ export function isDefined(value) {
8
+ return value !== undefined && value !== null;
9
+ }
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/type-guard/is-defined/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAQ,KAAY;IAC3C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Whether a value is a string with at least one character.
3
+ *
4
+ * @example
5
+ * isNonEmptyString(""); // false
6
+ */
7
+ export declare function isNonEmptyString(value: unknown): value is string;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/type-guard/is-non-empty-string/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEhE"}
@@ -0,0 +1,11 @@
1
+ import { isString } from "@sharadox/web-library/type-guard/is-string";
2
+ /**
3
+ * Whether a value is a string with at least one character.
4
+ *
5
+ * @example
6
+ * isNonEmptyString(""); // false
7
+ */
8
+ export function isNonEmptyString(value) {
9
+ return isString(value) && value.length > 0;
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/type-guard/is-non-empty-string/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether a value is a finite number (not `NaN`, not `Infinity`).
3
+ *
4
+ * @example
5
+ * isNumber(1.5); // true
6
+ * isNumber(Number.NaN); // false
7
+ */
8
+ export declare function isNumber(value: unknown): value is number;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/type-guard/is-number/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Whether a value is a finite number (not `NaN`, not `Infinity`).
3
+ *
4
+ * @example
5
+ * isNumber(1.5); // true
6
+ * isNumber(Number.NaN); // false
7
+ */
8
+ export function isNumber(value) {
9
+ return typeof value === "number" && Number.isFinite(value);
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/type-guard/is-number/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether a value is a plain object (an object literal or `Object.create(null)`), not an array, a date or `null`.
3
+ *
4
+ * @example
5
+ * isRecord({ a: 1 }); // true
6
+ * isRecord([]); // false
7
+ */
8
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/type-guard/is-record/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzE"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Whether a value is a plain object (an object literal or `Object.create(null)`), not an array, a date or `null`.
3
+ *
4
+ * @example
5
+ * isRecord({ a: 1 }); // true
6
+ * isRecord([]); // false
7
+ */
8
+ export function isRecord(value) {
9
+ if (typeof value !== "object" || value === null)
10
+ return false;
11
+ const prototype = Object.getPrototypeOf(value);
12
+ return prototype === Object.prototype || prototype === null;
13
+ }
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/type-guard/is-record/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAY,CAAC;IAC1D,OAAO,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether a value is a string.
3
+ *
4
+ * @example
5
+ * isString("a"); // true
6
+ * isString(1); // false
7
+ */
8
+ export declare function isString(value: unknown): value is string;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/type-guard/is-string/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Whether a value is a string.
3
+ *
4
+ * @example
5
+ * isString("a"); // true
6
+ * isString(1); // false
7
+ */
8
+ export function isString(value) {
9
+ return typeof value === "string";
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/type-guard/is-string/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC"}
package/llms.txt ADDED
@@ -0,0 +1,17 @@
1
+ # @sharadox/web-library
2
+
3
+ > General TypeScript utilities shared by every Sharadox library (no dependencies). Topic code moved to *-web-library topic packages (internationalization, metadata, style, consent, animation, scroll, pointer, form, time, test).
4
+
5
+ - type-guard/is-string → isString(value): value is string
6
+ - type-guard/is-non-empty-string → isNonEmptyString(value)
7
+ - type-guard/is-number → isNumber(value): finite numbers
8
+ - type-guard/is-boolean → isBoolean(value)
9
+ - type-guard/is-record → isRecord(value): plain objects
10
+ - type-guard/is-defined → isDefined(value): not null/undefined
11
+ - class-name → classNames(...names): joins truthy names
12
+ - html/escape → escapeHtml(text)
13
+ - text/separate → separate(separator, ...parts): "a • b", skipping empty parts
14
+ - math/clamp, math/radians, math/pseudo-random
15
+ - assert/never → assertNever(value): throws; for exhaustive switches
16
+ - Import by path: `import { isString } from "@sharadox/web-library/type-guard/is-string";`
17
+ - Licence: Sharadox Open Source Licence 0.1.0