Skip to content

Commit

Permalink
fix(react native): Move getBitrate func to fix crash in react native (#…
Browse files Browse the repository at this point in the history
…290)

React Native engine doesn't allow declaring functions in nested lexical scopes e.g. switches.
it throws `Strict mode does not allow function declarations in a lexically nested statement` error
  • Loading branch information
Khaled authored and fent committed Feb 23, 2018
1 parent a6ff6bc commit cf1ab21
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/util.js
Expand Up @@ -119,6 +119,10 @@ exports.chooseFormat = (formats, options) => {

var format;
var quality = options.quality || 'highest';
function getBitrate(f) {
let s = f.bitrate.split('-');
return parseFloat(s[s.length - 1], 10);
}
switch (quality) {
case 'highest':
format = formats[0];
Expand All @@ -140,10 +144,6 @@ exports.chooseFormat = (formats, options) => {
break;

case 'highestvideo':
function getBitrate(f) {
let s = f.bitrate.split('-');
return parseFloat(s[s.length - 1], 10);
}
formats = exports.filterFormats(formats, 'video');
format = null;
for (let f of formats) {
Expand Down

0 comments on commit cf1ab21

Please sign in to comment.