string-process-comma-separated 3.0.5 → 3.0.11
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/LICENSE +1 -1
- package/README.md +4 -5
- package/dist/string-process-comma-separated.esm.js +3 -123
- package/dist/string-process-comma-separated.umd.js +3 -2
- package/examples/_quickTake.js +1 -0
- package/package.json +23 -80
- package/types/index.d.ts +19 -12
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `2.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i string-process-comma-separated
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 2.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import { processCommaSep } from "string-process-comma-separated";
|
|
42
41
|
|
|
43
42
|
const gatheredChunks = [];
|
|
@@ -78,7 +77,7 @@ assert.deepEqual(gatheredErrors, [
|
|
|
78
77
|
|
|
79
78
|
## Documentation
|
|
80
79
|
|
|
81
|
-
Please [visit codsen.com](https://codsen.com/os/string-process-comma-separated/) for a full description of the API
|
|
80
|
+
Please [visit codsen.com](https://codsen.com/os/string-process-comma-separated/) for a full description of the API.
|
|
82
81
|
|
|
83
82
|
## Contributing
|
|
84
83
|
|
|
@@ -88,6 +87,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
88
87
|
|
|
89
88
|
MIT License
|
|
90
89
|
|
|
91
|
-
Copyright (c) 2010-
|
|
90
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
92
91
|
|
|
93
92
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
|
@@ -1,131 +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.0.
|
|
4
|
+
* @version 3.0.11
|
|
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
|
|
11
|
-
|
|
12
|
-
const version = version$1;
|
|
13
|
-
function processCommaSep(str, originalOpts) {
|
|
14
|
-
if (typeof str !== "string") {
|
|
15
|
-
throw new Error(`string-process-comma-separated: [THROW_ID_01] input must be string! It was given as ${typeof str}, equal to:\n${JSON.stringify(str, null, 4)}`);
|
|
16
|
-
} else if (!str.length || !originalOpts || !originalOpts.cb && !originalOpts.errCb) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const defaults = {
|
|
20
|
-
from: 0,
|
|
21
|
-
to: str.length,
|
|
22
|
-
offset: 0,
|
|
23
|
-
leadingWhitespaceOK: false,
|
|
24
|
-
trailingWhitespaceOK: false,
|
|
25
|
-
oneSpaceAfterCommaOK: false,
|
|
26
|
-
innerWhitespaceAllowed: false,
|
|
27
|
-
separator: ",",
|
|
28
|
-
cb: null,
|
|
29
|
-
errCb: null
|
|
30
|
-
};
|
|
31
|
-
const opts = { ...defaults,
|
|
32
|
-
...originalOpts
|
|
33
|
-
};
|
|
34
|
-
if (!Number.isInteger(originalOpts.from)) {
|
|
35
|
-
opts.from = 0;
|
|
36
|
-
}
|
|
37
|
-
if (!Number.isInteger(originalOpts.to)) {
|
|
38
|
-
opts.to = str.length;
|
|
39
|
-
}
|
|
40
|
-
if (!Number.isInteger(originalOpts.offset)) {
|
|
41
|
-
opts.offset = 0;
|
|
42
|
-
}
|
|
43
|
-
let chunkStartsAt = null;
|
|
44
|
-
let whitespaceStartsAt = null;
|
|
45
|
-
let firstNonwhitespaceNonseparatorCharFound = false;
|
|
46
|
-
let separatorsArr = [];
|
|
47
|
-
let lastNonWhitespaceCharAt = null;
|
|
48
|
-
let fixable = true;
|
|
49
|
-
for (let i = opts.from; i < opts.to; i++) {
|
|
50
|
-
if (str[i].trim() && str[i] !== opts.separator) {
|
|
51
|
-
lastNonWhitespaceCharAt = i;
|
|
52
|
-
}
|
|
53
|
-
if (chunkStartsAt === null && str[i].trim() && (!opts.separator || str[i] !== opts.separator)) {
|
|
54
|
-
if (!firstNonwhitespaceNonseparatorCharFound) {
|
|
55
|
-
firstNonwhitespaceNonseparatorCharFound = true;
|
|
56
|
-
}
|
|
57
|
-
if (separatorsArr.length) {
|
|
58
|
-
if (separatorsArr.length > 1) {
|
|
59
|
-
separatorsArr.forEach((separatorsIdx, orderNumber) => {
|
|
60
|
-
if (orderNumber) {
|
|
61
|
-
opts.errCb([[separatorsIdx + opts.offset, separatorsIdx + 1 + opts.offset]], "Remove separator.", fixable);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
separatorsArr = [];
|
|
66
|
-
}
|
|
67
|
-
chunkStartsAt = i;
|
|
68
|
-
}
|
|
69
|
-
if (Number.isInteger(chunkStartsAt) && (i > chunkStartsAt && opts.separator && str[i] === opts.separator || i + 1 === opts.to)) {
|
|
70
|
-
str.slice(chunkStartsAt, i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() ? i + 1 : i);
|
|
71
|
-
if (typeof opts.cb === "function") {
|
|
72
|
-
opts.cb(chunkStartsAt + opts.offset, (i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() ? i + 1 : lastNonWhitespaceCharAt + 1) + opts.offset);
|
|
73
|
-
}
|
|
74
|
-
chunkStartsAt = null;
|
|
75
|
-
}
|
|
76
|
-
if (!str[i].trim() && whitespaceStartsAt === null) {
|
|
77
|
-
whitespaceStartsAt = i;
|
|
78
|
-
}
|
|
79
|
-
if (whitespaceStartsAt !== null && (str[i].trim() || i + 1 === opts.to)) {
|
|
80
|
-
if (whitespaceStartsAt === opts.from) {
|
|
81
|
-
if (!opts.leadingWhitespaceOK && typeof opts.errCb === "function") {
|
|
82
|
-
opts.errCb([[whitespaceStartsAt + opts.offset, (i + 1 === opts.to ? i + 1 : i) + opts.offset]], "Remove whitespace.", fixable);
|
|
83
|
-
}
|
|
84
|
-
} else if (!str[i].trim() && i + 1 === opts.to) {
|
|
85
|
-
if (!opts.trailingWhitespaceOK && typeof opts.errCb === "function") {
|
|
86
|
-
opts.errCb([[whitespaceStartsAt + opts.offset, i + 1 + opts.offset]], "Remove whitespace.", fixable);
|
|
87
|
-
}
|
|
88
|
-
} else if ((!opts.oneSpaceAfterCommaOK || !(str[i].trim() && i > opts.from + 1 && str[i - 1] === " " && str[i - 2] === ",")) && (!opts.innerWhitespaceAllowed || !(firstNonwhitespaceNonseparatorCharFound && str[whitespaceStartsAt - 1] && str[i].trim() && str[i] !== opts.separator && str[whitespaceStartsAt - 1] !== opts.separator))) {
|
|
89
|
-
let startingIdx = whitespaceStartsAt;
|
|
90
|
-
let endingIdx = i;
|
|
91
|
-
if (i + 1 === opts.to && str[i] !== opts.separator && !str[i].trim()) {
|
|
92
|
-
endingIdx += 1;
|
|
93
|
-
}
|
|
94
|
-
let whatToAdd = "";
|
|
95
|
-
if (opts.oneSpaceAfterCommaOK) {
|
|
96
|
-
if (str[whitespaceStartsAt] === " " && str[whitespaceStartsAt - 1] === opts.separator) {
|
|
97
|
-
startingIdx += 1;
|
|
98
|
-
} else if (str[whitespaceStartsAt] !== " ") {
|
|
99
|
-
whatToAdd = " ";
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
let message = "Remove whitespace.";
|
|
103
|
-
if (!opts.innerWhitespaceAllowed && firstNonwhitespaceNonseparatorCharFound && str[whitespaceStartsAt - 1] && str[i].trim() && str[i] !== opts.separator && str[whitespaceStartsAt - 1] !== opts.separator) {
|
|
104
|
-
fixable = false;
|
|
105
|
-
message = "Bad whitespace.";
|
|
106
|
-
}
|
|
107
|
-
if (whatToAdd.length) {
|
|
108
|
-
opts.errCb([[startingIdx + opts.offset, endingIdx + opts.offset, whatToAdd]], message, fixable);
|
|
109
|
-
} else {
|
|
110
|
-
opts.errCb([[startingIdx + opts.offset, endingIdx + opts.offset]], message, fixable);
|
|
111
|
-
}
|
|
112
|
-
fixable = true;
|
|
113
|
-
}
|
|
114
|
-
whitespaceStartsAt = null;
|
|
115
|
-
}
|
|
116
|
-
if (str[i] === opts.separator) {
|
|
117
|
-
if (!firstNonwhitespaceNonseparatorCharFound) {
|
|
118
|
-
opts.errCb([[i + opts.offset, i + 1 + opts.offset]], "Remove separator.", fixable);
|
|
119
|
-
} else {
|
|
120
|
-
separatorsArr.push(i);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (i + 1 === opts.to) {
|
|
124
|
-
separatorsArr.forEach(separatorsIdx => {
|
|
125
|
-
opts.errCb([[separatorsIdx + opts.offset, separatorsIdx + 1 + opts.offset]], "Remove separator.", fixable);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export { processCommaSep, version };
|
|
10
|
+
var $="3.0.11";var y=$;function E(o,a){if(typeof o!="string")throw new Error(`string-process-comma-separated: [THROW_ID_01] input must be string! It was given as ${typeof o}, equal to:
|
|
11
|
+
${JSON.stringify(o,null,4)}`);if(!o.length||!a||!a.cb&&!a.errCb)return;let e={...{from:0,to:o.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=o.length),Number.isInteger(a.offset)||(e.offset=0);let i=null,s=null,u=!1,l=[],f=null,n=!0;for(let t=e.from;t<e.to;t++){if(o[t].trim()&&o[t]!==e.separator&&(f=t),i===null&&o[t].trim()&&(!e.separator||o[t]!==e.separator)&&(u||(u=!0),l.length&&(l.length>1&&l.forEach((r,m)=>{m&&e.errCb([[r+e.offset,r+1+e.offset]],"Remove separator.",n)}),l=[]),i=t),Number.isInteger(i)&&(t>i&&e.separator&&o[t]===e.separator||t+1===e.to)){let r=o.slice(i,t+1===e.to&&o[t]!==e.separator&&o[t].trim()?t+1:t);typeof e.cb=="function"&&e.cb(i+e.offset,(t+1===e.to&&o[t]!==e.separator&&o[t].trim()?t+1:f+1)+e.offset),i=null}if(!o[t].trim()&&s===null&&(s=t),s!==null&&(o[t].trim()||t+1===e.to)){if(s===e.from)!e.leadingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[s+e.offset,(t+1===e.to?t+1:t)+e.offset]],"Remove whitespace.",n);else if(!o[t].trim()&&t+1===e.to)!e.trailingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[s+e.offset,t+1+e.offset]],"Remove whitespace.",n);else if((!e.oneSpaceAfterCommaOK||!(o[t].trim()&&t>e.from+1&&o[t-1]===" "&&o[t-2]===","))&&(!e.innerWhitespaceAllowed||!(u&&o[s-1]&&o[t].trim()&&o[t]!==e.separator&&o[s-1]!==e.separator))){let r=s,m=t;t+1===e.to&&o[t]!==e.separator&&!o[t].trim()&&(m+=1);let p="";e.oneSpaceAfterCommaOK&&(o[s]===" "&&o[s-1]===e.separator?r+=1:o[s]!==" "&&(p=" "));let c="Remove whitespace.";!e.innerWhitespaceAllowed&&u&&o[s-1]&&o[t].trim()&&o[t]!==e.separator&&o[s-1]!==e.separator&&(n=!1,c="Bad whitespace."),p.length?e.errCb([[r+e.offset,m+e.offset,p]],c,n):e.errCb([[r+e.offset,m+e.offset]],c,n),n=!0}s=null}o[t]===e.separator&&(u?l.push(t):e.errCb([[t+e.offset,t+1+e.offset]],"Remove separator.",n)),t+1===e.to&&l.forEach(r=>{e.errCb([[r+e.offset,r+1+e.offset]],"Remove separator.",n)})}}export{E as processCommaSep,y as version};
|
|
@@ -1,10 +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.0.
|
|
4
|
+
* @version 3.0.11
|
|
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
|
-
|
|
10
|
+
var stringProcessCommaSeparated=(()=>{var c=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols;var d=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var y=(t,s,r)=>s in t?c(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,b=(t,s)=>{for(var r in s||(s={}))d.call(s,r)&&y(t,r,s[r]);if(h)for(var r of h(s))C.call(s,r)&&y(t,r,s[r]);return t};var A=t=>c(t,"__esModule",{value:!0});var w=(t,s)=>{for(var r in s)c(t,r,{get:s[r],enumerable:!0})},D=(t,s,r,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of N(s))!d.call(t,a)&&(r||a!=="default")&&c(t,a,{get:()=>s[a],enumerable:!(e=S(s,a))||e.enumerable});return t};var O=(t=>(s,r)=>t&&t.get(s)||(r=D(A({}),s,1),t&&t.set(s,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var x={};w(x,{processCommaSep:()=>v,version:()=>I});var E="3.0.11";var I=E;function v(t,s){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
|
+
${JSON.stringify(t,null,4)}`);if(!t.length||!s||!s.cb&&!s.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),s);Number.isInteger(s.from)||(e.from=0),Number.isInteger(s.to)||(e.to=t.length),Number.isInteger(s.offset)||(e.offset=0);let a=null,n=null,m=!1,u=[],g=null,l=!0;for(let o=e.from;o<e.to;o++){if(t[o].trim()&&t[o]!==e.separator&&(g=o),a===null&&t[o].trim()&&(!e.separator||t[o]!==e.separator)&&(m||(m=!0),u.length&&(u.length>1&&u.forEach((i,p)=>{p&&e.errCb([[i+e.offset,i+1+e.offset]],"Remove separator.",l)}),u=[]),a=o),Number.isInteger(a)&&(o>a&&e.separator&&t[o]===e.separator||o+1===e.to)){let i=t.slice(a,o+1===e.to&&t[o]!==e.separator&&t[o].trim()?o+1:o);typeof e.cb=="function"&&e.cb(a+e.offset,(o+1===e.to&&t[o]!==e.separator&&t[o].trim()?o+1:g+1)+e.offset),a=null}if(!t[o].trim()&&n===null&&(n=o),n!==null&&(t[o].trim()||o+1===e.to)){if(n===e.from)!e.leadingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[n+e.offset,(o+1===e.to?o+1:o)+e.offset]],"Remove whitespace.",l);else if(!t[o].trim()&&o+1===e.to)!e.trailingWhitespaceOK&&typeof e.errCb=="function"&&e.errCb([[n+e.offset,o+1+e.offset]],"Remove whitespace.",l);else if((!e.oneSpaceAfterCommaOK||!(t[o].trim()&&o>e.from+1&&t[o-1]===" "&&t[o-2]===","))&&(!e.innerWhitespaceAllowed||!(m&&t[n-1]&&t[o].trim()&&t[o]!==e.separator&&t[n-1]!==e.separator))){let i=n,p=o;o+1===e.to&&t[o]!==e.separator&&!t[o].trim()&&(p+=1);let f="";e.oneSpaceAfterCommaOK&&(t[n]===" "&&t[n-1]===e.separator?i+=1:t[n]!==" "&&(f=" "));let $="Remove whitespace.";!e.innerWhitespaceAllowed&&m&&t[n-1]&&t[o].trim()&&t[o]!==e.separator&&t[n-1]!==e.separator&&(l=!1,$="Bad whitespace."),f.length?e.errCb([[i+e.offset,p+e.offset,f]],$,l):e.errCb([[i+e.offset,p+e.offset]],$,l),l=!0}n=null}t[o]===e.separator&&(m?u.push(o):e.errCb([[o+e.offset,o+1+e.offset]],"Remove separator.",l)),o+1===e.to&&u.forEach(i=>{e.errCb([[i+e.offset,i+1+e.offset]],"Remove separator.",l)})}}return O(x);})();
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-process-comma-separated",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Extracts chunks from possibly comma or whatever-separated string",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"characters",
|
|
@@ -33,93 +33,36 @@
|
|
|
33
33
|
},
|
|
34
34
|
"types": "types/index.d.ts",
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"tap": "tap",
|
|
51
|
-
"pretest": "npm run build",
|
|
52
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
53
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
54
|
-
"tsc": "tsc",
|
|
55
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
36
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
37
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
38
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
39
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
40
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
41
|
+
"letspublish": "yarn publish || :",
|
|
42
|
+
"lint": "eslint . --fix",
|
|
43
|
+
"perf": "node perf/check.js",
|
|
44
|
+
"prepare": "echo 'ready'",
|
|
45
|
+
"prettier": "prettier",
|
|
46
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
47
|
+
"pretest": "yarn run lect && yarn run build",
|
|
48
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
49
|
+
"unit": "uvu test"
|
|
56
50
|
},
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"--no-warnings",
|
|
65
|
-
"--experimental-loader",
|
|
66
|
-
"@istanbuljs/esm-loader-hook"
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
53
|
+
},
|
|
54
|
+
"c8": {
|
|
55
|
+
"check-coverage": true,
|
|
56
|
+
"exclude": [
|
|
57
|
+
"**/test/**/*.*"
|
|
67
58
|
],
|
|
68
|
-
"
|
|
59
|
+
"lines": 100
|
|
69
60
|
},
|
|
70
61
|
"lect": {
|
|
71
62
|
"licence": {
|
|
72
63
|
"extras": [
|
|
73
64
|
""
|
|
74
65
|
]
|
|
75
|
-
},
|
|
76
|
-
"req": "{ processCommaSep }",
|
|
77
|
-
"various": {
|
|
78
|
-
"devDependencies": []
|
|
79
66
|
}
|
|
80
|
-
},
|
|
81
|
-
"dependencies": {
|
|
82
|
-
"@babel/runtime": "^7.16.0"
|
|
83
|
-
},
|
|
84
|
-
"devDependencies": {
|
|
85
|
-
"@babel/cli": "^7.16.0",
|
|
86
|
-
"@babel/core": "^7.16.0",
|
|
87
|
-
"@babel/node": "^7.16.0",
|
|
88
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
89
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
90
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
91
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
92
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
93
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
94
|
-
"@babel/preset-env": "^7.16.0",
|
|
95
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
96
|
-
"@babel/register": "^7.16.0",
|
|
97
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
98
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
99
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
100
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
101
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
102
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
103
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
104
|
-
"@types/node": "^16.11.6",
|
|
105
|
-
"@types/tap": "^15.0.5",
|
|
106
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
107
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
108
|
-
"core-js": "^3.19.1",
|
|
109
|
-
"cross-env": "^7.0.3",
|
|
110
|
-
"eslint": "^8.2.0",
|
|
111
|
-
"lect": "^0.18.5",
|
|
112
|
-
"rollup": "^2.59.0",
|
|
113
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
114
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
115
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
116
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
117
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
118
|
-
"tap": "^15.0.10",
|
|
119
|
-
"tslib": "^2.3.1",
|
|
120
|
-
"typescript": "^4.4.4"
|
|
121
|
-
},
|
|
122
|
-
"engines": {
|
|
123
|
-
"node": ">=12"
|
|
124
67
|
}
|
|
125
68
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
declare const version: string;
|
|
2
|
-
declare type ErrCb = (
|
|
2
|
+
declare type ErrCb = (
|
|
3
|
+
indexes: [from: number, to: number][],
|
|
4
|
+
explanation: string,
|
|
5
|
+
isFixable: boolean
|
|
6
|
+
) => void;
|
|
3
7
|
interface Opts {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
leadingWhitespaceOK: boolean;
|
|
12
|
+
trailingWhitespaceOK: boolean;
|
|
13
|
+
oneSpaceAfterCommaOK: boolean;
|
|
14
|
+
innerWhitespaceAllowed: boolean;
|
|
15
|
+
separator: string;
|
|
16
|
+
cb: null | ((from: number, to: number) => void);
|
|
17
|
+
errCb: null | ErrCb;
|
|
14
18
|
}
|
|
15
|
-
declare function processCommaSep(
|
|
19
|
+
declare function processCommaSep(
|
|
20
|
+
str: string,
|
|
21
|
+
originalOpts?: Partial<Opts>
|
|
22
|
+
): void;
|
|
16
23
|
|
|
17
24
|
export { processCommaSep, version };
|
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { processCommaSep } from \"string-process-comma-separated\";\n\nconst gatheredChunks = [];\nconst gatheredErrors = [];\nconst rawnbsp = \"\\u00a0\";\n\n// it's a callback-interface:\nprocessCommaSep(`<FRAMESET rows=\" ,,\\t50% ,${rawnbsp} 50% ,\\t\\t,\">`, {\n from: 16, // <- beginning of the attribute's value\n to: 35, // <- ending of the attribute's value\n separator: \",\",\n cb: (idxFrom, idxTo) => {\n gatheredChunks.push([idxFrom, idxTo]);\n },\n errCb: (ranges, message) => {\n gatheredErrors.push({ ranges, message });\n },\n});\n\nassert.deepEqual(gatheredChunks, [\n [20, 23],\n [27, 30],\n]);\n\nassert.deepEqual(gatheredErrors, [\n { ranges: [[16, 17]], message: \"Remove whitespace.\" },\n { ranges: [[17, 18]], message: \"Remove separator.\" },\n { ranges: [[18, 19]], message: \"Remove separator.\" },\n { ranges: [[19, 20]], message: \"Remove whitespace.\" },\n { ranges: [[23, 24]], message: \"Remove whitespace.\" },\n { ranges: [[25, 27]], message: \"Remove whitespace.\" },\n { ranges: [[30, 31]], message: \"Remove whitespace.\" },\n { ranges: [[32, 34]], message: \"Remove whitespace.\" },\n { ranges: [[31, 32]], message: \"Remove separator.\" },\n { ranges: [[34, 35]], message: \"Remove separator.\" },\n]);"}}
|