Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const BSON = require('bson-ext')
const Long = BSON.Long
const _ = require('lodash')
exports.describeTypes = function (doc) {
if (doc._bsontype) {
return doc._bsontype
} else if (Array.isArray(doc)) {
const types = doc.map(exports.describeTypes)
const uniqueTypes = _.uniqWith(types, _.isEqual)
if (uniqueTypes.length > 1) {
//throw new Error('arrays containing multiple data types are not allowed')
}
if (_.isUndefined(uniqueTypes[0])) {
return []
}
return uniqueTypes
} else if (typeof doc === 'object') {