yummies 7.11.0 → 7.13.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 (159) hide show
  1. package/README.md +5 -87
  2. package/async.cjs +179 -48
  3. package/async.cjs.map +1 -1
  4. package/async.d.ts +125 -7
  5. package/async.js +180 -54
  6. package/async.js.map +1 -1
  7. package/chunk-CVq3Gv4J.cjs +50 -0
  8. package/chunk-YKewjYmz.js +37 -0
  9. package/common.cjs +48 -8
  10. package/common.cjs.map +1 -1
  11. package/common.d.ts +53 -2
  12. package/common.js +49 -11
  13. package/common.js.map +1 -1
  14. package/complex.cjs +275 -128
  15. package/complex.cjs.map +1 -1
  16. package/complex.d.ts +66 -0
  17. package/complex.js +275 -133
  18. package/complex.js.map +1 -1
  19. package/cookie.cjs +17 -7
  20. package/cookie.cjs.map +1 -1
  21. package/cookie.d.ts +26 -0
  22. package/cookie.js +18 -9
  23. package/cookie.js.map +1 -1
  24. package/css.cjs +163 -39
  25. package/css.cjs.map +1 -1
  26. package/css.d.ts +115 -6
  27. package/css.js +159 -41
  28. package/css.js.map +1 -1
  29. package/data.cjs +90 -55
  30. package/data.cjs.map +1 -1
  31. package/data.d.ts +50 -0
  32. package/data.js +91 -61
  33. package/data.js.map +1 -1
  34. package/date-time.cjs +594 -412
  35. package/date-time.cjs.map +1 -1
  36. package/date-time.d.ts +105 -0
  37. package/date-time.js +591 -421
  38. package/date-time.js.map +1 -1
  39. package/device.cjs +65 -23
  40. package/device.cjs.map +1 -1
  41. package/device.d.ts +49 -0
  42. package/device.js +66 -31
  43. package/device.js.map +1 -1
  44. package/encodings.cjs +275 -266
  45. package/encodings.cjs.map +1 -1
  46. package/encodings.d.ts +25 -0
  47. package/encodings.js +276 -268
  48. package/encodings.js.map +1 -1
  49. package/errors.cjs +36 -18
  50. package/errors.cjs.map +1 -1
  51. package/errors.d.ts +17 -0
  52. package/errors.js +35 -19
  53. package/errors.js.map +1 -1
  54. package/file.cjs +58 -24
  55. package/file.cjs.map +1 -1
  56. package/file.d.ts +32 -0
  57. package/file.js +59 -27
  58. package/file.js.map +1 -1
  59. package/format.cjs +125 -83
  60. package/format.cjs.map +1 -1
  61. package/format.d.ts +18 -0
  62. package/format.js +118 -82
  63. package/format.js.map +1 -1
  64. package/html.cjs +242 -137
  65. package/html.cjs.map +1 -1
  66. package/html.d.ts +81 -0
  67. package/html.js +239 -150
  68. package/html.js.map +1 -1
  69. package/id.cjs +90 -17
  70. package/id.cjs.map +1 -1
  71. package/id.d.ts +16 -0
  72. package/id.js +89 -24
  73. package/id.js.map +1 -1
  74. package/imports.cjs +57 -29
  75. package/imports.cjs.map +1 -1
  76. package/imports.d.ts +24 -0
  77. package/imports.js +56 -31
  78. package/imports.js.map +1 -1
  79. package/math.cjs +32 -6
  80. package/math.cjs.map +1 -1
  81. package/math.d.ts +33 -0
  82. package/math.js +33 -10
  83. package/math.js.map +1 -1
  84. package/media.cjs +291 -84
  85. package/media.cjs.map +1 -1
  86. package/media.d.ts +204 -2
  87. package/media.js +290 -93
  88. package/media.js.map +1 -1
  89. package/mobx.cjs +449 -193
  90. package/mobx.cjs.map +1 -1
  91. package/mobx.d.ts +108 -0
  92. package/mobx.js +447 -200
  93. package/mobx.js.map +1 -1
  94. package/ms.cjs +37 -10
  95. package/ms.cjs.map +1 -1
  96. package/ms.d.ts +16 -0
  97. package/ms.js +38 -13
  98. package/ms.js.map +1 -1
  99. package/number.cjs +29 -7
  100. package/number.cjs.map +1 -1
  101. package/number.d.ts +16 -0
  102. package/number.js +30 -9
  103. package/number.js.map +1 -1
  104. package/package.json +11 -3
  105. package/parser.cjs +117 -64
  106. package/parser.cjs.map +1 -1
  107. package/parser.d.ts +17 -0
  108. package/parser.js +111 -64
  109. package/parser.js.map +1 -1
  110. package/price.cjs +24 -18
  111. package/price.cjs.map +1 -1
  112. package/price.d.ts +24 -0
  113. package/price.js +25 -20
  114. package/price.js.map +1 -1
  115. package/random.cjs +95 -13
  116. package/random.cjs.map +1 -1
  117. package/random.d.ts +80 -0
  118. package/random.js +96 -22
  119. package/random.js.map +1 -1
  120. package/react.cjs +673 -214
  121. package/react.cjs.map +1 -1
  122. package/react.d.ts +21 -0
  123. package/react.js +674 -239
  124. package/react.js.map +1 -1
  125. package/sound.cjs +30 -9
  126. package/sound.cjs.map +1 -1
  127. package/sound.d.ts +16 -0
  128. package/sound.js +31 -11
  129. package/sound.js.map +1 -1
  130. package/storage.cjs +49 -50
  131. package/storage.cjs.map +1 -1
  132. package/storage.d.ts +24 -0
  133. package/storage.js +50 -53
  134. package/storage.js.map +1 -1
  135. package/text.cjs +67 -34
  136. package/text.cjs.map +1 -1
  137. package/text.d.ts +16 -0
  138. package/text.js +68 -37
  139. package/text.js.map +1 -1
  140. package/type-guard.cjs +292 -72
  141. package/type-guard.cjs.map +1 -1
  142. package/type-guard.d.ts +18 -0
  143. package/type-guard.js +288 -73
  144. package/type-guard.js.map +1 -1
  145. package/types.cjs +0 -2
  146. package/types.d.ts +41 -0
  147. package/types.global.cjs +0 -2
  148. package/types.global.d.ts +41 -0
  149. package/types.global.js +0 -2
  150. package/types.js +0 -2
  151. package/vibrate.cjs +47 -6
  152. package/vibrate.cjs.map +1 -1
  153. package/vibrate.d.ts +39 -1
  154. package/vibrate.js +48 -8
  155. package/vibrate.js.map +1 -1
  156. package/types.cjs.map +0 -1
  157. package/types.global.cjs.map +0 -1
  158. package/types.global.js.map +0 -1
  159. package/types.js.map +0 -1
