@rtorcato/js-common 2.8.2 → 4.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.
Files changed (160) hide show
  1. package/AGENTS.md +114 -0
  2. package/CHANGELOG.md +23 -0
  3. package/CONTRIBUTORS.md +5 -0
  4. package/README.md +75 -26
  5. package/dist/abortController/index.d.ts +30 -0
  6. package/dist/abortController/index.d.ts.map +1 -1
  7. package/dist/arrays/arrays.test-d.js +1 -1
  8. package/dist/arrays/index.d.ts +0 -63
  9. package/dist/arrays/index.d.ts.map +1 -1
  10. package/dist/arrays/index.js +1 -1
  11. package/dist/boolean/index.d.ts +10 -33
  12. package/dist/boolean/index.d.ts.map +1 -1
  13. package/dist/boolean/index.js +1 -1
  14. package/dist/chunks/chunk-AVPQVYSA.js +1 -0
  15. package/dist/chunks/chunk-H7PB4TAW.js +1 -0
  16. package/dist/chunks/chunk-HUTZTT4Y.js +1 -0
  17. package/dist/chunks/chunk-RBXTRLWB.js +1 -0
  18. package/dist/chunks/chunk-UQBVI52L.js +1 -0
  19. package/dist/cli/catalog.js +131 -0
  20. package/dist/cli/cli.mjs +16 -109
  21. package/dist/colors/index.d.ts +23 -3
  22. package/dist/colors/index.d.ts.map +1 -1
  23. package/dist/console/index.d.ts +12 -0
  24. package/dist/console/index.d.ts.map +1 -1
  25. package/dist/crypto/index.d.ts +23 -0
  26. package/dist/crypto/index.d.ts.map +1 -1
  27. package/dist/currency/currencies.d.ts +1 -1
  28. package/dist/currency/currencies.d.ts.map +1 -1
  29. package/dist/currency/currencies.js +1 -1
  30. package/dist/currency/index.d.ts +0 -14
  31. package/dist/currency/index.d.ts.map +1 -1
  32. package/dist/currency/index.js +1 -1
  33. package/dist/date/index.d.ts +16 -0
  34. package/dist/date/index.d.ts.map +1 -1
  35. package/dist/datetime/index.d.ts +21 -9
  36. package/dist/datetime/index.d.ts.map +1 -1
  37. package/dist/datetime/index.js +1 -1
  38. package/dist/emails/index.d.ts +22 -0
  39. package/dist/emails/index.d.ts.map +1 -1
  40. package/dist/emails/index.js +1 -1
  41. package/dist/env/index.d.ts +24 -0
  42. package/dist/env/index.d.ts.map +1 -1
  43. package/dist/errors/index.d.ts +30 -2
  44. package/dist/errors/index.d.ts.map +1 -1
  45. package/dist/events/index.d.ts +25 -1
  46. package/dist/events/index.d.ts.map +1 -1
  47. package/dist/events/index.js +1 -1
  48. package/dist/fetch/index.d.ts +25 -0
  49. package/dist/fetch/index.d.ts.map +1 -1
  50. package/dist/file/index.d.ts +20 -0
  51. package/dist/file/index.d.ts.map +1 -1
  52. package/dist/functions/functions.test-d.d.ts +2 -0
  53. package/dist/functions/functions.test-d.d.ts.map +1 -0
  54. package/dist/functions/functions.test-d.js +1 -0
  55. package/dist/functions/index.d.ts +32 -2
  56. package/dist/functions/index.d.ts.map +1 -1
  57. package/dist/functions/index.js +1 -1
  58. package/dist/geometry/index.d.ts +21 -0
  59. package/dist/geometry/index.d.ts.map +1 -1
  60. package/dist/html/index.d.ts +38 -0
  61. package/dist/html/index.d.ts.map +1 -1
  62. package/dist/html/index.js +1 -1
  63. package/dist/i18n/index.d.ts +23 -7
  64. package/dist/i18n/index.d.ts.map +1 -1
  65. package/dist/i18n/index.js +1 -1
  66. package/dist/json/index.d.ts +27 -7
  67. package/dist/json/index.d.ts.map +1 -1
  68. package/dist/json/index.js +1 -1
  69. package/dist/logger/index.d.ts +16 -1
  70. package/dist/logger/index.d.ts.map +1 -1
  71. package/dist/logger/index.js +1 -1
  72. package/dist/logging/index.d.ts +19 -0
  73. package/dist/logging/index.d.ts.map +1 -1
  74. package/dist/maps/index.d.ts +21 -0
  75. package/dist/maps/index.d.ts.map +1 -1
  76. package/dist/mime-types/db.d.ts +5 -922
  77. package/dist/mime-types/db.d.ts.map +1 -1
  78. package/dist/mime-types/db.js +1 -1
  79. package/dist/mime-types/index.d.ts +20 -0
  80. package/dist/mime-types/index.d.ts.map +1 -1
  81. package/dist/mime-types/index.js +1 -1
  82. package/dist/node/index.d.ts +0 -9
  83. package/dist/node/index.d.ts.map +1 -1
  84. package/dist/node/index.js +1 -1
  85. package/dist/numbers/index.d.ts +28 -36
  86. package/dist/numbers/index.d.ts.map +1 -1
  87. package/dist/numbers/index.js +1 -1
  88. package/dist/objects/index.d.ts +23 -7
  89. package/dist/objects/index.d.ts.map +1 -1
  90. package/dist/objects/index.js +1 -1
  91. package/dist/objects/objects.test-d.js +1 -1
  92. package/dist/os/index.d.ts +18 -0
  93. package/dist/os/index.d.ts.map +1 -1
  94. package/dist/process/index.d.ts +18 -0
  95. package/dist/process/index.d.ts.map +1 -1
  96. package/dist/promises/index.d.ts +21 -26
  97. package/dist/promises/index.d.ts.map +1 -1
  98. package/dist/promises/index.js +1 -1
  99. package/dist/promises/promises.test-d.d.ts +2 -0
  100. package/dist/promises/promises.test-d.d.ts.map +1 -0
  101. package/dist/promises/promises.test-d.js +1 -0
  102. package/dist/random/index.d.ts +21 -0
  103. package/dist/random/index.d.ts.map +1 -1
  104. package/dist/regex/index.d.ts +23 -0
  105. package/dist/regex/index.d.ts.map +1 -1
  106. package/dist/security/index.d.ts +36 -4
  107. package/dist/security/index.d.ts.map +1 -1
  108. package/dist/security/index.js +1 -1
  109. package/dist/sleep/index.d.ts +20 -0
  110. package/dist/sleep/index.d.ts.map +1 -1
  111. package/dist/strings/index.d.ts +0 -75
  112. package/dist/strings/index.d.ts.map +1 -1
  113. package/dist/strings/index.js +1 -1
  114. package/dist/system/index.d.ts +18 -0
  115. package/dist/system/index.d.ts.map +1 -1
  116. package/dist/time/index.d.ts +23 -4
  117. package/dist/time/index.d.ts.map +1 -1
  118. package/dist/try/index.d.ts +52 -1
  119. package/dist/try/index.d.ts.map +1 -1
  120. package/dist/try/index.js +1 -1
  121. package/dist/try/trycatch.test-d.js +1 -1
  122. package/dist/types/index.d.ts +0 -1
  123. package/dist/url/index.d.ts +23 -0
  124. package/dist/url/index.d.ts.map +1 -1
  125. package/dist/url/index.js +1 -1
  126. package/dist/uuid/index.d.ts +5 -5
  127. package/dist/uuid/index.d.ts.map +1 -1
  128. package/dist/uuid/index.js +1 -1
  129. package/dist/validation/index.d.ts +25 -0
  130. package/dist/validation/index.d.ts.map +1 -1
  131. package/dist/validation/index.js +1 -1
  132. package/package.json +23 -37
  133. package/dist/chunks/chunk-5IA77ERW.js +0 -1
  134. package/dist/chunks/chunk-6J7HIWG6.js +0 -1
  135. package/dist/chunks/chunk-ARW46OJS.js +0 -1
  136. package/dist/chunks/chunk-W72HFHZY.js +0 -1
  137. package/dist/emails/banned/index.d.ts +0 -9
  138. package/dist/emails/banned/index.d.ts.map +0 -1
  139. package/dist/formatting/index.d.ts +0 -40
  140. package/dist/formatting/index.d.ts.map +0 -1
  141. package/dist/formatting/index.js +0 -1
  142. package/dist/interval/index.d.ts +0 -13
  143. package/dist/interval/index.d.ts.map +0 -1
  144. package/dist/interval/index.js +0 -1
  145. package/dist/logger/logger.d.ts +0 -7
  146. package/dist/logger/logger.d.ts.map +0 -1
  147. package/dist/logger/logger.js +0 -1
  148. package/dist/math/index.d.ts +0 -37
  149. package/dist/math/index.d.ts.map +0 -1
  150. package/dist/math/index.js +0 -1
  151. package/dist/sets/index.d.ts +0 -48
  152. package/dist/sets/index.d.ts.map +0 -1
  153. package/dist/sets/index.js +0 -1
  154. package/dist/try/attempt.d.ts +0 -8
  155. package/dist/try/attempt.d.ts.map +0 -1
  156. package/dist/try/attempt.js +0 -1
  157. package/dist/try/trycatch.d.ts +0 -29
  158. package/dist/try/trycatch.d.ts.map +0 -1
  159. package/dist/try/trycatch.js +0 -1
  160. /package/dist/chunks/{chunk-XAQ7VMV4.js → chunk-J4C2KNK5.js} +0 -0
