( source?: T, )
| 27 | * Create a null-prototype object, optionally copying from source. |
| 28 | */ |
| 29 | export function createNullProtoObject<T extends object>( |
| 30 | source?: T, |
| 31 | ): { [K in keyof T]: T[K] } { |
| 32 | if (!source) return Object.create(null) |
| 33 | const obj = Object.create(null) |
| 34 | for (const key of Object.keys(source)) { |
| 35 | if (isSafeKey(key)) obj[key] = (source as Record<string, unknown>)[key] |
| 36 | } |
| 37 | return obj |
| 38 | } |
no test coverage detected