string-process-comma-separated 3.1.2 → 3.1.3
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
|
@@ -12,7 +12,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
12
12
|
|
|
13
13
|
## 3.0.13 (2022-04-18)
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Fixed
|
|
16
16
|
|
|
17
17
|
- tweak the types ([9f5bddb](https://github.com/codsen/codsen/commit/9f5bddbf84173e51214a4c4ea75c527df0297a70))
|
|
18
18
|
|
|
@@ -40,7 +40,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
40
40
|
|
|
41
41
|
## 2.0.1 (2021-01-28)
|
|
42
42
|
|
|
43
|
-
###
|
|
43
|
+
### Fixed
|
|
44
44
|
|
|
45
45
|
- add testStats to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
|
|
46
46
|
|
|
@@ -60,13 +60,13 @@ Accidental version bump during migration to sourcehut. Sorry about that.
|
|
|
60
60
|
|
|
61
61
|
## 1.2.6 (2020-04-26)
|
|
62
62
|
|
|
63
|
-
###
|
|
63
|
+
### Fixed
|
|
64
64
|
|
|
65
65
|
- harden the eslint rules set, make all tests pass again and rebase a little ([8c2c0a8](https://gitlab.com/codsen/codsen/commit/8c2c0a8d1b0a0c195c853460ac4de117cee15033))
|
|
66
66
|
|
|
67
67
|
## 1.2.0 (2020-01-01)
|
|
68
68
|
|
|
69
|
-
###
|
|
69
|
+
### Fixed
|
|
70
70
|
|
|
71
71
|
- errCb argument fixable tests and functionality ([f89ebc0](https://gitlab.com/codsen/codsen/commit/f89ebc03858734e67e4ffd4db9a89b4116fa07ea))
|
|
72
72
|
- trailing whitespace clause fix ([9ef1181](https://gitlab.com/codsen/codsen/commit/9ef1181c20e15b135b791ccc53343d135241cf22))
|
|
@@ -77,7 +77,7 @@ Accidental version bump during migration to sourcehut. Sorry about that.
|
|
|
77
77
|
|
|
78
78
|
## 1.1.0 (2019-12-27)
|
|
79
79
|
|
|
80
|
-
###
|
|
80
|
+
### Fixed
|
|
81
81
|
|
|
82
82
|
- add more tests and cover opts.trailingWhitespaceOK ([335c6d6](https://gitlab.com/codsen/codsen/commit/335c6d63fa3ff0b324f5d191350fc0e593e88430))
|
|
83
83
|
- returned ranges is always array of arrays, not just a single range/array ([f9469a1](https://gitlab.com/codsen/codsen/commit/f9469a1f53aa13c7f85eb953e35428a735232cd1))
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-process-comma-separated
|
|
3
3
|
* @fileoverview Extracts chunks from possibly comma or whatever-separated string
|
|
4
|
-
* @version 3.1.
|
|
4
|
+
* @version 3.1.3
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-process-comma-separated/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var $="3.1.
|
|
10
|
+
var $="3.1.3";var O=$;function y(s,a){if(typeof s!="string")throw new Error(`string-process-comma-separated: [THROW_ID_01] input must be string! It was given as ${typeof s}, equal to:
|
|
11
11
|
${JSON.stringify(s,null,4)}`);if(!s.length||!a||!a.cb&&!a.errCb)return;let e={...{from:0,to:s.length,offset:0,leadingWhitespaceOK:!1,trailingWhitespaceOK:!1,oneSpaceAfterCommaOK:!1,innerWhitespaceAllowed:!1,separator:",",cb:null,errCb:null},...a};Number.isInteger(a.from)||(e.from=0),Number.isInteger(a.to)||(e.to=s.length),Number.isInteger(a.offset)||(e.offset=0);let l=null,o=null,u=!1,i=[],f=null,n=!0;for(let t=e.from;t<e.to;t++){if(s[t].trim()&&s[t]!==e.separator&&(f=t),l===null&&s[t].trim()&&(!e.separator||s[t]!==e.separator)&&(u||(u=!0),i.length&&(i.length>1&&i.forEach((r,p)=>{p&&e.errCb([[r+e.offset,r+1+e.offset]],"Remove separator.",n)}),i=[]),l=t),Number.isInteger(l)&&(t>l&&e.separator&&s[t]===e.separator||t+1===e.to)){let r=s.slice(l,t+1===e.to&&s[t]!==e.separator&&s[t].trim()?t+1:t);typeof e.cb=="function"&&e.cb(l+e.offset,(t+1===e.to&&s[t]!==e.separator&&s[t].trim()?t+1:f+1)+e.offset),l=null}if(!s[t].trim()&&o===null&&(o=t),o!==null&&(s[t].trim()||t+1===e.to)){if(o===e.from)!e.leadingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[o+e.offset,(t+1===e.to?t+1:t)+e.offset]],"Remove whitespace.",n);else if(!s[t].trim()&&t+1===e.to)!e.trailingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[o+e.offset,t+1+e.offset]],"Remove whitespace.",n);else if((!e.oneSpaceAfterCommaOK||!(s[t].trim()&&t>e.from+1&&s[t-1]===" "&&s[t-2]===","))&&(!e.innerWhitespaceAllowed||!(u&&s[o-1]&&s[t].trim()&&s[t]!==e.separator&&s[o-1]!==e.separator))){let r=o,p=t;t+1===e.to&&s[t]!==e.separator&&!s[t].trim()&&(p+=1);let m="";e.oneSpaceAfterCommaOK&&(s[o]===" "&&s[o-1]===e.separator?r+=1:s[o]!==" "&&(m=" "));let c="Remove whitespace.";!e.innerWhitespaceAllowed&&u&&s[o-1]&&s[t].trim()&&s[t]!==e.separator&&s[o-1]!==e.separator&&(n=!1,c="Bad whitespace."),m.length?e.errCb([[r+e.offset,p+e.offset,m]],c,n):e.errCb([[r+e.offset,p+e.offset]],c,n),n=!0}o=null}s[t]===e.separator&&(u?i.push(t):e.errCb([[t+e.offset,t+1+e.offset]],"Remove separator.",n)),t+1===e.to&&i.forEach(r=>{e.errCb([[r+e.offset,r+1+e.offset]],"Remove separator.",n)})}}export{y as processCommaSep,O as version};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-process-comma-separated
|
|
3
3
|
* @fileoverview Extracts chunks from possibly comma or whatever-separated string
|
|
4
|
-
* @version 3.1.
|
|
4
|
+
* @version 3.1.3
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-process-comma-separated/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var stringProcessCommaSeparated=(()=>{var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var h=(t,o,r)=>o in t?c(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r,b=(t,o)=>{for(var r in o||(o={}))O.call(o,r)&&h(t,r,o[r]);if(g)for(var r of g(o))S.call(o,r)&&h(t,r,o[r]);return t};var N=(t,o)=>{for(var r in o)c(t,r,{get:o[r],enumerable:!0})},A=(t,o,r,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of v(o))!O.call(t,a)&&a!==r&&c(t,a,{get:()=>o[a],enumerable:!(e=E(o,a))||e.enumerable});return t};var C=t=>A(c({},"__esModule",{value:!0}),t);var x={};N(x,{processCommaSep:()=>V,version:()=>D});var y="3.1.
|
|
10
|
+
"use strict";var stringProcessCommaSeparated=(()=>{var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var h=(t,o,r)=>o in t?c(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r,b=(t,o)=>{for(var r in o||(o={}))O.call(o,r)&&h(t,r,o[r]);if(g)for(var r of g(o))S.call(o,r)&&h(t,r,o[r]);return t};var N=(t,o)=>{for(var r in o)c(t,r,{get:o[r],enumerable:!0})},A=(t,o,r,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of v(o))!O.call(t,a)&&a!==r&&c(t,a,{get:()=>o[a],enumerable:!(e=E(o,a))||e.enumerable});return t};var C=t=>A(c({},"__esModule",{value:!0}),t);var x={};N(x,{processCommaSep:()=>V,version:()=>D});var y="3.1.3";var D=y;function V(t,o){if(typeof t!="string")throw new Error(`string-process-comma-separated: [THROW_ID_01] input must be string! It was given as ${typeof t}, equal to:
|
|
11
11
|
${JSON.stringify(t,null,4)}`);if(!t.length||!o||!o.cb&&!o.errCb)return;let r={from:0,to:t.length,offset:0,leadingWhitespaceOK:!1,trailingWhitespaceOK:!1,oneSpaceAfterCommaOK:!1,innerWhitespaceAllowed:!1,separator:",",cb:null,errCb:null},e=b(b({},r),o);Number.isInteger(o.from)||(e.from=0),Number.isInteger(o.to)||(e.to=t.length),Number.isInteger(o.offset)||(e.offset=0);let a=null,n=null,p=!1,u=[],d=null,i=!0;for(let s=e.from;s<e.to;s++){if(t[s].trim()&&t[s]!==e.separator&&(d=s),a===null&&t[s].trim()&&(!e.separator||t[s]!==e.separator)&&(p||(p=!0),u.length&&(u.length>1&&u.forEach((l,m)=>{m&&e.errCb([[l+e.offset,l+1+e.offset]],"Remove separator.",i)}),u=[]),a=s),Number.isInteger(a)&&(s>a&&e.separator&&t[s]===e.separator||s+1===e.to)){let l=t.slice(a,s+1===e.to&&t[s]!==e.separator&&t[s].trim()?s+1:s);typeof e.cb=="function"&&e.cb(a+e.offset,(s+1===e.to&&t[s]!==e.separator&&t[s].trim()?s+1:d+1)+e.offset),a=null}if(!t[s].trim()&&n===null&&(n=s),n!==null&&(t[s].trim()||s+1===e.to)){if(n===e.from)!e.leadingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[n+e.offset,(s+1===e.to?s+1:s)+e.offset]],"Remove whitespace.",i);else if(!t[s].trim()&&s+1===e.to)!e.trailingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[n+e.offset,s+1+e.offset]],"Remove whitespace.",i);else if((!e.oneSpaceAfterCommaOK||!(t[s].trim()&&s>e.from+1&&t[s-1]===" "&&t[s-2]===","))&&(!e.innerWhitespaceAllowed||!(p&&t[n-1]&&t[s].trim()&&t[s]!==e.separator&&t[n-1]!==e.separator))){let l=n,m=s;s+1===e.to&&t[s]!==e.separator&&!t[s].trim()&&(m+=1);let f="";e.oneSpaceAfterCommaOK&&(t[n]===" "&&t[n-1]===e.separator?l+=1:t[n]!==" "&&(f=" "));let $="Remove whitespace.";!e.innerWhitespaceAllowed&&p&&t[n-1]&&t[s].trim()&&t[s]!==e.separator&&t[n-1]!==e.separator&&(i=!1,$="Bad whitespace."),f.length?e.errCb([[l+e.offset,m+e.offset,f]],$,i):e.errCb([[l+e.offset,m+e.offset]],$,i),i=!0}n=null}t[s]===e.separator&&(p?u.push(s):e.errCb([[s+e.offset,s+1+e.offset]],"Remove separator.",i)),s+1===e.to&&u.forEach(l=>{e.errCb([[l+e.offset,l+1+e.offset]],"Remove separator.",i)})}}return C(x);})();
|