File tree Expand file tree Collapse file tree
.cache/Microsoft/DeveloperTools
.openvscode-server/extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 4a0953a5-7172-4699-889a-56bf53a2388d
Original file line number Diff line number Diff line change 1+ []
Original file line number Diff line number Diff line change 44 * @description Research library module.
55 */
66import JSZip from "jszip" ;
7- import grab from "grab-url" ;
7+
8+ /**
9+ * Fetch wrapper for grabbing binary content
10+ */
11+ async function grab ( url : string , options : { responseType ?: string ; timeout ?: number } = { } ) {
12+ const timeout = options . timeout ? options . timeout * 1000 : 10000 ;
13+ const controller = new AbortController ( ) ;
14+ const timeoutId = setTimeout ( ( ) => controller . abort ( ) , timeout ) ;
15+
16+ try {
17+ const response = await fetch ( url , {
18+ signal : controller . signal ,
19+ } ) ;
20+ clearTimeout ( timeoutId ) ;
21+
22+ if ( ! response . ok ) {
23+ throw new Error ( `HTTP ${ response . status } ` ) ;
24+ }
25+
26+ if ( options . responseType === "arraybuffer" ) {
27+ return await response . arrayBuffer ( ) ;
28+ }
29+ return await response . text ( ) ;
30+ } catch ( error ) {
31+ clearTimeout ( timeoutId ) ;
32+ throw error ;
33+ }
34+ }
835
936/**
1037 * Configuration options for DOCX parsing
You can’t perform that action at this time.
0 commit comments