string-trim-spaces-only 3.1.0 → 4.0.3
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,36 @@
|
|
|
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.3 (2021-11-02)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
- programs now are in ES Modules and won't work with Common JS require()
|
|
19
|
+
|
|
20
|
+
## 4.0.1 (2021-09-13)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
25
|
+
|
|
26
|
+
## 4.0.0 (2021-09-09)
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
- migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
|
|
31
|
+
|
|
32
|
+
### BREAKING CHANGES
|
|
33
|
+
|
|
34
|
+
- programs now are in ES Modules and won't work with Common JS require()
|
|
35
|
+
|
|
6
36
|
## 3.1.0 (2021-05-24)
|
|
7
37
|
|
|
8
38
|
### Features
|
package/README.md
CHANGED
|
@@ -26,10 +26,14 @@
|
|
|
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:
|
|
30
|
+
|
|
29
31
|
```bash
|
|
30
32
|
npm i string-trim-spaces-only
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
If you need a legacy version which works with `require`, use version 3.1.0
|
|
36
|
+
|
|
33
37
|
## Quick Take
|
|
34
38
|
|
|
35
39
|
```js
|
|
@@ -1,13 +1,13 @@
|
|
|
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
|
+
* @version 4.0.3
|
|
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 version$1 = "
|
|
10
|
+
var version$1 = "4.0.3";
|
|
11
11
|
|
|
12
12
|
const version = version$1;
|
|
13
13
|
const defaults = {
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
+
* @version 4.0.3
|
|
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
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).stringTrimSpacesOnly={})}(this,(function(e){"use strict";const n={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};e.defaults=n,e.trimSpaces=function(e,t){if("string"!=typeof e)throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}`);const s={...n,...t};function r(e){return s.classicTrim&&!e.trim()||!s.classicTrim&&(s.space&&" "===e||s.cr&&"\r"===e||s.lf&&"\n"===e||s.tab&&"\t"===e||s.nbsp&&" "===e)}let i,l;if(e.length){if(r(e[0]))for(let n=0,t=e.length;n<t;n++){if(!r(e[n])){i=n;break}if(n===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(r(e[e.length-1]))for(let n=e.length;n--;)if(!r(e[n])){l=n+1;break}return i?l?{res:e.slice(i,l),ranges:[[0,i],[l,e.length]]}:{res:e.slice(i),ranges:[[0,i]]}:l?{res:e.slice(0,l),ranges:[[l,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}},e.version="
|
|
10
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).stringTrimSpacesOnly={})}(this,(function(e){"use strict";const n={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};e.defaults=n,e.trimSpaces=function(e,t){if("string"!=typeof e)throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}`);const s={...n,...t};function r(e){return s.classicTrim&&!e.trim()||!s.classicTrim&&(s.space&&" "===e||s.cr&&"\r"===e||s.lf&&"\n"===e||s.tab&&"\t"===e||s.nbsp&&" "===e)}let i,l;if(e.length){if(r(e[0]))for(let n=0,t=e.length;n<t;n++){if(!r(e[n])){i=n;break}if(n===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(r(e[e.length-1]))for(let n=e.length;n--;)if(!r(e[n])){l=n+1;break}return i?l?{res:e.slice(i,l),ranges:[[0,i],[l,e.length]]}:{res:e.slice(i),ranges:[[0,i]]}:l?{res:e.slice(0,l),ranges:[[l,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}},e.version="4.0.3",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-trim-spaces-only",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Like String.trim() but you can choose granularly what to trim",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"characters",
|
|
@@ -26,17 +26,21 @@
|
|
|
26
26
|
"email": "roy@codsen.com",
|
|
27
27
|
"url": "https://codsen.com"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
"script": "./dist/string-trim-spaces-only.umd.js",
|
|
32
|
+
"default": "./dist/string-trim-spaces-only.esm.js"
|
|
33
|
+
},
|
|
32
34
|
"types": "types/index.d.ts",
|
|
33
35
|
"scripts": {
|
|
34
36
|
"build": "rollup -c",
|
|
35
|
-
"esbuild": "node '../../scripts/esbuild.js'",
|
|
36
|
-
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
37
37
|
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
|
|
38
|
+
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
|
|
39
|
+
"clean_types": "../../scripts/cleanTypes.js",
|
|
38
40
|
"dev": "rollup -c --dev",
|
|
39
41
|
"devunittest": "npm run dev && tap --only -R 'base'",
|
|
42
|
+
"esbuild": "node '../../scripts/esbuild.js'",
|
|
43
|
+
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
40
44
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
41
45
|
"lect": "lect",
|
|
42
46
|
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
|
|
@@ -44,22 +48,22 @@
|
|
|
44
48
|
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
45
49
|
"republish": "npm publish || :",
|
|
46
50
|
"tap": "tap",
|
|
47
|
-
"tsc": "tsc",
|
|
48
51
|
"pretest": "npm run build",
|
|
49
52
|
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
50
53
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"clean_types": "../../scripts/cleanTypes.js"
|
|
54
|
+
"tsc": "tsc",
|
|
55
|
+
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
54
56
|
},
|
|
55
57
|
"tap": {
|
|
58
|
+
"check-coverage": false,
|
|
56
59
|
"coverage-report": [
|
|
57
60
|
"json-summary",
|
|
58
61
|
"text"
|
|
59
62
|
],
|
|
60
|
-
"
|
|
61
|
-
"--
|
|
62
|
-
"--
|
|
63
|
+
"node-arg": [
|
|
64
|
+
"--no-warnings",
|
|
65
|
+
"--experimental-loader",
|
|
66
|
+
"@istanbuljs/esm-loader-hook"
|
|
63
67
|
],
|
|
64
68
|
"timeout": 0
|
|
65
69
|
},
|
|
@@ -75,43 +79,47 @@
|
|
|
75
79
|
}
|
|
76
80
|
},
|
|
77
81
|
"dependencies": {
|
|
78
|
-
"@babel/runtime": "^7.
|
|
82
|
+
"@babel/runtime": "^7.16.0"
|
|
79
83
|
},
|
|
80
84
|
"devDependencies": {
|
|
81
|
-
"@babel/cli": "^7.
|
|
82
|
-
"@babel/core": "^7.
|
|
83
|
-
"@babel/node": "^7.
|
|
84
|
-
"@babel/plugin-external-helpers": "^7.
|
|
85
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
86
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
87
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
88
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
89
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
90
|
-
"@babel/preset-env": "^7.
|
|
91
|
-
"@babel/preset-typescript": "^7.
|
|
92
|
-
"@babel/register": "^7.
|
|
85
|
+
"@babel/cli": "^7.16.0",
|
|
86
|
+
"@babel/core": "^7.16.0",
|
|
87
|
+
"@babel/node": "^7.16.0",
|
|
88
|
+
"@babel/plugin-external-helpers": "^7.16.0",
|
|
89
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
90
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
91
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
92
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
93
|
+
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
94
|
+
"@babel/preset-env": "^7.16.0",
|
|
95
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
96
|
+
"@babel/register": "^7.16.0",
|
|
97
|
+
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
93
98
|
"@rollup/plugin-babel": "^5.3.0",
|
|
94
|
-
"@rollup/plugin-commonjs": "^
|
|
99
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
95
100
|
"@rollup/plugin-json": "^4.1.0",
|
|
96
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
97
|
-
"@rollup/plugin-strip": "^2.0
|
|
98
|
-
"@rollup/plugin-typescript": "^8.
|
|
99
|
-
"@types/node": "^
|
|
100
|
-
"@types/tap": "^15.0.
|
|
101
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
102
|
-
"@typescript-eslint/parser": "^
|
|
103
|
-
"core-js": "^3.
|
|
101
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
102
|
+
"@rollup/plugin-strip": "^2.1.0",
|
|
103
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
104
|
+
"@types/node": "^16.11.6",
|
|
105
|
+
"@types/tap": "^15.0.5",
|
|
106
|
+
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
|
107
|
+
"@typescript-eslint/parser": "^5.2.0",
|
|
108
|
+
"core-js": "^3.19.0",
|
|
104
109
|
"cross-env": "^7.0.3",
|
|
105
|
-
"eslint": "^
|
|
106
|
-
"lect": "^0.
|
|
107
|
-
"rollup": "^2.
|
|
110
|
+
"eslint": "^8.1.0",
|
|
111
|
+
"lect": "^0.18.3",
|
|
112
|
+
"rollup": "^2.59.0",
|
|
108
113
|
"rollup-plugin-ascii": "^0.0.3",
|
|
109
114
|
"rollup-plugin-banner": "^0.2.1",
|
|
110
115
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
111
|
-
"rollup-plugin-dts": "^
|
|
116
|
+
"rollup-plugin-dts": "^4.0.0",
|
|
112
117
|
"rollup-plugin-terser": "^7.0.2",
|
|
113
|
-
"tap": "^
|
|
114
|
-
"tslib": "^2.
|
|
115
|
-
"typescript": "^4.
|
|
118
|
+
"tap": "^15.0.10",
|
|
119
|
+
"tslib": "^2.3.1",
|
|
120
|
+
"typescript": "^4.4.4"
|
|
121
|
+
},
|
|
122
|
+
"engines": {
|
|
123
|
+
"node": ">=12"
|
|
116
124
|
}
|
|
117
125
|
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name string-trim-spaces-only
|
|
3
|
-
* @fileoverview Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* @version 3.1.0
|
|
5
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6
|
-
* @license MIT
|
|
7
|
-
* {@link https://codsen.com/os/string-trim-spaces-only/}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
13
|
-
|
|
14
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
15
|
-
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
20
|
-
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
21
|
-
|
|
22
|
-
var version$1 = "3.1.0";
|
|
23
|
-
|
|
24
|
-
var version = version$1;
|
|
25
|
-
var defaults = {
|
|
26
|
-
classicTrim: false,
|
|
27
|
-
cr: false,
|
|
28
|
-
lf: false,
|
|
29
|
-
tab: false,
|
|
30
|
-
space: true,
|
|
31
|
-
nbsp: false
|
|
32
|
-
};
|
|
33
|
-
function trimSpaces(str, originalOpts) {
|
|
34
|
-
if (typeof str !== "string") {
|
|
35
|
-
throw new Error("string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ".concat(_typeof__default['default'](str), ", equal to:\n").concat(JSON.stringify(str, null, 4)));
|
|
36
|
-
}
|
|
37
|
-
var opts = _objectSpread__default['default'](_objectSpread__default['default']({}, defaults), originalOpts);
|
|
38
|
-
function check(_char) {
|
|
39
|
-
return opts.classicTrim && !_char.trim() || !opts.classicTrim && (opts.space && _char === " " || opts.cr && _char === "\r" || opts.lf && _char === "\n" || opts.tab && _char === "\t" || opts.nbsp && _char === "\xA0");
|
|
40
|
-
}
|
|
41
|
-
var newStart;
|
|
42
|
-
var newEnd;
|
|
43
|
-
if (str.length) {
|
|
44
|
-
if (check(str[0])) {
|
|
45
|
-
for (var i = 0, len = str.length; i < len; i++) {
|
|
46
|
-
if (!check(str[i])) {
|
|
47
|
-
newStart = i;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
if (i === str.length - 1) {
|
|
51
|
-
return {
|
|
52
|
-
res: "",
|
|
53
|
-
ranges: [[0, str.length]]
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (check(str[str.length - 1])) {
|
|
59
|
-
for (var _i = str.length; _i--;) {
|
|
60
|
-
if (!check(str[_i])) {
|
|
61
|
-
newEnd = _i + 1;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (newStart) {
|
|
67
|
-
if (newEnd) {
|
|
68
|
-
return {
|
|
69
|
-
res: str.slice(newStart, newEnd),
|
|
70
|
-
ranges: [[0, newStart], [newEnd, str.length]]
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
res: str.slice(newStart),
|
|
75
|
-
ranges: [[0, newStart]]
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
if (newEnd) {
|
|
79
|
-
return {
|
|
80
|
-
res: str.slice(0, newEnd),
|
|
81
|
-
ranges: [[newEnd, str.length]]
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
res: str,
|
|
86
|
-
ranges: []
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
res: "",
|
|
91
|
-
ranges: []
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exports.defaults = defaults;
|
|
96
|
-
exports.trimSpaces = trimSpaces;
|
|
97
|
-
exports.version = version;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name string-trim-spaces-only
|
|
3
|
-
* @fileoverview Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* @version 3.1.0
|
|
5
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6
|
-
* @license MIT
|
|
7
|
-
* {@link https://codsen.com/os/string-trim-spaces-only/}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
(function (global, factory) {
|
|
11
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
12
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
13
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.stringTrimSpacesOnly = {}));
|
|
14
|
-
}(this, (function (exports) { 'use strict';
|
|
15
|
-
|
|
16
|
-
var version$1 = "3.1.0";
|
|
17
|
-
|
|
18
|
-
const version = version$1;
|
|
19
|
-
const defaults = {
|
|
20
|
-
classicTrim: false,
|
|
21
|
-
cr: false,
|
|
22
|
-
lf: false,
|
|
23
|
-
tab: false,
|
|
24
|
-
space: true,
|
|
25
|
-
nbsp: false,
|
|
26
|
-
};
|
|
27
|
-
function trimSpaces(str, originalOpts) {
|
|
28
|
-
// insurance:
|
|
29
|
-
if (typeof str !== "string") {
|
|
30
|
-
throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof str}, equal to:\n${JSON.stringify(str, null, 4)}`);
|
|
31
|
-
}
|
|
32
|
-
// opts preparation:
|
|
33
|
-
const opts = { ...defaults, ...originalOpts };
|
|
34
|
-
function check(char) {
|
|
35
|
-
return ((opts.classicTrim && !char.trim()) ||
|
|
36
|
-
(!opts.classicTrim &&
|
|
37
|
-
((opts.space && char === " ") ||
|
|
38
|
-
(opts.cr && char === "\r") ||
|
|
39
|
-
(opts.lf && char === "\n") ||
|
|
40
|
-
(opts.tab && char === "\t") ||
|
|
41
|
-
(opts.nbsp && char === "\u00a0"))));
|
|
42
|
-
}
|
|
43
|
-
// action:
|
|
44
|
-
let newStart;
|
|
45
|
-
let newEnd;
|
|
46
|
-
if (str.length) {
|
|
47
|
-
if (check(str[0])) {
|
|
48
|
-
for (let i = 0, len = str.length; i < len; i++) {
|
|
49
|
-
if (!check(str[i])) {
|
|
50
|
-
newStart = i;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
// if we traversed the whole string this way and didn't stumble on a non-
|
|
54
|
-
// space/whitespace character (depending on opts.classicTrim), this means
|
|
55
|
-
// whole thing can be trimmed:
|
|
56
|
-
if (i === str.length - 1) {
|
|
57
|
-
// this means there are only spaces/whitespace from beginning to the end
|
|
58
|
-
return {
|
|
59
|
-
res: "",
|
|
60
|
-
ranges: [[0, str.length]],
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// if we reached this far, check the last character - find out, is it worth
|
|
66
|
-
// trimming the end of the given string:
|
|
67
|
-
if (check(str[str.length - 1])) {
|
|
68
|
-
for (let i = str.length; i--;) {
|
|
69
|
-
if (!check(str[i])) {
|
|
70
|
-
newEnd = i + 1;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (newStart) {
|
|
76
|
-
if (newEnd) {
|
|
77
|
-
return {
|
|
78
|
-
res: str.slice(newStart, newEnd),
|
|
79
|
-
ranges: [
|
|
80
|
-
[0, newStart],
|
|
81
|
-
[newEnd, str.length],
|
|
82
|
-
],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
res: str.slice(newStart),
|
|
87
|
-
ranges: [[0, newStart]],
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
if (newEnd) {
|
|
91
|
-
return {
|
|
92
|
-
res: str.slice(0, newEnd),
|
|
93
|
-
ranges: [[newEnd, str.length]],
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
// if we reached this far, there was nothing to trim:
|
|
97
|
-
return {
|
|
98
|
-
res: str,
|
|
99
|
-
ranges: [],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
// if we reached this far, this means it's an empty string. In which case,
|
|
103
|
-
// return empty values:
|
|
104
|
-
return {
|
|
105
|
-
res: "",
|
|
106
|
-
ranges: [],
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
exports.defaults = defaults;
|
|
111
|
-
exports.trimSpaces = trimSpaces;
|
|
112
|
-
exports.version = version;
|
|
113
|
-
|
|
114
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
115
|
-
|
|
116
|
-
})));
|