6.7.0 - Alpha6 - Scrapers 工具支持打印数据变更详情
This commit is contained in:
@@ -18,7 +18,7 @@ export function bytes2GiB(bytes, fractionDigits = 2) {
|
||||
* @example
|
||||
* // https://example.com?a=1&b=2
|
||||
* url('https://example.com', { a: 1, b: 2 });
|
||||
*
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {Object} query
|
||||
* @returns {string}
|
||||
@@ -26,7 +26,7 @@ export function bytes2GiB(bytes, fractionDigits = 2) {
|
||||
export function buildUrl(url, query) {
|
||||
if (!query) return url;
|
||||
const q = Object.entries(query)
|
||||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
||||
.map(([ key, value ]) => `${key}=${encodeURIComponent(value)}`)
|
||||
.join('&');
|
||||
return `${url}?${q}`;
|
||||
}
|
||||
@@ -41,3 +41,21 @@ export function buildUrl(url, query) {
|
||||
export function escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an object into a string representation where each key-value pair
|
||||
* is formatted as `"key": "value"` and separated by newline characters.<br>
|
||||
* zh-CN:<br>
|
||||
* 将对象转换为字符串表示形式, 每个键值对, 以 `"key": "value"` 的格式呈现并用换行符分隔.
|
||||
*
|
||||
* @example string
|
||||
* "name": "John"
|
||||
* "age": "30"
|
||||
* "city": "New York"
|
||||
*
|
||||
* @param {Object} o
|
||||
* @return {string}
|
||||
*/
|
||||
export function objectToLines(o) {
|
||||
return Object.entries(o).map(([ key, value ]) => `"${key}": "${value}"`).join(`\n`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user