Skip to content

Commit 86506e3

Browse files
MasterOdindpopp07
authored andcommitted
refactor: remove unused helper function from stt/v1 (#950)
* the removed method is `formatChunk`, which was only used by deprecated methods that have been removed from the service
1 parent 02fb8c9 commit 86506e3

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

speech-to-text/v1.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,6 @@ function isAnalyzed(corporaList: GeneratedSpeechToTextV1.Corpora): boolean {
4747
return corporaList.corpora.some(record => record['status'] === 'analyzed');
4848
}
4949

50-
/**
51-
* @private
52-
* @param chunk
53-
* @return {any}
54-
*/
55-
function formatChunk(chunk: string) {
56-
// Convert the string into an array
57-
let result = chunk;
58-
59-
// Check if in the stream doesn't have
60-
// two results together and parse them
61-
if (!result || result.indexOf('}{') === -1) {
62-
return JSON.parse(result);
63-
}
64-
65-
// Check if we can parse the response
66-
try {
67-
result = '[' + result.replace(/}{/g, '},{') + ']';
68-
result = JSON.parse(result);
69-
return result[result.length - 1];
70-
} catch (e) {
71-
// if it fails, then this isn't valid json (or a concatenated list of valid json) - just return the original string
72-
}
73-
74-
return result;
75-
}
76-
7750
class SpeechToTextV1 extends GeneratedSpeechToTextV1 {
7851
static ERR_NO_CORPORA = 'ERR_NO_CORPORA';
7952
static ERR_TIMEOUT = 'ERR_TIMEOUT';

0 commit comments

Comments
 (0)