fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 13 lines 463 B view raw
1import type { FileInfo, Plugin } from '../types'; 2 3const BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i; 4 5export const binaryParser: Plugin = { 6 canHandle: (file: FileInfo) => Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url), 7 handler: (file: FileInfo): Buffer => 8 Buffer.isBuffer(file.data) 9 ? file.data 10 : // This will reject if data is anything other than a string or typed array 11 Buffer.from(file.data), 12 name: 'binary', 13};