Skip to content

Commit 06103df

Browse files
JustinBeckwithNimJay
authored andcommitted
fix(deps): drop dependency on through2 (#388)
1 parent be447e6 commit 06103df

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

dialogflow/detect.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
const util = require('util');
1919
const fs = require('fs');
2020
const {struct} = require('pb-util');
21-
const pump = require('pump');
22-
const through2 = require('through2');
21+
const {Transform, pipeline} = require('stream');
22+
23+
const pump = util.promisify(pipeline);
2324

2425
function detectTextIntent(projectId, sessionId, queries, languageCode) {
2526
// [START dialogflow_detect_intent_text]
@@ -164,7 +165,7 @@ async function detectAudioIntent(
164165
// [END dialogflow_detect_intent_audio]
165166
}
166167

167-
function streamingDetectIntent(
168+
async function streamingDetectIntent(
168169
projectId,
169170
sessionId,
170171
filename,
@@ -227,11 +228,14 @@ function streamingDetectIntent(
227228

228229
// Stream an audio file from disk to the Conversation API, e.g.
229230
// "./resources/audio.raw"
230-
pump(
231+
await pump(
231232
fs.createReadStream(filename),
232233
// Format the audio stream into the request format.
233-
through2.obj((obj, _, next) => {
234-
next(null, {inputAudio: obj});
234+
new Transform({
235+
objectMode: true,
236+
transform: (obj, _, next) => {
237+
next(null, {inputAudio: obj});
238+
},
235239
}),
236240
detectStream
237241
);

dialogflow/package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
"resources"
1010
],
1111
"engines": {
12-
"node": ">=8.0.0"
12+
"node": ">=10.0.0"
1313
},
1414
"scripts": {
1515
"test": "mocha system-test --timeout=600000"
1616
},
1717
"dependencies": {
1818
"dialogflow": "^0.10.2",
1919
"pb-util": "^0.1.0",
20-
"pump": "^3.0.0",
21-
"through2": "^3.0.0",
2220
"uuid": "^3.3.2",
2321
"yargs": "^13.0.0"
2422
},

0 commit comments

Comments
 (0)