yummies 5.4.7 → 5.4.8

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 (295) hide show
  1. package/async.cjs +70 -0
  2. package/async.d.cts +28 -0
  3. package/async.d.cts.map +1 -0
  4. package/common.cjs +18 -0
  5. package/common.d.cts +15 -0
  6. package/common.d.cts.map +1 -0
  7. package/common.d.ts +1 -1
  8. package/common.d.ts.map +1 -1
  9. package/complex/counter.cjs +21 -0
  10. package/complex/counter.d.cts +15 -0
  11. package/complex/counter.d.cts.map +1 -0
  12. package/complex/global-config.cjs +46 -0
  13. package/complex/global-config.d.cts +11 -0
  14. package/complex/global-config.d.cts.map +1 -0
  15. package/complex/global-config.d.ts +1 -1
  16. package/complex/global-config.d.ts.map +1 -1
  17. package/complex/index.cjs +19 -0
  18. package/complex/index.d.cts +4 -0
  19. package/complex/index.d.cts.map +1 -0
  20. package/complex/index.d.ts +3 -3
  21. package/complex/index.d.ts.map +1 -1
  22. package/complex/index.js +3 -3
  23. package/complex/modules-factory.cjs +50 -0
  24. package/complex/modules-factory.d.cts +49 -0
  25. package/complex/modules-factory.d.cts.map +1 -0
  26. package/complex/modules-factory.d.ts +1 -1
  27. package/complex/modules-factory.d.ts.map +1 -1
  28. package/cookie.cjs +13 -0
  29. package/cookie.d.cts +3 -0
  30. package/cookie.d.cts.map +1 -0
  31. package/cookie.d.ts +1 -1
  32. package/cookie.d.ts.map +1 -1
  33. package/css.cjs +28 -0
  34. package/css.d.cts +36 -0
  35. package/css.d.cts.map +1 -0
  36. package/data.cjs +58 -0
  37. package/data.d.cts +4 -0
  38. package/data.d.cts.map +1 -0
  39. package/date-time.cjs +171 -0
  40. package/date-time.d.cts +28 -0
  41. package/date-time.d.cts.map +1 -0
  42. package/date-time.d.ts +1 -1
  43. package/date-time.d.ts.map +1 -1
  44. package/date-time.js +4 -4
  45. package/device.cjs +28 -0
  46. package/device.d.cts +8 -0
  47. package/device.d.cts.map +1 -0
  48. package/encodings.cjs +270 -0
  49. package/encodings.d.cts +2 -0
  50. package/encodings.d.cts.map +1 -0
  51. package/errors.cjs +34 -0
  52. package/errors.d.cts +19 -0
  53. package/errors.d.cts.map +1 -0
  54. package/errors.d.ts +1 -1
  55. package/errors.d.ts.map +1 -1
  56. package/errors.js +1 -1
  57. package/file.cjs +29 -0
  58. package/file.d.cts +3 -0
  59. package/file.d.cts.map +1 -0
  60. package/format/_exports.cjs +20 -0
  61. package/format/_exports.d.cts +5 -0
  62. package/format/_exports.d.cts.map +1 -0
  63. package/format/_exports.d.ts +4 -4
  64. package/format/_exports.d.ts.map +1 -1
  65. package/format/_exports.js +4 -4
  66. package/format/constants.cjs +6 -0
  67. package/format/constants.d.cts +4 -0
  68. package/format/constants.d.cts.map +1 -0
  69. package/format/index.cjs +40 -0
  70. package/format/index.d.cts +3 -0
  71. package/format/index.d.cts.map +1 -0
  72. package/format/index.d.ts +1 -1
  73. package/format/index.d.ts.map +1 -1
  74. package/format/index.js +1 -1
  75. package/format/number.cjs +48 -0
  76. package/format/number.d.cts +36 -0
  77. package/format/number.d.cts.map +1 -0
  78. package/format/number.d.ts +1 -1
  79. package/format/number.d.ts.map +1 -1
  80. package/format/number.js +3 -3
  81. package/format/percent.cjs +27 -0
  82. package/format/percent.d.cts +15 -0
  83. package/format/percent.d.cts.map +1 -0
  84. package/format/percent.d.ts +2 -2
  85. package/format/percent.d.ts.map +1 -1
  86. package/format/percent.js +3 -3
  87. package/format/skip-spaces.cjs +8 -0
  88. package/format/skip-spaces.d.cts +5 -0
  89. package/format/skip-spaces.d.cts.map +1 -0
  90. package/html.cjs +202 -0
  91. package/html.d.cts +44 -0
  92. package/html.d.cts.map +1 -0
  93. package/html.d.ts +1 -1
  94. package/html.d.ts.map +1 -1
  95. package/html.js +1 -1
  96. package/id.cjs +76 -0
  97. package/id.d.cts +63 -0
  98. package/id.d.cts.map +1 -0
  99. package/imports.cjs +45 -0
  100. package/imports.d.cts +15 -0
  101. package/imports.d.cts.map +1 -0
  102. package/imports.js +1 -1
  103. package/math.cjs +23 -0
  104. package/math.d.cts +13 -0
  105. package/math.d.cts.map +1 -0
  106. package/math.d.ts +1 -1
  107. package/math.d.ts.map +1 -1
  108. package/media.cjs +115 -0
  109. package/media.d.cts +20 -0
  110. package/media.d.cts.map +1 -0
  111. package/media.js +1 -1
  112. package/mobx/apply-observable.cjs +16 -0
  113. package/mobx/apply-observable.d.cts +4 -0
  114. package/mobx/apply-observable.d.cts.map +1 -0
  115. package/mobx/apply-observable.d.ts +1 -1
  116. package/mobx/apply-observable.d.ts.map +1 -1
  117. package/mobx/create-enhanced-atom.cjs +16 -0
  118. package/mobx/create-enhanced-atom.d.cts +11 -0
  119. package/mobx/create-enhanced-atom.d.cts.map +1 -0
  120. package/mobx/create-enhanced-atom.d.ts +1 -1
  121. package/mobx/create-enhanced-atom.d.ts.map +1 -1
  122. package/mobx/deep-observable-struct.cjs +61 -0
  123. package/mobx/deep-observable-struct.d.cts +7 -0
  124. package/mobx/deep-observable-struct.d.cts.map +1 -0
  125. package/mobx/deep-observable-struct.d.ts +1 -1
  126. package/mobx/deep-observable-struct.d.ts.map +1 -1
  127. package/mobx/deep-observable-struct.js +1 -1
  128. package/mobx/get-mobx-administration.cjs +6 -0
  129. package/mobx/get-mobx-administration.d.cts +6 -0
  130. package/mobx/get-mobx-administration.d.cts.map +1 -0
  131. package/mobx/get-mobx-administration.d.ts +1 -1
  132. package/mobx/get-mobx-administration.d.ts.map +1 -1
  133. package/mobx/index.cjs +21 -0
  134. package/mobx/index.d.cts +6 -0
  135. package/mobx/index.d.cts.map +1 -0
  136. package/mobx/index.d.ts +5 -5
  137. package/mobx/index.d.ts.map +1 -1
  138. package/mobx/index.js +5 -5
  139. package/mobx/lazy-observe.cjs +47 -0
  140. package/mobx/lazy-observe.d.cts +8 -0
  141. package/mobx/lazy-observe.d.cts.map +1 -0
  142. package/ms.cjs +22 -0
  143. package/ms.d.cts +19 -0
  144. package/ms.d.cts.map +1 -0
  145. package/number.cjs +16 -0
  146. package/number.d.cts +8 -0
  147. package/number.d.cts.map +1 -0
  148. package/package.json +91 -329
  149. package/parser/_exports.cjs +19 -0
  150. package/parser/_exports.d.cts +4 -0
  151. package/parser/_exports.d.cts.map +1 -0
  152. package/parser/_exports.d.ts +3 -3
  153. package/parser/_exports.d.ts.map +1 -1
  154. package/parser/_exports.js +3 -3
  155. package/parser/index.cjs +40 -0
  156. package/parser/index.d.cts +3 -0
  157. package/parser/index.d.cts.map +1 -0
  158. package/parser/index.d.ts +1 -1
  159. package/parser/index.d.ts.map +1 -1
  160. package/parser/index.js +1 -1
  161. package/parser/number.cjs +48 -0
  162. package/parser/number.d.cts +21 -0
  163. package/parser/number.d.cts.map +1 -0
  164. package/parser/number.d.ts +1 -1
  165. package/parser/number.d.ts.map +1 -1
  166. package/parser/number.js +2 -2
  167. package/parser/percent.cjs +8 -0
  168. package/parser/percent.d.cts +4 -0
  169. package/parser/percent.d.cts.map +1 -0
  170. package/parser/percent.d.ts +2 -2
  171. package/parser/percent.d.ts.map +1 -1
  172. package/parser/percent.js +1 -1
  173. package/parser/string.cjs +18 -0
  174. package/parser/string.d.cts +7 -0
  175. package/parser/string.d.cts.map +1 -0
  176. package/parser/string.d.ts +1 -1
  177. package/parser/string.d.ts.map +1 -1
  178. package/parser/string.js +1 -1
  179. package/price.cjs +21 -0
  180. package/price.d.cts +6 -0
  181. package/price.d.cts.map +1 -0
  182. package/random.cjs +25 -0
  183. package/random.d.cts +9 -0
  184. package/random.d.cts.map +1 -0
  185. package/react/hooks/index.cjs +37 -0
  186. package/react/hooks/index.d.cts +22 -0
  187. package/react/hooks/index.d.cts.map +1 -0
  188. package/react/hooks/index.d.ts +21 -21
  189. package/react/hooks/index.d.ts.map +1 -1
  190. package/react/hooks/index.js +21 -21
  191. package/react/hooks/use-abort-controller.cjs +15 -0
  192. package/react/hooks/use-abort-controller.d.cts +2 -0
  193. package/react/hooks/use-abort-controller.d.cts.map +1 -0
  194. package/react/hooks/use-abort-controller.js +1 -1
  195. package/react/hooks/use-abort-signal.cjs +8 -0
  196. package/react/hooks/use-abort-signal.d.cts +2 -0
  197. package/react/hooks/use-abort-signal.d.cts.map +1 -0
  198. package/react/hooks/use-abort-signal.js +1 -1
  199. package/react/hooks/use-click-outside.cjs +17 -0
  200. package/react/hooks/use-click-outside.d.cts +9 -0
  201. package/react/hooks/use-click-outside.d.cts.map +1 -0
  202. package/react/hooks/use-click-outside.js +1 -1
  203. package/react/hooks/use-constant.cjs +19 -0
  204. package/react/hooks/use-constant.d.cts +9 -0
  205. package/react/hooks/use-constant.d.cts.map +1 -0
  206. package/react/hooks/use-define-ref.cjs +19 -0
  207. package/react/hooks/use-define-ref.d.cts +10 -0
  208. package/react/hooks/use-define-ref.d.cts.map +1 -0
  209. package/react/hooks/use-element-ref.cjs +12 -0
  210. package/react/hooks/use-element-ref.d.cts +2 -0
  211. package/react/hooks/use-element-ref.d.cts.map +1 -0
  212. package/react/hooks/use-event-listener.cjs +17 -0
  213. package/react/hooks/use-event-listener.d.cts +8 -0
  214. package/react/hooks/use-event-listener.d.cts.map +1 -0
  215. package/react/hooks/use-event-listener.js +1 -1
  216. package/react/hooks/use-event.cjs +23 -0
  217. package/react/hooks/use-event.d.cts +3 -0
  218. package/react/hooks/use-event.d.cts.map +1 -0
  219. package/react/hooks/use-event.d.ts +1 -1
  220. package/react/hooks/use-event.d.ts.map +1 -1
  221. package/react/hooks/use-flag.cjs +19 -0
  222. package/react/hooks/use-flag.d.cts +8 -0
  223. package/react/hooks/use-flag.d.cts.map +1 -0
  224. package/react/hooks/use-force-update.cjs +11 -0
  225. package/react/hooks/use-force-update.d.cts +2 -0
  226. package/react/hooks/use-force-update.d.cts.map +1 -0
  227. package/react/hooks/use-initial-height.cjs +15 -0
  228. package/react/hooks/use-initial-height.d.cts +5 -0
  229. package/react/hooks/use-initial-height.d.cts.map +1 -0
  230. package/react/hooks/use-instance.cjs +31 -0
  231. package/react/hooks/use-instance.d.cts +27 -0
  232. package/react/hooks/use-instance.d.cts.map +1 -0
  233. package/react/hooks/use-instance.js +2 -2
  234. package/react/hooks/use-intersection-observer.cjs +14 -0
  235. package/react/hooks/use-intersection-observer.d.cts +2 -0
  236. package/react/hooks/use-intersection-observer.d.cts.map +1 -0
  237. package/react/hooks/use-last-defined-value.cjs +12 -0
  238. package/react/hooks/use-last-defined-value.d.cts +2 -0
  239. package/react/hooks/use-last-defined-value.d.cts.map +1 -0
  240. package/react/hooks/use-last-value-ref.cjs +12 -0
  241. package/react/hooks/use-last-value-ref.d.cts +2 -0
  242. package/react/hooks/use-last-value-ref.d.cts.map +1 -0
  243. package/react/hooks/use-life-cycle.cjs +14 -0
  244. package/react/hooks/use-life-cycle.d.cts +5 -0
  245. package/react/hooks/use-life-cycle.d.cts.map +1 -0
  246. package/react/hooks/use-life-cycle.js +1 -1
  247. package/react/hooks/use-resize-observer.cjs +15 -0
  248. package/react/hooks/use-resize-observer.d.cts +2 -0
  249. package/react/hooks/use-resize-observer.d.cts.map +1 -0
  250. package/react/hooks/use-resize-observer.js +1 -1
  251. package/react/hooks/use-sync-ref.cjs +10 -0
  252. package/react/hooks/use-sync-ref.d.cts +2 -0
  253. package/react/hooks/use-sync-ref.d.cts.map +1 -0
  254. package/react/hooks/use-toggle.cjs +10 -0
  255. package/react/hooks/use-toggle.d.cts +2 -0
  256. package/react/hooks/use-toggle.d.cts.map +1 -0
  257. package/react/hooks/use-value.cjs +12 -0
  258. package/react/hooks/use-value.d.cts +5 -0
  259. package/react/hooks/use-value.d.cts.map +1 -0
  260. package/react/hooks/use-visibility-state.cjs +18 -0
  261. package/react/hooks/use-visibility-state.d.cts +2 -0
  262. package/react/hooks/use-visibility-state.d.cts.map +1 -0
  263. package/react/index.cjs +17 -0
  264. package/react/index.d.cts +2 -0
  265. package/react/index.d.cts.map +1 -0
  266. package/react/index.d.ts +1 -1
  267. package/react/index.d.ts.map +1 -1
  268. package/react/index.js +1 -1
  269. package/sound.cjs +16 -0
  270. package/sound.d.cts +7 -0
  271. package/sound.d.cts.map +1 -0
  272. package/storage.cjs +48 -0
  273. package/storage.d.cts +39 -0
  274. package/storage.d.cts.map +1 -0
  275. package/text.cjs +53 -0
  276. package/text.d.cts +15 -0
  277. package/text.d.cts.map +1 -0
  278. package/type-guard/_exports.cjs +129 -0
  279. package/type-guard/_exports.d.cts +86 -0
  280. package/type-guard/_exports.d.cts.map +1 -0
  281. package/type-guard/_exports.d.ts +1 -1
  282. package/type-guard/_exports.d.ts.map +1 -1
  283. package/type-guard/index.cjs +40 -0
  284. package/type-guard/index.d.cts +3 -0
  285. package/type-guard/index.d.cts.map +1 -0
  286. package/type-guard/index.d.ts +1 -1
  287. package/type-guard/index.d.ts.map +1 -1
  288. package/type-guard/index.js +1 -1
  289. package/utility-types.d.ts +1 -0
  290. package/utils/types.cjs +2 -0
  291. package/utils/types.d.cts +395 -0
  292. package/utils/types.d.cts.map +1 -0
  293. package/vibrate.cjs +12 -0
  294. package/vibrate.d.cts +5 -0
  295. package/vibrate.d.cts.map +1 -0
