Skip to content

Commit

Permalink
feat(@142vip/utils): 引入qs模块,导出vipQs对象,支持stringifyparse方法
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdapl committed Oct 5, 2024
1 parent 47f5fd0 commit 007fc90
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"@inquirer/confirm": "^3.1.15",
"ansi-colors": "^4.1.3",
"dayjs": "^1.11.11",
"inquirer": "7"
"inquirer": "7",
"qs": "^6.13.0"
},
"publishConfig": {
"access": "public",
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './shell'
export * from './inquirer'
export * from './git'
export * from './docker'
export * from './qs'
25 changes: 25 additions & 0 deletions packages/utils/src/qs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { BooleanOptional, IParseOptions, IStringifyOptions } from 'qs'
import qs from 'qs'

/**
* 序列化 query string
* @param obj
* @param options
*/
function stringify(obj: any, options?: IStringifyOptions<BooleanOptional>) {
return qs.stringify(obj, options)
}

/**
* 解析 query string
* @param str
* @param options
*/
function parse(str: string, options?: IParseOptions<BooleanOptional> & { decoder?: never | undefined }) {
return qs.parse(str, options)
}

export const vipQs = {
stringify,
parse,
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 007fc90

Please sign in to comment.