1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1× 1× 1× | 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 }) |