Skip to content

Commit

Permalink
refactor: remove unused helper function from stt/v1 (#950)
Browse files Browse the repository at this point in the history
* the removed method is `formatChunk`, which was only used by deprecated methods that have been removed from the service
  • Loading branch information
MasterOdin authored and dpopp07 committed Sep 12, 2019
1 parent 02fb8c9 commit 86506e3
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions speech-to-text/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,6 @@ function isAnalyzed(corporaList: GeneratedSpeechToTextV1.Corpora): boolean {
return corporaList.corpora.some(record => record['status'] === 'analyzed');
}

/**
* @private
* @param chunk
* @return {any}
*/
function formatChunk(chunk: string) {
// Convert the string into an array
let result = chunk;

// Check if in the stream doesn't have
// two results together and parse them
if (!result || result.indexOf('}{') === -1) {
return JSON.parse(result);
}

// Check if we can parse the response
try {
result = '[' + result.replace(/}{/g, '},{') + ']';
result = JSON.parse(result);
return result[result.length - 1];
} catch (e) {
// if it fails, then this isn't valid json (or a concatenated list of valid json) - just return the original string
}

return result;
}

class SpeechToTextV1 extends GeneratedSpeechToTextV1 {
static ERR_NO_CORPORA = 'ERR_NO_CORPORA';
static ERR_TIMEOUT = 'ERR_TIMEOUT';
Expand Down

0 comments on commit 86506e3

Please sign in to comment.