string-split-by-whitespace 3.0.10 → 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-
|
|
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
|
-
|
|
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-split-by-whitespace
|
|
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
|
|
@@ -74,8 +72,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
74
72
|
|
|
75
73
|
MIT License
|
|
76
74
|
|
|
77
|
-
Copyright (c) 2010-
|
|
78
|
-
|
|
75
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
79
76
|
|
|
80
77
|
<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">
|
|
81
|
-
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-split-by-whitespace
|
|
3
3
|
* @fileoverview Split string into array by chunks of whitespace
|
|
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-split-by-whitespace/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{isIndexWithin as
|
|
10
|
+
import{isIndexWithin as o}from"ranges-is-index-within";var a="3.0.11";var y=a;function m(t,p){if(t===void 0)throw new Error("string-split-by-whitespace: [THROW_ID_01] The input is missing!");if(typeof t!="string")return t;if(t.trim()==="")return[];let s={...{ignoreRanges:[]},...p};if(s.ignoreRanges.length>0&&!s.ignoreRanges.every(e=>Array.isArray(e)))throw new Error("string-split-by-whitespace: [THROW_ID_03] The opts.ignoreRanges contains elements which are not arrays!");let n=null,i=[];for(let e=0,l=t.length;e<l;e++)n===null&&t[e].trim()&&(!s||!s.ignoreRanges||!s.ignoreRanges.length||s.ignoreRanges.length&&!o(e,s.ignoreRanges.map(r=>[r[0],r[1]-1]),{inclusiveRangeEnds:!0}))&&(n=e),n!==null&&(t[e].trim()?s.ignoreRanges.length&&o(e,s.ignoreRanges)?(i.push(t.slice(n,e-1)),n=null):t[e+1]===void 0&&i.push(t.slice(n,e+1)):(i.push(t.slice(n,e)),n=null));return i}export{m as splitByW,y as version};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-split-by-whitespace
|
|
3
3
|
* @fileoverview Split string into array by chunks of whitespace
|
|
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-split-by-whitespace/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var stringSplitByWhitespace=(()=>{var
|
|
10
|
+
var stringSplitByWhitespace=(()=>{var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols;var d=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var g=(e,n,s)=>n in e?l(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,a=(e,n)=>{for(var s in n||(n={}))d.call(n,s)&&g(e,s,n[s]);if(c)for(var s of c(n))R.call(n,s)&&g(e,s,n[s]);return e};var w=e=>l(e,"__esModule",{value:!0});var b=(e,n)=>{for(var s in n)l(e,s,{get:n[s],enumerable:!0})},v=(e,n,s,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of f(n))!d.call(e,t)&&(s||t!=="default")&&l(e,t,{get:()=>n[t],enumerable:!(i=m(n,t))||i.enumerable});return e};var x=(e=>(n,s)=>e&&e.get(n)||(s=v(w({}),n,1),e&&e.set(n,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var j={};b(j,{splitByW:()=>T,version:()=>O});var I={inclusiveRangeEnds:!1,returnMatchedRangeInsteadOfTrue:!1};function p(e,n,s){let i=a(a({},I),s);if(!Number.isInteger(e))throw new Error(`ranges-is-index-within: [THROW_ID_01] the first input argument should be string index, a natural number (or zero). It was given as ${e} (type ${typeof e})`);return Array.isArray(n)?i.returnMatchedRangeInsteadOfTrue?n.find(t=>i.inclusiveRangeEnds?e>=t[0]&&e<=t[1]:e>t[0]&&e<t[1])||!1:n.some(t=>i.inclusiveRangeEnds?e>=t[0]&&e<=t[1]:e>t[0]&&e<t[1]):!1}var h="3.0.11";var O=h;function T(e,n){if(e===void 0)throw new Error("string-split-by-whitespace: [THROW_ID_01] The input is missing!");if(typeof e!="string")return e;if(e.trim()==="")return[];let i=a(a({},{ignoreRanges:[]}),n);if(i.ignoreRanges.length>0&&!i.ignoreRanges.every(r=>Array.isArray(r)))throw new Error("string-split-by-whitespace: [THROW_ID_03] The opts.ignoreRanges contains elements which are not arrays!");let t=null,o=[];for(let r=0,y=e.length;r<y;r++)t===null&&e[r].trim()&&(!i||!i.ignoreRanges||!i.ignoreRanges.length||i.ignoreRanges.length&&!p(r,i.ignoreRanges.map(u=>[u[0],u[1]-1]),{inclusiveRangeEnds:!0}))&&(t=r),t!==null&&(e[r].trim()?i.ignoreRanges.length&&p(r,i.ignoreRanges)?(o.push(e.slice(t,r-1)),t=null):e[r+1]===void 0&&o.push(e.slice(t,r+1)):(o.push(e.slice(t,r)),t=null));return o}return x(j);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name ranges-is-index-within
|
|
13
13
|
* @fileoverview Checks if index is within any of the given string index ranges
|
|
14
|
-
* @version 3.0.
|
|
14
|
+
* @version 3.0.11
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/ranges-is-index-within/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-split-by-whitespace",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Split string into array by chunks of whitespace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alt",
|
|
@@ -39,13 +39,15 @@
|
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
41
41
|
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
42
|
-
"dts": "rollup -c",
|
|
42
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
43
43
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
44
44
|
"lect": "node '../../ops/lect/lect.js'",
|
|
45
45
|
"letspublish": "yarn publish || :",
|
|
46
46
|
"lint": "eslint . --fix",
|
|
47
47
|
"perf": "node perf/check.js",
|
|
48
48
|
"prepare": "echo 'ready'",
|
|
49
|
+
"prettier": "prettier",
|
|
50
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
49
51
|
"pretest": "yarn run lect && yarn run build",
|
|
50
52
|
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
51
53
|
"unit": "uvu test"
|
|
@@ -68,9 +70,9 @@
|
|
|
68
70
|
}
|
|
69
71
|
},
|
|
70
72
|
"dependencies": {
|
|
71
|
-
"ranges-is-index-within": "^3.0.
|
|
73
|
+
"ranges-is-index-within": "^3.0.11"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
74
|
-
"string-find-heads-tails": "^5.0.
|
|
76
|
+
"string-find-heads-tails": "^5.0.11"
|
|
75
77
|
}
|
|
76
78
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
declare type Range =
|
|
1
|
+
declare type Range =
|
|
2
|
+
| [from: number, to: number]
|
|
3
|
+
| [from: number, to: number, whatToInsert: string | null | undefined];
|
|
2
4
|
|
|
3
5
|
declare const version: string;
|
|
4
6
|
interface Opts {
|
|
5
|
-
|
|
7
|
+
ignoreRanges: Range[];
|
|
6
8
|
}
|
|
7
9
|
declare function splitByW(str: string, originalOpts?: Partial<Opts>): string[];
|
|
8
10
|
|