@rtorcato/js-common 3.0.0 → 5.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 (107) hide show
  1. package/AGENTS.md +21 -23
  2. package/README.md +31 -20
  3. package/dist/abortController/index.d.ts +3 -2
  4. package/dist/abortController/index.d.ts.map +1 -1
  5. package/dist/abortController/index.js +1 -1
  6. package/dist/arrays/arrays.test-d.js +1 -1
  7. package/dist/arrays/index.d.ts +43 -54
  8. package/dist/arrays/index.d.ts.map +1 -1
  9. package/dist/arrays/index.js +1 -1
  10. package/dist/boolean/index.d.ts +0 -35
  11. package/dist/boolean/index.d.ts.map +1 -1
  12. package/dist/boolean/index.js +1 -1
  13. package/dist/chunks/chunk-6FGK7LS2.js +1 -0
  14. package/dist/chunks/chunk-H7PB4TAW.js +1 -0
  15. package/dist/chunks/chunk-HUTZTT4Y.js +1 -0
  16. package/dist/chunks/chunk-NEODDZIS.js +1 -0
  17. package/dist/chunks/chunk-U2F5TMN2.js +1 -0
  18. package/dist/chunks/chunk-VSTXGIC3.js +1 -0
  19. package/dist/crypto/index.d.ts +15 -10
  20. package/dist/crypto/index.d.ts.map +1 -1
  21. package/dist/crypto/index.js +1 -1
  22. package/dist/currency/currencies.d.ts +1 -1
  23. package/dist/currency/currencies.d.ts.map +1 -1
  24. package/dist/currency/currencies.js +1 -1
  25. package/dist/date/index.d.ts +22 -2
  26. package/dist/date/index.d.ts.map +1 -1
  27. package/dist/date/index.js +1 -1
  28. package/dist/env/index.js +3 -1
  29. package/dist/fetch/index.d.ts +6 -3
  30. package/dist/fetch/index.d.ts.map +1 -1
  31. package/dist/fetch/index.js +1 -1
  32. package/dist/json/index.d.ts +0 -7
  33. package/dist/json/index.d.ts.map +1 -1
  34. package/dist/json/index.js +1 -1
  35. package/dist/logger/index.d.ts +16 -1
  36. package/dist/logger/index.d.ts.map +1 -1
  37. package/dist/logger/index.js +1 -1
  38. package/dist/mime-types/db.d.ts +5 -922
  39. package/dist/mime-types/db.d.ts.map +1 -1
  40. package/dist/mime-types/db.js +1 -1
  41. package/dist/mime-types/index.js +1 -1
  42. package/dist/numbers/index.d.ts +88 -19
  43. package/dist/numbers/index.d.ts.map +1 -1
  44. package/dist/numbers/index.js +1 -1
  45. package/dist/objects/index.d.ts +0 -7
  46. package/dist/objects/index.d.ts.map +1 -1
  47. package/dist/objects/index.js +1 -1
  48. package/dist/objects/objects.test-d.js +1 -1
  49. package/dist/os/index.d.ts +0 -11
  50. package/dist/os/index.d.ts.map +1 -1
  51. package/dist/os/index.js +1 -1
  52. package/dist/promises/index.d.ts +47 -28
  53. package/dist/promises/index.d.ts.map +1 -1
  54. package/dist/promises/index.js +1 -1
  55. package/dist/promises/promises.test-d.js +1 -1
  56. package/dist/regex/index.d.ts +7 -0
  57. package/dist/regex/index.d.ts.map +1 -1
  58. package/dist/regex/index.js +1 -1
  59. package/dist/security/index.d.ts +0 -13
  60. package/dist/security/index.d.ts.map +1 -1
  61. package/dist/security/index.js +1 -1
  62. package/dist/sleep/index.d.ts +3 -2
  63. package/dist/sleep/index.d.ts.map +1 -1
  64. package/dist/sleep/index.js +1 -1
  65. package/dist/strings/index.d.ts +3 -25
  66. package/dist/strings/index.d.ts.map +1 -1
  67. package/dist/strings/index.js +1 -1
  68. package/dist/system/index.d.ts +22 -3
  69. package/dist/system/index.d.ts.map +1 -1
  70. package/dist/system/index.js +1 -1
  71. package/dist/try/index.d.ts +64 -1
  72. package/dist/try/index.d.ts.map +1 -1
  73. package/dist/try/index.js +1 -1
  74. package/dist/try/trycatch.test-d.js +1 -1
  75. package/dist/url/index.d.ts.map +1 -1
  76. package/dist/url/index.js +1 -1
  77. package/dist/uuid/index.d.ts +0 -10
  78. package/dist/uuid/index.d.ts.map +1 -1
  79. package/dist/uuid/index.js +1 -1
  80. package/dist/validation/index.d.ts +0 -12
  81. package/dist/validation/index.d.ts.map +1 -1
  82. package/dist/validation/index.js +1 -1
  83. package/package.json +35 -36
  84. package/dist/chunks/chunk-5IA77ERW.js +0 -1
  85. package/dist/chunks/chunk-7JQSIREC.js +0 -1
  86. package/dist/chunks/chunk-ARW46OJS.js +0 -1
  87. package/dist/chunks/chunk-FBDKWWIQ.js +0 -3
  88. package/dist/chunks/chunk-MFJ5XPUX.js +0 -1
  89. package/dist/chunks/chunk-W72HFHZY.js +0 -1
  90. package/dist/chunks/chunk-XAQ7VMV4.js +0 -1
  91. package/dist/emails/banned/index.d.ts +0 -9
  92. package/dist/emails/banned/index.d.ts.map +0 -1
  93. package/dist/index.d.ts +0 -2
  94. package/dist/index.d.ts.map +0 -1
  95. package/dist/index.js +0 -0
  96. package/dist/interval/index.d.ts +0 -28
  97. package/dist/interval/index.d.ts.map +0 -1
  98. package/dist/interval/index.js +0 -1
  99. package/dist/logger/logger.d.ts +0 -17
  100. package/dist/logger/logger.d.ts.map +0 -1
  101. package/dist/logger/logger.js +0 -1
  102. package/dist/sets/index.d.ts +0 -67
  103. package/dist/sets/index.d.ts.map +0 -1
  104. package/dist/sets/index.js +0 -1
  105. package/dist/try/trycatch.d.ts +0 -53
  106. package/dist/try/trycatch.d.ts.map +0 -1
  107. package/dist/try/trycatch.js +0 -1
