string-collapse-white-space
Advanced tools
Comparing version
/** | ||
* @name string-collapse-white-space | ||
* @fileoverview Replace chunks of whitespace with a single spaces | ||
* @version 11.0.17 | ||
* @version 11.0.18 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -10,3 +10,3 @@ * @license MIT | ||
import{rApply as w}from"ranges-apply";import{Ranges as x}from"ranges-push";import{right as D}from"string-left-right";var A="11.0.17";var L=A,O={trimStart:!0,trimEnd:!0,trimLines:!1,trimnbsp:!1,removeEmptyLines:!1,limitConsecutiveEmptyLinesTo:0,enforceSpacesOnly:!1,cb:({suggested:e})=>e},R=["suggested","whiteSpaceStartsAt","whiteSpaceEndsAt","str"];function J(e,b){if(typeof e!="string")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_01] The input is not string but ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(b&&typeof b!="object")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_02] The resolvedOpts is not a plain object but ${typeof b}, equal to: | ||
import{rApply as w}from"ranges-apply";import{Ranges as x}from"ranges-push";import{right as D}from"string-left-right";var A="11.0.18";var L=A,O={trimStart:!0,trimEnd:!0,trimLines:!1,trimnbsp:!1,removeEmptyLines:!1,limitConsecutiveEmptyLinesTo:0,enforceSpacesOnly:!1,cb:({suggested:e})=>e},R=["suggested","whiteSpaceStartsAt","whiteSpaceEndsAt","str"];function J(e,b){if(typeof e!="string")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_01] The input is not string but ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(b&&typeof b!="object")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_02] The resolvedOpts is not a plain object but ${typeof b}, equal to: | ||
${JSON.stringify(b,null,4)}`);if(!e.length)return{result:"",ranges:null};let S=new x,c="\xA0",n={...O,...b};function p(t,y){if(typeof n.cb=="function"){let o=n.cb({suggested:t,...y});Array.isArray(o)&&S.push(...o)}else t&&S.push(...t)}let l=null,s=null,i=null,a=null,E=null,m=!1,f=[],h=0;for(let t=0,y=e.length;t<=y;t++){if((e[t]==="\r"||e[t]===` | ||
@@ -13,0 +13,0 @@ `&&e[t-1]!=="\r")&&(h+=1,a===null&&(a=t),E=e[t]==="\r"&&e[t+1]===` |
/** | ||
* @name string-collapse-white-space | ||
* @fileoverview Replace chunks of whitespace with a single spaces | ||
* @version 11.0.17 | ||
* @version 11.0.18 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -19,3 +19,3 @@ * @license MIT | ||
\r`.includes(e[n+2])||s&&e[n+2]===j))return n+2;for(let i=n+1,r=e.length;i<r;i++)if(e[i].trim()||o&&` | ||
\r`.includes(e[i])||s&&e[i]===j)return i;return null}function C(e,n=0){return ge({str:e,idx:n,stopAtNewlines:!1,stopAtRawNbsp:!1})}var K="11.0.17";var ce=K,Z={trimStart:!0,trimEnd:!0,trimLines:!1,trimnbsp:!1,removeEmptyLines:!1,limitConsecutiveEmptyLinesTo:0,enforceSpacesOnly:!1,cb:({suggested:e})=>e},me=["suggested","whiteSpaceStartsAt","whiteSpaceEndsAt","str"];function he(e,n){if(typeof e!="string")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_01] The input is not string but ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(n&&typeof n!="object")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_02] The resolvedOpts is not a plain object but ${typeof n}, equal to: | ||
\r`.includes(e[i])||s&&e[i]===j)return i;return null}function C(e,n=0){return ge({str:e,idx:n,stopAtNewlines:!1,stopAtRawNbsp:!1})}var K="11.0.18";var ce=K,Z={trimStart:!0,trimEnd:!0,trimLines:!1,trimnbsp:!1,removeEmptyLines:!1,limitConsecutiveEmptyLinesTo:0,enforceSpacesOnly:!1,cb:({suggested:e})=>e},me=["suggested","whiteSpaceStartsAt","whiteSpaceEndsAt","str"];function he(e,n){if(typeof e!="string")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_01] The input is not string but ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(n&&typeof n!="object")throw new Error(`string-collapse-white-space/collapse(): [THROW_ID_02] The resolvedOpts is not a plain object but ${typeof n}, equal to: | ||
${JSON.stringify(n,null,4)}`);if(!e.length)return{result:"",ranges:null};let o=new U,s="\xA0",i=h(h({},Z),n);function r(f,T){if(typeof i.cb=="function"){let d=i.cb(h({suggested:f},T));Array.isArray(d)&&o.push(...d)}else f&&o.push(...f)}let a=null,l=null,u=null,t=null,g=null,c=!1,m=[],p=0;for(let f=0,T=e.length;f<=T;f++){if((e[f]==="\r"||e[f]===` | ||
@@ -43,3 +43,3 @@ `&&e[f-1]!=="\r")&&(p+=1,t===null&&(t=f),g=e[f]==="\r"&&e[f+1]===` | ||
* @fileoverview Merge and sort string index ranges | ||
* @version 9.0.14 | ||
* @version 9.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -52,3 +52,3 @@ * @license MIT | ||
* @fileoverview Take an array of string index ranges, delete/replace the string according to them | ||
* @version 7.0.14 | ||
* @version 7.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -69,3 +69,3 @@ * @license MIT | ||
* @fileoverview Various utility functions | ||
* @version 1.6.3 | ||
* @version 1.6.4 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -78,3 +78,3 @@ * @license MIT | ||
* @fileoverview Gather string index ranges | ||
* @version 7.0.14 | ||
* @version 7.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -87,3 +87,3 @@ * @license MIT | ||
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index | ||
* @version 6.0.16 | ||
* @version 6.0.17 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -90,0 +90,0 @@ * @license MIT |
{ | ||
"name": "string-collapse-white-space", | ||
"version": "11.0.17", | ||
"version": "11.0.18", | ||
"description": "Replace chunks of whitespace with a single spaces", | ||
@@ -72,9 +72,9 @@ "keywords": [ | ||
"dependencies": { | ||
"ranges-apply": "^7.0.14", | ||
"ranges-push": "^7.0.14", | ||
"string-left-right": "^6.0.16" | ||
"ranges-apply": "^7.0.15", | ||
"ranges-push": "^7.0.15", | ||
"string-left-right": "^6.0.17" | ||
}, | ||
"devDependencies": { | ||
"test-mixer": "^4.1.13" | ||
"test-mixer": "^4.1.14" | ||
} | ||
} |
Updated
Updated
Updated