@fluixi/utils 1.0.0-alpha.53

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 (354) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/index.cjs +1 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +1 -0
  7. package/dist/index.mjs +1 -0
  8. package/dist/lib/array/advanced.cjs +1 -0
  9. package/dist/lib/array/advanced.d.ts +1116 -0
  10. package/dist/lib/array/advanced.d.ts.map +1 -0
  11. package/dist/lib/array/advanced.js +2429 -0
  12. package/dist/lib/array/advanced.mjs +1 -0
  13. package/dist/lib/array/array.cjs +1 -0
  14. package/dist/lib/array/array.d.ts +6 -0
  15. package/dist/lib/array/array.d.ts.map +1 -0
  16. package/dist/lib/array/array.js +31 -0
  17. package/dist/lib/array/array.mjs +1 -0
  18. package/dist/lib/array/index.cjs +1 -0
  19. package/dist/lib/array/index.d.ts +4 -0
  20. package/dist/lib/array/index.d.ts.map +1 -0
  21. package/dist/lib/array/index.js +3 -0
  22. package/dist/lib/array/index.mjs +1 -0
  23. package/dist/lib/array/utils.cjs +1 -0
  24. package/dist/lib/array/utils.d.ts +100 -0
  25. package/dist/lib/array/utils.d.ts.map +1 -0
  26. package/dist/lib/array/utils.js +165 -0
  27. package/dist/lib/array/utils.mjs +1 -0
  28. package/dist/lib/color/color.cjs +1 -0
  29. package/dist/lib/color/color.d.ts +366 -0
  30. package/dist/lib/color/color.d.ts.map +1 -0
  31. package/dist/lib/color/color.js +722 -0
  32. package/dist/lib/color/color.mjs +1 -0
  33. package/dist/lib/color/constants.cjs +1 -0
  34. package/dist/lib/color/constants.d.ts +361 -0
  35. package/dist/lib/color/constants.d.ts.map +1 -0
  36. package/dist/lib/color/constants.js +358 -0
  37. package/dist/lib/color/constants.mjs +1 -0
  38. package/dist/lib/color/conversions.cjs +1 -0
  39. package/dist/lib/color/conversions.d.ts +166 -0
  40. package/dist/lib/color/conversions.d.ts.map +1 -0
  41. package/dist/lib/color/conversions.js +766 -0
  42. package/dist/lib/color/conversions.mjs +1 -0
  43. package/dist/lib/color/helpers.cjs +1 -0
  44. package/dist/lib/color/helpers.d.ts +75 -0
  45. package/dist/lib/color/helpers.d.ts.map +1 -0
  46. package/dist/lib/color/helpers.js +419 -0
  47. package/dist/lib/color/helpers.mjs +1 -0
  48. package/dist/lib/color/index.cjs +1 -0
  49. package/dist/lib/color/index.d.ts +12 -0
  50. package/dist/lib/color/index.d.ts.map +1 -0
  51. package/dist/lib/color/index.js +15 -0
  52. package/dist/lib/color/index.mjs +1 -0
  53. package/dist/lib/color/types.cjs +1 -0
  54. package/dist/lib/color/types.d.ts +179 -0
  55. package/dist/lib/color/types.d.ts.map +1 -0
  56. package/dist/lib/color/types.js +1 -0
  57. package/dist/lib/color/types.mjs +0 -0
  58. package/dist/lib/color/utils.cjs +1 -0
  59. package/dist/lib/color/utils.d.ts +199 -0
  60. package/dist/lib/color/utils.d.ts.map +1 -0
  61. package/dist/lib/color/utils.js +858 -0
  62. package/dist/lib/color/utils.mjs +1 -0
  63. package/dist/lib/compare/comparators.cjs +1 -0
  64. package/dist/lib/compare/comparators.d.ts +65 -0
  65. package/dist/lib/compare/comparators.d.ts.map +1 -0
  66. package/dist/lib/compare/comparators.js +210 -0
  67. package/dist/lib/compare/comparators.mjs +1 -0
  68. package/dist/lib/compare/index.cjs +1 -0
  69. package/dist/lib/compare/index.d.ts +2 -0
  70. package/dist/lib/compare/index.d.ts.map +1 -0
  71. package/dist/lib/compare/index.js +1 -0
  72. package/dist/lib/compare/index.mjs +1 -0
  73. package/dist/lib/crypto/hash.cjs +1 -0
  74. package/dist/lib/crypto/hash.d.ts +6 -0
  75. package/dist/lib/crypto/hash.d.ts.map +1 -0
  76. package/dist/lib/crypto/hash.js +53 -0
  77. package/dist/lib/crypto/hash.mjs +1 -0
  78. package/dist/lib/crypto/index.cjs +1 -0
  79. package/dist/lib/crypto/index.d.ts +2 -0
  80. package/dist/lib/crypto/index.d.ts.map +1 -0
  81. package/dist/lib/crypto/index.js +1 -0
  82. package/dist/lib/crypto/index.mjs +1 -0
  83. package/dist/lib/dom/events.cjs +1 -0
  84. package/dist/lib/dom/events.d.ts +159 -0
  85. package/dist/lib/dom/events.d.ts.map +1 -0
  86. package/dist/lib/dom/events.js +50 -0
  87. package/dist/lib/dom/events.mjs +1 -0
  88. package/dist/lib/dom/index.cjs +1 -0
  89. package/dist/lib/dom/index.d.ts +3 -0
  90. package/dist/lib/dom/index.d.ts.map +1 -0
  91. package/dist/lib/dom/index.js +2 -0
  92. package/dist/lib/dom/index.mjs +1 -0
  93. package/dist/lib/dom/utils.cjs +1 -0
  94. package/dist/lib/dom/utils.d.ts +6 -0
  95. package/dist/lib/dom/utils.d.ts.map +1 -0
  96. package/dist/lib/dom/utils.js +37 -0
  97. package/dist/lib/dom/utils.mjs +1 -0
  98. package/dist/lib/functions/functions.cjs +1 -0
  99. package/dist/lib/functions/functions.d.ts +329 -0
  100. package/dist/lib/functions/functions.d.ts.map +1 -0
  101. package/dist/lib/functions/functions.js +585 -0
  102. package/dist/lib/functions/functions.mjs +1 -0
  103. package/dist/lib/functions/index.cjs +1 -0
  104. package/dist/lib/functions/index.d.ts +3 -0
  105. package/dist/lib/functions/index.d.ts.map +1 -0
  106. package/dist/lib/functions/index.js +1 -0
  107. package/dist/lib/functions/index.mjs +1 -0
  108. package/dist/lib/functions/types.cjs +1 -0
  109. package/dist/lib/functions/types.d.ts +2 -0
  110. package/dist/lib/functions/types.d.ts.map +1 -0
  111. package/dist/lib/functions/types.js +1 -0
  112. package/dist/lib/functions/types.mjs +0 -0
  113. package/dist/lib/helpers.cjs +1 -0
  114. package/dist/lib/helpers.d.ts +13 -0
  115. package/dist/lib/helpers.d.ts.map +1 -0
  116. package/dist/lib/helpers.js +66 -0
  117. package/dist/lib/helpers.mjs +1 -0
  118. package/dist/lib/index.cjs +1 -0
  119. package/dist/lib/index.d.ts +6 -0
  120. package/dist/lib/index.d.ts.map +1 -0
  121. package/dist/lib/index.js +8 -0
  122. package/dist/lib/index.mjs +1 -0
  123. package/dist/lib/maths/constants.cjs +1 -0
  124. package/dist/lib/maths/constants.d.ts +84 -0
  125. package/dist/lib/maths/constants.d.ts.map +1 -0
  126. package/dist/lib/maths/constants.js +79 -0
  127. package/dist/lib/maths/constants.mjs +1 -0
  128. package/dist/lib/maths/fn/advanced.cjs +1 -0
  129. package/dist/lib/maths/fn/advanced.d.ts +149 -0
  130. package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
  131. package/dist/lib/maths/fn/advanced.js +264 -0
  132. package/dist/lib/maths/fn/advanced.mjs +1 -0
  133. package/dist/lib/maths/fn/basic.cjs +1 -0
  134. package/dist/lib/maths/fn/basic.d.ts +182 -0
  135. package/dist/lib/maths/fn/basic.d.ts.map +1 -0
  136. package/dist/lib/maths/fn/basic.js +343 -0
  137. package/dist/lib/maths/fn/basic.mjs +1 -0
  138. package/dist/lib/maths/fn/complex.cjs +1 -0
  139. package/dist/lib/maths/fn/complex.d.ts +153 -0
  140. package/dist/lib/maths/fn/complex.d.ts.map +1 -0
  141. package/dist/lib/maths/fn/complex.js +383 -0
  142. package/dist/lib/maths/fn/complex.mjs +1 -0
  143. package/dist/lib/maths/fn/index.cjs +1 -0
  144. package/dist/lib/maths/fn/index.d.ts +10 -0
  145. package/dist/lib/maths/fn/index.d.ts.map +1 -0
  146. package/dist/lib/maths/fn/index.js +9 -0
  147. package/dist/lib/maths/fn/index.mjs +1 -0
  148. package/dist/lib/maths/fn/trigo.cjs +1 -0
  149. package/dist/lib/maths/fn/trigo.d.ts +147 -0
  150. package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
  151. package/dist/lib/maths/fn/trigo.js +227 -0
  152. package/dist/lib/maths/fn/trigo.mjs +1 -0
  153. package/dist/lib/maths/fn/vector.cjs +1 -0
  154. package/dist/lib/maths/fn/vector.d.ts +512 -0
  155. package/dist/lib/maths/fn/vector.d.ts.map +1 -0
  156. package/dist/lib/maths/fn/vector.js +1136 -0
  157. package/dist/lib/maths/fn/vector.mjs +1 -0
  158. package/dist/lib/maths/formatter.cjs +1 -0
  159. package/dist/lib/maths/formatter.d.ts +35 -0
  160. package/dist/lib/maths/formatter.d.ts.map +1 -0
  161. package/dist/lib/maths/formatter.js +56 -0
  162. package/dist/lib/maths/formatter.mjs +1 -0
  163. package/dist/lib/maths/guards.cjs +1 -0
  164. package/dist/lib/maths/guards.d.ts +166 -0
  165. package/dist/lib/maths/guards.d.ts.map +1 -0
  166. package/dist/lib/maths/guards.js +315 -0
  167. package/dist/lib/maths/guards.mjs +1 -0
  168. package/dist/lib/maths/index.cjs +1 -0
  169. package/dist/lib/maths/index.d.ts +24 -0
  170. package/dist/lib/maths/index.d.ts.map +1 -0
  171. package/dist/lib/maths/index.js +29 -0
  172. package/dist/lib/maths/index.mjs +1 -0
  173. package/dist/lib/maths/parser.cjs +1 -0
  174. package/dist/lib/maths/parser.d.ts +20 -0
  175. package/dist/lib/maths/parser.d.ts.map +1 -0
  176. package/dist/lib/maths/parser.js +78 -0
  177. package/dist/lib/maths/parser.mjs +1 -0
  178. package/dist/lib/maths/random.cjs +1 -0
  179. package/dist/lib/maths/random.d.ts +27 -0
  180. package/dist/lib/maths/random.d.ts.map +1 -0
  181. package/dist/lib/maths/random.js +49 -0
  182. package/dist/lib/maths/random.mjs +1 -0
  183. package/dist/lib/maths/types/advanced.cjs +1 -0
  184. package/dist/lib/maths/types/advanced.d.ts +357 -0
  185. package/dist/lib/maths/types/advanced.d.ts.map +1 -0
  186. package/dist/lib/maths/types/advanced.js +5 -0
  187. package/dist/lib/maths/types/advanced.mjs +0 -0
  188. package/dist/lib/maths/types/basic.cjs +1 -0
  189. package/dist/lib/maths/types/basic.d.ts +95 -0
  190. package/dist/lib/maths/types/basic.d.ts.map +1 -0
  191. package/dist/lib/maths/types/basic.js +5 -0
  192. package/dist/lib/maths/types/basic.mjs +0 -0
  193. package/dist/lib/maths/types/index.cjs +1 -0
  194. package/dist/lib/maths/types/index.d.ts +4 -0
  195. package/dist/lib/maths/types/index.d.ts.map +1 -0
  196. package/dist/lib/maths/types/index.js +3 -0
  197. package/dist/lib/maths/types/index.mjs +0 -0
  198. package/dist/lib/maths/types/negative.cjs +1 -0
  199. package/dist/lib/maths/types/negative.d.ts +51 -0
  200. package/dist/lib/maths/types/negative.d.ts.map +1 -0
  201. package/dist/lib/maths/types/negative.js +5 -0
  202. package/dist/lib/maths/types/negative.mjs +0 -0
  203. package/dist/lib/maths/types/operations.cjs +1 -0
  204. package/dist/lib/maths/types/operations.d.ts +188 -0
  205. package/dist/lib/maths/types/operations.d.ts.map +1 -0
  206. package/dist/lib/maths/types/operations.js +6 -0
  207. package/dist/lib/maths/types/operations.mjs +0 -0
  208. package/dist/lib/object/clone.cjs +1 -0
  209. package/dist/lib/object/clone.d.ts +46 -0
  210. package/dist/lib/object/clone.d.ts.map +1 -0
  211. package/dist/lib/object/clone.js +104 -0
  212. package/dist/lib/object/clone.mjs +1 -0
  213. package/dist/lib/object/diff.cjs +1 -0
  214. package/dist/lib/object/diff.d.ts +203 -0
  215. package/dist/lib/object/diff.d.ts.map +1 -0
  216. package/dist/lib/object/diff.js +805 -0
  217. package/dist/lib/object/diff.mjs +1 -0
  218. package/dist/lib/object/getter-setter.cjs +1 -0
  219. package/dist/lib/object/getter-setter.d.ts +361 -0
  220. package/dist/lib/object/getter-setter.d.ts.map +1 -0
  221. package/dist/lib/object/getter-setter.js +1771 -0
  222. package/dist/lib/object/getter-setter.mjs +1 -0
  223. package/dist/lib/object/index.cjs +6 -0
  224. package/dist/lib/object/index.d.ts +13 -0
  225. package/dist/lib/object/index.d.ts.map +1 -0
  226. package/dist/lib/object/index.js +12 -0
  227. package/dist/lib/object/index.mjs +6 -0
  228. package/dist/lib/object/merge.cjs +1 -0
  229. package/dist/lib/object/merge.d.ts +93 -0
  230. package/dist/lib/object/merge.d.ts.map +1 -0
  231. package/dist/lib/object/merge.js +474 -0
  232. package/dist/lib/object/merge.mjs +1 -0
  233. package/dist/lib/object/object.cjs +1 -0
  234. package/dist/lib/object/object.d.ts +128 -0
  235. package/dist/lib/object/object.d.ts.map +1 -0
  236. package/dist/lib/object/object.js +432 -0
  237. package/dist/lib/object/object.mjs +1 -0
  238. package/dist/lib/object/omit.cjs +1 -0
  239. package/dist/lib/object/omit.d.ts +351 -0
  240. package/dist/lib/object/omit.d.ts.map +1 -0
  241. package/dist/lib/object/omit.js +656 -0
  242. package/dist/lib/object/omit.mjs +1 -0
  243. package/dist/lib/object/reconcile.cjs +1 -0
  244. package/dist/lib/object/reconcile.d.ts +7 -0
  245. package/dist/lib/object/reconcile.d.ts.map +1 -0
  246. package/dist/lib/object/reconcile.js +122 -0
  247. package/dist/lib/object/reconcile.mjs +1 -0
  248. package/dist/lib/object/selector.cjs +1 -0
  249. package/dist/lib/object/selector.d.ts +50 -0
  250. package/dist/lib/object/selector.d.ts.map +1 -0
  251. package/dist/lib/object/selector.js +371 -0
  252. package/dist/lib/object/selector.mjs +1 -0
  253. package/dist/lib/object/sort.cjs +1 -0
  254. package/dist/lib/object/sort.d.ts +149 -0
  255. package/dist/lib/object/sort.d.ts.map +1 -0
  256. package/dist/lib/object/sort.js +298 -0
  257. package/dist/lib/object/sort.mjs +1 -0
  258. package/dist/lib/object/transform.cjs +1 -0
  259. package/dist/lib/object/transform.d.ts +620 -0
  260. package/dist/lib/object/transform.d.ts.map +1 -0
  261. package/dist/lib/object/transform.js +1058 -0
  262. package/dist/lib/object/transform.mjs +1 -0
  263. package/dist/lib/object/types.cjs +1 -0
  264. package/dist/lib/object/types.d.ts +250 -0
  265. package/dist/lib/object/types.d.ts.map +1 -0
  266. package/dist/lib/object/types.js +1 -0
  267. package/dist/lib/object/types.mjs +0 -0
  268. package/dist/lib/object/utils.cjs +6 -0
  269. package/dist/lib/object/utils.d.ts +165 -0
  270. package/dist/lib/object/utils.d.ts.map +1 -0
  271. package/dist/lib/object/utils.js +444 -0
  272. package/dist/lib/object/utils.mjs +6 -0
  273. package/dist/lib/primitive/boolean/boolean.cjs +1 -0
  274. package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
  275. package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
  276. package/dist/lib/primitive/boolean/boolean.js +615 -0
  277. package/dist/lib/primitive/boolean/boolean.mjs +1 -0
  278. package/dist/lib/primitive/boolean/index.cjs +1 -0
  279. package/dist/lib/primitive/boolean/index.d.ts +3 -0
  280. package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
  281. package/dist/lib/primitive/boolean/index.js +2 -0
  282. package/dist/lib/primitive/boolean/index.mjs +1 -0
  283. package/dist/lib/primitive/boolean/types.cjs +1 -0
  284. package/dist/lib/primitive/boolean/types.d.ts +14 -0
  285. package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
  286. package/dist/lib/primitive/boolean/types.js +1 -0
  287. package/dist/lib/primitive/boolean/types.mjs +0 -0
  288. package/dist/lib/primitive/date/date.cjs +1 -0
  289. package/dist/lib/primitive/date/date.d.ts +641 -0
  290. package/dist/lib/primitive/date/date.d.ts.map +1 -0
  291. package/dist/lib/primitive/date/date.js +1998 -0
  292. package/dist/lib/primitive/date/date.mjs +1 -0
  293. package/dist/lib/primitive/date/index.cjs +1 -0
  294. package/dist/lib/primitive/date/index.d.ts +3 -0
  295. package/dist/lib/primitive/date/index.d.ts.map +1 -0
  296. package/dist/lib/primitive/date/index.js +2 -0
  297. package/dist/lib/primitive/date/index.mjs +1 -0
  298. package/dist/lib/primitive/date/types.cjs +1 -0
  299. package/dist/lib/primitive/date/types.d.ts +205 -0
  300. package/dist/lib/primitive/date/types.d.ts.map +1 -0
  301. package/dist/lib/primitive/date/types.js +7 -0
  302. package/dist/lib/primitive/date/types.mjs +0 -0
  303. package/dist/lib/primitive/index.cjs +5 -0
  304. package/dist/lib/primitive/index.d.ts +5 -0
  305. package/dist/lib/primitive/index.d.ts.map +1 -0
  306. package/dist/lib/primitive/index.js +4 -0
  307. package/dist/lib/primitive/index.mjs +5 -0
  308. package/dist/lib/primitive/string/index.cjs +5 -0
  309. package/dist/lib/primitive/string/index.d.ts +3 -0
  310. package/dist/lib/primitive/string/index.d.ts.map +1 -0
  311. package/dist/lib/primitive/string/index.js +2 -0
  312. package/dist/lib/primitive/string/index.mjs +5 -0
  313. package/dist/lib/primitive/string/parser-2.cjs +8 -0
  314. package/dist/lib/primitive/string/parser-2.d.ts +17 -0
  315. package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
  316. package/dist/lib/primitive/string/parser-2.js +656 -0
  317. package/dist/lib/primitive/string/parser-2.mjs +8 -0
  318. package/dist/lib/primitive/string/parser.cjs +3 -0
  319. package/dist/lib/primitive/string/parser.d.ts +9 -0
  320. package/dist/lib/primitive/string/parser.d.ts.map +1 -0
  321. package/dist/lib/primitive/string/parser.js +775 -0
  322. package/dist/lib/primitive/string/parser.mjs +3 -0
  323. package/dist/lib/primitive/string/string.cjs +5 -0
  324. package/dist/lib/primitive/string/string.d.ts +535 -0
  325. package/dist/lib/primitive/string/string.d.ts.map +1 -0
  326. package/dist/lib/primitive/string/string.js +1301 -0
  327. package/dist/lib/primitive/string/string.mjs +5 -0
  328. package/dist/lib/primitive/string/types.cjs +1 -0
  329. package/dist/lib/primitive/string/types.d.ts +318 -0
  330. package/dist/lib/primitive/string/types.d.ts.map +1 -0
  331. package/dist/lib/primitive/string/types.js +5 -0
  332. package/dist/lib/primitive/string/types.mjs +0 -0
  333. package/dist/lib/primitive/types.cjs +1 -0
  334. package/dist/lib/primitive/types.d.ts +27 -0
  335. package/dist/lib/primitive/types.d.ts.map +1 -0
  336. package/dist/lib/primitive/types.js +1 -0
  337. package/dist/lib/primitive/types.mjs +0 -0
  338. package/dist/lib/url/index.cjs +1 -0
  339. package/dist/lib/url/index.d.ts +3 -0
  340. package/dist/lib/url/index.d.ts.map +1 -0
  341. package/dist/lib/url/index.js +2 -0
  342. package/dist/lib/url/index.mjs +1 -0
  343. package/dist/lib/url/parser.cjs +1 -0
  344. package/dist/lib/url/parser.d.ts +216 -0
  345. package/dist/lib/url/parser.d.ts.map +1 -0
  346. package/dist/lib/url/parser.js +488 -0
  347. package/dist/lib/url/parser.mjs +1 -0
  348. package/dist/lib/url/types.cjs +1 -0
  349. package/dist/lib/url/types.d.ts +18 -0
  350. package/dist/lib/url/types.d.ts.map +1 -0
  351. package/dist/lib/url/types.js +1 -0
  352. package/dist/lib/url/types.mjs +0 -0
  353. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  354. package/package.json +150 -0