package/AGENTS.md CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  # Using @rtorcato/js-common
4
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.
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 — 42 of them. There is no package root export.
6
6
 
7
7
  ## Rules
8
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.
9
+ 1. **Import from the subpath, never the package root.** The root has no `exports` entry at all, so a root import fails at resolve time (`ERR_PACKAGE_PATH_NOT_EXPORTED`) instead of silently binding nothing.
10
10
 
11
11
  ```ts
12
12
  // ✅ do
13
13
  import { slugify } from '@rtorcato/js-common/strings'
14
- // ❌ don't — the root export is empty by design
14
+ // ❌ don't — there is no root export; this throws at resolve time
15
15
  import { slugify } from '@rtorcato/js-common'
16
16
  ```
17
17
 
@@ -19,12 +19,12 @@
19
19
 
20
20
  | Looks like | Actually |
21
21
  |---|---|
22
- | `functions.once` vs `events.onceEvent` | `once(fn)` memoises a call; `onceEvent(target, type)` awaits a DOM event |
22
+ | `functions.once` vs `events.onceEvent` | `once(fn)` memoises a call; `onceEvent(target, type)` awaits an `EventTarget` event |
23
23
  | `logger` vs `logging` | `logger` is one configured pino instance; `logging` is `console` helpers with no runtime deps |
24
24
  | `try.tryCatch` vs `errors.tryWithFallback` | Result object vs swallow-and-fall-back — see rule 3 |
25
25
  | `date.formatDate` vs `datetime.formatDateTimeLocal` | a UTC calendar day vs a local instant |
