fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at feat/use-query-options 21 lines 619 B view raw
1import type { FileInfo, Plugin } from '../types'; 2import { ParserError } from '../util/errors'; 3 4const TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i; 5 6export const textParser: Plugin = { 7 canHandle: (file: FileInfo) => 8 (typeof file.data === 'string' || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url), 9 handler(file: FileInfo): string { 10 if (typeof file.data === 'string') { 11 return file.data; 12 } 13 14 if (!Buffer.isBuffer(file.data)) { 15 throw new ParserError('data is not text', file.url); 16 } 17 18 return file.data.toString('utf-8'); 19 }, 20 name: 'text', 21};