string-remove-widows 3.0.6 → 3.0.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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name string-remove-widows
3
3
  * @fileoverview Helps to prevent widow words in a text
4
- * @version 3.0.6
4
+ * @version 3.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-remove-widows/}
@@ -12,7 +12,7 @@ import { left, right } from 'string-left-right';
12
12
  import { Ranges } from 'ranges-push';
13
13
  import { rApply } from 'ranges-apply';
14
14
 
15
- var version$1 = "3.0.6";
15
+ var version$1 = "3.0.7";
16
16
 
17
17
  const rawnbsp = "\u00A0";
18
18
  const encodedNbspHtml = " ";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name string-remove-widows
3
3
  * @fileoverview Helps to prevent widow words in a text
4
- * @version 3.0.6
4
+ * @version 3.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-remove-widows/}
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * @name arrayiffy-if-string
13
13
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
14
- * @version 4.0.6
14
+ * @version 4.0.7
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/arrayiffy-if-string/}
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * @name string-match-left-right
21
21
  * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
22
- * @version 8.0.6
22
+ * @version 8.0.7
23
23
  * @author Roy Revelt, Codsen Ltd
24
24
  * @license MIT
25
25
  * {@link https://codsen.com/os/string-match-left-right/}
@@ -28,7 +28,7 @@ function e(t){return t&&"object"==typeof t&&!Array.isArray(t)}function r(t){retu
28
28
  /**
29
29
  * @name string-left-right
30
30
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
31
- * @version 5.0.6
31
+ * @version 5.0.7
32
32
  * @author Roy Revelt, Codsen Ltd
33
33
  * @license MIT
34
34
  * {@link https://codsen.com/os/string-left-right/}
@@ -37,7 +37,7 @@ const l=" ";function c(t,e=0){return function({str:t,idx:e=0,stopAtNewlines:r=!
37
37
  /**
38
38
  * @name string-collapse-leading-whitespace
39
39
  * @fileoverview Collapse the leading and trailing whitespace of a string
40
- * @version 6.0.6
40
+ * @version 6.0.7
41
41
  * @author Roy Revelt, Codsen Ltd
42
42
  * @license MIT
43
43
  * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
@@ -45,7 +45,7 @@ const l=" ";function c(t,e=0){return function({str:t,idx:e=0,stopAtNewlines:r=!
45
45
  /**
46
46
  * @name ranges-push
47
47
  * @fileoverview Gather string index ranges
48
- * @version 6.0.6
48
+ * @version 6.0.7
49
49
  * @author Roy Revelt, Codsen Ltd
50
50
  * @license MIT
51
51
  * {@link https://codsen.com/os/ranges-push/}
@@ -53,7 +53,7 @@ const l=" ";function c(t,e=0){return function({str:t,idx:e=0,stopAtNewlines:r=!
53
53
  /**
54
54
  * @name ranges-sort
55
55
  * @fileoverview Sort string index ranges
56
- * @version 5.0.6
56
+ * @version 5.0.7
57
57
  * @author Roy Revelt, Codsen Ltd
58
58
  * @license MIT
59
59
  * {@link https://codsen.com/os/ranges-sort/}
@@ -61,7 +61,7 @@ const l=" ";function c(t,e=0){return function({str:t,idx:e=0,stopAtNewlines:r=!
61
61
  /**
62
62
  * @name ranges-merge
63
63
  * @fileoverview Merge and sort string index ranges
64
- * @version 8.0.6
64
+ * @version 8.0.7
65
65
  * @author Roy Revelt, Codsen Ltd
66
66
  * @license MIT
67
67
  * {@link https://codsen.com/os/ranges-merge/}
@@ -69,8 +69,8 @@ const l=" ";function c(t,e=0){return function({str:t,idx:e=0,stopAtNewlines:r=!
69
69
  /**
70
70
  * @name ranges-apply
71
71
  * @fileoverview Take an array of string index ranges, delete/replace the string according to them
72
- * @version 6.0.6
72
+ * @version 6.0.7
73
73
  * @author Roy Revelt, Codsen Ltd
74
74
  * @license MIT
75
75
  * {@link https://codsen.com/os/ranges-apply/}
76
- */function j(t,e,r){let n,o=0,i=0;if(0===arguments.length)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if("string"!=typeof t)throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(e&&!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(r&&"function"!=typeof r)throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!e||!e.filter((t=>t)).length)return t;n=Array.isArray(e)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?[Array.from(e)]:Array.from(e);const s=n.length;let a=0;n.filter((t=>t)).forEach(((t,e)=>{if(r&&(o=Math.floor(a/s*10),o!==i&&(i=o,r(o))),!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${e}th element not an array: ${JSON.stringify(t,null,4)}, which is ${typeof t}`);if(!Number.isInteger(t[0])){if(!Number.isInteger(+t[0])||+t[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${e}th element, array ${JSON.stringify(t,null,0)}. Its first element is not an integer, string index, but ${typeof t[0]}, equal to: ${JSON.stringify(t[0],null,4)}.`);n[e][0]=+n[e][0]}if(!Number.isInteger(t[1])){if(!Number.isInteger(+t[1])||+t[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${e}th element, array ${JSON.stringify(t,null,0)}. Its second element is not an integer, string index, but ${typeof t[1]}, equal to: ${JSON.stringify(t[1],null,4)}.`);n[e][1]=+n[e][1]}a+=1}));const u=A(n,{progressFn:t=>{r&&(o=10+Math.floor(t/10),o!==i&&(i=o,r(o)))}}),l=Array.isArray(u)?u.length:0;if(l>0){const e=t.slice(u[l-1][1]);t=u.reduce(((e,n,s,a)=>{r&&(o=20+Math.floor(s/l*80),o!==i&&(i=o,r(o)));return e+t.slice(0===s?0:a[s-1][1],a[s][0])+(a[s][2]||"")}),""),t+=e}return t}const $=" ",E="&nbsp;",I="\\00A0",M="\\u00A0",R=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],W=[{heads:"{{",tails:"}}"}],F=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],C=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"],N={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};t.defaults=N,t.removeWidows=function(t,e){const r=Date.now();if("string"!=typeof t)throw void 0===t?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:\n${JSON.stringify(t,null,4)}`);if(e&&"object"!=typeof e)throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof e}, equal to ${JSON.stringify(e,null,4)}`);const n=Array.isArray,o=t.length,i=new v({mergeType:2}),a=["."],u=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,l=/^[0-9][A-Z]{2}/,f=.06;let h,p,y,m,d,b,w,_,T,O=0,A=0,S=0;const L={...N,...e},x={removeWidows:!1,convertEntities:!1};if(!L.ignore||!n(L.ignore)&&"string"!=typeof L.ignore)L.ignore=[];else if("string"==typeof L.ignore&&(L.ignore=[L.ignore]),L.ignore.includes("all"))L.ignore=L.ignore.concat(R.concat(F));else if(L.ignore.some((t=>"string"==typeof t))){let t=[];L.ignore=L.ignore.filter((e=>"string"==typeof e&&e.length?(["nunjucks","jinja","liquid"].includes(e.trim().toLowerCase())?t=t.concat(R):["hugo"].includes(e.trim().toLowerCase())?t=t.concat(W):["hexo"].includes(e.trim().toLowerCase())&&(t=t.concat(F)),!1):"object"==typeof e||void 0)),t.length&&(L.ignore=L.ignore.concat(t))}let D;function B(e,r){let n=$;L.removeWidowPreventionMeasures?n=" ":L.convertEntities&&(n=E,"string"==typeof L.targetLanguage&&("css"===L.targetLanguage.trim().toLowerCase()?n=I:"js"===L.targetLanguage.trim().toLowerCase()&&(n=M))),t.slice(e,r)!==n&&i.push(e,r,n)}function H(){A=0,S=0,p=void 0,y=void 0,m=void 0,d=void 0,b=void 0,w=void 0}L.reportProgressFunc&&(D=Math.floor(L.reportProgressFuncTo-(L.reportProgressFuncTo-L.reportProgressFuncFrom)*f-L.reportProgressFuncFrom)),H();for(let e=0;e<=o;e++){if(!_&&n(L.ignore)&&L.ignore.length&&L.ignore.some(((r,o)=>{if(n(r.heads)&&r.heads.some((r=>t.startsWith(r,e)))||"string"==typeof r.heads&&t.startsWith(r.heads,e))return A+=1,_=L.ignore[o].tails,!0})),!_&&T&&T===e&&(A+=1,T=void 0),"function"==typeof L.reportProgressFunc&&(h=L.reportProgressFuncFrom+Math.floor(e/o*(D||1)),h!==O&&(O=h,L.reportProgressFunc(h))),!_&&e&&t[e]&&t[e].trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(d=e),!_&&t[e]&&t[e].trim()&&(S+=1),_||!L.hyphens||!("-—–".includes(t[e])||t.startsWith("&ndash;",e)||t.startsWith("\\2013",e)||t.startsWith("\\u2013",e)||t.startsWith("&mdash;",e)||t.startsWith("\\2014",e)||t.startsWith("\\u2014",e))||!t[e+1]||t[e+1].trim()&&"&"!==t[e]||t[e-1]&&!t[e-1].trim()&&t[g(t,e)]&&(B(g(t,e)+1,e),x.removeWidows=!0),_||!t.startsWith("&nbsp;",e)&&!t.startsWith("&#160;",e)||(b=e,w=e+6,t[e+6]&&t[e+6].trim()&&(T=e+6),L.convertEntities?"css"!==L.targetLanguage&&"js"!==L.targetLanguage||(i.push(e,e+6,"css"===L.targetLanguage?I:M),x.convertEntities=!0):(i.push(e,e+6,$),x.convertEntities=!0)),!_&&t[e+4]&&"\\"===t[e]&&"0"===t[e+1]&&"0"===t[e+2]&&"A"===t[e+3].toUpperCase()&&"0"===t[e+4]&&(b=e,w=e+5,t[e+5]&&t[e+5].trim()&&(T=e+5),L.convertEntities?"html"!==L.targetLanguage&&"js"!==L.targetLanguage||(i.push(e,e+5,"html"===L.targetLanguage?E:M),x.convertEntities=!0):(i.push(e,e+5,$),x.convertEntities=!0)),!_&&"\\"===t[e]&&t[e+1]&&"u"===t[e+1].toLowerCase()&&"0"===t[e+2]&&"0"===t[e+3]&&t[e+4]&&"A"===t[e+4].toUpperCase()&&"0"===t[e+5]&&(b=e,w=e+6,t[e+6]&&t[e+6].trim()&&(T=e+6),L.convertEntities?"html"!==L.targetLanguage&&"css"!==L.targetLanguage||i.push(e,e+6,"html"===L.targetLanguage?E:I):i.push(e,e+6,$)),_||t[e]!==$||(b=e,w=e+1,L.convertEntities&&i.push(e,e+1,"css"===L.targetLanguage?I:"js"===L.targetLanguage?M:E)),_||!t[e]||!t[e].trim()||t[e-1]&&t[e-1].trim()||(A+=1),!_&&(!t[e]||"\r\n".includes(t[e])||("\n"===t[e]||"\r"===t[e]||"\r"===t[e]&&"\n"===t[e+1])&&g(t,e)&&a.includes(t[g(t,e)]))){if((!L.minWordCount||A>=L.minWordCount)&&(!L.minCharCount||S>=L.minCharCount)){let t,e;void 0!==m&&void 0!==d&&void 0!==b&&void 0!==w?m>b?(t=m,e=d):(t=b,e=w):void 0!==m&&void 0!==d?(t=m,e=d):void 0!==b&&void 0!==w&&(t=b,e=w),t&&e||!p||!y||(t=p,e=y),t&&e&&(B(t,e),x.removeWidows=!0)}H()}let r;L.UKPostcodes&&t[e]&&!t[e].trim()&&t[e-1]&&t[e-1].trim()&&u.test(t.slice(0,e))&&t[c(t,e)]&&l.test(t.slice(c(t,e)))&&(B(e,c(t,e)),x.removeWidows=!0),_||!t[e]||t[e].trim()||!t[e-1]||!t[e-1].trim()||!(void 0===m||t[m-1]&&t[m-1].trim())||"/>".includes(t[c(t,e)])||t.slice(0,e).trim().endsWith("br")||t.slice(0,e).trim().endsWith("hr")||t.slice(0,e).endsWith("<")&&C.some((r=>t.startsWith(r,c(t,e))))||(p=m,y=d,m=e,d=void 0,void 0===b&&void 0===w||(b=void 0,w=void 0)),_&&("string"!=typeof _||_.length&&!t.startsWith(_,e)?!n(_)||_.length&&!_.some((n=>{if(t.startsWith(n,e))return r=n,!0}))||(_=void 0,e+=r.length,n(L.ignore)&&L.ignore.length&&t[e+1]&&L.ignore.some((r=>s(t,e,r.tails,{trimBeforeMatching:!0,cb:(r,n,o)=>(o&&(e=o-1,t[e+1]&&t[e+1].trim()&&(A+=1)),!0)})))):_=void 0),t[e]&&"\r\n".includes(t[e])&&(A=0,S=0),n(L.tagRanges)&&L.tagRanges.length&&L.tagRanges.some((t=>{if(e>=t[0]&&e<=t[1]&&t[1]-1>e)return e=t[1]-1,!0}))}return j(t,i.current()).split("").forEach(((t,e)=>{})),{res:j(t,i.current(),L.reportProgressFunc?t=>{h=Math.floor(.94*(L.reportProgressFuncTo-L.reportProgressFuncFrom)+t/100*(L.reportProgressFuncTo-L.reportProgressFuncFrom)*f),h!==O&&(O=h,L.reportProgressFunc(h))}:void 0),ranges:i.current(),log:{timeTakenInMilliseconds:Date.now()-r},whatWasDone:x}},t.version="3.0.6",Object.defineProperty(t,"__esModule",{value:!0})}));
76
+ */function j(t,e,r){let n,o=0,i=0;if(0===arguments.length)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if("string"!=typeof t)throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(e&&!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(r&&"function"!=typeof r)throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!e||!e.filter((t=>t)).length)return t;n=Array.isArray(e)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?[Array.from(e)]:Array.from(e);const s=n.length;let a=0;n.filter((t=>t)).forEach(((t,e)=>{if(r&&(o=Math.floor(a/s*10),o!==i&&(i=o,r(o))),!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${e}th element not an array: ${JSON.stringify(t,null,4)}, which is ${typeof t}`);if(!Number.isInteger(t[0])){if(!Number.isInteger(+t[0])||+t[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${e}th element, array ${JSON.stringify(t,null,0)}. Its first element is not an integer, string index, but ${typeof t[0]}, equal to: ${JSON.stringify(t[0],null,4)}.`);n[e][0]=+n[e][0]}if(!Number.isInteger(t[1])){if(!Number.isInteger(+t[1])||+t[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${e}th element, array ${JSON.stringify(t,null,0)}. Its second element is not an integer, string index, but ${typeof t[1]}, equal to: ${JSON.stringify(t[1],null,4)}.`);n[e][1]=+n[e][1]}a+=1}));const u=A(n,{progressFn:t=>{r&&(o=10+Math.floor(t/10),o!==i&&(i=o,r(o)))}}),l=Array.isArray(u)?u.length:0;if(l>0){const e=t.slice(u[l-1][1]);t=u.reduce(((e,n,s,a)=>{r&&(o=20+Math.floor(s/l*80),o!==i&&(i=o,r(o)));return e+t.slice(0===s?0:a[s-1][1],a[s][0])+(a[s][2]||"")}),""),t+=e}return t}const $=" ",E="&nbsp;",I="\\00A0",M="\\u00A0",R=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],W=[{heads:"{{",tails:"}}"}],F=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],C=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"],N={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};t.defaults=N,t.removeWidows=function(t,e){const r=Date.now();if("string"!=typeof t)throw void 0===t?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:\n${JSON.stringify(t,null,4)}`);if(e&&"object"!=typeof e)throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof e}, equal to ${JSON.stringify(e,null,4)}`);const n=Array.isArray,o=t.length,i=new v({mergeType:2}),a=["."],u=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,l=/^[0-9][A-Z]{2}/,f=.06;let h,p,y,m,d,b,w,_,T,O=0,A=0,S=0;const L={...N,...e},x={removeWidows:!1,convertEntities:!1};if(!L.ignore||!n(L.ignore)&&"string"!=typeof L.ignore)L.ignore=[];else if("string"==typeof L.ignore&&(L.ignore=[L.ignore]),L.ignore.includes("all"))L.ignore=L.ignore.concat(R.concat(F));else if(L.ignore.some((t=>"string"==typeof t))){let t=[];L.ignore=L.ignore.filter((e=>"string"==typeof e&&e.length?(["nunjucks","jinja","liquid"].includes(e.trim().toLowerCase())?t=t.concat(R):["hugo"].includes(e.trim().toLowerCase())?t=t.concat(W):["hexo"].includes(e.trim().toLowerCase())&&(t=t.concat(F)),!1):"object"==typeof e||void 0)),t.length&&(L.ignore=L.ignore.concat(t))}let D;function B(e,r){let n=$;L.removeWidowPreventionMeasures?n=" ":L.convertEntities&&(n=E,"string"==typeof L.targetLanguage&&("css"===L.targetLanguage.trim().toLowerCase()?n=I:"js"===L.targetLanguage.trim().toLowerCase()&&(n=M))),t.slice(e,r)!==n&&i.push(e,r,n)}function H(){A=0,S=0,p=void 0,y=void 0,m=void 0,d=void 0,b=void 0,w=void 0}L.reportProgressFunc&&(D=Math.floor(L.reportProgressFuncTo-(L.reportProgressFuncTo-L.reportProgressFuncFrom)*f-L.reportProgressFuncFrom)),H();for(let e=0;e<=o;e++){if(!_&&n(L.ignore)&&L.ignore.length&&L.ignore.some(((r,o)=>{if(n(r.heads)&&r.heads.some((r=>t.startsWith(r,e)))||"string"==typeof r.heads&&t.startsWith(r.heads,e))return A+=1,_=L.ignore[o].tails,!0})),!_&&T&&T===e&&(A+=1,T=void 0),"function"==typeof L.reportProgressFunc&&(h=L.reportProgressFuncFrom+Math.floor(e/o*(D||1)),h!==O&&(O=h,L.reportProgressFunc(h))),!_&&e&&t[e]&&t[e].trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(d=e),!_&&t[e]&&t[e].trim()&&(S+=1),_||!L.hyphens||!("-—–".includes(t[e])||t.startsWith("&ndash;",e)||t.startsWith("\\2013",e)||t.startsWith("\\u2013",e)||t.startsWith("&mdash;",e)||t.startsWith("\\2014",e)||t.startsWith("\\u2014",e))||!t[e+1]||t[e+1].trim()&&"&"!==t[e]||t[e-1]&&!t[e-1].trim()&&t[g(t,e)]&&(B(g(t,e)+1,e),x.removeWidows=!0),_||!t.startsWith("&nbsp;",e)&&!t.startsWith("&#160;",e)||(b=e,w=e+6,t[e+6]&&t[e+6].trim()&&(T=e+6),L.convertEntities?"css"!==L.targetLanguage&&"js"!==L.targetLanguage||(i.push(e,e+6,"css"===L.targetLanguage?I:M),x.convertEntities=!0):(i.push(e,e+6,$),x.convertEntities=!0)),!_&&t[e+4]&&"\\"===t[e]&&"0"===t[e+1]&&"0"===t[e+2]&&"A"===t[e+3].toUpperCase()&&"0"===t[e+4]&&(b=e,w=e+5,t[e+5]&&t[e+5].trim()&&(T=e+5),L.convertEntities?"html"!==L.targetLanguage&&"js"!==L.targetLanguage||(i.push(e,e+5,"html"===L.targetLanguage?E:M),x.convertEntities=!0):(i.push(e,e+5,$),x.convertEntities=!0)),!_&&"\\"===t[e]&&t[e+1]&&"u"===t[e+1].toLowerCase()&&"0"===t[e+2]&&"0"===t[e+3]&&t[e+4]&&"A"===t[e+4].toUpperCase()&&"0"===t[e+5]&&(b=e,w=e+6,t[e+6]&&t[e+6].trim()&&(T=e+6),L.convertEntities?"html"!==L.targetLanguage&&"css"!==L.targetLanguage||i.push(e,e+6,"html"===L.targetLanguage?E:I):i.push(e,e+6,$)),_||t[e]!==$||(b=e,w=e+1,L.convertEntities&&i.push(e,e+1,"css"===L.targetLanguage?I:"js"===L.targetLanguage?M:E)),_||!t[e]||!t[e].trim()||t[e-1]&&t[e-1].trim()||(A+=1),!_&&(!t[e]||"\r\n".includes(t[e])||("\n"===t[e]||"\r"===t[e]||"\r"===t[e]&&"\n"===t[e+1])&&g(t,e)&&a.includes(t[g(t,e)]))){if((!L.minWordCount||A>=L.minWordCount)&&(!L.minCharCount||S>=L.minCharCount)){let t,e;void 0!==m&&void 0!==d&&void 0!==b&&void 0!==w?m>b?(t=m,e=d):(t=b,e=w):void 0!==m&&void 0!==d?(t=m,e=d):void 0!==b&&void 0!==w&&(t=b,e=w),t&&e||!p||!y||(t=p,e=y),t&&e&&(B(t,e),x.removeWidows=!0)}H()}let r;L.UKPostcodes&&t[e]&&!t[e].trim()&&t[e-1]&&t[e-1].trim()&&u.test(t.slice(0,e))&&t[c(t,e)]&&l.test(t.slice(c(t,e)))&&(B(e,c(t,e)),x.removeWidows=!0),_||!t[e]||t[e].trim()||!t[e-1]||!t[e-1].trim()||!(void 0===m||t[m-1]&&t[m-1].trim())||"/>".includes(t[c(t,e)])||t.slice(0,e).trim().endsWith("br")||t.slice(0,e).trim().endsWith("hr")||t.slice(0,e).endsWith("<")&&C.some((r=>t.startsWith(r,c(t,e))))||(p=m,y=d,m=e,d=void 0,void 0===b&&void 0===w||(b=void 0,w=void 0)),_&&("string"!=typeof _||_.length&&!t.startsWith(_,e)?!n(_)||_.length&&!_.some((n=>{if(t.startsWith(n,e))return r=n,!0}))||(_=void 0,e+=r.length,n(L.ignore)&&L.ignore.length&&t[e+1]&&L.ignore.some((r=>s(t,e,r.tails,{trimBeforeMatching:!0,cb:(r,n,o)=>(o&&(e=o-1,t[e+1]&&t[e+1].trim()&&(A+=1)),!0)})))):_=void 0),t[e]&&"\r\n".includes(t[e])&&(A=0,S=0),n(L.tagRanges)&&L.tagRanges.length&&L.tagRanges.some((t=>{if(e>=t[0]&&e<=t[1]&&t[1]-1>e)return e=t[1]-1,!0}))}return j(t,i.current()).split("").forEach(((t,e)=>{})),{res:j(t,i.current(),L.reportProgressFunc?t=>{h=Math.floor(.94*(L.reportProgressFuncTo-L.reportProgressFuncFrom)+t/100*(L.reportProgressFuncTo-L.reportProgressFuncFrom)*f),h!==O&&(O=h,L.reportProgressFunc(h))}:void 0),ranges:i.current(),log:{timeTakenInMilliseconds:Date.now()-r},whatWasDone:x}},t.version="3.0.7",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-remove-widows",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "Helps to prevent widow words in a text",
5
5
  "keywords": [
6
6
  "against",
@@ -81,10 +81,10 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "@babel/runtime": "^7.16.3",
84
- "ranges-apply": "^6.0.6",
85
- "ranges-push": "^6.0.6",
86
- "string-left-right": "^5.0.6",
87
- "string-match-left-right": "^8.0.6"
84
+ "ranges-apply": "^6.0.7",
85
+ "ranges-push": "^6.0.7",
86
+ "string-left-right": "^5.0.7",
87
+ "string-match-left-right": "^8.0.7"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@babel/cli": "^7.16.0",
@@ -106,21 +106,21 @@
106
106
  "@rollup/plugin-node-resolve": "^13.0.6",
107
107
  "@rollup/plugin-strip": "^2.1.0",
108
108
  "@rollup/plugin-typescript": "^8.3.0",
109
- "@types/node": "^16.11.9",
109
+ "@types/node": "^16.11.10",
110
110
  "@types/tap": "^15.0.5",
111
- "@typescript-eslint/eslint-plugin": "^5.4.0",
112
- "@typescript-eslint/parser": "^5.4.0",
113
- "core-js": "^3.19.1",
111
+ "@typescript-eslint/eslint-plugin": "^5.5.0",
112
+ "@typescript-eslint/parser": "^5.5.0",
113
+ "core-js": "^3.19.2",
114
114
  "cross-env": "^7.0.3",
115
115
  "eslint": "^8.3.0",
116
- "lect": "^0.18.6",
117
- "rollup": "^2.60.0",
116
+ "lect": "^0.18.7",
117
+ "rollup": "^2.60.1",
118
118
  "rollup-plugin-ascii": "^0.0.3",
119
119
  "rollup-plugin-banner": "^0.2.1",
120
120
  "rollup-plugin-cleanup": "^3.2.1",
121
121
  "rollup-plugin-dts": "^4.0.1",
122
122
  "rollup-plugin-terser": "^7.0.2",
123
- "tap": "^15.1.2",
123
+ "tap": "^15.1.5",
124
124
  "tslib": "^2.3.1",
125
125
  "typescript": "^4.5.2"
126
126
  },