string-left-right 2.3.18 → 2.3.22
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 +3 -3
- package/dist/string-left-right.cjs.js +91 -32
- package/dist/string-left-right.dev.umd.js +101 -32
- package/dist/string-left-right.esm.js +53 -43
- package/dist/string-left-right.umd.js +2 -2
- package/package.json +21 -13
package/README.md
CHANGED
|
@@ -84,9 +84,9 @@ This package has three builds in `dist/` folder:
|
|
|
84
84
|
|
|
85
85
|
| Type | Key in `package.json` | Path | Size |
|
|
86
86
|
| ------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------- | ----- |
|
|
87
|
-
| Main export - **CommonJS version**, transpiled to ES5, contains `require` and `module.exports` | `main` | `dist/string-left-right.cjs.js` |
|
|
87
|
+
| Main export - **CommonJS version**, transpiled to ES5, contains `require` and `module.exports` | `main` | `dist/string-left-right.cjs.js` | 14 KB |
|
|
88
88
|
| **ES module** build that Webpack/Rollup understands. Untranspiled ES6 code with `import`/`export`. | `module` | `dist/string-left-right.esm.js` | 11 KB |
|
|
89
|
-
| **UMD build** for browsers, transpiled, minified, containing `iife`'s and has all dependencies baked-in | `browser` | `dist/string-left-right.umd.js` |
|
|
89
|
+
| **UMD build** for browsers, transpiled, minified, containing `iife`'s and has all dependencies baked-in | `browser` | `dist/string-left-right.umd.js` | 17 KB |
|
|
90
90
|
|
|
91
91
|
**[⬆ back to top](#)**
|
|
92
92
|
|
|
@@ -363,7 +363,7 @@ Copyright (c) 2015-2020 Roy Revelt and other contributors
|
|
|
363
363
|
|
|
364
364
|
[gitlab-img]: https://img.shields.io/badge/repo-on%20GitLab-brightgreen.svg?style=flat-square
|
|
365
365
|
[gitlab-url]: https://gitlab.com/codsen/codsen/tree/master/packages/string-left-right
|
|
366
|
-
[cov-img]: https://img.shields.io/badge/coverage-
|
|
366
|
+
[cov-img]: https://img.shields.io/badge/coverage-96.88%25-brightgreen.svg?style=flat-square
|
|
367
367
|
[cov-url]: https://gitlab.com/codsen/codsen/tree/master/packages/string-left-right
|
|
368
368
|
[deps2d-img]: https://img.shields.io/badge/deps%20in%202D-see_here-08f0fd.svg?style=flat-square
|
|
369
369
|
[deps2d-url]: http://npm.anvaka.com/#/view/2d/string-left-right
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-left-right
|
|
3
3
|
* Look what's to the left or the right of a given index within a string
|
|
4
|
-
* Version: 2.3.
|
|
4
|
+
* Version: 2.3.22
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-left-right
|
|
@@ -32,6 +32,55 @@ function _typeof(obj) {
|
|
|
32
32
|
return _typeof(obj);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function _defineProperty(obj, key, value) {
|
|
36
|
+
if (key in obj) {
|
|
37
|
+
Object.defineProperty(obj, key, {
|
|
38
|
+
value: value,
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
obj[key] = value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function ownKeys(object, enumerableOnly) {
|
|
51
|
+
var keys = Object.keys(object);
|
|
52
|
+
|
|
53
|
+
if (Object.getOwnPropertySymbols) {
|
|
54
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
55
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
57
|
+
});
|
|
58
|
+
keys.push.apply(keys, symbols);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return keys;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _objectSpread2(target) {
|
|
65
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
66
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
67
|
+
|
|
68
|
+
if (i % 2) {
|
|
69
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
70
|
+
_defineProperty(target, key, source[key]);
|
|
71
|
+
});
|
|
72
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
73
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
74
|
+
} else {
|
|
75
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
76
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return target;
|
|
82
|
+
}
|
|
83
|
+
|
|
35
84
|
function _toConsumableArray(arr) {
|
|
36
85
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
37
86
|
}
|
|
@@ -49,7 +98,7 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
49
98
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
50
99
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
51
100
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
52
|
-
if (n === "Map" || n === "Set") return Array.from(
|
|
101
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
53
102
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
54
103
|
}
|
|
55
104
|
|
|
@@ -99,13 +148,15 @@ function rightMain(str, idx, stopAtNewlines) {
|
|
|
99
148
|
}
|
|
100
149
|
if (!str[idx + 1]) {
|
|
101
150
|
return null;
|
|
102
|
-
}
|
|
151
|
+
}
|
|
152
|
+
if (str[idx + 1] && (!stopAtNewlines && str[idx + 1].trim() || stopAtNewlines && (str[idx + 1].trim() || "\n\r".includes(str[idx + 1])))) {
|
|
103
153
|
return idx + 1;
|
|
104
|
-
}
|
|
154
|
+
}
|
|
155
|
+
if (str[idx + 2] && (!stopAtNewlines && str[idx + 2].trim() || stopAtNewlines && (str[idx + 2].trim() || "\n\r".includes(str[idx + 2])))) {
|
|
105
156
|
return idx + 2;
|
|
106
157
|
}
|
|
107
158
|
for (var i = idx + 1, len = str.length; i < len; i++) {
|
|
108
|
-
if (str[i] && (!stopAtNewlines && str[i].trim()
|
|
159
|
+
if (str[i] && (!stopAtNewlines && str[i].trim() || stopAtNewlines && (str[i].trim() || "\n\r".includes(str[i])))) {
|
|
109
160
|
return i;
|
|
110
161
|
}
|
|
111
162
|
}
|
|
@@ -126,13 +177,15 @@ function leftMain(str, idx, stopAtNewlines) {
|
|
|
126
177
|
}
|
|
127
178
|
if (idx < 1) {
|
|
128
179
|
return null;
|
|
129
|
-
}
|
|
180
|
+
}
|
|
181
|
+
if (str[idx - 1] && (!stopAtNewlines && str[idx - 1].trim() || stopAtNewlines && (str[idx - 1].trim() || "\n\r".includes(str[idx - 1])))) {
|
|
130
182
|
return idx - 1;
|
|
131
|
-
}
|
|
183
|
+
}
|
|
184
|
+
if (str[idx - 2] && (!stopAtNewlines && str[idx - 2].trim() || stopAtNewlines && (str[idx - 2].trim() || "\n\r".includes(str[idx - 2])))) {
|
|
132
185
|
return idx - 2;
|
|
133
186
|
}
|
|
134
187
|
for (var i = idx; i--;) {
|
|
135
|
-
if (str[i] && (!stopAtNewlines && str[i].trim()
|
|
188
|
+
if (str[i] && (!stopAtNewlines && str[i].trim() || stopAtNewlines && (str[i].trim() || "\n\r".includes(str[i])))) {
|
|
136
189
|
return i;
|
|
137
190
|
}
|
|
138
191
|
}
|
|
@@ -162,7 +215,7 @@ function seq(direction, str, idx, opts, args) {
|
|
|
162
215
|
var i = 0;
|
|
163
216
|
while (i < args.length) {
|
|
164
217
|
if (!isStr(args[i]) || !args[i].length) {
|
|
165
|
-
i
|
|
218
|
+
i += 1;
|
|
166
219
|
continue;
|
|
167
220
|
}
|
|
168
221
|
var _x = x(args[i]),
|
|
@@ -175,7 +228,7 @@ function seq(direction, str, idx, opts, args) {
|
|
|
175
228
|
if (hungry && (opts.i && str[temp].toLowerCase() === value.toLowerCase() || !opts.i && str[temp] === value)) {
|
|
176
229
|
satiated = true;
|
|
177
230
|
} else {
|
|
178
|
-
i
|
|
231
|
+
i += 1;
|
|
179
232
|
}
|
|
180
233
|
if (direction === "right" && whattsOnTheSide > lastFinding + 1) {
|
|
181
234
|
gaps.push([lastFinding + 1, whattsOnTheSide]);
|
|
@@ -195,10 +248,10 @@ function seq(direction, str, idx, opts, args) {
|
|
|
195
248
|
leftmostChar = whattsOnTheSide;
|
|
196
249
|
}
|
|
197
250
|
} else if (optional) {
|
|
198
|
-
i
|
|
251
|
+
i += 1;
|
|
199
252
|
continue;
|
|
200
253
|
} else if (satiated) {
|
|
201
|
-
i
|
|
254
|
+
i += 1;
|
|
202
255
|
satiated = undefined;
|
|
203
256
|
continue;
|
|
204
257
|
} else {
|
|
@@ -226,7 +279,7 @@ function leftSeq(str, idx) {
|
|
|
226
279
|
};
|
|
227
280
|
var opts;
|
|
228
281
|
if (isObj(args[0])) {
|
|
229
|
-
opts =
|
|
282
|
+
opts = _objectSpread2(_objectSpread2({}, defaults), args.shift());
|
|
230
283
|
} else {
|
|
231
284
|
opts = defaults;
|
|
232
285
|
}
|
|
@@ -244,7 +297,7 @@ function rightSeq(str, idx) {
|
|
|
244
297
|
};
|
|
245
298
|
var opts;
|
|
246
299
|
if (isObj(args[0])) {
|
|
247
|
-
opts =
|
|
300
|
+
opts = _objectSpread2(_objectSpread2({}, defaults), args.shift());
|
|
248
301
|
} else {
|
|
249
302
|
opts = defaults;
|
|
250
303
|
}
|
|
@@ -269,20 +322,21 @@ function chomp(direction, str, idx, opts, args) {
|
|
|
269
322
|
}
|
|
270
323
|
} while (lastRes);
|
|
271
324
|
if (lastIdx != null && direction === "right") {
|
|
272
|
-
lastIdx
|
|
325
|
+
lastIdx += 1;
|
|
273
326
|
}
|
|
274
327
|
if (lastIdx === null) {
|
|
275
328
|
return null;
|
|
276
329
|
}
|
|
277
330
|
if (direction === "right") {
|
|
278
|
-
if (str[lastIdx] && str[lastIdx].trim()
|
|
331
|
+
if (str[lastIdx] && str[lastIdx].trim()) {
|
|
279
332
|
return lastIdx;
|
|
280
333
|
}
|
|
281
334
|
var whatsOnTheRight = right(str, lastIdx);
|
|
282
335
|
if (opts.mode === 0) {
|
|
283
336
|
if (whatsOnTheRight === lastIdx + 1) {
|
|
284
337
|
return lastIdx;
|
|
285
|
-
}
|
|
338
|
+
}
|
|
339
|
+
if (str.slice(lastIdx, whatsOnTheRight || str.length).trim() || str.slice(lastIdx, whatsOnTheRight || str.length).includes("\n") || str.slice(lastIdx, whatsOnTheRight || str.length).includes("\r")) {
|
|
286
340
|
for (var y = lastIdx, len = str.length; y < len; y++) {
|
|
287
341
|
if ("\n\r".includes(str[y])) {
|
|
288
342
|
return y;
|
|
@@ -295,39 +349,42 @@ function chomp(direction, str, idx, opts, args) {
|
|
|
295
349
|
return lastIdx;
|
|
296
350
|
} else if (opts.mode === 2) {
|
|
297
351
|
var remainderString = str.slice(lastIdx);
|
|
298
|
-
if (remainderString.trim()
|
|
352
|
+
if (remainderString.trim() || remainderString.includes("\n") || remainderString.includes("\r")) {
|
|
299
353
|
for (var _y = lastIdx, _len3 = str.length; _y < _len3; _y++) {
|
|
300
|
-
if (str[_y].trim()
|
|
354
|
+
if (str[_y].trim() || "\n\r".includes(str[_y])) {
|
|
301
355
|
return _y;
|
|
302
356
|
}
|
|
303
357
|
}
|
|
304
358
|
}
|
|
305
359
|
return str.length;
|
|
306
360
|
}
|
|
307
|
-
return whatsOnTheRight
|
|
361
|
+
return whatsOnTheRight || str.length;
|
|
308
362
|
}
|
|
309
|
-
if (str[lastIdx] && str[lastIdx - 1] && str[lastIdx - 1].trim()
|
|
363
|
+
if (str[lastIdx] && str[lastIdx - 1] && str[lastIdx - 1].trim()) {
|
|
310
364
|
return lastIdx;
|
|
311
365
|
}
|
|
312
366
|
var whatsOnTheLeft = left(str, lastIdx);
|
|
313
367
|
if (opts.mode === 0) {
|
|
314
368
|
if (whatsOnTheLeft === lastIdx - 2) {
|
|
315
369
|
return lastIdx;
|
|
316
|
-
}
|
|
370
|
+
}
|
|
371
|
+
if (str.slice(0, lastIdx).trim() || str.slice(0, lastIdx).includes("\n") || str.slice(0, lastIdx).includes("\r")) {
|
|
317
372
|
for (var _y2 = lastIdx; _y2--;) {
|
|
318
|
-
if ("\n\r".includes(str[_y2]) || str[_y2].trim()
|
|
319
|
-
return _y2 + 1 + (str[_y2].trim()
|
|
373
|
+
if ("\n\r".includes(str[_y2]) || str[_y2].trim()) {
|
|
374
|
+
return _y2 + 1 + (str[_y2].trim() ? 1 : 0);
|
|
320
375
|
}
|
|
321
376
|
}
|
|
322
377
|
}
|
|
323
378
|
return 0;
|
|
324
|
-
}
|
|
379
|
+
}
|
|
380
|
+
if (opts.mode === 1) {
|
|
325
381
|
return lastIdx;
|
|
326
|
-
}
|
|
382
|
+
}
|
|
383
|
+
if (opts.mode === 2) {
|
|
327
384
|
var _remainderString = str.slice(0, lastIdx);
|
|
328
|
-
if (_remainderString.trim()
|
|
385
|
+
if (_remainderString.trim() || _remainderString.includes("\n") || _remainderString.includes("\r")) {
|
|
329
386
|
for (var _y3 = lastIdx; _y3--;) {
|
|
330
|
-
if (str[_y3].trim()
|
|
387
|
+
if (str[_y3].trim() || "\n\r".includes(str[_y3])) {
|
|
331
388
|
return _y3 + 1;
|
|
332
389
|
}
|
|
333
390
|
}
|
|
@@ -347,7 +404,7 @@ function chompLeft(str, idx) {
|
|
|
347
404
|
mode: 0
|
|
348
405
|
};
|
|
349
406
|
if (isObj(args[0])) {
|
|
350
|
-
var opts =
|
|
407
|
+
var opts = _objectSpread2(_objectSpread2({}, defaults), clone(args[0]));
|
|
351
408
|
if (!opts.mode) {
|
|
352
409
|
opts.mode = 0;
|
|
353
410
|
} else if (isStr(opts.mode) && "0123".includes(opts.mode)) {
|
|
@@ -356,7 +413,8 @@ function chompLeft(str, idx) {
|
|
|
356
413
|
throw new Error("string-left-right/chompLeft(): [THROW_ID_01] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(opts.mode, " (type ").concat(_typeof(opts.mode), ")"));
|
|
357
414
|
}
|
|
358
415
|
return chomp("left", str, idx, opts, clone(args).slice(1));
|
|
359
|
-
}
|
|
416
|
+
}
|
|
417
|
+
if (!isStr(args[0])) {
|
|
360
418
|
return chomp("left", str, idx, defaults, clone(args).slice(1));
|
|
361
419
|
}
|
|
362
420
|
return chomp("left", str, idx, defaults, clone(args));
|
|
@@ -372,7 +430,7 @@ function chompRight(str, idx) {
|
|
|
372
430
|
mode: 0
|
|
373
431
|
};
|
|
374
432
|
if (isObj(args[0])) {
|
|
375
|
-
var opts =
|
|
433
|
+
var opts = _objectSpread2(_objectSpread2({}, defaults), clone(args[0]));
|
|
376
434
|
if (!opts.mode) {
|
|
377
435
|
opts.mode = 0;
|
|
378
436
|
} else if (isStr(opts.mode) && "0123".includes(opts.mode)) {
|
|
@@ -381,7 +439,8 @@ function chompRight(str, idx) {
|
|
|
381
439
|
throw new Error("string-left-right/chompRight(): [THROW_ID_02] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(opts.mode, " (type ").concat(_typeof(opts.mode), ")"));
|
|
382
440
|
}
|
|
383
441
|
return chomp("right", str, idx, opts, clone(args).slice(1));
|
|
384
|
-
}
|
|
442
|
+
}
|
|
443
|
+
if (!isStr(args[0])) {
|
|
385
444
|
return chomp("right", str, idx, defaults, clone(args).slice(1));
|
|
386
445
|
}
|
|
387
446
|
return chomp("right", str, idx, defaults, clone(args));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-left-right
|
|
3
3
|
* Look what's to the left or the right of a given index within a string
|
|
4
|
-
* Version: 2.3.
|
|
4
|
+
* Version: 2.3.22
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-left-right
|
|
@@ -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 _toConsumableArray(arr) {
|
|
33
82
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
34
83
|
}
|
|
@@ -46,7 +95,7 @@
|
|
|
46
95
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
47
96
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
48
97
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
49
|
-
if (n === "Map" || n === "Set") return Array.from(
|
|
98
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
50
99
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
51
100
|
}
|
|
52
101
|
|
|
@@ -2137,17 +2186,21 @@
|
|
|
2137
2186
|
|
|
2138
2187
|
if (!str[idx + 1]) {
|
|
2139
2188
|
return null;
|
|
2140
|
-
}
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
if (str[idx + 1] && (!stopAtNewlines && str[idx + 1].trim() || stopAtNewlines && (str[idx + 1].trim() || "\n\r".includes(str[idx + 1])))) {
|
|
2141
2192
|
// best case scenario - next character is non-whitespace:
|
|
2142
2193
|
return idx + 1;
|
|
2143
|
-
}
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
if (str[idx + 2] && (!stopAtNewlines && str[idx + 2].trim() || stopAtNewlines && (str[idx + 2].trim() || "\n\r".includes(str[idx + 2])))) {
|
|
2144
2197
|
// second best case scenario - second next character is non-whitespace:
|
|
2145
2198
|
return idx + 2;
|
|
2146
2199
|
} // worst case scenario - traverse forwards
|
|
2147
2200
|
|
|
2148
2201
|
|
|
2149
2202
|
for (var i = idx + 1, len = str.length; i < len; i++) {
|
|
2150
|
-
if (str[i] && (!stopAtNewlines && str[i].trim()
|
|
2203
|
+
if (str[i] && (!stopAtNewlines && str[i].trim() || stopAtNewlines && (str[i].trim() || "\n\r".includes(str[i])))) {
|
|
2151
2204
|
return i;
|
|
2152
2205
|
}
|
|
2153
2206
|
}
|
|
@@ -2195,17 +2248,21 @@
|
|
|
2195
2248
|
|
|
2196
2249
|
if (idx < 1) {
|
|
2197
2250
|
return null;
|
|
2198
|
-
}
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
if (str[idx - 1] && (!stopAtNewlines && str[idx - 1].trim() || stopAtNewlines && (str[idx - 1].trim() || "\n\r".includes(str[idx - 1])))) {
|
|
2199
2254
|
// best case scenario - next character is non-whitespace:
|
|
2200
2255
|
return idx - 1;
|
|
2201
|
-
}
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
if (str[idx - 2] && (!stopAtNewlines && str[idx - 2].trim() || stopAtNewlines && (str[idx - 2].trim() || "\n\r".includes(str[idx - 2])))) {
|
|
2202
2259
|
// second best case scenario - second next character is non-whitespace:
|
|
2203
2260
|
return idx - 2;
|
|
2204
2261
|
} // worst case scenario - traverse backwards
|
|
2205
2262
|
|
|
2206
2263
|
|
|
2207
2264
|
for (var i = idx; i--;) {
|
|
2208
|
-
if (str[i] && (!stopAtNewlines && str[i].trim()
|
|
2265
|
+
if (str[i] && (!stopAtNewlines && str[i].trim() || stopAtNewlines && (str[i].trim() || "\n\r".includes(str[i])))) {
|
|
2209
2266
|
return i;
|
|
2210
2267
|
}
|
|
2211
2268
|
}
|
|
@@ -2282,7 +2339,7 @@
|
|
|
2282
2339
|
|
|
2283
2340
|
while (i < args.length) {
|
|
2284
2341
|
if (!isStr(args[i]) || !args[i].length) {
|
|
2285
|
-
i
|
|
2342
|
+
i += 1;
|
|
2286
2343
|
continue;
|
|
2287
2344
|
}
|
|
2288
2345
|
|
|
@@ -2305,7 +2362,7 @@
|
|
|
2305
2362
|
satiated = true;
|
|
2306
2363
|
} else {
|
|
2307
2364
|
// move on
|
|
2308
|
-
i
|
|
2365
|
+
i += 1;
|
|
2309
2366
|
} // 1. first, tackle gaps
|
|
2310
2367
|
// if there was a gap, push it to gaps array:
|
|
2311
2368
|
|
|
@@ -2333,10 +2390,10 @@
|
|
|
2333
2390
|
leftmostChar = whattsOnTheSide;
|
|
2334
2391
|
}
|
|
2335
2392
|
} else if (optional) {
|
|
2336
|
-
i
|
|
2393
|
+
i += 1;
|
|
2337
2394
|
continue;
|
|
2338
2395
|
} else if (satiated) {
|
|
2339
|
-
i
|
|
2396
|
+
i += 1;
|
|
2340
2397
|
satiated = undefined;
|
|
2341
2398
|
continue;
|
|
2342
2399
|
} else {
|
|
@@ -2396,7 +2453,7 @@
|
|
|
2396
2453
|
var opts;
|
|
2397
2454
|
|
|
2398
2455
|
if (lodash_isplainobject(args[0])) {
|
|
2399
|
-
opts =
|
|
2456
|
+
opts = _objectSpread2(_objectSpread2({}, defaults), args.shift());
|
|
2400
2457
|
} else {
|
|
2401
2458
|
opts = defaults;
|
|
2402
2459
|
}
|
|
@@ -2420,7 +2477,7 @@
|
|
|
2420
2477
|
var opts;
|
|
2421
2478
|
|
|
2422
2479
|
if (lodash_isplainobject(args[0])) {
|
|
2423
|
-
opts =
|
|
2480
|
+
opts = _objectSpread2(_objectSpread2({}, defaults), args.shift());
|
|
2424
2481
|
} else {
|
|
2425
2482
|
opts = defaults;
|
|
2426
2483
|
}
|
|
@@ -2496,7 +2553,7 @@
|
|
|
2496
2553
|
} while (lastRes);
|
|
2497
2554
|
|
|
2498
2555
|
if (lastIdx != null && direction === "right") {
|
|
2499
|
-
lastIdx
|
|
2556
|
+
lastIdx += 1;
|
|
2500
2557
|
}
|
|
2501
2558
|
|
|
2502
2559
|
if (lastIdx === null) {
|
|
@@ -2515,7 +2572,7 @@
|
|
|
2515
2572
|
//
|
|
2516
2573
|
//
|
|
2517
2574
|
// quick ending - no whitespace on the right at all:
|
|
2518
|
-
if (str[lastIdx] && str[lastIdx].trim()
|
|
2575
|
+
if (str[lastIdx] && str[lastIdx].trim()) {
|
|
2519
2576
|
// if the character follows tightly right after,
|
|
2520
2577
|
return lastIdx;
|
|
2521
2578
|
} // Default, 0 is leave single space if possible or chomp up to nearest line
|
|
@@ -2529,7 +2586,9 @@
|
|
|
2529
2586
|
// if there's one whitespace character, Bob's your uncle here's
|
|
2530
2587
|
// the final result
|
|
2531
2588
|
return lastIdx;
|
|
2532
|
-
}
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
if (str.slice(lastIdx, whatsOnTheRight || str.length).trim() || str.slice(lastIdx, whatsOnTheRight || str.length).includes("\n") || str.slice(lastIdx, whatsOnTheRight || str.length).includes("\r")) {
|
|
2533
2592
|
// if there are line break characters between current "lastIdx" we're on
|
|
2534
2593
|
// and the first non-whitespace character on the right
|
|
2535
2594
|
for (var y = lastIdx, len = str.length; y < len; y++) {
|
|
@@ -2547,10 +2606,10 @@
|
|
|
2547
2606
|
// mode 2 hungrily chomps all whitespace except newlines
|
|
2548
2607
|
var remainderString = str.slice(lastIdx);
|
|
2549
2608
|
|
|
2550
|
-
if (remainderString.trim()
|
|
2609
|
+
if (remainderString.trim() || remainderString.includes("\n") || remainderString.includes("\r")) {
|
|
2551
2610
|
// if there are line breaks, we need to loop to chomp up to them but not further
|
|
2552
2611
|
for (var _y = lastIdx, _len3 = str.length; _y < _len3; _y++) {
|
|
2553
|
-
if (str[_y].trim()
|
|
2612
|
+
if (str[_y].trim() || "\n\r".includes(str[_y])) {
|
|
2554
2613
|
return _y;
|
|
2555
2614
|
}
|
|
2556
2615
|
}
|
|
@@ -2562,7 +2621,7 @@
|
|
|
2562
2621
|
// mode 3 is an aggro chomp - will chump all whitespace
|
|
2563
2622
|
|
|
2564
2623
|
|
|
2565
|
-
return whatsOnTheRight
|
|
2624
|
+
return whatsOnTheRight || str.length; //
|
|
2566
2625
|
//
|
|
2567
2626
|
//
|
|
2568
2627
|
// R I G H T E N D S
|
|
@@ -2579,7 +2638,7 @@
|
|
|
2579
2638
|
// quick ending - no whitespace on the left at all:
|
|
2580
2639
|
|
|
2581
2640
|
|
|
2582
|
-
if (str[lastIdx] && str[lastIdx - 1] && str[lastIdx - 1].trim()
|
|
2641
|
+
if (str[lastIdx] && str[lastIdx - 1] && str[lastIdx - 1].trim()) {
|
|
2583
2642
|
// if the non-whitespace character is on the left
|
|
2584
2643
|
return lastIdx;
|
|
2585
2644
|
} // Default, 0 is leave single space if possible or chomp up to nearest line
|
|
@@ -2593,29 +2652,35 @@
|
|
|
2593
2652
|
// if there's one whitespace character between here and next real character, Bob's your uncle here's
|
|
2594
2653
|
// the final result
|
|
2595
2654
|
return lastIdx;
|
|
2596
|
-
}
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
if (str.slice(0, lastIdx).trim() || str.slice(0, lastIdx).includes("\n") || str.slice(0, lastIdx).includes("\r")) {
|
|
2597
2658
|
// if there are line break characters between current "lastIdx" we're on
|
|
2598
2659
|
// and the first non-whitespace character on the right
|
|
2599
2660
|
for (var _y2 = lastIdx; _y2--;) {
|
|
2600
|
-
if ("\n\r".includes(str[_y2]) || str[_y2].trim()
|
|
2601
|
-
return _y2 + 1 + (str[_y2].trim()
|
|
2661
|
+
if ("\n\r".includes(str[_y2]) || str[_y2].trim()) {
|
|
2662
|
+
return _y2 + 1 + (str[_y2].trim() ? 1 : 0);
|
|
2602
2663
|
}
|
|
2603
2664
|
}
|
|
2604
2665
|
} // ELSE
|
|
2605
2666
|
|
|
2606
2667
|
|
|
2607
2668
|
return 0;
|
|
2608
|
-
}
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
if (opts.mode === 1) {
|
|
2609
2672
|
// mode 1 doesn't touch the whitespace, so it's quick:
|
|
2610
2673
|
return lastIdx;
|
|
2611
|
-
}
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
if (opts.mode === 2) {
|
|
2612
2677
|
// mode 2 hungrily chomps all whitespace except newlines
|
|
2613
2678
|
var _remainderString = str.slice(0, lastIdx);
|
|
2614
2679
|
|
|
2615
|
-
if (_remainderString.trim()
|
|
2680
|
+
if (_remainderString.trim() || _remainderString.includes("\n") || _remainderString.includes("\r")) {
|
|
2616
2681
|
// if there are line breaks, we need to loop to chomp up to them but not further
|
|
2617
2682
|
for (var _y3 = lastIdx; _y3--;) {
|
|
2618
|
-
if (str[_y3].trim()
|
|
2683
|
+
if (str[_y3].trim() || "\n\r".includes(str[_y3])) {
|
|
2619
2684
|
return _y3 + 1;
|
|
2620
2685
|
}
|
|
2621
2686
|
}
|
|
@@ -2685,7 +2750,7 @@
|
|
|
2685
2750
|
// It's a plain object so it's easy to distinguish
|
|
2686
2751
|
|
|
2687
2752
|
if (lodash_isplainobject(args[0])) {
|
|
2688
|
-
var opts =
|
|
2753
|
+
var opts = _objectSpread2(_objectSpread2({}, defaults), lodash_clonedeep(args[0]));
|
|
2689
2754
|
|
|
2690
2755
|
if (!opts.mode) {
|
|
2691
2756
|
opts.mode = 0;
|
|
@@ -2696,7 +2761,9 @@
|
|
|
2696
2761
|
}
|
|
2697
2762
|
|
|
2698
2763
|
return chomp("left", str, idx, opts, lodash_clonedeep(args).slice(1));
|
|
2699
|
-
}
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
if (!isStr(args[0])) {
|
|
2700
2767
|
return chomp("left", str, idx, defaults, lodash_clonedeep(args).slice(1));
|
|
2701
2768
|
} // ELSE
|
|
2702
2769
|
// all arguments are values to match, first element is not options object
|
|
@@ -2754,7 +2821,7 @@
|
|
|
2754
2821
|
// It's a plain object so it's easy to distinguish
|
|
2755
2822
|
|
|
2756
2823
|
if (lodash_isplainobject(args[0])) {
|
|
2757
|
-
var opts =
|
|
2824
|
+
var opts = _objectSpread2(_objectSpread2({}, defaults), lodash_clonedeep(args[0]));
|
|
2758
2825
|
|
|
2759
2826
|
if (!opts.mode) {
|
|
2760
2827
|
opts.mode = 0;
|
|
@@ -2765,7 +2832,9 @@
|
|
|
2765
2832
|
}
|
|
2766
2833
|
|
|
2767
2834
|
return chomp("right", str, idx, opts, lodash_clonedeep(args).slice(1));
|
|
2768
|
-
}
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
if (!isStr(args[0])) {
|
|
2769
2838
|
return chomp("right", str, idx, defaults, lodash_clonedeep(args).slice(1));
|
|
2770
2839
|
} // ELSE
|
|
2771
2840
|
// all arguments are values to match, first element is not options object
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-left-right
|
|
3
3
|
* Look what's to the left or the right of a given index within a string
|
|
4
|
-
* Version: 2.3.
|
|
4
|
+
* Version: 2.3.22
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-left-right
|
|
@@ -47,26 +47,28 @@ function rightMain(str, idx, stopAtNewlines) {
|
|
|
47
47
|
}
|
|
48
48
|
if (!str[idx + 1]) {
|
|
49
49
|
return null;
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
|
+
if (
|
|
51
52
|
str[idx + 1] &&
|
|
52
|
-
((!stopAtNewlines && str[idx + 1].trim()
|
|
53
|
+
((!stopAtNewlines && str[idx + 1].trim()) ||
|
|
53
54
|
(stopAtNewlines &&
|
|
54
|
-
(str[idx + 1].trim()
|
|
55
|
+
(str[idx + 1].trim() || "\n\r".includes(str[idx + 1]))))
|
|
55
56
|
) {
|
|
56
57
|
return idx + 1;
|
|
57
|
-
}
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
58
60
|
str[idx + 2] &&
|
|
59
|
-
((!stopAtNewlines && str[idx + 2].trim()
|
|
61
|
+
((!stopAtNewlines && str[idx + 2].trim()) ||
|
|
60
62
|
(stopAtNewlines &&
|
|
61
|
-
(str[idx + 2].trim()
|
|
63
|
+
(str[idx + 2].trim() || "\n\r".includes(str[idx + 2]))))
|
|
62
64
|
) {
|
|
63
65
|
return idx + 2;
|
|
64
66
|
}
|
|
65
67
|
for (let i = idx + 1, len = str.length; i < len; i++) {
|
|
66
68
|
if (
|
|
67
69
|
str[i] &&
|
|
68
|
-
((!stopAtNewlines && str[i].trim()
|
|
69
|
-
(stopAtNewlines && (str[i].trim()
|
|
70
|
+
((!stopAtNewlines && str[i].trim()) ||
|
|
71
|
+
(stopAtNewlines && (str[i].trim() || "\n\r".includes(str[i]))))
|
|
70
72
|
) {
|
|
71
73
|
return i;
|
|
72
74
|
}
|
|
@@ -88,26 +90,28 @@ function leftMain(str, idx, stopAtNewlines) {
|
|
|
88
90
|
}
|
|
89
91
|
if (idx < 1) {
|
|
90
92
|
return null;
|
|
91
|
-
}
|
|
93
|
+
}
|
|
94
|
+
if (
|
|
92
95
|
str[idx - 1] &&
|
|
93
|
-
((!stopAtNewlines && str[idx - 1].trim()
|
|
96
|
+
((!stopAtNewlines && str[idx - 1].trim()) ||
|
|
94
97
|
(stopAtNewlines &&
|
|
95
|
-
(str[idx - 1].trim()
|
|
98
|
+
(str[idx - 1].trim() || "\n\r".includes(str[idx - 1]))))
|
|
96
99
|
) {
|
|
97
100
|
return idx - 1;
|
|
98
|
-
}
|
|
101
|
+
}
|
|
102
|
+
if (
|
|
99
103
|
str[idx - 2] &&
|
|
100
|
-
((!stopAtNewlines && str[idx - 2].trim()
|
|
104
|
+
((!stopAtNewlines && str[idx - 2].trim()) ||
|
|
101
105
|
(stopAtNewlines &&
|
|
102
|
-
(str[idx - 2].trim()
|
|
106
|
+
(str[idx - 2].trim() || "\n\r".includes(str[idx - 2]))))
|
|
103
107
|
) {
|
|
104
108
|
return idx - 2;
|
|
105
109
|
}
|
|
106
110
|
for (let i = idx; i--; ) {
|
|
107
111
|
if (
|
|
108
112
|
str[i] &&
|
|
109
|
-
((!stopAtNewlines && str[i].trim()
|
|
110
|
-
(stopAtNewlines && (str[i].trim()
|
|
113
|
+
((!stopAtNewlines && str[i].trim()) ||
|
|
114
|
+
(stopAtNewlines && (str[i].trim() || "\n\r".includes(str[i]))))
|
|
111
115
|
) {
|
|
112
116
|
return i;
|
|
113
117
|
}
|
|
@@ -141,7 +145,7 @@ function seq(direction, str, idx, opts, args) {
|
|
|
141
145
|
let i = 0;
|
|
142
146
|
while (i < args.length) {
|
|
143
147
|
if (!isStr(args[i]) || !args[i].length) {
|
|
144
|
-
i
|
|
148
|
+
i += 1;
|
|
145
149
|
continue;
|
|
146
150
|
}
|
|
147
151
|
const { value, optional, hungry } = x(args[i]);
|
|
@@ -162,7 +166,7 @@ function seq(direction, str, idx, opts, args) {
|
|
|
162
166
|
) {
|
|
163
167
|
satiated = true;
|
|
164
168
|
} else {
|
|
165
|
-
i
|
|
169
|
+
i += 1;
|
|
166
170
|
}
|
|
167
171
|
if (direction === "right" && whattsOnTheSide > lastFinding + 1) {
|
|
168
172
|
gaps.push([lastFinding + 1, whattsOnTheSide]);
|
|
@@ -182,10 +186,10 @@ function seq(direction, str, idx, opts, args) {
|
|
|
182
186
|
leftmostChar = whattsOnTheSide;
|
|
183
187
|
}
|
|
184
188
|
} else if (optional) {
|
|
185
|
-
i
|
|
189
|
+
i += 1;
|
|
186
190
|
continue;
|
|
187
191
|
} else if (satiated) {
|
|
188
|
-
i
|
|
192
|
+
i += 1;
|
|
189
193
|
satiated = undefined;
|
|
190
194
|
continue;
|
|
191
195
|
} else {
|
|
@@ -206,7 +210,7 @@ function leftSeq(str, idx, ...args) {
|
|
|
206
210
|
};
|
|
207
211
|
let opts;
|
|
208
212
|
if (isObj(args[0])) {
|
|
209
|
-
opts =
|
|
213
|
+
opts = { ...defaults, ...args.shift() };
|
|
210
214
|
} else {
|
|
211
215
|
opts = defaults;
|
|
212
216
|
}
|
|
@@ -221,7 +225,7 @@ function rightSeq(str, idx, ...args) {
|
|
|
221
225
|
};
|
|
222
226
|
let opts;
|
|
223
227
|
if (isObj(args[0])) {
|
|
224
|
-
opts =
|
|
228
|
+
opts = { ...defaults, ...args.shift() };
|
|
225
229
|
} else {
|
|
226
230
|
opts = defaults;
|
|
227
231
|
}
|
|
@@ -253,21 +257,22 @@ function chomp(direction, str, idx, opts, args) {
|
|
|
253
257
|
}
|
|
254
258
|
} while (lastRes);
|
|
255
259
|
if (lastIdx != null && direction === "right") {
|
|
256
|
-
lastIdx
|
|
260
|
+
lastIdx += 1;
|
|
257
261
|
}
|
|
258
262
|
if (lastIdx === null) {
|
|
259
263
|
return null;
|
|
260
264
|
}
|
|
261
265
|
if (direction === "right") {
|
|
262
|
-
if (str[lastIdx] && str[lastIdx].trim()
|
|
266
|
+
if (str[lastIdx] && str[lastIdx].trim()) {
|
|
263
267
|
return lastIdx;
|
|
264
268
|
}
|
|
265
269
|
const whatsOnTheRight = right(str, lastIdx);
|
|
266
270
|
if (opts.mode === 0) {
|
|
267
271
|
if (whatsOnTheRight === lastIdx + 1) {
|
|
268
272
|
return lastIdx;
|
|
269
|
-
}
|
|
270
|
-
|
|
273
|
+
}
|
|
274
|
+
if (
|
|
275
|
+
str.slice(lastIdx, whatsOnTheRight || str.length).trim() ||
|
|
271
276
|
str.slice(lastIdx, whatsOnTheRight || str.length).includes("\n") ||
|
|
272
277
|
str.slice(lastIdx, whatsOnTheRight || str.length).includes("\r")
|
|
273
278
|
) {
|
|
@@ -284,50 +289,53 @@ function chomp(direction, str, idx, opts, args) {
|
|
|
284
289
|
} else if (opts.mode === 2) {
|
|
285
290
|
const remainderString = str.slice(lastIdx);
|
|
286
291
|
if (
|
|
287
|
-
remainderString.trim()
|
|
292
|
+
remainderString.trim() ||
|
|
288
293
|
remainderString.includes("\n") ||
|
|
289
294
|
remainderString.includes("\r")
|
|
290
295
|
) {
|
|
291
296
|
for (let y = lastIdx, len = str.length; y < len; y++) {
|
|
292
|
-
if (str[y].trim()
|
|
297
|
+
if (str[y].trim() || `\n\r`.includes(str[y])) {
|
|
293
298
|
return y;
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
302
|
return str.length;
|
|
298
303
|
}
|
|
299
|
-
return whatsOnTheRight
|
|
304
|
+
return whatsOnTheRight || str.length;
|
|
300
305
|
}
|
|
301
|
-
if (str[lastIdx] && str[lastIdx - 1] && str[lastIdx - 1].trim()
|
|
306
|
+
if (str[lastIdx] && str[lastIdx - 1] && str[lastIdx - 1].trim()) {
|
|
302
307
|
return lastIdx;
|
|
303
308
|
}
|
|
304
309
|
const whatsOnTheLeft = left(str, lastIdx);
|
|
305
310
|
if (opts.mode === 0) {
|
|
306
311
|
if (whatsOnTheLeft === lastIdx - 2) {
|
|
307
312
|
return lastIdx;
|
|
308
|
-
}
|
|
309
|
-
|
|
313
|
+
}
|
|
314
|
+
if (
|
|
315
|
+
str.slice(0, lastIdx).trim() ||
|
|
310
316
|
str.slice(0, lastIdx).includes("\n") ||
|
|
311
317
|
str.slice(0, lastIdx).includes("\r")
|
|
312
318
|
) {
|
|
313
319
|
for (let y = lastIdx; y--; ) {
|
|
314
|
-
if (`\n\r`.includes(str[y]) || str[y].trim()
|
|
315
|
-
return y + 1 + (str[y].trim()
|
|
320
|
+
if (`\n\r`.includes(str[y]) || str[y].trim()) {
|
|
321
|
+
return y + 1 + (str[y].trim() ? 1 : 0);
|
|
316
322
|
}
|
|
317
323
|
}
|
|
318
324
|
}
|
|
319
325
|
return 0;
|
|
320
|
-
}
|
|
326
|
+
}
|
|
327
|
+
if (opts.mode === 1) {
|
|
321
328
|
return lastIdx;
|
|
322
|
-
}
|
|
329
|
+
}
|
|
330
|
+
if (opts.mode === 2) {
|
|
323
331
|
const remainderString = str.slice(0, lastIdx);
|
|
324
332
|
if (
|
|
325
|
-
remainderString.trim()
|
|
333
|
+
remainderString.trim() ||
|
|
326
334
|
remainderString.includes("\n") ||
|
|
327
335
|
remainderString.includes("\r")
|
|
328
336
|
) {
|
|
329
337
|
for (let y = lastIdx; y--; ) {
|
|
330
|
-
if (str[y].trim()
|
|
338
|
+
if (str[y].trim() || `\n\r`.includes(str[y])) {
|
|
331
339
|
return y + 1;
|
|
332
340
|
}
|
|
333
341
|
}
|
|
@@ -344,7 +352,7 @@ function chompLeft(str, idx, ...args) {
|
|
|
344
352
|
mode: 0,
|
|
345
353
|
};
|
|
346
354
|
if (isObj(args[0])) {
|
|
347
|
-
const opts =
|
|
355
|
+
const opts = { ...defaults, ...clone(args[0]) };
|
|
348
356
|
if (!opts.mode) {
|
|
349
357
|
opts.mode = 0;
|
|
350
358
|
} else if (isStr(opts.mode) && `0123`.includes(opts.mode)) {
|
|
@@ -357,7 +365,8 @@ function chompLeft(str, idx, ...args) {
|
|
|
357
365
|
);
|
|
358
366
|
}
|
|
359
367
|
return chomp("left", str, idx, opts, clone(args).slice(1));
|
|
360
|
-
}
|
|
368
|
+
}
|
|
369
|
+
if (!isStr(args[0])) {
|
|
361
370
|
return chomp("left", str, idx, defaults, clone(args).slice(1));
|
|
362
371
|
}
|
|
363
372
|
return chomp("left", str, idx, defaults, clone(args));
|
|
@@ -370,7 +379,7 @@ function chompRight(str, idx, ...args) {
|
|
|
370
379
|
mode: 0,
|
|
371
380
|
};
|
|
372
381
|
if (isObj(args[0])) {
|
|
373
|
-
const opts =
|
|
382
|
+
const opts = { ...defaults, ...clone(args[0]) };
|
|
374
383
|
if (!opts.mode) {
|
|
375
384
|
opts.mode = 0;
|
|
376
385
|
} else if (isStr(opts.mode) && `0123`.includes(opts.mode)) {
|
|
@@ -383,7 +392,8 @@ function chompRight(str, idx, ...args) {
|
|
|
383
392
|
);
|
|
384
393
|
}
|
|
385
394
|
return chomp("right", str, idx, opts, clone(args).slice(1));
|
|
386
|
-
}
|
|
395
|
+
}
|
|
396
|
+
if (!isStr(args[0])) {
|
|
387
397
|
return chomp("right", str, idx, defaults, clone(args).slice(1));
|
|
388
398
|
}
|
|
389
399
|
return chomp("right", str, idx, defaults, clone(args));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* string-left-right
|
|
3
3
|
* Look what's to the left or the right of a given index within a string
|
|
4
|
-
* Version: 2.3.
|
|
4
|
+
* Version: 2.3.22
|
|
5
5
|
* Author: Roy Revelt, Codsen Ltd
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Homepage: https://gitlab.com/codsen/codsen/tree/master/packages/string-left-right
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).stringLeftRight={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var o,i,u=Function.prototype,c=Object.prototype,a=u.toString,l=c.hasOwnProperty,f=a.call(Object),s=c.toString,h=(o=Object.getPrototypeOf,i=Object,function(t){return o(i(t))});var p=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=s.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=h(t);if(null===e)return!0;var r=l.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&a.call(r)==f},g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var y=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){var r="[object Arguments]",n="[object Function]",o="[object GeneratorFunction]",i="[object Map]",u="[object Set]",c=/\w*$/,a=/^\[object .+?Constructor\]$/,l=/^(?:0|[1-9]\d*)$/,f={};f[r]=f["[object Array]"]=f["[object ArrayBuffer]"]=f["[object DataView]"]=f["[object Boolean]"]=f["[object Date]"]=f["[object Float32Array]"]=f["[object Float64Array]"]=f["[object Int8Array]"]=f["[object Int16Array]"]=f["[object Int32Array]"]=f[i]=f["[object Number]"]=f["[object Object]"]=f["[object RegExp]"]=f[u]=f["[object String]"]=f["[object Symbol]"]=f["[object Uint8Array]"]=f["[object Uint8ClampedArray]"]=f["[object Uint16Array]"]=f["[object Uint32Array]"]=!0,f["[object Error]"]=f[n]=f["[object WeakMap]"]=!1;var s="object"==typeof g&&g&&g.Object===Object&&g,h="object"==typeof self&&self&&self.Object===Object&&self,p=s||h||Function("return this")(),y=e&&!e.nodeType&&e,d=y&&t&&!t.nodeType&&t,v=d&&d.exports===y;function b(t,e){return t.set(e[0],e[1]),t}function _(t,e){return t.add(e),t}function m(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function j(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function w(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function A(t,e){return function(r){return t(e(r))}}function O(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var S,I=Array.prototype,x=Function.prototype,C=Object.prototype,E=p["__core-js_shared__"],L=(S=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+S:"",P=x.toString,U=C.hasOwnProperty,W=C.toString,D=RegExp("^"+P.call(U).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),F=v?p.Buffer:void 0,R=p.Symbol,$=p.Uint8Array,M=A(Object.getPrototypeOf,Object),T=Object.create,k=C.propertyIsEnumerable,B=I.splice,N=Object.getOwnPropertySymbols,V=F?F.isBuffer:void 0,q=A(Object.keys,Object),z=dt(p,"DataView"),H=dt(p,"Map"),G=dt(p,"Promise"),J=dt(p,"Set"),K=dt(p,"WeakMap"),Q=dt(Object,"create"),X=jt(z),Y=jt(H),Z=jt(G),tt=jt(J),et=jt(K),rt=R?R.prototype:void 0,nt=rt?rt.valueOf:void 0;function ot(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function it(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ut(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ct(t){this.__data__=new it(t)}function at(t,e){var n=At(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ot(t)}(t)&&U.call(t,"callee")&&(!k.call(t,"callee")||W.call(t)==r)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],o=n.length,i=!!o;for(var u in t)!e&&!U.call(t,u)||i&&("length"==u||_t(u,o))||n.push(u);return n}function lt(t,e,r){var n=t[e];U.call(t,e)&&wt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function ft(t,e){for(var r=t.length;r--;)if(wt(t[r][0],e))return r;return-1}function st(t,e,a,l,s,h,p){var g;if(l&&(g=h?l(t,s,h,p):l(t)),void 0!==g)return g;if(!xt(t))return t;var y=At(t);if(y){if(g=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&U.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,g)}else{var d=bt(t),v=d==n||d==o;if(St(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if("[object Object]"==d||d==r||v&&!h){if(j(t))return h?t:{};if(g=function(t){return"function"!=typeof t.constructor||mt(t)?{}:(e=M(t),xt(e)?T(e):{});var e}(v?{}:t),!e)return function(t,e){return gt(t,vt(t),e)}(t,function(t,e){return t&>(e,Ct(e),t)}(g,t))}else{if(!f[d])return h?t:{};g=function(t,e,r,n){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return pt(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t,e){var r=e?pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case i:return function(t,e,r){return m(e?r(w(t),!0):w(t),b,new t.constructor)}(t,n,r);case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,c.exec(t));return e.lastIndex=t.lastIndex,e}(t);case u:return function(t,e,r){return m(e?r(O(t),!0):O(t),_,new t.constructor)}(t,n,r);case"[object Symbol]":return a=t,nt?Object(nt.call(a)):{}}var a}(t,d,st,e)}}p||(p=new ct);var A=p.get(t);if(A)return A;if(p.set(t,g),!y)var S=a?function(t){return function(t,e,r){var n=e(t);return At(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,Ct,vt)}(t):Ct(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(S||t,(function(r,n){S&&(r=t[n=r]),lt(g,n,st(r,e,a,l,n,t,p))})),g}function ht(t){return!(!xt(t)||function(t){return!!L&&L in t}(t))&&(It(t)||j(t)?D:a).test(jt(t))}function pt(t){var e=new t.constructor(t.byteLength);return new $(e).set(new $(t)),e}function gt(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var u=e[o],c=n?n(r[u],t[u],u,r,t):void 0;lt(r,u,void 0===c?t[u]:c)}return r}function yt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function dt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ht(r)?r:void 0}ot.prototype.clear=function(){this.__data__=Q?Q(null):{}},ot.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},ot.prototype.get=function(t){var e=this.__data__;if(Q){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return U.call(e,t)?e[t]:void 0},ot.prototype.has=function(t){var e=this.__data__;return Q?void 0!==e[t]:U.call(e,t)},ot.prototype.set=function(t,e){return this.__data__[t]=Q&&void 0===e?"__lodash_hash_undefined__":e,this},it.prototype.clear=function(){this.__data__=[]},it.prototype.delete=function(t){var e=this.__data__,r=ft(e,t);return!(r<0)&&(r==e.length-1?e.pop():B.call(e,r,1),!0)},it.prototype.get=function(t){var e=this.__data__,r=ft(e,t);return r<0?void 0:e[r][1]},it.prototype.has=function(t){return ft(this.__data__,t)>-1},it.prototype.set=function(t,e){var r=this.__data__,n=ft(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},ut.prototype.clear=function(){this.__data__={hash:new ot,map:new(H||it),string:new ot}},ut.prototype.delete=function(t){return yt(this,t).delete(t)},ut.prototype.get=function(t){return yt(this,t).get(t)},ut.prototype.has=function(t){return yt(this,t).has(t)},ut.prototype.set=function(t,e){return yt(this,t).set(t,e),this},ct.prototype.clear=function(){this.__data__=new it},ct.prototype.delete=function(t){return this.__data__.delete(t)},ct.prototype.get=function(t){return this.__data__.get(t)},ct.prototype.has=function(t){return this.__data__.has(t)},ct.prototype.set=function(t,e){var r=this.__data__;if(r instanceof it){var n=r.__data__;if(!H||n.length<199)return n.push([t,e]),this;r=this.__data__=new ut(n)}return r.set(t,e),this};var vt=N?A(N,Object):function(){return[]},bt=function(t){return W.call(t)};function _t(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||l.test(t))&&t>-1&&t%1==0&&t<e}function mt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||C)}function jt(t){if(null!=t){try{return P.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function wt(t,e){return t===e||t!=t&&e!=e}(z&&"[object DataView]"!=bt(new z(new ArrayBuffer(1)))||H&&bt(new H)!=i||G&&"[object Promise]"!=bt(G.resolve())||J&&bt(new J)!=u||K&&"[object WeakMap]"!=bt(new K))&&(bt=function(t){var e=W.call(t),r="[object Object]"==e?t.constructor:void 0,n=r?jt(r):void 0;if(n)switch(n){case X:return"[object DataView]";case Y:return i;case Z:return"[object Promise]";case tt:return u;case et:return"[object WeakMap]"}return e});var At=Array.isArray;function Ot(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}(t.length)&&!It(t)}var St=V||function(){return!1};function It(t){var e=xt(t)?W.call(t):"";return e==n||e==o}function xt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ct(t){return Ot(t)?at(t):function(t){if(!mt(t))return q(t);var e=[];for(var r in Object(t))U.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return st(t,!0,!0)}}));function d(t){return"number"==typeof t}function v(t){return"string"==typeof t}function b(t,e,r){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),!t[e+1])return null;if(t[e+1]&&(!r&&t[e+1].trim().length||r&&(t[e+1].trim().length||"\n\r".includes(t[e+1]))))return e+1;if(t[e+2]&&(!r&&t[e+2].trim().length||r&&(t[e+2].trim().length||"\n\r".includes(t[e+2]))))return e+2;for(var n=e+1,o=t.length;n<o;n++)if(t[n]&&(!r&&t[n].trim().length||r&&(t[n].trim().length||"\n\r".includes(t[n]))))return n;return null}function _(t,e){return b(t,e,!1)}function m(t,e,r){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),e<1)return null;if(t[e-1]&&(!r&&t[e-1].trim().length||r&&(t[e-1].trim().length||"\n\r".includes(t[e-1]))))return e-1;if(t[e-2]&&(!r&&t[e-2].trim().length||r&&(t[e-2].trim().length||"\n\r".includes(t[e-2]))))return e-2;for(var n=e;n--;)if(t[n]&&(!r&&t[n].trim().length||r&&(t[n].trim().length||"\n\r".includes(t[n]))))return n;return null}function j(t,e){return m(t,e,!1)}function w(t,e,r,n,o){if("string"!=typeof e||!e.length)return null;if(r&&"number"==typeof r||(r=0),"right"===t&&!e[r+1]||"left"===t&&!e[r-1])return null;for(var i,u,c,a,l,f=r,s=[],h=0;h<o.length;)if(v(o[h])&&o[h].length){var p=(a=o[h],l=void 0,((l={value:a,hungry:!1,optional:!1}).value.endsWith("?*")||l.value.endsWith("*?"))&&l.value.length>2?(l.value=l.value.slice(0,l.value.length-2),l.optional=!0,l.hungry=!0):l.value.endsWith("?")&&l.value.length>1?(l.value=l.value.slice(0,l.value.length-1),l.optional=!0):l.value.endsWith("*")&&l.value.length>1&&(l.value=l.value.slice(0,l.value.length-1),l.hungry=!0),l),g=p.value,y=p.optional,d=p.hungry,b="right"===t?_(e,f):j(e,f);if(!(n.i&&e[b].toLowerCase()===g.toLowerCase()||!n.i&&e[b]===g)){if(y){h++;continue}if(c){h++,c=void 0;continue}return null}var m="right"===t?_(e,b):j(e,b);d&&(n.i&&e[m].toLowerCase()===g.toLowerCase()||!n.i&&e[m]===g)?c=!0:h++,"right"===t&&b>f+1?s.push([f+1,b]):"left"===t&&b<f-1&&s.unshift([b+1,f]),f=b,"right"===t?(void 0===i&&(i=b),u=b):(void 0===u&&(u=b),i=b)}else h++;return void 0===i?null:{gaps:s,leftmostChar:i,rightmostChar:u}}function A(t,e){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];if(!n.length)return j(t,e);var i={i:!1};return w("left",t,e,p(n[0])?Object.assign({},i,n.shift()):i,Array.from(n).reverse())}function O(t,e){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];if(!n.length)return _(t,e);var i={i:!1};return w("right",t,e,p(n[0])?Object.assign({},i,n.shift()):i,n)}function S(t,e,n,o,i){if("string"!=typeof e||!e.length)return null;if(n&&"number"==typeof n||(n=0),"right"===t&&!e[n+1]||"left"===t&&(d(n)&&n<1||"0"===n))return null;var u=null,c=null;do{null!==(u="right"===t?O.apply(void 0,[e,d(c)?c:n].concat(r(i))):A.apply(void 0,[e,d(c)?c:n].concat(r(i))))&&(c="right"===t?u.rightmostChar:u.leftmostChar)}while(u);if(null!=c&&"right"===t&&c++,null===c)return null;if("right"===t){if(e[c]&&e[c].trim().length)return c;var a=_(e,c);if(0===o.mode){if(a===c+1)return c;if(!(e.slice(c,a||e.length).trim().length||e.slice(c,a||e.length).includes("\n")||e.slice(c,a||e.length).includes("\r")))return a?a-1:e.length;for(var l=c,f=e.length;l<f;l++)if("\n\r".includes(e[l]))return l}else{if(1===o.mode)return c;if(2===o.mode){var s=e.slice(c);if(s.trim().length||s.includes("\n")||s.includes("\r"))for(var h=c,p=e.length;h<p;h++)if(e[h].trim().length||"\n\r".includes(e[h]))return h;return e.length}}return a||e.length}if(e[c]&&e[c-1]&&e[c-1].trim().length)return c;var g=j(e,c);if(0===o.mode){if(g===c-2)return c;if(e.slice(0,c).trim().length||e.slice(0,c).includes("\n")||e.slice(0,c).includes("\r"))for(var y=c;y--;)if("\n\r".includes(e[y])||e[y].trim().length)return y+1+(e[y].trim().length?1:0);return 0}if(1===o.mode)return c;if(2===o.mode){var v=e.slice(0,c);if(v.trim().length||v.includes("\n")||v.includes("\r"))for(var b=c;b--;)if(e[b].trim().length||"\n\r".includes(e[b]))return b+1;return 0}return null!==g?g+1:0}t.chompLeft=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];if(!o.length||1===o.length&&p(o[0]))return null;var u={mode:0};if(p(o[0])){var c=Object.assign({},u,y(o[0]));if(c.mode){if(v(c.mode)&&"0123".includes(c.mode))c.mode=Number.parseInt(c.mode,10);else if(!d(c.mode))throw new Error("string-left-right/chompLeft(): [THROW_ID_01] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(c.mode," (type ").concat(e(c.mode),")"))}else c.mode=0;return S("left",t,r,c,y(o).slice(1))}return v(o[0])?S("left",t,r,u,y(o)):S("left",t,r,u,y(o).slice(1))},t.chompRight=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];if(!o.length||1===o.length&&p(o[0]))return null;var u={mode:0};if(p(o[0])){var c=Object.assign({},u,y(o[0]));if(c.mode){if(v(c.mode)&&"0123".includes(c.mode))c.mode=Number.parseInt(c.mode,10);else if(!d(c.mode))throw new Error("string-left-right/chompRight(): [THROW_ID_02] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(c.mode," (type ").concat(e(c.mode),")"))}else c.mode=0;return S("right",t,r,c,y(o).slice(1))}return v(o[0])?S("right",t,r,u,y(o)):S("right",t,r,u,y(o).slice(1))},t.left=j,t.leftSeq=A,t.leftStopAtNewLines=function(t,e){return m(t,e,!0)},t.right=_,t.rightSeq=O,t.rightStopAtNewLines=function(t,e){return b(t,e,!0)},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
10
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).stringLeftRight={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(Object(o),!0).forEach((function(e){r(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function i(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var c,a,f=Function.prototype,l=Object.prototype,s=f.toString,p=l.hasOwnProperty,h=s.call(Object),y=l.toString,d=(c=Object.getPrototypeOf,a=Object,function(t){return c(a(t))});var b=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=y.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=d(t);if(null===e)return!0;var r=p.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&s.call(r)==h},v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var g=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){var r="[object Arguments]",n="[object Function]",o="[object GeneratorFunction]",i="[object Map]",u="[object Set]",c=/\w*$/,a=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,l={};l[r]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[i]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[u]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[n]=l["[object WeakMap]"]=!1;var s="object"==typeof v&&v&&v.Object===Object&&v,p="object"==typeof self&&self&&self.Object===Object&&self,h=s||p||Function("return this")(),y=e&&!e.nodeType&&e,d=y&&t&&!t.nodeType&&t,b=d&&d.exports===y;function g(t,e){return t.set(e[0],e[1]),t}function m(t,e){return t.add(e),t}function _(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function j(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function w(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function O(t,e){return function(r){return t(e(r))}}function A(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var S,I=Array.prototype,P=Function.prototype,x=Object.prototype,D=h["__core-js_shared__"],E=(S=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+S:"",C=P.toString,L=x.hasOwnProperty,U=x.toString,W=RegExp("^"+C.call(L).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),F=b?h.Buffer:void 0,R=h.Symbol,$=h.Uint8Array,k=O(Object.getPrototypeOf,Object),M=Object.create,T=x.propertyIsEnumerable,B=I.splice,N=Object.getOwnPropertySymbols,V=F?F.isBuffer:void 0,q=O(Object.keys,Object),z=bt(h,"DataView"),H=bt(h,"Map"),G=bt(h,"Promise"),J=bt(h,"Set"),K=bt(h,"WeakMap"),Q=bt(Object,"create"),X=jt(z),Y=jt(H),Z=jt(G),tt=jt(J),et=jt(K),rt=R?R.prototype:void 0,nt=rt?rt.valueOf:void 0;function ot(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function it(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ut(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ct(t){this.__data__=new it(t)}function at(t,e){var n=Ot(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&At(t)}(t)&&L.call(t,"callee")&&(!T.call(t,"callee")||U.call(t)==r)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],o=n.length,i=!!o;for(var u in t)!e&&!L.call(t,u)||i&&("length"==u||mt(u,o))||n.push(u);return n}function ft(t,e,r){var n=t[e];L.call(t,e)&&wt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function lt(t,e){for(var r=t.length;r--;)if(wt(t[r][0],e))return r;return-1}function st(t,e,a,f,s,p,h){var y;if(f&&(y=p?f(t,s,p,h):f(t)),void 0!==y)return y;if(!Pt(t))return t;var d=Ot(t);if(d){if(y=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&L.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,y)}else{var b=gt(t),v=b==n||b==o;if(St(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if("[object Object]"==b||b==r||v&&!p){if(j(t))return p?t:{};if(y=function(t){return"function"!=typeof t.constructor||_t(t)?{}:(e=k(t),Pt(e)?M(e):{});var e}(v?{}:t),!e)return function(t,e){return yt(t,vt(t),e)}(t,function(t,e){return t&&yt(e,xt(e),t)}(y,t))}else{if(!l[b])return p?t:{};y=function(t,e,r,n){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return ht(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var r=e?ht(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t,e){var r=e?ht(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case i:return function(t,e,r){return _(e?r(w(t),!0):w(t),g,new t.constructor)}(t,n,r);case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,c.exec(t));return e.lastIndex=t.lastIndex,e}(t);case u:return function(t,e,r){return _(e?r(A(t),!0):A(t),m,new t.constructor)}(t,n,r);case"[object Symbol]":return a=t,nt?Object(nt.call(a)):{}}var a}(t,b,st,e)}}h||(h=new ct);var O=h.get(t);if(O)return O;if(h.set(t,y),!d)var S=a?function(t){return function(t,e,r){var n=e(t);return Ot(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,xt,vt)}(t):xt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(S||t,(function(r,n){S&&(r=t[n=r]),ft(y,n,st(r,e,a,f,n,t,h))})),y}function pt(t){return!(!Pt(t)||function(t){return!!E&&E in t}(t))&&(It(t)||j(t)?W:a).test(jt(t))}function ht(t){var e=new t.constructor(t.byteLength);return new $(e).set(new $(t)),e}function yt(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var u=e[o],c=n?n(r[u],t[u],u,r,t):void 0;ft(r,u,void 0===c?t[u]:c)}return r}function dt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function bt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return pt(r)?r:void 0}ot.prototype.clear=function(){this.__data__=Q?Q(null):{}},ot.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},ot.prototype.get=function(t){var e=this.__data__;if(Q){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return L.call(e,t)?e[t]:void 0},ot.prototype.has=function(t){var e=this.__data__;return Q?void 0!==e[t]:L.call(e,t)},ot.prototype.set=function(t,e){return this.__data__[t]=Q&&void 0===e?"__lodash_hash_undefined__":e,this},it.prototype.clear=function(){this.__data__=[]},it.prototype.delete=function(t){var e=this.__data__,r=lt(e,t);return!(r<0)&&(r==e.length-1?e.pop():B.call(e,r,1),!0)},it.prototype.get=function(t){var e=this.__data__,r=lt(e,t);return r<0?void 0:e[r][1]},it.prototype.has=function(t){return lt(this.__data__,t)>-1},it.prototype.set=function(t,e){var r=this.__data__,n=lt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},ut.prototype.clear=function(){this.__data__={hash:new ot,map:new(H||it),string:new ot}},ut.prototype.delete=function(t){return dt(this,t).delete(t)},ut.prototype.get=function(t){return dt(this,t).get(t)},ut.prototype.has=function(t){return dt(this,t).has(t)},ut.prototype.set=function(t,e){return dt(this,t).set(t,e),this},ct.prototype.clear=function(){this.__data__=new it},ct.prototype.delete=function(t){return this.__data__.delete(t)},ct.prototype.get=function(t){return this.__data__.get(t)},ct.prototype.has=function(t){return this.__data__.has(t)},ct.prototype.set=function(t,e){var r=this.__data__;if(r instanceof it){var n=r.__data__;if(!H||n.length<199)return n.push([t,e]),this;r=this.__data__=new ut(n)}return r.set(t,e),this};var vt=N?O(N,Object):function(){return[]},gt=function(t){return U.call(t)};function mt(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||f.test(t))&&t>-1&&t%1==0&&t<e}function _t(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||x)}function jt(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function wt(t,e){return t===e||t!=t&&e!=e}(z&&"[object DataView]"!=gt(new z(new ArrayBuffer(1)))||H&>(new H)!=i||G&&"[object Promise]"!=gt(G.resolve())||J&>(new J)!=u||K&&"[object WeakMap]"!=gt(new K))&&(gt=function(t){var e=U.call(t),r="[object Object]"==e?t.constructor:void 0,n=r?jt(r):void 0;if(n)switch(n){case X:return"[object DataView]";case Y:return i;case Z:return"[object Promise]";case tt:return u;case et:return"[object WeakMap]"}return e});var Ot=Array.isArray;function At(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}(t.length)&&!It(t)}var St=V||function(){return!1};function It(t){var e=Pt(t)?U.call(t):"";return e==n||e==o}function Pt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function xt(t){return At(t)?at(t):function(t){if(!_t(t))return q(t);var e=[];for(var r in Object(t))L.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return st(t,!0,!0)}}));function m(t){return"number"==typeof t}function _(t){return"string"==typeof t}function j(t,e,r){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),!t[e+1])return null;if(t[e+1]&&(!r&&t[e+1].trim()||r&&(t[e+1].trim()||"\n\r".includes(t[e+1]))))return e+1;if(t[e+2]&&(!r&&t[e+2].trim()||r&&(t[e+2].trim()||"\n\r".includes(t[e+2]))))return e+2;for(var n=e+1,o=t.length;n<o;n++)if(t[n]&&(!r&&t[n].trim()||r&&(t[n].trim()||"\n\r".includes(t[n]))))return n;return null}function w(t,e){return j(t,e,!1)}function O(t,e,r){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),e<1)return null;if(t[e-1]&&(!r&&t[e-1].trim()||r&&(t[e-1].trim()||"\n\r".includes(t[e-1]))))return e-1;if(t[e-2]&&(!r&&t[e-2].trim()||r&&(t[e-2].trim()||"\n\r".includes(t[e-2]))))return e-2;for(var n=e;n--;)if(t[n]&&(!r&&t[n].trim()||r&&(t[n].trim()||"\n\r".includes(t[n]))))return n;return null}function A(t,e){return O(t,e,!1)}function S(t,e,r,n,o){if("string"!=typeof e||!e.length)return null;if(r&&"number"==typeof r||(r=0),"right"===t&&!e[r+1]||"left"===t&&!e[r-1])return null;for(var i,u,c,a,f,l=r,s=[],p=0;p<o.length;)if(_(o[p])&&o[p].length){var h=(a=o[p],f=void 0,((f={value:a,hungry:!1,optional:!1}).value.endsWith("?*")||f.value.endsWith("*?"))&&f.value.length>2?(f.value=f.value.slice(0,f.value.length-2),f.optional=!0,f.hungry=!0):f.value.endsWith("?")&&f.value.length>1?(f.value=f.value.slice(0,f.value.length-1),f.optional=!0):f.value.endsWith("*")&&f.value.length>1&&(f.value=f.value.slice(0,f.value.length-1),f.hungry=!0),f),y=h.value,d=h.optional,b=h.hungry,v="right"===t?w(e,l):A(e,l);if(!(n.i&&e[v].toLowerCase()===y.toLowerCase()||!n.i&&e[v]===y)){if(d){p+=1;continue}if(c){p+=1,c=void 0;continue}return null}var g="right"===t?w(e,v):A(e,v);b&&(n.i&&e[g].toLowerCase()===y.toLowerCase()||!n.i&&e[g]===y)?c=!0:p+=1,"right"===t&&v>l+1?s.push([l+1,v]):"left"===t&&v<l-1&&s.unshift([v+1,l]),l=v,"right"===t?(void 0===i&&(i=v),u=v):(void 0===u&&(u=v),i=v)}else p+=1;return void 0===i?null:{gaps:s,leftmostChar:i,rightmostChar:u}}function I(t,e){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];if(!n.length)return A(t,e);var u={i:!1};return S("left",t,e,b(n[0])?o(o({},u),n.shift()):u,Array.from(n).reverse())}function P(t,e){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];if(!n.length)return w(t,e);var u={i:!1};return S("right",t,e,b(n[0])?o(o({},u),n.shift()):u,n)}function x(t,e,r,n,o){if("string"!=typeof e||!e.length)return null;if(r&&"number"==typeof r||(r=0),"right"===t&&!e[r+1]||"left"===t&&(m(r)&&r<1||"0"===r))return null;var u=null,c=null;do{null!==(u="right"===t?P.apply(void 0,[e,m(c)?c:r].concat(i(o))):I.apply(void 0,[e,m(c)?c:r].concat(i(o))))&&(c="right"===t?u.rightmostChar:u.leftmostChar)}while(u);if(null!=c&&"right"===t&&(c+=1),null===c)return null;if("right"===t){if(e[c]&&e[c].trim())return c;var a=w(e,c);if(0===n.mode){if(a===c+1)return c;if(!(e.slice(c,a||e.length).trim()||e.slice(c,a||e.length).includes("\n")||e.slice(c,a||e.length).includes("\r")))return a?a-1:e.length;for(var f=c,l=e.length;f<l;f++)if("\n\r".includes(e[f]))return f}else{if(1===n.mode)return c;if(2===n.mode){var s=e.slice(c);if(s.trim()||s.includes("\n")||s.includes("\r"))for(var p=c,h=e.length;p<h;p++)if(e[p].trim()||"\n\r".includes(e[p]))return p;return e.length}}return a||e.length}if(e[c]&&e[c-1]&&e[c-1].trim())return c;var y=A(e,c);if(0===n.mode){if(y===c-2)return c;if(e.slice(0,c).trim()||e.slice(0,c).includes("\n")||e.slice(0,c).includes("\r"))for(var d=c;d--;)if("\n\r".includes(e[d])||e[d].trim())return d+1+(e[d].trim()?1:0);return 0}if(1===n.mode)return c;if(2===n.mode){var b=e.slice(0,c);if(b.trim()||b.includes("\n")||b.includes("\r"))for(var v=c;v--;)if(e[v].trim()||"\n\r".includes(e[v]))return v+1;return 0}return null!==y?y+1:0}t.chompLeft=function(t,r){for(var n=arguments.length,i=new Array(n>2?n-2:0),u=2;u<n;u++)i[u-2]=arguments[u];if(!i.length||1===i.length&&b(i[0]))return null;var c={mode:0};if(b(i[0])){var a=o(o({},c),g(i[0]));if(a.mode){if(_(a.mode)&&"0123".includes(a.mode))a.mode=Number.parseInt(a.mode,10);else if(!m(a.mode))throw new Error("string-left-right/chompLeft(): [THROW_ID_01] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(a.mode," (type ").concat(e(a.mode),")"))}else a.mode=0;return x("left",t,r,a,g(i).slice(1))}return _(i[0])?x("left",t,r,c,g(i)):x("left",t,r,c,g(i).slice(1))},t.chompRight=function(t,r){for(var n=arguments.length,i=new Array(n>2?n-2:0),u=2;u<n;u++)i[u-2]=arguments[u];if(!i.length||1===i.length&&b(i[0]))return null;var c={mode:0};if(b(i[0])){var a=o(o({},c),g(i[0]));if(a.mode){if(_(a.mode)&&"0123".includes(a.mode))a.mode=Number.parseInt(a.mode,10);else if(!m(a.mode))throw new Error("string-left-right/chompRight(): [THROW_ID_02] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(a.mode," (type ").concat(e(a.mode),")"))}else a.mode=0;return x("right",t,r,a,g(i).slice(1))}return _(i[0])?x("right",t,r,c,g(i)):x("right",t,r,c,g(i).slice(1))},t.left=A,t.leftSeq=I,t.leftStopAtNewLines=function(t,e){return O(t,e,!0)},t.right=w,t.rightSeq=P,t.rightStopAtNewLines=function(t,e){return j(t,e,!0)},Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-left-right",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.22",
|
|
4
4
|
"description": "Look what's to the left or the right of a given index within a string",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://gitlab.com/codsen/codsen/",
|
|
@@ -30,18 +30,20 @@
|
|
|
30
30
|
"browser": "dist/string-left-right.umd.js",
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "rollup -c",
|
|
33
|
+
"ci_test": "npm run build && npm run lint && tap --no-only --reporter=silent --output-file=testStats.md && npm run format",
|
|
33
34
|
"dev": "rollup -c --dev",
|
|
34
|
-
"devunittest": "npm run dev && ./node_modules/.bin/tap --only",
|
|
35
|
+
"devunittest": "npm run dev && ./node_modules/.bin/tap --only -R 'base'",
|
|
35
36
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
36
37
|
"lect": "lect",
|
|
37
|
-
"lint": "../../node_modules/eslint/bin/eslint.js \"**/*.js\" --fix --config \"../../.eslintrc.json\"",
|
|
38
|
+
"lint": "../../node_modules/eslint/bin/eslint.js \"**/*.js\" --fix --config \"../../.eslintrc.json\" --quiet",
|
|
38
39
|
"perf": "node perf/check",
|
|
39
40
|
"prepare": "npm run build",
|
|
40
|
-
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md}' --write",
|
|
41
|
+
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md}' --write --loglevel silent",
|
|
42
|
+
"republish": "npm publish || :",
|
|
41
43
|
"tap": "tap",
|
|
42
44
|
"pretest": "npm run build",
|
|
43
45
|
"test": "npm run lint && npm run unittest && npm run format",
|
|
44
|
-
"unittest": "./node_modules/.bin/tap --no-only -
|
|
46
|
+
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md && npm run perf",
|
|
45
47
|
"version": "npm run build && git add ."
|
|
46
48
|
},
|
|
47
49
|
"husky": {
|
|
@@ -113,7 +115,13 @@
|
|
|
113
115
|
}
|
|
114
116
|
},
|
|
115
117
|
"tap": {
|
|
116
|
-
"coverage-report":
|
|
118
|
+
"coverage-report": [
|
|
119
|
+
"json-summary",
|
|
120
|
+
"text"
|
|
121
|
+
],
|
|
122
|
+
"nyc-arg": [
|
|
123
|
+
"--exclude=**/*.umd.js"
|
|
124
|
+
],
|
|
117
125
|
"timeout": 0
|
|
118
126
|
},
|
|
119
127
|
"dependencies": {
|
|
@@ -121,16 +129,16 @@
|
|
|
121
129
|
"lodash.isplainobject": "^4.0.6"
|
|
122
130
|
},
|
|
123
131
|
"devDependencies": {
|
|
124
|
-
"@babel/core": "^7.9.
|
|
125
|
-
"@babel/preset-env": "^7.9.
|
|
126
|
-
"@rollup/plugin-
|
|
127
|
-
"@rollup/plugin-
|
|
132
|
+
"@babel/core": "^7.9.6",
|
|
133
|
+
"@babel/preset-env": "^7.9.6",
|
|
134
|
+
"@rollup/plugin-babel": "^5.0.0",
|
|
135
|
+
"@rollup/plugin-commonjs": "^11.1.0",
|
|
136
|
+
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
128
137
|
"@rollup/plugin-strip": "^1.3.2",
|
|
129
138
|
"benchmark": "^2.1.4",
|
|
130
|
-
"lect": "^0.
|
|
131
|
-
"rollup": "^2.
|
|
139
|
+
"lect": "^0.13.0",
|
|
140
|
+
"rollup": "^2.8.0",
|
|
132
141
|
"rollup-plugin-ascii": "^0.0.3",
|
|
133
|
-
"rollup-plugin-babel": "^4.4.0",
|
|
134
142
|
"rollup-plugin-banner": "^0.2.1",
|
|
135
143
|
"rollup-plugin-cleanup": "^3.1.1",
|
|
136
144
|
"rollup-plugin-terser": "^5.3.0",
|