Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const dataTypeDefs = (() => {
const defs = [];
if (globalThis.ArrayBuffer !== undefined)
defs.push({ type: ArrayBuffer, lengthOf: (arg: ArrayBuffer) => arg.byteLength });
if (globalThis.Buffer !== undefined)
defs.push({ type: Buffer, lengthOf: (arg: Buffer) => arg.length }); // MUST be before Uint8Array
if (globalThis.Uint8Array !== undefined)
defs.push({ type: Uint8Array, lengthOf: (arg: Uint8Array) => arg.length });
if (globalThis.File !== undefined) {
defs.push({ type: File, lengthOf: (arg: File) => arg.size }); // MUST be before FilePonyfill and Blob
defs.push({ type: FilePonyfill, lengthOf: (arg: FilePonyfill) => arg.size }); // MUST be before Blob
}
if (globalThis.Blob !== undefined)
defs.push({ type: Blob, lengthOf: (arg: Blob) => arg.size });
return defs;
})();
export const getConstructorName = (constructor: Object): string => {
if (constructor === ArrayBuffer)
return 'ArrayBuffer';
if (globalThis.Buffer && constructor === Buffer)
return 'Buffer';
if (constructor === Uint8Array)
return 'Uint8Array';
if (globalThis.File && (constructor === File || constructor === FilePonyfill)) // must be before Blob
return 'File';
if (globalThis.Blob && constructor === Blob)
return 'Blob';
throw new InternalError('Assertion error: unhandled type');
};