string-left-right 5.0.3 → 5.0.7

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,26 +3,6 @@
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
- ## 5.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
- ## 5.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
6
  ## 5.0.0 (2021-09-09)
27
7
 
28
8
  ### Features
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-%YEAR% Roy Revelt and other contributors
3
+ Copyright (c) 2010-2021 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name string-left-right
3
3
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
4
- * @version 5.0.3
4
+ * @version 5.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-left-right/}
@@ -10,414 +10,401 @@
10
10
  import isObj from 'lodash.isplainobject';
11
11
  import clone from 'lodash.clonedeep';
12
12
 
13
- var version$1 = "5.0.3";
13
+ var version$1 = "5.0.7";
14
14
 
15
15
  const version = version$1;
16
16
  const RAWNBSP = "\u00A0";
17
17
  function x(something) {
18
- const res = {
19
- value: something,
20
- hungry: false,
21
- optional: false
22
- };
23
- if ((res.value.endsWith("?*") || res.value.endsWith("*?")) && res.value.length > 2) {
24
- res.value = res.value.slice(0, res.value.length - 2);
25
- res.optional = true;
26
- res.hungry = true;
27
- } else if (res.value.endsWith("?") && res.value.length > 1) {
28
- res.value = res.value.slice(0, ~-res.value.length);
29
- res.optional = true;
30
- } else if (res.value.endsWith("*") && res.value.length > 1) {
31
- res.value = res.value.slice(0, ~-res.value.length);
32
- res.hungry = true;
33
- }
34
- return res;
18
+ const res = {
19
+ value: something,
20
+ hungry: false,
21
+ optional: false,
22
+ };
23
+ if ((res.value.endsWith("?*") || res.value.endsWith("*?")) &&
24
+ res.value.length > 2) {
25
+ res.value = res.value.slice(0, res.value.length - 2);
26
+ res.optional = true;
27
+ res.hungry = true;
28
+ }
29
+ else if (res.value.endsWith("?") && res.value.length > 1) {
30
+ res.value = res.value.slice(0, ~-res.value.length);
31
+ res.optional = true;
32
+ }
33
+ else if (res.value.endsWith("*") && res.value.length > 1) {
34
+ res.value = res.value.slice(0, ~-res.value.length);
35
+ res.hungry = true;
36
+ }
37
+ return res;
35
38
  }
36
39
  function isNum(something) {
37
- return typeof something === "number";
40
+ return typeof something === "number";
38
41
  }
39
42
  function isStr(something) {
40
- return typeof something === "string";
43
+ return typeof something === "string";
41
44
  }
42
- function rightMain({
43
- str,
44
- idx = 0,
45
- stopAtNewlines = false,
46
- stopAtRawNbsp = false
47
- }) {
48
- if (typeof str !== "string" || !str.length) {
49
- return null;
50
- }
51
- if (!idx || typeof idx !== "number") {
52
- idx = 0;
53
- }
54
- if (!str[idx + 1]) {
55
- return null;
56
- }
57
- if (
58
- str[idx + 1] && (
59
- str[idx + 1].trim() ||
60
- stopAtNewlines &&
61
- "\n\r".includes(str[idx + 1]) ||
62
- stopAtRawNbsp &&
63
- str[idx + 1] === RAWNBSP)) {
64
- return idx + 1;
65
- }
66
- if (
67
- str[idx + 2] && (
68
- str[idx + 2].trim() ||
69
- stopAtNewlines &&
70
- "\n\r".includes(str[idx + 2]) ||
71
- stopAtRawNbsp &&
72
- str[idx + 2] === RAWNBSP)) {
73
- return idx + 2;
74
- }
75
- for (let i = idx + 1, len = str.length; i < len; i++) {
45
+ function rightMain({ str, idx = 0, stopAtNewlines = false, stopAtRawNbsp = false, }) {
46
+ if (typeof str !== "string" || !str.length) {
47
+ return null;
48
+ }
49
+ if (!idx || typeof idx !== "number") {
50
+ idx = 0;
51
+ }
52
+ if (!str[idx + 1]) {
53
+ return null;
54
+ }
55
+ if (
56
+ str[idx + 1] &&
57
+ (str[idx + 1].trim() ||
58
+ (stopAtNewlines &&
59
+ "\n\r".includes(str[idx + 1])) ||
60
+ (stopAtRawNbsp &&
61
+ str[idx + 1] === RAWNBSP))) {
62
+ return idx + 1;
63
+ }
76
64
  if (
77
- str[i].trim() ||
78
- stopAtNewlines &&
79
- "\n\r".includes(str[i]) ||
80
- stopAtRawNbsp &&
81
- str[i] === RAWNBSP) {
82
- return i;
83
- }
84
- }
85
- return null;
65
+ str[idx + 2] &&
66
+ (str[idx + 2].trim() ||
67
+ (stopAtNewlines &&
68
+ "\n\r".includes(str[idx + 2])) ||
69
+ (stopAtRawNbsp &&
70
+ str[idx + 2] === RAWNBSP))) {
71
+ return idx + 2;
72
+ }
73
+ for (let i = idx + 1, len = str.length; i < len; i++) {
74
+ if (
75
+ str[i].trim() ||
76
+ (stopAtNewlines &&
77
+ "\n\r".includes(str[i])) ||
78
+ (stopAtRawNbsp &&
79
+ str[i] === RAWNBSP)) {
80
+ return i;
81
+ }
82
+ }
83
+ return null;
86
84
  }
87
85
  function right(str, idx = 0) {
88
- return rightMain({
89
- str,
90
- idx,
91
- stopAtNewlines: false,
92
- stopAtRawNbsp: false
93
- });
86
+ return rightMain({ str, idx, stopAtNewlines: false, stopAtRawNbsp: false });
94
87
  }
95
88
  function rightStopAtNewLines(str, idx) {
96
- return rightMain({
97
- str,
98
- idx,
99
- stopAtNewlines: true,
100
- stopAtRawNbsp: false
101
- });
89
+ return rightMain({ str, idx, stopAtNewlines: true, stopAtRawNbsp: false });
102
90
  }
103
91
  function rightStopAtRawNbsp(str, idx) {
104
- return rightMain({
105
- str,
106
- idx,
107
- stopAtNewlines: false,
108
- stopAtRawNbsp: true
109
- });
92
+ return rightMain({ str, idx, stopAtNewlines: false, stopAtRawNbsp: true });
110
93
  }
