crocks
Version:
A collection of well known Algebraic Datatypes for your utter enjoyment.
27 lines (21 loc) • 711 B
JavaScript
/** @license ISC License (c) copyright 2017 original and current authors */
/** @author Ian Hofmann-Hicks (evil) */
var curry = require('../core/curry')
var isDefined = require('../core/isDefined')
var isEmpty = require('../core/isEmpty')
var isInteger = require('../core/isInteger')
var isNil = require('../core/isNil')
var isString = require('../core/isString')
// hasProp : (String | Integer) -> a -> Boolean
function hasProp(key, x) {
if(!(isString(key) && !isEmpty(key) || isInteger(key))) {
throw new TypeError(
'hasProp: Non-empty String or Integer required for first argument'
)
}
if(isNil(x)) {
return false
}
return isDefined(x[key])
}
module.exports = curry(hasProp)