string-split-by-whitespace 3.2.4 → 3.2.6
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
|
@@ -30,7 +30,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
30
30
|
|
|
31
31
|
### BREAKING CHANGES
|
|
32
32
|
|
|
33
|
-
- programs now are in ES Modules and won't work with Common JS require()
|
|
33
|
+
- programs now are in ES Modules and won't work with Common JS `require()`
|
|
34
34
|
|
|
35
35
|
## 2.1.0 (2021-05-24)
|
|
36
36
|
|
|
@@ -48,7 +48,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
48
48
|
|
|
49
49
|
### Fixed
|
|
50
50
|
|
|
51
|
-
- add testStats to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
|
|
51
|
+
- add `testStats` to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
|
|
52
52
|
|
|
53
53
|
## 2.0.0 (2021-01-23)
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
62
62
|
|
|
63
63
|
## 1.7.0 (2020-11-28)
|
|
64
64
|
|
|
65
|
-
Accidental version bump during migration to
|
|
65
|
+
Accidental version bump during migration to SourceHut. Sorry about that.
|
|
66
66
|
|
|
67
67
|
## 1.6.46 (2019-10-05)
|
|
68
68
|
|
package/README.md
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">string-split-by-whitespace</h1>
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
<p align="center">Split string into array by chunks of whitespace</p>
|
|
4
4
|
|
|
5
|
-
<
|
|
6
|
-
<a href="https://www.npmjs.com/package/string-split-by-whitespace" 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-split-by-whitespace" 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-split-by-whitespace" 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-split-by-whitespace" 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-split-by-whitespace?interval=30" rel="nofollow noreferrer noopener" target="_blank">
|
|
16
16
|
<img src="https://img.shields.io/npm/dm/string-split-by-whitespace.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-split-by-whitespace/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
|
|
|
@@ -70,8 +67,8 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
70
67
|
|
|
71
68
|
## Licence
|
|
72
69
|
|
|
73
|
-
MIT License
|
|
70
|
+
MIT License.
|
|
74
71
|
|
|
75
|
-
Copyright
|
|
72
|
+
Copyright © 2010-2022 Roy Revelt and other contributors.
|
|
76
73
|
|
|
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">
|
|
74
|
+
<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,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.2.
|
|
4
|
+
* @version 3.2.6
|
|
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 a}from"ranges-is-index-within";var o="3.2.
|
|
10
|
+
import{isIndexWithin as a}from"ranges-is-index-within";var o="3.2.6";var f=o,u={ignoreRanges:[]};function R(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 n={...u,...p};if(n.ignoreRanges.length&&!n.ignoreRanges.every(e=>Array.isArray(e)))throw new Error("string-split-by-whitespace: [THROW_ID_03] The resolvedOpts.ignoreRanges contains elements which are not arrays!");let s=null,r=[];for(let e=0,l=t.length;e<l;e++)s===null&&t[e].trim()&&(!n||!n.ignoreRanges||!n.ignoreRanges.length||n.ignoreRanges.length&&!a(e,n.ignoreRanges.map(i=>[i[0],i[1]-1]),{inclusiveRangeEnds:!0}))&&(s=e),s!==null&&(t[e].trim()?n.ignoreRanges.length&&a(e,n.ignoreRanges)?(r.push(t.slice(s,e-1)),s=null):t[e+1]===void 0&&r.push(t.slice(s,e+1)):(r.push(t.slice(s,e)),s=null));return r}export{u as defaults,R as splitByW,f 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.2.
|
|
4
|
+
* @version 3.2.6
|
|
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
|
-
"use strict";var stringSplitByWhitespace=(()=>{var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols;var c=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var d=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,a=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(u)for(var n of u(t))R.call(t,n)&&d(e,n,t[n]);return e};var b=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!c.call(e,r)&&r!==n&&o(e,r,{get:()=>t[r],enumerable:!(s=m(t,r))||s.enumerable});return e};var w=e=>v(o({},"__esModule",{value:!0}),e);var
|
|
10
|
+
"use strict";var stringSplitByWhitespace=(()=>{var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols;var c=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var d=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,a=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(u)for(var n of u(t))R.call(t,n)&&d(e,n,t[n]);return e};var b=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!c.call(e,r)&&r!==n&&o(e,r,{get:()=>t[r],enumerable:!(s=m(t,r))||s.enumerable});return e};var w=e=>v(o({},"__esModule",{value:!0}),e);var j={};b(j,{defaults:()=>h,splitByW:()=>E,version:()=>O});var x={inclusiveRangeEnds:!1,returnMatchedRangeInsteadOfTrue:!1};function l(e,t,n){let s=a(a({},x),n);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(t)?s.returnMatchedRangeInsteadOfTrue?t.find(r=>s.inclusiveRangeEnds?e>=r[0]&&e<=r[1]:e>r[0]&&e<r[1])||!1:t.some(r=>s.inclusiveRangeEnds?e>=r[0]&&e<=r[1]:e>r[0]&&e<r[1]):!1}var g="3.2.6";var O=g,h={ignoreRanges:[]};function E(e,t){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 n=a(a({},h),t);if(n.ignoreRanges.length&&!n.ignoreRanges.every(i=>Array.isArray(i)))throw new Error("string-split-by-whitespace: [THROW_ID_03] The resolvedOpts.ignoreRanges contains elements which are not arrays!");let s=null,r=[];for(let i=0,y=e.length;i<y;i++)s===null&&e[i].trim()&&(!n||!n.ignoreRanges||!n.ignoreRanges.length||n.ignoreRanges.length&&!l(i,n.ignoreRanges.map(p=>[p[0],p[1]-1]),{inclusiveRangeEnds:!0}))&&(s=i),s!==null&&(e[i].trim()?n.ignoreRanges.length&&l(i,n.ignoreRanges)?(r.push(e.slice(s,i-1)),s=null):e[i+1]===void 0&&r.push(e.slice(s,i+1)):(r.push(e.slice(s,i)),s=null));return r}return w(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.2.
|
|
14
|
+
* @version 3.2.5
|
|
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.2.
|
|
3
|
+
"version": "3.2.6",
|
|
4
4
|
"description": "Split string into array by chunks of whitespace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alt",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
46
46
|
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
47
47
|
"letspublish": "yarn publish || :",
|
|
48
|
-
"lint": "eslint . --fix",
|
|
48
|
+
"lint": "eslint . --ext .js --ext .ts --fix",
|
|
49
49
|
"perf": "node perf/check.js",
|
|
50
50
|
"prepare": "echo 'ready'",
|
|
51
51
|
"prettier": "prettier",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"ranges-is-index-within": "^3.2.
|
|
75
|
+
"ranges-is-index-within": "^3.2.5"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"string-find-heads-tails": "^5.1.
|
|
78
|
+
"string-find-heads-tails": "^5.1.6"
|
|
79
79
|
}
|
|
80
80
|
}
|
package/examples/_quickTake.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Quick Take
|
|
2
|
-
|
|
3
|
-
import { strict as assert } from "assert";
|
|
4
|
-
|
|
5
|
-
import { splitByW } from "../dist/string-split-by-whitespace.esm.js";
|
|
6
|
-
|
|
7
|
-
// Split by whitespace is easy - use native String.prototype.split()
|
|
8
|
-
assert.deepEqual("abc def ghi".split(/\s+/), ["abc", "def", "ghi"]);
|
|
9
|
-
|
|
10
|
-
const source = `\n \n a\t \nb \n \t`;
|
|
11
|
-
|
|
12
|
-
// this program is nearly equivalent to regex-based split:
|
|
13
|
-
assert.deepEqual(source.split(/\s+/), ["", "a", "b", ""]);
|
|
14
|
-
assert.deepEqual(splitByW(source), ["a", "b"]);
|
|
15
|
-
// regex-based split needs more filtration but it's native solution
|
|
16
|
-
|
|
17
|
-
// ADDITIONALLY...
|
|
18
|
-
|
|
19
|
-
// this program allows to exclude certain index ranges:
|
|
20
|
-
assert.deepEqual(
|
|
21
|
-
splitByW("a b c d e", {
|
|
22
|
-
ignoreRanges: [[0, 2]], // that's "a" and space after it
|
|
23
|
-
}),
|
|
24
|
-
["b", "c", "d", "e"]
|
|
25
|
-
);
|