@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.
- package/eslint/package.json +1 -1
- package/fetch/package.json +2 -2
- package/index.cjs.js +38 -14
- package/index.esm.js +38 -14
- package/package.json +1 -1
- package/test/package.json +2 -2
package/eslint/package.json
CHANGED
package/fetch/package.json
CHANGED
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
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
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
|
|
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
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
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
|
|
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