string-split-by-whitespace 3.1.0 → 3.1.1

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/README.md CHANGED
@@ -26,14 +26,12 @@
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
+ 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-split-by-whitespace@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
@@ -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.1.0
4
+ * @version 3.1.1
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.1.0";var y=o,g={ignoreRanges:[]};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 n={...g,...p};if(n.ignoreRanges.length>0&&!n.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 s=null,i=[];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(r=>[r[0],r[1]-1]),{inclusiveRangeEnds:!0}))&&(s=e),s!==null&&(t[e].trim()?n.ignoreRanges.length&&a(e,n.ignoreRanges)?(i.push(t.slice(s,e-1)),s=null):t[e+1]===void 0&&i.push(t.slice(s,e+1)):(i.push(t.slice(s,e)),s=null));return i}export{g as defaults,m as splitByW,y as version};
10
+ import{isIndexWithin as a}from"ranges-is-index-within";var o="3.1.1";var y=o,g={ignoreRanges:[]};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 n={...g,...p};if(n.ignoreRanges.length&&!n.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 s=null,i=[];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(r=>[r[0],r[1]-1]),{inclusiveRangeEnds:!0}))&&(s=e),s!==null&&(t[e].trim()?n.ignoreRanges.length&&a(e,n.ignoreRanges)?(i.push(t.slice(s,e-1)),s=null):t[e+1]===void 0&&i.push(t.slice(s,e+1)):(i.push(t.slice(s,e)),s=null));return i}export{g as defaults,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.1.0
4
+ * @version 3.1.1
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 o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols;var d=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var c=(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={}))d.call(t,n)&&c(e,n,t[n]);if(u)for(var n of u(t))R.call(t,n)&&c(e,n,t[n]);return e};var w=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},b=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of f(t))!d.call(e,s)&&s!==n&&o(e,s,{get:()=>t[s],enumerable:!(r=m(t,s))||r.enumerable});return e};var v=e=>b(o({},"__esModule",{value:!0}),e);var j={};w(j,{defaults:()=>h,splitByW:()=>O,version:()=>I});var x={inclusiveRangeEnds:!1,returnMatchedRangeInsteadOfTrue:!1};function l(e,t,n){let r=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)?r.returnMatchedRangeInsteadOfTrue?t.find(s=>r.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1])||!1:t.some(s=>r.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1]):!1}var g="3.1.0";var I=g,h={ignoreRanges:[]};function O(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>0&&!n.ignoreRanges.every(i=>Array.isArray(i)))throw new Error("string-split-by-whitespace: [THROW_ID_03] The opts.ignoreRanges contains elements which are not arrays!");let r=null,s=[];for(let i=0,y=e.length;i<y;i++)r===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}))&&(r=i),r!==null&&(e[i].trim()?n.ignoreRanges.length&&l(i,n.ignoreRanges)?(s.push(e.slice(r,i-1)),r=null):e[i+1]===void 0&&s.push(e.slice(r,i+1)):(s.push(e.slice(r,i)),r=null));return s}return v(j);})();
10
+ var stringSplitByWhitespace=(()=>{var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols;var d=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var u=(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={}))d.call(t,n)&&u(e,n,t[n]);if(c)for(var n of c(t))R.call(t,n)&&u(e,n,t[n]);return e};var w=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},b=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of f(t))!d.call(e,s)&&s!==n&&o(e,s,{get:()=>t[s],enumerable:!(r=m(t,s))||r.enumerable});return e};var v=e=>b(o({},"__esModule",{value:!0}),e);var j={};w(j,{defaults:()=>h,splitByW:()=>O,version:()=>I});var x={inclusiveRangeEnds:!1,returnMatchedRangeInsteadOfTrue:!1};function l(e,t,n){let r=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)?r.returnMatchedRangeInsteadOfTrue?t.find(s=>r.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1])||!1:t.some(s=>r.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1]):!1}var g="3.1.1";var I=g,h={ignoreRanges:[]};function O(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 opts.ignoreRanges contains elements which are not arrays!");let r=null,s=[];for(let i=0,y=e.length;i<y;i++)r===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}))&&(r=i),r!==null&&(e[i].trim()?n.ignoreRanges.length&&l(i,n.ignoreRanges)?(s.push(e.slice(r,i-1)),r=null):e[i+1]===void 0&&s.push(e.slice(r,i+1)):(s.push(e.slice(r,i)),r=null));return s}return v(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.12
14
+ * @version 3.1.0
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.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Split string into array by chunks of whitespace",
5
5
  "keywords": [
6
6
  "alt",
@@ -71,9 +71,9 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "ranges-is-index-within": "^3.0.12"
74
+ "ranges-is-index-within": "^3.1.0"
75
75
  },
76
76
  "devDependencies": {
77
- "string-find-heads-tails": "^5.0.13"
77
+ "string-find-heads-tails": "^5.0.14"
78
78
  }
79
79
  }