From 2e49a165504662c482c335184e1313115c717074 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Fri, 9 Feb 2024 12:50:13 +0000 Subject: [PATCH] utils: adjust checkOpts to work in proxied envs --- src/utils.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index ec12452..a7e8a7d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -152,17 +152,12 @@ export function concatBytes(...arrays: Uint8Array[]): Uint8Array { return res; } -// Check if object doens't have custom constructor (like Uint8Array/Array) -const isPlainObject = (obj: any) => - Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object; - type EmptyObj = {}; export function checkOpts( defaults: T1, - opts?: T2 + opts: T2 ): T1 & T2 { - if (opts !== undefined && (typeof opts !== 'object' || !isPlainObject(opts))) - throw new Error('options must be object or undefined'); + if (opts == null || typeof opts !== 'object') throw new Error('options must be defined'); const merged = Object.assign(defaults, opts); return merged as T1 & T2; }