string-range-expander 3.1.0 → 3.1.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
@@ -71,8 +71,8 @@ Accidental version bump during migration to sourcehut. Sorry about that.
71
71
 
72
72
  ## 1.10.0 (2019-01-20)
73
73
 
74
- - Various documentation and setup tweaks after we migrated to monorepo
75
- - Setup refresh: updated dependencies and all config files using automated tools
74
+ - Various documentation and setup tweaks after we migrated to monorepo
75
+ - Setup refresh: updated dependencies and all config files using automated tools
76
76
 
77
77
  ## 1.6.0 (2018-12-26)
78
78
 
@@ -84,23 +84,23 @@ Accidental version bump during migration to sourcehut. Sorry about that.
84
84
 
85
85
  ## 1.5.0 (2018-10-26)
86
86
 
87
- - Updated all dependencies
88
- - Restored coveralls.io reporting
89
- - Restored unit test linting
87
+ - Updated all dependencies
88
+ - Restored coveralls.io reporting
89
+ - Restored unit test linting
90
90
 
91
91
  ## 1.4.0 (2018-09-20)
92
92
 
93
- - Improvements to `opts.addSingleSpaceToPreventAccidentalConcatenation`, now it detects is there at least one digit or number around and if there's none, it doesn't add a space.
93
+ - Improvements to `opts.addSingleSpaceToPreventAccidentalConcatenation`, now it detects is there at least one digit or number around and if there's none, it doesn't add a space.
94
94
 
95
95
  ## 1.3.0 (2018-09-20)
96
96
 
97
- - Improvements to cases when `opts.ifLeftSideIncludesThisThenCropTightly`/`opts.ifRightSideIncludesThisThenCropTightly` is an array
98
- - Now we tend an edge case when `opts.addSingleSpaceToPreventAccidentalConcatenation` is surrounded by characters, whitelisted by `opts.ifLeftSideIncludesThisThenCropTightly` and `opts.ifRightSideIncludesThisThenCropTightly` (or just one of them, but then the other is a falsey empty string). In that case, the compensation space is not added.
97
+ - Improvements to cases when `opts.ifLeftSideIncludesThisThenCropTightly`/`opts.ifRightSideIncludesThisThenCropTightly` is an array
98
+ - Now we tend an edge case when `opts.addSingleSpaceToPreventAccidentalConcatenation` is surrounded by characters, whitelisted by `opts.ifLeftSideIncludesThisThenCropTightly` and `opts.ifRightSideIncludesThisThenCropTightly` (or just one of them, but then the other is a falsey empty string). In that case, the compensation space is not added.
99
99
 
100
100
  ## 1.2.0 (2018-09-18)
101
101
 
