@visulima/string 3.0.0-alpha.15 → 3.0.0-alpha.17

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 (110) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +80 -2
  3. package/dist/align-text.js +2 -2
  4. package/dist/case/camel-case.d.ts +2 -3
  5. package/dist/case/camel-case.js +1 -1
  6. package/dist/case/capital-case.d.ts +2 -3
  7. package/dist/case/capital-case.js +1 -1
  8. package/dist/case/constant-case.d.ts +2 -3
  9. package/dist/case/constant-case.js +1 -1
  10. package/dist/case/dot-case.d.ts +2 -3
  11. package/dist/case/dot-case.js +1 -1
  12. package/dist/case/flat-case.d.ts +2 -3
  13. package/dist/case/flat-case.js +1 -1
  14. package/dist/case/flip-case.d.ts +2 -3
  15. package/dist/case/flip-case.js +1 -1
  16. package/dist/case/identify-case.d.ts +2 -3
  17. package/dist/case/identify-case.js +1 -1
  18. package/dist/case/index.d.ts +2 -3
  19. package/dist/case/index.js +1 -1
  20. package/dist/case/kebab-case.d.ts +2 -3
  21. package/dist/case/kebab-case.js +1 -1
  22. package/dist/case/lower-first.d.ts +2 -3
  23. package/dist/case/lower-first.js +1 -1
  24. package/dist/case/no-case.d.ts +2 -3
  25. package/dist/case/no-case.js +1 -1
  26. package/dist/case/pascal-case.d.ts +2 -3
  27. package/dist/case/pascal-case.js +1 -1
  28. package/dist/case/pascal-snake-case.d.ts +2 -3
  29. package/dist/case/pascal-snake-case.js +1 -1
  30. package/dist/case/path-case.d.ts +2 -3
  31. package/dist/case/path-case.js +1 -1
  32. package/dist/case/sentence-case.d.ts +2 -3
  33. package/dist/case/sentence-case.js +1 -1
  34. package/dist/case/snake-case.d.ts +2 -3
  35. package/dist/case/snake-case.js +1 -1
  36. package/dist/case/split-by-case.d.ts +2 -3
  37. package/dist/case/split-by-case.js +1 -1
  38. package/dist/case/title-case.d.ts +2 -3
  39. package/dist/case/title-case.js +1 -1
  40. package/dist/case/train-case.d.ts +2 -3
  41. package/dist/case/train-case.js +1 -1
  42. package/dist/case/upper-first.d.ts +2 -3
  43. package/dist/case/upper-first.js +1 -1
  44. package/dist/closest-string.js +1 -1
  45. package/dist/compare-similarity.js +1 -1
  46. package/dist/count-occurrences.d.ts +9 -0
  47. package/dist/count-occurrences.js +1 -0
  48. package/dist/direction.d.ts +7 -0
  49. package/dist/direction.js +1 -0
  50. package/dist/east-asian-width.d.ts +52 -0
  51. package/dist/east-asian-width.js +1 -0
  52. package/dist/excerpt.d.ts +25 -0
  53. package/dist/excerpt.js +53 -0
  54. package/dist/get-string-truncated-width.js +1 -1
  55. package/dist/get-string-width.js +1 -1
  56. package/dist/indent.d.ts +87 -0
  57. package/dist/indent.js +1 -0
  58. package/dist/index.d.ts +12 -205
  59. package/dist/index.js +1 -1
  60. package/dist/is-fullwidth-code-point.d.ts +7 -0
  61. package/dist/is-fullwidth-code-point.js +1 -0
  62. package/dist/levenshtein.d.ts +25 -0
  63. package/dist/levenshtein.js +1 -0
  64. package/dist/outdent.js +1 -1
  65. package/dist/packem_shared/_isFullWidth-Dqc3MWgl.js +1 -0
  66. package/dist/packem_shared/closest-C6YDQs4m.js +1 -0
  67. package/dist/packem_shared/constants-B7EE3d7a.js +1 -0
  68. package/dist/packem_shared/dedent-CPjAYUXh.js +1 -0
  69. package/dist/packem_shared/eastAsianWidth-DJV8Kqd-.js +1 -0
  70. package/dist/packem_shared/generate-cache-key-BqU1Cqwm.js +1 -0
  71. package/dist/packem_shared/indent-cz8WMI0e.js +1 -0
  72. package/dist/packem_shared/joinSegments-DwpAvf1_.js +1 -0
  73. package/dist/packem_shared/lru-cache-BtMSrYQJ.js +1 -0
  74. package/dist/packem_shared/normalize-german-eszett-hNMwtGjd.js +1 -0
  75. package/dist/packem_shared/redent-ByOoJ6fN.js +1 -0
  76. package/dist/packem_shared/{types.d-NJ4vcG-A.d.ts → types.d-CmNvyl4l.d.ts} +16 -2
  77. package/dist/packem_shared/{types.d-XxhGlCLZ.d.ts → types.d-fhe030jX.d.ts} +13 -3
  78. package/dist/replace-string.d.ts +10 -0
  79. package/dist/replace-string.js +1 -0
  80. package/dist/slice.js +1 -1
  81. package/dist/slugify.d.ts +1 -1
  82. package/dist/slugify.js +1 -1
  83. package/dist/test/utils.js +2 -2
  84. package/dist/test/vitest.js +1 -1
  85. package/dist/transliterate.d.ts +10 -0
  86. package/dist/{packem_shared/transliterate-D1p1yYE7.js → transliterate.js} +3 -3
  87. package/dist/truncate.js +1 -1
  88. package/dist/utilities.d.ts +1 -2
  89. package/dist/utilities.js +1 -1
  90. package/dist/word-similarity-sort.js +1 -1
  91. package/dist/word-wrap.js +7 -7
  92. package/package.json +37 -1
  93. package/dist/packem_shared/LRUCache-Dpk7Vnfr.js +0 -1
  94. package/dist/packem_shared/closest-uarbVSbs.js +0 -1
  95. package/dist/packem_shared/closestN-Daviv9V6.js +0 -1
  96. package/dist/packem_shared/constants-DmzZF6_u.js +0 -1
  97. package/dist/packem_shared/countOccurrences-DIHSCdcG.js +0 -1
  98. package/dist/packem_shared/direction-dtczwUOE.js +0 -1
  99. package/dist/packem_shared/eastAsianWidthType-GZeXsSGs.js +0 -1
  100. package/dist/packem_shared/excerpt-DhV2yoHG.js +0 -54
  101. package/dist/packem_shared/generate-cache-key-DPByFaMH.js +0 -1
  102. package/dist/packem_shared/indent-CDlPQmpe.js +0 -1
  103. package/dist/packem_shared/isFullwidthCodePoint-DJd4PBMe.js +0 -1
  104. package/dist/packem_shared/joinSegments-D27SxoCV.js +0 -1
  105. package/dist/packem_shared/lookup-CNDd-Nq4.js +0 -1
  106. package/dist/packem_shared/lru-cache.d-BVu2_gfi.d.ts +0 -12
  107. package/dist/packem_shared/normalize-german-eszett-AKfdw2MZ.js +0 -1
  108. package/dist/packem_shared/redent-BECVOaZp.js +0 -1
  109. package/dist/packem_shared/replaceString-aq-C7Wor.js +0 -1
  110. package/dist/packem_shared/stripIndent-Dt8hSxVM.js +0 -1