package/text.cjs CHANGED
@@ -1,38 +1,71 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- 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)]];
4
- const splitTextByLines = (text, lineLingth = 60) => {
5
- const words = text.split(/\s+/).filter((word) => word !== "");
6
- const lines = [];
7
- let currentLine = "";
8
- for (const word of words) {
9
- if (word.length > lineLingth) {
10
- if (currentLine !== "") {
11
- lines.push(currentLine);
12
- currentLine = "";
13
- }
14
- let start = 0;
15
- while (start < word.length) {
16
- const chunk = word.slice(start, start + lineLingth);
17
- lines.push(chunk);
18
- start += lineLingth;
19
- }
20
- continue;
21
- }
22
- if (currentLine === "") {
23
- currentLine = word;
24
- } else if (currentLine.length + 1 + word.length <= lineLingth) {
25
- currentLine += ` ${word}`;
26
- } else {
27
- lines.push(currentLine);
28
- currentLine = word;
29
- }
30
- }
31
- if (currentLine !== "" || lines.length === 0) {
32
- lines.push(currentLine);
33
- }
34
- return lines;
2
+ //#region src/text.ts
3
+ /**
4
+ * ---header-docs-section---
5
+ * # yummies/text
6
+ *
7
+ * ## Description
8
+ *
9
+ * Russian-centric text helpers: **declension** by count (одно слово / два слова / пять слов) and
10
+ * utilities for splitting long strings into wrapped lines. Pair with `yummies/date-time` for
11
+ * natural language timestamps and labels in Slavic locales.
12
+ *
13
+ * ## Usage
14
+ *
15
+ * ```ts
16
+ * import { declension } from "yummies/text";
17
+ * ```
18
+ */
19
+ /**
20
+ * Returns the correct word form based on the provided count.
21
+ * @example
22
+ * declension(1, ['slovo', 'slova', 'slov']) // 'slovo'
23
+ * @example
24
+ * declension(2, ['slovo', 'slova', 'slov']) // 'slova'
25
+ * @example
26
+ * declension(5, ['slovo', 'slova', 'slov']) // 'slov'
27
+ */
28
+ var declension = (count, txt, cases = [
29
+ 2,
30
+ 0,
31
+ 1,
32
+ 1,
33
+ 1,
34
+ 2
35
+ ]) => txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];
36
+ /**
37
+ * Splits text into lines with a maximum line length.
38
+ */
39
+ var splitTextByLines = (text, lineLingth = 60) => {
40
+ const words = text.split(/\s+/).filter((word) => word !== "");
41
+ const lines = [];
42
+ let currentLine = "";
43
+ for (const word of words) {
44
+ if (word.length > lineLingth) {
45
+ if (currentLine !== "") {
46
+ lines.push(currentLine);
47
+ currentLine = "";
48
+ }
49
+ let start = 0;
50
+ while (start < word.length) {
51
+ const chunk = word.slice(start, start + lineLingth);
52
+ lines.push(chunk);
53
+ start += lineLingth;
54
+ }
55
+ continue;
56
+ }
57
+ if (currentLine === "") currentLine = word;
58
+ else if (currentLine.length + 1 + word.length <= lineLingth) currentLine += ` ${word}`;
59
+ else {
60
+ lines.push(currentLine);
61
+ currentLine = word;
62
+ }
63
+ }
64
+ if (currentLine !== "" || lines.length === 0) lines.push(currentLine);
65
+ return lines;
35
66
  };