package/AGENTS.md ADDED
@@ -0,0 +1,114 @@
1
+ <!-- Generated from skills/js-common/SKILL.md by scripts/sync-agents.mjs — do not edit by hand; run `pnpm sync:agents`. -->
2
+
3
+ # Using @rtorcato/js-common
4
+
5
+ `@rtorcato/js-common` is a tree-shakeable, ESM-only utility library for Node.js >= 22 (TypeScript-first, JSDoc on every public API). One subpath export per concern — 44 of them. The package root is intentionally empty.
6
+
7
+ ## Rules
8
+
9
+ 1. **Import from the subpath, never the package root.** The root export has no runtime code at all, so a root import gets you nothing.
10
+
11
+ ```ts
12
+ // ✅ do
13
+ import { slugify } from '@rtorcato/js-common/strings'
14
+ // ❌ don't — the root export is empty by design
15
+ import { slugify } from '@rtorcato/js-common'
16
+ ```
17
+
18
+ 2. **Every export name has exactly one home.** No name is exported from two modules, so the module → exports table below is the only lookup you need. These pairs still read alike — check which one you want:
19
+
20
+ | Looks like | Actually |
21
+ |---|---|
22
+ | `functions.once` vs `events.onceEvent` | `once(fn)` memoises a call; `onceEvent(target, type)` awaits a DOM event |
23
+ | `logger` vs `logging` | `logger` is one configured pino instance; `logging` is `console` helpers with no runtime deps |
24
+ | `try.tryCatch` vs `errors.tryWithFallback` | Result object vs swallow-and-fall-back — see rule 3 |
25
+ | `date.formatDate` vs `datetime.formatDateTimeLocal` | a UTC calendar day vs a local instant |
26
+
27
+ Where two modules used to ship the same name, the loser was deleted rather than aliased — [MODULE-BOUNDARIES.md](https://github.com/rtorcato/js-common/blob/main/MODULE-BOUNDARIES.md) records which side won and why.
28
+
29
+ 3. **Three different error idioms — don't mix them up.**
30
+
31
+ ```ts
32
+ // Result object — preferred for new code
33
+ import { tryCatch } from '@rtorcato/js-common/try'
34
+ const { data, error } = await tryCatch(() => fetchData())
35
+
36
+ // Go-style tuple: [error, data] — error FIRST
37
+ import { to } from '@rtorcato/js-common/promises'
38
+ const [err, value] = await to(fetchData())
39
+
40
+ // Swallows the error and returns a fallback — only when the fallback is genuinely safe
41
+ import { tryWithFallback } from '@rtorcato/js-common/errors'
42
+ const rows = await tryWithFallback(() => fetchRows(), [])
43
+ ```
44
+
45
+ `tryCatch` in `errors` was renamed to `tryWithFallback` in 2.0; `tryCatch` now means the Result helper in `try`.
46
+
47
+ 4. **Node-only modules.** `crypto`, `security`, and `file` import `node:crypto` / `node:fs`; `logger` uses pino. Don't ship these to a browser bundle. `events` is the opposite — it wraps DOM `EventTarget` and is browser-only. `os`, `process`, `node`, and `system` probe for `process` / `window` and degrade rather than throw.
48
+
49
+ 5. **`./types` is types-only.** It has a `types` field and no `import` field on purpose — use it for `import type { Prettify, Merge } from '@rtorcato/js-common/types'` only.
50
+
51
+ 6. **Some helpers need a peer input you must supply.** `convertCurrency(amount, rate)` takes the rate — the library does no FX lookup. `checkEnv(schema)` needs a Zod object schema and throws with the list of missing keys.
52
+
53
+ ## Module → exports
54
+
55
+ Import from `@rtorcato/js-common/<module>`.
56
+
57
+ | Module | Exports |
58
+ |---|---|
59
+ | abortController | createAbortController, abortPromise, withAbort, abortAfter |
60
+ | arrays | unique, chunk, compact, shuffle |
61
+ | boolean | toBoolean |
62
+ | colors | randomColor, matchingTextColor, hexToRgb, rgbToHex, isValidHex, darken, lighten |
63
+ | console | disableConsole, clearConsole |
64
+ | crypto | hashString, randomHex, hmacHash, base64Encode, base64Decode |
65
+ | currency | getCurrencySymbol, getCurrencyName, getCurrencyLocale, formatPrice, formatPriceCompact, parsePrice, parseCurrencyString, convertCurrency, isValidCurrencyCode, isValidCurrency |
66
+ | date | today, parseDate, formatDate, daysBetween, diffInHours, diffInMinutes, isLeapYear, addDays, subDays, addMonths, getDayOfWeek, startOfDay, endOfDay, isWeekend, isSameDay, isToday, formatRelative |
67
+ | datetime | nowIso, parseIsoDateTime, formatDateTimeLocal, getTimezoneOffset, toUtcDate, unixTimestamp, unixMillis, getIsoWeek, getIsoWeekInfo |
68
+ | emails | isValidEmail, normalizeEmail, maskEmail, getEmailDomain, isFreeEmailProvider |
69
+ | env | getENV, isDev, isProd, isTest, getNodeEnv, checkEnv, RootApiEnvSchema |
70
+ | errors | createCustomError, isErrorName, getErrorMessage, assert, tryWithFallback |
71
+ | events | on, emit, onceEvent, preventDefault, stopPropagation |
72
+ | fetch | fetchWithTimeout, postJson, getJson, fetchText, handleApiError |
73
+ | file | readFileAsString, writeFileAsString, fileExists, deleteFile, getFileExtension |
74
+ | functions | once, debounce, throttle, compose, pipe |
75
+ | geometry | distance2D, midpoint2D, angle2D, pointInRect, rectsOverlap, polygonArea |
76
+ | html | escapeHtml, unescapeHtml, stripHtmlTags, textToHtml, containsHtml |
77
+ | i18n | detectLanguage, formatNumber, formatDateI18n, t |
78
+ | json | safeJsonParse, safeJsonStringify, isValidJson |
79
+ | logger | logger (pino instance — pretty in dev, JSON in prod) |
80
+ | logging | logWithTimestamp, info, warn, error, captureConsole, ConsoleLevel |
81
+ | maps | invertMap, mapValues, mergeMaps, objectToMap, mapToObject |
82
+ | mime-types | lookup, types, extensions, mimeTypes |
83
+ | node | nodeVersionCheck, getNodeMajorVersion, isNode, requireOptional |
84
+ | numbers | clamp, roundTo, formatPercent, between, sum, average, mod |
85
+ | objects | isPlainObject, deepMerge, omit, pick |
86
+ | os | getOsPlatform, getOsRelease, getOsArch, getHomeDir, getTmpDir |
87
+ | process | getProcessId, getProcessUptime, getCwd, getProcessPlatform, exitProcess, isCI |
88
+ | promises | to, withTimeout |
89
+ | random | randomInt, randomFloat, randomBool, randomElement, randomString |
90
+ | regex | escapeRegExp, testRegex, matchAll, replaceAllRegex, splitByRegex |
91
+ | security | stripScriptish, isStrongPassword, generateSecureToken |
92
+ | sleep | sleep, sleepSync, sleepRandom, sleepWithAbort |
93
+ | strings | titleCase, capitalize, camelCase, kebabCase, snakeCase, truncate, reverse, slugify, words, wordCount, pluralize, ordinalize, isBlank, mask, template |
94
+ | system | isMacOs, isWindows, isLinux, isIOS, isAndroid, getPlatform, isTouchDevice |
95
+ | time | nowTime, nowTimeShort, parseTime, formatTime, secondsBetween, pad2 |
96
+ | try | tryCatch, isSuccess, Result, Success, Failure |
97
+ | types | Prettify, Merge (types only) |
98
+ | url | isValidUrl, getQueryParams, setQueryParam, removeQueryParam, joinUrl, getHostname |
99
+ | uuid | getUUIDv7, getShortUUID, toShortUUID, fromShortUUID, isUUID, isUUIDv4, isNilUUID, getUUIDVersion, getNilUUID, uuidToBytes, bytesToUUID |
100
+ | validation | isDefined, isString, isNumber, isBoolean, isArray, isObject, isEmail, isUrl |
101
+
102
+ ## CLI
103
+
104
+ The package also ships a binary for shell use:
105
+
106
+ ```bash
107
+ npx @rtorcato/js-common@latest date today
108
+ npx @rtorcato/js-common@latest math sum 1 2 3
109
+ npx @rtorcato/js-common@latest text capitalize "hello world"
110
+ ```
111
+
112
+ See [CLI.md](https://github.com/rtorcato/js-common/blob/main/CLI.md) for the full command list.
113
+
114
+ For full signatures and examples, see <https://rtorcato.github.io/js-common/>.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ # Changelog — frozen at 2.8.2
2
+
3
+ **This file stops at 2.8.2 and will not be updated again. It is not the place to
4
+ look for what shipped.**
5
+
6
+ [**GitHub Releases**](https://github.com/rtorcato/js-common/releases) is the
7
+ canonical record, and the [changelog page on the docs
8
+ site](https://rtorcato.github.io/js-common/docs/changelog) is built from it.
9
+
10
+ Why: `@semantic-release/git` is dropped from this repo's plugin list because the
11
+ `code-scanning-main` ruleset rejects the release commit with `GH013` — a commit
12
+ created seconds earlier can never have CodeQL results (see
13
+ [#153](https://github.com/rtorcato/js-common/issues/153) and
14
+ [#211](https://github.com/rtorcato/js-common/issues/211)). Nothing commits this
15
+ file back to `main`, so it holds whatever the last release with that plugin
16
+ wrote. The same applies to the `version` field in `package.json`.
17
+
18
+ Kept in the repo rather than deleted because GitHub Releases only go back to
19
+ v1.2.0 — the hand-written `1.0.0` section at the bottom is the only record of
20
+ that release, which is also why this file carries two formats.
21
+
22
+ ---
23
+
1
24
  ## [2.8.2](https://github.com/rtorcato/js-common/compare/v2.8.1...v2.8.2) (2026-07-23)
2
25
 
3
26
 
package/CONTRIBUTORS.md CHANGED
@@ -31,6 +31,11 @@ We welcome contributions from everyone! Here's how you can help:
31
31
  8. Push to your branch (`git push origin feature/amazing-feature`)
32
32
  9. Open a Pull Request
33
33
 
34
+ Adding a helper? Check [MODULE-BOUNDARIES.md](MODULE-BOUNDARIES.md) first. It
35
+ records which module owns what, and the rule that no name is exported from two
36
+ modules — module paths are frozen, so a helper in the wrong place is expensive
37
+ to move later.
38
+
34
39
  ### 📝 Documentation
35
40
  - Improve README.md, code comments, or JSDoc
36
41
  - Add examples for existing functions
package/README.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # js-common
2
2
 
3
- ![js-common banner](./banner.png)
4
-
3
+ <p align="center">
4
+ <picture>
5
+ <source media="(max-width: 600px)" srcset="./brand/banner-mobile.png">
6
+ <img src="./brand/banner.png" alt="js-common — Tree-shakeable TypeScript utilities: tiny bundles, full type safety, CLI included." width="100%">
7
+ </picture>
8
+ </p>
9
+
10
+ [![CI](https://github.com/rtorcato/js-common/actions/workflows/ci.yml/badge.svg)](https://github.com/rtorcato/js-common/actions/workflows/ci.yml)
5
11
  [![npm version](https://badge.fury.io/js/%40rtorcato%2Fjs-common.svg)](https://badge.fury.io/js/%40rtorcato%2Fjs-common)
12
+ [![npm downloads](https://img.shields.io/npm/dm/@rtorcato/js-common.svg)](https://www.npmjs.com/package/@rtorcato/js-common)
13
+ [![Bundle size](https://img.shields.io/bundlephobia/minzip/@rtorcato/js-common)](https://bundlephobia.com/package/@rtorcato/js-common)
6
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
15
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
8
16
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22.0.0-brightgreen.svg)](https://nodejs.org/)
@@ -18,8 +26,8 @@ A comprehensive set of common JavaScript and TypeScript utilities for Node.js pr
18
26
  - **Tree-shakeable** — import only what you need via subpath exports
19
27
  - **TypeScript** — full type definitions, JSDoc on every public API
20
28
  - **CLI included** — optional binary for use in scripts and terminals
21
- - **Modular** — one module per concern, 46 subpaths
22
- - **Minimal runtime deps** — only `date-fns`, `date-fns-tz`, `luxon`, `pino`, `uuid`, `short-uuid`, `zod`. CLI packages (`chalk`, `commander`, `figlet`, …) are `optionalDependencies` and only needed for the CLI.
29
+ - **Modular** — one module per concern, 42 subpaths
30
+ - **Minimal runtime deps** — only `pino`, `uuid`, `short-uuid`, `zod`. CLI packages (`chalk`, `commander`, `figlet`, …) are `optionalDependencies` and only needed for the CLI.
23
31
 
24
32
  ## Installation
25
33
 
@@ -27,11 +35,43 @@ A comprehensive set of common JavaScript and TypeScript utilities for Node.js pr
27
35
  npm install @rtorcato/js-common
28
36
  ```
29
37
 
30
- ## Migrating from 1.x to 2.x
38
+ Pre-release builds are published to the `beta` dist-tag, so they never reach a plain `npm install`:
39
+
40
+ ```bash
41
+ npm install @rtorcato/js-common@beta
42
+ ```
43
+
44
+ ## Use with AI
45
+
46
+ An agent skill lives in [`skills/js-common`](./skills/js-common/SKILL.md) — it teaches an AI coding agent the subpath-import rules, which same-named helper belongs to which module, the three error idioms, which modules are Node-only, and the full module → exports map.
47
+
48
+ **Claude Code** — this repo is its own plugin marketplace:
49
+
50
+ ```
51
+ /plugin marketplace add rtorcato/js-common
52
+ /plugin install js-common@js-common
53
+ ```
54
+
55
+ **Cursor, Copilot, Codex and other tools** — read [`AGENTS.md`](./AGENTS.md), the cross-tool convention file. It carries the same guidance and also ships in the npm tarball, so tools that scan `node_modules` find it at `node_modules/@rtorcato/js-common/AGENTS.md`.
56
+
57
+ **Any tool the [`skills`](https://www.npmjs.com/package/skills) CLI supports:**
58
+
59
+ ```bash
60
+ npx skills add https://github.com/rtorcato/js-common --skill js-common
61
+ ```
62
+
63
+ `AGENTS.md` is generated from `SKILL.md` by `pnpm sync:agents`; CI fails if they drift. Edit `SKILL.md`, never `AGENTS.md`.
64
+
65
+ ## Migrating
66
+
67
+ **3.x → 4.x** — everything the runtime already does was removed. `./sets` and `./interval` are gone as modules, and the pass-through wrappers inside surviving modules went with them: `promises.all`/`allSettled`/`race`/`delay`, `boolean.and`/`or`/`not`/`xor`, `strings.padStart`/`padEnd`/`replaceString`, `arrays.first`/`last`/`flatten`/`groupBy`, `numbers.isInteger`/`isFiniteNumber`/`min`/`max`, `objects.deepClone`, `json.deepCloneJson` and `uuid.getUUID`. Nothing moved to another module — the replacement is a JavaScript built-in in every case, which the Node 22 floor guarantees. Two are **not** drop-ins: `Object.groupBy` returns a null-prototype object with optional values, and `structuredClone` keeps `Date`s where the JSON round trip flattened them. The full before/after table is in the [migration guide](https://rtorcato.github.io/js-common/docs/guides/migration).
31
68
 
32
- The only breaking change in 2.0 is a rename in the `errors` module:
69
+ **2.x → 3.x** — every helper now has exactly one home. `./formatting` and `./math` are gone, and where two modules shipped the same name the loser was deleted rather than aliased, so you get a build error naming the fix. One helper was also renamed rather than moved: `sanitizeString` is now `stripScriptish`, because the old name promised sanitising it never did — it removes `<script>` blocks and inline `on*` handlers and nothing else. The full before/after map is in the [migration guide](https://rtorcato.github.io/js-common/docs/guides/migration); the reasoning is in [MODULE-BOUNDARIES.md](MODULE-BOUNDARIES.md).
70
+
71
+ **1.x → 2.x** — the only breaking change in 2.0 is a rename in the `errors` module:
33
72
 
34
73
  ```ts
74
+ // boundary-check: ignore — quotes the pre-2.0 API on purpose
35
75
  // 1.x — swallow errors and fall back to a default value
36
76
  import { tryCatch } from '@rtorcato/js-common/errors'
37
77
  const data = await tryCatch(() => fetchData(), [])
@@ -76,16 +116,16 @@ See [CLI.md](./CLI.md) for complete CLI documentation.
76
116
  ```typescript
77
117
  // Import specific modules (recommended for tree-shaking)
78
118
  import { formatDate, today, daysBetween } from '@rtorcato/js-common/date'
79
- import { validateEmail, isValidEmail } from '@rtorcato/js-common/emails'
80
- import { generateUUID, isValidUUID } from '@rtorcato/js-common/uuid'
119
+ import { isValidEmail, normalizeEmail } from '@rtorcato/js-common/emails'
120
+ import { getUUIDv7, isUUID } from '@rtorcato/js-common/uuid'
81
121
  import { sum, average, roundTo } from '@rtorcato/js-common/numbers'
82
- import { capitalize, toTitleCase } from '@rtorcato/js-common/formatting'
122
+ import { capitalize, titleCase } from '@rtorcato/js-common/strings'
83
123
 
84
124
  // Example usage
85
125
  console.log(today()) // "2026-05-29"
86
126
  console.log(sum([1, 2, 3, 4, 5])) // 15
87
127
  console.log(capitalize('hello world')) // "Hello world"
88
- console.log(generateUUID()) // "f47ac10b-58cc-4372-a567-0e02b2c3d479"
128
+ console.log(getUUIDv7()) // "018e5e2c-7c0a-7000-8000-0e02b2c3d479"
89
129
  ```
90
130
 
91
131
  ### Bundle Size Impact
@@ -94,51 +134,51 @@ Each module is shipped as its own subpath export so bundlers only include what y
94
134
 
95
135
  ## Available Modules
96
136
 
137
+ Which module a helper belongs to — and why no helper is exported from two of
138
+ them — is recorded in [MODULE-BOUNDARIES.md](MODULE-BOUNDARIES.md). These paths
139
+ are frozen as of that record.
140
+
97
141
  ### Date & Time
98
142
  ```typescript
99
143
  import { today, formatDate, daysBetween, isLeapYear } from '@rtorcato/js-common/date'
100
144
  import { nowIso, formatDateTimeLocal, unixTimestamp } from '@rtorcato/js-common/datetime'
101
145
  import { nowTime, parseTime, secondsBetween } from '@rtorcato/js-common/time'
102
- import { runInterval, clearIntervalById } from '@rtorcato/js-common/interval'
103
146
  ```
104
147
 
105
- ### Numbers & Math
148
+ ### Numbers
106
149
  ```typescript
107
- import { sum, average, roundTo, clamp, getRandomInt } from '@rtorcato/js-common/numbers'
108
- import { add, subtract, multiply, divide } from '@rtorcato/js-common/math'
150
+ import { sum, average, roundTo, clamp, formatPercent } from '@rtorcato/js-common/numbers'
109
151
  import { randomInt, randomFloat, randomBool, randomElement } from '@rtorcato/js-common/random'
110
152
  ```
111
153
 
112
154
  ### Text & Strings
113
155
  ```typescript
114
- import { capitalize, toTitleCase, padZero } from '@rtorcato/js-common/formatting'
115
- import { slugify, truncate, removeEmojis } from '@rtorcato/js-common/strings'
156
+ import { slugify, truncate, capitalize, titleCase, pluralize } from '@rtorcato/js-common/strings'
116
157
  import { escapeHtml, unescapeHtml, stripHtmlTags } from '@rtorcato/js-common/html'
117
158
  import { escapeRegExp, matchAll, replaceAllRegex } from '@rtorcato/js-common/regex'
118
- import { detectLanguage, formatNumber, t, pluralize } from '@rtorcato/js-common/i18n'
159
+ import { detectLanguage, formatNumber, formatDateI18n, t } from '@rtorcato/js-common/i18n'
119
160
  ```
120
161
 
121
162
  ### Security & Validation
122
163
  ```typescript
123
164
  import { isStrongPassword, generateSecureToken } from '@rtorcato/js-common/security'
124
- import { isValidEmail, validateEmail } from '@rtorcato/js-common/emails'
165
+ import { isValidEmail, maskEmail } from '@rtorcato/js-common/emails'
125
166
  import { isValidUrl } from '@rtorcato/js-common/url'
126
- import { isString, isNumber, isArray, isObject } from '@rtorcato/js-common/validation'
127
- import { toBoolean, isBoolean, xor } from '@rtorcato/js-common/boolean'
167
+ import { isString, isNumber, isBoolean, isArray, isObject } from '@rtorcato/js-common/validation'
168
+ import { toBoolean } from '@rtorcato/js-common/boolean'
128
169
  ```
129
170
 
130
171
  ### Data Structures
131
172
  ```typescript
132
- import { flatten, unique, chunk, groupBy } from '@rtorcato/js-common/arrays'
133
- import { deepMerge, pick, omit, deepClone } from '@rtorcato/js-common/objects'
173
+ import { unique, chunk, compact, shuffle } from '@rtorcato/js-common/arrays'
174
+ import { deepMerge, pick, omit, isPlainObject } from '@rtorcato/js-common/objects'
134
175
  import { safeJsonParse, safeJsonStringify } from '@rtorcato/js-common/json'
135
176
  import { invertMap, mapValues, objectToMap, mapToObject } from '@rtorcato/js-common/maps'
136
- import { union, intersection, difference, isSubset } from '@rtorcato/js-common/sets'
137
177
  ```
138
178
 
139
179
  ### Async & Control Flow
140
180
  ```typescript
141
- import { delay, timeout, retry } from '@rtorcato/js-common/promises'
181
+ import { to, withTimeout } from '@rtorcato/js-common/promises'
142
182
  import { debounce, throttle, once } from '@rtorcato/js-common/functions'
143
183
  import { sleep } from '@rtorcato/js-common/sleep'
144
184
  import { tryCatch } from '@rtorcato/js-common/try'
@@ -166,7 +206,7 @@ import { info, warn, error, captureConsole } from '@rtorcato/js-common/logging'
166
206
  - `colors` — color manipulation and conversion
167
207
  - `crypto` — cryptographic helpers
168
208
  - `currency` — currency formatting and conversion
169
- - `events` — event emitter utilities
209
+ - `events` — DOM event helpers (`on`, `emit`, `onceEvent`)
170
210
  - `fetch` — HTTP request helpers
171
211
  - `file` — file system helpers
172
212
  - `geometry` — 2D geometry calculations
@@ -212,7 +252,7 @@ pnpm run benchmark
212
252
  The full documentation site lives in [`apps/docs`](./apps/docs) and is built with [Docusaurus](https://docusaurus.io/). It auto-deploys to GitHub Pages on every push to `main` that touches `apps/docs/**`.
213
253
 
214
254
  ```bash
215
- # Run the docs locally (http://localhost:4321/js-common)
255
+ # Run the docs locally (http://localhost:3000/js-common/)
216
256
  pnpm --filter @rtorcato/js-common-docs dev
217
257
 
218
258
  # Build the static site
@@ -221,6 +261,10 @@ pnpm --filter @rtorcato/js-common-docs build
221
261
 
222
262
  Live site: <https://rtorcato.github.io/js-common/>
223
263
 
264
+ ## Roadmap
265
+
266
+ Direction and progress are tracked entirely on GitHub — see the [milestones](https://github.com/rtorcato/js-common/milestones) for the stages (shipped 2.x modules, the beta npm preview, the v1.0 stable API) and the [open issues](https://github.com/rtorcato/js-common/issues) for day-to-day work.
267
+
224
268
  ## Contributing
225
269
 
226
270
  Contributions are welcome! Please read [CONTRIBUTORS.md](./CONTRIBUTORS.md) for guidelines.
@@ -231,6 +275,11 @@ Contributions are welcome! Please read [CONTRIBUTORS.md](./CONTRIBUTORS.md) for
231
275
  4. Run the test suite: `pnpm test`
232
276
  5. Submit a pull request
233
277
 
278
+ ## Related packages
279
+
280
+ - [@rtorcato/browser-common](https://github.com/rtorcato/browser-common) — Browser Web API wrappers (clipboard, observers, storage, etc.)
281
+ - [@rtorcato/repo-tooling](https://github.com/rtorcato/repo-tooling) — Project scaffolding for TypeScript libraries (Biome, Vitest, Husky, semantic-release)
282
+
234
283
  ## License
235
284
 
236
285
  MIT © [Richard Torcato](https://github.com/rtorcato)
@@ -1,5 +1,14 @@
1
1
  /**
2
2
  * Creates a new AbortController and returns its controller and signal.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const { controller, signal } = createAbortController()
7
+ * signal.aborted // false
8
+ * controller.abort()
9
+ * signal.aborted // true
10
+ * ```
11
+ *
3
12
  * @returns {{ controller: AbortController, signal: AbortSignal }}
4
13
  */
5
14
  export declare function createAbortController(): {
@@ -8,12 +17,33 @@ export declare function createAbortController(): {
8
17
  };
9
18
  /**
10
19
  * Returns a promise that rejects when the given AbortSignal is aborted.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const { controller, signal } = createAbortController()
24
+ * const pending = abortPromise(signal)
25
+ * controller.abort()
26
+ * await pending.catch((err) => err.name) // 'AbortError'
27
+ * ```
28
+ *
11
29
  * @param signal The AbortSignal to listen to.
12
30
  * @returns {Promise<never>}
13
31
  */
14
32
  export declare function abortPromise(signal: AbortSignal): Promise<never>;
15
33
  /**
16
34
  * Wraps a promise and rejects it if the signal is aborted.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const { controller, signal } = createAbortController()
39
+ * const slow = new Promise<string>((resolve) => setTimeout(() => resolve('done'), 50))
40
+ *
41
+ * await withAbort(slow, signal) // 'done'
42
+ *
43
+ * controller.abort()
44
+ * await withAbort(slow, signal).catch((err) => err.name) // 'AbortError'
45
+ * ```
46
+ *
17
47
  * @param promise The promise to wrap.
18
48
  * @param signal The AbortSignal.
19
49
  * @returns {Promise<T>}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abortController/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,qBAAqB;;;EAGpC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAchE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAEjG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abortController/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB;;;EAGpC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAchE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAEjG"}
@@ -1 +1 @@
1
- import{a as n,b as a,c as t,e as u,h as s}from"../chunks/chunk-5IA77ERW.js";import"../chunks/chunk-ANN5UYCF.js";import{describe as o,expectTypeOf as e,it as r}from"vitest";o("arrays \u2014 types",()=>{r("first/last preserve element type and add undefined",()=>{e(n([1,2,3])).toEqualTypeOf(),e(n(["a","b"])).toEqualTypeOf(),e(a([{id:1}])).toEqualTypeOf()}),r("unique preserves element type",()=>{e(t([1,2,3])).toEqualTypeOf(),e(t(["a"])).toEqualTypeOf()}),r("chunk returns array of arrays of the element type",()=>{e(u([1,2,3],2)).toEqualTypeOf(),e(u(["a","b"],1)).toEqualTypeOf()}),r("groupBy preserves element type in the grouped arrays",()=>{let i=s([{kind:"a",n:1}],p=>p.kind);e(i).toEqualTypeOf()})});
1
+ import{a as r,b as t}from"../chunks/chunk-UQBVI52L.js";import"../chunks/chunk-ANN5UYCF.js";import{describe as a,expectTypeOf as e,it as u}from"vitest";a("arrays \u2014 types",()=>{u("unique preserves element type",()=>{e(r([1,2,3])).toEqualTypeOf(),e(r(["a"])).toEqualTypeOf()}),u("chunk returns array of arrays of the element type",()=>{e(t([1,2,3],2)).toEqualTypeOf(),e(t(["a","b"],1)).toEqualTypeOf()})});
@@ -1,33 +1,3 @@
1
- /**
2
- * Returns the first element of an array, or undefined if the array is empty.
3
- *
4
- * @example
5
- * ```typescript
6
- * first([1, 2, 3]) // 1
7
- * first([]) // undefined
8
- * first(['a', 'b']) // 'a'
9
- * ```
10
- *
11
- * @param arr The array to get the first element from
12
- * @returns The first element or undefined if array is empty
13
- * @category Array Utilities
14
- */
15
- export declare function first<T>(arr: T[]): T | undefined;
16
- /**
17
- * Returns the last element of an array, or undefined if the array is empty.
18
- *
19
- * @example
20
- * ```typescript
21
- * last([1, 2, 3]) // 3
22
- * last([]) // undefined
23
- * last(['a', 'b']) // 'b'
24
- * ```
25
- *
26
- * @param arr The array to get the last element from
27
- * @returns The last element or undefined if array is empty
28
- * @category Array Utilities
29
- */
30
- export declare function last<T>(arr: T[]): T | undefined;
31
1
  /**
32
2
  * Removes duplicate values from an array while preserving order.
33
3
  * Uses Set for O(n) performance with primitive values.
@@ -44,21 +14,6 @@ export declare function last<T>(arr: T[]): T | undefined;
44
14
  * @category Array Utilities
45
15
  */
46
16
  export declare function unique<T>(arr: T[]): T[];
47
- /**
48
- * Flattens an array one level deep.
49
- *
50
- * @example
51
- * ```typescript
52
- * flatten([[1, 2], [3, 4]]) // [1, 2, 3, 4]
53
- * flatten([1, [2, 3], 4]) // [1, 2, 3, 4]
54
- * flatten([[1, [2]], [3]]) // [1, [2], 3] (only one level deep)
55
- * ```
56
- *
57
- * @param arr The array to flatten
58
- * @returns A new flattened array
59
- * @category Array Utilities
60
- */
61
- export declare function flatten<T>(arr: readonly (T | T[])[]): T[];
62
17
  /**
63
18
  * Chunks an array into smaller arrays of a specified size.
64
19
  * The last chunk may be smaller if the array length is not evenly divisible.
@@ -113,22 +68,4 @@ export declare function compact<T>(arr: T[]): T[];
113
68
  * @category Array Utilities
114
69
  */
115
70
  export declare function shuffle<T>(arr: T[]): T[];
116
- /**
117
- * Groups array elements by a key derived from each element.
118
- *
119
- * @example
120
- * ```typescript
121
- * groupBy([1, 2, 3, 4], n => n % 2 === 0 ? 'even' : 'odd')
122
- * // { odd: [1, 3], even: [2, 4] }
123
- *
124
- * groupBy([{ type: 'a' }, { type: 'b' }, { type: 'a' }], x => x.type)
125
- * // { a: [{ type: 'a' }, { type: 'a' }], b: [{ type: 'b' }] }
126
- * ```
127
- *
128
- * @param arr The array to group
129
- * @param fn Function that returns the group key for each element
130
- * @returns An object mapping keys to arrays of elements
131
- * @category Array Utilities
132
- */
133
- export declare function groupBy<T>(arr: T[], fn: (item: T) => string | number): Record<string | number, T[]>;
134
71
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/arrays/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAEhD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAE/C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEzD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAOtD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAExC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAOxC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACxB,GAAG,EAAE,CAAC,EAAE,EACR,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAC9B,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,CAO9B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/arrays/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAOtD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAExC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAOxC"}
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"../chunks/chunk-5IA77ERW.js";import"../chunks/chunk-ANN5UYCF.js";export{e as chunk,f as compact,a as first,d as flatten,h as groupBy,b as last,g as shuffle,c as unique};
1
+ import{a,b,c,d}from"../chunks/chunk-UQBVI52L.js";import"../chunks/chunk-ANN5UYCF.js";export{b as chunk,c as compact,d as shuffle,a as unique};
@@ -1,41 +1,18 @@
1
1
  /**
2
2
  * Converts a value to a boolean.
3
3
  * Accepts 'true', '1', 1 as true; 'false', '0', 0 as false.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * toBoolean('true') // true
8
+ * toBoolean('0') // false
9
+ * toBoolean(1) // true
10
+ * toBoolean(2) // false
11
+ * toBoolean(null) // false
12
+ * ```
13
+ *
4
14
  * @param value The value to convert.
5
15
  * @returns The boolean representation.
6
16
  */
7
17
  export declare function toBoolean(value: unknown): boolean;
8
- /**
9
- * Checks if a value is a boolean.
10
- * @param value The value to check.
11
- * @returns True if the value is a boolean, false otherwise.
12
- */
13
- export declare function isBoolean(value: unknown): value is boolean;
14
- /**
15
- * Returns the logical exclusive OR (XOR) of two booleans.
16
- * @param a First boolean.
17
- * @param b Second boolean.
18
- * @returns True if exactly one of a or b is true.
19
- */
20
- export declare function xor(a: boolean, b: boolean): boolean;
21
- /**
22
- * Logical AND for two booleans.
23
- * @param a First boolean.
24
- * @param b Second boolean.
25
- * @returns True if both a and b are true.
26
- */
27
- export declare function and(a: boolean, b: boolean): boolean;
28
- /**
29
- * Logical OR for two booleans.
30
- * @param a First boolean.
31
- * @param b Second boolean.
32
- * @returns True if either a or b is true.
33
- */
34
- export declare function or(a: boolean, b: boolean): boolean;
35
- /**
36
- * Logical NOT for a boolean.
37
- * @param a The boolean to negate.
38
- * @returns The negated boolean.
39
- */
40
- export declare function not(a: boolean): boolean;
41
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/boolean/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAWjD;AAED;;;;GAIG;AAEH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAElD;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEvC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/boolean/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAWjD"}
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function e(o){if(typeof o=="boolean")return o;if(typeof o=="string"){let n=o.trim().toLowerCase();if(n==="true"||n==="1")return!0;if(n==="false"||n==="0")return!1}return typeof o=="number"?o===1:!!o}function r(o){return typeof o=="boolean"}function t(o,n){return!!(o?!n:n)}function a(o,n){return o&&n}function f(o,n){return o||n}function u(o){return!o}export{a as and,r as isBoolean,u as not,f as or,e as toBoolean,t as xor};
1
+ import"../chunks/chunk-ANN5UYCF.js";function r(o){if(typeof o=="boolean")return o;if(typeof o=="string"){let n=o.trim().toLowerCase();if(n==="true"||n==="1")return!0;if(n==="false"||n==="0")return!1}return typeof o=="number"?o===1:!!o}export{r as toBoolean};
@@ -0,0 +1 @@
1
+ async function i(r){try{return[null,await r]}catch(e){return[e,void 0]}}function u(r,e,n=new Error("Timeout")){return Promise.race([r,new Promise((o,t)=>setTimeout(()=>t(n),e))])}export{i as a,u as b};