@dereekb/util 13.11.11 → 13.11.12

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/eslint",
3
- "version": "13.11.11",
3
+ "version": "13.11.12",
4
4
  "peerDependencies": {
5
5
  "@typescript-eslint/utils": "8.59.0"
6
6
  },
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "13.11.11",
3
+ "version": "13.11.12",
4
4
  "peerDependencies": {
5
- "@dereekb/util": "13.11.11",
5
+ "@dereekb/util": "13.11.12",
6
6
  "make-error": "^1.3.6",
7
7
  "fast-content-type-parse": "^3.0.0"
8
8
  },
package/index.cjs.js CHANGED
@@ -6284,21 +6284,45 @@ function joinStrings(input) {
6284
6284
  * @param limit - maximum number of resulting segments; overflow segments are rejoined with the separator
6285
6285
  * @returns array of string segments, with length at most equal to limit
6286
6286
  */ function splitJoinRemainder(input, separator, limit) {
6287
- var split = input.split(separator);
6288
- var components = [];
6289
- if (split.length > 1) {
6290
- var hasItemsToMerge = split.length > limit;
6291
- var stopIndex = hasItemsToMerge ? limit - 1 : split.length;
6292
- for(var i = 0; i < stopIndex; i += 1){
6293
- components.push(split[i]);
6294
- }
6295
- if (hasItemsToMerge) {
6296
- components.push(split.slice(stopIndex).join(separator));
6297
- }
6298
- } else {
6299
- components.push(split[0]);
6287
+ var result;
6288
+ switch(limit){
6289
+ case 1:
6290
+ result = [
6291
+ input
6292
+ ];
6293
+ break;
6294
+ case 2:
6295
+ {
6296
+ var splitIndex = input.indexOf(separator);
6297
+ result = splitIndex < 0 ? [
6298
+ input
6299
+ ] : [
6300
+ input.slice(0, splitIndex),
6301
+ input.slice(splitIndex + separator.length)
6302
+ ];
6303
+ break;
6304
+ }
6305
+ default:
6306
+ {
6307
+ var split = input.split(separator);
6308
+ var components = [];
6309
+ if (split.length > 1) {
6310
+ var hasItemsToMerge = split.length > limit;
6311
+ var stopIndex = hasItemsToMerge ? limit - 1 : split.length;
6312
+ for(var i = 0; i < stopIndex; i += 1){
6313
+ components.push(split[i]);
6314
+ }
6315
+ if (hasItemsToMerge) {
6316
+ components.push(split.slice(stopIndex).join(separator));
6317
+ }
6318
+ } else {
6319
+ components.push(split[0]);
6320
+ }
6321
+ result = components;
6322
+ break;
6323
+ }
6300
6324
  }
6301
- return components;
6325
+ return result;
6302
6326
  }
6303
6327
  /**
6304
6328
  * Creates a {@link JoinStringsInstance} that joins arrays of strings using the configured delimiter.
package/index.esm.js CHANGED
@@ -6282,21 +6282,45 @@ function joinStrings(input) {
6282
6282
  * @param limit - maximum number of resulting segments; overflow segments are rejoined with the separator
6283
6283
  * @returns array of string segments, with length at most equal to limit
6284
6284
  */ function splitJoinRemainder(input, separator, limit) {
6285
- var split = input.split(separator);
6286
- var components = [];
6287
- if (split.length > 1) {
6288
- var hasItemsToMerge = split.length > limit;
6289
- var stopIndex = hasItemsToMerge ? limit - 1 : split.length;
6290
- for(var i = 0; i < stopIndex; i += 1){
6291
- components.push(split[i]);
6292
- }
6293
- if (hasItemsToMerge) {
6294
- components.push(split.slice(stopIndex).join(separator));
6295
- }
6296
- } else {
6297
- components.push(split[0]);
6285
+ var result;
6286
+ switch(limit){
6287
+ case 1:
6288
+ result = [
6289
+ input
6290
+ ];
6291
+ break;
6292
+ case 2:
6293
+ {
6294
+ var splitIndex = input.indexOf(separator);
6295
+ result = splitIndex < 0 ? [
6296
+ input
6297
+ ] : [
6298
+ input.slice(0, splitIndex),
6299
+ input.slice(splitIndex + separator.length)
6300
+ ];
6301
+ break;
6302
+ }
6303
+ default:
6304
+ {
6305
+ var split = input.split(separator);
6306
+ var components = [];
6307
+ if (split.length > 1) {
6308
+ var hasItemsToMerge = split.length > limit;
6309
+ var stopIndex = hasItemsToMerge ? limit - 1 : split.length;
6310
+ for(var i = 0; i < stopIndex; i += 1){
6311
+ components.push(split[i]);
6312
+ }
6313
+ if (hasItemsToMerge) {
6314
+ components.push(split.slice(stopIndex).join(separator));
6315
+ }
6316
+ } else {
6317
+ components.push(split[0]);
6318
+ }
6319
+ result = components;
6320
+ break;
6321
+ }
6298
6322
  }
6299
- return components;
6323
+ return result;
6300
6324
  }
6301
6325
  /**
6302
6326
  * Creates a {@link JoinStringsInstance} that joins arrays of strings using the configured delimiter.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "13.11.11",
3
+ "version": "13.11.12",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./test": {
package/test/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dereekb/util/test",
3
- "version": "13.11.11",
3
+ "version": "13.11.12",
4
4
  "peerDependencies": {
5
- "@dereekb/util": "13.11.11",
5
+ "@dereekb/util": "13.11.12",
6
6
  "make-error": "^1.3.6"
7
7
  },
8
8
  "exports": {