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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
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
- This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
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 and examples.
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-2021 Roy Revelt and other contributors
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.5
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 version$1 = "3.0.5";
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.5
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
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).stringProcessCommaSeparated={})}(this,(function(e){"use strict";e.processCommaSep=function(e,t){if("string"!=typeof e)throw new Error(`string-process-comma-separated: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}`);if(!e.length||!t||!t.cb&&!t.errCb)return;const r={...{from:0,to:e.length,offset:0,leadingWhitespaceOK:!1,trailingWhitespaceOK:!1,oneSpaceAfterCommaOK:!1,innerWhitespaceAllowed:!1,separator:",",cb:null,errCb:null},...t};Number.isInteger(t.from)||(r.from=0),Number.isInteger(t.to)||(r.to=e.length),Number.isInteger(t.offset)||(r.offset=0);let o=null,s=null,f=!1,a=[],i=null,n=!0;for(let t=r.from;t<r.to;t++){if(e[t].trim()&&e[t]!==r.separator&&(i=t),null!==o||!e[t].trim()||r.separator&&e[t]===r.separator||(f||(f=!0),a.length&&(a.length>1&&a.forEach(((e,t)=>{t&&r.errCb([[e+r.offset,e+1+r.offset]],"Remove separator.",n)})),a=[]),o=t),Number.isInteger(o)&&(t>o&&r.separator&&e[t]===r.separator||t+1===r.to)&&(e.slice(o,t+1===r.to&&e[t]!==r.separator&&e[t].trim()?t+1:t),"function"==typeof r.cb&&r.cb(o+r.offset,(t+1===r.to&&e[t]!==r.separator&&e[t].trim()?t+1:i+1)+r.offset),o=null),e[t].trim()||null!==s||(s=t),null!==s&&(e[t].trim()||t+1===r.to)){if(s===r.from)r.leadingWhitespaceOK||"function"!=typeof r.errCb||r.errCb([[s+r.offset,(t+1===r.to?t+1:t)+r.offset]],"Remove whitespace.",n);else if(e[t].trim()||t+1!==r.to){if(!(r.oneSpaceAfterCommaOK&&e[t].trim()&&t>r.from+1&&" "===e[t-1]&&","===e[t-2]||r.innerWhitespaceAllowed&&f&&e[s-1]&&e[t].trim()&&e[t]!==r.separator&&e[s-1]!==r.separator)){let o=s,a=t;t+1!==r.to||e[t]===r.separator||e[t].trim()||(a+=1);let i="";r.oneSpaceAfterCommaOK&&(" "===e[s]&&e[s-1]===r.separator?o+=1:" "!==e[s]&&(i=" "));let l="Remove whitespace.";!r.innerWhitespaceAllowed&&f&&e[s-1]&&e[t].trim()&&e[t]!==r.separator&&e[s-1]!==r.separator&&(n=!1,l="Bad whitespace."),r.errCb(i.length?[[o+r.offset,a+r.offset,i]]:[[o+r.offset,a+r.offset]],l,n),n=!0}}else r.trailingWhitespaceOK||"function"!=typeof r.errCb||r.errCb([[s+r.offset,t+1+r.offset]],"Remove whitespace.",n);s=null}e[t]===r.separator&&(f?a.push(t):r.errCb([[t+r.offset,t+1+r.offset]],"Remove separator.",n)),t+1===r.to&&a.forEach((e=>{r.errCb([[e+r.offset,e+1+r.offset]],"Remove separator.",n)}))}},e.version="3.0.5",Object.defineProperty(e,"__esModule",{value:!0})}));
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);})();
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { processCommaSep } from "../dist/string-process-comma-separated.esm.js";
5
6
 
6
7
  const gatheredChunks = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-process-comma-separated",
3
- "version": "3.0.5",
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": "rollup -c",
37
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
38
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
39
- "clean_types": "../../scripts/cleanTypes.js",
40
- "dev": "rollup -c --dev",
41
- "devunittest": "npm run dev && tap --only -R 'base'",
42
- "esbuild": "node '../../scripts/esbuild.js'",
43
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
44
- "format": "npm run lect && npm run prettier && npm run lint",
45
- "lect": "lect",
46
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
47
- "perf": "node perf/check",
48
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
49
- "republish": "npm publish || :",
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
- "tap": {
58
- "check-coverage": false,
59
- "coverage-report": [
60
- "json-summary",
61
- "text"
62
- ],
63
- "node-arg": [
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
- "timeout": 0
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 = (indexes: [from: number, to: number][], explanation: string, isFixable: boolean) => void;
2
+ declare type ErrCb = (
3
+ indexes: [from: number, to: number][],
4
+ explanation: string,
5
+ isFixable: boolean
6
+ ) => void;
3
7
  interface Opts {
4
- from: number;
5
- to: number;
6
- offset: number;
7
- leadingWhitespaceOK: boolean;
8
- trailingWhitespaceOK: boolean;
9
- oneSpaceAfterCommaOK: boolean;
10
- innerWhitespaceAllowed: boolean;
11
- separator: string;
12
- cb: null | ((from: number, to: number) => void);
13
- errCb: null | ErrCb;
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(str: string, originalOpts?: Partial<Opts>): void;
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 &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; processCommaSep &#x7D; from \"string-process-comma-separated\";\n\nconst gatheredChunks = [];\nconst gatheredErrors = [];\nconst rawnbsp = \"\\u00a0\";\n\n// it's a callback-interface:\nprocessCommaSep(`<FRAMESET rows=\" ,,\\t50% ,$&#x7B;rawnbsp&#x7D; 50% ,\\t\\t,\">`, &#x7B;\n from: 16, // <- beginning of the attribute's value\n to: 35, // <- ending of the attribute's value\n separator: \",\",\n cb: (idxFrom, idxTo) => &#x7B;\n gatheredChunks.push([idxFrom, idxTo]);\n &#x7D;,\n errCb: (ranges, message) => &#x7B;\n gatheredErrors.push(&#x7B; ranges, message &#x7D;);\n &#x7D;,\n&#x7D;);\n\nassert.deepEqual(gatheredChunks, [\n [20, 23],\n [27, 30],\n]);\n\nassert.deepEqual(gatheredErrors, [\n &#x7B; ranges: [[16, 17]], message: \"Remove whitespace.\" &#x7D;,\n &#x7B; ranges: [[17, 18]], message: \"Remove separator.\" &#x7D;,\n &#x7B; ranges: [[18, 19]], message: \"Remove separator.\" &#x7D;,\n &#x7B; ranges: [[19, 20]], message: \"Remove whitespace.\" &#x7D;,\n &#x7B; ranges: [[23, 24]], message: \"Remove whitespace.\" &#x7D;,\n &#x7B; ranges: [[25, 27]], message: \"Remove whitespace.\" &#x7D;,\n &#x7B; ranges: [[30, 31]], message: \"Remove whitespace.\" &#x7D;,\n &#x7B; ranges: [[32, 34]], message: \"Remove whitespace.\" &#x7D;,\n &#x7B; ranges: [[31, 32]], message: \"Remove separator.\" &#x7D;,\n &#x7B; ranges: [[34, 35]], message: \"Remove separator.\" &#x7D;,\n]);"}}