Archived
1
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
api-ts-gen/lib/utils/qStringify.ts
sup39 85c026ba01 object-type properties conversion in req func
Change Full#advance and implement Full#advanced
2020-08-17 13:12:34 +08:00

15 lines
519 B
TypeScript

import * as Qs0 from 'qs';
const options0 = {
filter(prefix: string, value: any) {
const con = value?.constructor;
if (con === null || con === Array || con === Object) return value;
if (con === Date) return value.toJSON();
// use Class.toString() if defined explicitly
return con.prototype?.hasOwnProperty('toString') ? value.toString() : value;
},
};
export function qStringify(obj: any, options?: Qs0.IStringifyOptions) {
return Qs0.stringify(obj, Object.assign({}, options0, options));
}