string-split-by-whitespace 4.1.3 → 4.2.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/CHANGELOG.md CHANGED
@@ -3,11 +3,23 @@
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
- ## 4.1.0 (2025-10-15)
6
+ ## 4.2.0 (2026-08-19)
7
+
8
+ ### Bug Fixes
9
+
10
+ - resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
11
+ - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
12
+ - standardise whitespace splitting errs ([ff79fd8](https://github.com/codsen/codsen/commit/ff79fd897daeae0ac857dc4dca41caccb1bd60ce))
7
13
 
8
14
  ### Features
9
15
 
10
- - if value to be added is a number, keep it as is, don't stringify ([ce3e1a5](https://github.com/codsen/codsen/commit/ce3e1a525998ca3c0abf0142affef95b14cd1990))
16
+ - add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
17
+ - refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
18
+
19
+ ### Reverts
20
+
21
+ - Revert "Merge pull request #128 from codsen/release/npm-32198404552-1" ([5baeeaa](https://github.com/codsen/codsen/commit/5baeeaaa677b86f1eaa6396cadf3aea32b06416e)), closes [#128](https://github.com/codsen/codsen/issues/128)
22
+ - Revert "Merge pull request #127 from codsen/release/npm-32194020886-1" ([5f1e94d](https://github.com/codsen/codsen/commit/5f1e94deef910ce735266b16aeee08a76de7a862)), closes [#127](https://github.com/codsen/codsen/issues/127)
11
23
 
12
24
  ## 4.0.0 (2022-12-01)
13
25
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2010-2025 Roy Revelt and other contributors
3
+ Copyright © 2010-2026 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
@@ -32,31 +32,15 @@ npm i string-split-by-whitespace
32
32
  ## Quick Take
33
33
 
34
34
  ```js
35
- import { strict as assert } from "assert";
35
+ import { strict as assert } from "node:assert";
36
36
 
37
37
  import { splitByW } from "string-split-by-whitespace";
38
38
 
39
- // Split by whitespace is easy - use native String.prototype.split()
40
- assert.deepEqual("abc def ghi".split(/\s+/), ["abc", "def", "ghi"]);
41
-
42
- const source = "\n \n a\t \nb \n \t";
43
-
44
- // this program is nearly equivalent to regex-based split:
45
- assert.deepEqual(source.split(/\s+/), ["", "a", "b", ""]);
46
- assert.deepEqual(splitByW(source), ["a", "b"]);
47
- // regex-based split needs more filtration but it's native solution
48
-
49
- // ADDITIONALLY...
50
-
51
- // this program allows to exclude certain index ranges:
52
- assert.deepEqual(
53
- splitByW("a b c d e", {
54
- ignoreRanges: [[0, 2]], // that's "a" and space after it
55
- }),
56
- ["b", "c", "d", "e"],
57
- );
39
+ // Split on any whitespace and omit empty edge values.
40
+ assert.deepEqual(splitByW("\n \n a\t \nb \n \t"), ["a", "b"]);
58
41
  ```
59
42
 
43
+
60
44
  ## Documentation
61
45
 
62
46
  Please [visit codsen.com](https://codsen.com/os/string-split-by-whitespace/) for a full description of the API. If you’re looking for the **Changelog**, it’s [here](https://github.com/codsen/codsen/blob/main/packages/string-split-by-whitespace/CHANGELOG.md).
@@ -69,6 +53,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
69
53
 
70
54
  MIT License
71
55
 
72
- Copyright © 2010-2025 Roy Revelt and other contributors
56
+ Copyright © 2010-2026 Roy Revelt and other contributors
73
57
 
74
58
  <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 4.1.3
4
+ * @version 4.2.1
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-split-by-whitespace/}
8
8
  */
9
9
 
10
- import{isIndexWithin as o}from"ranges-is-index-within";var p="4.1.3";var y=p,g={ignoreRanges:[]};function b(t,l){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={...g,...l};if(s.ignoreRanges.length&&!s.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 n=null,i=[];for(let e=0,a=t.length;e<a;e++)n===null&&t[e].trim()&&(!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{g as defaults,b as splitByW,y as version};
10
+ import{isIndexWithin as p}from"ranges-is-index-within";var o="4.2.1";var h=o,g={ignoreRanges:[]};function y(t,l){if(t===void 0)throw new Error("string-split-by-whitespace/splitByW(): [THROW_ID_01] The input is missing!");if(typeof t!="string")return t;if(t.trim()==="")return[];let n={...g,...l};if(n.ignoreRanges.length&&!n.ignoreRanges.every(e=>Array.isArray(e)))throw new Error("string-split-by-whitespace/splitByW(): [THROW_ID_02] The resolvedOpts.ignoreRanges contains elements which are not arrays!");let s=null,i=[];for(let e=0,c=t.length;e<c;e++)s===null&&t[e].trim()&&(!n?.ignoreRanges?.length||n.ignoreRanges.length&&!p(e,n.ignoreRanges.map(r=>[r[0],r[1]-1]),{inclusiveRangeEnds:!0}))&&(s=e),s!==null&&(t[e].trim()?n.ignoreRanges.length&&p(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,y as splitByW,h 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 4.1.3
4
+ * @version 4.2.1
5
5
  * @author Roy Revelt
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 p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols;var d=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var g=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,o=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&g(e,n,t[n]);if(c)for(var n of c(t))b.call(t,n)&&g(e,n,t[n]);return e};var v=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of R(t))!d.call(e,s)&&s!==n&&p(e,s,{get:()=>t[s],enumerable:!(i=y(t,s))||i.enumerable});return e};var x=e=>w(p({},"__esModule",{value:!0}),e);var T={};v(T,{defaults:()=>h,splitByW:()=>O,version:()=>E});var j={inclusiveRangeEnds:!1,returnMatchedRangeInsteadOfTrue:!1};function a(e,t,n){let i=o(o({},j),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 ".concat(e," (type ").concat(typeof e,")"));return Array.isArray(t)?i.returnMatchedRangeInsteadOfTrue?t.find(s=>i.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1])||!1:t.some(s=>i.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1]):!1}var m="4.1.3";var E=m,h={ignoreRanges:[]};function O(e,t){var l;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=o(o({},h),t);if(n.ignoreRanges.length&&!n.ignoreRanges.every(r=>Array.isArray(r)))throw new Error("string-split-by-whitespace: [THROW_ID_03] The resolvedOpts.ignoreRanges contains elements which are not arrays!");let i=null,s=[];for(let r=0,f=e.length;r<f;r++)i===null&&e[r].trim()&&(!((l=n==null?void 0:n.ignoreRanges)!=null&&l.length)||n.ignoreRanges.length&&!a(r,n.ignoreRanges.map(u=>[u[0],u[1]-1]),{inclusiveRangeEnds:!0}))&&(i=r),i!==null&&(e[r].trim()?n.ignoreRanges.length&&a(r,n.ignoreRanges)?(s.push(e.slice(i,r-1)),i=null):e[r+1]===void 0&&s.push(e.slice(i,r+1)):(s.push(e.slice(i,r)),i=null));return s}return x(T);})();
10
+ "use strict";var stringSplitByWhitespace=(()=>{var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols;var m=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var d=(e,n,t)=>n in e?l(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,c=(e,n)=>{for(var t in n||(n={}))m.call(n,t)&&d(e,t,n[t]);if(u)for(var t of u(n))w.call(n,t)&&d(e,t,n[t]);return e};var v=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},R=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of b(n))!m.call(e,r)&&r!==t&&l(e,r,{get:()=>n[r],enumerable:!(i=y(n,r))||i.enumerable});return e};var x=e=>R(l({},"__esModule",{value:!0}),e);var T={};v(T,{defaults:()=>f,splitByW:()=>I,version:()=>k});function g(e,n,t){var p,s;if(!Number.isInteger(e)||e<0)throw new TypeError("ranges-is-index-within/isIndexWithin(): [THROW_ID_01] The first input argument should be a string index: a natural number or zero. It was ".concat(e," (type ").concat(typeof e,")."));if(!Array.isArray(n))return!1;let i=(p=t==null?void 0:t.inclusiveRangeEnds)!=null?p:!1,r=(s=t==null?void 0:t.returnMatchedRangeInsteadOfTrue)!=null?s:!1;for(let a=0;a<n.length;a++){let o=n[a];if(i?e>=o[0]&&e<=o[1]:e>o[0]&&e<o[1])return r?o:!0}return!1}var h="4.2.1";var k=h,f={ignoreRanges:[]};function I(e,n){var p;if(e===void 0)throw new Error("string-split-by-whitespace/splitByW(): [THROW_ID_01] The input is missing!");if(typeof e!="string")return e;if(e.trim()==="")return[];let t=c(c({},f),n);if(t.ignoreRanges.length&&!t.ignoreRanges.every(s=>Array.isArray(s)))throw new Error("string-split-by-whitespace/splitByW(): [THROW_ID_02] The resolvedOpts.ignoreRanges contains elements which are not arrays!");let i=null,r=[];for(let s=0,a=e.length;s<a;s++)i===null&&e[s].trim()&&(!((p=t==null?void 0:t.ignoreRanges)!=null&&p.length)||t.ignoreRanges.length&&!g(s,t.ignoreRanges.map(o=>[o[0],o[1]-1]),{inclusiveRangeEnds:!0}))&&(i=s),i!==null&&(e[s].trim()?t.ignoreRanges.length&&g(s,t.ignoreRanges)?(r.push(e.slice(i,s-1)),i=null):e[s+1]===void 0&&r.push(e.slice(i,s+1)):(r.push(e.slice(i,s)),i=null));return r}return x(T);})();
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 4.1.3
14
+ * @version 4.2.0
15
15
  * @author Roy Revelt
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": "4.1.3",
3
+ "version": "4.2.1",
4
4
  "description": "Split string into array by chunks of whitespace",
5
5
  "keywords": [
6
6
  "alt",
@@ -38,46 +38,45 @@
38
38
  },
39
39
  "types": "types/index.d.ts",
40
40
  "scripts": {
41
- "build": "node '../../ops/scripts/esbuild.js' && npm run dts",
42
- "cjs-off": "exit 0",
43
- "cjs-on": "exit 0",
44
- "dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
41
+ "build": "node ../../ops/scripts/esbuild.js && npm run dts",
42
+ "coverage": "c8 uvu test",
43
+ "dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
45
44
  "devtest": "c8 npm run unit && npm run examples && npm run lint",
46
- "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --log-level 'silent'",
45
+ "dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
47
46
  "examples": "node '../../ops/scripts/run-examples.js'",
48
- "lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
49
- "letspublish": "npm publish --provenance || :",
50
- "lint": "eslint . --fix --concurrency=auto --cache",
47
+ "lect": "node '../../ops/lect/lect.js'",
48
+ "lect:check": "node '../../ops/lect/lect.js' --check",
49
+ "lint": "biome lint --error-on-warnings . && npm run typecheck",
50
+ "lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
51
51
  "perf": "node perf/check.js",
52
52
  "prep": "echo 'ready'",
53
- "prettier": "prettier",
54
- "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --log-level 'silent'",
55
- "pretest": "npm run lect && npm run build",
53
+ "prettier": "biome format",
54
+ "prettier:format": "biome format --write .",
55
+ "pretest": "npm run lect:check && npm run build",
56
56
  "test": "npm run devtest",
57
+ "typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
57
58
  "unit": "uvu test"
58
59
  },
59
- "engines": {
60
- "node": ">=14.18.0"
61
- },
62
60
  "c8": {
61
+ "all": true,
63
62
  "check-coverage": true,
64
- "exclude": [
65
- "**/test/**/*.*"
66
- ],
63
+ "exclude": ["**/test/**/*.*"],
64
+ "include": ["dist/*.esm.js"],
67
65
  "lines": 100
68
66
  },
69
67
  "lect": {
70
68
  "licence": {
71
- "extras": [
72
- ""
73
- ]
69
+ "extras": [""]
74
70
  }
75
71
  },
76
72
  "dependencies": {
77
- "ranges-is-index-within": "^4.1.3"
73
+ "ranges-is-index-within": "^4.2.0"
78
74
  },
79
75
  "devDependencies": {
80
- "string-find-heads-tails": "^6.1.3"
76
+ "string-find-heads-tails": "^6.2.1"
77
+ },
78
+ "engines": {
79
+ "node": ">=18.20.8"
81
80
  },
82
81
  "publishConfig": {
83
82
  "registry": "https://registry.npmjs.org/"