26
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.
27
+ Where two modules used to ship the same name, the loser was deleted — use `emails.isValidEmail`, `url.isValidUrl` and `process.getProcessPlatform` (not `validation.isEmail`, `validation.isUrl` or `os.getOsPlatform`). [MODULE-BOUNDARIES.md](https://github.com/rtorcato/js-common/blob/main/MODULE-BOUNDARIES.md) records which side won and why.
28
28
 
29
29
  3. **Three different error idioms — don't mix them up.**
30
30
 
@@ -44,7 +44,7 @@
44
44
 
45
45
  `tryCatch` in `errors` was renamed to `tryWithFallback` in 2.0; `tryCatch` now means the Result helper in `try`.
46
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.
47
+ 4. **Node-only modules.** `file` imports `node:fs`; `logger` uses pino. `crypto` is Web Crypto (`globalThis.crypto`), so it runs anywhere — `hashString` and `hmacHash` return promises. Don't ship `file` or `logger` to a browser bundle. `events` wraps `EventTarget` / `CustomEvent`, which are globals in browsers and Node ≥ 22, so it runs in both. `os`, `process`, `node`, `system`, and `i18n` probe for `process` / `window` / `navigator` and degrade rather than throw. `console` and `env` read `process` unguarded, so a browser bundle needs the bundler to define it. Everything else runs anywhere. `src/runtime-boundaries.test.ts` enforces this paragraph and the `Runtime:` line on each docs module page.
48
48
 
49
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
50
 
@@ -57,13 +57,13 @@ Import from `@rtorcato/js-common/<module>`.
57
57
  | Module | Exports |
58
58
  |---|---|
59
59
  | abortController | createAbortController, abortPromise, withAbort, abortAfter |
60
- | arrays | first, last, unique, flatten, chunk, compact, shuffle, groupBy |
61
- | boolean | toBoolean, xor, and, or, not |
60
+ | arrays | unique, chunk, compact, shuffle, partition, sortBy, zip |
61
+ | boolean | toBoolean |
62
62
  | colors | randomColor, matchingTextColor, hexToRgb, rgbToHex, isValidHex, darken, lighten |
63
63
  | console | disableConsole, clearConsole |
64
64
  | crypto | hashString, randomHex, hmacHash, base64Encode, base64Decode |
65
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 |
66
+ | date | today, parseDate, formatDate, daysBetween, diffInHours, diffInMinutes, isLeapYear, addDays, subDays, addMonths, getDayOfWeek, startOfDay, endOfDay, isWeekend, isWeekday, isSameDay, isToday, formatRelative |
67
67
  | datetime | nowIso, parseIsoDateTime, formatDateTimeLocal, getTimezoneOffset, toUtcDate, unixTimestamp, unixMillis, getIsoWeek, getIsoWeekInfo |
68
68
  | emails | isValidEmail, normalizeEmail, maskEmail, getEmailDomain, isFreeEmailProvider |
69
69
  | env | getENV, isDev, isProd, isTest, getNodeEnv, checkEnv, RootApiEnvSchema |
@@ -75,31 +75,29 @@ Import from `@rtorcato/js-common/<module>`.
75
75
  | geometry | distance2D, midpoint2D, angle2D, pointInRect, rectsOverlap, polygonArea |
76
76
  | html | escapeHtml, unescapeHtml, stripHtmlTags, textToHtml, containsHtml |
77
77
  | i18n | detectLanguage, formatNumber, formatDateI18n, t |
78
- | interval | runInterval, clearIntervalById |
79
- | json | safeJsonParse, safeJsonStringify, isValidJson, deepCloneJson |
78
+ | json | safeJsonParse, safeJsonStringify, isValidJson |
80
79
  | logger | logger (pino instance — pretty in dev, JSON in prod) |
81
80
  | logging | logWithTimestamp, info, warn, error, captureConsole, ConsoleLevel |
82
81
  | maps | invertMap, mapValues, mergeMaps, objectToMap, mapToObject |
83
- | mime-types | lookup, types, extensions, mimeTypes |
82
+ | mime-types | lookup, types, extensions, mimeTypes, FileExtension, MimeType, MimeValue |
84
83
  | node | nodeVersionCheck, getNodeMajorVersion, isNode, requireOptional |
85
- | numbers | clamp, roundTo, formatPercent, isFiniteNumber, isInteger, between, sum, average, mod, min, max |
86
- | objects | isPlainObject, deepMerge, omit, pick, deepClone |
87
- | os | getOsPlatform, getOsRelease, getOsArch, getHomeDir, getTmpDir |
84
+ | numbers | clamp, roundTo, formatPercent, FormatPercentOptions, between, sum, average, mod, variance, stdDev, median, percentile |
85
+ | objects | isPlainObject, deepMerge, omit, pick |
86
+ | os | getOsRelease, getOsArch, getHomeDir, getTmpDir |
88
87
  | process | getProcessId, getProcessUptime, getCwd, getProcessPlatform, exitProcess, isCI |
89
- | promises | delay, to, withTimeout, all, allSettled, race |
88
+ | promises | to, withTimeout, mapLimit, retry, RetryOptions |
90
89
  | random | randomInt, randomFloat, randomBool, randomElement, randomString |
91
90
  | regex | escapeRegExp, testRegex, matchAll, replaceAllRegex, splitByRegex |
92
- | security | stripScriptish, isStrongPassword, generateSecureToken |
93
- | sets | union, intersection, difference, isSubset, isSuperset, setToArray, arrayToSet |
91
+ | security | stripScriptish, isStrongPassword |
94
92
  | sleep | sleep, sleepSync, sleepRandom, sleepWithAbort |
95
- | strings | titleCase, capitalize, camelCase, kebabCase, snakeCase, truncate, padStart, padEnd, replaceString, reverse, slugify, words, wordCount, pluralize, ordinalize, isBlank, mask, template |
93
+ | strings | titleCase, capitalize, camelCase, kebabCase, snakeCase, truncate, reverse, slugify, words, wordCount, pluralize, ordinalize, isBlank, mask, template |
96
94
  | system | isMacOs, isWindows, isLinux, isIOS, isAndroid, getPlatform, isTouchDevice |
97
95
  | time | nowTime, nowTimeShort, parseTime, formatTime, secondsBetween, pad2 |
98
- | try | tryCatch, isSuccess, Result, Success, Failure |
96
+ | try | tryCatch, tryCatchSync, isSuccess, Result, Success, Failure |
99
97
  | types | Prettify, Merge (types only) |
100
98
  | url | isValidUrl, getQueryParams, setQueryParam, removeQueryParam, joinUrl, getHostname |
101
- | uuid | getUUID, getUUIDv7, getShortUUID, toShortUUID, fromShortUUID, isUUID, isUUIDv4, isNilUUID, getUUIDVersion, getNilUUID, uuidToBytes, bytesToUUID |
102
- | validation | isDefined, isString, isNumber, isBoolean, isArray, isObject, isEmail, isUrl |
99
+ | uuid | getUUIDv7, getShortUUID, toShortUUID, fromShortUUID, isUUID, isUUIDv4, isNilUUID, getUUIDVersion, getNilUUID, uuidToBytes, bytesToUUID |
100
+ | validation | isDefined, isString, isNumber, isBoolean, isArray, isObject |
103
101
 
104
102
  ## CLI
105
103
 
@@ -113,4 +111,4 @@ npx @rtorcato/js-common@latest text capitalize "hello world"
113
111
 
114
112
  See [CLI.md](https://github.com/rtorcato/js-common/blob/main/CLI.md) for the full command list.
115
113
 
116
- For full signatures and examples, see <https://rtorcato.github.io/js-common/>.
114
+ For full signatures and examples, see <https://docs.torcato.dev/js-common/>.
package/README.md CHANGED
@@ -15,19 +15,21 @@
15
15
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
16
16
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22.0.0-brightgreen.svg)](https://nodejs.org/)
17
17
  [![codecov](https://codecov.io/gh/rtorcato/js-common/branch/main/graph/badge.svg)](https://codecov.io/gh/rtorcato/js-common)
18
- [![Docs](https://img.shields.io/badge/docs-rtorcato.github.io%2Fjs--common-blue.svg)](https://rtorcato.github.io/js-common/)
18
+ [![Docs](https://img.shields.io/badge/docs-docs.torcato.dev%2Fjs--common-blue.svg)](https://docs.torcato.dev/js-common/)
19
19
 
20
20
  A comprehensive set of common JavaScript and TypeScript utilities for Node.js projects.
21
21
 
22
- 📘 **Documentation:** <https://rtorcato.github.io/js-common/>
22
+ > **Browser APIs live in [`@rtorcato/browser-common`](https://github.com/rtorcato/browser-common).** js-common covers runtime-agnostic JavaScript and Node.js. Wrappers around browser Web APIs, such as clipboard, storage, observers, geolocation, the DOM and user-agent detection, belong to browser-common. The two packages don't overlap.
23
+
24
+ 📘 **Documentation:** <https://docs.torcato.dev/js-common/>
23
25
 
24
26
  ## Features
25
27
 
26
28
  - **Tree-shakeable** — import only what you need via subpath exports
27
29
  - **TypeScript** — full type definitions, JSDoc on every public API
28
30
  - **CLI included** — optional binary for use in scripts and terminals
29
- - **Modular** — one module per concern, 44 subpaths
30
- - **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.
31
+ - **Modular** — one module per concern, 42 subpaths
32
+ - **No required runtime deps** — `zod` (`./env`), `pino` (`./logger`) and `uuid` + `short-uuid` (`./uuid`) are optional peers: install one only if you import its module. CLI packages (`chalk`, `commander`, `figlet`, …) are `optionalDependencies` and only needed for the CLI.
31
33
 
32
34
  ## Installation
33
35
 
@@ -35,6 +37,14 @@ A comprehensive set of common JavaScript and TypeScript utilities for Node.js pr
35
37
  npm install @rtorcato/js-common
36
38
  ```
37
39
 
40
+ Three modules need an optional peer you install yourself:
41
+
42
+ | Module | Peer |
43
+ |---|---|
44
+ | `./env` | `npm install zod` |
45
+ | `./logger` | `npm install pino` |
46
+ | `./uuid` | `npm install uuid short-uuid` |
47
+
38
48
  Pre-release builds are published to the `beta` dist-tag, so they never reach a plain `npm install`:
39
49
 
40
50
  ```bash
@@ -64,7 +74,11 @@ npx skills add https://github.com/rtorcato/js-common --skill js-common
64
74
 
65
75
  ## Migrating
66
76
 
67
- **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).
77
+ **4.x → 5.x** — `zod`, `pino`, `uuid` and `short-uuid` moved from `dependencies` to optional `peerDependencies`. If you import `./env`, add `zod`; `./logger`, add `pino`; `./uuid`, add `uuid` and `short-uuid`. Every other module is unaffected. Details in the [migration guide](https://docs.torcato.dev/js-common/docs/guides/migration).
78
+
79
+ **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://docs.torcato.dev/js-common/docs/guides/migration).
80
+
81
+ **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://docs.torcato.dev/js-common/docs/guides/migration); the reasoning is in [MODULE-BOUNDARIES.md](MODULE-BOUNDARIES.md).
68
82
 
69
83
  **1.x → 2.x** — the only breaking change in 2.0 is a rename in the `errors` module:
70
84
 
@@ -115,7 +129,7 @@ See [CLI.md](./CLI.md) for complete CLI documentation.
115
129
  // Import specific modules (recommended for tree-shaking)
116
130
  import { formatDate, today, daysBetween } from '@rtorcato/js-common/date'
117
131
  import { isValidEmail, normalizeEmail } from '@rtorcato/js-common/emails'
118
- import { getUUID, isUUID } from '@rtorcato/js-common/uuid'
132
+ import { getUUIDv7, isUUID } from '@rtorcato/js-common/uuid'
119
133
  import { sum, average, roundTo } from '@rtorcato/js-common/numbers'
120
134
  import { capitalize, titleCase } from '@rtorcato/js-common/strings'
121
135
 
@@ -123,7 +137,7 @@ import { capitalize, titleCase } from '@rtorcato/js-common/strings'
123
137
  console.log(today()) // "2026-05-29"
124
138
  console.log(sum([1, 2, 3, 4, 5])) // 15
125
139
  console.log(capitalize('hello world')) // "Hello world"
126
- console.log(getUUID()) // "f47ac10b-58cc-4372-a567-0e02b2c3d479"
140
+ console.log(getUUIDv7()) // "018e5e2c-7c0a-7000-8000-0e02b2c3d479"
127
141
  ```
128
142
 
129
143
  ### Bundle Size Impact
@@ -141,12 +155,12 @@ are frozen as of that record.
141
155
  import { today, formatDate, daysBetween, isLeapYear } from '@rtorcato/js-common/date'
142
156
  import { nowIso, formatDateTimeLocal, unixTimestamp } from '@rtorcato/js-common/datetime'
143
157
  import { nowTime, parseTime, secondsBetween } from '@rtorcato/js-common/time'
144
- import { runInterval, clearIntervalById } from '@rtorcato/js-common/interval'
145
158
  ```
146
159
 
147
160
  ### Numbers
148
161
  ```typescript
149
162
  import { sum, average, roundTo, clamp, formatPercent } from '@rtorcato/js-common/numbers'
163
+ import { variance, stdDev, median, percentile } from '@rtorcato/js-common/numbers' // dispersion
150
164
  import { randomInt, randomFloat, randomBool, randomElement } from '@rtorcato/js-common/random'
151
165
  ```
152
166
 
@@ -160,25 +174,25 @@ import { detectLanguage, formatNumber, formatDateI18n, t } from '@rtorcato/js-co
160
174
 
161
175
  ### Security & Validation
162
176
  ```typescript
163
- import { isStrongPassword, generateSecureToken } from '@rtorcato/js-common/security'
177
+ import { isStrongPassword, stripScriptish } from '@rtorcato/js-common/security'
178
+ import { randomHex, hashString, hmacHash } from '@rtorcato/js-common/crypto'
164
179
  import { isValidEmail, maskEmail } from '@rtorcato/js-common/emails'
165
180
  import { isValidUrl } from '@rtorcato/js-common/url'
166
181
  import { isString, isNumber, isBoolean, isArray, isObject } from '@rtorcato/js-common/validation'
167
- import { toBoolean, and, or, not, xor } from '@rtorcato/js-common/boolean'
182
+ import { toBoolean } from '@rtorcato/js-common/boolean'
168
183
  ```
169
184
 
170
185
  ### Data Structures
171
186
  ```typescript
172
- import { flatten, unique, chunk, groupBy } from '@rtorcato/js-common/arrays'
173
- import { deepMerge, pick, omit, deepClone } from '@rtorcato/js-common/objects'
187
+ import { unique, chunk, compact, shuffle, partition, sortBy, zip } from '@rtorcato/js-common/arrays'
188
+ import { deepMerge, pick, omit, isPlainObject } from '@rtorcato/js-common/objects'
174
189
  import { safeJsonParse, safeJsonStringify } from '@rtorcato/js-common/json'
175
190
  import { invertMap, mapValues, objectToMap, mapToObject } from '@rtorcato/js-common/maps'
176
- import { union, intersection, difference, isSubset } from '@rtorcato/js-common/sets'
177
191
  ```
178
192
 
179
193
  ### Async & Control Flow
180
194
  ```typescript
181
- import { delay, withTimeout, allSettled } from '@rtorcato/js-common/promises'
195
+ import { retry, to, withTimeout } from '@rtorcato/js-common/promises'
182
196
  import { debounce, throttle, once } from '@rtorcato/js-common/functions'
183
197
  import { sleep } from '@rtorcato/js-common/sleep'
184
198
  import { tryCatch } from '@rtorcato/js-common/try'
@@ -189,9 +203,9 @@ import { createCustomError, getErrorMessage, assert } from '@rtorcato/js-common/
189
203
  ### System & Process
190
204
  ```typescript
191
205
  import { getENV, isDev, isProd, getNodeEnv, checkEnv } from '@rtorcato/js-common/env'
192
- import { getOsPlatform, getOsArch, getHomeDir } from '@rtorcato/js-common/os'
206
+ import { getOsArch, getOsRelease, getHomeDir } from '@rtorcato/js-common/os'
193
207
  import { getNodeMajorVersion, isNode, requireOptional } from '@rtorcato/js-common/node'
194
- import { getProcessId, getCwd, exitProcess, isCI } from '@rtorcato/js-common/process'
208
+ import { getProcessPlatform, getCwd, exitProcess, isCI } from '@rtorcato/js-common/process'
195
209
  import { isMacOs, isWindows, isLinux, getPlatform } from '@rtorcato/js-common/system'
196
210
  import { disableConsole, clearConsole } from '@rtorcato/js-common/console'
197
211
  ```
@@ -242,9 +256,6 @@ pnpm run check:fix
242
256
 
243
257
  # Type checking
244
258
  pnpm run typecheck
245
-
246
- # Run micro-benchmarks (scripts/benchmark.mjs)
247
- pnpm run benchmark
248
259
  ```
249
260
 
250
261
  ## Documentation site
@@ -259,7 +270,7 @@ pnpm --filter @rtorcato/js-common-docs dev
259
270
  pnpm --filter @rtorcato/js-common-docs build
260
271
  ```
261
272
 
262
- Live site: <https://rtorcato.github.io/js-common/>
273
+ Live site: <https://docs.torcato.dev/js-common/>
263
274
 
264
275
  ## Roadmap
265
276
 
@@ -16,7 +16,7 @@ export declare function createAbortController(): {
16
16
  signal: AbortSignal;
17
17
  };
18
18
  /**
19
- * Returns a promise that rejects when the given AbortSignal is aborted.
19
+ * Returns a promise that rejects with `signal.reason` when the given AbortSignal is aborted.
20
20
  *
21
21
  * @example
22
22
  * ```typescript
@@ -31,7 +31,8 @@ export declare function createAbortController(): {
31
31
  */
32
32
  export declare function abortPromise(signal: AbortSignal): Promise<never>;
33
33
  /**
34
- * Wraps a promise and rejects it if the signal is aborted.
34
+ * Wraps a promise and rejects it with `signal.reason` if the signal is aborted.
35
+ * The abort listener is removed once the promise settles.
35
36
  *
36
37
  * @example
37
38
  * ```typescript
@@ -1 +1 @@
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
+ {"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,CAKhE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAiBjF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAEjG"}
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function n(){let r=new AbortController;return{controller:r,signal:r.signal}}function t(r){return new Promise((e,o)=>{r.aborted?o(new DOMException("Aborted","AbortError")):r.addEventListener("abort",()=>{o(new DOMException("Aborted","AbortError"))},{once:!0})})}function i(r,e){return Promise.race([r,t(e)])}function b(r,e){return setTimeout(()=>r.abort(),e)}export{b as abortAfter,t as abortPromise,n as createAbortController,i as withAbort};
1
+ import"../chunks/chunk-ANN5UYCF.js";function u(){let e=new AbortController;return{controller:e,signal:e.signal}}function s(e){return new Promise((r,o)=>{e.aborted?o(e.reason):e.addEventListener("abort",()=>o(e.reason),{once:!0})})}function a(e,r){return r.aborted?Promise.reject(r.reason):new Promise((o,n)=>{let b=()=>n(r.reason);r.addEventListener("abort",b,{once:!0});let i=()=>r.removeEventListener("abort",b);e.then(t=>{i(),o(t)},t=>{i(),n(t)})})}function c(e,r){return setTimeout(()=>e.abort(),r)}export{c as abortAfter,s as abortPromise,u as createAbortController,a as withAbort};
@@ -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 p,b as a,e as n,f as u,g as y}from"../chunks/chunk-U2F5TMN2.js";import"../chunks/chunk-ANN5UYCF.js";import{describe as o,expectTypeOf as e,it as r}from"vitest";o("arrays \u2014 types",()=>{r("unique preserves element type",()=>{e(p([1,2,3])).toEqualTypeOf(),e(p(["a"])).toEqualTypeOf()}),r("chunk returns array of arrays of the element type",()=>{e(a([1,2,3],2)).toEqualTypeOf(),e(a(["a","b"],1)).toEqualTypeOf()})});o("arrays \u2014 grouping helper types",()=>{r("partition returns a tuple of element arrays",()=>{e(n([1,2],t=>t>1)).toEqualTypeOf()}),r("sortBy preserves the element type",()=>{e(u([1,2],t=>t)).toEqualTypeOf()}),r("zip pairs both element types",()=>{e(y([1],["a"])).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.
@@ -114,21 +69,55 @@ export declare function compact<T>(arr: T[]): T[];
114
69
  */
115
70
  export declare function shuffle<T>(arr: T[]): T[];
116
71
  /**
117
- * Groups array elements by a key derived from each element.
72
+ * Splits an array into two arrays: the elements that satisfy the predicate and
73
+ * the ones that do not. Order is preserved within each half.
118
74
  *
119
75
  * @example
120
76
  * ```typescript
121
- * groupBy([1, 2, 3, 4], n => n % 2 === 0 ? 'even' : 'odd')
122
- * // { odd: [1, 3], even: [2, 4] }
77
+ * partition([1, 2, 3, 4], (n) => n % 2 === 0) // [[2, 4], [1, 3]]
78
+ * partition(['a', 'bb'], (s) => s.length > 1) // [['bb'], ['a']]
79
+ * ```
123
80
  *
124
- * groupBy([{ type: 'a' }, { type: 'b' }, { type: 'a' }], x => x.type)
125
- * // { a: [{ type: 'a' }, { type: 'a' }], b: [{ type: 'b' }] }
81
+ * @param arr The array to split
82
+ * @param predicate Called with each element and its index; truthy sends the element to the first half
83
+ * @returns A `[pass, fail]` tuple of new arrays
84
+ * @category Array Utilities
85
+ */
86
+ export declare function partition<T>(arr: T[], predicate: (value: T, index: number) => boolean): [T[], T[]];
87
+ /**
88
+ * Sorts an array by a derived key, without mutating the input.
89
+ * Keys are compared with `<` / `>`, so strings sort lexicographically and
90
+ * numbers numerically — unlike `Array#sort`, which stringifies everything.
91
+ * The sort is stable, so equal keys keep their original order.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * sortBy([{ n: 2 }, { n: 1 }], (o) => o.n) // [{ n: 1 }, { n: 2 }]
96
+ * sortBy([10, 9, 100], (n) => n) // [9, 10, 100] — not [10, 100, 9]
97
+ * sortBy(users, (u) => u.name, 'desc')
98
+ * ```
99
+ *
100
+ * @param arr The array to sort
101
+ * @param keyFn Maps an element to the value to sort by
102
+ * @param direction `'asc'` (default) or `'desc'`
103
+ * @returns A new sorted array
104
+ * @category Array Utilities
105
+ */
106
+ export declare function sortBy<T>(arr: T[], keyFn: (value: T) => number | string | bigint | Date, direction?: 'asc' | 'desc'): T[];
107
+ /**
108
+ * Pairs up two arrays element by element. The result is as long as the shorter
109
+ * input — surplus elements are dropped.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * zip([1, 2, 3], ['a', 'b', 'c']) // [[1, 'a'], [2, 'b'], [3, 'c']]
114
+ * zip([1, 2, 3], ['a']) // [[1, 'a']]
126
115
  * ```
127
116
  *
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
117
+ * @param a The first array
118
+ * @param b The second array
119
+ * @returns An array of `[a[i], b[i]]` pairs
131
120
  * @category Array Utilities
132
121
  */
133
- export declare function groupBy<T>(arr: T[], fn: (item: T) => string | number): Record<string | number, T[]>;
122
+ export declare function zip<A, B>(a: A[], b: B[]): [A, B][];
134
123
  //# 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;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAC1B,GAAG,EAAE,CAAC,EAAE,EACR,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,GAC7C,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAOZ;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACvB,GAAG,EAAE,CAAC,EAAE,EACR,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,EACpD,SAAS,GAAE,KAAK,GAAG,MAAc,GAC/B,CAAC,EAAE,CAWL;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAKlD"}
@@ -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,e,f,g}from"../chunks/chunk-U2F5TMN2.js";import"../chunks/chunk-ANN5UYCF.js";export{b as chunk,c as compact,e as partition,d as shuffle,f as sortBy,a as unique,g as zip};
@@ -15,39 +15,4 @@
15
15
  * @returns The boolean representation.
16
16
  */
17
17
  export declare function toBoolean(value: unknown): boolean;
18
- /**
19
- * Returns the logical exclusive OR (XOR) of two booleans.
20
- *
21
- * @example
22
- * ```typescript
23
- * xor(true, false) // true
24
- * xor(true, true) // false
25
- * xor(false, false) // false
26
- * ```
27
- *
28
- * @param a First boolean.
29
- * @param b Second boolean.
30
- * @returns True if exactly one of a or b is true.
31
- */
32
- export declare function xor(a: boolean, b: boolean): boolean;
33
- /**
34
- * Logical AND for two booleans.
35
- * @param a First boolean.
36
- * @param b Second boolean.
37
- * @returns True if both a and b are true.
38
- */
39
- export declare function and(a: boolean, b: boolean): boolean;
40
- /**
41
- * Logical OR for two booleans.
42
- * @param a First boolean.
43
- * @param b Second boolean.
44
- * @returns True if either a or b is true.
45
- */
46
- export declare function or(a: boolean, b: boolean): boolean;
47
- /**
48
- * Logical NOT for a boolean.
49
- * @param a The boolean to negate.
50
- * @returns The negated boolean.
51
- */
52
- export declare function not(a: boolean): boolean;
53
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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;AAED;;;;;;;;;;;;;GAaG;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,n){return!!(o?!n:n)}function t(o,n){return o&&n}function f(o,n){return o||n}function a(o){return!o}export{t as and,a as not,f as or,e as toBoolean,r 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
+ function e(r){return r.error===null}async function u(r){try{return{data:await r(),error:null}}catch(t){return{data:null,error:t}}}function a(r){try{return{data:r(),error:null}}catch(t){return{data:null,error:t}}}export{e as a,u as b,a as c};