string-process-comma-separated 3.1.2 → 3.1.4
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
|
|
|
@@ -24,7 +24,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
24
24
|
|
|
25
25
|
### BREAKING CHANGES
|
|
26
26
|
|
|
27
|
-
- programs now are in ES Modules and won't work with Common JS require()
|
|
27
|
+
- programs now are in ES Modules and won't work with Common JS `require()`
|
|
28
28
|
|
|
29
29
|
## 2.1.0 (2021-05-24)
|
|
30
30
|
|
|
@@ -40,9 +40,9 @@ 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
|
-
- add testStats to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
|
|
45
|
+
- add `testStats` to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
|
|
46
46
|
|
|
47
47
|
## 2.0.0 (2021-01-23)
|
|
48
48
|
|
|
@@ -56,30 +56,30 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
56
56
|
|
|
57
57
|
## 1.3.0 (2020-11-28)
|
|
58
58
|
|
|
59
|
-
Accidental version bump during migration to
|
|
59
|
+
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))
|
|
73
73
|
|
|
74
74
|
### Features
|
|
75
75
|
|
|
76
|
-
- opts.innerWhitespaceAllowed ([65dfb1f](https://gitlab.com/codsen/codsen/commit/65dfb1fa5fed0b201b3e5001d418b49b5f94917c))
|
|
76
|
+
- `opts.innerWhitespaceAllowed` ([65dfb1f](https://gitlab.com/codsen/codsen/commit/65dfb1fa5fed0b201b3e5001d418b49b5f94917c))
|
|
77
77
|
|
|
78
78
|
## 1.1.0 (2019-12-27)
|
|
79
79
|
|
|
80
|
-
###
|
|
80
|
+
### Fixed
|
|
81
81
|
|
|
82
|
-
- add more tests and cover opts.trailingWhitespaceOK ([335c6d6](https://gitlab.com/codsen/codsen/commit/335c6d63fa3ff0b324f5d191350fc0e593e88430))
|
|
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))
|
|
84
84
|
|
|
85
85
|
### Features
|
|
@@ -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.4
|
|
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.4";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.4
|
|
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.4";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);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-process-comma-separated",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "Extracts chunks from possibly comma or whatever-separated string",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"characters",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
42
42
|
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
43
43
|
"letspublish": "yarn publish || :",
|
|
44
|
-
"lint": "eslint . --fix",
|
|
44
|
+
"lint": "eslint . --ext .js --ext .ts --fix",
|
|
45
45
|
"perf": "node perf/check.js",
|
|
46
46
|
"prepare": "echo 'ready'",
|
|
47
47
|
"prettier": "prettier",
|
package/examples/_quickTake.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Quick Take
|
|
2
|
-
|
|
3
|
-
import { strict as assert } from "assert";
|
|
4
|
-
|
|
5
|
-
import { processCommaSep } from "../dist/string-process-comma-separated.esm.js";
|
|
6
|
-
|
|
7
|
-
const gatheredChunks = [];
|
|
8
|
-
const gatheredErrors = [];
|
|
9
|
-
const rawnbsp = "\u00a0";
|
|
10
|
-
|
|
11
|
-
// it's a callback-interface:
|
|
12
|
-
processCommaSep(`<FRAMESET rows=" ,,\t50% ,${rawnbsp} 50% ,\t\t,">`, {
|
|
13
|
-
from: 16, // <- beginning of the attribute's value
|
|
14
|
-
to: 35, // <- ending of the attribute's value
|
|
15
|
-
separator: ",",
|
|
16
|
-
cb: (idxFrom, idxTo) => {
|
|
17
|
-
gatheredChunks.push([idxFrom, idxTo]);
|
|
18
|
-
},
|
|
19
|
-
errCb: (ranges, message) => {
|
|
20
|
-
gatheredErrors.push({ ranges, message });
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
assert.deepEqual(gatheredChunks, [
|
|
25
|
-
[20, 23],
|
|
26
|
-
[27, 30],
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
assert.deepEqual(gatheredErrors, [
|
|
30
|
-
{ ranges: [[16, 17]], message: "Remove whitespace." },
|
|
31
|
-
{ ranges: [[17, 18]], message: "Remove separator." },
|
|
32
|
-
{ ranges: [[18, 19]], message: "Remove separator." },
|
|
33
|
-
{ ranges: [[19, 20]], message: "Remove whitespace." },
|
|
34
|
-
{ ranges: [[23, 24]], message: "Remove whitespace." },
|
|
35
|
-
{ ranges: [[25, 27]], message: "Remove whitespace." },
|
|
36
|
-
{ ranges: [[30, 31]], message: "Remove whitespace." },
|
|
37
|
-
{ ranges: [[32, 34]], message: "Remove whitespace." },
|
|
38
|
-
{ ranges: [[31, 32]], message: "Remove separator." },
|
|
39
|
-
{ ranges: [[34, 35]], message: "Remove separator." },
|
|
40
|
-
]);
|