conductor
Version:
A modern & functional JavaScript utility library
17 lines (15 loc) • 349 B
JavaScript
const curry = require('./curry')
const type = require('./type')
const has = (key, collection) => {
switch (type(collection)) {
case 'map':
case 'set':
return collection.has(key)
case 'array':
return key <= collection.length - 1
case 'object':
default:
return collection.hasOwnProperty(key)
}
}
module.exports = curry(has)