102
- - New feature - `opts.addSingleSpaceToPreventAccidentalConcatenation`. It's off by default but if it's on, it can prevent accidental concatenation of string when chunk is deleted. It checks the outer edges of the string range what is about to be deleted and if non-whitespace surrounds both sides it adds a single space (as range's third argument).
102
+ - New feature - `opts.addSingleSpaceToPreventAccidentalConcatenation`. It's off by default but if it's on, it can prevent accidental concatenation of string when chunk is deleted. It checks the outer edges of the string range what is about to be deleted and if non-whitespace surrounds both sides it adds a single space (as range's third argument).
103
103
 
104
104
  ## 1.0.0 (2018-09-11)
105
105
 
106
- - First public release
106
+ - First public release
package/README.md CHANGED
@@ -57,7 +57,6 @@ assert.deepEqual(
57
57
  );
58
58
  ```
59
59
 
60
-
61
60
  ## Documentation
62
61
 
63
62
  Please [visit codsen.com](https://codsen.com/os/string-range-expander/) for a full description of the API.
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * @name string-range-expander
3
3
  * @fileoverview Expands string index ranges within whitespace boundaries until letters are met
4
- * @version 3.1.0
4
+ * @version 3.1.2
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-range-expander/}
8
8
  */
9
9
 
10
- var u="3.1.0";var m=u,g={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function y(i){let a=/^[0-9a-zA-Z]+$/;function o(n){return!n||typeof n!="string"?!1:!n.trim()}function l(n){return typeof n=="string"}if(!i||typeof i!="object"||Array.isArray(i)){let n;throw i===void 0?n="but it is missing completely.":i===null?n="but it was given as null.":n=`but it was given as ${typeof i}, equal to:
10
+ var u="3.1.2";var m=u,g={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function y(i){let a=/^[0-9a-zA-Z]+$/;function o(n){return!n||typeof n!="string"?!1:!n.trim()}function l(n){return typeof n=="string"}if(!i||typeof i!="object"||Array.isArray(i)){let n;throw i===void 0?n="but it is missing completely.":i===null?n="but it was given as null.":n=`but it was given as ${typeof i}, equal to:
11
11
  ${JSON.stringify(i,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${n}`)}else if(typeof i=="object"&&i!==null&&!Array.isArray(i)&&!Object.keys(i).length)throw new Error("string-range-expander: [THROW_ID_02] Input must be a plain object but it was given as a plain object without any keys.");if(typeof i.from!="number")throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! Currently it's given as ${typeof i.from}, equal to ${JSON.stringify(i.from,null,0)}`);if(typeof i.to!="number")throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! Currently it's given as ${typeof i.to}, equal to ${JSON.stringify(i.to,null,0)}`);if(i?.str&&!i.str[i.from]&&i.from!==i.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("${i.str}") must contain the character at index "from" ("${i.from}")`);if(i?.str&&!i.str[i.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.str ("${i.str}") must contain the character at index before "to" ("${i.to-1}")`);if(i.from>i.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${i.from}" is greater than "to" index, "${i.to}". That's wrong!`);if(l(i.extendToOneSide)&&i.extendToOneSide!=="left"&&i.extendToOneSide!=="right"||!l(i.extendToOneSide)&&i.extendToOneSide!==void 0&&i.extendToOneSide!==!1)throw new Error(`string-range-expander: [THROW_ID_08] The resolvedOpts.extendToOneSide value is not recognisable! It's set to: "${i.extendToOneSide}" (${typeof i.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);let e={...g,...i};if(Array.isArray(e.ifLeftSideIncludesThisThenCropTightly)){let n,d;if(e.ifLeftSideIncludesThisThenCropTightly.every((f,h)=>l(f)?!0:(n=h,d=f,!1)))e.ifLeftSideIncludesThisThenCropTightly=e.ifLeftSideIncludesThisThenCropTightly.join("");else throw new Error(`string-range-expander: [THROW_ID_09] The resolvedOpts.ifLeftSideIncludesThisThenCropTightly was set to an array:
12
12
  ${JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${n} is of a type ${typeof d} (equal to ${JSON.stringify(d,null,0)}).`)}let t=e.str,r=e.from,s=e.to;if(e.extendToOneSide!=="right"&&(o(t[r-1])&&(o(t[r-2])||e.ifLeftSideIncludesThisCropItToo.includes(t[r-2]))||t[r-1]&&e.ifLeftSideIncludesThisCropItToo.includes(t[r-1])||e.wipeAllWhitespaceOnLeft&&o(t[r-1]))){for(let n=r;n--;)if(!e.ifLeftSideIncludesThisCropItToo.includes(t[n])){if(t[n].trim()){e.wipeAllWhitespaceOnLeft||e.ifLeftSideIncludesThisCropItToo.includes(t[n+1])?r=n+1:r=n+2;break}else if(n===0){e.wipeAllWhitespaceOnLeft?r=0:r=1;break}}}if(e.extendToOneSide!=="left"&&(o(t[s])&&(e.wipeAllWhitespaceOnRight||o(t[s+1]))||e.ifRightSideIncludesThisCropItToo.includes(t[s]))){for(let n=s,d=t.length;n<d;n++)if(!e.ifRightSideIncludesThisCropItToo.includes(t[n])&&t[n]?.trim()){e.wipeAllWhitespaceOnRight||e.ifRightSideIncludesThisCropItToo.includes(t[n-1])?s=n:s=n-1;break}}return(e.extendToOneSide!=="right"&&l(e.ifLeftSideIncludesThisThenCropTightly)&&e.ifLeftSideIncludesThisThenCropTightly&&(t[r-2]&&e.ifLeftSideIncludesThisThenCropTightly.includes(t[r-2])||t[r-1]&&e.ifLeftSideIncludesThisThenCropTightly.includes(t[r-1]))||e.extendToOneSide!=="left"&&l(e.ifRightSideIncludesThisThenCropTightly)&&e.ifRightSideIncludesThisThenCropTightly&&(t[s+1]&&e.ifRightSideIncludesThisThenCropTightly.includes(t[s+1])||t[s]&&e.ifRightSideIncludesThisThenCropTightly.includes(t[s])))&&(e.extendToOneSide!=="right"&&o(t[r-1])&&!e.wipeAllWhitespaceOnLeft&&(r-=1),e.extendToOneSide!=="left"&&o(t[s])&&!e.wipeAllWhitespaceOnRight&&(s+=1)),e.addSingleSpaceToPreventAccidentalConcatenation&&t[r-1]&&t[r-1].trim()&&t[s]&&t[s].trim()&&(!e.ifLeftSideIncludesThisThenCropTightly&&!e.ifRightSideIncludesThisThenCropTightly||!((!e.ifLeftSideIncludesThisThenCropTightly||e.ifLeftSideIncludesThisThenCropTightly.includes(t[r-1]))&&(!e.ifRightSideIncludesThisThenCropTightly||t[s]&&e.ifRightSideIncludesThisThenCropTightly.includes(t[s]))))&&(a.test(t[r-1])||a.test(t[s]))?[r,s," "]:[r,s]}export{g as defaults,y as expander,m as version};
@@ -1,12 +1,12 @@
1
- "use strict";/**
1
+ /**
2
2
  * @name string-range-expander
3
3
  * @fileoverview Expands string index ranges within whitespace boundaries until letters are met
4
- * @version 3.1.0
4
+ * @version 3.1.2
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-range-expander/}
8
8
  */
9
9
 
10
- var stringRangeExpander=(()=>{var f=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var T=(e,r,s)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,u=(e,r)=>{for(var s in r||(r={}))p.call(r,s)&&T(e,s,r[s]);if(g)for(var s of g(r))I.call(r,s)&&T(e,s,r[s]);return e};var O=(e,r)=>{for(var s in r)f(e,s,{get:r[s],enumerable:!0})},x=(e,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of b(r))!p.call(e,i)&&i!==s&&f(e,i,{get:()=>r[i],enumerable:!(d=S(r,i))||d.enumerable});return e};var w=e=>x(f({},"__esModule",{value:!0}),e);var v={};O(v,{defaults:()=>y,expander:()=>E,version:()=>C});var m="3.1.0";var C=m,y={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function E(e){var h;let r=/^[0-9a-zA-Z]+$/;function s(n){return!n||typeof n!="string"?!1:!n.trim()}function d(n){return typeof n=="string"}if(!e||typeof e!="object"||Array.isArray(e)){let n;throw e===void 0?n="but it is missing completely.":e===null?n="but it was given as null.":n=`but it was given as ${typeof e}, equal to:
10
+ "use strict";var stringRangeExpander=(()=>{var f=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var T=(e,r,s)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,u=(e,r)=>{for(var s in r||(r={}))p.call(r,s)&&T(e,s,r[s]);if(g)for(var s of g(r))I.call(r,s)&&T(e,s,r[s]);return e};var O=(e,r)=>{for(var s in r)f(e,s,{get:r[s],enumerable:!0})},x=(e,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of b(r))!p.call(e,i)&&i!==s&&f(e,i,{get:()=>r[i],enumerable:!(d=S(r,i))||d.enumerable});return e};var w=e=>x(f({},"__esModule",{value:!0}),e);var v={};O(v,{defaults:()=>y,expander:()=>E,version:()=>C});var m="3.1.2";var C=m,y={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function E(e){var h;let r=/^[0-9a-zA-Z]+$/;function s(n){return!n||typeof n!="string"?!1:!n.trim()}function d(n){return typeof n=="string"}if(!e||typeof e!="object"||Array.isArray(e)){let n;throw e===void 0?n="but it is missing completely.":e===null?n="but it was given as null.":n=`but it was given as ${typeof e}, equal to:
11
11
  ${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${n}`)}else if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&!Object.keys(e).length)throw new Error("string-range-expander: [THROW_ID_02] Input must be a plain object but it was given as a plain object without any keys.");if(typeof e.from!="number")throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! Currently it's given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(typeof e.to!="number")throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! Currently it's given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if((e==null?void 0:e.str)&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if((e==null?void 0:e.str)&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.str ("${e.str}") must contain the character at index before "to" ("${e.to-1}")`);if(e.from>e.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${e.from}" is greater than "to" index, "${e.to}". That's wrong!`);if(d(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!d(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide!==!1)throw new Error(`string-range-expander: [THROW_ID_08] The resolvedOpts.extendToOneSide value is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);let i=u(u({},y),e);if(Array.isArray(i.ifLeftSideIncludesThisThenCropTightly)){let n,a;if(i.ifLeftSideIncludesThisThenCropTightly.every((c,$)=>d(c)?!0:(n=$,a=c,!1)))i.ifLeftSideIncludesThisThenCropTightly=i.ifLeftSideIncludesThisThenCropTightly.join("");else throw new Error(`string-range-expander: [THROW_ID_09] The resolvedOpts.ifLeftSideIncludesThisThenCropTightly was set to an array:
12
12
  ${JSON.stringify(i.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${n} is of a type ${typeof a} (equal to ${JSON.stringify(a,null,0)}).`)}let t=i.str,o=i.from,l=i.to;if(i.extendToOneSide!=="right"&&(s(t[o-1])&&(s(t[o-2])||i.ifLeftSideIncludesThisCropItToo.includes(t[o-2]))||t[o-1]&&i.ifLeftSideIncludesThisCropItToo.includes(t[o-1])||i.wipeAllWhitespaceOnLeft&&s(t[o-1]))){for(let n=o;n--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(t[n])){if(t[n].trim()){i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(t[n+1])?o=n+1:o=n+2;break}else if(n===0){i.wipeAllWhitespaceOnLeft?o=0:o=1;break}}}if(i.extendToOneSide!=="left"&&(s(t[l])&&(i.wipeAllWhitespaceOnRight||s(t[l+1]))||i.ifRightSideIncludesThisCropItToo.includes(t[l]))){for(let n=l,a=t.length;n<a;n++)if(!i.ifRightSideIncludesThisCropItToo.includes(t[n])&&((h=t[n])==null?void 0:h.trim())){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(t[n-1])?l=n:l=n-1;break}}return(i.extendToOneSide!=="right"&&d(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(t[o-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(t[o-2])||t[o-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(t[o-1]))||i.extendToOneSide!=="left"&&d(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(t[l+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[l+1])||t[l]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[l])))&&(i.extendToOneSide!=="right"&&s(t[o-1])&&!i.wipeAllWhitespaceOnLeft&&(o-=1),i.extendToOneSide!=="left"&&s(t[l])&&!i.wipeAllWhitespaceOnRight&&(l+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&t[o-1]&&t[o-1].trim()&&t[l]&&t[l].trim()&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||!((!i.ifLeftSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly.includes(t[o-1]))&&(!i.ifRightSideIncludesThisThenCropTightly||t[l]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[l]))))&&(r.test(t[o-1])||r.test(t[l]))?[o,l," "]:[o,l]}return w(v);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-range-expander",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Expands string index ranges within whitespace boundaries until letters are met",
5
5
  "keywords": [
6
6
  "expand",
@@ -13,7 +13,7 @@
13
13
  "text",
14
14
  "within"
15
15
  ],
16
- "homepage": "https://codsen.com/os/string-range-expander/",
16
+ "homepage": "https://codsen.com/os/string-range-expander",
17
17
  "repository": {
18
18
  "type": "git",
19
19
  "url": "https://github.com/codsen/codsen.git",