@newdash/newdash
Version:
javascript/typescript utility library
36 lines (35 loc) • 973 B
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.has = void 0;
const hasPath_1 = __importDefault(require("./hasPath"));
const baseHas_1 = require("./.internal/baseHas");
/**
* Checks if `key` is a direct property of `object`.
*
* @since 5.3.0
* @category Object
* @param object The object to query.
* @param path The key to check.
* @returns Returns `true` if `key` exists, else `false`.
* @see [[hasIn]],[[hasPath]],[[hasPathIn]]
* @example
*
* ```js
* const object = { 'a': { 'b': 2 } }
* const other = create({ 'a': create({ 'b': 2 }) })
*
* has(object, 'a')
* // => true
*
* has(other, 'a')
* // => false
* ```
*/
function has(object, path) {
return object != null && (0, hasPath_1.default)(object, path, baseHas_1.baseHas);
}
exports.has = has;
exports.default = has;