yummies 5.4.6 → 5.4.7

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 (290) hide show
  1. package/async.d.ts +28 -0
  2. package/async.d.ts.map +1 -0
  3. package/async.js +62 -0
  4. package/{src/common.ts → common.d.ts} +3 -14
  5. package/common.d.ts.map +1 -0
  6. package/common.js +14 -0
  7. package/complex/counter.d.ts +15 -0
  8. package/complex/counter.d.ts.map +1 -0
  9. package/complex/counter.js +17 -0
  10. package/complex/global-config.d.ts +11 -0
  11. package/complex/global-config.d.ts.map +1 -0
  12. package/complex/global-config.js +41 -0
  13. package/complex/index.d.ts +4 -0
  14. package/complex/index.d.ts.map +1 -0
  15. package/complex/modules-factory.d.ts +49 -0
  16. package/complex/modules-factory.d.ts.map +1 -0
  17. package/complex/modules-factory.js +46 -0
  18. package/cookie.d.ts +3 -0
  19. package/cookie.d.ts.map +1 -0
  20. package/cookie.js +9 -0
  21. package/css.d.ts +36 -0
  22. package/css.d.ts.map +1 -0
  23. package/css.js +20 -0
  24. package/data.d.ts +4 -0
  25. package/data.d.ts.map +1 -0
  26. package/data.js +52 -0
  27. package/date-time.d.ts +28 -0
  28. package/date-time.d.ts.map +1 -0
  29. package/date-time.js +160 -0
  30. package/device.d.ts +8 -0
  31. package/device.d.ts.map +1 -0
  32. package/device.js +21 -0
  33. package/encodings.d.ts +2 -0
  34. package/encodings.d.ts.map +1 -0
  35. package/encodings.js +267 -0
  36. package/errors.d.ts +19 -0
  37. package/errors.d.ts.map +1 -0
  38. package/errors.js +30 -0
  39. package/file.d.ts +3 -0
  40. package/file.d.ts.map +1 -0
  41. package/file.js +24 -0
  42. package/format/_exports.d.ts +5 -0
  43. package/format/_exports.d.ts.map +1 -0
  44. package/format/constants.d.ts +4 -0
  45. package/format/constants.d.ts.map +1 -0
  46. package/{src/format/constants.ts → format/constants.js} +0 -2
  47. package/format/index.d.ts +3 -0
  48. package/format/index.d.ts.map +1 -0
  49. package/{src/format/index.ts → format/index.js} +0 -1
  50. package/format/number.d.ts +36 -0
  51. package/format/number.d.ts.map +1 -0
  52. package/format/number.js +44 -0
  53. package/format/percent.d.ts +15 -0
  54. package/format/percent.d.ts.map +1 -0
  55. package/format/percent.js +23 -0
  56. package/format/skip-spaces.d.ts +5 -0
  57. package/format/skip-spaces.d.ts.map +1 -0
  58. package/format/skip-spaces.js +4 -0
  59. package/html.d.ts +44 -0
  60. package/html.d.ts.map +1 -0
  61. package/html.js +182 -0
  62. package/id.d.ts +63 -0
  63. package/id.d.ts.map +1 -0
  64. package/{src/id.ts → id.js} +6 -16
  65. package/imports.d.ts +15 -0
  66. package/imports.d.ts.map +1 -0
  67. package/imports.js +40 -0
  68. package/math.d.ts +13 -0
  69. package/math.d.ts.map +1 -0
  70. package/math.js +17 -0
  71. package/media.d.ts +20 -0
  72. package/media.d.ts.map +1 -0
  73. package/media.js +103 -0
  74. package/mobx/apply-observable.d.ts +4 -0
  75. package/mobx/apply-observable.d.ts.map +1 -0
  76. package/mobx/apply-observable.js +12 -0
  77. package/mobx/create-enhanced-atom.d.ts +11 -0
  78. package/mobx/create-enhanced-atom.d.ts.map +1 -0
  79. package/mobx/create-enhanced-atom.js +12 -0
  80. package/mobx/deep-observable-struct.d.ts +7 -0
  81. package/mobx/deep-observable-struct.d.ts.map +1 -0
  82. package/mobx/deep-observable-struct.js +57 -0
  83. package/mobx/get-mobx-administration.d.ts +6 -0
  84. package/mobx/get-mobx-administration.d.ts.map +1 -0
  85. package/mobx/get-mobx-administration.js +2 -0
  86. package/mobx/index.d.ts +6 -0
  87. package/mobx/index.d.ts.map +1 -0
  88. package/mobx/lazy-observe.d.ts +8 -0
  89. package/mobx/lazy-observe.d.ts.map +1 -0
  90. package/mobx/lazy-observe.js +43 -0
  91. package/ms.d.ts +19 -0
  92. package/ms.d.ts.map +1 -0
  93. package/ms.js +18 -0
  94. package/number.d.ts +8 -0
  95. package/number.d.ts.map +1 -0
  96. package/number.js +13 -0
  97. package/package.json +399 -3
  98. package/parser/_exports.d.ts +4 -0
  99. package/parser/_exports.d.ts.map +1 -0
  100. package/parser/index.d.ts +3 -0
  101. package/parser/index.d.ts.map +1 -0
  102. package/{src/parser/index.ts → parser/index.js} +0 -1
  103. package/parser/number.d.ts +21 -0
  104. package/parser/number.d.ts.map +1 -0
  105. package/parser/number.js +44 -0
  106. package/parser/percent.d.ts +4 -0
  107. package/parser/percent.d.ts.map +1 -0
  108. package/parser/percent.js +4 -0
  109. package/parser/string.d.ts +7 -0
  110. package/parser/string.d.ts.map +1 -0
  111. package/parser/string.js +14 -0
  112. package/price.d.ts +6 -0
  113. package/price.d.ts.map +1 -0
  114. package/price.js +17 -0
  115. package/random.d.ts +9 -0
  116. package/random.d.ts.map +1 -0
  117. package/random.js +14 -0
  118. package/react/hooks/index.d.ts +22 -0
  119. package/react/hooks/index.d.ts.map +1 -0
  120. package/react/hooks/use-abort-controller.d.ts +2 -0
  121. package/react/hooks/use-abort-controller.d.ts.map +1 -0
  122. package/react/hooks/use-abort-controller.js +11 -0
  123. package/react/hooks/use-abort-signal.d.ts +2 -0
  124. package/react/hooks/use-abort-signal.d.ts.map +1 -0
  125. package/{src/react/hooks/use-abort-signal.ts → react/hooks/use-abort-signal.js} +1 -2
  126. package/react/hooks/use-click-outside.d.ts +9 -0
  127. package/react/hooks/use-click-outside.d.ts.map +1 -0
  128. package/react/hooks/use-click-outside.js +13 -0
  129. package/react/hooks/use-constant.d.ts +9 -0
  130. package/react/hooks/use-constant.d.ts.map +1 -0
  131. package/{src/react/hooks/use-constant.ts → react/hooks/use-constant.js} +6 -9
  132. package/react/hooks/use-define-ref.d.ts +10 -0
  133. package/react/hooks/use-define-ref.d.ts.map +1 -0
  134. package/{src/react/hooks/use-define-ref.ts → react/hooks/use-define-ref.js} +7 -10
  135. package/react/hooks/use-element-ref.d.ts +2 -0
  136. package/react/hooks/use-element-ref.d.ts.map +1 -0
  137. package/react/hooks/use-element-ref.js +8 -0
  138. package/react/hooks/use-event-listener.d.ts +8 -0
  139. package/react/hooks/use-event-listener.d.ts.map +1 -0
  140. package/react/hooks/use-event-listener.js +13 -0
  141. package/react/hooks/use-event.d.ts +3 -0
  142. package/react/hooks/use-event.d.ts.map +1 -0
  143. package/react/hooks/use-event.js +19 -0
  144. package/react/hooks/use-flag.d.ts +8 -0
  145. package/react/hooks/use-flag.d.ts.map +1 -0
  146. package/react/hooks/use-flag.js +15 -0
  147. package/react/hooks/use-force-update.d.ts +2 -0
  148. package/react/hooks/use-force-update.d.ts.map +1 -0
  149. package/react/hooks/use-force-update.js +7 -0
  150. package/react/hooks/use-initial-height.d.ts +5 -0
  151. package/react/hooks/use-initial-height.d.ts.map +1 -0
  152. package/react/hooks/use-initial-height.js +11 -0
  153. package/react/hooks/use-instance.d.ts +27 -0
  154. package/react/hooks/use-instance.d.ts.map +1 -0
  155. package/{src/react/hooks/use-instance.ts → react/hooks/use-instance.js} +7 -29
  156. package/react/hooks/use-intersection-observer.d.ts +2 -0
  157. package/react/hooks/use-intersection-observer.d.ts.map +1 -0
  158. package/react/hooks/use-intersection-observer.js +10 -0
  159. package/react/hooks/use-last-defined-value.d.ts +2 -0
  160. package/react/hooks/use-last-defined-value.d.ts.map +1 -0
  161. package/react/hooks/use-last-defined-value.js +8 -0
  162. package/react/hooks/use-last-value-ref.d.ts +2 -0
  163. package/react/hooks/use-last-value-ref.d.ts.map +1 -0
  164. package/react/hooks/use-last-value-ref.js +8 -0
  165. package/react/hooks/use-life-cycle.d.ts +5 -0
  166. package/react/hooks/use-life-cycle.d.ts.map +1 -0
  167. package/react/hooks/use-life-cycle.js +10 -0
  168. package/react/hooks/use-resize-observer.d.ts +2 -0
  169. package/react/hooks/use-resize-observer.d.ts.map +1 -0
  170. package/react/hooks/use-resize-observer.js +11 -0
  171. package/react/hooks/use-sync-ref.d.ts +2 -0
  172. package/react/hooks/use-sync-ref.d.ts.map +1 -0
  173. package/react/hooks/use-sync-ref.js +6 -0
  174. package/react/hooks/use-toggle.d.ts +2 -0
  175. package/react/hooks/use-toggle.d.ts.map +1 -0
  176. package/react/hooks/use-toggle.js +6 -0
  177. package/react/hooks/use-value.d.ts +5 -0
  178. package/react/hooks/use-value.d.ts.map +1 -0
  179. package/react/hooks/use-value.js +8 -0
  180. package/react/hooks/use-visibility-state.d.ts +2 -0
  181. package/react/hooks/use-visibility-state.d.ts.map +1 -0
  182. package/react/hooks/use-visibility-state.js +14 -0
  183. package/react/index.d.ts +2 -0
  184. package/react/index.d.ts.map +1 -0
  185. package/sound.d.ts +7 -0
  186. package/sound.d.ts.map +1 -0
  187. package/sound.js +12 -0
  188. package/storage.d.ts +39 -0
  189. package/storage.d.ts.map +1 -0
  190. package/storage.js +43 -0
  191. package/text.d.ts +15 -0
  192. package/text.d.ts.map +1 -0
  193. package/text.js +48 -0
  194. package/type-guard/_exports.d.ts +86 -0
  195. package/type-guard/_exports.d.ts.map +1 -0
  196. package/type-guard/_exports.js +125 -0
  197. package/type-guard/index.d.ts +3 -0
  198. package/type-guard/index.d.ts.map +1 -0
  199. package/{src/type-guard/index.ts → type-guard/index.js} +0 -1
  200. package/utility-types.d.ts +395 -0
  201. package/utils/types.d.ts +395 -0
  202. package/utils/types.d.ts.map +1 -0
  203. package/utils/types.js +1 -0
  204. package/vibrate.d.ts +5 -0
  205. package/vibrate.d.ts.map +1 -0
  206. package/vibrate.js +8 -0
  207. package/.changeset/README.md +0 -8
  208. package/.changeset/config.json +0 -11
  209. package/.github/FUNDING.yml +0 -1
  210. package/.github/workflows/main.yml +0 -34
  211. package/.github/workflows/version-or-publish.yml +0 -45
  212. package/.nvmrc +0 -1
  213. package/.vscode/settings.json +0 -19
  214. package/CHANGELOG.md +0 -215
  215. package/CONTRIBUTING.md +0 -8
  216. package/Makefile +0 -7
  217. package/biome.json +0 -3
  218. package/commitfmt.toml +0 -18
  219. package/lefthook.yml +0 -14
  220. package/scripts/post-build.ts +0 -71
  221. package/src/async.ts +0 -86
  222. package/src/complex/counter.test.ts +0 -41
  223. package/src/complex/counter.ts +0 -40
  224. package/src/complex/global-config.ts +0 -55
  225. package/src/complex/modules-factory.ts +0 -65
  226. package/src/cookie.ts +0 -11
  227. package/src/css.ts +0 -60
  228. package/src/data.test.ts +0 -99
  229. package/src/data.ts +0 -65
  230. package/src/date-time.test.ts +0 -119
  231. package/src/date-time.ts +0 -236
  232. package/src/device.ts +0 -42
  233. package/src/encodings.ts +0 -270
  234. package/src/errors.ts +0 -40
  235. package/src/file.ts +0 -25
  236. package/src/format/number.test.ts +0 -16
  237. package/src/format/number.ts +0 -96
  238. package/src/format/percent.ts +0 -40
  239. package/src/format/skip-spaces.ts +0 -4
  240. package/src/html.ts +0 -238
  241. package/src/imports.ts +0 -52
  242. package/src/math.ts +0 -20
  243. package/src/media.ts +0 -134
  244. package/src/mobx/apply-observable.ts +0 -20
  245. package/src/mobx/create-enhanced-atom.ts +0 -28
  246. package/src/mobx/deep-observable-struct.test.ts +0 -69
  247. package/src/mobx/deep-observable-struct.ts +0 -69
  248. package/src/mobx/get-mobx-administration.ts +0 -10
  249. package/src/mobx/lazy-observe.ts +0 -59
  250. package/src/ms.ts +0 -20
  251. package/src/number.ts +0 -14
  252. package/src/parser/number.test.ts +0 -38
  253. package/src/parser/number.ts +0 -73
  254. package/src/parser/percent.ts +0 -11
  255. package/src/parser/string.ts +0 -29
  256. package/src/price.ts +0 -33
  257. package/src/random.ts +0 -27
  258. package/src/react/hooks/use-abort-controller.ts +0 -15
  259. package/src/react/hooks/use-click-outside.ts +0 -27
  260. package/src/react/hooks/use-element-ref.ts +0 -11
  261. package/src/react/hooks/use-event-listener.ts +0 -29
  262. package/src/react/hooks/use-event.ts +0 -23
  263. package/src/react/hooks/use-flag.ts +0 -27
  264. package/src/react/hooks/use-force-update.ts +0 -9
  265. package/src/react/hooks/use-initial-height.ts +0 -16
  266. package/src/react/hooks/use-intersection-observer.ts +0 -18
  267. package/src/react/hooks/use-last-defined-value.ts +0 -9
  268. package/src/react/hooks/use-last-value-ref.ts +0 -11
  269. package/src/react/hooks/use-life-cycle.ts +0 -17
  270. package/src/react/hooks/use-resize-observer.ts +0 -14
  271. package/src/react/hooks/use-sync-ref.ts +0 -7
  272. package/src/react/hooks/use-toggle.ts +0 -9
  273. package/src/react/hooks/use-value.ts +0 -10
  274. package/src/react/hooks/use-visibility-state.ts +0 -19
  275. package/src/sound.ts +0 -15
  276. package/src/storage.ts +0 -137
  277. package/src/text.test.ts +0 -91
  278. package/src/text.ts +0 -60
  279. package/src/type-guard/_exports.ts +0 -154
  280. package/src/type-guard/index.test.ts +0 -127
  281. package/src/vibrate.ts +0 -8
  282. package/tsconfig.json +0 -26
  283. package/tsconfig.test.json +0 -33
  284. package/vitest.config.ts +0 -20
  285. /package/{src/complex/index.ts → complex/index.js} +0 -0
  286. /package/{src/format/_exports.ts → format/_exports.js} +0 -0
  287. /package/{src/mobx/index.ts → mobx/index.js} +0 -0
  288. /package/{src/parser/_exports.ts → parser/_exports.js} +0 -0
  289. /package/{src/react/hooks/index.ts → react/hooks/index.js} +0 -0
  290. /package/{src/react/index.ts → react/index.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAO9C,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,KAAK,MAAM,EACX,YAAY,MAAM,WACsC,CAAC;AAmB3D,MAAM,WAAW,kBAAkB,CAAC,CAAC,CACnC,SAAQ,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,yBAAyB,CACnC,CAAC,EACD,UAAU,SAAS,iBAAiB,IAClC,IAAI,CACN,kBAAkB,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,MAAM,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACvD,GACC,OAAO,CACL,IAAI,CACF,kBAAkB,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,MAAM,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACvD,CACF,GACD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,UAAU,EAAE,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3E,MAAM,MAAM,2BAA2B,CACrC,CAAC,EACD,UAAU,SAAS,iBAAiB,IAClC,IAAI,CACN,oBAAoB,CAAC,CAAC,CAAC,EACvB,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACzD,GACC,OAAO,CACL,IAAI,CACF,oBAAoB,CAAC,CAAC,CAAC,EACvB,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACzD,CACF,GACD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,UAAU,EAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7E,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,CACnD,CAAC;AAEF,MAAM,WAAW,UAAU,CAAC,UAAU,SAAS,iBAAiB;IAC9D,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,yBAAyB,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;IACvE,GAAG,CAAC,KAAK,EACP,MAAM,EAAE,2BAA2B,CAAC,KAAK,EAAE,UAAU,CAAC,GACrD,KAAK,GAAG,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,SAAS,iBAAiB,EAChE,aAAa,EAAE,UAAU,GACxB,UAAU,CAAC,UAAU,CAAC,CAgCxB"}
package/storage.js ADDED
@@ -0,0 +1,43 @@
1
+ const storages = {
2
+ session: sessionStorage,
3
+ local: localStorage,
4
+ };
5
+ export const createStorageKey = (prefix, key, namespace) => `${prefix}${namespace ? `/${namespace}` : ''}/${key}`;
6
+ const parseStorageValue = (value) => {
7
+ if (typeof value !== 'string') {
8
+ return value;
9
+ }
10
+ try {
11
+ const parsed = JSON.parse(value);
12
+ return parsed;
13
+ }
14
+ catch {
15
+ return null;
16
+ }
17
+ };
18
+ const formatValueToStorage = (value) => {
19
+ return JSON.stringify(value);
20
+ };
21
+ /**
22
+ * Создает интерфейс для работы с хранилищем (localStorage, sessionStorage)
23
+ */
24
+ export function createStorage(storageConfig) {
25
+ return {
26
+ set: (cfg) => {
27
+ const config = cfg;
28
+ const storageType = (config.type ?? storageConfig.type);
29
+ const storagePrefix = (config.prefix ?? storageConfig.prefix);
30
+ const storage = storages[storageType];
31
+ storage.setItem(createStorageKey(storagePrefix, config.key, config.namespace), formatValueToStorage(config.value));
32
+ },
33
+ get: (cfg) => {
34
+ const config = cfg;
35
+ const storageType = (config.type ?? storageConfig.type);
36
+ const storagePrefix = (config.prefix ?? storageConfig.prefix);
37
+ const storage = storages[storageType];
38
+ return (parseStorageValue(storage.getItem(createStorageKey(storagePrefix, config.key, config.namespace))) ??
39
+ config.fallback ??
40
+ null);
41
+ },
42
+ };
43
+ }
package/text.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Склонение слова в зависимости от количества
3
+ * @example
4
+ * declension(1, ['слово', 'слова', 'слов']) // 'слово'
5
+ * @example
6
+ * declension(2, ['слово', 'слова', 'слов']) // 'слова'
7
+ * @example
8
+ * declension(5, ['слово', 'слова', 'слов']) // 'слов'
9
+ */
10
+ export declare const declension: (count: number, txt: readonly [one: string, two: string, five: string], cases?: number[]) => string;
11
+ /**
12
+ * Разбиение текста на линии
13
+ */
14
+ export declare const splitTextByLines: (text: string, lineLingth?: number) => string[];
15
+ //# sourceMappingURL=text.d.ts.map
package/text.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,EACb,KAAK,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EACtD,gBAA0B,WAEmD,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,aAAY,MAAW,KACtB,MAAM,EAqCR,CAAC"}
package/text.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Склонение слова в зависимости от количества
3
+ * @example
4
+ * declension(1, ['слово', 'слова', 'слов']) // 'слово'
5
+ * @example
6
+ * declension(2, ['слово', 'слова', 'слов']) // 'слова'
7
+ * @example
8
+ * declension(5, ['слово', 'слова', 'слов']) // 'слов'
9
+ */
10
+ export const declension = (count, txt, cases = [2, 0, 1, 1, 1, 2]) => txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];
11
+ /**
12
+ * Разбиение текста на линии
13
+ */
14
+ export const splitTextByLines = (text, lineLingth = 60) => {
15
+ const words = text.split(/\s+/).filter((word) => word !== '');
16
+ const lines = [];
17
+ let currentLine = '';
18
+ for (const word of words) {
19
+ if (word.length > lineLingth) {
20
+ if (currentLine !== '') {
21
+ lines.push(currentLine);
22
+ currentLine = '';
23
+ }
24
+ let start = 0;
25
+ while (start < word.length) {
26
+ const chunk = word.slice(start, start + lineLingth);
27
+ lines.push(chunk);
28
+ start += lineLingth;
29
+ }
30
+ continue;
31
+ }
32
+ // Проверка возможности добавления слова в текущую строку
33
+ if (currentLine === '') {
34
+ currentLine = word;
35
+ }
36
+ else if (currentLine.length + 1 + word.length <= lineLingth) {
37
+ currentLine += ` ${word}`;
38
+ }
39
+ else {
40
+ lines.push(currentLine);
41
+ currentLine = word;
42
+ }
43
+ }
44
+ if (currentLine !== '' || lines.length === 0) {
45
+ lines.push(currentLine);
46
+ }
47
+ return lines;
48
+ };
@@ -0,0 +1,86 @@
1
+ import type { AnyFunction, AnyObject } from '../utils/types.js';
2
+ /**
3
+ * Check if a value is not null or undefined
4
+ * @param value the value to check
5
+ * @returns boolean
6
+ */
7
+ export declare const isDefined: <T>(value: T | undefined | null) => value is T;
8
+ /**
9
+ * Check if a value is null
10
+ * @param value the value to check
11
+ * @returns boolean
12
+ */
13
+ export declare const isNull: (value: unknown) => value is null;
14
+ /**
15
+ * Check if a value is undefined
16
+ * @param value the value to check
17
+ * @returns boolean
18
+ */
19
+ export declare const isUndefined: (value: unknown) => value is undefined;
20
+ /**
21
+ * Check if a value is an object
22
+ * @param value the value to check
23
+ * @returns boolean
24
+ */
25
+ export declare const isObject: (value: unknown) => value is AnyObject;
26
+ /**
27
+ * Check if a value is an array
28
+ * @param value the value to check
29
+ * @returns boolean
30
+ */
31
+ export declare const isArray: (value: unknown) => value is unknown[];
32
+ /**
33
+ * Check if a value is a string
34
+ * @param value the value to check
35
+ * @returns boolean
36
+ */
37
+ export declare const isString: (value: unknown) => value is string;
38
+ /**
39
+ * Check if a value is a number
40
+ * @param value the value to check
41
+ * @returns boolean
42
+ */
43
+ export declare const isNumber: (value: unknown) => value is number;
44
+ /**
45
+ * Check if a value is a boolean
46
+ * @param value the value to check
47
+ * @returns boolean
48
+ */
49
+ export declare const isBoolean: (value: unknown) => value is boolean;
50
+ /**
51
+ * Check if a value is a function
52
+ * @param value the value to check
53
+ * @returns boolean
54
+ */
55
+ export declare const isFunction: (value: unknown) => value is AnyFunction;
56
+ /**
57
+ * Check if a value is a regular expression
58
+ * @param value the value to check
59
+ * @returns boolean
60
+ */
61
+ export declare const isRegExp: (value: unknown) => value is RegExp;
62
+ /**
63
+ * Check if a value is a DOM element
64
+ * @param value the value to check
65
+ * @returns boolean
66
+ */
67
+ export declare const isElement: (value: unknown) => value is HTMLElement;
68
+ /**
69
+ * Check if a value is NaN
70
+ * @param value the value to check
71
+ * @returns boolean
72
+ */
73
+ export declare const isNaN: (value: unknown) => boolean;
74
+ /**
75
+ * Check if a value is infinity
76
+ * @param value the value to check
77
+ * @returns boolean
78
+ */
79
+ export declare const isInfinite: (value: unknown) => boolean;
80
+ /**
81
+ * Check if a value is a symbol
82
+ * @param value the value to check
83
+ * @returns boolean
84
+ */
85
+ export declare const isSymbol: (value: unknown) => value is symbol;
86
+ //# sourceMappingURL=_exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_exports.d.ts","sourceRoot":"","sources":["../../src/type-guard/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAoDhE;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,KAAG,KAAK,IAAI,CACrD,CAAC;AAEhB;;;;GAIG;AACH,eAAO,MAAM,MAAM,UAhBT,OAAO,KAAG,KAAK,QAgB6B,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,UAvBd,OAAO,KAAG,KAAK,aAuB4C,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UA9BX,OAAO,KAAG,KAAK,aA8BsC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,OAAO,UArCV,OAAO,KAAG,KAAK,aAqCoC,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UA5CX,OAAO,KAAG,KAAK,UA4CmC,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAnDX,OAAO,KAAG,KAAK,UAmDmC,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,SAAS,UA1DZ,OAAO,KAAG,KAAK,WA0DsC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,UAAU,UAjEb,OAAO,KAAG,KAAK,eAiE4C,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAxEX,OAAO,KAAG,KAAK,UAwEmC,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,SAAS,UA/EZ,OAAO,KAAG,KAAK,eA+E0C,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAwC,CACxD,KAAK,EAAE,OAAO,KACX,OAAO,CAAC;AAEb;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAA6C,CAClE,KAAK,EAAE,OAAO,KACX,OAAO,CAAC;AAEb;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAxGX,OAAO,KAAG,KAAK,UAwGmC,CAAC"}
@@ -0,0 +1,125 @@
1
+ var Type;
2
+ (function (Type) {
3
+ Type["Null"] = "null";
4
+ Type["Undefined"] = "undefined";
5
+ Type["NaN"] = "nan";
6
+ Type["Object"] = "[object Object]";
7
+ Type["Array"] = "[object Array]";
8
+ Type["String"] = "[object String]";
9
+ Type["Number"] = "[object Number]";
10
+ Type["Boolean"] = "[object Boolean]";
11
+ Type["Function"] = "[object Function]";
12
+ Type["RegExp"] = "[object RegExp]";
13
+ Type["Symbol"] = "[object Symbol]";
14
+ Type["Infinite"] = "infinite";
15
+ Type["Element"] = "element";
16
+ })(Type || (Type = {}));
17
+ function getType(value) {
18
+ if (value === undefined) {
19
+ return Type.Undefined;
20
+ }
21
+ if (value === null) {
22
+ return Type.Null;
23
+ }
24
+ // handle DOM elements
25
+ // @ts-expect-error
26
+ if (value && (value.nodeType === 1 || value.nodeType === 9)) {
27
+ return Type.Element;
28
+ }
29
+ const stringifiedValue = Object.prototype.toString.call(value);
30
+ // handle NaN and Infinity
31
+ if (stringifiedValue === Type.Number) {
32
+ if (Number.isNaN(value)) {
33
+ return Type.NaN;
34
+ }
35
+ if (!Number.isFinite(value)) {
36
+ return Type.Infinite;
37
+ }
38
+ }
39
+ return stringifiedValue;
40
+ }
41
+ const createTypeGuard = (type) => (value) => getType(value) === type;
42
+ /**
43
+ * Check if a value is not null or undefined
44
+ * @param value the value to check
45
+ * @returns boolean
46
+ */
47
+ export const isDefined = (value) => value != null;
48
+ /**
49
+ * Check if a value is null
50
+ * @param value the value to check
51
+ * @returns boolean
52
+ */
53
+ export const isNull = createTypeGuard(Type.Null);
54
+ /**
55
+ * Check if a value is undefined
56
+ * @param value the value to check
57
+ * @returns boolean
58
+ */
59
+ export const isUndefined = createTypeGuard(Type.Undefined);
60
+ /**
61
+ * Check if a value is an object
62
+ * @param value the value to check
63
+ * @returns boolean
64
+ */
65
+ export const isObject = createTypeGuard(Type.Object);
66
+ /**
67
+ * Check if a value is an array
68
+ * @param value the value to check
69
+ * @returns boolean
70
+ */
71
+ export const isArray = createTypeGuard(Type.Array);
72
+ /**
73
+ * Check if a value is a string
74
+ * @param value the value to check
75
+ * @returns boolean
76
+ */
77
+ export const isString = createTypeGuard(Type.String);
78
+ /**
79
+ * Check if a value is a number
80
+ * @param value the value to check
81
+ * @returns boolean
82
+ */
83
+ export const isNumber = createTypeGuard(Type.Number);
84
+ /**
85
+ * Check if a value is a boolean
86
+ * @param value the value to check
87
+ * @returns boolean
88
+ */
89
+ export const isBoolean = createTypeGuard(Type.Boolean);
90
+ /**
91
+ * Check if a value is a function
92
+ * @param value the value to check
93
+ * @returns boolean
94
+ */
95
+ export const isFunction = createTypeGuard(Type.Function);
96
+ /**
97
+ * Check if a value is a regular expression
98
+ * @param value the value to check
99
+ * @returns boolean
100
+ */
101
+ export const isRegExp = createTypeGuard(Type.RegExp);
102
+ /**
103
+ * Check if a value is a DOM element
104
+ * @param value the value to check
105
+ * @returns boolean
106
+ */
107
+ export const isElement = createTypeGuard(Type.Element);
108
+ /**
109
+ * Check if a value is NaN
110
+ * @param value the value to check
111
+ * @returns boolean
112
+ */
113
+ export const isNaN = createTypeGuard(Type.NaN);
114
+ /**
115
+ * Check if a value is infinity
116
+ * @param value the value to check
117
+ * @returns boolean
118
+ */
119
+ export const isInfinite = createTypeGuard(Type.Infinite);
120
+ /**
121
+ * Check if a value is a symbol
122
+ * @param value the value to check
123
+ * @returns boolean
124
+ */
125
+ export const isSymbol = createTypeGuard(Type.Symbol);
@@ -0,0 +1,3 @@
1
+ import * as typeGuard from './_exports.js';
2
+ export { typeGuard };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/type-guard/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,5 +1,4 @@
1
1
  // This way is more treeshakable than collecting
2
2
  // it into one exportable object export const typeGuard
3
3
  import * as typeGuard from './_exports.js';
4
-
5
4
  export { typeGuard };