(define: Record<string, any>)
| 203 | * the global `window` object directly. |
| 204 | */ |
| 205 | export function serializeDefine(define: Record<string, any>): string { |
| 206 | let res = `{` |
| 207 | const keys = Object.keys(define).sort() |
| 208 | for (let i = 0; i < keys.length; i++) { |
| 209 | const key = keys[i] |
| 210 | const val = define[key] |
| 211 | res += `${JSON.stringify(key)}: ${handleDefineValue(val)}` |
| 212 | if (i !== keys.length - 1) { |
| 213 | res += `, ` |
| 214 | } |
| 215 | } |
| 216 | return res + `}` |
| 217 | } |
| 218 | |
| 219 | function handleDefineValue(value: any): string { |
| 220 | if (typeof value === 'undefined') return 'undefined' |
no test coverage detected