string-trim-spaces-only 2.8.13 → 2.8.17
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
|
@@ -55,9 +55,9 @@ This package has three builds in `dist/` folder:
|
|
|
55
55
|
|
|
56
56
|
| Type | Key in `package.json` | Path | Size |
|
|
57
57
|
| ------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------- | ---- |
|
|
58
|
-
| Main export - **CommonJS version**, transpiled to ES5, contains `require` and `module.exports` | `main` | `dist/string-trim-spaces-only.cjs.js` |
|
|
58
|
+
| Main export - **CommonJS version**, transpiled to ES5, contains `require` and `module.exports` | `main` | `dist/string-trim-spaces-only.cjs.js` | 4 KB |
|
|
59
59
|
| **ES module** build that Webpack/Rollup understands. Untranspiled ES6 code with `import`/`export`. | `module` | `dist/string-trim-spaces-only.esm.js` | 2 KB |
|
|
60
|
-
| **UMD build** for browsers, transpiled, minified, containing `iife`'s and has all dependencies baked-in | `browser` | `dist/string-trim-spaces-only.umd.js` |
|
|
60
|
+
| **UMD build** for browsers, transpiled, minified, containing `iife`'s and has all dependencies baked-in | `browser` | `dist/string-trim-spaces-only.umd.js` | 2 KB |
|
|
61
61
|
|
|
62
62
|
**[⬆ back to top](#)**
|
|
63
63
|
|
|
@@ -189,7 +189,7 @@ Copyright (c) 2015-2020 Roy Revelt and other contributors
|
|
|
189
189
|
|
|
190
190
|
[gitlab-img]: https://img.shields.io/badge/repo-on%20GitLab-brightgreen.svg?style=flat-square
|
|
191
191
|
[gitlab-url]: https://gitlab.com/codsen/codsen/tree/master/packages/string-trim-spaces-only
|
|
192
|
-
[cov-img]: https://img.shields.io/badge/coverage-
|
|
192
|
+
[cov-img]: https://img.shields.io/badge/coverage-100%25-brightgreen.svg?style=flat-square
|
|
193
193
|
[cov-url]: https://gitlab.com/codsen/codsen/tree/master/packages/string-trim-spaces-only
|
|
194
194
|
[no-deps-img]: https://img.shields.io/badge/-no%20dependencies-brightgreen?style=flat-square
|
|
195
195
|
[no-deps-url]: https://www.npmjs.com/package/string-trim-spaces-only?activeTab=dependencies
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-trim-spaces-only
|
|
3
3
|
* Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* Version: 2.8.
|
|
4
|
+
* Version: 2.8.17
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-trim-spaces-only
|
|
@@ -25,6 +25,55 @@ function _typeof(obj) {
|
|
|
25
25
|
return _typeof(obj);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
function _defineProperty(obj, key, value) {
|
|
29
|
+
if (key in obj) {
|
|
30
|
+
Object.defineProperty(obj, key, {
|
|
31
|
+
value: value,
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
obj[key] = value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ownKeys(object, enumerableOnly) {
|
|
44
|
+
var keys = Object.keys(object);
|
|
45
|
+
|
|
46
|
+
if (Object.getOwnPropertySymbols) {
|
|
47
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
48
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
50
|
+
});
|
|
51
|
+
keys.push.apply(keys, symbols);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return keys;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _objectSpread2(target) {
|
|
58
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
59
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
60
|
+
|
|
61
|
+
if (i % 2) {
|
|
62
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
63
|
+
_defineProperty(target, key, source[key]);
|
|
64
|
+
});
|
|
65
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
66
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
67
|
+
} else {
|
|
68
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
69
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return target;
|
|
75
|
+
}
|
|
76
|
+
|
|
28
77
|
function trimSpaces(s, originalOpts) {
|
|
29
78
|
if (typeof s !== "string") {
|
|
30
79
|
throw new Error("string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ".concat(_typeof(s), ", equal to:\n").concat(JSON.stringify(s, null, 4)));
|
|
@@ -37,13 +86,13 @@ function trimSpaces(s, originalOpts) {
|
|
|
37
86
|
space: true,
|
|
38
87
|
nbsp: false
|
|
39
88
|
};
|
|
40
|
-
var opts =
|
|
41
|
-
function check(
|
|
42
|
-
return opts.classicTrim &&
|
|
89
|
+
var opts = _objectSpread2(_objectSpread2({}, defaults), originalOpts);
|
|
90
|
+
function check(char) {
|
|
91
|
+
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");
|
|
43
92
|
}
|
|
44
93
|
var newStart;
|
|
45
94
|
var newEnd;
|
|
46
|
-
if (s.length
|
|
95
|
+
if (s.length) {
|
|
47
96
|
if (check(s[0])) {
|
|
48
97
|
for (var i = 0, len = s.length; i < len; i++) {
|
|
49
98
|
if (!check(s[i])) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-trim-spaces-only
|
|
3
3
|
* Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* Version: 2.8.
|
|
4
|
+
* Version: 2.8.17
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-trim-spaces-only
|
|
@@ -29,6 +29,55 @@
|
|
|
29
29
|
return _typeof(obj);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function _defineProperty(obj, key, value) {
|
|
33
|
+
if (key in obj) {
|
|
34
|
+
Object.defineProperty(obj, key, {
|
|
35
|
+
value: value,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
obj[key] = value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function ownKeys(object, enumerableOnly) {
|
|
48
|
+
var keys = Object.keys(object);
|
|
49
|
+
|
|
50
|
+
if (Object.getOwnPropertySymbols) {
|
|
51
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
52
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
53
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
54
|
+
});
|
|
55
|
+
keys.push.apply(keys, symbols);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return keys;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _objectSpread2(target) {
|
|
62
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
63
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
64
|
+
|
|
65
|
+
if (i % 2) {
|
|
66
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
67
|
+
_defineProperty(target, key, source[key]);
|
|
68
|
+
});
|
|
69
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
70
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
71
|
+
} else {
|
|
72
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
73
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
|
|
32
81
|
function trimSpaces(s, originalOpts) {
|
|
33
82
|
// insurance:
|
|
34
83
|
if (typeof s !== "string") {
|
|
@@ -44,17 +93,18 @@
|
|
|
44
93
|
space: true,
|
|
45
94
|
nbsp: false
|
|
46
95
|
};
|
|
47
|
-
var opts = Object.assign({}, defaults, originalOpts);
|
|
48
96
|
|
|
49
|
-
|
|
50
|
-
|
|
97
|
+
var opts = _objectSpread2(_objectSpread2({}, defaults), originalOpts);
|
|
98
|
+
|
|
99
|
+
function check(char) {
|
|
100
|
+
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");
|
|
51
101
|
} // action:
|
|
52
102
|
|
|
53
103
|
|
|
54
104
|
var newStart;
|
|
55
105
|
var newEnd;
|
|
56
106
|
|
|
57
|
-
if (s.length
|
|
107
|
+
if (s.length) {
|
|
58
108
|
if (check(s[0])) {
|
|
59
109
|
for (var i = 0, len = s.length; i < len; i++) {
|
|
60
110
|
if (!check(s[i])) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-trim-spaces-only
|
|
3
3
|
* Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* Version: 2.8.
|
|
4
|
+
* Version: 2.8.17
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-trim-spaces-only
|
|
@@ -25,10 +25,10 @@ function trimSpaces(s, originalOpts) {
|
|
|
25
25
|
space: true,
|
|
26
26
|
nbsp: false,
|
|
27
27
|
};
|
|
28
|
-
const opts =
|
|
28
|
+
const opts = { ...defaults, ...originalOpts };
|
|
29
29
|
function check(char) {
|
|
30
30
|
return (
|
|
31
|
-
(opts.classicTrim && char.trim()
|
|
31
|
+
(opts.classicTrim && !char.trim()) ||
|
|
32
32
|
(!opts.classicTrim &&
|
|
33
33
|
((opts.space && char === " ") ||
|
|
34
34
|
(opts.cr && char === "\r") ||
|
|
@@ -39,7 +39,7 @@ function trimSpaces(s, originalOpts) {
|
|
|
39
39
|
}
|
|
40
40
|
let newStart;
|
|
41
41
|
let newEnd;
|
|
42
|
-
if (s.length
|
|
42
|
+
if (s.length) {
|
|
43
43
|
if (check(s[0])) {
|
|
44
44
|
for (let i = 0, len = s.length; i < len; i++) {
|
|
45
45
|
if (!check(s[i])) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-trim-spaces-only
|
|
3
3
|
* Like String.trim() but you can choose granularly what to trim
|
|
4
|
-
* Version: 2.8.
|
|
4
|
+
* Version: 2.8.17
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-trim-spaces-only
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).stringTrimSpacesOnly=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(r){t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}return function(t,r){if("string"!=typeof t)throw new Error("string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ".concat(e(t),", equal to:\n").concat(JSON.stringify(t,null,4)));var o,i,c=n(n({},{classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1}),r);function s(e){return c.classicTrim&&!e.trim()||!c.classicTrim&&(c.space&&" "===e||c.cr&&"\r"===e||c.lf&&"\n"===e||c.tab&&"\t"===e||c.nbsp&&" "===e)}if(t.length){if(s(t[0]))for(var f=0,l=t.length;f<l;f++){if(!s(t[f])){o=f;break}if(f===t.length-1)return{res:"",ranges:[[0,t.length]]}}if(s(t[t.length-1]))for(var u=t.length;u--;)if(!s(t[u])){i=u+1;break}return o?i?{res:t.slice(o,i),ranges:[[0,o],[i,t.length]]}:{res:t.slice(o),ranges:[[0,o]]}:i?{res:t.slice(0,i),ranges:[[i,t.length]]}:{res:t,ranges:[]}}return{res:"",ranges:[]}}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-trim-spaces-only",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.17",
|
|
4
4
|
"description": "Like String.trim() but you can choose granularly what to trim",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://gitlab.com/codsen/codsen/",
|
|
@@ -27,18 +27,20 @@
|
|
|
27
27
|
"browser": "dist/string-trim-spaces-only.umd.js",
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "rollup -c",
|
|
30
|
+
"ci_test": "npm run build && npm run lint && tap --no-only --reporter=silent --output-file=testStats.md && npm run format",
|
|
30
31
|
"dev": "rollup -c --dev",
|
|
31
|
-
"devunittest": "npm run dev && ./node_modules/.bin/tap --only",
|
|
32
|
+
"devunittest": "npm run dev && ./node_modules/.bin/tap --only -R 'base'",
|
|
32
33
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
33
34
|
"lect": "lect",
|
|
34
|
-
"lint": "../../node_modules/eslint/bin/eslint.js \"**/*.js\" --fix --config \"../../.eslintrc.json\"",
|
|
35
|
+
"lint": "../../node_modules/eslint/bin/eslint.js \"**/*.js\" --fix --config \"../../.eslintrc.json\" --quiet",
|
|
35
36
|
"perf": "node perf/check",
|
|
36
37
|
"prepare": "npm run build",
|
|
37
|
-
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md}' --write",
|
|
38
|
+
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md}' --write --loglevel silent",
|
|
39
|
+
"republish": "npm publish || :",
|
|
38
40
|
"tap": "tap",
|
|
39
41
|
"pretest": "npm run build",
|
|
40
42
|
"test": "npm run lint && npm run unittest && npm run format",
|
|
41
|
-
"unittest": "./node_modules/.bin/tap --no-only -
|
|
43
|
+
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md && npm run perf",
|
|
42
44
|
"version": "npm run build && git add ."
|
|
43
45
|
},
|
|
44
46
|
"husky": {
|
|
@@ -110,20 +112,26 @@
|
|
|
110
112
|
}
|
|
111
113
|
},
|
|
112
114
|
"tap": {
|
|
113
|
-
"coverage-report":
|
|
115
|
+
"coverage-report": [
|
|
116
|
+
"json-summary",
|
|
117
|
+
"text"
|
|
118
|
+
],
|
|
119
|
+
"nyc-arg": [
|
|
120
|
+
"--exclude=**/*.umd.js"
|
|
121
|
+
],
|
|
114
122
|
"timeout": 0
|
|
115
123
|
},
|
|
116
124
|
"devDependencies": {
|
|
117
|
-
"@babel/core": "^7.9.
|
|
118
|
-
"@babel/preset-env": "^7.9.
|
|
125
|
+
"@babel/core": "^7.9.6",
|
|
126
|
+
"@babel/preset-env": "^7.9.6",
|
|
127
|
+
"@rollup/plugin-babel": "^5.0.0",
|
|
119
128
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
120
129
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
121
130
|
"@rollup/plugin-strip": "^1.3.2",
|
|
122
131
|
"benchmark": "^2.1.4",
|
|
123
|
-
"lect": "^0.
|
|
124
|
-
"rollup": "^2.
|
|
132
|
+
"lect": "^0.13.0",
|
|
133
|
+
"rollup": "^2.8.0",
|
|
125
134
|
"rollup-plugin-ascii": "^0.0.3",
|
|
126
|
-
"rollup-plugin-babel": "^4.4.0",
|
|
127
135
|
"rollup-plugin-banner": "^0.2.1",
|
|
128
136
|
"rollup-plugin-cleanup": "^3.1.1",
|
|
129
137
|
"rollup-plugin-terser": "^5.3.0",
|