@daysnap/utils
Version:
16 lines (14 loc) • 402 B
TypeScript
/**
* 格式化字符串参数,一般用来处理 api path params
* const url = 'api/v1/user/{id}'
* const { path, rest } = formatPathParams(url, { id: 123, xxx: 1 })
* path = 'api/v1/user/123'
* rest = { xxx: 1 }
*/
declare function formatPathParams(path: string, params?: Record<string, any>): {
path: string;
rest: {
[x: string]: any;
};
};
export { formatPathParams };