string-process-comma-separated 3.0.10 → 3.0.13
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 +6 -0
- package/LICENSE +1 -1
- package/README.md +2 -6
- package/dist/string-process-comma-separated.esm.js +3 -3
- package/dist/string-process-comma-separated.umd.js +3 -3
- package/package.json +7 -4
- package/types/index.d.ts +16 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 3.0.13 (2022-04-18)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- tweak the types ([9f5bddb](https://github.com/codsen/codsen/commit/9f5bddbf84173e51214a4c4ea75c527df0297a70))
|
|
11
|
+
|
|
6
12
|
## 3.0.0 (2021-09-09)
|
|
7
13
|
|
|
8
14
|
### Features
|
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,14 +26,12 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
This package is ESM
|
|
29
|
+
This package is [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you're not ready yet, install an older version of this program, 2.1.0 (`npm i string-process-comma-separated@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
|
|
@@ -89,8 +87,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
89
87
|
|
|
90
88
|
MIT License
|
|
91
89
|
|
|
92
|
-
Copyright (c) 2010-
|
|
93
|
-
|
|
90
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
94
91
|
|
|
95
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">
|
|
96
|
-
|
|
@@ -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.0.
|
|
4
|
+
* @version 3.0.13
|
|
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.0.
|
|
11
|
-
${JSON.stringify(
|
|
10
|
+
var $="3.0.13";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
|
+
${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.0.
|
|
4
|
+
* @version 3.0.13
|
|
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 stringProcessCommaSeparated=(()=>{var
|
|
11
|
-
${JSON.stringify(t,null,4)}`);if(!t.length||!
|
|
10
|
+
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 I={};N(I,{processCommaSep:()=>V,version:()=>D});var y="3.0.13";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
|
+
${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(I);})();
|
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.13",
|
|
4
4
|
"description": "Extracts chunks from possibly comma or whatever-separated string",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"characters",
|
|
@@ -35,15 +35,18 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
37
37
|
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
38
|
-
"
|
|
38
|
+
"devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
39
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
39
40
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
40
|
-
"lect": "node '../../ops/lect/lect.js'",
|
|
41
|
+
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
41
42
|
"letspublish": "yarn publish || :",
|
|
42
43
|
"lint": "eslint . --fix",
|
|
43
44
|
"perf": "node perf/check.js",
|
|
44
45
|
"prepare": "echo 'ready'",
|
|
46
|
+
"prettier": "prettier",
|
|
47
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
45
48
|
"pretest": "yarn run lect && yarn run build",
|
|
46
|
-
"test": "
|
|
49
|
+
"test": "yarn run devtest",
|
|
47
50
|
"unit": "uvu test"
|
|
48
51
|
},
|
|
49
52
|
"engines": {
|
package/types/index.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
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(str: string,
|
|
19
|
+
declare function processCommaSep(str: string, opts?: Partial<Opts>): void;
|
|
16
20
|
|
|
17
21
|
export { processCommaSep, version };
|