full-utils 1.0.10 → 2.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 (153) hide show
  1. package/README.md +189 -1
  2. package/dist/index.cjs +1039 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +4495 -0
  5. package/dist/index.d.ts +4495 -48
  6. package/dist/index.js +977 -97
  7. package/dist/index.js.map +1 -1
  8. package/package.json +64 -18
  9. package/dist/src/from/fromJSON.d.ts +0 -5
  10. package/dist/src/from/fromJSON.js +0 -71
  11. package/dist/src/from/fromJSON.js.map +0 -1
  12. package/dist/src/from/fromTimestamp.d.ts +0 -6
  13. package/dist/src/from/fromTimestamp.js +0 -8
  14. package/dist/src/from/fromTimestamp.js.map +0 -1
  15. package/dist/src/index.d.ts +0 -48
  16. package/dist/src/index.js +0 -98
  17. package/dist/src/index.js.map +0 -1
  18. package/dist/src/is/isArr.d.ts +0 -1
  19. package/dist/src/is/isArr.js +0 -7
  20. package/dist/src/is/isArr.js.map +0 -1
  21. package/dist/src/is/isArrFilled.d.ts +0 -1
  22. package/dist/src/is/isArrFilled.js +0 -8
  23. package/dist/src/is/isArrFilled.js.map +0 -1
  24. package/dist/src/is/isBool.d.ts +0 -1
  25. package/dist/src/is/isBool.js +0 -7
  26. package/dist/src/is/isBool.js.map +0 -1
  27. package/dist/src/is/isDate.d.ts +0 -1
  28. package/dist/src/is/isDate.js +0 -16
  29. package/dist/src/is/isDate.js.map +0 -1
  30. package/dist/src/is/isEmail.d.ts +0 -1
  31. package/dist/src/is/isEmail.js +0 -9
  32. package/dist/src/is/isEmail.js.map +0 -1
  33. package/dist/src/is/isExists.d.ts +0 -1
  34. package/dist/src/is/isExists.js +0 -7
  35. package/dist/src/is/isExists.js.map +0 -1
  36. package/dist/src/is/isFunc.d.ts +0 -1
  37. package/dist/src/is/isFunc.js +0 -7
  38. package/dist/src/is/isFunc.js.map +0 -1
  39. package/dist/src/is/isIp.d.ts +0 -1
  40. package/dist/src/is/isIp.js +0 -13
  41. package/dist/src/is/isIp.js.map +0 -1
  42. package/dist/src/is/isMac.d.ts +0 -1
  43. package/dist/src/is/isMac.js +0 -8
  44. package/dist/src/is/isMac.js.map +0 -1
  45. package/dist/src/is/isNum.d.ts +0 -1
  46. package/dist/src/is/isNum.js +0 -7
  47. package/dist/src/is/isNum.js.map +0 -1
  48. package/dist/src/is/isNumFloat.d.ts +0 -1
  49. package/dist/src/is/isNumFloat.js +0 -8
  50. package/dist/src/is/isNumFloat.js.map +0 -1
  51. package/dist/src/is/isNumN.d.ts +0 -1
  52. package/dist/src/is/isNumN.js +0 -8
  53. package/dist/src/is/isNumN.js.map +0 -1
  54. package/dist/src/is/isNumNZ.d.ts +0 -1
  55. package/dist/src/is/isNumNZ.js +0 -8
  56. package/dist/src/is/isNumNZ.js.map +0 -1
  57. package/dist/src/is/isNumP.d.ts +0 -1
  58. package/dist/src/is/isNumP.js +0 -8
  59. package/dist/src/is/isNumP.js.map +0 -1
  60. package/dist/src/is/isNumPZ.d.ts +0 -1
  61. package/dist/src/is/isNumPZ.js +0 -8
  62. package/dist/src/is/isNumPZ.js.map +0 -1
  63. package/dist/src/is/isObj.d.ts +0 -1
  64. package/dist/src/is/isObj.js +0 -10
  65. package/dist/src/is/isObj.js.map +0 -1
  66. package/dist/src/is/isObjFilled.d.ts +0 -1
  67. package/dist/src/is/isObjFilled.js +0 -8
  68. package/dist/src/is/isObjFilled.js.map +0 -1
  69. package/dist/src/is/isPassword.d.ts +0 -10
  70. package/dist/src/is/isPassword.js +0 -26
  71. package/dist/src/is/isPassword.js.map +0 -1
  72. package/dist/src/is/isPhone.d.ts +0 -1
  73. package/dist/src/is/isPhone.js +0 -35
  74. package/dist/src/is/isPhone.js.map +0 -1
  75. package/dist/src/is/isStr.d.ts +0 -1
  76. package/dist/src/is/isStr.js +0 -7
  77. package/dist/src/is/isStr.js.map +0 -1
  78. package/dist/src/is/isStrBool.d.ts +0 -1
  79. package/dist/src/is/isStrBool.js +0 -12
  80. package/dist/src/is/isStrBool.js.map +0 -1
  81. package/dist/src/is/isStrFilled.d.ts +0 -1
  82. package/dist/src/is/isStrFilled.js +0 -8
  83. package/dist/src/is/isStrFilled.js.map +0 -1
  84. package/dist/src/is/isStrOrderType.d.ts +0 -1
  85. package/dist/src/is/isStrOrderType.js +0 -12
  86. package/dist/src/is/isStrOrderType.js.map +0 -1
  87. package/dist/src/is/isVar.d.ts +0 -1
  88. package/dist/src/is/isVar.js +0 -8
  89. package/dist/src/is/isVar.js.map +0 -1
  90. package/dist/src/net/netTCP.d.ts +0 -6
  91. package/dist/src/net/netTCP.js +0 -52
  92. package/dist/src/net/netTCP.js.map +0 -1
  93. package/dist/src/to/toArrFuncArgs.d.ts +0 -1
  94. package/dist/src/to/toArrFuncArgs.js +0 -139
  95. package/dist/src/to/toArrFuncArgs.js.map +0 -1
  96. package/dist/src/to/toBool.d.ts +0 -1
  97. package/dist/src/to/toBool.js +0 -23
  98. package/dist/src/to/toBool.js.map +0 -1
  99. package/dist/src/to/toCellDate.d.ts +0 -1
  100. package/dist/src/to/toCellDate.js +0 -12
  101. package/dist/src/to/toCellDate.js.map +0 -1
  102. package/dist/src/to/toDateStr.d.ts +0 -1
  103. package/dist/src/to/toDateStr.js +0 -14
  104. package/dist/src/to/toDateStr.js.map +0 -1
  105. package/dist/src/to/toGB.d.ts +0 -1
  106. package/dist/src/to/toGB.js +0 -47
  107. package/dist/src/to/toGB.js.map +0 -1
  108. package/dist/src/to/toGH.d.ts +0 -1
  109. package/dist/src/to/toGH.js +0 -36
  110. package/dist/src/to/toGH.js.map +0 -1
  111. package/dist/src/to/toInetAton.d.ts +0 -1
  112. package/dist/src/to/toInetAton.js +0 -18
  113. package/dist/src/to/toInetAton.js.map +0 -1
  114. package/dist/src/to/toInetNtoa.d.ts +0 -1
  115. package/dist/src/to/toInetNtoa.js +0 -16
  116. package/dist/src/to/toInetNtoa.js.map +0 -1
  117. package/dist/src/to/toJSON.d.ts +0 -1
  118. package/dist/src/to/toJSON.js +0 -14
  119. package/dist/src/to/toJSON.js.map +0 -1
  120. package/dist/src/to/toLower.d.ts +0 -1
  121. package/dist/src/to/toLower.js +0 -14
  122. package/dist/src/to/toLower.js.map +0 -1
  123. package/dist/src/to/toNull.d.ts +0 -1
  124. package/dist/src/to/toNull.js +0 -11
  125. package/dist/src/to/toNull.js.map +0 -1
  126. package/dist/src/to/toNum.d.ts +0 -1
  127. package/dist/src/to/toNum.js +0 -40
  128. package/dist/src/to/toNum.js.map +0 -1
  129. package/dist/src/to/toPhone.d.ts +0 -1
  130. package/dist/src/to/toPhone.js +0 -24
  131. package/dist/src/to/toPhone.js.map +0 -1
  132. package/dist/src/to/toPoolName.d.ts +0 -1
  133. package/dist/src/to/toPoolName.js +0 -19
  134. package/dist/src/to/toPoolName.js.map +0 -1
  135. package/dist/src/to/toPortions.d.ts +0 -1
  136. package/dist/src/to/toPortions.js +0 -16
  137. package/dist/src/to/toPortions.js.map +0 -1
  138. package/dist/src/to/toRangeip.d.ts +0 -1
  139. package/dist/src/to/toRangeip.js +0 -24
  140. package/dist/src/to/toRangeip.js.map +0 -1
  141. package/dist/src/to/toSqlUpdateMany.d.ts +0 -1
  142. package/dist/src/to/toSqlUpdateMany.js +0 -39
  143. package/dist/src/to/toSqlUpdateMany.js.map +0 -1
  144. package/dist/src/to/toTimestamp.d.ts +0 -6
  145. package/dist/src/to/toTimestamp.js +0 -11
  146. package/dist/src/to/toTimestamp.js.map +0 -1
  147. package/dist/src/to/toTrim.d.ts +0 -1
  148. package/dist/src/to/toTrim.js +0 -10
  149. package/dist/src/to/toTrim.js.map +0 -1
  150. package/dist/src/to/toUndefined.d.ts +0 -1
  151. package/dist/src/to/toUndefined.js +0 -11
  152. package/dist/src/to/toUndefined.js.map +0 -1
  153. package/dist/tsconfig.build.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -1,2 +1,190 @@