package/date-time.cjs ADDED
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.timeDuration = exports.changeDate = exports.dayTimeDuration = exports.formatDate = void 0;
7
+ exports.getFormatDuration = getFormatDuration;
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
+ const duration_js_1 = __importDefault(require("dayjs/plugin/duration.js"));
10
+ const relativeTime_js_1 = __importDefault(require("dayjs/plugin/relativeTime.js"));
11
+ const index_js_1 = require("./format/index.cjs");
12
+ const ms_js_1 = require("./ms.cjs");
13
+ const text_js_1 = require("./text.cjs");
14
+ const index_js_2 = require("./type-guard/index.cjs");
15
+ require("dayjs/locale/ru.js");
16
+ dayjs_1.default.extend(relativeTime_js_1.default);
17
+ dayjs_1.default.extend(duration_js_1.default);
18
+ dayjs_1.default.locale('ru');
19
+ const toLibFormat = (value, asTime) => {
20
+ if (index_js_2.typeGuard.isNumber(value)) {
21
+ if (asTime) {
22
+ return dayjs_1.default.duration(value);
23
+ }
24
+ return (0, dayjs_1.default)(value);
25
+ }
26
+ else if (dayjs_1.default.isDayjs(value)) {
27
+ return value;
28
+ }
29
+ else {
30
+ return (0, dayjs_1.default)(value);
31
+ }
32
+ };
33
+ const formatDate = (value, settings) => {
34
+ const dateFormat = settings?.format;
35
+ const datePattern = settings?.pattern;
36
+ const asTime = settings?.asTime;
37
+ value = toLibFormat(value, asTime);
38
+ if (index_js_2.typeGuard.isUndefined(value) || !value.isValid()) {
39
+ return index_js_1.format.NO_VALUE;
40
+ }
41
+ if (datePattern) {
42
+ return value.format(datePattern);
43
+ }
44
+ switch (dateFormat) {
45
+ case 'human': {
46
+ return value.fromNow();
47
+ }
48
+ case 'spent-time': {
49
+ return value.fromNow(true);
50
+ }
51
+ case 'full': {
52
+ return value.format('DD MMM YYYY HH:mm:ss');
53
+ }
54
+ case 'short': {
55
+ return value.format('DD MMM HH:mm');
56
+ }
57
+ case 'time': {
58
+ return value.format('HH:mm:ss');
59
+ }
60
+ case 'time-short': {
61
+ return value.format('HH:mm');
62
+ }
63
+ case 'day': {
64
+ return value.format('DD MMM YYYY');
65
+ }
66
+ case 'month': {
67
+ return value.format('MMMM YYYY');
68
+ }
69
+ default: {
70
+ return value.format('DD.MM.YYYY');
71
+ }
72
+ }
73
+ };
74
+ exports.formatDate = formatDate;
75
+ const dayTimeDuration = (timeInMs) => {
76
+ let left = Math.max(timeInMs, 0);
77
+ const days = Math.floor(left / ms_js_1.unitsToMs.day);
78
+ left = left % ms_js_1.unitsToMs.day;
79
+ const hours = Math.floor(left / ms_js_1.unitsToMs.hour);
80
+ left = left % ms_js_1.unitsToMs.hour;
81
+ const minutes = Math.floor(left / ms_js_1.unitsToMs.min);
82
+ left = left % ms_js_1.unitsToMs.min;
83
+ const seconds = Math.floor(left / ms_js_1.unitsToMs.sec);
84
+ left = left % ms_js_1.unitsToMs.sec;
85
+ const milliseconds = Math.floor(left);
86
+ return {
87
+ days,
88
+ hours,
89
+ minutes,
90
+ seconds,
91
+ milliseconds,
92
+ };
93
+ };
94
+ exports.dayTimeDuration = dayTimeDuration;
95
+ const changeDate = (date, ...args) => {
96
+ let wrappedDate = toLibFormat(date);
97
+ for (let i = 0; i < args.length; i += 2) {
98
+ const amount = args[i];
99
+ const unit = args[i + 1];
100
+ if (unit != null) {
101
+ wrappedDate = wrappedDate.add(amount, unit);
102
+ }
103
+ }
104
+ return wrappedDate.toDate();
105
+ };
106
+ exports.changeDate = changeDate;
107
+ const timeDuration = (timeInMs) => {
108
+ const { days, hours, milliseconds, minutes, seconds } = (0, exports.dayTimeDuration)(timeInMs);
109
+ return {
110
+ hours: hours + ms_js_1.unitsToMs.day * days,
111
+ milliseconds,
112
+ minutes,
113
+ seconds,
114
+ };
115
+ };
116
+ exports.timeDuration = timeDuration;
117
+ const durationFormatLabels = {
118
+ days: { compact: 'д', full: ['день', 'дня', 'дней'] },
119
+ hours: { compact: 'ч', full: ['час', 'часа', 'часов'] },
120
+ minutes: { compact: 'мин', full: ['минута', 'минуты', 'минут'] },
121
+ seconds: { compact: 'сек', full: ['секунда', 'секунды', 'секунд'] },
122
+ };
123
+ function getFormatDuration(...args) {
124
+ let compact = false;
125
+ let diff = 0;
126
+ if (args[0] instanceof Date) {
127
+ const startedDate = (0, dayjs_1.default)(args[0]);
128
+ const endedDate = (0, dayjs_1.default)(args[1]);
129
+ diff = endedDate.diff(startedDate, 'ms');
130
+ compact = args[2] === true;
131
+ }
132
+ else {
133
+ diff = args[0];
134
+ compact = args[1] === true;
135
+ }
136
+ const { days, hours, minutes, seconds } = (0, exports.dayTimeDuration)(diff);
137
+ const formattedParts = [];
138
+ if (days) {
139
+ if (compact) {
140
+ formattedParts.push(`${days} ${durationFormatLabels.days.compact}`);
141
+ }
142
+ else {
143
+ formattedParts.push(`${days} ${(0, text_js_1.declension)(days, durationFormatLabels.days.full)}`);
144
+ }
145
+ }
146
+ if (hours) {
147
+ if (compact) {
148
+ formattedParts.push(`${hours} ${durationFormatLabels.hours.compact}`);
149
+ }
150
+ else {
151
+ formattedParts.push(`${hours} ${(0, text_js_1.declension)(hours, durationFormatLabels.hours.full)}`);
152
+ }
153
+ }
154
+ if (minutes) {
155
+ if (compact) {
156
+ formattedParts.push(`${minutes} ${durationFormatLabels.minutes.compact}`);
157
+ }
158
+ else {
159
+ formattedParts.push(`${minutes} ${(0, text_js_1.declension)(minutes, durationFormatLabels.minutes.full)}`);
160
+ }
161
+ }
162
+ if (seconds) {
163
+ if (compact) {
164
+ formattedParts.push(`${seconds} ${durationFormatLabels.seconds.compact}`);
165
+ }
166
+ else {
167
+ formattedParts.push(`${seconds} ${(0, text_js_1.declension)(seconds, durationFormatLabels.seconds.full)}`);
168
+ }
169
+ }
170
+ return formattedParts.join(' ');
171
+ }
@@ -0,0 +1,28 @@
1
+ import { type Dayjs, type ManipulateType } from 'dayjs';
2
+ import type { Maybe } from "./utils/types.cjs";
3
+ import 'dayjs/locale/ru.js';
4
+ export type RawDateToFormat = Date | string | number | Dayjs;
5
+ export declare const formatDate: (value: Maybe<RawDateToFormat>, settings?: Maybe<{
6
+ format?: "human" | "full" | "short" | "day" | "day-only" | "date" | "month" | "spent-time" | "time" | "time-short";
7
+ pattern?: string;
8
+ asTime?: boolean;
9
+ }>) => string;
10
+ export declare const dayTimeDuration: (timeInMs: number) => {
11
+ days: number;
12
+ hours: number;
13
+ minutes: number;
14
+ seconds: number;
15
+ milliseconds: number;
16
+ };
17
+ type DateChangeParam = [amount: number, unit?: Maybe<ManipulateType>];
18
+ export declare const changeDate: (date: Maybe<RawDateToFormat>, ...args: [...DateChangeParam, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>, ...Partial<DateChangeParam>]) => Date;
19
+ export declare const timeDuration: (timeInMs: number) => {
20
+ hours: number;
21
+ milliseconds: number;
22
+ minutes: number;
23
+ seconds: number;
24
+ };
25
+ export declare function getFormatDuration(dateA: Date, dateB: Date, compact?: boolean): string;
26
+ export declare function getFormatDuration(ms: number, compact?: boolean): string;
27
+ export {};
28
+ //# sourceMappingURL=date-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,KAAK,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/D,OAAO,KAAK,EAAE,KAAK,EAAE,0BAAyB;AAE9C,OAAO,oBAAoB,CAAC;AAsB5B,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D,eAAO,MAAM,UAAU,GACrB,OAAO,KAAK,CAAC,eAAe,CAAC,EAC7B,WAAW,KAAK,CAAC;IACf,MAAM,CAAC,EACH,OAAO,GACP,MAAM,GACN,OAAO,GACP,KAAK,GACL,UAAU,GACV,MAAM,GACN,OAAO,GACP,YAAY,GACZ,MAAM,GACN,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,WA6CH,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM;;;;;;CAwB/C,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAEtE,eAAO,MAAM,UAAU,GACrB,MAAM,KAAK,CAAC,eAAe,CAAC,EAC5B,GAAG,MAAM,CACP,GAAG,eAAe,EAClB,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,CAC5B,SAaF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM;;;;;CAU5C,CAAC;AASF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,EACX,KAAK,EAAE,IAAI,EACX,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,CAAC;AACV,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC"}
package/date-time.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Dayjs, type ManipulateType } from 'dayjs';
2
- import type { Maybe } from './utils/types.js';
2
+ import type { Maybe } from "./utils/types.js";
3
3
  import 'dayjs/locale/ru.js';
