all files / oak/lib/ util.js

37.5% Statements 3/8
0% Branches 0/6
0% Functions 0/1
37.5% Lines 3/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                          
const _ = require('lodash')
 
function toBoolean (v) {
  if (!v) {
    return false
  }
  if (typeof v === 'number' || typeof v === 'boolean') {
    return !!v
  }
  return _.replace(_.trim(v.toLowerCase()), /[""'']/ig, '') === 'true'
}
 
_.mixin({
  'toBoolean': toBoolean
})