string-trim-spaces-only 4.0.10 → 4.0.13
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 +6 -0
- package/LICENSE +1 -1
- package/README.md +2 -6
- package/dist/string-trim-spaces-only.esm.js +4 -4
- package/dist/string-trim-spaces-only.umd.js +4 -4
- package/package.json +7 -4
- package/types/index.d.ts +12 -10
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
|
+
## 4.0.13 (2022-04-18)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- tweak types ([e1e4166](https://github.com/codsen/codsen/commit/e1e4166157c90b0a8561b1d4c65defeffae84112))
|
|
11
|
+
|
|
6
12
|
## 4.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-
|
|
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
|
-
This package is ESM
|
|
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, 3.1.0 (`npm i string-trim-spaces-only@3.1.0`).
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i string-trim-spaces-only
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 3.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
@@ -70,8 +68,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
70
68
|
|
|
71
69
|
MIT License
|
|
72
70
|
|
|
73
|
-
Copyright (c) 2010-
|
|
74
|
-
|
|
71
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
75
72
|
|
|
76
73
|
<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">
|
|
77
|
-
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-trim-spaces-only
|
|
3
3
|
* @fileoverview Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.13
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-trim-spaces-only/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
${JSON.stringify(e,null,4)}`);let
|
|
12
|
-
`||
|
|
10
|
+
var i="4.0.13";var g=i,u={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function d(e,l){if(typeof e!="string")throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:
|
|
11
|
+
${JSON.stringify(e,null,4)}`);let n={...u,...l};function o(t){return n.classicTrim&&!t.trim()||!n.classicTrim&&(n.space&&t===" "||n.cr&&t==="\r"||n.lf&&t===`
|
|
12
|
+
`||n.tab&&t===" "||n.nbsp&&t==="\xA0")}let r,s;if(e.length){if(o(e[0]))for(let t=0,a=e.length;t<a;t++){if(!o(e[t])){r=t;break}if(t===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(o(e[e.length-1])){for(let t=e.length;t--;)if(!o(e[t])){s=t+1;break}}return r?s?{res:e.slice(r,s),ranges:[[0,r],[s,e.length]]}:{res:e.slice(r),ranges:[[0,r]]}:s?{res:e.slice(0,s),ranges:[[s,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}export{u as defaults,d as trimSpaces,g as version};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-trim-spaces-only
|
|
3
3
|
* @fileoverview Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.13
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-trim-spaces-only/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var stringTrimSpacesOnly=(()=>{var
|
|
11
|
-
${JSON.stringify(e,null,4)}`);let
|
|
12
|
-
`||
|
|
10
|
+
var stringTrimSpacesOnly=(()=>{var l=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;var u=(e,n,t)=>n in e?l(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,a=(e,n)=>{for(var t in n||(n={}))p.call(n,t)&&u(e,t,n[t]);if(c)for(var t of c(n))f.call(n,t)&&u(e,t,n[t]);return e};var y=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},h=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of $(n))!p.call(e,r)&&r!==t&&l(e,r,{get:()=>n[r],enumerable:!(o=b(n,r))||o.enumerable});return e};var E=e=>h(l({},"__esModule",{value:!0}),e);var V={};y(V,{defaults:()=>g,trimSpaces:()=>S,version:()=>D});var m="4.0.13";var D=m,g={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function S(e,n){if(typeof e!="string")throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:
|
|
11
|
+
${JSON.stringify(e,null,4)}`);let t=a(a({},g),n);function o(s){return t.classicTrim&&!s.trim()||!t.classicTrim&&(t.space&&s===" "||t.cr&&s==="\r"||t.lf&&s===`
|
|
12
|
+
`||t.tab&&s===" "||t.nbsp&&s==="\xA0")}let r,i;if(e.length){if(o(e[0]))for(let s=0,d=e.length;s<d;s++){if(!o(e[s])){r=s;break}if(s===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(o(e[e.length-1])){for(let s=e.length;s--;)if(!o(e[s])){i=s+1;break}}return r?i?{res:e.slice(r,i),ranges:[[0,r],[i,e.length]]}:{res:e.slice(r),ranges:[[0,r]]}:i?{res:e.slice(0,i),ranges:[[i,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}return E(V);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-trim-spaces-only",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.13",
|
|
4
4
|
"description": "Like String.trim() but you can choose granularly what to trim",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"characters",
|
|
@@ -35,15 +35,18 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
37
37
|
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
38
|
-
"
|
|
38
|
+
"devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
39
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
39
40
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
40
|
-
"lect": "node '../../ops/lect/lect.js'",
|
|
41
|
+
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
41
42
|
"letspublish": "yarn publish || :",
|
|
42
43
|
"lint": "eslint . --fix",
|
|
43
44
|
"perf": "node perf/check.js",
|
|
44
45
|
"prepare": "echo 'ready'",
|
|
46
|
+
"prettier": "prettier",
|
|
47
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
45
48
|
"pretest": "yarn run lect && yarn run build",
|
|
46
|
-
"test": "
|
|
49
|
+
"test": "yarn run devtest",
|
|
47
50
|
"unit": "uvu test"
|
|
48
51
|
},
|
|
49
52
|
"engines": {
|
package/types/index.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
declare type Range =
|
|
1
|
+
declare type Range =
|
|
2
|
+
| [from: number, to: number]
|
|
3
|
+
| [from: number, to: number, whatToInsert: string | null | undefined];
|
|
2
4
|
declare type Ranges = Range[] | null;
|
|
3
5
|
|
|
4
6
|
declare const version: string;
|
|
5
7
|
interface Opts {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
classicTrim: boolean;
|
|
9
|
+
cr: boolean;
|
|
10
|
+
lf: boolean;
|
|
11
|
+
tab: boolean;
|
|
12
|
+
space: boolean;
|
|
13
|
+
nbsp: boolean;
|
|
12
14
|
}
|
|
13
15
|
declare const defaults: Opts;
|
|
14
16
|
interface Res {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
res: string;
|
|
18
|
+
ranges: Ranges;
|
|
17
19
|
}
|
|
18
|
-
declare function trimSpaces(str: string,
|
|
20
|
+
declare function trimSpaces(str: string, opts?: Partial<Opts>): Res;
|
|
19
21
|
|
|
20
22
|
export { defaults, trimSpaces, version };
|