File tree 1 file changed +4
-4
lines changed 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 1
- import 'https://cdnjs.cloudflare.com/ajax/libs/pako/2.1.0/pako.min.js'
2
-
3
1
export default class CSV {
4
2
/**
5
3
* @param {Array<Array<*>> } data data
@@ -112,10 +110,12 @@ export default class CSV {
112
110
static async load ( value , config = { } ) {
113
111
if ( typeof value === 'string' ) {
114
112
const response = await fetch ( value )
115
- const buf = await response . arrayBuffer ( )
113
+ let buf = await response . arrayBuffer ( )
116
114
const decoder = new TextDecoder ( config . encoding || 'utf-8' )
117
115
if ( value . endsWith ( '.gz' ) ) {
118
- return CSV . parse ( decoder . decode ( pako . ungzip ( buf ) ) , config )
116
+ const ds = new DecompressionStream ( 'gzip' )
117
+ const decompressedStream = new Blob ( [ buf ] ) . stream ( ) . pipeThrough ( ds )
118
+ buf = await new Response ( decompressedStream ) . arrayBuffer ( )
119
119
}
120
120
return CSV . parse ( decoder . decode ( buf ) , config )
121
121
} else if ( value instanceof File ) {
You can’t perform that action at this time.
0 commit comments