1
1
  # full-utils
2
- ## A set of pure functions for all occasions.
2
+ Lightweight, dependency-free collection of pure TypeScript/JavaScript utility functions for everyday development.
3
+ It’s designed to be clear, fast, and easy to use — both in Node.js and in browser environments.
4
+
5
+ Whether you work with strings, numbers, dates, IPs, JSON, arrays, or type checks, this package provides you with a well-documented, consistent, and predictable API.
6
+
7
+ ## Installation
8
+ ```bash
9
+ # with npm
10
+ npm install full-utils
11
+
12
+ # or with yarn
13
+ yarn add full-utils
14
+
15
+ # or with pnpm
16
+ pnpm add full-utils
17
+
18
+ ```
19
+ ## Works in:
20
+ - Node.js (CommonJS & ESM)
21
+ - Browser / Front-end
22
+ - TypeScript or plain JavaScript
23
+
24
+ ## Concept
25
+
26
+ full-utils follows a simple philosophy:
27
+ Small, pure, and type-safe utilities — reusable across any kind of project, from scripts to large applications.
28
+
29
+ All functions:
30
+ - Are pure (no side effects)
31
+ - Include TypeScript typings
32
+ - Have clear naming
33
+ - Are documented via TypeDoc
34
+ - Work without any external dependencies
35
+
36
+ ## Documentation
37
+ Full API documentation:
38
+ - full-utils.docs.ihor.bielchenko.com
39
+
40
+ ## Quick Example
41
+ ```javascript
42
+ import { isStrFilled, formatDateToString, rangeIPv4 } from 'full-utils';
43
+
44
+ // Check if a string has content
45
+ console.log(isStrFilled('Hello')); // true
46
+
47
+ // Format current date as 'YYYY-MM-DD HH:mm:ss'
48
+ console.log(formatDateToString(new Date()));
49
+
50
+ // Generate all IPs in a range
51
+ for (const ip of rangeIPv4('192.168.0.1', '192.168.0.5')) {
52
+ console.log(ip);
53
+ }
54
+
55
+ ```
56
+
57
+ ## Modules Overview
58
+ ### Number utilities (/num)
59
+ Work with numbers precisely — including BigInt-based fixed decimals.
60
+
61
+ | Function | Description |
62
+ | ----------------------------------------- | ---------------------------------------------------------- |
63
+ | `formatToNum` | Parse strings/numbers to normalized numeric values. |
64
+ | `parseToFixedDecimal` | Convert any input to a precise fixed-decimal structure. |
65
+ | `roundFixedDecimal` | Round a fixed-decimal number using half-up or trunc modes. |
66
+ | `convertExponentialToParts` | Convert exponential notation into decimal components. |
67
+ | `fixedDecimalToNum` / `fixedDecimalToStr` | Convert precise decimals to number or string. |
68
+ | `changeFixedDecimalScale` | Increase or decrease the scale of a fixed decimal. |
69
+
70
+ ### Date utilities (/date)
71
+ | Function | Description |
72
+ | ----------------------------------- | ------------------------------------------------------- |
73
+ | `floorDateToMinutes` | Floor date to the nearest time step (e.g. every 5 min). |
74
+ | `formatDateToString` | Convert a Date to `'YYYY-MM-DD HH:mm:ss'` string. |
75
+ | `secondsToParts` / `partsToSeconds` | Convert between seconds and time components. |
76
+
77
+ ### IP utilities (/ip-addr)
78
+ | Function | Description |
79
+ | ----------------------------- | --------------------------------------------------- |
80
+ | `parseIPv4` / `toIPv4` | Parse or format IPv4 addresses. |
81
+ | `cidrToRange` | Convert a CIDR (e.g. `192.168.0.0/24`) to IP range. |
82
+ | `rangeIPv4` | Generate an iterator of IP addresses in range. |
83
+ | `rangeIPv4ToArr` | Materialize the range as an array. |
84
+ | `ipAddrToNum` / `numToIpAddr` | Convert between IPv4 and integer. |
85
+
86
+ ### Type & Value checkers (/is)
87
+ Simple and strict predicates like isStr, isNum, isObjFilled, isFunc, etc.
88
+
89
+ | Function | Checks if... |
90
+ | ------------------------------------------ | --------------------------------------------- |
91
+ | `isStr`, `isStrFilled` | Value is a string (optionally non-empty). |
92
+ | `isNum`, `isNumP`, `isNumNZ`, `isNumFloat` | Numeric type and positivity/zero constraints. |
93
+ | `isArr`, `isArrFilled` | Array exists and optionally has elements. |
94
+ | `isBool`, `isStrBool` | Boolean or boolean-like string. |
95
+ | `isIpAddr`, `isMacAddr` | Valid network address formats. |
96
+ | `isObj`, `isObjFilled` | Object is plain and not empty. |
97
+ | `isFunc`, `isVar` | Function or valid variable identifier. |
98
+ | `isEmail`, `isPhone`, `isPassword` | Common data validation helpers. |
99
+
100
+ ### Array utilities (/arr)
101
+ | Function | Description |
102
+ | --------------------- | -------------------------------------------------- |
103
+ | `formatStrToFuncArgs` | Convert a comma-separated string to argument list. |
104
+ | `splitArrToPortions` | Split large arrays into chunks of fixed size. |
105
+
106
+ ### String utilities (/str)
107
+ | Function | Description |
108
+ | ----------------------------------- | ---------------------------------------- |
109
+ | `formatToTrim` | Trim string safely. |
110
+ | `formatToLowerCase` | Lowercase string safely. |
111
+ | `formatToPhone` | Normalize to international phone format. |
112
+ | `formatToNull`, `formatToUndefined` | Convert empty strings to null/undefined. |
113
+
114
+ ### Common utilities (/common)
115
+ | Function | Description |
116
+ | -------- | ------------------------------------------------------ |
117
+ | `wait` | Pause execution asynchronously for given milliseconds. |
118
+
119
+ Example:
120
+ ```javascript
121
+ await wait(500); // waits for 0.5 seconds
122
+ ```
123
+
124
+ ### Network utilities (/net)
125
+
126
+ Node-only helpers for TCP connections.
127
+ | Function | Description |
128
+ | -------------------------------- | -------------------------------------------- |
129
+ | `netTCP(message, host, options)` | Send a TCP message and receive the response. |
130
+
131
+ Supports:
132
+ - Timeout controls (timeoutMs, connectTimeoutMs)
133
+ - Safe abort via AbortSignal
134
+ - Line terminator (\n / \r\n)
135
+ - Max bytes and half-close options.
136
+ - Available only in Node.js builds (import from 'full-utils/node')
137
+
138
+ ### URL & Host (/url)
139
+ | Function | Description |
140
+ | ------------- | ---------------------------------------------- |
141
+ | `extractHost` | Extract clean hostname from URL or raw string. |
142
+
143
+ ### JSON utilities (/json)
144
+ | Function | Description |
145
+ | --------------------------- | ------------------------------------------------------- |
146
+ | `jsonEncode` / `jsonDecode` | Safe JSON (de)serialization. |
147
+ | `tryParseJSON` | Try parsing with graceful fallback. |
148
+ | `parseStringLike` | Parse non-strict JSON-like strings (with quotes, etc.). |
149
+
150
+ ### Units (/units)
151
+ | Function | Description |
152
+ | ----------------------- | --------------------------------------------------------------------- |
153
+ | `toH` / `toGH` / `toGB` | Convert numeric values to readable units (hours, gigahash, gigabyte). |
154
+
155
+ ## Importing by environment
156
+ For Node.js:
157
+ ```javascript
158
+ import * from 'full-utils/node';
159
+
160
+ ```
161
+
162
+ For Browser / universal code:
163
+ ```javascript
164
+ import * from 'full-utils/browser';
165
+
166
+ ```
167
+
168
+ Or use tree-shakable imports directly from the source root:
169
+ ```javascript
170
+ import { formatDateToString, isStrFilled } from 'full-utils';
171
+
172
+ ```
173
+
174
+ ## TypeScript Ready
175
+ Every function is strongly typed and documented.
176
+ You’ll get autocompletion, inline JSDoc, and type inference automatically.
177
+
178
+ ## Versioning
179
+ Follows semantic versioning (MAJOR.MINOR.PATCH).
180
+ Breaking changes are always reflected in a major version bump
181
+
182
+ ## License
183
+ Use freely in your own projects. Add proper notices if you publish a package (MIT/Apache-2.0, etc.).
184
+
185
+ ## Summary
186
+
187
+ full-utils gives you many of ready-to-use, predictable, and documented helpers
188
+ that you can safely use in any project, no matter how large or small.
189
+
190
+ One toolkit. Zero dependencies. Full control.