67
+ //#endregion
36
68
  exports.declension = declension;
37
69
  exports.splitTextByLines = splitTextByLines;
38
- //# sourceMappingURL=text.cjs.map
70
+
71
+ //# sourceMappingURL=text.cjs.map
package/text.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.cjs","sources":["../src/text.ts"],"sourcesContent":["/**\n * Returns the correct word form based on the provided count.\n * @example\n * declension(1, ['slovo', 'slova', 'slov']) // 'slovo'\n * @example\n * declension(2, ['slovo', 'slova', 'slov']) // 'slova'\n * @example\n * declension(5, ['slovo', 'slova', 'slov']) // 'slov'\n */\nexport const declension = (\n count: number,\n txt: readonly [one: string, two: string, five: string],\n cases = [2, 0, 1, 1, 1, 2],\n) =>\n txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];\n\n/**\n * Splits text into lines with a maximum line length.\n */\nexport const splitTextByLines = (\n text: string,\n lineLingth: number = 60,\n): string[] => {\n const words = text.split(/\\s+/).filter((word) => word !== '');\n const lines = [];\n let currentLine = '';\n\n for (const word of words) {\n if (word.length > lineLingth) {\n if (currentLine !== '') {\n lines.push(currentLine);\n currentLine = '';\n }\n\n let start = 0;\n while (start < word.length) {\n const chunk = word.slice(start, start + lineLingth);\n lines.push(chunk);\n start += lineLingth;\n }\n continue;\n }\n\n // Проверка возможности добавления слова в текущую строку\n if (currentLine === '') {\n currentLine = word;\n } else if (currentLine.length + 1 + word.length <= lineLingth) {\n currentLine += ` ${word}`;\n } else {\n lines.push(currentLine);\n currentLine = word;\n }\n }\n\n if (currentLine !== '' || lines.length === 0) {\n lines.push(currentLine);\n }\n\n return lines;\n};\n"],"names":[],"mappings":";;AASO,MAAM,aAAa,CACxB,OACA,KACA,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,MAEzB,IAAI,QAAQ,MAAM,KAAK,QAAQ,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC;AAKvE,MAAM,mBAAmB,CAC9B,MACA,aAAqB,OACR;AACb,QAAM,QAAQ,KAAK,MAAM,KAAK,EAAE,OAAO,CAAC,SAAS,SAAS,EAAE;AAC5D,QAAM,QAAQ,CAAA;AACd,MAAI,cAAc;AAElB,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,SAAS,YAAY;AAC5B,UAAI,gBAAgB,IAAI;AACtB,cAAM,KAAK,WAAW;AACtB,sBAAc;AAAA,MAChB;AAEA,UAAI,QAAQ;AACZ,aAAO,QAAQ,KAAK,QAAQ;AAC1B,cAAM,QAAQ,KAAK,MAAM,OAAO,QAAQ,UAAU;AAClD,cAAM,KAAK,KAAK;AAChB,iBAAS;AAAA,MACX;AACA;AAAA,IACF;AAGA,QAAI,gBAAgB,IAAI;AACtB,oBAAc;AAAA,IAChB,WAAW,YAAY,SAAS,IAAI,KAAK,UAAU,YAAY;AAC7D,qBAAe,IAAI,IAAI;AAAA,IACzB,OAAO;AACL,YAAM,KAAK,WAAW;AACtB,oBAAc;AAAA,IAChB;AAAA,EACF;AAEA,MAAI,gBAAgB,MAAM,MAAM,WAAW,GAAG;AAC5C,UAAM,KAAK,WAAW;AAAA,EACxB;AAEA,SAAO;AACT;;;"}
1
+ {"version":3,"file":"text.cjs","names":[],"sources":["../src/text.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/text\n *\n * ## Description\n *\n * Russian-centric text helpers: **declension** by count (одно слово / два слова / пять слов) and\n * utilities for splitting long strings into wrapped lines. Pair with `yummies/date-time` for\n * natural language timestamps and labels in Slavic locales.\n *\n * ## Usage\n *\n * ```ts\n * import { declension } from \"yummies/text\";\n * ```\n */\n\n/**\n * Returns the correct word form based on the provided count.\n * @example\n * declension(1, ['slovo', 'slova', 'slov']) // 'slovo'\n * @example\n * declension(2, ['slovo', 'slova', 'slov']) // 'slova'\n * @example\n * declension(5, ['slovo', 'slova', 'slov']) // 'slov'\n */\nexport const declension = (\n count: number,\n txt: readonly [one: string, two: string, five: string],\n cases = [2, 0, 1, 1, 1, 2],\n) =>\n txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];\n\n/**\n * Splits text into lines with a maximum line length.\n */\nexport const splitTextByLines = (\n text: string,\n lineLingth: number = 60,\n): string[] => {\n const words = text.split(/\\s+/).filter((word) => word !== '');\n const lines = [];\n let currentLine = '';\n\n for (const word of words) {\n if (word.length > lineLingth) {\n if (currentLine !== '') {\n lines.push(currentLine);\n currentLine = '';\n }\n\n let start = 0;\n while (start < word.length) {\n const chunk = word.slice(start, start + lineLingth);\n lines.push(chunk);\n start += lineLingth;\n }\n continue;\n }\n\n // Проверка возможности добавления слова в текущую строку\n if (currentLine === '') {\n currentLine = word;\n } else if (currentLine.length + 1 + word.length <= lineLingth) {\n currentLine += ` ${word}`;\n } else {\n lines.push(currentLine);\n currentLine = word;\n }\n }\n\n if (currentLine !== '' || lines.length === 0) {\n lines.push(currentLine);\n }\n\n return lines;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,cACX,OACA,KACA,QAAQ;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAE,KAE1B,IAAI,QAAQ,MAAM,KAAK,QAAQ,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,QAAQ,IAAI,EAAE;;;;AAK7E,IAAa,oBACX,MACA,aAAqB,OACR;CACb,MAAM,QAAQ,KAAK,MAAM,MAAM,CAAC,QAAQ,SAAS,SAAS,GAAG;CAC7D,MAAM,QAAQ,EAAE;CAChB,IAAI,cAAc;AAElB,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,KAAK,SAAS,YAAY;AAC5B,OAAI,gBAAgB,IAAI;AACtB,UAAM,KAAK,YAAY;AACvB,kBAAc;;GAGhB,IAAI,QAAQ;AACZ,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,QAAQ,KAAK,MAAM,OAAO,QAAQ,WAAW;AACnD,UAAM,KAAK,MAAM;AACjB,aAAS;;AAEX;;AAIF,MAAI,gBAAgB,GAClB,eAAc;WACL,YAAY,SAAS,IAAI,KAAK,UAAU,WACjD,gBAAe,IAAI;OACd;AACL,SAAM,KAAK,YAAY;AACvB,iBAAc;;;AAIlB,KAAI,gBAAgB,MAAM,MAAM,WAAW,EACzC,OAAM,KAAK,YAAY;AAGzB,QAAO"}
package/text.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ * ---header-docs-section---
3
+ * # yummies/text
4
+ *
5
+ * ## Description
6
+ *
7
+ * Russian-centric text helpers: **declension** by count (одно слово / два слова / пять слов) and
8
+ * utilities for splitting long strings into wrapped lines. Pair with `yummies/date-time` for
9
+ * natural language timestamps and labels in Slavic locales.
10
+ *
11
+ * ## Usage
12
+ *
13
+ * ```ts
14
+ * import { declension } from "yummies/text";
15
+ * ```
16
+ */
1
17
  /**
2
18
  * Returns the correct word form based on the provided count.
3
19
  * @example
package/text.js CHANGED
@@ -1,38 +1,69 @@
1
- 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)]];
2
- const splitTextByLines = (text, lineLingth = 60) => {
3
- const words = text.split(/\s+/).filter((word) => word !== "");
4
- const lines = [];
5
- let currentLine = "";
6
- for (const word of words) {
7
- if (word.length > lineLingth) {
8
- if (currentLine !== "") {
9
- lines.push(currentLine);
10
- currentLine = "";
11
- }
12
- let start = 0;
13
- while (start < word.length) {
14
- const chunk = word.slice(start, start + lineLingth);
15
- lines.push(chunk);
16
- start += lineLingth;
17
- }
18
- continue;
19
- }
20
- if (currentLine === "") {
21
- currentLine = word;
22
- } else if (currentLine.length + 1 + word.length <= lineLingth) {
23
- currentLine += ` ${word}`;
24
- } else {
25
- lines.push(currentLine);
26
- currentLine = word;
27
- }
28
- }
29
- if (currentLine !== "" || lines.length === 0) {
30
- lines.push(currentLine);
31
- }
32
- return lines;
1
+ //#region src/text.ts
2
+ /**
3
+ * ---header-docs-section---
4
+ * # yummies/text
5
+ *
6
+ * ## Description
7
+ *
8
+ * Russian-centric text helpers: **declension** by count (одно слово / два слова / пять слов) and
9
+ * utilities for splitting long strings into wrapped lines. Pair with `yummies/date-time` for
10
+ * natural language timestamps and labels in Slavic locales.
11
+ *
12
+ * ## Usage
13
+ *
14
+ * ```ts
15
+ * import { declension } from "yummies/text";
16
+ * ```
17
+ */
18
+ /**
19
+ * Returns the correct word form based on the provided count.
20
+ * @example
21
+ * declension(1, ['slovo', 'slova', 'slov']) // 'slovo'
22
+ * @example
23
+ * declension(2, ['slovo', 'slova', 'slov']) // 'slova'
24
+ * @example
25
+ * declension(5, ['slovo', 'slova', 'slov']) // 'slov'
26
+ */
27
+ var declension = (count, txt, cases = [
28
+ 2,
29
+ 0,
30
+ 1,
31
+ 1,
32
+ 1,
33
+ 2
34
+ ]) => txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];
35
+ /**
36
+ * Splits text into lines with a maximum line length.
37
+ */
38
+ var splitTextByLines = (text, lineLingth = 60) => {
39
+ const words = text.split(/\s+/).filter((word) => word !== "");
40
+ const lines = [];
41
+ let currentLine = "";
42
+ for (const word of words) {
43
+ if (word.length > lineLingth) {
44
+ if (currentLine !== "") {
45
+ lines.push(currentLine);
46
+ currentLine = "";
47
+ }
48
+ let start = 0;
49
+ while (start < word.length) {
50
+ const chunk = word.slice(start, start + lineLingth);
51
+ lines.push(chunk);
52
+ start += lineLingth;
53
+ }
54
+ continue;
55
+ }
56
+ if (currentLine === "") currentLine = word;
57
+ else if (currentLine.length + 1 + word.length <= lineLingth) currentLine += ` ${word}`;
58
+ else {
59
+ lines.push(currentLine);
60
+ currentLine = word;
61
+ }
62
+ }
63
+ if (currentLine !== "" || lines.length === 0) lines.push(currentLine);
64
+ return lines;
33
65
  };
34
- export {
35
- declension,
36
- splitTextByLines
37
- };
38
- //# sourceMappingURL=text.js.map
66
+ //#endregion
67
+ export { declension, splitTextByLines };
68
+
69
+ //# sourceMappingURL=text.js.map
package/text.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sources":["../src/text.ts"],"sourcesContent":["/**\n * Returns the correct word form based on the provided count.\n * @example\n * declension(1, ['slovo', 'slova', 'slov']) // 'slovo'\n * @example\n * declension(2, ['slovo', 'slova', 'slov']) // 'slova'\n * @example\n * declension(5, ['slovo', 'slova', 'slov']) // 'slov'\n */\nexport const declension = (\n count: number,\n txt: readonly [one: string, two: string, five: string],\n cases = [2, 0, 1, 1, 1, 2],\n) =>\n txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];\n\n/**\n * Splits text into lines with a maximum line length.\n */\nexport const splitTextByLines = (\n text: string,\n lineLingth: number = 60,\n): string[] => {\n const words = text.split(/\\s+/).filter((word) => word !== '');\n const lines = [];\n let currentLine = '';\n\n for (const word of words) {\n if (word.length > lineLingth) {\n if (currentLine !== '') {\n lines.push(currentLine);\n currentLine = '';\n }\n\n let start = 0;\n while (start < word.length) {\n const chunk = word.slice(start, start + lineLingth);\n lines.push(chunk);\n start += lineLingth;\n }\n continue;\n }\n\n // Проверка возможности добавления слова в текущую строку\n if (currentLine === '') {\n currentLine = word;\n } else if (currentLine.length + 1 + word.length <= lineLingth) {\n currentLine += ` ${word}`;\n } else {\n lines.push(currentLine);\n currentLine = word;\n }\n }\n\n if (currentLine !== '' || lines.length === 0) {\n lines.push(currentLine);\n }\n\n return lines;\n};\n"],"names":[],"mappings":"AASO,MAAM,aAAa,CACxB,OACA,KACA,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,MAEzB,IAAI,QAAQ,MAAM,KAAK,QAAQ,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC;AAKvE,MAAM,mBAAmB,CAC9B,MACA,aAAqB,OACR;AACb,QAAM,QAAQ,KAAK,MAAM,KAAK,EAAE,OAAO,CAAC,SAAS,SAAS,EAAE;AAC5D,QAAM,QAAQ,CAAA;AACd,MAAI,cAAc;AAElB,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,SAAS,YAAY;AAC5B,UAAI,gBAAgB,IAAI;AACtB,cAAM,KAAK,WAAW;AACtB,sBAAc;AAAA,MAChB;AAEA,UAAI,QAAQ;AACZ,aAAO,QAAQ,KAAK,QAAQ;AAC1B,cAAM,QAAQ,KAAK,MAAM,OAAO,QAAQ,UAAU;AAClD,cAAM,KAAK,KAAK;AAChB,iBAAS;AAAA,MACX;AACA;AAAA,IACF;AAGA,QAAI,gBAAgB,IAAI;AACtB,oBAAc;AAAA,IAChB,WAAW,YAAY,SAAS,IAAI,KAAK,UAAU,YAAY;AAC7D,qBAAe,IAAI,IAAI;AAAA,IACzB,OAAO;AACL,YAAM,KAAK,WAAW;AACtB,oBAAc;AAAA,IAChB;AAAA,EACF;AAEA,MAAI,gBAAgB,MAAM,MAAM,WAAW,GAAG;AAC5C,UAAM,KAAK,WAAW;AAAA,EACxB;AAEA,SAAO;AACT;"}
1
+ {"version":3,"file":"text.js","names":[],"sources":["../src/text.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/text\n *\n * ## Description\n *\n * Russian-centric text helpers: **declension** by count (одно слово / два слова / пять слов) and\n * utilities for splitting long strings into wrapped lines. Pair with `yummies/date-time` for\n * natural language timestamps and labels in Slavic locales.\n *\n * ## Usage\n *\n * ```ts\n * import { declension } from \"yummies/text\";\n * ```\n */\n\n/**\n * Returns the correct word form based on the provided count.\n * @example\n * declension(1, ['slovo', 'slova', 'slov']) // 'slovo'\n * @example\n * declension(2, ['slovo', 'slova', 'slov']) // 'slova'\n * @example\n * declension(5, ['slovo', 'slova', 'slov']) // 'slov'\n */\nexport const declension = (\n count: number,\n txt: readonly [one: string, two: string, five: string],\n cases = [2, 0, 1, 1, 1, 2],\n) =>\n txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];\n\n/**\n * Splits text into lines with a maximum line length.\n */\nexport const splitTextByLines = (\n text: string,\n lineLingth: number = 60,\n): string[] => {\n const words = text.split(/\\s+/).filter((word) => word !== '');\n const lines = [];\n let currentLine = '';\n\n for (const word of words) {\n if (word.length > lineLingth) {\n if (currentLine !== '') {\n lines.push(currentLine);\n currentLine = '';\n }\n\n let start = 0;\n while (start < word.length) {\n const chunk = word.slice(start, start + lineLingth);\n lines.push(chunk);\n start += lineLingth;\n }\n continue;\n }\n\n // Проверка возможности добавления слова в текущую строку\n if (currentLine === '') {\n currentLine = word;\n } else if (currentLine.length + 1 + word.length <= lineLingth) {\n currentLine += ` ${word}`;\n } else {\n lines.push(currentLine);\n currentLine = word;\n }\n }\n\n if (currentLine !== '' || lines.length === 0) {\n lines.push(currentLine);\n }\n\n return lines;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,cACX,OACA,KACA,QAAQ;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAE,KAE1B,IAAI,QAAQ,MAAM,KAAK,QAAQ,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,QAAQ,IAAI,EAAE;;;;AAK7E,IAAa,oBACX,MACA,aAAqB,OACR;CACb,MAAM,QAAQ,KAAK,MAAM,MAAM,CAAC,QAAQ,SAAS,SAAS,GAAG;CAC7D,MAAM,QAAQ,EAAE;CAChB,IAAI,cAAc;AAElB,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,KAAK,SAAS,YAAY;AAC5B,OAAI,gBAAgB,IAAI;AACtB,UAAM,KAAK,YAAY;AACvB,kBAAc;;GAGhB,IAAI,QAAQ;AACZ,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,QAAQ,KAAK,MAAM,OAAO,QAAQ,WAAW;AACnD,UAAM,KAAK,MAAM;AACjB,aAAS;;AAEX;;AAIF,MAAI,gBAAgB,GAClB,eAAc;WACL,YAAY,SAAS,IAAI,KAAK,UAAU,WACjD,gBAAe,IAAI;OACd;AACL,SAAM,KAAK,YAAY;AACvB,iBAAc;;;AAIlB,KAAI,gBAAgB,MAAM,MAAM,WAAW,EACzC,OAAM,KAAK,YAAY;AAGzB,QAAO"}
package/type-guard.cjs CHANGED
@@ -1,76 +1,296 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const TYPE = {
4
- Null: "null",
5
- Undefined: "undefined",
6
- NaN: "nan",
7
- Object: "[object Object]",
8
- Array: "[object Array]",
9
- String: "[object String]",
10
- Number: "[object Number]",
11
- Boolean: "[object Boolean]",
12
- Function: "[object Function]",
13
- AsyncFunction: "[object AsyncFunction]",
14
- RegExp: "[object RegExp]",
15
- Symbol: "[object Symbol]",
16
- Infinite: "infinite",
17
- Element: "element"
2
+ //#region src/type-guard/_exports.ts
3
+ var _exports_exports = /* @__PURE__ */ require("./chunk-CVq3Gv4J.cjs").__exportAll({
4
+ isArray: () => isArray,
5
+ isBoolean: () => isBoolean,
6
+ isDefined: () => isDefined,
7
+ isElement: () => isElement,
8
+ isFunction: () => isFunction,
9
+ isInfinite: () => isInfinite,
10
+ isNaN: () => isNaN,
11
+ isNull: () => isNull,
12
+ isNumber: () => isNumber,
13
+ isObject: () => isObject,
14
+ isRegExp: () => isRegExp,
15
+ isString: () => isString,
16
+ isSymbol: () => isSymbol,
17
+ isUndefined: () => isUndefined
18
+ });
19
+ var TYPE = {
20
+ Null: "null",
21
+ Undefined: "undefined",
22
+ NaN: "nan",
23
+ Object: "[object Object]",
24
+ Array: "[object Array]",
25
+ String: "[object String]",
26
+ Number: "[object Number]",
27
+ Boolean: "[object Boolean]",
28
+ Function: "[object Function]",
29
+ AsyncFunction: "[object AsyncFunction]",
30
+ RegExp: "[object RegExp]",
31
+ Symbol: "[object Symbol]",
32
+ Infinite: "infinite",
33
+ Element: "element"
18
34
  };
19
35
  function getType(value) {
20
- if (value === void 0) {
21
- return TYPE.Undefined;
22
- }
23
- if (value === null) {
24
- return TYPE.Null;
25
- }
26
- if (value && (value.nodeType === 1 || value.nodeType === 9)) {
27
- return TYPE.Element;
28
- }
29
- const stringifiedValue = Object.prototype.toString.call(value);
30
- if (stringifiedValue === TYPE.Number) {
31
- if (Number.isNaN(value)) {
32
- return TYPE.NaN;
33
- }
34
- if (!Number.isFinite(value)) {
35
- return TYPE.Infinite;
36
- }
37
- }
38
- return stringifiedValue;
36
+ if (value === void 0) return TYPE.Undefined;
37
+ if (value === null) return TYPE.Null;
38
+ if (value && (value.nodeType === 1 || value.nodeType === 9)) return TYPE.Element;
39
+ const stringifiedValue = Object.prototype.toString.call(value);
40
+ if (stringifiedValue === TYPE.Number) {
41
+ if (Number.isNaN(value)) return TYPE.NaN;
42
+ if (!Number.isFinite(value)) return TYPE.Infinite;
43
+ }
44
+ return stringifiedValue;
39
45
  }
40
- const createTypeGuard = (...types) => (value) => types.includes(getType(value));
41
- const isDefined = (value) => value != null;
42
- const isNull = createTypeGuard(TYPE.Null);
43
- const isUndefined = createTypeGuard(TYPE.Undefined);
44
- const isObject = createTypeGuard(TYPE.Object);
45
- const isArray = createTypeGuard(TYPE.Array);
46
- const isString = createTypeGuard(TYPE.String);
47
- const isNumber = createTypeGuard(TYPE.Number);
48
- const isBoolean = createTypeGuard(TYPE.Boolean);
49
- const isFunction = createTypeGuard(
50
- TYPE.Function,
51
- TYPE.AsyncFunction
52
- );
53
- const isRegExp = createTypeGuard(TYPE.RegExp);
54
- const isElement = createTypeGuard(TYPE.Element);
55
- const isNaN = createTypeGuard(TYPE.NaN);
56
- const isInfinite = createTypeGuard(TYPE.Infinite);
57
- const isSymbol = createTypeGuard(TYPE.Symbol);
58
- const _exports = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
59
- __proto__: null,
60
- isArray,
61
- isBoolean,
62
- isDefined,
63
- isElement,
64
- isFunction,
65
- isInfinite,
66
- isNaN,
67
- isNull,
68
- isNumber,
69
- isObject,
70
- isRegExp,
71
- isString,
72
- isSymbol,
73
- isUndefined
74
- }, Symbol.toStringTag, { value: "Module" }));
75
- exports.typeGuard = _exports;
76
- //# sourceMappingURL=type-guard.cjs.map
46
+ var createTypeGuard = (...types) => (value) => types.includes(getType(value));
47
+ /**
48
+ * Checks that a value is neither `null` nor `undefined`.
49
+ *
50
+ * @template T Value type without nullish branches.
51
+ * @param value Value to test.
52
+ * @returns `true` when the value is defined.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * isDefined(0); // true
57
+ * ```
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * isDefined(null); // false
62
+ * ```
63
+ */
64
+ var isDefined = (value) => value != null;
65
+ /**
66
+ * Checks whether a value is exactly `null`.
67
+ *
68
+ * @param value Value to test.
69
+ * @returns `true` when the value is `null`.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * isNull(null); // true
74
+ * ```
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * isNull(undefined); // false
79
+ * ```
80
+ */
81
+ var isNull = createTypeGuard(TYPE.Null);
82
+ /**
83
+ * Checks whether a value is exactly `undefined`.
84
+ *
85
+ * @param value Value to test.
86
+ * @returns `true` when the value is `undefined`.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * isUndefined(undefined); // true
91
+ * ```
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * isUndefined('value'); // false
96
+ * ```
97
+ */
98
+ var isUndefined = createTypeGuard(TYPE.Undefined);
99
+ /**
100
+ * Checks whether a value is a plain object.
101
+ *
102
+ * @param value Value to test.
103
+ * @returns `true` when the value matches `[object Object]`.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * isObject({ id: 1 }); // true
108
+ * ```
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * isObject([]); // false
113
+ * ```
114
+ */
115
+ var isObject = createTypeGuard(TYPE.Object);
116
+ /**
117
+ * Checks whether a value is an array.
118
+ *
119
+ * @param value Value to test.
120
+ * @returns `true` when the value is an array.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * isArray([1, 2, 3]); // true
125
+ * ```
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * isArray({ length: 1 }); // false
130
+ * ```
131
+ */
132
+ var isArray = createTypeGuard(TYPE.Array);
133
+ /**
134
+ * Checks whether a value is a string object or primitive string.
135
+ *
136
+ * @param value Value to test.
137
+ * @returns `true` when the value is a string.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * isString('hello'); // true
142
+ * ```
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * isString(123); // false
147
+ * ```
148
+ */
149
+ var isString = createTypeGuard(TYPE.String);
150
+ /**
151
+ * Checks whether a value is a finite number.
152
+ *
153
+ * Unlike `isNaN` and `isInfinite`, this guard only matches regular numeric values.
154
+ *
155
+ * @param value Value to test.
156
+ * @returns `true` when the value is a non-NaN finite number.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * isNumber(123); // true
161
+ * ```
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * isNumber(Number.NaN); // false
166
+ * ```
167
+ */
168
+ var isNumber = createTypeGuard(TYPE.Number);
169
+ /**
170
+ * Checks whether a value is a boolean.
171
+ *
172
+ * @param value Value to test.
173
+ * @returns `true` when the value is a boolean.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * isBoolean(true); // true
178
+ * ```
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * isBoolean('true'); // false
183
+ * ```
184
+ */
185
+ var isBoolean = createTypeGuard(TYPE.Boolean);
186
+ /**
187
+ * Checks whether a value is a synchronous or asynchronous function.
188
+ *
189
+ * @param value Value to test.
190
+ * @returns `true` when the value is a function.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * isFunction(() => {}); // true
195
+ * ```
196
+ *
197
+ * @example
198
+ * ```ts
199
+ * isFunction(async () => {}); // true
200
+ * ```
201
+ */
202
+ var isFunction = createTypeGuard(TYPE.Function, TYPE.AsyncFunction);
203
+ /**
204
+ * Checks whether a value is a regular expression.
205
+ *
206
+ * @param value Value to test.
207
+ * @returns `true` when the value is a `RegExp`.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * isRegExp(/foo/); // true
212
+ * ```
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * isRegExp('foo'); // false
217
+ * ```
218
+ */
219
+ var isRegExp = createTypeGuard(TYPE.RegExp);
220
+ /**
221
+ * Checks whether a value looks like a DOM element or document node.
222
+ *
223
+ * @param value Value to test.
224
+ * @returns `true` when the value has an element-like node type.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * isElement(document.body); // true
229
+ * ```
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * isElement({ nodeType: 3 }); // false
234
+ * ```
235
+ */
236
+ var isElement = createTypeGuard(TYPE.Element);
237
+ /**
238
+ * Checks whether a value is `NaN`.
239
+ *
240
+ * @param value Value to test.
241
+ * @returns `true` when the value is `NaN`.
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * isNaN(Number.NaN); // true
246
+ * ```
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * isNaN(5); // false
251
+ * ```
252
+ */
253
+ var isNaN = createTypeGuard(TYPE.NaN);
254
+ /**
255
+ * Checks whether a value is positive or negative infinity.
256
+ *
257
+ * @param value Value to test.
258
+ * @returns `true` when the value is not finite.
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * isInfinite(Infinity); // true
263
+ * ```
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * isInfinite(10); // false
268
+ * ```
269
+ */
270
+ var isInfinite = createTypeGuard(TYPE.Infinite);
271
+ /**
272
+ * Checks whether a value is a symbol.
273
+ *
274
+ * @param value Value to test.
275
+ * @returns `true` when the value is a symbol.
276
+ *
277
+ * @example
278
+ * ```ts
279
+ * isSymbol(Symbol('id')); // true
280
+ * ```
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * isSymbol('id'); // false
285
+ * ```
286
+ */
287
+ var isSymbol = createTypeGuard(TYPE.Symbol);
288
+ //#endregion
289
+ Object.defineProperty(exports, "typeGuard", {
290
+ enumerable: true,
291
+ get: function() {
292
+ return _exports_exports;
293
+ }
294
+ });
295
+
296
+ //# sourceMappingURL=type-guard.cjs.map