@visulima/string 2.0.1 → 2.0.2

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## @visulima/string [2.0.2](https://github.com/visulima/visulima/compare/@visulima/string@2.0.1...@visulima/string@2.0.2) (2025-10-22)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **string/truncate:** don't replace single-character strings with the ellipsis ([#559](https://github.com/visulima/visulima/issues/559)) ([91f185d](https://github.com/visulima/visulima/commit/91f185d669240986da883035e59432050058272e))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * update package dependencies and configurations ([7bfe7e7](https://github.com/visulima/visulima/commit/7bfe7e71869580900aab50efb064b4293994ed9a))
10
+
1
11
  ## @visulima/string [2.0.1](https://github.com/visulima/visulima/compare/@visulima/string@2.0.0...@visulima/string@2.0.1) (2025-10-21)
2
12
 
3
13
  ### Bug Fixes
package/dist/truncate.js CHANGED
@@ -1 +1 @@
1
- var g=Object.defineProperty;var h=(t,i)=>g(t,"name",{value:i,configurable:!0});import{getStringTruncatedWidth as l}from"./get-string-truncated-width.js";import{slice as d}from"./slice.js";var b=Object.defineProperty,p=h((t,i)=>b(t,"name",{value:i,configurable:!0}),"h");const u="…",y=3,f=p((t,i,e=!1)=>{if(t.charAt(i)===" ")return i;const r=e?1:-1,a=Math.min(y,e?t.length-i:i);for(let c=1;c<=a;c++){const n=i+c*r;if(t.charAt(n)===" ")return n}return i},"findNearestSpace"),T=p((t,i,e={})=>{if(typeof t!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof t}`);if(typeof i!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof i}`);if(t===""||i<=0)return"";t=t.normalize("NFC");const{ellipsis:r=u,position:a="end",preferTruncationOnSpace:c=!1}=e;let n=e.ellipsisWidth??r===u?1:void 0;if(n===void 0&&(n=l(r,{...e.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width),i===1&&n===1)return r;if(i===1)return"";const{width:o}=l(t,{...e.width,ellipsis:r,ellipsisWidth:n});if(o<=i)return t;switch(a){case"end":{if(c){const s=f(t,i-1);return d(t,0,s,{width:e.width})+r}return d(t,0,i-n,{width:e.width})+r}case"middle":{const s=Math.floor(i/2);if(c){const w=f(t,s),m=f(t,o-(i-s)+1,!0);return d(t,0,w)+r+d(t,m,o).trim()}return d(t,0,s,{width:e.width})+r+d(t,o-(i-s)+n,o,{width:e.width})}case"start":{if(c){const s=f(t,o-i+1,!0);return r+d(t,s,o).trim()}return r+d(t,o-i+n,o,{width:e.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${a}'`)}},"truncate");export{T as truncate};
1
+ var g=Object.defineProperty;var l=(t,i)=>g(t,"name",{value:i,configurable:!0});import{getStringTruncatedWidth as p}from"./get-string-truncated-width.js";import{slice as d}from"./slice.js";var b=Object.defineProperty,f=l((t,i)=>b(t,"name",{value:i,configurable:!0}),"h");const u="…",y=3,h=f((t,i,e=!1)=>{if(t.charAt(i)===" ")return i;const r=e?1:-1,c=Math.min(y,e?t.length-i:i);for(let a=1;a<=c;a++){const n=i+a*r;if(t.charAt(n)===" ")return n}return i},"findNearestSpace"),T=f((t,i,e={})=>{if(typeof t!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof t}`);if(typeof i!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof i}`);if(t===""||i<=0)return"";t=t.normalize("NFC");const{ellipsis:r=u,position:c="end",preferTruncationOnSpace:a=!1}=e;let n=e.ellipsisWidth??r===u?1:void 0;n===void 0&&(n=p(r,{...e.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width);const{width:o}=p(t,{...e.width,ellipsis:r,ellipsisWidth:n});if(o<=i)return t;switch(c){case"end":{if(a){const s=h(t,i-1);return d(t,0,s,{width:e.width})+r}return d(t,0,i-n,{width:e.width})+r}case"middle":{const s=Math.floor(i/2);if(a){const w=h(t,s),m=h(t,o-(i-s)+1,!0);return d(t,0,w)+r+d(t,m,o).trim()}return d(t,0,s,{width:e.width})+r+d(t,o-(i-s)+n,o,{width:e.width})}case"start":{if(a){const s=h(t,o-i+1,!0);return r+d(t,s,o).trim()}return r+d(t,o-i+n,o,{width:e.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${c}'`)}},"truncate");export{T as truncate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/string",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Functions for manipulating strings.",
5
5
  "keywords": [
6
6
  "visulima",