@@ -0,0 +1,615 @@
1
+ /**
2
+ * Boolean utilities collection for TypeScript
3
+ * Provides optimized methods for common boolean operations and conversions
4
+ */
5
+ /**
6
+ * Checks if a value is a boolean (strict type guard)
7
+ * @param value - The value to check
8
+ * @returns True if value is exactly true or false
9
+ * @example
10
+ * isBoolean(true) // true
11
+ * isBoolean(false) // true
12
+ * isBoolean(1) // false
13
+ * isBoolean("true") // false
14
+ */
15
+ export const isBoolean = (value) => {
16
+ return value === true || value === false;
17
+ };
18
+ /**
19
+ * Checks if a value is a boolean or boolean-like
20
+ * Accepts 0, 1, "true", "false", "0", "1" as boolean-like
21
+ * @param value - The value to check
22
+ * @returns True if value is boolean or boolean-like
23
+ * @example
24
+ * isBooleanLike(true) // true
25
+ * isBooleanLike(1) // true
26
+ * isBooleanLike("true") // true
27
+ * isBooleanLike("yes") // false
28
+ */
29
+ export const isBooleanLike = (value) => {
30
+ if (value === true || value === false)
31
+ return true;
32
+ if (value === 0 || value === 1)
33
+ return true;
34
+ if (typeof value === 'string') {
35
+ const lower = value.toLowerCase().trim();
36
+ return (lower === 'true' || lower === 'false' || lower === '0' || lower === '1');
37
+ }
38
+ return false;
39
+ };
40
+ /**
41
+ * Converts any value to boolean with various strategies
42
+ * @param value - The value to convert
43
+ * @param strategy - Conversion strategy (default: 'strict')
44
+ * - 'strict': Only true/false, 1/0, "true"/"false", "1"/"0" are converted
45
+ * - 'truthy': JavaScript truthy values become true
46
+ * - 'falsy': JavaScript falsy values become false
47
+ * - 'string': Parse string representations strictly
48
+ * - 'number': Parse number representations strictly
49
+ * @returns Converted boolean
50
+ * @throws {Error} If value cannot be converted with strict strategy
51
+ * @example
52
+ * toBoolean("true") // true
53
+ * toBoolean(1) // true
54
+ * toBoolean("yes", "strict") // throws Error
55
+ * toBoolean("yes", "truthy") // true (non-empty string is truthy)
56
+ */
57
+ export const toBoolean = (value, strategy = 'strict', debug = false) => {
58
+ // Handle null/undefined
59
+ // if (debug) {
60
+ // console.log('null value', strategy, value);
61
+ // }
62
+ if (value === null) {
63
+ if (strategy === 'strict') {
64
+ throw new Error(`Cannot convert ${value} to boolean with strict strategy`);
65
+ }
66
+ // return false;
67
+ }
68
+ // Handle boolean directly
69
+ if (typeof value === 'boolean') {
70
+ return value;
71
+ }
72
+ switch (strategy) {
73
+ case 'strict':
74
+ return convertStrict(value);
75
+ case 'truthy':
76
+ return Boolean(value);
77
+ case 'falsy':
78
+ return convertFalsy(value);
79
+ // return !convertFalsy(value);
80
+ case 'string':
81
+ return convertFromString(value);
82
+ case 'number':
83
+ return convertFromNumber(value);
84
+ default:
85
+ return Boolean(value);
86
+ }
87
+ };
88
+ /**
89
+ * Strict conversion for toBoolean
90
+ */
91
+ const convertStrict = (_value) => {
92
+ const value = typeof _value === 'string' ? _value.trim().toLowerCase() : _value;
93
+ if (value === 1 || value === '1')
94
+ return true;
95
+ if (value === 0 || value === '0')
96
+ return false;
97
+ if (typeof value === 'string') {
98
+ const trimmed = value.trim().toLowerCase();
99
+ if (trimmed === 'true')
100
+ return true;
101
+ if (trimmed === 'false')
102
+ return false;
103
+ throw new Error(`Cannot convert string "${value}" to boolean with strict strategy`);
104
+ }
105
+ if (value === true)
106
+ return true;
107
+ if (value === false)
108
+ return false;
109
+ throw new Error(`Cannot convert ${typeof value} to boolean with strict strategy`);
110
+ };
111
+ /**
112
+ * Falsy conversion for toBoolean
113
+ */
114
+ const convertFalsy = (value) => {
115
+ if (typeof value === 'string') {
116
+ const trimmed = value.trim().toLowerCase();
117
+ if (trimmed === '' ||
118
+ trimmed === '0' ||
119
+ trimmed === 'false' ||
120
+ trimmed === 'null' ||
121
+ trimmed === 'undefined' ||
122
+ trimmed === 'nan') {
123
+ return false;
124
+ }
125
+ return true;
126
+ }
127
+ if (typeof value === 'number') {
128
+ if (value === 0 || isNaN(value))
129
+ return false;
130
+ return true;
131
+ }
132
+ return Boolean(value);
133
+ };
134
+ /**
135
+ * String conversion for toBoolean
136
+ */
137
+ const convertFromString = (value) => {
138
+ if (typeof value !== 'string') {
139
+ throw new Error(`String strategy requires string input, got ${typeof value}`);
140
+ }
141
+ const trimmed = value.trim().toLowerCase();
142
+ // True values
143
+ if (['true', 'yes', 'y', 'on', '1', 'enabled', 'enable', 'active'].includes(trimmed)) {
144
+ return true;
145
+ }
146
+ // False values
147
+ if ([
148
+ 'false',
149
+ 'no',
150
+ 'n',
151
+ 'off',
152
+ '0',
153
+ 'disabled',
154
+ 'disable',
155
+ 'inactive',
156
+ ].includes(trimmed)) {
157
+ return false;
158
+ }
159
+ // Try to parse as number
160
+ if (!isNaN(Number(trimmed))) {
161
+ return Number(trimmed) !== 0;
162
+ }
163
+ throw new Error(`Cannot convert string "${value}" to boolean`);
164
+ };
165
+ /**
166
+ * Number conversion for toBoolean
167
+ */
168
+ const convertFromNumber = (value) => {
169
+ if (typeof value !== 'number') {
170
+ throw new Error(`Number strategy requires number input, got ${typeof value}`);
171
+ }
172
+ if (isNaN(value))
173
+ return false;
174
+ if (value === 0)
175
+ return false;
176
+ if (value === 1)
177
+ return true;
178
+ // For other numbers, non-zero is truthy
179
+ return value !== 0;
180
+ };
181
+ /**
182
+ * Safely converts any value to boolean with fallback
183
+ * @param value - The value to convert
184
+ * @param fallback - Fallback value if conversion fails (default: false)
185
+ * @returns Converted boolean or fallback
186
+ * @example
187
+ * safeToBoolean("true") // true
188
+ * safeToBoolean("invalid", true) // true (fallback)
189
+ * safeToBoolean(null, false) // false
190
+ */
191
+ export const safeToBoolean = (value, fallback) => {
192
+ try {
193
+ return toBoolean(value, 'strict');
194
+ }
195
+ catch {
196
+ return fallback !== undefined ? fallback : false;
197
+ }
198
+ };
199
+ /**
200
+ * Checks if all values are truthy (logical AND)
201
+ * @param values - Array of values to check
202
+ * @returns True if all values are truthy
203
+ * @example
204
+ * all([true, 1, "hello"]) // true
205
+ * all([true, false]) // false
206
+ */
207
+ export const all = (values) => {
208
+ if (!Array.isArray(values) || values.length === 0) {
209
+ return false;
210
+ }
211
+ for (const value of values) {
212
+ if (!Boolean(value)) {
213
+ return false;
214
+ }
215
+ }
216
+ return true;
217
+ };
218
+ /**
219
+ * Checks if any value is truthy (logical OR)
220
+ * @param values - Array of values to check
221
+ * @returns True if any value is truthy
222
+ * @example
223
+ * any([false, 0, "hello"]) // true
224
+ * any([false, 0, ""]) // false
225
+ */
226
+ export const any = (values) => {
227
+ if (!Array.isArray(values) || values.length === 0) {
228
+ return false;
229
+ }
230
+ for (const value of values) {
231
+ if (Boolean(value)) {
232
+ return true;
233
+ }
234
+ }
235
+ return false;
236
+ };
237
+ /**
238
+ * Checks if no values are truthy (logical NOR)
239
+ * @param values - Array of values to check
240
+ * @returns True if no values are truthy
241
+ * @example
242
+ * none([false, 0, ""]) // true
243
+ * none([false, true]) // false
244
+ */
245
+ export const none = (values) => {
246
+ return !any(values);
247
+ };
248
+ /**
249
+ * Logical NOT operation
250
+ * @param value - The value to negate
251
+ * @returns Negated boolean value
252
+ * @example
253
+ * not(true) // false
254
+ * not(false) // true
255
+ * not(1) // false (truthy becomes false)
256
+ */
257
+ export const not = (value) => {
258
+ return !Boolean(value);
259
+ };
260
+ /**
261
+ * Logical XOR operation (exclusive OR)
262
+ * Returns true if exactly one of the values is truthy
263
+ * @param values - Array of values to check
264
+ * @returns True if exactly one value is truthy
265
+ * @example
266
+ * xor([true, false]) // true
267
+ * xor([true, true]) // false
268
+ * xor([false, false]) // false
269
+ */
270
+ export const xor = (values) => {
271
+ if (!Array.isArray(values)) {
272
+ return false;
273
+ }
274
+ let truthyCount = 0;
275
+ for (const value of values) {
276
+ if (Boolean(value)) {
277
+ truthyCount++;
278
+ if (truthyCount > 1) {
279
+ return false; // Early exit if more than one truthy
280
+ }
281
+ }
282
+ }
283
+ return truthyCount === 1;
284
+ };
285
+ /**
286
+ * Logical NAND operation (NOT AND)
287
+ * Returns true unless all values are truthy
288
+ * @param values - Array of values to check
289
+ * @returns True unless all values are truthy
290
+ * @example
291
+ * nand([true, true]) // false
292
+ * nand([true, false]) // true
293
+ */
294
+ export const nand = (values) => {
295
+ return !all(values);
296
+ };
297
+ /**
298
+ * Logical NOR operation (NOT OR)
299
+ * Returns true only if all values are falsy
300
+ * @param values - Array of values to check
301
+ * @returns True only if all values are falsy
302
+ * @example
303
+ * nor([false, false]) // true
304
+ * nor([false, true]) // false
305
+ */
306
+ export const nor = (values) => {
307
+ return none(values);
308
+ };
309
+ /**
310
+ * Logical XNOR operation (equivalence)
311
+ * Returns true if all values are the same truthiness
312
+ * @param values - Array of values to check
313
+ * @returns True if all values have same truthiness
314
+ * @example
315
+ * xnor([true, true]) // true
316
+ * xnor([true, false]) // false
317
+ * xnor([false, false, false]) // true
318
+ */
319
+ export const xnor = (values) => {
320
+ if (!Array.isArray(values) || values.length === 0) {
321
+ return true;
322
+ }
323
+ const firstTruthy = Boolean(values[0]);
324
+ for (let i = 1; i < values.length; i++) {
325
+ if (Boolean(values[i]) !== firstTruthy) {
326
+ return false;
327
+ }
328
+ }
329
+ return true;
330
+ };
331
+ /**
332
+ * Counts truthy values in an array
333
+ * @param values - Array of values to count
334
+ * @returns Number of truthy values
335
+ * @example
336
+ * countTruthy([true, false, 1, 0, "hello"]) // 3
337
+ */
338
+ export const countTruthy = (values) => {
339
+ if (!Array.isArray(values)) {
340
+ return 0;
341
+ }
342
+ let count = 0;
343
+ for (const value of values) {
344
+ if (Boolean(value)) {
345
+ count++;
346
+ }
347
+ }
348
+ return count;
349
+ };
350
+ /**
351
+ * Counts falsy values in an array
352
+ * @param values - Array of values to count
353
+ * @returns Number of falsy values
354
+ * @example
355
+ * countFalsy([true, false, 0, "", null]) // 3
356
+ */
357
+ export const countFalsy = (values) => {
358
+ if (!Array.isArray(values)) {
359
+ return 0;
360
+ }
361
+ return values.length - countTruthy(values);
362
+ };
363
+ /**
364
+ * Creates a boolean toggle function
365
+ * @param initialState - Initial state (default: false)
366
+ * @returns Function that toggles and returns current state
367
+ * @example
368
+ * const toggle = createToggle();
369
+ * toggle() // true
370
+ * toggle() // false
371
+ * toggle() // true
372
+ */
373
+ export const createToggle = (initialState = false) => {
374
+ let state = initialState;
375
+ return () => {
376
+ state = !state;
377
+ return state;
378
+ };
379
+ };
380
+ /**
381
+ * Compares two values with various comparison operators
382
+ * @param a - First value
383
+ * @param b - Second value
384
+ * @param operator - Comparison operator
385
+ * @returns Result of comparison
386
+ * @example
387
+ * compare(5, 3, '>') // true
388
+ * compare(5, 5, '===') // false (different types)
389
+ * compare(5, '5', '==') // true
390
+ */
391
+ export const compare = (a, b, operator = '===') => {
392
+ switch (operator) {
393
+ case '==':
394
+ return a == b;
395
+ case '===':
396
+ return a === b;
397
+ case '!=':
398
+ return a != b;
399
+ case '!==':
400
+ return a !== b;
401
+ case '>':
402
+ return a > b;
403
+ case '<':
404
+ return a < b;
405
+ case '>=':
406
+ return a >= b;
407
+ case '<=':
408
+ return a <= b;
409
+ default:
410
+ throw new Error(`Unsupported operator: ${operator}`);
411
+ }
412
+ };
413
+ /**
414
+ * Creates a boolean condition checker with multiple comparisons
415
+ * @param value - The value to check
416
+ * @param checks - Array of comparison checks
417
+ * @returns True if all checks pass
418
+ * @example
419
+ * checkConditions(5, [
420
+ * { operator: '>', value: 0 },
421
+ * { operator: '<', value: 10 }
422
+ * ]) // true
423
+ */
424
+ export const checkConditions = (value, checks) => {
425
+ for (const check of checks) {
426
+ if (!compare(value, check.value, check.operator)) {
427
+ return false;
428
+ }
429
+ }
430
+ return true;
431
+ };
432
+ /**
433
+ * Validates that a value is within a boolean constraint
434
+ * @param value - The value to validate
435
+ * @param constraint - Constraint type
436
+ * @returns True if value meets constraint
437
+ * @example
438
+ * validateBooleanConstraint(true, 'required') // true
439
+ * validateBooleanConstraint(false, 'required') // false
440
+ * validateBooleanConstraint(undefined, 'optional') // true
441
+ */
442
+ export const validateBooleanConstraint = (value, constraint) => {
443
+ switch (constraint) {
444
+ case 'required':
445
+ return value === true;
446
+ case 'optional':
447
+ return value === true || value === false;
448
+ case 'true':
449
+ return value === true;
450
+ case 'false':
451
+ return value === false;
452
+ case 'truthy':
453
+ return Boolean(value);
454
+ case 'falsy':
455
+ return !Boolean(value);
456
+ default:
457
+ return false;
458
+ }
459
+ };
460
+ /**
461
+ * Generates random boolean value
462
+ * @param probability - Probability of returning true (0 to 1, default: 0.5)
463
+ * @returns Random boolean
464
+ * @example
465
+ * randomBoolean() // true or false with 50% probability
466
+ * randomBoolean(0.8) // true 80% of the time
467
+ */
468
+ export const randomBoolean = (probability = 0.5) => {
469
+ if (probability < 0 || probability > 1) {
470
+ throw new Error('Probability must be between 0 and 1');
471
+ }
472
+ if (probability === 0)
473
+ return false;
474
+ return Math.random() <= probability;
475
+ };
476
+ /**
477
+ * Debounces a boolean function
478
+ * @param fn - Function that returns boolean
479
+ * @param delay - Debounce delay in ms
480
+ * @returns Debounced function
481
+ */
482
+ export const debounceBoolean = (fn, delay) => {
483
+ let timeoutId;
484
+ let lastResult;
485
+ return (...args) => {
486
+ if (timeoutId) {
487
+ clearTimeout(timeoutId);
488
+ }
489
+ timeoutId = setTimeout(() => {
490
+ lastResult = fn(...args);
491
+ }, delay);
492
+ return lastResult;
493
+ };
494
+ };
495
+ /**
496
+ * Memoizes a boolean function
497
+ * @param fn - Function that returns boolean
498
+ * @returns Memoized function
499
+ */
500
+ export const memoizeBoolean = (fn) => {
501
+ const cache = new WeakMap();
502
+ return ((...args) => {
503
+ // Get a stable key for the cache
504
+ let keyObj = null;
505
+ let keyString = '';
506
+ // Find the first object argument to use as WeakMap key
507
+ for (let i = 0; i < args.length; i++) {
508
+ if (args[i] !== null && typeof args[i] === 'object') {
509
+ keyObj = args[i];
510
+ break;
511
+ }
512
+ }
513
+ // Create a string key for the remaining arguments
514
+ keyString = JSON.stringify(args);
515
+ if (keyObj) {
516
+ // Use a two-level cache with WeakMap -> Map for object arguments
517
+ let objCache = cache.get(keyObj);
518
+ if (!objCache) {
519
+ objCache = new Map();
520
+ cache.set(keyObj, objCache);
521
+ }
522
+ if (objCache.has(keyString)) {
523
+ return objCache.get(keyString);
524
+ }
525
+ const result = fn(...args);
526
+ objCache.set(keyString, result);
527
+ return result;
528
+ }
529
+ else {
530
+ // Fallback to string-only cache for primitive arguments
531
+ const stringCache = cache.get(Object.prototype) || new Map();
532
+ if (!cache.has(Object.prototype)) {
533
+ cache.set(Object.prototype, stringCache);
534
+ }
535
+ if (stringCache.has(keyString)) {
536
+ return stringCache.get(keyString);
537
+ }
538
+ const result = fn(...args);
539
+ stringCache.set(keyString, result);
540
+ return result;
541
+ }
542
+ });
543
+ };
544
+ /**
545
+ * Creates a boolean pipeline (function composition)
546
+ * @param functions - Array of functions that return boolean
547
+ * @returns Function that applies all functions with AND logic
548
+ * @example
549
+ * const pipeline = createPipeline([
550
+ * (x) => x > 0,
551
+ * (x) => x < 10,
552
+ * (x) => x % 2 === 0
553
+ * ]);
554
+ * pipeline(4) // true
555
+ * pipeline(5) // false
556
+ */
557
+ export const createPipeline = (functions) => {
558
+ return (value) => {
559
+ for (const fn of functions) {
560
+ if (!fn(value)) {
561
+ return false;
562
+ }
563
+ }
564
+ return true;
565
+ };
566
+ };
567
+ /**
568
+ * Type guard for boolean array
569
+ * @param value - Value to check
570
+ * @returns True if value is a boolean array
571
+ */
572
+ export const isBooleanArray = (value) => {
573
+ return (Array.isArray(value) &&
574
+ value.every((item) => item === true || item === false));
575
+ };
576
+ /**
577
+ * Type guard for boolean-like array
578
+ * @param value - Value to check
579
+ * @returns True if value is a boolean-like array
580
+ */
581
+ export const isBooleanLikeArray = (value) => {
582
+ return Array.isArray(value) && value.every((item) => isBooleanLike(item));
583
+ };
584
+ export const compareBoolean = (value, newValue) => {
585
+ const o = toBoolean(value);
586
+ const n = toBoolean(newValue);
587
+ return o !== n;
588
+ };
589
+ // Export all utilities
590
+ export default {
591
+ isBoolean,
592
+ isBooleanLike,
593
+ toBoolean,
594
+ safeToBoolean,
595
+ all,
596
+ any,
597
+ none,
598
+ not,
599
+ xor,
600
+ nand,
601
+ nor,
602
+ xnor,
603
+ countTruthy,
604
+ countFalsy,
605
+ createToggle,
606
+ compare,
607
+ checkConditions,
608
+ validateBooleanConstraint,
609
+ randomBoolean,
610
+ debounceBoolean,
611
+ memoizeBoolean,
612
+ createPipeline,
613
+ isBooleanArray,
614
+ isBooleanLikeArray,
615
+ };
@@ -0,0 +1 @@
1
+ var b=r=>r===!0||r===!1,i=r=>{if(r===!0||r===!1||r===0||r===1)return!0;if(typeof r=="string"){let e=r.toLowerCase().trim();return e==="true"||e==="false"||e==="0"||e==="1"}return!1},u=(r,e="strict",n=!1)=>{if(r===null&&e==="strict")throw new Error(`Cannot convert ${r} to boolean with strict strategy`);if(typeof r=="boolean")return r;switch(e){case"strict":return w(r);case"truthy":return!!r;case"falsy":return m(r);case"string":return h(r);case"number":return d(r);default:return!!r}},w=r=>{let e=typeof r=="string"?r.trim().toLowerCase():r;if(e===1||e==="1")return!0;if(e===0||e==="0")return!1;if(typeof e=="string"){let n=e.trim().toLowerCase();if(n==="true")return!0;if(n==="false")return!1;throw new Error(`Cannot convert string "${e}" to boolean with strict strategy`)}if(e===!0)return!0;if(e===!1)return!1;throw new Error(`Cannot convert ${typeof e} to boolean with strict strategy`)},m=r=>{if(typeof r=="string"){let e=r.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="null"||e==="undefined"||e==="nan")}return typeof r=="number"?!(r===0||isNaN(r)):!!r},h=r=>{if(typeof r!="string")throw new Error(`String strategy requires string input, got ${typeof r}`);let e=r.trim().toLowerCase();if(["true","yes","y","on","1","enabled","enable","active"].includes(e))return!0;if(["false","no","n","off","0","disabled","disable","inactive"].includes(e))return!1;if(!isNaN(Number(e)))return Number(e)!==0;throw new Error(`Cannot convert string "${r}" to boolean`)},d=r=>{if(typeof r!="number")throw new Error(`Number strategy requires number input, got ${typeof r}`);return isNaN(r)||r===0?!1:r===1?!0:r!==0},g=(r,e)=>{try{return u(r,"strict")}catch{return e!==void 0?e:!1}},f=r=>{if(!Array.isArray(r)||r.length===0)return!1;for(let e of r)if(!e)return!1;return!0},l=r=>{if(!Array.isArray(r)||r.length===0)return!1;for(let e of r)if(e)return!0;return!1},c=r=>!l(r),k=r=>!r,x=r=>{if(!Array.isArray(r))return!1;let e=0;for(let n of r)if(n&&(e++,e>1))return!1;return e===1},B=r=>!f(r),C=r=>c(r),A=r=>{if(!Array.isArray(r)||r.length===0)return!0;let e=!!r[0];for(let n=1;n<r.length;n++)if(!!r[n]!==e)return!1;return!0},y=r=>{if(!Array.isArray(r))return 0;let e=0;for(let n of r)n&&e++;return e},T=r=>Array.isArray(r)?r.length-y(r):0,N=(r=!1)=>{let e=r;return()=>(e=!e,e)},p=(r,e,n="===")=>{switch(n){case"==":return r==e;case"===":return r===e;case"!=":return r!=e;case"!==":return r!==e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e;default:throw new Error(`Unsupported operator: ${n}`)}},j=(r,e)=>{for(let n of e)if(!p(r,n.value,n.operator))return!1;return!0},S=(r,e)=>{switch(e){case"required":return r===!0;case"optional":return r===!0||r===!1;case"true":return r===!0;case"false":return r===!1;case"truthy":return!!r;case"falsy":return!r;default:return!1}},E=(r=.5)=>{if(r<0||r>1)throw new Error("Probability must be between 0 and 1");return r===0?!1:Math.random()<=r},L=(r,e)=>{let n,o;return(...a)=>(n&&clearTimeout(n),n=setTimeout(()=>{o=r(...a)},e),o)},O=r=>{let e=new WeakMap;return((...n)=>{let o=null,a="";for(let t=0;t<n.length;t++)if(n[t]!==null&&typeof n[t]=="object"){o=n[t];break}if(a=JSON.stringify(n),o){let t=e.get(o);if(t||(t=new Map,e.set(o,t)),t.has(a))return t.get(a);let s=r(...n);return t.set(a,s),s}else{let t=e.get(Object.prototype)||new Map;if(e.has(Object.prototype)||e.set(Object.prototype,t),t.has(a))return t.get(a);let s=r(...n);return t.set(a,s),s}})},$=r=>e=>{for(let n of r)if(!n(e))return!1;return!0},M=r=>Array.isArray(r)&&r.every(e=>e===!0||e===!1),q=r=>Array.isArray(r)&&r.every(e=>i(e)),F=(r,e)=>{let n=u(r),o=u(e);return n!==o},K={isBoolean:b,isBooleanLike:i,toBoolean:u,safeToBoolean:g,all:f,any:l,none:c,not:k,xor:x,nand:B,nor:C,xnor:A,countTruthy:y,countFalsy:T,createToggle:N,compare:p,checkConditions:j,validateBooleanConstraint:S,randomBoolean:E,debounceBoolean:L,memoizeBoolean:O,createPipeline:$,isBooleanArray:M,isBooleanLikeArray:q};export{f as all,l as any,j as checkConditions,p as compare,F as compareBoolean,T as countFalsy,y as countTruthy,$ as createPipeline,N as createToggle,L as debounceBoolean,K as default,b as isBoolean,M as isBooleanArray,i as isBooleanLike,q as isBooleanLikeArray,O as memoizeBoolean,B as nand,c as none,C as nor,k as not,E as randomBoolean,g as safeToBoolean,u as toBoolean,S as validateBooleanConstraint,A as xnor,x as xor};
@@ -0,0 +1 @@
1
+ "use strict";var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(r,e)=>{for(var n in e)i(r,n,{get:e[n],enumerable:!0})},g=(r,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!h.call(r,o)&&o!==n&&i(r,o,{get:()=>e[o],enumerable:!(a=w(e,o))||a.enumerable});return r};var x=r=>g(i({},"__esModule",{value:!0}),r);var U={};d(U,{all:()=>l,any:()=>c,checkConditions:()=>q,compare:()=>b,compareBoolean:()=>R,countFalsy:()=>$,countTruthy:()=>p,createPipeline:()=>V,createToggle:()=>M,debounceBoolean:()=>J,isBoolean:()=>k,isBooleanArray:()=>z,isBooleanLike:()=>f,isBooleanLikeArray:()=>I,memoizeBoolean:()=>P,nand:()=>E,none:()=>y,nor:()=>L,not:()=>j,randomBoolean:()=>K,safeToBoolean:()=>N,toBoolean:()=>u,validateBooleanConstraint:()=>F,xnor:()=>O,xor:()=>S});module.exports=x(U);var k=r=>r===!0||r===!1,f=r=>{if(r===!0||r===!1||r===0||r===1)return!0;if(typeof r=="string"){let e=r.toLowerCase().trim();return e==="true"||e==="false"||e==="0"||e==="1"}return!1},u=(r,e="strict",n=!1)=>{if(r===null&&e==="strict")throw new Error(`Cannot convert ${r} to boolean with strict strategy`);if(typeof r=="boolean")return r;switch(e){case"strict":return B(r);case"truthy":return!!r;case"falsy":return C(r);case"string":return A(r);case"number":return T(r);default:return!!r}},B=r=>{let e=typeof r=="string"?r.trim().toLowerCase():r;if(e===1||e==="1")return!0;if(e===0||e==="0")return!1;if(typeof e=="string"){let n=e.trim().toLowerCase();if(n==="true")return!0;if(n==="false")return!1;throw new Error(`Cannot convert string "${e}" to boolean with strict strategy`)}if(e===!0)return!0;if(e===!1)return!1;throw new Error(`Cannot convert ${typeof e} to boolean with strict strategy`)},C=r=>{if(typeof r=="string"){let e=r.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="null"||e==="undefined"||e==="nan")}return typeof r=="number"?!(r===0||isNaN(r)):!!r},A=r=>{if(typeof r!="string")throw new Error(`String strategy requires string input, got ${typeof r}`);let e=r.trim().toLowerCase();if(["true","yes","y","on","1","enabled","enable","active"].includes(e))return!0;if(["false","no","n","off","0","disabled","disable","inactive"].includes(e))return!1;if(!isNaN(Number(e)))return Number(e)!==0;throw new Error(`Cannot convert string "${r}" to boolean`)},T=r=>{if(typeof r!="number")throw new Error(`Number strategy requires number input, got ${typeof r}`);return isNaN(r)||r===0?!1:r===1?!0:r!==0},N=(r,e)=>{try{return u(r,"strict")}catch{return e!==void 0?e:!1}},l=r=>{if(!Array.isArray(r)||r.length===0)return!1;for(let e of r)if(!e)return!1;return!0},c=r=>{if(!Array.isArray(r)||r.length===0)return!1;for(let e of r)if(e)return!0;return!1},y=r=>!c(r),j=r=>!r,S=r=>{if(!Array.isArray(r))return!1;let e=0;for(let n of r)if(n&&(e++,e>1))return!1;return e===1},E=r=>!l(r),L=r=>y(r),O=r=>{if(!Array.isArray(r)||r.length===0)return!0;let e=!!r[0];for(let n=1;n<r.length;n++)if(!!r[n]!==e)return!1;return!0},p=r=>{if(!Array.isArray(r))return 0;let e=0;for(let n of r)n&&e++;return e},$=r=>Array.isArray(r)?r.length-p(r):0,M=(r=!1)=>{let e=r;return()=>(e=!e,e)},b=(r,e,n="===")=>{switch(n){case"==":return r==e;case"===":return r===e;case"!=":return r!=e;case"!==":return r!==e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e;default:throw new Error(`Unsupported operator: ${n}`)}},q=(r,e)=>{for(let n of e)if(!b(r,n.value,n.operator))return!1;return!0},F=(r,e)=>{switch(e){case"required":return r===!0;case"optional":return r===!0||r===!1;case"true":return r===!0;case"false":return r===!1;case"truthy":return!!r;case"falsy":return!r;default:return!1}},K=(r=.5)=>{if(r<0||r>1)throw new Error("Probability must be between 0 and 1");return r===0?!1:Math.random()<=r},J=(r,e)=>{let n,a;return(...o)=>(n&&clearTimeout(n),n=setTimeout(()=>{a=r(...o)},e),a)},P=r=>{let e=new WeakMap;return((...n)=>{let a=null,o="";for(let t=0;t<n.length;t++)if(n[t]!==null&&typeof n[t]=="object"){a=n[t];break}if(o=JSON.stringify(n),a){let t=e.get(a);if(t||(t=new Map,e.set(a,t)),t.has(o))return t.get(o);let s=r(...n);return t.set(o,s),s}else{let t=e.get(Object.prototype)||new Map;if(e.has(Object.prototype)||e.set(Object.prototype,t),t.has(o))return t.get(o);let s=r(...n);return t.set(o,s),s}})},V=r=>e=>{for(let n of r)if(!n(e))return!1;return!0},z=r=>Array.isArray(r)&&r.every(e=>e===!0||e===!1),I=r=>Array.isArray(r)&&r.every(e=>f(e)),R=(r,e)=>{let n=u(r),a=u(e);return n!==a};
@@ -0,0 +1,3 @@
1
+ export * from './boolean.js';
2
+ export * from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/primitive/boolean/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './boolean.js';
2
+ export * from './types.js';
@@ -0,0 +1 @@
1
+ var d=r=>r===!0||r===!1,i=r=>{if(r===!0||r===!1||r===0||r===1)return!0;if(typeof r=="string"){let e=r.toLowerCase().trim();return e==="true"||e==="false"||e==="0"||e==="1"}return!1},u=(r,e="strict",n=!1)=>{if(r===null&&e==="strict")throw new Error(`Cannot convert ${r} to boolean with strict strategy`);if(typeof r=="boolean")return r;switch(e){case"strict":return f(r);case"truthy":return!!r;case"falsy":return l(r);case"string":return c(r);case"number":return y(r);default:return!!r}},f=r=>{let e=typeof r=="string"?r.trim().toLowerCase():r;if(e===1||e==="1")return!0;if(e===0||e==="0")return!1;if(typeof e=="string"){let n=e.trim().toLowerCase();if(n==="true")return!0;if(n==="false")return!1;throw new Error(`Cannot convert string "${e}" to boolean with strict strategy`)}if(e===!0)return!0;if(e===!1)return!1;throw new Error(`Cannot convert ${typeof e} to boolean with strict strategy`)},l=r=>{if(typeof r=="string"){let e=r.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="null"||e==="undefined"||e==="nan")}return typeof r=="number"?!(r===0||isNaN(r)):!!r},c=r=>{if(typeof r!="string")throw new Error(`String strategy requires string input, got ${typeof r}`);let e=r.trim().toLowerCase();if(["true","yes","y","on","1","enabled","enable","active"].includes(e))return!0;if(["false","no","n","off","0","disabled","disable","inactive"].includes(e))return!1;if(!isNaN(Number(e)))return Number(e)!==0;throw new Error(`Cannot convert string "${r}" to boolean`)},y=r=>{if(typeof r!="number")throw new Error(`Number strategy requires number input, got ${typeof r}`);return isNaN(r)||r===0?!1:r===1?!0:r!==0},g=(r,e)=>{try{return u(r,"strict")}catch{return e!==void 0?e:!1}},p=r=>{if(!Array.isArray(r)||r.length===0)return!1;for(let e of r)if(!e)return!1;return!0},b=r=>{if(!Array.isArray(r)||r.length===0)return!1;for(let e of r)if(e)return!0;return!1},w=r=>!b(r),x=r=>!r,k=r=>{if(!Array.isArray(r))return!1;let e=0;for(let n of r)if(n&&(e++,e>1))return!1;return e===1},B=r=>!p(r),C=r=>w(r),A=r=>{if(!Array.isArray(r)||r.length===0)return!0;let e=!!r[0];for(let n=1;n<r.length;n++)if(!!r[n]!==e)return!1;return!0},m=r=>{if(!Array.isArray(r))return 0;let e=0;for(let n of r)n&&e++;return e},T=r=>Array.isArray(r)?r.length-m(r):0,N=(r=!1)=>{let e=r;return()=>(e=!e,e)},h=(r,e,n="===")=>{switch(n){case"==":return r==e;case"===":return r===e;case"!=":return r!=e;case"!==":return r!==e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e;default:throw new Error(`Unsupported operator: ${n}`)}},j=(r,e)=>{for(let n of e)if(!h(r,n.value,n.operator))return!1;return!0},S=(r,e)=>{switch(e){case"required":return r===!0;case"optional":return r===!0||r===!1;case"true":return r===!0;case"false":return r===!1;case"truthy":return!!r;case"falsy":return!r;default:return!1}},E=(r=.5)=>{if(r<0||r>1)throw new Error("Probability must be between 0 and 1");return r===0?!1:Math.random()<=r},L=(r,e)=>{let n,o;return(...a)=>(n&&clearTimeout(n),n=setTimeout(()=>{o=r(...a)},e),o)},O=r=>{let e=new WeakMap;return((...n)=>{let o=null,a="";for(let t=0;t<n.length;t++)if(n[t]!==null&&typeof n[t]=="object"){o=n[t];break}if(a=JSON.stringify(n),o){let t=e.get(o);if(t||(t=new Map,e.set(o,t)),t.has(a))return t.get(a);let s=r(...n);return t.set(a,s),s}else{let t=e.get(Object.prototype)||new Map;if(e.has(Object.prototype)||e.set(Object.prototype,t),t.has(a))return t.get(a);let s=r(...n);return t.set(a,s),s}})},$=r=>e=>{for(let n of r)if(!n(e))return!1;return!0},M=r=>Array.isArray(r)&&r.every(e=>e===!0||e===!1),q=r=>Array.isArray(r)&&r.every(e=>i(e)),F=(r,e)=>{let n=u(r),o=u(e);return n!==o};export{p as all,b as any,j as checkConditions,h as compare,F as compareBoolean,T as countFalsy,m as countTruthy,$ as createPipeline,N as createToggle,L as debounceBoolean,d as isBoolean,M as isBooleanArray,i as isBooleanLike,q as isBooleanLikeArray,O as memoizeBoolean,B as nand,w as none,C as nor,x as not,E as randomBoolean,g as safeToBoolean,u as toBoolean,S as validateBooleanConstraint,A as xnor,k as xor};
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var u=(e,o,n,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of l(o))!i.call(e,r)&&r!==n&&a(e,r,{get:()=>o[r],enumerable:!(t=p(o,r))||t.enumerable});return e};var b=e=>u(a({},"__esModule",{value:!0}),e);var C={};module.exports=b(C);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Type for truthy values that can be converted to boolean
3
+ */
4
+ export type BooleanConvertible = string | number | boolean | null | undefined | object | any[];
5
+ /**
6
+ * Type for strict boolean values
7
+ */
8
+ export type StrictBoolean = boolean | 0 | 1 | 'true' | 'false' | '0' | '1';
9
+ export type ComparatorOperator = '>' | '<' | '>=' | '<=' | '==' | '===' | '!=' | '!==';
10
+ export interface ComparatorCondition {
11
+ value: unknown;
12
+ operator: ComparatorOperator;
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/primitive/boolean/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,MAAM,GACN,GAAG,EAAE,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,OAAO,GAAG,GAAG,GAAG,GAAG,CAAC;AAE3E,MAAM,MAAM,kBAAkB,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAA;AACtF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,kBAAkB,CAAC;CAC9B"}
@@ -0,0 +1 @@
1
+ export {};
File without changes