@splendidlabz/utils 1.11.6 → 1.12.1
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/dist/cjs/lib/http/index.cjs +100 -0
- package/dist/cjs/lib/http/status-text.cjs +98 -0
- package/dist/cjs/lib/index.cjs +472 -8
- package/dist/cjs/lib/promises/index.cjs +72 -15
- package/dist/cjs/lib/promises/reject.cjs +72 -13
- package/dist/cjs/lib/strings/index.cjs +396 -5
- package/dist/cjs/lib/strings/pluralize.cjs +372 -14
- package/dist/cjs/lib/strings/query-string.cjs +28 -5
- package/dist/esm/lib/http/index.js +1 -0
- package/dist/esm/lib/http/status-text.js +72 -0
- package/dist/esm/lib/index.js +1 -0
- package/dist/esm/lib/promises/reject.js +2 -2
- package/dist/esm/lib/strings/pluralize.js +366 -3
- package/dist/esm/lib/strings/query-string.js +27 -4
- package/dist/types/lib/http/index.d.cts +1 -0
- package/dist/types/lib/http/status-text.d.cts +73 -0
- package/dist/types/lib/index.d.cts +3 -2
- package/dist/types/lib/strings/index.d.cts +2 -2
- package/dist/types/lib/strings/pluralize.d.cts +24 -2
- package/dist/types/lib/strings/query-string.d.cts +10 -2
- package/package.json +3 -5
package/dist/cjs/lib/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(lib_exports, {
|
|
|
38
38
|
composeAsync: () => composeAsync,
|
|
39
39
|
concatMix: () => concatMix,
|
|
40
40
|
createMix: () => createMix,
|
|
41
|
+
createPluralize: () => createPluralize,
|
|
41
42
|
createSSE: () => createSSE,
|
|
42
43
|
curry: () => curry,
|
|
43
44
|
debounce: () => debounce,
|
|
@@ -61,6 +62,8 @@ __export(lib_exports, {
|
|
|
61
62
|
isHashedValue: () => isHashedValue,
|
|
62
63
|
isLastItem: () => isLastItem,
|
|
63
64
|
isObject: () => isObject,
|
|
65
|
+
isPlural: () => isPlural,
|
|
66
|
+
isSingular: () => isSingular,
|
|
64
67
|
joinWithConjunction: () => joinWithConjunction,
|
|
65
68
|
last: () => last,
|
|
66
69
|
lastArrayItem: () => lastArrayItem,
|
|
@@ -76,6 +79,7 @@ __export(lib_exports, {
|
|
|
76
79
|
omitEmpty: () => omitEmpty,
|
|
77
80
|
parseFullName: () => parseFullName,
|
|
78
81
|
parseJSON: () => parseJSON,
|
|
82
|
+
parseQueryString: () => parseQueryString,
|
|
79
83
|
parseSSE: () => parseSSE,
|
|
80
84
|
pipe: () => pipe,
|
|
81
85
|
pipeAsync: () => pipeAsync,
|
|
@@ -86,11 +90,14 @@ __export(lib_exports, {
|
|
|
86
90
|
sanitizeArray: () => sanitizeArray,
|
|
87
91
|
sanitizeObject: () => sanitizeObject,
|
|
88
92
|
shuffle: () => shuffle,
|
|
93
|
+
singular: () => singular,
|
|
89
94
|
sizeOf: () => sizeOf,
|
|
90
95
|
sort: () => sort,
|
|
91
96
|
splitArray: () => splitArray,
|
|
92
97
|
splitObject: () => splitObject,
|
|
93
98
|
splitUnit: () => splitUnit,
|
|
99
|
+
statusText: () => statusText,
|
|
100
|
+
statusTexts: () => statusTexts,
|
|
94
101
|
stripNumbers: () => stripNumbers,
|
|
95
102
|
throttle: () => throttle,
|
|
96
103
|
timeout: () => timeout,
|
|
@@ -643,6 +650,76 @@ function isHashedValue(value, type = "sha256") {
|
|
|
643
650
|
return null;
|
|
644
651
|
}
|
|
645
652
|
|
|
653
|
+
// src/lib/http/status-text.js
|
|
654
|
+
var statusTexts = {
|
|
655
|
+
100: "Continue",
|
|
656
|
+
101: "Switching Protocols",
|
|
657
|
+
102: "Processing",
|
|
658
|
+
103: "Early Hints",
|
|
659
|
+
200: "OK",
|
|
660
|
+
201: "Created",
|
|
661
|
+
202: "Accepted",
|
|
662
|
+
203: "Non-Authoritative Information",
|
|
663
|
+
204: "No Content",
|
|
664
|
+
205: "Reset Content",
|
|
665
|
+
206: "Partial Content",
|
|
666
|
+
207: "Multi-Status",
|
|
667
|
+
208: "Already Reported",
|
|
668
|
+
226: "IM Used",
|
|
669
|
+
300: "Multiple Choices",
|
|
670
|
+
301: "Moved Permanently",
|
|
671
|
+
302: "Found",
|
|
672
|
+
303: "See Other",
|
|
673
|
+
304: "Not Modified",
|
|
674
|
+
305: "Use Proxy",
|
|
675
|
+
307: "Temporary Redirect",
|
|
676
|
+
308: "Permanent Redirect",
|
|
677
|
+
400: "Bad Request",
|
|
678
|
+
401: "Unauthorized",
|
|
679
|
+
402: "Payment Required",
|
|
680
|
+
403: "Forbidden",
|
|
681
|
+
404: "Not Found",
|
|
682
|
+
405: "Method Not Allowed",
|
|
683
|
+
406: "Not Acceptable",
|
|
684
|
+
407: "Proxy Authentication Required",
|
|
685
|
+
408: "Request Timeout",
|
|
686
|
+
409: "Conflict",
|
|
687
|
+
410: "Gone",
|
|
688
|
+
411: "Length Required",
|
|
689
|
+
412: "Precondition Failed",
|
|
690
|
+
413: "Payload Too Large",
|
|
691
|
+
414: "URI Too Long",
|
|
692
|
+
415: "Unsupported Media Type",
|
|
693
|
+
416: "Range Not Satisfiable",
|
|
694
|
+
417: "Expectation Failed",
|
|
695
|
+
418: "I'm a Teapot",
|
|
696
|
+
421: "Misdirected Request",
|
|
697
|
+
422: "Unprocessable Entity",
|
|
698
|
+
423: "Locked",
|
|
699
|
+
424: "Failed Dependency",
|
|
700
|
+
425: "Too Early",
|
|
701
|
+
426: "Upgrade Required",
|
|
702
|
+
428: "Precondition Required",
|
|
703
|
+
429: "Too Many Requests",
|
|
704
|
+
431: "Request Header Fields Too Large",
|
|
705
|
+
451: "Unavailable For Legal Reasons",
|
|
706
|
+
500: "Internal Server Error",
|
|
707
|
+
501: "Not Implemented",
|
|
708
|
+
502: "Bad Gateway",
|
|
709
|
+
503: "Service Unavailable",
|
|
710
|
+
504: "Gateway Timeout",
|
|
711
|
+
505: "HTTP Version Not Supported",
|
|
712
|
+
506: "Variant Also Negotiates",
|
|
713
|
+
507: "Insufficient Storage",
|
|
714
|
+
508: "Loop Detected",
|
|
715
|
+
509: "Bandwidth Limit Exceeded",
|
|
716
|
+
510: "Not Extended",
|
|
717
|
+
511: "Network Authentication Required"
|
|
718
|
+
};
|
|
719
|
+
function statusText(code) {
|
|
720
|
+
return statusTexts[code];
|
|
721
|
+
}
|
|
722
|
+
|
|
646
723
|
// src/lib/objects/loop.js
|
|
647
724
|
function objectForEach(object, callback) {
|
|
648
725
|
Object.entries(object).forEach(([key, value]) => {
|
|
@@ -935,13 +1012,12 @@ function splitObject(obj, keys) {
|
|
|
935
1012
|
}
|
|
936
1013
|
|
|
937
1014
|
// src/lib/promises/reject.js
|
|
938
|
-
var import_statuses = __toESM(require("statuses"), 1);
|
|
939
1015
|
function reject(props, { includeStack = true } = {}) {
|
|
940
|
-
const { status, statusText, body, message } = props;
|
|
1016
|
+
const { status, statusText: statusText2, body, message } = props;
|
|
941
1017
|
const e = new Error();
|
|
942
1018
|
const err = {
|
|
943
1019
|
status,
|
|
944
|
-
statusText:
|
|
1020
|
+
statusText: statusText2 || status && statusText(status),
|
|
945
1021
|
body,
|
|
946
1022
|
message,
|
|
947
1023
|
stack: includeStack && e.stack
|
|
@@ -1054,17 +1130,398 @@ function parseFullName(name) {
|
|
|
1054
1130
|
}
|
|
1055
1131
|
|
|
1056
1132
|
// src/lib/strings/pluralize.js
|
|
1057
|
-
|
|
1058
|
-
|
|
1133
|
+
function sanitizeRule(rule) {
|
|
1134
|
+
if (typeof rule === "string") return new RegExp("^" + rule + "$", "i");
|
|
1135
|
+
return rule;
|
|
1136
|
+
}
|
|
1137
|
+
function restoreCase(word, token) {
|
|
1138
|
+
if (word === token) return token;
|
|
1139
|
+
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
1140
|
+
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
1141
|
+
if (word[0] === word[0].toUpperCase()) {
|
|
1142
|
+
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
1143
|
+
}
|
|
1144
|
+
return token.toLowerCase();
|
|
1145
|
+
}
|
|
1146
|
+
function interpolate(str, args) {
|
|
1147
|
+
return str.replace(/\$(\d{1,2})/g, (match, index) => args[index] || "");
|
|
1148
|
+
}
|
|
1149
|
+
function replace(word, rule) {
|
|
1150
|
+
return word.replace(rule[0], function(match, index) {
|
|
1151
|
+
const result = interpolate(rule[1], arguments);
|
|
1152
|
+
if (match === "") return restoreCase(word[index - 1], result);
|
|
1153
|
+
return restoreCase(match, result);
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
function sanitizeWord(token, word, rules, uncountables) {
|
|
1157
|
+
if (!token.length || uncountables.hasOwnProperty(token)) return word;
|
|
1158
|
+
let len = rules.length;
|
|
1159
|
+
while (len--) {
|
|
1160
|
+
const rule = rules[len];
|
|
1161
|
+
if (rule[0].test(word)) return replace(word, rule);
|
|
1162
|
+
}
|
|
1163
|
+
return word;
|
|
1164
|
+
}
|
|
1165
|
+
function replaceWord(replaceMap, keepMap, rules, uncountables) {
|
|
1166
|
+
return function(word) {
|
|
1167
|
+
const token = word.toLowerCase();
|
|
1168
|
+
if (keepMap.hasOwnProperty(token)) return restoreCase(word, token);
|
|
1169
|
+
if (replaceMap.hasOwnProperty(token)) {
|
|
1170
|
+
return restoreCase(word, replaceMap[token]);
|
|
1171
|
+
}
|
|
1172
|
+
return sanitizeWord(token, word, rules, uncountables);
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
function checkWord(replaceMap, keepMap, rules, uncountables) {
|
|
1176
|
+
return function(word) {
|
|
1177
|
+
const token = word.toLowerCase();
|
|
1178
|
+
if (keepMap.hasOwnProperty(token)) return true;
|
|
1179
|
+
if (replaceMap.hasOwnProperty(token)) return false;
|
|
1180
|
+
return sanitizeWord(token, token, rules, uncountables) === token;
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
var BASE_IRREGULAR = [
|
|
1184
|
+
// Pronouns.
|
|
1185
|
+
["I", "we"],
|
|
1186
|
+
["me", "us"],
|
|
1187
|
+
["he", "they"],
|
|
1188
|
+
["she", "they"],
|
|
1189
|
+
["them", "them"],
|
|
1190
|
+
["myself", "ourselves"],
|
|
1191
|
+
["yourself", "yourselves"],
|
|
1192
|
+
["itself", "themselves"],
|
|
1193
|
+
["herself", "themselves"],
|
|
1194
|
+
["himself", "themselves"],
|
|
1195
|
+
["themself", "themselves"],
|
|
1196
|
+
["is", "are"],
|
|
1197
|
+
["was", "were"],
|
|
1198
|
+
["has", "have"],
|
|
1199
|
+
["this", "these"],
|
|
1200
|
+
["that", "those"],
|
|
1201
|
+
// Words ending with a consonant and `o`.
|
|
1202
|
+
["echo", "echoes"],
|
|
1203
|
+
["dingo", "dingoes"],
|
|
1204
|
+
["volcano", "volcanoes"],
|
|
1205
|
+
["tornado", "tornadoes"],
|
|
1206
|
+
["torpedo", "torpedoes"],
|
|
1207
|
+
// Ends with `us`.
|
|
1208
|
+
["genus", "genera"],
|
|
1209
|
+
["viscus", "viscera"],
|
|
1210
|
+
// Ends with `ma`.
|
|
1211
|
+
["stigma", "stigmata"],
|
|
1212
|
+
["stoma", "stomata"],
|
|
1213
|
+
["dogma", "dogmata"],
|
|
1214
|
+
["lemma", "lemmata"],
|
|
1215
|
+
["schema", "schemata"],
|
|
1216
|
+
["anathema", "anathemata"],
|
|
1217
|
+
// Other irregular rules.
|
|
1218
|
+
["ox", "oxen"],
|
|
1219
|
+
["axe", "axes"],
|
|
1220
|
+
["die", "dice"],
|
|
1221
|
+
["yes", "yeses"],
|
|
1222
|
+
["foot", "feet"],
|
|
1223
|
+
["eave", "eaves"],
|
|
1224
|
+
["goose", "geese"],
|
|
1225
|
+
["tooth", "teeth"],
|
|
1226
|
+
["quiz", "quizzes"],
|
|
1227
|
+
["human", "humans"],
|
|
1228
|
+
["proof", "proofs"],
|
|
1229
|
+
["carve", "carves"],
|
|
1230
|
+
["valve", "valves"],
|
|
1231
|
+
["looey", "looies"],
|
|
1232
|
+
["thief", "thieves"],
|
|
1233
|
+
["groove", "grooves"],
|
|
1234
|
+
["pickaxe", "pickaxes"],
|
|
1235
|
+
["passerby", "passersby"]
|
|
1236
|
+
];
|
|
1237
|
+
var BASE_PLURAL = [
|
|
1238
|
+
[/s?$/i, "s"],
|
|
1239
|
+
// eslint-disable-next-line no-control-regex
|
|
1240
|
+
[/[^\u0000-\u007F]$/i, "$0"],
|
|
1241
|
+
[/([^aeiou]ese)$/i, "$1"],
|
|
1242
|
+
[/(ax|test)is$/i, "$1es"],
|
|
1243
|
+
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
|
1244
|
+
[/(e[mn]u)s?$/i, "$1s"],
|
|
1245
|
+
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
|
1246
|
+
[
|
|
1247
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
1248
|
+
"$1i"
|
|
1249
|
+
],
|
|
1250
|
+
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
|
1251
|
+
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
|
1252
|
+
[/(her|at|gr)o$/i, "$1oes"],
|
|
1253
|
+
[
|
|
1254
|
+
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,
|
|
1255
|
+
"$1a"
|
|
1256
|
+
],
|
|
1257
|
+
[
|
|
1258
|
+
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,
|
|
1259
|
+
"$1a"
|
|
1260
|
+
],
|
|
1261
|
+
[/sis$/i, "ses"],
|
|
1262
|
+
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
|
1263
|
+
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
|
1264
|
+
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
|
1265
|
+
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
|
1266
|
+
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
|
1267
|
+
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
|
1268
|
+
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
|
1269
|
+
[/(child)(?:ren)?$/i, "$1ren"],
|
|
1270
|
+
[/eaux$/i, "$0"],
|
|
1271
|
+
[/m[ae]n$/i, "men"],
|
|
1272
|
+
["thou", "you"]
|
|
1273
|
+
];
|
|
1274
|
+
var BASE_SINGULAR = [
|
|
1275
|
+
[/s$/i, ""],
|
|
1276
|
+
[/(ss)$/i, "$1"],
|
|
1277
|
+
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
|
|
1278
|
+
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
1279
|
+
[/ies$/i, "y"],
|
|
1280
|
+
[
|
|
1281
|
+
/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,
|
|
1282
|
+
"$1ie"
|
|
1283
|
+
],
|
|
1284
|
+
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
1285
|
+
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
1286
|
+
[/(seraph|cherub)im$/i, "$1"],
|
|
1287
|
+
[
|
|
1288
|
+
/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,
|
|
1289
|
+
"$1"
|
|
1290
|
+
],
|
|
1291
|
+
[
|
|
1292
|
+
/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,
|
|
1293
|
+
"$1sis"
|
|
1294
|
+
],
|
|
1295
|
+
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
1296
|
+
[/(test)(?:is|es)$/i, "$1is"],
|
|
1297
|
+
[
|
|
1298
|
+
/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,
|
|
1299
|
+
"$1us"
|
|
1300
|
+
],
|
|
1301
|
+
[
|
|
1302
|
+
/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,
|
|
1303
|
+
"$1um"
|
|
1304
|
+
],
|
|
1305
|
+
[
|
|
1306
|
+
/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,
|
|
1307
|
+
"$1on"
|
|
1308
|
+
],
|
|
1309
|
+
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
1310
|
+
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
1311
|
+
[/(matr|append)ices$/i, "$1ix"],
|
|
1312
|
+
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
1313
|
+
[/(child)ren$/i, "$1"],
|
|
1314
|
+
[/(eau)x?$/i, "$1"],
|
|
1315
|
+
[/men$/i, "man"]
|
|
1316
|
+
];
|
|
1317
|
+
var BASE_UNCOUNTABLE = [
|
|
1318
|
+
// Singular words with no plurals.
|
|
1319
|
+
"adulthood",
|
|
1320
|
+
"advice",
|
|
1321
|
+
"agenda",
|
|
1322
|
+
"aid",
|
|
1323
|
+
"aircraft",
|
|
1324
|
+
"alcohol",
|
|
1325
|
+
"ammo",
|
|
1326
|
+
"analytics",
|
|
1327
|
+
"anime",
|
|
1328
|
+
"athletics",
|
|
1329
|
+
"audio",
|
|
1330
|
+
"bison",
|
|
1331
|
+
"blood",
|
|
1332
|
+
"bream",
|
|
1333
|
+
"buffalo",
|
|
1334
|
+
"butter",
|
|
1335
|
+
"carp",
|
|
1336
|
+
"cash",
|
|
1337
|
+
"chassis",
|
|
1338
|
+
"chess",
|
|
1339
|
+
"clothing",
|
|
1340
|
+
"cod",
|
|
1341
|
+
"commerce",
|
|
1342
|
+
"cooperation",
|
|
1343
|
+
"corps",
|
|
1344
|
+
"debris",
|
|
1345
|
+
"diabetes",
|
|
1346
|
+
"digestion",
|
|
1347
|
+
"elk",
|
|
1348
|
+
"energy",
|
|
1349
|
+
"equipment",
|
|
1350
|
+
"excretion",
|
|
1351
|
+
"expertise",
|
|
1352
|
+
"firmware",
|
|
1353
|
+
"flounder",
|
|
1354
|
+
"fun",
|
|
1355
|
+
"gallows",
|
|
1356
|
+
"garbage",
|
|
1357
|
+
"graffiti",
|
|
1358
|
+
"hardware",
|
|
1359
|
+
"headquarters",
|
|
1360
|
+
"health",
|
|
1361
|
+
"herpes",
|
|
1362
|
+
"highjinks",
|
|
1363
|
+
"homework",
|
|
1364
|
+
"housework",
|
|
1365
|
+
"information",
|
|
1366
|
+
"jeans",
|
|
1367
|
+
"justice",
|
|
1368
|
+
"kudos",
|
|
1369
|
+
"labour",
|
|
1370
|
+
"literature",
|
|
1371
|
+
"machinery",
|
|
1372
|
+
"mackerel",
|
|
1373
|
+
"mail",
|
|
1374
|
+
"media",
|
|
1375
|
+
"mews",
|
|
1376
|
+
"moose",
|
|
1377
|
+
"music",
|
|
1378
|
+
"mud",
|
|
1379
|
+
"manga",
|
|
1380
|
+
"news",
|
|
1381
|
+
"only",
|
|
1382
|
+
"personnel",
|
|
1383
|
+
"pike",
|
|
1384
|
+
"plankton",
|
|
1385
|
+
"pliers",
|
|
1386
|
+
"police",
|
|
1387
|
+
"pollution",
|
|
1388
|
+
"premises",
|
|
1389
|
+
"rain",
|
|
1390
|
+
"research",
|
|
1391
|
+
"rice",
|
|
1392
|
+
"salmon",
|
|
1393
|
+
"scissors",
|
|
1394
|
+
"series",
|
|
1395
|
+
"sewage",
|
|
1396
|
+
"shambles",
|
|
1397
|
+
"shrimp",
|
|
1398
|
+
"software",
|
|
1399
|
+
"species",
|
|
1400
|
+
"staff",
|
|
1401
|
+
"swine",
|
|
1402
|
+
"tennis",
|
|
1403
|
+
"traffic",
|
|
1404
|
+
"transportation",
|
|
1405
|
+
"trout",
|
|
1406
|
+
"tuna",
|
|
1407
|
+
"wealth",
|
|
1408
|
+
"welfare",
|
|
1409
|
+
"whiting",
|
|
1410
|
+
"wildebeest",
|
|
1411
|
+
"wildlife",
|
|
1412
|
+
"you",
|
|
1413
|
+
/pok[eé]mon$/i,
|
|
1414
|
+
// Regexes.
|
|
1415
|
+
/[^aeiou]ese$/i,
|
|
1416
|
+
// "chinese", "japanese"
|
|
1417
|
+
/deer$/i,
|
|
1418
|
+
// "deer", "reindeer"
|
|
1419
|
+
/fish$/i,
|
|
1420
|
+
// "fish", "blowfish", "angelfish"
|
|
1421
|
+
/measles$/i,
|
|
1422
|
+
/o[iu]s$/i,
|
|
1423
|
+
// "carnivorous"
|
|
1424
|
+
/pox$/i,
|
|
1425
|
+
// "chickpox", "smallpox"
|
|
1426
|
+
/sheep$/i
|
|
1427
|
+
];
|
|
1428
|
+
function createPluralize(config = {}) {
|
|
1429
|
+
const pluralRules = [];
|
|
1430
|
+
const singularRules = [];
|
|
1431
|
+
const uncountables = {};
|
|
1432
|
+
const irregularPlurals = {};
|
|
1433
|
+
const irregularSingles = {};
|
|
1434
|
+
for (const [single, plur] of [
|
|
1435
|
+
...BASE_IRREGULAR,
|
|
1436
|
+
...config.irregular || []
|
|
1437
|
+
]) {
|
|
1438
|
+
irregularSingles[single.toLowerCase()] = plur.toLowerCase();
|
|
1439
|
+
irregularPlurals[plur.toLowerCase()] = single.toLowerCase();
|
|
1440
|
+
}
|
|
1441
|
+
for (const [rule, replacement] of [...BASE_PLURAL, ...config.plural || []]) {
|
|
1442
|
+
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
1443
|
+
}
|
|
1444
|
+
for (const [rule, replacement] of [
|
|
1445
|
+
...BASE_SINGULAR,
|
|
1446
|
+
...config.singular || []
|
|
1447
|
+
]) {
|
|
1448
|
+
singularRules.push([sanitizeRule(rule), replacement]);
|
|
1449
|
+
}
|
|
1450
|
+
for (const word of [...BASE_UNCOUNTABLE, ...config.uncountable || []]) {
|
|
1451
|
+
if (typeof word === "string") {
|
|
1452
|
+
uncountables[word.toLowerCase()] = true;
|
|
1453
|
+
} else {
|
|
1454
|
+
pluralRules.push([sanitizeRule(word), "$0"]);
|
|
1455
|
+
singularRules.push([sanitizeRule(word), "$0"]);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
const plural2 = replaceWord(
|
|
1459
|
+
irregularSingles,
|
|
1460
|
+
irregularPlurals,
|
|
1461
|
+
pluralRules,
|
|
1462
|
+
uncountables
|
|
1463
|
+
);
|
|
1464
|
+
const singular2 = replaceWord(
|
|
1465
|
+
irregularPlurals,
|
|
1466
|
+
irregularSingles,
|
|
1467
|
+
singularRules,
|
|
1468
|
+
uncountables
|
|
1469
|
+
);
|
|
1470
|
+
const isPlural2 = checkWord(
|
|
1471
|
+
irregularSingles,
|
|
1472
|
+
irregularPlurals,
|
|
1473
|
+
pluralRules,
|
|
1474
|
+
uncountables
|
|
1475
|
+
);
|
|
1476
|
+
const isSingular2 = checkWord(
|
|
1477
|
+
irregularPlurals,
|
|
1478
|
+
irregularSingles,
|
|
1479
|
+
singularRules,
|
|
1480
|
+
uncountables
|
|
1481
|
+
);
|
|
1482
|
+
function pluralize2(word, count, inclusive) {
|
|
1483
|
+
const out = count === 1 ? singular2(word) : plural2(word);
|
|
1484
|
+
return (inclusive ? count + " " : "") + out;
|
|
1485
|
+
}
|
|
1486
|
+
return Object.assign(pluralize2, { plural: plural2, singular: singular2, isPlural: isPlural2, isSingular: isSingular2 });
|
|
1487
|
+
}
|
|
1488
|
+
var pluralize = createPluralize();
|
|
1489
|
+
var plural = pluralize.plural;
|
|
1490
|
+
var singular = pluralize.singular;
|
|
1491
|
+
var isPlural = pluralize.isPlural;
|
|
1492
|
+
var isSingular = pluralize.isSingular;
|
|
1059
1493
|
|
|
1060
1494
|
// src/lib/strings/query-string.js
|
|
1061
1495
|
function toQueryString(object) {
|
|
1062
1496
|
const searchParams = new URLSearchParams(object);
|
|
1063
1497
|
return searchParams.toString();
|
|
1064
1498
|
}
|
|
1065
|
-
function
|
|
1066
|
-
|
|
1067
|
-
|
|
1499
|
+
function parseQueryString(string = "") {
|
|
1500
|
+
const query = string.startsWith("?") ? string.slice(1) : string;
|
|
1501
|
+
const result = {};
|
|
1502
|
+
if (!query) return result;
|
|
1503
|
+
const decode = (str) => decodeURIComponent(str.replace(/\+/g, " "));
|
|
1504
|
+
const keyToPath = (key) => key.replace(/\]/g, "").split("[").map(decode);
|
|
1505
|
+
for (const pair of query.split("&")) {
|
|
1506
|
+
if (!pair) continue;
|
|
1507
|
+
const eq = pair.indexOf("=");
|
|
1508
|
+
const path = keyToPath(eq === -1 ? pair : pair.slice(0, eq));
|
|
1509
|
+
const value = decode(eq === -1 ? "" : pair.slice(eq + 1));
|
|
1510
|
+
let current = result;
|
|
1511
|
+
path.forEach((key, i) => {
|
|
1512
|
+
const index = Array.isArray(current) ? Number(key) : key;
|
|
1513
|
+
if (i === path.length - 1) {
|
|
1514
|
+
if (key === "") current.push(value);
|
|
1515
|
+
else current[index] = value;
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
const next = path[i + 1];
|
|
1519
|
+
const childIsArray = next === "" || /^\d+$/.test(next);
|
|
1520
|
+
if (current[index] == null) current[index] = childIsArray ? [] : {};
|
|
1521
|
+
current = current[index];
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
return result;
|
|
1068
1525
|
}
|
|
1069
1526
|
function stripNumbers(string) {
|
|
1070
1527
|
return string.replace(/\d*/, "");
|
|
@@ -1100,6 +1557,7 @@ function getSymbolValue(object, description) {
|
|
|
1100
1557
|
composeAsync,
|
|
1101
1558
|
concatMix,
|
|
1102
1559
|
createMix,
|
|
1560
|
+
createPluralize,
|
|
1103
1561
|
createSSE,
|
|
1104
1562
|
curry,
|
|
1105
1563
|
debounce,
|
|
@@ -1123,6 +1581,8 @@ function getSymbolValue(object, description) {
|
|
|
1123
1581
|
isHashedValue,
|
|
1124
1582
|
isLastItem,
|
|
1125
1583
|
isObject,
|
|
1584
|
+
isPlural,
|
|
1585
|
+
isSingular,
|
|
1126
1586
|
joinWithConjunction,
|
|
1127
1587
|
last,
|
|
1128
1588
|
lastArrayItem,
|
|
@@ -1138,6 +1598,7 @@ function getSymbolValue(object, description) {
|
|
|
1138
1598
|
omitEmpty,
|
|
1139
1599
|
parseFullName,
|
|
1140
1600
|
parseJSON,
|
|
1601
|
+
parseQueryString,
|
|
1141
1602
|
parseSSE,
|
|
1142
1603
|
pipe,
|
|
1143
1604
|
pipeAsync,
|
|
@@ -1148,11 +1609,14 @@ function getSymbolValue(object, description) {
|
|
|
1148
1609
|
sanitizeArray,
|
|
1149
1610
|
sanitizeObject,
|
|
1150
1611
|
shuffle,
|
|
1612
|
+
singular,
|
|
1151
1613
|
sizeOf,
|
|
1152
1614
|
sort,
|
|
1153
1615
|
splitArray,
|
|
1154
1616
|
splitObject,
|
|
1155
1617
|
splitUnit,
|
|
1618
|
+
statusText,
|
|
1619
|
+
statusTexts,
|
|
1156
1620
|
stripNumbers,
|
|
1157
1621
|
throttle,
|
|
1158
1622
|
timeout,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/lib/promises/index.js
|
|
@@ -33,9 +23,6 @@ __export(promises_exports, {
|
|
|
33
23
|
});
|
|
34
24
|
module.exports = __toCommonJS(promises_exports);
|
|
35
25
|
|
|
36
|
-
// src/lib/promises/reject.js
|
|
37
|
-
var import_statuses = __toESM(require("statuses"), 1);
|
|
38
|
-
|
|
39
26
|
// src/lib/objects/omit-empty.js
|
|
40
27
|
function omitEmpty(obj, shallow = false) {
|
|
41
28
|
if (typeof obj !== "object" || obj === null) return obj;
|
|
@@ -50,13 +37,83 @@ function omitEmpty(obj, shallow = false) {
|
|
|
50
37
|
return result;
|
|
51
38
|
}
|
|
52
39
|
|
|
40
|
+
// src/lib/http/status-text.js
|
|
41
|
+
var statusTexts = {
|
|
42
|
+
100: "Continue",
|
|
43
|
+
101: "Switching Protocols",
|
|
44
|
+
102: "Processing",
|
|
45
|
+
103: "Early Hints",
|
|
46
|
+
200: "OK",
|
|
47
|
+
201: "Created",
|
|
48
|
+
202: "Accepted",
|
|
49
|
+
203: "Non-Authoritative Information",
|
|
50
|
+
204: "No Content",
|
|
51
|
+
205: "Reset Content",
|
|
52
|
+
206: "Partial Content",
|
|
53
|
+
207: "Multi-Status",
|
|
54
|
+
208: "Already Reported",
|
|
55
|
+
226: "IM Used",
|
|
56
|
+
300: "Multiple Choices",
|
|
57
|
+
301: "Moved Permanently",
|
|
58
|
+
302: "Found",
|
|
59
|
+
303: "See Other",
|
|
60
|
+
304: "Not Modified",
|
|
61
|
+
305: "Use Proxy",
|
|
62
|
+
307: "Temporary Redirect",
|
|
63
|
+
308: "Permanent Redirect",
|
|
64
|
+
400: "Bad Request",
|
|
65
|
+
401: "Unauthorized",
|
|
66
|
+
402: "Payment Required",
|
|
67
|
+
403: "Forbidden",
|
|
68
|
+
404: "Not Found",
|
|
69
|
+
405: "Method Not Allowed",
|
|
70
|
+
406: "Not Acceptable",
|
|
71
|
+
407: "Proxy Authentication Required",
|
|
72
|
+
408: "Request Timeout",
|
|
73
|
+
409: "Conflict",
|
|
74
|
+
410: "Gone",
|
|
75
|
+
411: "Length Required",
|
|
76
|
+
412: "Precondition Failed",
|
|
77
|
+
413: "Payload Too Large",
|
|
78
|
+
414: "URI Too Long",
|
|
79
|
+
415: "Unsupported Media Type",
|
|
80
|
+
416: "Range Not Satisfiable",
|
|
81
|
+
417: "Expectation Failed",
|
|
82
|
+
418: "I'm a Teapot",
|
|
83
|
+
421: "Misdirected Request",
|
|
84
|
+
422: "Unprocessable Entity",
|
|
85
|
+
423: "Locked",
|
|
86
|
+
424: "Failed Dependency",
|
|
87
|
+
425: "Too Early",
|
|
88
|
+
426: "Upgrade Required",
|
|
89
|
+
428: "Precondition Required",
|
|
90
|
+
429: "Too Many Requests",
|
|
91
|
+
431: "Request Header Fields Too Large",
|
|
92
|
+
451: "Unavailable For Legal Reasons",
|
|
93
|
+
500: "Internal Server Error",
|
|
94
|
+
501: "Not Implemented",
|
|
95
|
+
502: "Bad Gateway",
|
|
96
|
+
503: "Service Unavailable",
|
|
97
|
+
504: "Gateway Timeout",
|
|
98
|
+
505: "HTTP Version Not Supported",
|
|
99
|
+
506: "Variant Also Negotiates",
|
|
100
|
+
507: "Insufficient Storage",
|
|
101
|
+
508: "Loop Detected",
|
|
102
|
+
509: "Bandwidth Limit Exceeded",
|
|
103
|
+
510: "Not Extended",
|
|
104
|
+
511: "Network Authentication Required"
|
|
105
|
+
};
|
|
106
|
+
function statusText(code) {
|
|
107
|
+
return statusTexts[code];
|
|
108
|
+
}
|
|
109
|
+
|
|
53
110
|
// src/lib/promises/reject.js
|
|
54
111
|
function reject(props, { includeStack = true } = {}) {
|
|
55
|
-
const { status, statusText, body, message } = props;
|
|
112
|
+
const { status, statusText: statusText2, body, message } = props;
|
|
56
113
|
const e = new Error();
|
|
57
114
|
const err = {
|
|
58
115
|
status,
|
|
59
|
-
statusText:
|
|
116
|
+
statusText: statusText2 || status && statusText(status),
|
|
60
117
|
body,
|
|
61
118
|
message,
|
|
62
119
|
stack: includeStack && e.stack
|