cafe-utility 9.5.0 → 9.7.0
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/index.d.ts +3 -1
- package/index.js +10 -11
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -160,6 +160,7 @@ declare function resolveVariableWithDefaultSyntax(string: string, key: string, v
|
|
|
160
160
|
declare function resolveRemainingVariablesWithDefaults(string: string, prefix?: string, separator?: string): string;
|
|
161
161
|
declare function resolveMarkdownLinks(string: string, transformer: (label: string, link: string) => string): string;
|
|
162
162
|
declare function toQueryString(object: Record<string, any>, questionMark?: boolean): string;
|
|
163
|
+
declare function buildUrl(baseUrl?: string | null, path?: string | null, query?: Record<string, any> | null): string;
|
|
163
164
|
declare function parseCsv(string: string, delimiter?: string, quote?: string): string[];
|
|
164
165
|
declare function humanizeProgress(state: Progress): string;
|
|
165
166
|
declare function waitFor(predicate: () => Promise<boolean>, waitLength: number, maxWaits: number): Promise<boolean>;
|
|
@@ -210,7 +211,7 @@ declare function getPreLine(string: string): string;
|
|
|
210
211
|
declare function containsWord(string: string, word: string): boolean;
|
|
211
212
|
declare function containsWords(string: string, words: string[]): boolean;
|
|
212
213
|
declare function getCached<T>(key: string, ttlMillis: number, handler: () => Promise<T>): Promise<T>;
|
|
213
|
-
declare function joinUrl(...parts:
|
|
214
|
+
declare function joinUrl(...parts: unknown[]): string;
|
|
214
215
|
declare function sortObject<T>(object: CafeObject<T>): CafeObject<T>;
|
|
215
216
|
declare function sortArray<T>(array: T[]): T[];
|
|
216
217
|
declare function sortAny(any: unknown): unknown;
|
|
@@ -543,6 +544,7 @@ export declare const Strings: {
|
|
|
543
544
|
linesMatchInOrder: typeof linesMatchInOrder;
|
|
544
545
|
represent: typeof represent;
|
|
545
546
|
resolveMarkdownLinks: typeof resolveMarkdownLinks;
|
|
547
|
+
buildUrl: typeof buildUrl;
|
|
546
548
|
};
|
|
547
549
|
export declare const Assertions: {
|
|
548
550
|
asEqual: typeof asEqual;
|
package/index.js
CHANGED
|
@@ -1140,6 +1140,10 @@ function toQueryString(object, questionMark = true) {
|
|
|
1140
1140
|
return queryString ? (questionMark ? '?' : '') + queryString : ''
|
|
1141
1141
|
}
|
|
1142
1142
|
|
|
1143
|
+
function buildUrl(baseUrl, path, query) {
|
|
1144
|
+
return joinUrl(baseUrl, path) + toQueryString(query || {})
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1143
1147
|
function parseCsv(string, delimiter = ',', quote = '"') {
|
|
1144
1148
|
const items = []
|
|
1145
1149
|
let buffer = ''
|
|
@@ -1390,16 +1394,10 @@ async function getCached(key, ttlMillis, handler) {
|
|
|
1390
1394
|
}
|
|
1391
1395
|
|
|
1392
1396
|
function joinUrl(...parts) {
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
continue
|
|
1398
|
-
}
|
|
1399
|
-
const starts = part[0] === '/'
|
|
1400
|
-
const ends = part[part.length - 1] === '/'
|
|
1401
|
-
url += '/' + part.slice(starts ? 1 : 0, ends ? -1 : undefined)
|
|
1402
|
-
}
|
|
1397
|
+
const url = parts
|
|
1398
|
+
.filter(part => part && isString(part))
|
|
1399
|
+
.join('/')
|
|
1400
|
+
.replace(/([^:]\/)\/+/g, '$1')
|
|
1403
1401
|
return url
|
|
1404
1402
|
}
|
|
1405
1403
|
|
|
@@ -2496,7 +2494,8 @@ exports.Strings = {
|
|
|
2496
2494
|
lineMatches,
|
|
2497
2495
|
linesMatchInOrder,
|
|
2498
2496
|
represent,
|
|
2499
|
-
resolveMarkdownLinks
|
|
2497
|
+
resolveMarkdownLinks,
|
|
2498
|
+
buildUrl
|
|
2500
2499
|
}
|
|
2501
2500
|
|
|
2502
2501
|
exports.Assertions = {
|