111
- function leftMain({
112
- str,
113
- idx,
114
- stopAtNewlines,
115
- stopAtRawNbsp
116
- }) {
117
- if (typeof str !== "string" || !str.length) {
118
- return null;
119
- }
120
- if (!idx || typeof idx !== "number") {
121
- idx = 0;
122
- }
123
- if (idx < 1) {
94
+ function leftMain({ str, idx, stopAtNewlines, stopAtRawNbsp }) {
95
+ if (typeof str !== "string" || !str.length) {
96
+ return null;
97
+ }
98
+ if (!idx || typeof idx !== "number") {
99
+ idx = 0;
100
+ }
101
+ if (idx < 1) {
102
+ return null;
103
+ }
104
+ if (
105
+ str[~-idx] &&
106
+ (str[~-idx].trim() ||
107
+ (stopAtNewlines &&
108
+ "\n\r".includes(str[~-idx])) ||
109
+ (stopAtRawNbsp &&
110
+ str[~-idx] === RAWNBSP))) {
111
+ return ~-idx;
112
+ }
113
+ if (
114
+ str[idx - 2] &&
115
+ (str[idx - 2].trim() ||
116
+ (stopAtNewlines &&
117
+ "\n\r".includes(str[idx - 2])) ||
118
+ (stopAtRawNbsp &&
119
+ str[idx - 2] === RAWNBSP))) {
120
+ return idx - 2;
121
+ }
122
+ for (let i = idx; i--;) {
123
+ if (str[i] &&
124
+ (str[i].trim() ||
125
+ (stopAtNewlines &&
126
+ "\n\r".includes(str[i])) ||
127
+ (stopAtRawNbsp &&
128
+ str[i] === RAWNBSP))) {
129
+ return i;
130
+ }
131
+ }
124
132
  return null;
125
- }
126
- if (
127
- str[~-idx] && (
128
- str[~-idx].trim() ||
129
- stopAtNewlines &&
130
- "\n\r".includes(str[~-idx]) ||
131
- stopAtRawNbsp &&
132
- str[~-idx] === RAWNBSP)) {
133
- return ~-idx;
134
- }
135
- if (
136
- str[idx - 2] && (
137
- str[idx - 2].trim() ||
138
- stopAtNewlines &&
139
- "\n\r".includes(str[idx - 2]) ||
140
- stopAtRawNbsp &&
141
- str[idx - 2] === RAWNBSP)) {
142
- return idx - 2;
143
- }
144
- for (let i = idx; i--;) {
145
- if (str[i] && (
146
- str[i].trim() ||
147
- stopAtNewlines &&
148
- "\n\r".includes(str[i]) ||
149
- stopAtRawNbsp &&
150
- str[i] === RAWNBSP)) {
151
- return i;
152
- }
153
- }
154
- return null;
155
133
  }
156
134
  function left(str, idx = 0) {
157
- return leftMain({
158
- str,
159
- idx,
160
- stopAtNewlines: false,
161
- stopAtRawNbsp: false
162
- });
135
+ return leftMain({ str, idx, stopAtNewlines: false, stopAtRawNbsp: false });
163
136
  }
164
137
  function leftStopAtNewLines(str, idx) {
165
- return leftMain({
166
- str,
167
- idx,
168
- stopAtNewlines: true,
169
- stopAtRawNbsp: false
170
- });
138
+ return leftMain({ str, idx, stopAtNewlines: true, stopAtRawNbsp: false });
171
139
  }
172
140
  function leftStopAtRawNbsp(str, idx) {
173
- return leftMain({
174
- str,
175
- idx,
176
- stopAtNewlines: false,
177
- stopAtRawNbsp: true
178
- });
141
+ return leftMain({ str, idx, stopAtNewlines: false, stopAtRawNbsp: true });
179
142
  }
180
143
  function seq(direction, str, idx, opts, args) {
181
- if (typeof str !== "string" || !str.length) {
182
- return null;
183
- }
184
- if (typeof idx !== "number") {
185
- idx = 0;
186
- }
187
- if (direction === "right" && !str[idx + 1] || direction === "left" && !str[~-idx]) {
188
- return null;
189
- }
190
- let lastFinding = idx;
191
- const gaps = [];
192
- let leftmostChar;
193
- let rightmostChar;
194
- let satiated;
195
- let i = 0;
196
- while (i < args.length) {
197
- if (!isStr(args[i]) || !args[i].length) {
198
- i += 1;
199
- continue;
200
- }
201
- const {
202
- value,
203
- optional,
204
- hungry
205
- } = x(args[i]);
206
- const whattsOnTheSide = direction === "right" ? right(str, lastFinding) : left(str, lastFinding);
207
- if (opts.i && str[whattsOnTheSide].toLowerCase() === value.toLowerCase() || !opts.i && str[whattsOnTheSide] === value) {
208
- const temp = direction === "right" ? right(str, whattsOnTheSide) : left(str, whattsOnTheSide);
209
- if (hungry && (opts.i && str[temp].toLowerCase() === value.toLowerCase() || !opts.i && str[temp] === value)) {
210
- satiated = true;
211
- } else {
212
- i += 1;
213
- }
214
- if (typeof whattsOnTheSide === "number" && direction === "right" && whattsOnTheSide > lastFinding + 1) {
215
- gaps.push([lastFinding + 1, whattsOnTheSide]);
216
- } else if (direction === "left" && typeof whattsOnTheSide === "number" && whattsOnTheSide < ~-lastFinding) {
217
- gaps.unshift([whattsOnTheSide + 1, lastFinding]);
218
- }
219
- lastFinding = whattsOnTheSide;
220
- if (direction === "right") {
221
- if (leftmostChar === undefined) {
222
- leftmostChar = whattsOnTheSide;
144
+ if (typeof str !== "string" || !str.length) {
145
+ return null;
146
+ }
147
+ if (typeof idx !== "number") {
148
+ idx = 0;
149
+ }
150
+ if ((direction === "right" && !str[idx + 1]) ||
151
+ (direction === "left" && !str[~-idx])) {
152
+ return null;
153
+ }
154
+ let lastFinding = idx;
155
+ const gaps = [];
156
+ let leftmostChar;
157
+ let rightmostChar;
158
+ let satiated;
159
+ let i = 0;
160
+ while (i < args.length) {
161
+ if (!isStr(args[i]) || !args[i].length) {
162
+ i += 1;
163
+ continue;
223
164
  }
224
- rightmostChar = whattsOnTheSide;
225
- } else {
226
- if (rightmostChar === undefined) {
227
- rightmostChar = whattsOnTheSide;
165
+ const { value, optional, hungry } = x(args[i]);
166
+ const whattsOnTheSide = direction === "right" ? right(str, lastFinding) : left(str, lastFinding);
167
+ if ((opts.i &&
168
+ str[whattsOnTheSide].toLowerCase() === value.toLowerCase()) ||
169
+ (!opts.i && str[whattsOnTheSide] === value)) {
170
+ const temp = direction === "right"
171
+ ? right(str, whattsOnTheSide)
172
+ : left(str, whattsOnTheSide);
173
+ if (hungry &&
174
+ ((opts.i &&
175
+ str[temp].toLowerCase() === value.toLowerCase()) ||
176
+ (!opts.i && str[temp] === value))) {
177
+ satiated = true;
178
+ }
179
+ else {
180
+ i += 1;
181
+ }
182
+ if (typeof whattsOnTheSide === "number" &&
183
+ direction === "right" &&
184
+ whattsOnTheSide > lastFinding + 1) {
185
+ gaps.push([lastFinding + 1, whattsOnTheSide]);
186
+ }
187
+ else if (direction === "left" &&
188
+ typeof whattsOnTheSide === "number" &&
189
+ whattsOnTheSide < ~-lastFinding) {
190
+ gaps.unshift([whattsOnTheSide + 1, lastFinding]);
191
+ }
192
+ lastFinding = whattsOnTheSide;
193
+ if (direction === "right") {
194
+ if (leftmostChar === undefined) {
195
+ leftmostChar = whattsOnTheSide;
196
+ }
197
+ rightmostChar = whattsOnTheSide;
198
+ }
199
+ else {
200
+ if (rightmostChar === undefined) {
201
+ rightmostChar = whattsOnTheSide;
202
+ }
203
+ leftmostChar = whattsOnTheSide;
204
+ }
228
205
  }
229
- leftmostChar = whattsOnTheSide;
230
- }
231
- } else if (optional) {
232
- i += 1;
233
- continue;
234
- } else if (satiated) {
235
- i += 1;
236
- satiated = undefined;
237
- continue;
238
- } else {
239
- return null;
240
- }
241
- }
242
- if (leftmostChar === undefined || rightmostChar === undefined) {
243
- return null;
244
- }
245
- return {
246
- gaps,
247
- leftmostChar,
248
- rightmostChar
249
- };
206
+ else if (optional) {
207
+ i += 1;
208
+ continue;
209
+ }
210
+ else if (satiated) {
211
+ i += 1;
212
+ satiated = undefined;
213
+ continue;
214
+ }
215
+ else {
216
+ return null;
217
+ }
218
+ }
219
+ if (leftmostChar === undefined || rightmostChar === undefined) {
220
+ return null;
221
+ }
222
+ return { gaps, leftmostChar, rightmostChar };
250
223
  }
251
224
  const seqDefaults = {
252
- i: false
225
+ i: false,
253
226
  };
254
227
  function leftSeq(str, idx, ...args) {
255
- if (!args || !args.length) {
256
- throw new Error(`string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?`);
257
- }
258
- let opts;
259
- if (isObj(args[0])) {
260
- opts = { ...seqDefaults,
261
- ...args.shift()
262
- };
263
- } else {
264
- opts = seqDefaults;
265
- }
266
- return seq("left", str, idx, opts, Array.from(args).reverse());
228
+ if (!args || !args.length) {
229
+ throw new Error(`string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?`);
230
+ }
231
+ let opts;
232
+ if (isObj(args[0])) {
233
+ opts = { ...seqDefaults, ...args.shift() };
234
+ }
235
+ else {
236
+ opts = seqDefaults;
237
+ }
238
+ return seq("left", str, idx, opts, Array.from(args).reverse());
267
239
  }
268
240
  function rightSeq(str, idx, ...args) {
269
- if (!args || !args.length) {
270
- throw new Error(`string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?`);
271
- }
272
- let opts;
273
- if (isObj(args[0])) {
274
- opts = { ...seqDefaults,
275
- ...args.shift()
276
- };
277
- } else {
278
- opts = seqDefaults;
279
- }
280
- return seq("right", str, idx, opts, args);
241
+ if (!args || !args.length) {
242
+ throw new Error(`string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?`);
243
+ }
244
+ let opts;
245
+ if (isObj(args[0])) {
246
+ opts = { ...seqDefaults, ...args.shift() };
247
+ }
248
+ else {
249
+ opts = seqDefaults;
250
+ }
251
+ return seq("right", str, idx, opts, args);
281
252
  }
282
253
  function chomp(direction, str, idx, opts, args = []) {
283
- if (typeof str !== "string" || !str.length) {
284
- return null;
285
- }
286
- if (!idx || typeof idx !== "number") {
287
- idx = 0;
288
- }
289
- if (direction === "right" && !str[idx + 1] || direction === "left" && +idx === 0) {
290
- return null;
291
- }
292
- let lastRes = null;
293
- let lastIdx = null;
294
- do {
295
- lastRes = direction === "right" ? rightSeq(str, typeof lastIdx === "number" ? lastIdx : idx, ...args) : leftSeq(str, typeof lastIdx === "number" ? lastIdx : idx, ...args);
296
- if (lastRes !== null) {
297
- lastIdx = direction === "right" ? lastRes.rightmostChar : lastRes.leftmostChar;
298
- }
299
- } while (lastRes);
300
- if (lastIdx != null && direction === "right") {
301
- lastIdx += 1;
302
- }
303
- if (lastIdx === null) {
304
- return null;
305
- }
306
- if (direction === "right") {
307
- if (str[lastIdx] && str[lastIdx].trim()) {
308
- return lastIdx;
254
+ if (typeof str !== "string" || !str.length) {
255
+ return null;
309
256
  }
310
- const whatsOnTheRight = right(str, lastIdx);
311
- if (!opts || opts.mode === 0) {
312
- if (whatsOnTheRight === lastIdx + 1) {
313
- return lastIdx;
314
- }
315
- if (str.slice(lastIdx, whatsOnTheRight || str.length).trim() || str.slice(lastIdx, whatsOnTheRight || str.length).includes("\n") || str.slice(lastIdx, whatsOnTheRight || str.length).includes("\r")) {
316
- for (let y = lastIdx, len = str.length; y < len; y++) {
317
- if (`\n\r`.includes(str[y])) {
318
- return y;
319
- }
257
+ if (!idx || typeof idx !== "number") {
258
+ idx = 0;
259
+ }
260
+ if ((direction === "right" && !str[idx + 1]) ||
261
+ (direction === "left" && +idx === 0)) {
262
+ return null;
263
+ }
264
+ let lastRes = null;
265
+ let lastIdx = null;
266
+ do {
267
+ lastRes =
268
+ direction === "right"
269
+ ? rightSeq(str, typeof lastIdx === "number" ? lastIdx : idx, ...args)
270
+ : leftSeq(str, typeof lastIdx === "number" ? lastIdx : idx, ...args);
271
+ if (lastRes !== null) {
272
+ lastIdx =
273
+ direction === "right" ? lastRes.rightmostChar : lastRes.leftmostChar;
274
+ }
275
+ } while (lastRes);
276
+ if (lastIdx != null && direction === "right") {
277
+ lastIdx += 1;
278
+ }
279
+ if (lastIdx === null) {
280
+ return null;
281
+ }
282
+ if (direction === "right") {
283
+ if (str[lastIdx] && str[lastIdx].trim()) {
284
+ return lastIdx;
320
285
  }
321
- } else {
322
- return whatsOnTheRight ? ~-whatsOnTheRight : str.length;
323
- }
324
- } else if (opts.mode === 1) {
325
- return lastIdx;
326
- } else if (opts.mode === 2) {
327
- const remainderString = str.slice(lastIdx);
328
- if (remainderString.trim() || remainderString.includes("\n") || remainderString.includes("\r")) {
329
- for (let y = lastIdx, len = str.length; y < len; y++) {
330
- if (str[y].trim() || `\n\r`.includes(str[y])) {
331
- return y;
332
- }
286
+ const whatsOnTheRight = right(str, lastIdx);
287
+ if (!opts || opts.mode === 0) {
288
+ if (whatsOnTheRight === lastIdx + 1) {
289
+ return lastIdx;
290
+ }
291
+ if (str.slice(lastIdx, whatsOnTheRight || str.length).trim() ||
292
+ str.slice(lastIdx, whatsOnTheRight || str.length).includes("\n") ||
293
+ str.slice(lastIdx, whatsOnTheRight || str.length).includes("\r")) {
294
+ for (let y = lastIdx, len = str.length; y < len; y++) {
295
+ if (`\n\r`.includes(str[y])) {
296
+ return y;
297
+ }
298
+ }
299
+ }
300
+ else {
301
+ return whatsOnTheRight ? ~-whatsOnTheRight : str.length;
302
+ }
333
303
  }
334
- }
335
- return str.length;
336
- }
337
- return whatsOnTheRight || str.length;
338
- }
339
- if (str[lastIdx] && str[~-lastIdx] && str[~-lastIdx].trim()) {
340
- return lastIdx;
341
- }
342
- const whatsOnTheLeft = left(str, lastIdx);
343
- if (!opts || opts.mode === 0) {
344
- if (whatsOnTheLeft === lastIdx - 2) {
345
- return lastIdx;
346
- }
347
- if (str.slice(0, lastIdx).trim() || str.slice(0, lastIdx).includes("\n") || str.slice(0, lastIdx).includes("\r")) {
348
- for (let y = lastIdx; y--;) {
349
- if (`\n\r`.includes(str[y]) || str[y].trim()) {
350
- return y + 1 + (str[y].trim() ? 1 : 0);
304
+ else if (opts.mode === 1) {
305
+ return lastIdx;
351
306
  }
352
- }
353
- }
354
- return 0;
355
- }
356
- if (opts.mode === 1) {
357
- return lastIdx;
358
- }
359
- if (opts.mode === 2) {
360
- const remainderString = str.slice(0, lastIdx);
361
- if (remainderString.trim() || remainderString.includes("\n") || remainderString.includes("\r")) {
362
- for (let y = lastIdx; y--;) {
363
- if (str[y].trim() || `\n\r`.includes(str[y])) {
364
- return y + 1;
307
+ else if (opts.mode === 2) {
308
+ const remainderString = str.slice(lastIdx);
309
+ if (remainderString.trim() ||
310
+ remainderString.includes("\n") ||
311
+ remainderString.includes("\r")) {
312
+ for (let y = lastIdx, len = str.length; y < len; y++) {
313
+ if (str[y].trim() || `\n\r`.includes(str[y])) {
314
+ return y;
315
+ }
316
+ }
317
+ }
318
+ return str.length;
365
319
  }
366
- }
320
+ return whatsOnTheRight || str.length;
367
321
  }
368
- return 0;
369
- }
370
- return whatsOnTheLeft !== null ? whatsOnTheLeft + 1 : 0;
322
+ if (str[lastIdx] && str[~-lastIdx] && str[~-lastIdx].trim()) {
323
+ return lastIdx;
324
+ }
325
+ const whatsOnTheLeft = left(str, lastIdx);
326
+ if (!opts || opts.mode === 0) {
327
+ if (whatsOnTheLeft === lastIdx - 2) {
328
+ return lastIdx;
329
+ }
330
+ if (str.slice(0, lastIdx).trim() ||
331
+ str.slice(0, lastIdx).includes("\n") ||
332
+ str.slice(0, lastIdx).includes("\r")) {
333
+ for (let y = lastIdx; y--;) {
334
+ if (`\n\r`.includes(str[y]) || str[y].trim()) {
335
+ return y + 1 + (str[y].trim() ? 1 : 0);
336
+ }
337
+ }
338
+ }
339
+ return 0;
340
+ }
341
+ if (opts.mode === 1) {
342
+ return lastIdx;
343
+ }
344
+ if (opts.mode === 2) {
345
+ const remainderString = str.slice(0, lastIdx);
346
+ if (remainderString.trim() ||
347
+ remainderString.includes("\n") ||
348
+ remainderString.includes("\r")) {
349
+ for (let y = lastIdx; y--;) {
350
+ if (str[y].trim() || `\n\r`.includes(str[y])) {
351
+ return y + 1;
352
+ }
353
+ }
354
+ }
355
+ return 0;
356
+ }
357
+ return whatsOnTheLeft !== null ? whatsOnTheLeft + 1 : 0;
371
358
  }
372
359
  function chompLeft(str, idx, ...args) {
373
- if (!args.length || args.length === 1 && isObj(args[0])) {
374
- return null;
375
- }
376
- const defaults = {
377
- mode: 0
378
- };
379
- if (isObj(args[0])) {
380
- const opts = { ...defaults,
381
- ...clone(args[0])
360
+ if (!args.length || (args.length === 1 && isObj(args[0]))) {
361
+ return null;
362
+ }
363
+ const defaults = {
364
+ mode: 0,
382
365
  };
383
- if (!opts.mode) {
384
- opts.mode = 0;
385
- } else if (isStr(opts.mode) && `0123`.includes(opts.mode)) {
386
- opts.mode = Number.parseInt(opts.mode, 10);
387
- } else if (!isNum(opts.mode)) {
388
- 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 ${opts.mode} (type ${typeof opts.mode})`);
389
- }
390
- return chomp("left", str, idx, opts, clone(args).slice(1));
391
- }
392
- if (!isStr(args[0])) {
393
- return chomp("left", str, idx, defaults, clone(args).slice(1));
394
- }
395
- return chomp("left", str, idx, defaults, clone(args));
366
+ if (isObj(args[0])) {
367
+ const opts = { ...defaults, ...clone(args[0]) };
368
+ if (!opts.mode) {
369
+ opts.mode = 0;
370
+ }
371
+ else if (isStr(opts.mode) && `0123`.includes(opts.mode)) {
372
+ opts.mode = Number.parseInt(opts.mode, 10);
373
+ }
374
+ else if (!isNum(opts.mode)) {
375
+ 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 ${opts.mode} (type ${typeof opts.mode})`);
376
+ }
377
+ return chomp("left", str, idx, opts, clone(args).slice(1));
378
+ }
379
+ if (!isStr(args[0])) {
380
+ return chomp("left", str, idx, defaults, clone(args).slice(1));
381
+ }
382
+ return chomp("left", str, idx, defaults, clone(args));
396
383
  }
397
384
  function chompRight(str, idx, ...args) {
398
- if (!args.length || args.length === 1 && isObj(args[0])) {
399
- return null;
400
- }
401
- const defaults = {
402
- mode: 0
403
- };
404
- if (isObj(args[0])) {
405
- const opts = { ...defaults,
406
- ...clone(args[0])
385
+ if (!args.length || (args.length === 1 && isObj(args[0]))) {
386
+ return null;
387
+ }
388
+ const defaults = {
389
+ mode: 0,
407
390
  };
408
- if (!opts.mode) {
409
- opts.mode = 0;
410
- } else if (isStr(opts.mode) && `0123`.includes(opts.mode)) {
411
- opts.mode = Number.parseInt(opts.mode, 10);
412
- } else if (!isNum(opts.mode)) {
413
- 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 ${opts.mode} (type ${typeof opts.mode})`);
414
- }
415
- return chomp("right", str, idx, opts, clone(args).slice(1));
416
- }
417
- if (!isStr(args[0])) {
418
- return chomp("right", str, idx, defaults, clone(args).slice(1));
419
- }
420
- return chomp("right", str, idx, defaults, clone(args));
391
+ if (isObj(args[0])) {
392
+ const opts = { ...defaults, ...clone(args[0]) };
393
+ if (!opts.mode) {
394
+ opts.mode = 0;
395
+ }
396
+ else if (isStr(opts.mode) && `0123`.includes(opts.mode)) {
397
+ opts.mode = Number.parseInt(opts.mode, 10);
398
+ }
399
+ else if (!isNum(opts.mode)) {
400
+ 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 ${opts.mode} (type ${typeof opts.mode})`);
401
+ }
402
+ return chomp("right", str, idx, opts, clone(args).slice(1));
403
+ }
404
+ if (!isStr(args[0])) {
405
+ return chomp("right", str, idx, defaults, clone(args).slice(1));
406
+ }
407
+ return chomp("right", str, idx, defaults, clone(args));
421
408
  }
422
409
 
423
410
  export { chompLeft, chompRight, left, leftSeq, leftStopAtNewLines, leftStopAtRawNbsp, right, rightSeq, rightStopAtNewLines, rightStopAtRawNbsp, version };
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name string-left-right
3
3
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
4
- * @version 5.0.3
4
+ * @version 5.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/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="undefined"!=typeof globalThis?globalThis:t||self).stringLeftRight={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n,o=Object.prototype,i=Function.prototype.toString,u=o.hasOwnProperty,c=i.call(Object),f=o.toString,s=(r=Object.getPrototypeOf,n=Object,function(t){return r(n(t))});var l=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=f.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=s(t);if(null===e)return!0;var r=u.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&i.call(r)==c},a={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",u="[object Boolean]",c="[object Date]",f="[object Function]",s="[object GeneratorFunction]",l="[object Map]",a="[object Number]",p="[object Object]",h="[object Promise]",d="[object RegExp]",g="[object Set]",y="[object String]",v="[object Symbol]",b="[object WeakMap]",_="[object ArrayBuffer]",m="[object DataView]",w="[object Float32Array]",j="[object Float64Array]",A="[object Int8Array]",O="[object Int16Array]",x="[object Int32Array]",N="[object Uint8Array]",S="[object Uint8ClampedArray]",R="[object Uint16Array]",I="[object Uint32Array]",$=/\w*$/,E=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,C={};C[i]=C["[object Array]"]=C[_]=C[m]=C[u]=C[c]=C[w]=C[j]=C[A]=C[O]=C[x]=C[l]=C[a]=C[p]=C[d]=C[g]=C[y]=C[v]=C[N]=C[S]=C[R]=C[I]=!0,C["[object Error]"]=C[f]=C[b]=!1;var P="object"==typeof self&&self&&self.Object===Object&&self,T="object"==typeof e&&e&&e.Object===Object&&e||P||Function("return this")(),W=r&&!r.nodeType&&r,D=W&&t&&!t.nodeType&&t,F=D&&D.exports===W;function k(t,e){return t.set(e[0],e[1]),t}function B(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 U(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function q(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function z(t,e){return function(r){return t(e(r))}}function H(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var V,G=Array.prototype,J=Function.prototype,K=Object.prototype,Q=T["__core-js_shared__"],X=(V=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Y=J.toString,Z=K.hasOwnProperty,tt=K.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=F?T.Buffer:void 0,nt=T.Symbol,ot=T.Uint8Array,it=z(Object.getPrototypeOf,Object),ut=Object.create,ct=K.propertyIsEnumerable,ft=G.splice,st=Object.getOwnPropertySymbols,lt=rt?rt.isBuffer:void 0,at=z(Object.keys,Object),pt=Dt(T,"DataView"),ht=Dt(T,"Map"),dt=Dt(T,"Promise"),gt=Dt(T,"Set"),yt=Dt(T,"WeakMap"),vt=Dt(Object,"create"),bt=Ut(pt),_t=Ut(ht),mt=Ut(dt),wt=Ut(gt),jt=Ut(yt),At=nt?nt.prototype:void 0,Ot=At?At.valueOf:void 0;function xt(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 Nt(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 St(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 Rt(t){this.__data__=new Nt(t)}function It(t,e){var r=zt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ht(t)}(t)&&Z.call(t,"callee")&&(!ct.call(t,"callee")||tt.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var u in t)!e&&!Z.call(t,u)||o&&("length"==u||Bt(u,n))||r.push(u);return r}function $t(t,e,r){var n=t[e];Z.call(t,e)&&qt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Et(t,e){for(var r=t.length;r--;)if(qt(t[r][0],e))return r;return-1}function Lt(t,e,r,n,o,h,b){var E;if(n&&(E=h?n(t,o,h,b):n(t)),void 0!==E)return E;if(!Jt(t))return t;var L=zt(t);if(L){if(E=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.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,E)}else{var P=kt(t),T=P==f||P==s;if(Vt(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(P==p||P==i||T&&!h){if(U(t))return h?t:{};if(E=function(t){return"function"!=typeof t.constructor||Mt(t)?{}:(e=it(t),Jt(e)?ut(e):{});var e}(T?{}:t),!e)return function(t,e){return Tt(t,Ft(t),e)}(t,function(t,e){return t&&Tt(e,Kt(e),t)}(E,t))}else{if(!C[P])return h?t:{};E=function(t,e,r,n){var o=t.constructor;switch(e){case _:return Pt(t);case u:case c:return new o(+t);case m:return function(t,e){var r=e?Pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case w:case j:case A:case O:case x:case N:case S:case R:case I:return function(t,e){var r=e?Pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case l:return function(t,e,r){return M(e?r(q(t),!0):q(t),k,new t.constructor)}(t,n,r);case a:case y:return new o(t);case d:return function(t){var e=new t.constructor(t.source,$.exec(t));return e.lastIndex=t.lastIndex,e}(t);case g:return function(t,e,r){return M(e?r(H(t),!0):H(t),B,new t.constructor)}(t,n,r);case v:return i=t,Ot?Object(Ot.call(i)):{}}var i}(t,P,Lt,e)}}b||(b=new Rt);var W=b.get(t);if(W)return W;if(b.set(t,E),!L)var D=r?function(t){return function(t,e,r){var n=e(t);return zt(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,Kt,Ft)}(t):Kt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(D||t,(function(o,i){D&&(o=t[i=o]),$t(E,i,Lt(o,e,r,n,i,t,b))})),E}function Ct(t){return!(!Jt(t)||function(t){return!!X&&X in t}(t))&&(Gt(t)||U(t)?et:E).test(Ut(t))}function Pt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Tt(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;$t(r,u,void 0===c?t[u]:c)}return r}function Wt(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 Ct(r)?r:void 0}xt.prototype.clear=function(){this.__data__=vt?vt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(vt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return vt?void 0!==e[t]:Z.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=vt&&void 0===e?n:e,this},Nt.prototype.clear=function(){this.__data__=[]},Nt.prototype.delete=function(t){var e=this.__data__,r=Et(e,t);return!(r<0)&&(r==e.length-1?e.pop():ft.call(e,r,1),!0)},Nt.prototype.get=function(t){var e=this.__data__,r=Et(e,t);return r<0?void 0:e[r][1]},Nt.prototype.has=function(t){return Et(this.__data__,t)>-1},Nt.prototype.set=function(t,e){var r=this.__data__,n=Et(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},St.prototype.clear=function(){this.__data__={hash:new xt,map:new(ht||Nt),string:new xt}},St.prototype.delete=function(t){return Wt(this,t).delete(t)},St.prototype.get=function(t){return Wt(this,t).get(t)},St.prototype.has=function(t){return Wt(this,t).has(t)},St.prototype.set=function(t,e){return Wt(this,t).set(t,e),this},Rt.prototype.clear=function(){this.__data__=new Nt},Rt.prototype.delete=function(t){return this.__data__.delete(t)},Rt.prototype.get=function(t){return this.__data__.get(t)},Rt.prototype.has=function(t){return this.__data__.has(t)},Rt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Nt){var n=r.__data__;if(!ht||n.length<199)return n.push([t,e]),this;r=this.__data__=new St(n)}return r.set(t,e),this};var Ft=st?z(st,Object):function(){return[]},kt=function(t){return tt.call(t)};function Bt(t,e){return!!(e=null==e?o: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||K)}function Ut(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function qt(t,e){return t===e||t!=t&&e!=e}(pt&&kt(new pt(new ArrayBuffer(1)))!=m||ht&&kt(new ht)!=l||dt&&kt(dt.resolve())!=h||gt&&kt(new gt)!=g||yt&&kt(new yt)!=b)&&(kt=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Ut(r):void 0;if(n)switch(n){case bt:return m;case _t:return l;case mt:return h;case wt:return g;case jt:return b}return e});var zt=Array.isArray;function Ht(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Gt(t)}var Vt=lt||function(){return!1};function Gt(t){var e=Jt(t)?tt.call(t):"";return e==f||e==s}function Jt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Kt(t){return Ht(t)?It(t):function(t){if(!Mt(t))return at(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Lt(t,!0,!0)}}(a,a.exports);var p=a.exports;const h=" ";function d(t){const e={value:t,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function g(t){return"number"==typeof t}function y(t){return"string"==typeof t}function v({str:t,idx:e=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),!t[e+1])return null;if(t[e+1]&&(t[e+1].trim()||r&&"\n\r".includes(t[e+1])||n&&t[e+1]===h))return e+1;if(t[e+2]&&(t[e+2].trim()||r&&"\n\r".includes(t[e+2])||n&&t[e+2]===h))return e+2;for(let o=e+1,i=t.length;o<i;o++)if(t[o].trim()||r&&"\n\r".includes(t[o])||n&&t[o]===h)return o;return null}function b(t,e=0){return v({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function _({str:t,idx:e,stopAtNewlines:r,stopAtRawNbsp:n}){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),e<1)return null;if(t[~-e]&&(t[~-e].trim()||r&&"\n\r".includes(t[~-e])||n&&t[~-e]===h))return~-e;if(t[e-2]&&(t[e-2].trim()||r&&"\n\r".includes(t[e-2])||n&&t[e-2]===h))return e-2;for(let o=e;o--;)if(t[o]&&(t[o].trim()||r&&"\n\r".includes(t[o])||n&&t[o]===h))return o;return null}function m(t,e=0){return _({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function w(t,e,r,n,o){if("string"!=typeof e||!e.length)return null;if("number"!=typeof r&&(r=0),"right"===t&&!e[r+1]||"left"===t&&!e[~-r])return null;let i=r;const u=[];let c,f,s,l=0;for(;l<o.length;){if(!y(o[l])||!o[l].length){l+=1;continue}const{value:r,optional:a,hungry:p}=d(o[l]),h="right"===t?b(e,i):m(e,i);if(!(n.i&&e[h].toLowerCase()===r.toLowerCase()||!n.i&&e[h]===r)){if(a){l+=1;continue}if(s){l+=1,s=void 0;continue}return null}{const o="right"===t?b(e,h):m(e,h);p&&(n.i&&e[o].toLowerCase()===r.toLowerCase()||!n.i&&e[o]===r)?s=!0:l+=1,"number"==typeof h&&"right"===t&&h>i+1?u.push([i+1,h]):"left"===t&&"number"==typeof h&&h<~-i&&u.unshift([h+1,i]),i=h,"right"===t?(void 0===c&&(c=h),f=h):(void 0===f&&(f=h),c=h)}}return void 0===c||void 0===f?null:{gaps:u,leftmostChar:c,rightmostChar:f}}const j={i:!1};function A(t,e,...r){if(!r||!r.length)throw new Error("string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?");let n;return n=l(r[0])?{...j,...r.shift()}:j,w("left",t,e,n,Array.from(r).reverse())}function O(t,e,...r){if(!r||!r.length)throw new Error("string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?");let n;return n=l(r[0])?{...j,...r.shift()}:j,w("right",t,e,n,r)}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&&0==+r)return null;let i=null,u=null;do{i="right"===t?O(e,"number"==typeof u?u:r,...o):A(e,"number"==typeof u?u:r,...o),null!==i&&(u="right"===t?i.rightmostChar:i.leftmostChar)}while(i);if(null!=u&&"right"===t&&(u+=1),null===u)return null;if("right"===t){if(e[u]&&e[u].trim())return u;const t=b(e,u);if(n&&0!==n.mode){if(1===n.mode)return u;if(2===n.mode){const t=e.slice(u);if(t.trim()||t.includes("\n")||t.includes("\r"))for(let t=u,r=e.length;t<r;t++)if(e[t].trim()||"\n\r".includes(e[t]))return t;return e.length}}else{if(t===u+1)return u;if(!(e.slice(u,t||e.length).trim()||e.slice(u,t||e.length).includes("\n")||e.slice(u,t||e.length).includes("\r")))return t?~-t:e.length;for(let t=u,r=e.length;t<r;t++)if("\n\r".includes(e[t]))return t}return t||e.length}if(e[u]&&e[~-u]&&e[~-u].trim())return u;const c=m(e,u);if(!n||0===n.mode){if(c===u-2)return u;if(e.slice(0,u).trim()||e.slice(0,u).includes("\n")||e.slice(0,u).includes("\r"))for(let t=u;t--;)if("\n\r".includes(e[t])||e[t].trim())return t+1+(e[t].trim()?1:0);return 0}if(1===n.mode)return u;if(2===n.mode){const t=e.slice(0,u);if(t.trim()||t.includes("\n")||t.includes("\r"))for(let t=u;t--;)if(e[t].trim()||"\n\r".includes(e[t]))return t+1;return 0}return null!==c?c+1:0}t.chompLeft=function(t,e,...r){if(!r.length||1===r.length&&l(r[0]))return null;const n={mode:0};if(l(r[0])){const o={...n,...p(r[0])};if(o.mode){if(y(o.mode)&&"0123".includes(o.mode))o.mode=Number.parseInt(o.mode,10);else if(!g(o.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 ${o.mode} (type ${typeof o.mode})`)}else o.mode=0;return x("left",t,e,o,p(r).slice(1))}return y(r[0])?x("left",t,e,n,p(r)):x("left",t,e,n,p(r).slice(1))},t.chompRight=function(t,e,...r){if(!r.length||1===r.length&&l(r[0]))return null;const n={mode:0};if(l(r[0])){const o={...n,...p(r[0])};if(o.mode){if(y(o.mode)&&"0123".includes(o.mode))o.mode=Number.parseInt(o.mode,10);else if(!g(o.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 ${o.mode} (type ${typeof o.mode})`)}else o.mode=0;return x("right",t,e,o,p(r).slice(1))}return y(r[0])?x("right",t,e,n,p(r)):x("right",t,e,n,p(r).slice(1))},t.left=m,t.leftSeq=A,t.leftStopAtNewLines=function(t,e){return _({str:t,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})},t.leftStopAtRawNbsp=function(t,e){return _({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})},t.right=b,t.rightSeq=O,t.rightStopAtNewLines=function(t,e){return v({str:t,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})},t.rightStopAtRawNbsp=function(t,e){return v({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})},t.version="5.0.3",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="undefined"!=typeof globalThis?globalThis:t||self).stringLeftRight={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n,o=Object.prototype,i=Function.prototype.toString,u=o.hasOwnProperty,c=i.call(Object),f=o.toString,s=(r=Object.getPrototypeOf,n=Object,function(t){return r(n(t))});var l=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=f.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=s(t);if(null===e)return!0;var r=u.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&i.call(r)==c},a={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",u="[object Boolean]",c="[object Date]",f="[object Function]",s="[object GeneratorFunction]",l="[object Map]",a="[object Number]",p="[object Object]",h="[object Promise]",d="[object RegExp]",g="[object Set]",y="[object String]",v="[object Symbol]",b="[object WeakMap]",_="[object ArrayBuffer]",m="[object DataView]",w="[object Float32Array]",j="[object Float64Array]",A="[object Int8Array]",O="[object Int16Array]",x="[object Int32Array]",N="[object Uint8Array]",S="[object Uint8ClampedArray]",R="[object Uint16Array]",I="[object Uint32Array]",$=/\w*$/,E=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,C={};C[i]=C["[object Array]"]=C[_]=C[m]=C[u]=C[c]=C[w]=C[j]=C[A]=C[O]=C[x]=C[l]=C[a]=C[p]=C[d]=C[g]=C[y]=C[v]=C[N]=C[S]=C[R]=C[I]=!0,C["[object Error]"]=C[f]=C[b]=!1;var P="object"==typeof self&&self&&self.Object===Object&&self,T="object"==typeof e&&e&&e.Object===Object&&e||P||Function("return this")(),W=r&&!r.nodeType&&r,D=W&&t&&!t.nodeType&&t,F=D&&D.exports===W;function k(t,e){return t.set(e[0],e[1]),t}function B(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 U(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function q(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function z(t,e){return function(r){return t(e(r))}}function H(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var V,G=Array.prototype,J=Function.prototype,K=Object.prototype,Q=T["__core-js_shared__"],X=(V=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Y=J.toString,Z=K.hasOwnProperty,tt=K.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=F?T.Buffer:void 0,nt=T.Symbol,ot=T.Uint8Array,it=z(Object.getPrototypeOf,Object),ut=Object.create,ct=K.propertyIsEnumerable,ft=G.splice,st=Object.getOwnPropertySymbols,lt=rt?rt.isBuffer:void 0,at=z(Object.keys,Object),pt=Dt(T,"DataView"),ht=Dt(T,"Map"),dt=Dt(T,"Promise"),gt=Dt(T,"Set"),yt=Dt(T,"WeakMap"),vt=Dt(Object,"create"),bt=Ut(pt),_t=Ut(ht),mt=Ut(dt),wt=Ut(gt),jt=Ut(yt),At=nt?nt.prototype:void 0,Ot=At?At.valueOf:void 0;function xt(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 Nt(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 St(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 Rt(t){this.__data__=new Nt(t)}function It(t,e){var r=zt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ht(t)}(t)&&Z.call(t,"callee")&&(!ct.call(t,"callee")||tt.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var u in t)!e&&!Z.call(t,u)||o&&("length"==u||Bt(u,n))||r.push(u);return r}function $t(t,e,r){var n=t[e];Z.call(t,e)&&qt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Et(t,e){for(var r=t.length;r--;)if(qt(t[r][0],e))return r;return-1}function Lt(t,e,r,n,o,h,b){var E;if(n&&(E=h?n(t,o,h,b):n(t)),void 0!==E)return E;if(!Jt(t))return t;var L=zt(t);if(L){if(E=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.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,E)}else{var P=kt(t),T=P==f||P==s;if(Vt(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(P==p||P==i||T&&!h){if(U(t))return h?t:{};if(E=function(t){return"function"!=typeof t.constructor||Mt(t)?{}:(e=it(t),Jt(e)?ut(e):{});var e}(T?{}:t),!e)return function(t,e){return Tt(t,Ft(t),e)}(t,function(t,e){return t&&Tt(e,Kt(e),t)}(E,t))}else{if(!C[P])return h?t:{};E=function(t,e,r,n){var o=t.constructor;switch(e){case _:return Pt(t);case u:case c:return new o(+t);case m:return function(t,e){var r=e?Pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case w:case j:case A:case O:case x:case N:case S:case R:case I:return function(t,e){var r=e?Pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case l:return function(t,e,r){return M(e?r(q(t),!0):q(t),k,new t.constructor)}(t,n,r);case a:case y:return new o(t);case d:return function(t){var e=new t.constructor(t.source,$.exec(t));return e.lastIndex=t.lastIndex,e}(t);case g:return function(t,e,r){return M(e?r(H(t),!0):H(t),B,new t.constructor)}(t,n,r);case v:return i=t,Ot?Object(Ot.call(i)):{}}var i}(t,P,Lt,e)}}b||(b=new Rt);var W=b.get(t);if(W)return W;if(b.set(t,E),!L)var D=r?function(t){return function(t,e,r){var n=e(t);return zt(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,Kt,Ft)}(t):Kt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(D||t,(function(o,i){D&&(o=t[i=o]),$t(E,i,Lt(o,e,r,n,i,t,b))})),E}function Ct(t){return!(!Jt(t)||function(t){return!!X&&X in t}(t))&&(Gt(t)||U(t)?et:E).test(Ut(t))}function Pt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Tt(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;$t(r,u,void 0===c?t[u]:c)}return r}function Wt(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 Ct(r)?r:void 0}xt.prototype.clear=function(){this.__data__=vt?vt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(vt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return vt?void 0!==e[t]:Z.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=vt&&void 0===e?n:e,this},Nt.prototype.clear=function(){this.__data__=[]},Nt.prototype.delete=function(t){var e=this.__data__,r=Et(e,t);return!(r<0)&&(r==e.length-1?e.pop():ft.call(e,r,1),!0)},Nt.prototype.get=function(t){var e=this.__data__,r=Et(e,t);return r<0?void 0:e[r][1]},Nt.prototype.has=function(t){return Et(this.__data__,t)>-1},Nt.prototype.set=function(t,e){var r=this.__data__,n=Et(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},St.prototype.clear=function(){this.__data__={hash:new xt,map:new(ht||Nt),string:new xt}},St.prototype.delete=function(t){return Wt(this,t).delete(t)},St.prototype.get=function(t){return Wt(this,t).get(t)},St.prototype.has=function(t){return Wt(this,t).has(t)},St.prototype.set=function(t,e){return Wt(this,t).set(t,e),this},Rt.prototype.clear=function(){this.__data__=new Nt},Rt.prototype.delete=function(t){return this.__data__.delete(t)},Rt.prototype.get=function(t){return this.__data__.get(t)},Rt.prototype.has=function(t){return this.__data__.has(t)},Rt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Nt){var n=r.__data__;if(!ht||n.length<199)return n.push([t,e]),this;r=this.__data__=new St(n)}return r.set(t,e),this};var Ft=st?z(st,Object):function(){return[]},kt=function(t){return tt.call(t)};function Bt(t,e){return!!(e=null==e?o: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||K)}function Ut(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function qt(t,e){return t===e||t!=t&&e!=e}(pt&&kt(new pt(new ArrayBuffer(1)))!=m||ht&&kt(new ht)!=l||dt&&kt(dt.resolve())!=h||gt&&kt(new gt)!=g||yt&&kt(new yt)!=b)&&(kt=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Ut(r):void 0;if(n)switch(n){case bt:return m;case _t:return l;case mt:return h;case wt:return g;case jt:return b}return e});var zt=Array.isArray;function Ht(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Gt(t)}var Vt=lt||function(){return!1};function Gt(t){var e=Jt(t)?tt.call(t):"";return e==f||e==s}function Jt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Kt(t){return Ht(t)?It(t):function(t){if(!Mt(t))return at(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Lt(t,!0,!0)}}(a,a.exports);var p=a.exports;const h=" ";function d(t){const e={value:t,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function g(t){return"number"==typeof t}function y(t){return"string"==typeof t}function v({str:t,idx:e=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),!t[e+1])return null;if(t[e+1]&&(t[e+1].trim()||r&&"\n\r".includes(t[e+1])||n&&t[e+1]===h))return e+1;if(t[e+2]&&(t[e+2].trim()||r&&"\n\r".includes(t[e+2])||n&&t[e+2]===h))return e+2;for(let o=e+1,i=t.length;o<i;o++)if(t[o].trim()||r&&"\n\r".includes(t[o])||n&&t[o]===h)return o;return null}function b(t,e=0){return v({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function _({str:t,idx:e,stopAtNewlines:r,stopAtRawNbsp:n}){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),e<1)return null;if(t[~-e]&&(t[~-e].trim()||r&&"\n\r".includes(t[~-e])||n&&t[~-e]===h))return~-e;if(t[e-2]&&(t[e-2].trim()||r&&"\n\r".includes(t[e-2])||n&&t[e-2]===h))return e-2;for(let o=e;o--;)if(t[o]&&(t[o].trim()||r&&"\n\r".includes(t[o])||n&&t[o]===h))return o;return null}function m(t,e=0){return _({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function w(t,e,r,n,o){if("string"!=typeof e||!e.length)return null;if("number"!=typeof r&&(r=0),"right"===t&&!e[r+1]||"left"===t&&!e[~-r])return null;let i=r;const u=[];let c,f,s,l=0;for(;l<o.length;){if(!y(o[l])||!o[l].length){l+=1;continue}const{value:r,optional:a,hungry:p}=d(o[l]),h="right"===t?b(e,i):m(e,i);if(!(n.i&&e[h].toLowerCase()===r.toLowerCase()||!n.i&&e[h]===r)){if(a){l+=1;continue}if(s){l+=1,s=void 0;continue}return null}{const o="right"===t?b(e,h):m(e,h);p&&(n.i&&e[o].toLowerCase()===r.toLowerCase()||!n.i&&e[o]===r)?s=!0:l+=1,"number"==typeof h&&"right"===t&&h>i+1?u.push([i+1,h]):"left"===t&&"number"==typeof h&&h<~-i&&u.unshift([h+1,i]),i=h,"right"===t?(void 0===c&&(c=h),f=h):(void 0===f&&(f=h),c=h)}}return void 0===c||void 0===f?null:{gaps:u,leftmostChar:c,rightmostChar:f}}const j={i:!1};function A(t,e,...r){if(!r||!r.length)throw new Error("string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?");let n;return n=l(r[0])?{...j,...r.shift()}:j,w("left",t,e,n,Array.from(r).reverse())}function O(t,e,...r){if(!r||!r.length)throw new Error("string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?");let n;return n=l(r[0])?{...j,...r.shift()}:j,w("right",t,e,n,r)}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&&0==+r)return null;let i=null,u=null;do{i="right"===t?O(e,"number"==typeof u?u:r,...o):A(e,"number"==typeof u?u:r,...o),null!==i&&(u="right"===t?i.rightmostChar:i.leftmostChar)}while(i);if(null!=u&&"right"===t&&(u+=1),null===u)return null;if("right"===t){if(e[u]&&e[u].trim())return u;const t=b(e,u);if(n&&0!==n.mode){if(1===n.mode)return u;if(2===n.mode){const t=e.slice(u);if(t.trim()||t.includes("\n")||t.includes("\r"))for(let t=u,r=e.length;t<r;t++)if(e[t].trim()||"\n\r".includes(e[t]))return t;return e.length}}else{if(t===u+1)return u;if(!(e.slice(u,t||e.length).trim()||e.slice(u,t||e.length).includes("\n")||e.slice(u,t||e.length).includes("\r")))return t?~-t:e.length;for(let t=u,r=e.length;t<r;t++)if("\n\r".includes(e[t]))return t}return t||e.length}if(e[u]&&e[~-u]&&e[~-u].trim())return u;const c=m(e,u);if(!n||0===n.mode){if(c===u-2)return u;if(e.slice(0,u).trim()||e.slice(0,u).includes("\n")||e.slice(0,u).includes("\r"))for(let t=u;t--;)if("\n\r".includes(e[t])||e[t].trim())return t+1+(e[t].trim()?1:0);return 0}if(1===n.mode)return u;if(2===n.mode){const t=e.slice(0,u);if(t.trim()||t.includes("\n")||t.includes("\r"))for(let t=u;t--;)if(e[t].trim()||"\n\r".includes(e[t]))return t+1;return 0}return null!==c?c+1:0}t.chompLeft=function(t,e,...r){if(!r.length||1===r.length&&l(r[0]))return null;const n={mode:0};if(l(r[0])){const o={...n,...p(r[0])};if(o.mode){if(y(o.mode)&&"0123".includes(o.mode))o.mode=Number.parseInt(o.mode,10);else if(!g(o.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 ${o.mode} (type ${typeof o.mode})`)}else o.mode=0;return x("left",t,e,o,p(r).slice(1))}return y(r[0])?x("left",t,e,n,p(r)):x("left",t,e,n,p(r).slice(1))},t.chompRight=function(t,e,...r){if(!r.length||1===r.length&&l(r[0]))return null;const n={mode:0};if(l(r[0])){const o={...n,...p(r[0])};if(o.mode){if(y(o.mode)&&"0123".includes(o.mode))o.mode=Number.parseInt(o.mode,10);else if(!g(o.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 ${o.mode} (type ${typeof o.mode})`)}else o.mode=0;return x("right",t,e,o,p(r).slice(1))}return y(r[0])?x("right",t,e,n,p(r)):x("right",t,e,n,p(r).slice(1))},t.left=m,t.leftSeq=A,t.leftStopAtNewLines=function(t,e){return _({str:t,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})},t.leftStopAtRawNbsp=function(t,e){return _({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})},t.right=b,t.rightSeq=O,t.rightStopAtNewLines=function(t,e){return v({str:t,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})},t.rightStopAtRawNbsp=function(t,e){return v({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})},t.version="5.0.7",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-left-right",
3
- "version": "5.0.3",
3
+ "version": "5.0.7",
4
4
  "description": "Looks up the first non-whitespace character to the left/right of a given index",
5
5
  "keywords": [
6
6
  "check",
@@ -37,13 +37,12 @@
37
37
  "types": "types/index.d.ts",
38
38
  "scripts": {
39
39
  "build": "rollup -c",
40
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
41
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
40
+ "build:esbuild": "node '../../scripts/esbuild.js'",
41
+ "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
42
+ "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
42
43
  "clean_types": "../../scripts/cleanTypes.js",
43
44
  "dev": "rollup -c --dev",
44
45
  "devunittest": "npm run dev && tap --only -R 'base'",
45
- "esbuild": "node '../../scripts/esbuild.js'",
46
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
47
46
  "format": "npm run lect && npm run prettier && npm run lint",
48
47
  "lect": "lect",
49
48
  "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
@@ -52,17 +51,14 @@
52
51
  "republish": "npm publish || :",
53
52
  "tap": "tap",
54
53
  "pretest": "npm run build",
55
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
54
+ "test": "npm run test:ci && npm run perf",
55
+ "test:ci": "npm run unittest && npm run test:examples && npm run format",
56
56
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
57
57
  "tsc": "tsc",
58
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
58
+ "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
59
59
  },
60
60
  "tap": {
61
61
  "check-coverage": false,
62
- "coverage-report": [
63
- "json-summary",
64
- "text"
65
- ],
66
62
  "node-arg": [
67
63
  "--no-warnings",
68
64
  "--experimental-loader",
@@ -85,7 +81,7 @@
85
81
  }
86
82
  },
87
83
  "dependencies": {
88
- "@babel/runtime": "^7.16.0",
84
+ "@babel/runtime": "^7.16.3",
89
85
  "lodash.clonedeep": "^4.5.0",
90
86
  "lodash.isplainobject": "^4.0.6"
91
87
  },
@@ -98,8 +94,8 @@
98
94
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
99
95
  "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
100
96
  "@babel/plugin-proposal-optional-chaining": "^7.16.0",
101
- "@babel/plugin-transform-runtime": "^7.16.0",
102
- "@babel/preset-env": "^7.16.0",
97
+ "@babel/plugin-transform-runtime": "^7.16.4",
98
+ "@babel/preset-env": "^7.16.4",
103
99
  "@babel/preset-typescript": "^7.16.0",
104
100
  "@babel/register": "^7.16.0",
105
101
  "@istanbuljs/esm-loader-hook": "^0.1.2",
@@ -111,25 +107,25 @@
111
107
  "@rollup/plugin-typescript": "^8.3.0",
112
108
  "@types/lodash.clonedeep": "^4.5.6",
113
109
  "@types/lodash.isplainobject": "^4.0.6",
114
- "@types/node": "^16.11.6",
110
+ "@types/node": "^16.11.10",
115
111
  "@types/tap": "^15.0.5",
116
- "@typescript-eslint/eslint-plugin": "^5.2.0",
117
- "@typescript-eslint/parser": "^5.2.0",
118
- "core-js": "^3.19.0",
112
+ "@typescript-eslint/eslint-plugin": "^5.5.0",
113
+ "@typescript-eslint/parser": "^5.5.0",
114
+ "core-js": "^3.19.2",
119
115
  "cross-env": "^7.0.3",
120
- "eslint": "^8.1.0",
121
- "lect": "^0.18.3",
122
- "rollup": "^2.59.0",
116
+ "eslint": "^8.3.0",
117
+ "lect": "^0.18.7",
118
+ "rollup": "^2.60.1",
123
119
  "rollup-plugin-ascii": "^0.0.3",
124
120
  "rollup-plugin-banner": "^0.2.1",
125
121
  "rollup-plugin-cleanup": "^3.2.1",
126
- "rollup-plugin-dts": "^4.0.0",
122
+ "rollup-plugin-dts": "^4.0.1",
127
123
  "rollup-plugin-terser": "^7.0.2",
128
- "tap": "^15.0.10",
124
+ "tap": "^15.1.5",
129
125
  "tslib": "^2.3.1",
130
- "typescript": "^4.4.4"
126
+ "typescript": "^4.5.2"
131
127
  },
132
128
  "engines": {
133
- "node": ">=12"
129
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
134
130
  }
135
131
  }