4
4
  export type RawDateToFormat = Date | string | number | Dayjs;
5
5
  export declare const formatDate: (value: Maybe<RawDateToFormat>, settings?: Maybe<{
@@ -1 +1 @@
1
- {"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,KAAK,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,oBAAoB,CAAC;AAsB5B,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D,eAAO,MAAM,UAAU,GACrB,OAAO,KAAK,CAAC,eAAe,CAAC,EAC7B,WAAW,KAAK,CAAC;IACf,MAAM,CAAC,EACH,OAAO,GACP,MAAM,GACN,OAAO,GACP,KAAK,GACL,UAAU,GACV,MAAM,GACN,OAAO,GACP,YAAY,GACZ,MAAM,GACN,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,WA6CH,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM;;;;;;CAwB/C,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAEtE,eAAO,MAAM,UAAU,GACrB,MAAM,KAAK,CAAC,eAAe,CAAC,EAC5B,GAAG,MAAM,CACP,GAAG,eAAe,EAClB,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,CAC5B,SAaF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM;;;;;CAU5C,CAAC;AASF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,EACX,KAAK,EAAE,IAAI,EACX,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,CAAC;AACV,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,KAAK,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/D,OAAO,KAAK,EAAE,KAAK,EAAE,yBAAyB;AAE9C,OAAO,oBAAoB,CAAC;AAsB5B,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D,eAAO,MAAM,UAAU,GACrB,OAAO,KAAK,CAAC,eAAe,CAAC,EAC7B,WAAW,KAAK,CAAC;IACf,MAAM,CAAC,EACH,OAAO,GACP,MAAM,GACN,OAAO,GACP,KAAK,GACL,UAAU,GACV,MAAM,GACN,OAAO,GACP,YAAY,GACZ,MAAM,GACN,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,WA6CH,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM;;;;;;CAwB/C,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAEtE,eAAO,MAAM,UAAU,GACrB,MAAM,KAAK,CAAC,eAAe,CAAC,EAC5B,GAAG,MAAM,CACP,GAAG,eAAe,EAClB,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3B,GAAG,OAAO,CAAC,eAAe,CAAC,CAC5B,SAaF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM;;;;;CAU5C,CAAC;AASF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,EACX,KAAK,EAAE,IAAI,EACX,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,CAAC;AACV,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC"}
package/date-time.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import dayjs from 'dayjs';
2
2
  import duration from 'dayjs/plugin/duration.js';
3
3
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
- import { format } from './format/index.js';
5
- import { unitsToMs } from './ms.js';
6
- import { declension } from './text.js';
7
- import { typeGuard } from './type-guard/index.js';
4
+ import { format } from "./format/index.js";
5
+ import { unitsToMs } from "./ms.js";
6
+ import { declension } from "./text.js";
7
+ import { typeGuard } from "./type-guard/index.js";
8
8
  import 'dayjs/locale/ru.js';
9
9
  dayjs.extend(relativeTime);
10
10
  dayjs.extend(duration);
package/device.cjs ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTouchDevice = exports.isTabletDevice = exports.isMobileDevice = exports.checkIsTouchDevice = exports.checkIsTabletDevice = exports.checkIsMobileDevice = exports.getUserAgent = void 0;
4
+ const getUserAgent = () => (navigator.userAgent ||
5
+ navigator.vendor ||
6
+ // @ts-expect-error skip opera
7
+ globalThis.opera ||
8
+ '').toLowerCase();
9
+ exports.getUserAgent = getUserAgent;
10
+ const checkIsMobileDevice = () => {
11
+ const userAgent = (0, exports.getUserAgent)();
12
+ if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(userAgent || '') ||
13
+ /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test((userAgent || '').slice(0, 4))) {
14
+ return true;
15
+ }
16
+ return false;
17
+ };
18
+ exports.checkIsMobileDevice = checkIsMobileDevice;
19
+ const checkIsTabletDevice = () => {
20
+ const userAgent = (0, exports.getUserAgent)();
21
+ return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(userAgent);
22
+ };
23
+ exports.checkIsTabletDevice = checkIsTabletDevice;
24
+ const checkIsTouchDevice = () => (0, exports.checkIsMobileDevice)() || (0, exports.checkIsTabletDevice)();
25
+ exports.checkIsTouchDevice = checkIsTouchDevice;
26
+ exports.isMobileDevice = (0, exports.checkIsMobileDevice)();
27
+ exports.isTabletDevice = (0, exports.checkIsTabletDevice)();
28
+ exports.isTouchDevice = exports.isMobileDevice || exports.isTabletDevice;
package/device.d.cts ADDED
@@ -0,0 +1,8 @@
1
+ export declare const getUserAgent: () => any;
2
+ export declare const checkIsMobileDevice: () => boolean;
3
+ export declare const checkIsTabletDevice: () => boolean;
4
+ export declare const checkIsTouchDevice: () => boolean;
5
+ export declare const isMobileDevice: boolean;
6
+ export declare const isTabletDevice: boolean;
7
+ export declare const isTouchDevice: boolean;
8
+ //# sourceMappingURL=device.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,WAOR,CAAC;AAElB,eAAO,MAAM,mBAAmB,eAe/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAM/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,eACiB,CAAC;AAEjD,eAAO,MAAM,cAAc,SAAwB,CAAC;AAEpD,eAAO,MAAM,cAAc,SAAwB,CAAC;AAEpD,eAAO,MAAM,aAAa,SAAmC,CAAC"}
package/encodings.cjs ADDED
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unicodeToWin1251 = unicodeToWin1251;
4
+ const DMap = {
5
+ 0: 0,
6
+ 1: 1,
7
+ 2: 2,
8
+ 3: 3,
9
+ 4: 4,
10
+ 5: 5,
11
+ 6: 6,
12
+ 7: 7,
13
+ 8: 8,
14
+ 9: 9,
15
+ 10: 10,
16
+ 11: 11,
17
+ 12: 12,
18
+ 13: 13,
19
+ 14: 14,
20
+ 15: 15,
21
+ 16: 16,
22
+ 17: 17,
23
+ 18: 18,
24
+ 19: 19,
25
+ 20: 20,
26
+ 21: 21,
27
+ 22: 22,
28
+ 23: 23,
29
+ 24: 24,
30
+ 25: 25,
31
+ 26: 26,
32
+ 27: 27,
33
+ 28: 28,
34
+ 29: 29,
35
+ 30: 30,
36
+ 31: 31,
37
+ 32: 32,
38
+ 33: 33,
39
+ 34: 34,
40
+ 35: 35,
41
+ 36: 36,
42
+ 37: 37,
43
+ 38: 38,
44
+ 39: 39,
45
+ 40: 40,
46
+ 41: 41,
47
+ 42: 42,
48
+ 43: 43,
49
+ 44: 44,
50
+ 45: 45,
51
+ 46: 46,
52
+ 47: 47,
53
+ 48: 48,
54
+ 49: 49,
55
+ 50: 50,
56
+ 51: 51,
57
+ 52: 52,
58
+ 53: 53,
59
+ 54: 54,
60
+ 55: 55,
61
+ 56: 56,
62
+ 57: 57,
63
+ 58: 58,
64
+ 59: 59,
65
+ 60: 60,
66
+ 61: 61,
67
+ 62: 62,
68
+ 63: 63,
69
+ 64: 64,
70
+ 65: 65,
71
+ 66: 66,
72
+ 67: 67,
73
+ 68: 68,
74
+ 69: 69,
75
+ 70: 70,
76
+ 71: 71,
77
+ 72: 72,
78
+ 73: 73,
79
+ 74: 74,
80
+ 75: 75,
81
+ 76: 76,
82
+ 77: 77,
83
+ 78: 78,
84
+ 79: 79,
85
+ 80: 80,
86
+ 81: 81,
87
+ 82: 82,
88
+ 83: 83,
89
+ 84: 84,
90
+ 85: 85,
91
+ 86: 86,
92
+ 87: 87,
93
+ 88: 88,
94
+ 89: 89,
95
+ 90: 90,
96
+ 91: 91,
97
+ 92: 92,
98
+ 93: 93,
99
+ 94: 94,
100
+ 95: 95,
101
+ 96: 96,
102
+ 97: 97,
103
+ 98: 98,
104
+ 99: 99,
105
+ 100: 100,
106
+ 101: 101,
107
+ 102: 102,
108
+ 103: 103,
109
+ 104: 104,
110
+ 105: 105,
111
+ 106: 106,
112
+ 107: 107,
113
+ 108: 108,
114
+ 109: 109,
115
+ 110: 110,
116
+ 111: 111,
117
+ 112: 112,
118
+ 113: 113,
119
+ 114: 114,
120
+ 115: 115,
121
+ 116: 116,
122
+ 117: 117,
123
+ 118: 118,
124
+ 119: 119,
125
+ 120: 120,
126
+ 121: 121,
127
+ 122: 122,
128
+ 123: 123,
129
+ 124: 124,
130
+ 125: 125,
131
+ 126: 126,
132
+ 127: 127,
133
+ 1027: 129,
134
+ 8225: 135,
135
+ 1046: 198,
136
+ 8222: 132,
137
+ 1047: 199,
138
+ 1168: 165,
139
+ 1048: 200,
140
+ 1113: 154,
141
+ 1049: 201,
142
+ 1045: 197,
143
+ 1050: 202,
144
+ 1028: 170,
145
+ 160: 160,
146
+ 1040: 192,
147
+ 1051: 203,
148
+ 164: 164,
149
+ 166: 166,
150
+ 167: 167,
151
+ 169: 169,
152
+ 171: 171,
153
+ 172: 172,
154
+ 173: 173,
155
+ 174: 174,
156
+ 1053: 205,
157
+ 176: 176,
158
+ 177: 177,
159
+ 1114: 156,
160
+ 181: 181,
161
+ 182: 182,
162
+ 183: 183,
163
+ 8221: 148,
164
+ 187: 187,
165
+ 1029: 189,
166
+ 1056: 208,
167
+ 1057: 209,
168
+ 1058: 210,
169
+ 8364: 136,
170
+ 1112: 188,
171
+ 1115: 158,
172
+ 1059: 211,
173
+ 1060: 212,
174
+ 1030: 178,
175
+ 1061: 213,
176
+ 1062: 214,
177
+ 1063: 215,
178
+ 1116: 157,
179
+ 1064: 216,
180
+ 1065: 217,
181
+ 1031: 175,
182
+ 1066: 218,
183
+ 1067: 219,
184
+ 1068: 220,
185
+ 1069: 221,
186
+ 1070: 222,
187
+ 1032: 163,
188
+ 8226: 149,
189
+ 1071: 223,
190
+ 1072: 224,
191
+ 8482: 153,
192
+ 1073: 225,
193
+ 8240: 137,
194
+ 1118: 162,
195
+ 1074: 226,
196
+ 1110: 179,
197
+ 8230: 133,
198
+ 1075: 227,
199
+ 1033: 138,
200
+ 1076: 228,
201
+ 1077: 229,
202
+ 8211: 150,
203
+ 1078: 230,
204
+ 1119: 159,
205
+ 1079: 231,
206
+ 1042: 194,
207
+ 1080: 232,
208
+ 1034: 140,
209
+ 1025: 168,
210
+ 1081: 233,
211
+ 1082: 234,
212
+ 8212: 151,
213
+ 1083: 235,
214
+ 1169: 180,
215
+ 1084: 236,
216
+ 1052: 204,
217
+ 1085: 237,
218
+ 1035: 142,
219
+ 1086: 238,
220
+ 1087: 239,
221
+ 1088: 240,
222
+ 1089: 241,
223
+ 1090: 242,
224
+ 1036: 141,
225
+ 1041: 193,
226
+ 1091: 243,
227
+ 1092: 244,
228
+ 8224: 134,
229
+ 1093: 245,
230
+ 8470: 185,
231
+ 1094: 246,
232
+ 1054: 206,
233
+ 1095: 247,
234
+ 1096: 248,
235
+ 8249: 139,
236
+ 1097: 249,
237
+ 1098: 250,
238
+ 1044: 196,
239
+ 1099: 251,
240
+ 1111: 191,
241
+ 1055: 207,
242
+ 1100: 252,
243
+ 1038: 161,
244
+ 8220: 147,
245
+ 1101: 253,
246
+ 8250: 155,
247
+ 1102: 254,
248
+ 8216: 145,
249
+ 1103: 255,
250
+ 1043: 195,
251
+ 1105: 184,
252
+ 1039: 143,
253
+ 1026: 128,
254
+ 1106: 144,
255
+ 8218: 130,
256
+ 1107: 131,
257
+ 8217: 146,
258
+ 1108: 186,
259
+ 1109: 190,
260
+ };
261
+ function unicodeToWin1251(s) {
262
+ const L = [];
263
+ for (let i = 0; i < s.length; i++) {
264
+ const ord = s.charCodeAt(i);
265
+ if (!(ord in DMap))
266
+ throw new Error(`Character ${s.charAt(i)} isn't supported by win1251!`);
267
+ L.push(String.fromCharCode(DMap[ord]));
268
+ }
269
+ return L.join('');
270
+ }
@@ -0,0 +1,2 @@
1
+ export declare function unicodeToWin1251(s: string): string;
2
+ //# sourceMappingURL=encodings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodings.d.ts","sourceRoot":"","sources":["../src/encodings.ts"],"names":[],"mappings":"AAoQA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,UASzC"}
package/errors.cjs ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getErrorText = void 0;
4
+ const index_js_1 = require("./type-guard/index.cjs");
5
+ /**
6
+ * Universal function for transforming any errors into readable error text
7
+ *
8
+ * This function can be enhanced with custom handlers using:
9
+ * - `getErrorText.unknownErrorText`
10
+ * - `getErrorText.formatError`
11
+ * - `getErrorText.enhance`
12
+ */
13
+ const getErrorText = (error) => {
14
+ if (!error) {
15
+ return exports.getErrorText.unknownErrorText;
16
+ }
17
+ if (index_js_1.typeGuard.isString(error)) {
18
+ return error || exports.getErrorText.unknownErrorText;
19
+ }
20
+ if (error instanceof Error) {
21
+ return ((exports.getErrorText.formatError?.(error) ?? error.message) ||
22
+ exports.getErrorText.unknownErrorText);
23
+ }
24
+ if (exports.getErrorText.enhance) {
25
+ return exports.getErrorText.enhance(error) ?? exports.getErrorText.unknownErrorText;
26
+ }
27
+ else {
28
+ return exports.getErrorText.unknownErrorText;
29
+ }
30
+ };
31
+ exports.getErrorText = getErrorText;
32
+ exports.getErrorText.unknownErrorText = '';
33
+ exports.getErrorText.formatError = null;
34
+ exports.getErrorText.enhance = null;
package/errors.d.cts ADDED
@@ -0,0 +1,19 @@
1
+ import type { Maybe } from "./utils/types.cjs";
2
+ type GetErrorTextEnhancer = (error: any) => string;
3
+ type GetErrorTextFormatErrorFn = (error: Error) => string;
4
+ /**
5
+ * Universal function for transforming any errors into readable error text
6
+ *
7
+ * This function can be enhanced with custom handlers using:
8
+ * - `getErrorText.unknownErrorText`
9
+ * - `getErrorText.formatError`
10
+ * - `getErrorText.enhance`
11
+ */
12
+ export declare const getErrorText: {
13
+ (error: unknown): string;
14
+ unknownErrorText: string;
15
+ formatError: Maybe<GetErrorTextFormatErrorFn>;
16
+ enhance: Maybe<GetErrorTextEnhancer>;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,0BAAyB;AAE9C,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;AACnD,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;YAAW,OAAO;;;;CAqB1C,CAAC"}
package/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Maybe } from './utils/types.js';
1
+ import type { Maybe } from "./utils/types.js";
2
2
  type GetErrorTextEnhancer = (error: any) => string;
3
3
  type GetErrorTextFormatErrorFn = (error: Error) => string;
4
4
  /**
package/errors.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;AACnD,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;YAAW,OAAO;;;;CAqB1C,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,yBAAyB;AAE9C,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;AACnD,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;YAAW,OAAO;;;;CAqB1C,CAAC"}
package/errors.js CHANGED
@@ -1,4 +1,4 @@
1
- import { typeGuard } from './type-guard/index.js';
1
+ import { typeGuard } from "./type-guard/index.js";
2
2
  /**
3
3
  * Universal function for transforming any errors into readable error text
4
4
  *
package/file.cjs ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTextFromFile = exports.getBase64FromFile = void 0;
4
+ const getBase64FromFile = (file) => {
5
+ return new Promise((resolve, reject) => {
6
+ const reader = new FileReader();
7
+ reader.readAsDataURL(file);
8
+ reader.onload = () => {
9
+ resolve(reader.result.toString());
10
+ };
11
+ reader.onerror = (error) => {
12
+ reject(error);
13
+ };
14
+ });
15
+ };
16
+ exports.getBase64FromFile = getBase64FromFile;
17
+ const getTextFromFile = (file, encoding) => {
18
+ return new Promise((resolve, reject) => {
19
+ const reader = new FileReader();
20
+ reader.readAsText(file, encoding);
21
+ reader.onload = () => {
22
+ resolve(reader.result.toString());
23
+ };
24
+ reader.onerror = (error) => {
25
+ reject(error);
26
+ };
27
+ });
28
+ };
29
+ exports.getTextFromFile = getTextFromFile;
package/file.d.cts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const getBase64FromFile: (file: File) => Promise<string>;
2
+ export declare const getTextFromFile: (file: File, encoding?: string) => Promise<string>;
3
+ //# sourceMappingURL=file.d.ts.map
package/file.d.cts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,GAAI,MAAM,IAAI,oBAW3C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,WAAW,MAAM,oBAW5D,CAAC"}