string-split-by-whitespace 3.0.10 → 3.1.0

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,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.1.0 (2022-04-10)
7
+
8
+ ### Features
9
+
10
+ - export defaults ([613b92c](https://github.com/codsen/codsen/commit/613b92c4cdf9e84727c8d2d9c3144138ed457bd7))
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-2021 Roy Revelt and other contributors
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
@@ -74,8 +74,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
74
74
 
75
75
  MIT License
76
76
 
77
- Copyright (c) 2010-2021 Roy Revelt and other contributors
78
-
77
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
79
78
 
80
79
  <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.10
4
+ * @version 3.1.0
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 l="3.0.10";var y=l;function m(s,o){if(s===void 0)throw new Error("string-split-by-whitespace: [THROW_ID_01] The input is missing!");if(typeof s!="string")return s;if(s.trim()==="")return[];let n={...{ignoreRanges:[]},...o};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 t=null,i=[];for(let e=0,p=s.length;e<p;e++)t===null&&s[e].trim()&&(!n||!n.ignoreRanges||!n.ignoreRanges.length||n.ignoreRanges.length&&!a(e,n.ignoreRanges.map(r=>[r[0],r[1]-1]),{inclusiveRangeEnds:!0}))&&(t=e),t!==null&&(s[e].trim()?n.ignoreRanges.length&&a(e,n.ignoreRanges)?(i.push(s.slice(t,e-1)),t=null):s[e+1]===void 0&&i.push(s.slice(t,e+1)):(i.push(s.slice(t,e)),t=null));return i}export{m as splitByW,y as version};
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};
@@ -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.10
4
+ * @version 3.1.0
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 f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var d=(e,n,i)=>n in e?o(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,a=(e,n)=>{for(var i in n||(n={}))g.call(n,i)&&d(e,i,n[i]);if(c)for(var i of c(n))R.call(n,i)&&d(e,i,n[i]);return e};var b=e=>o(e,"__esModule",{value:!0});var v=(e,n)=>{for(var i in n)o(e,i,{get:n[i],enumerable:!0})},w=(e,n,i,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of m(n))!g.call(e,s)&&(i||s!=="default")&&o(e,s,{get:()=>n[s],enumerable:!(t=f(n,s))||t.enumerable});return e};var x=(e=>(n,i)=>e&&e.get(n)||(i=w(b({}),n,1),e&&e.set(n,i),i))(typeof WeakMap!="undefined"?new WeakMap:0);var j={};v(j,{splitByW:()=>T,version:()=>O});var I={inclusiveRangeEnds:!1,returnMatchedRangeInsteadOfTrue:!1};function p(e,n,i){let t=a(a({},I),i);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)?t.returnMatchedRangeInsteadOfTrue?n.find(s=>t.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1])||!1:n.some(s=>t.inclusiveRangeEnds?e>=s[0]&&e<=s[1]:e>s[0]&&e<s[1]):!1}var h="3.0.10";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 t=a(a({},{ignoreRanges:[]}),n);if(t.ignoreRanges.length>0&&!t.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 s=null,l=[];for(let r=0,y=e.length;r<y;r++)s===null&&e[r].trim()&&(!t||!t.ignoreRanges||!t.ignoreRanges.length||t.ignoreRanges.length&&!p(r,t.ignoreRanges.map(u=>[u[0],u[1]-1]),{inclusiveRangeEnds:!0}))&&(s=r),s!==null&&(e[r].trim()?t.ignoreRanges.length&&p(r,t.ignoreRanges)?(l.push(e.slice(s,r-1)),s=null):e[r+1]===void 0&&l.push(e.slice(s,r+1)):(l.push(e.slice(s,r)),s=null));return l}return x(j);})();
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);})();
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.10
14
+ * @version 3.0.12
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.10",
3
+ "version": "3.1.0",
4
4
  "description": "Split string into array by chunks of whitespace",
5
5
  "keywords": [
6
6
  "alt",
@@ -39,15 +39,18 @@
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
+ "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
43
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
43
44
  "examples": "node '../../ops/scripts/run-examples.js'",
44
- "lect": "node '../../ops/lect/lect.js'",
45
+ "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
45
46
  "letspublish": "yarn publish || :",
46
47
  "lint": "eslint . --fix",
47
48
  "perf": "node perf/check.js",
48
49
  "prepare": "echo 'ready'",
50
+ "prettier": "prettier",
51
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
49
52
  "pretest": "yarn run lect && yarn run build",
50
- "test": "c8 yarn run unit && yarn run examples && yarn run lint",
53
+ "test": "yarn run devtest",
51
54
  "unit": "uvu test"
52
55
  },
53
56
  "engines": {
@@ -68,9 +71,9 @@
68
71
  }
69
72
  },
70
73
  "dependencies": {
71
- "ranges-is-index-within": "^3.0.10"
74
+ "ranges-is-index-within": "^3.0.12"
72
75
  },
73
76
  "devDependencies": {
74
- "string-find-heads-tails": "^5.0.10"
77
+ "string-find-heads-tails": "^5.0.13"
75
78
  }
76
79
  }
package/types/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- declare type Range = [from: number, to: number] | [from: number, to: number, whatToInsert: string | null | undefined];
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
- ignoreRanges: Range[];
7
+ ignoreRanges: Range[];
6
8
  }
9
+ declare const defaults: Opts;
7
10
  declare function splitByW(str: string, originalOpts?: Partial<Opts>): string[];
8
11
 
9
- export { splitByW, version };
12
+ export { defaults, splitByW, version };