rubico
Version:
[a]synchronous functional programming
34 lines (29 loc) • 841 B
JavaScript
/**
* rubico v2.6.2
* https://github.com/a-synchronous/rubico
* (c) 2019-2024 Richard Tong
* rubico may be freely distributed under the MIT license.
*/
(function (root, has) {
if (typeof module == 'object') (module.exports = has) // CommonJS
else if (typeof define == 'function') define(() => has) // AMD
else (root.has = has) // Browser
}(typeof globalThis == 'object' ? globalThis : this, (function () { 'use strict'
// (object Object, key string) -> boolean
const objectHas = function (object, key) {
return object[key] != null
}
const has = key => function hasKey(container) {
if (container == null) {
return false
}
if (typeof container.has == 'function') {
return container.has(key)
}
if (container.constructor == Object) {
return objectHas(container, key)
}
return false
}
return has
}())))