string-process-comma-separated 3.1.3 → 3.1.5
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
|
@@ -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
|
|
|
@@ -42,7 +42,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
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,7 +56,7 @@ 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
|
|
|
@@ -73,13 +73,13 @@ Accidental version bump during migration to sourcehut. Sorry about that.
|
|
|
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
|
package/README.md
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">string-process-comma-separated</h1>
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
<p align="center">Extracts chunks from possibly comma or whatever-separated string</p>
|
|
4
4
|
|
|
5
|
-
<
|
|
6
|
-
<a href="https://www.npmjs.com/package/string-process-comma-separated" rel="nofollow noreferrer noopener">
|
|
7
|
-
<img src="https://img.shields.io/badge/-npm-blue?style=flat-square" alt="page on npm">
|
|
8
|
-
</a>
|
|
5
|
+
<p align="center">
|
|
9
6
|
<a href="https://codsen.com/os/string-process-comma-separated" rel="nofollow noreferrer noopener">
|
|
10
7
|
<img src="https://img.shields.io/badge/-codsen-blue?style=flat-square" alt="page on codsen.com">
|
|
11
8
|
</a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/string-process-comma-separated" rel="nofollow noreferrer noopener">
|
|
10
|
+
<img src="https://img.shields.io/badge/-npm-blue?style=flat-square" alt="page on npm">
|
|
11
|
+
</a>
|
|
12
12
|
<a href="https://github.com/codsen/codsen/tree/main/packages/string-process-comma-separated" rel="nofollow noreferrer noopener">
|
|
13
13
|
<img src="https://img.shields.io/badge/-github-blue?style=flat-square" alt="page on github">
|
|
14
14
|
</a>
|
|
15
15
|
<a href="https://npmcharts.com/compare/string-process-comma-separated?interval=30" rel="nofollow noreferrer noopener" target="_blank">
|
|
16
16
|
<img src="https://img.shields.io/npm/dm/string-process-comma-separated.svg?style=flat-square" alt="Downloads per month">
|
|
17
17
|
</a>
|
|
18
|
-
<a href="https://
|
|
19
|
-
<img src="https://img.shields.io/badge/
|
|
20
|
-
</a>
|
|
21
|
-
<img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg?style=flat-square" alt="MIT License">
|
|
22
|
-
<a href="https://liberamanifesto.com" rel="nofollow noreferrer noopener" target="_blank">
|
|
23
|
-
<img src="https://img.shields.io/badge/libera-manifesto-lightgrey.svg?style=flat-square" alt="libera manifesto">
|
|
18
|
+
<a href="https://codsen.com/os/string-process-comma-separated/changelog" rel="nofollow noreferrer noopener">
|
|
19
|
+
<img src="https://img.shields.io/badge/changelog-here-brightgreen?style=flat-square" alt="changelog">
|
|
24
20
|
</a>
|
|
25
|
-
|
|
21
|
+
<img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg?style=flat-square" alt="MIT Licence">
|
|
22
|
+
</p>
|
|
26
23
|
|
|
27
24
|
## Install
|
|
28
25
|
|
|
@@ -85,8 +82,8 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
85
82
|
|
|
86
83
|
## Licence
|
|
87
84
|
|
|
88
|
-
MIT License
|
|
85
|
+
MIT License.
|
|
89
86
|
|
|
90
|
-
Copyright
|
|
87
|
+
Copyright © 2010-2022 Roy Revelt and other contributors.
|
|
91
88
|
|
|
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">
|
|
89
|
+
<p align="center"><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"></p>
|
|
@@ -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.5
|
|
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.5";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.5
|
|
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.5";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.5",
|
|
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
|
-
]);
|