@@ -34,7 +34,7 @@ import fs from 'fs'
3434 * ```
3535 */
3636const $readJSON = async ( filePath : string , options : JsonInputOptionsNode = { } ) => {
37- const { method, headers } = { method : "GET" , headers : { } , ...options }
37+ const { method, headers, frameConfig } = { method : "GET" , headers : { } , frameConfig : { } , ...options }
3838
3939 if ( filePath . startsWith ( "http" ) || filePath . startsWith ( "https" ) ) {
4040
@@ -44,7 +44,7 @@ const $readJSON = async (filePath: string, options: JsonInputOptionsNode = {}) =
4444 throw new Error ( `Failed to load ${ filePath } ` )
4545 }
4646 response . json ( ) . then ( json => {
47- resolve ( new DataFrame ( json ) ) ;
47+ resolve ( new DataFrame ( json , frameConfig ) ) ;
4848 } ) ;
4949 } ) . catch ( ( err ) => {
5050 throw new Error ( err )
@@ -54,7 +54,7 @@ const $readJSON = async (filePath: string, options: JsonInputOptionsNode = {}) =
5454 } else {
5555 return new Promise ( resolve => {
5656 const file = fs . readFileSync ( filePath , "utf8" )
57- const df = new DataFrame ( JSON . parse ( file ) ) ;
57+ const df = new DataFrame ( JSON . parse ( file ) , frameConfig ) ;
5858 resolve ( df ) ;
5959 } ) ;
6060 }
@@ -80,14 +80,14 @@ const $streamJSON = async (
8080 callback : ( df : DataFrame ) => void ,
8181 options ?: request . RequiredUriUrl & request . CoreOptions ,
8282) => {
83- const { method, headers } = { method : "GET" , headers : { } , ...options }
83+ const { method, headers, frameConfig } = { method : "GET" , headers : { } , frameConfig : { } , ...options }
8484 if ( filePath . startsWith ( "http" ) || filePath . startsWith ( "https" ) ) {
8585 return new Promise ( resolve => {
8686 let count = - 1
8787 const dataStream = request ( { url : filePath , method, headers } )
8888 const pipeline = dataStream . pipe ( parser ( ) ) . pipe ( streamArray ( ) ) ;
8989 pipeline . on ( 'data' , ( { value } ) => {
90- const df = new DataFrame ( [ value ] , { index : [ count ++ ] } ) ;
90+ const df = new DataFrame ( [ value ] , { ... frameConfig , index : [ count ++ ] } ) ;
9191 callback ( df ) ;
9292 } ) ;
9393 pipeline . on ( 'end' , ( ) => resolve ( null ) ) ;
@@ -99,7 +99,7 @@ const $streamJSON = async (
9999 const fileStream = fs . createReadStream ( filePath )
100100 const pipeline = fileStream . pipe ( parser ( ) ) . pipe ( streamArray ( ) ) ;
101101 pipeline . on ( 'data' , ( { value } ) => {
102- const df = new DataFrame ( [ value ] , { index : [ count ++ ] } ) ;
102+ const df = new DataFrame ( [ value ] , { ... frameConfig , index : [ count ++ ] } ) ;
103103 callback ( df ) ;
104104 } ) ;
105105 pipeline . on ( 'end' , ( ) => resolve ( null ) ) ;
0 commit comments