@@ -1,6 +1,5 @@
1
- import { C as CaseOptions, T as TitleCase } from "../packem_shared/types.d-XxhGlCLZ.js";
2
- import "../packem_shared/types.d-NJ4vcG-A.js";
3
- import "../packem_shared/lru-cache.d-BVu2_gfi.js";
1
+ import { b as CaseOptions, T as TitleCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
4
3
  /**
5
4
  * With Title Case all words are capitalized, except for minor words.
6
5
  * @example
@@ -1 +1 @@
1
- var c=Object.defineProperty;var i=(r,o)=>c(r,"name",{value:o,configurable:!0});import m from"../packem_shared/LRUCache-Dpk7Vnfr.js";import{splitByCase as p}from"./split-by-case.js";import f from"./upper-first.js";import{a as u}from"../packem_shared/generate-cache-key-DPByFaMH.js";import{l as d}from"../packem_shared/normalize-german-eszett-AKfdw2MZ.js";var h=Object.defineProperty,j=i((r,o)=>h(r,"name",{value:o,configurable:!0}),"c");const A=new m(1e3);function w(r,o){if(typeof r!="string")return"";const a=o?.cache??!1,e=o?.cacheStore??A;let t;if(a&&(t=u(r,o)),a&&t&&e.has(t))return e.get(t);const n=p(r,{handleAnsi:o?.handleAnsi,handleEmoji:o?.handleEmoji,knownAcronyms:o?.knownAcronyms,locale:o?.locale,normalize:o?.normalize,separators:void 0,stripAnsi:o?.stripAnsi,stripEmoji:o?.stripEmoji}).map(l=>{const s=o?.locale?.startsWith("de")?d(l):l;return f(o?.locale?s.toLocaleLowerCase(o.locale):s.toLowerCase(),{locale:o?.locale})}).join(" ");return a&&t&&e.set(t,n),n}i(w,"g");j(w,"titleCase");export{w as default};
1
+ import{i as e}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{splitByCase as c}from"./split-by-case.js";import m from"./upper-first.js";import{n as p}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";import{a as f}from"../packem_shared/normalize-german-eszett-hNMwtGjd.js";const d=new e(1e3);function y(t,o){if(typeof t!="string")return"";const a=o?.cache??!1,i=o?.cacheStore??d;let r;if(a&&(r=p(t,o)),a&&r&&i.has(r))return i.get(r);const n=c(t,{handleAnsi:o?.handleAnsi,handleEmoji:o?.handleEmoji,knownAcronyms:o?.knownAcronyms,locale:o?.locale,normalize:o?.normalize,separators:void 0,stripAnsi:o?.stripAnsi,stripEmoji:o?.stripEmoji}).map(s=>{const l=o?.locale?.startsWith("de")?f(s):s;return m(o?.locale?l.toLocaleLowerCase(o.locale):l.toLowerCase(),{locale:o?.locale})}).join(" ");return a&&r&&i.set(r,n),n}export{y as default};
@@ -1,6 +1,5 @@
1
- import { C as CaseOptions, j as TrainCase } from "../packem_shared/types.d-XxhGlCLZ.js";
2
- import "../packem_shared/types.d-NJ4vcG-A.js";
3
- import "../packem_shared/lru-cache.d-BVu2_gfi.js";
1
+ import { b as CaseOptions, j as TrainCase } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
4
3
  /**
5
4
  * Converts a string to Train-Case.
6
5
  * @example
@@ -1 +1 @@
1
- var m=Object.defineProperty;var e=(o,r)=>m(o,"name",{value:r,configurable:!0});import l from"../packem_shared/LRUCache-Dpk7Vnfr.js";import{splitByCase as p}from"./split-by-case.js";import c from"./upper-first.js";import{a as f}from"../packem_shared/generate-cache-key-DPByFaMH.js";import h from"../packem_shared/joinSegments-D27SxoCV.js";var d=Object.defineProperty,u=e((o,r)=>d(o,"name",{value:r,configurable:!0}),"i");const A=new l(1e3),C=u((o,r)=>{if(typeof o!="string")return"";const n=r?.cache??!1,i=r?.cacheStore??A;let t;if(n&&(t=f(o,r)),n&&t&&i.has(t))return i.get(t);const a=h(p(o,{handleAnsi:r?.handleAnsi,handleEmoji:r?.handleEmoji,knownAcronyms:r?.knownAcronyms,locale:r?.locale,normalize:r?.normalize,separators:void 0,stripAnsi:r?.stripAnsi,stripEmoji:r?.stripEmoji}).map(s=>c(s,{locale:r?.locale})),"-");return n&&t&&i.set(t,a),a},"trainCase");export{C as default};
1
+ import{i as a}from"../packem_shared/lru-cache-BtMSrYQJ.js";import{splitByCase as l}from"./split-by-case.js";import e from"./upper-first.js";import{n as p}from"../packem_shared/generate-cache-key-BqU1Cqwm.js";import c from"../packem_shared/joinSegments-DwpAvf1_.js";const f=new a(1e3),y=(n,o)=>{if(typeof n!="string")return"";const t=o?.cache??!1,i=o?.cacheStore??f;let r;if(t&&(r=p(n,o)),t&&r&&i.has(r))return i.get(r);const s=c(l(n,{handleAnsi:o?.handleAnsi,handleEmoji:o?.handleEmoji,knownAcronyms:o?.knownAcronyms,locale:o?.locale,normalize:o?.normalize,separators:void 0,stripAnsi:o?.stripAnsi,stripEmoji:o?.stripEmoji}).map(m=>e(m,{locale:o?.locale})),"-");return t&&r&&i.set(r,s),s};export{y as default};
@@ -1,6 +1,5 @@
1
- import { L as LocaleOptions, U as UpperFirst } from "../packem_shared/types.d-XxhGlCLZ.js";
2
- import "../packem_shared/types.d-NJ4vcG-A.js";
3
- import "../packem_shared/lru-cache.d-BVu2_gfi.js";
1
+ import { L as LocaleOptions, U as UpperFirst } from "../packem_shared/types.d-fhe030jX.js";
2
+ import "../packem_shared/types.d-CmNvyl4l.js";
4
3
  /**
5
4
  * Converts first character to upper case.
6
5
  * @param value The string to convert.
@@ -1 +1 @@
1
- var p=Object.defineProperty;var o=(e,a)=>p(e,"name",{value:a,configurable:!0});var t=Object.defineProperty,l=o((e,a)=>t(e,"name",{value:a,configurable:!0}),"s");const s=l((e,a)=>typeof e!="string"||e===""?"":(a?.locale?e[0].toLocaleUpperCase(a.locale):e[0].toUpperCase())+e.slice(1),"upperFirst");export{s as default};
1
+ const a=(e,o)=>typeof e!="string"||e===""?"":(o?.locale?e[0].toLocaleUpperCase(o.locale):e[0].toUpperCase())+e.slice(1);export{a as default};
@@ -1 +1 @@
1
- var g=Object.defineProperty;var l=(t,e)=>g(t,"name",{value:e,configurable:!0});import{distance as p}from"./packem_shared/closest-uarbVSbs.js";var u=Object.defineProperty,m=l((t,e)=>u(t,"name",{value:e,configurable:!0}),"l");const h=m((t,e,f)=>{if(e.length===0)throw new TypeError("When using closestString(), the possibleWords array must contain at least one word");const{caseSensitive:r,compareFn:s=p}={...f},n=r?t:t.toLowerCase();let a=e[0]??void 0,i=1/0;for(const d of e){const o=d,c=r?s(n,o):s(n,o.toLowerCase());c<i&&(a=o,i=c)}return a},"closestString");export{h as closestString};
1
+ import{distance as p}from"./packem_shared/closest-C6YDQs4m.js";const d=(s,o,l)=>{if(o.length===0)throw new TypeError("When using closestString(), the possibleWords array must contain at least one word");const{caseSensitive:e,compareFn:r=p}={...l},n=e?s:s.toLowerCase();let a=o[0]??void 0,i=1/0;for(const g of o){const t=g,c=e?r(n,t):r(n,t.toLowerCase());c<i&&(a=t,i=c)}return a};export{d as closestString};
@@ -1 +1 @@
1
- var s=Object.defineProperty;var n=(e,r)=>s(e,"name",{value:r,configurable:!0});import{distance as c}from"./packem_shared/closest-uarbVSbs.js";var m=Object.defineProperty,p=n((e,r)=>m(e,"name",{value:r,configurable:!0}),"a");const l=p((e,r)=>{const{compareFn:o=c}={...r};if(r?.caseSensitive)return(t,a)=>o(e,t)-o(e,a);const i=e.toLowerCase();return(t,a)=>o(i,t.toLowerCase())-o(i,a.toLowerCase())},"compareSimilarity");export{l as compareSimilarity};
1
+ import{distance as i}from"./packem_shared/closest-C6YDQs4m.js";const n=(o,s)=>{const{compareFn:e=i}={...s};if(s?.caseSensitive)return(t,r)=>e(o,t)-e(o,r);const a=o.toLowerCase();return(t,r)=>e(a,t.toLowerCase())-e(a,r.toLowerCase())};export{n as compareSimilarity};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the count of `substring` in `value`.
3
+ * @param value Content to search in. Will be coerced to string.
4
+ * @param substring Substring to look for, typically one character.
5
+ * @returns Count of `substring`s in `value`.
6
+ * @throws {TypeError} When substring is not a string or is empty.
7
+ */
8
+ declare const countOccurrences: (value: unknown, substring: string) => number;
9
+ export { countOccurrences };
@@ -0,0 +1 @@
1
+ const i=(c,r)=>{const n=String(c);if(typeof r!="string")throw new TypeError("Expected character");if(r.length===0)throw new TypeError("Expected non-empty substring");let e=0,t=n.indexOf(r);for(;t!==-1;){e++;const o=t+r.length;if(o<=t)break;t=n.indexOf(r,o)}return e};export{i as countOccurrences};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Detect the direction of text: left-to-right, right-to-left, or neutral.
3
+ * @param value The string to analyze.
4
+ * @returns The text direction: 'rtl' for right-to-left, 'ltr' for left-to-right, or 'neutral' for neutral.
5
+ */
6
+ declare const direction: (value?: string) => "rtl" | "ltr" | "neutral";
7
+ export { direction };
@@ -0,0 +1 @@
1
+ const e="֑-߿יִ-﷽ﹰ-ﻼ",n="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",o=new RegExp(`^[^${n}]*[${e}]`),s=new RegExp(`^[^${e}]*[${n}]`),c=(r="")=>{const t=r;return o.test(t)?"rtl":s.test(t)?"ltr":"neutral"};export{c as direction};
@@ -0,0 +1,52 @@
1
+ type WidthType = 'fullwidth' | 'halfwidth' | 'wide' | 'narrow' | 'neutral' | 'ambiguous';
2
+ type Options = {
3
+ /**
4
+ Whether to treat an `'ambiguous'` character as wide.
5
+ @default true
6
+ @example
7
+ ```
8
+ import {eastAsianWidth} from 'get-east-asian-width';
9
+ const codePoint = '⛣'.codePointAt(0);
10
+ console.log(eastAsianWidth(codePoint));
11
+ //=> 1
12
+ console.log(eastAsianWidth(codePoint, {ambiguousAsWide: true}));
13
+ //=> 2
14
+ ```
15
+ > Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). __If the context cannot be established reliably, they should be treated as narrow characters by default.__
16
+ > - http://www.unicode.org/reports/tr11/
17
+ */
18
+ readonly ambiguousAsWide?: boolean;
19
+ };
20
+ /**
21
+ Returns the width as a number for the given code point.
22
+
23
+ @param codePoint - A Unicode code point.
24
+
25
+ @example
26
+ ```
27
+ import {eastAsianWidth} from 'get-east-asian-width';
28
+
29
+ const codePoint = '字'.codePointAt(0);
30
+
31
+ console.log(eastAsianWidth(codePoint));
32
+ //=> 2
33
+ ```
34
+ */
35
+ declare function eastAsianWidth(codePoint: number, options?: Options): 1 | 2;
36
+ /**
37
+ Returns the type of “East Asian Width” for the given code point.
38
+
39
+ @param codePoint - A Unicode code point.
40
+
41
+ @example
42
+ ```
43
+ import {eastAsianWidthType} from 'get-east-asian-width';
44
+
45
+ const codePoint = '字'.codePointAt(0);
46
+
47
+ console.log(eastAsianWidthType(codePoint));
48
+ //=> 'wide'
49
+ ```
50
+ */
51
+ declare function eastAsianWidthType(codePoint: number): WidthType;
52
+ export { type Options as EastAsianWidthOptions, type WidthType as EastAsianWidthType, eastAsianWidth, eastAsianWidthType };
@@ -0,0 +1 @@
1
+ import{eastAsianWidth as e,eastAsianWidthType as i}from"./packem_shared/eastAsianWidth-DJV8Kqd-.js";export{e as eastAsianWidth,i as eastAsianWidthType};
@@ -0,0 +1,25 @@
1
+ import { TruncateOptions } from "./truncate.js";
2
+ import "./get-string-truncated-width.js";
3
+ /**
4
+ * Truncates a sentence to be under the given character limit and strips HTML tags from it.
5
+ * This function first removes all HTML tags and decodes HTML entities, then truncates
6
+ * the resulting plain text to the specified character limit using the truncate function.
7
+ * @example
8
+ * ```typescript
9
+ * excerpt('<p>Hello <strong>world</strong>!</p>', 10);
10
+ * // => 'Hello worl…'
11
+ *
12
+ * excerpt('<div>This is a <em>long</em> text</div>', 20, { ellipsis: '...' });
13
+ * // => 'This is a long text'
14
+ * ```
15
+ * @param html The HTML string to truncate
16
+ * @param limit Maximum character limit for the truncated string
17
+ * @param options Configuration options for truncation
18
+ * @returns The truncated plain text string with HTML tags removed
19
+ */
20
+ declare const excerpt: (html: string, limit: number, options?: ExcerptOptions) => string;
21
+ /**
22
+ * Options for the excerpt function
23
+ */
24
+ type ExcerptOptions = Omit<TruncateOptions, "position">;
25
+ export { ExcerptOptions, excerpt };