moltres-utils
Version:
Utils for Moltres apps
32 lines (23 loc) • 866 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _isSymbol = _interopRequireDefault(require("./isSymbol"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/** Used to match property names within property paths. */
const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
const reIsPlainProp = /^\w*$/;
const isKey = (value, object) => {
if (Array.isArray(value)) {
return false;
}
const type = typeof value;
if (type == 'number' || type == 'boolean' || value == null || (0, _isSymbol.default)(value)) {
return true;
}
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
};
var _default = isKey;
exports.default = _default;
//# sourceMappingURL=isKey.js.map
;