Skip to content

Commit d24e7d6

Browse files
committed
refactor: createAddStream
1 parent 312f8df commit d24e7d6

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

lib/solr.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
} from './types';
1616
import { Duplex } from 'stream';
1717
import { request } from 'undici';
18+
import undici from 'undici';
19+
import stream from 'stream';
1820

1921
const oldRequest = require('request');
2022
const format = require('./utils/format');
@@ -300,10 +302,13 @@ export class Client {
300302
method: 'POST',
301303
headers: headers,
302304
};
303-
const jsonStreamStringify = JSONStream.stringify();
304-
const postRequest = oldRequest(optionsRequest);
305-
jsonStreamStringify.pipe(postRequest);
306-
return duplexer(jsonStreamStringify, postRequest);
305+
return stream.compose(
306+
JSONStream.stringify(),
307+
undici.pipeline(optionsRequest, ({ statusCode, headers, body }) => {
308+
// TODO:
309+
return body
310+
})
311+
)
307312
}
308313

309314
/**

0 commit comments

Comments
 (0)