Failsafe function that uses Object.prototype.hasOwnProperty() and return false in case if target is not a valid object.
Note: It uses arrow functions that may not be supported by some old environments.
You better use lodash/has.
Failsafe function that uses Object.prototype.hasOwnProperty() and return false in case if target is not a valid object.
Note: It uses arrow functions that may not be supported by some old environments.
You better use lodash/has.
export function hasOwn(target: any, name: string | symbol): boolean; |
export const hasOwn = ( | |
(has) => | |
(target, property) => | |
Boolean(target && has.call(target, property)) | |
)(Object.prototype.hasOwnProperty); | |
export default hasOwn; |
'use strict'; | |
Object.defineProperty(exports, '__esModule', { value: true }); | |
const hasOwn = ( | |
(has) => | |
(target, property) => | |
Boolean(target && has.call(target, property)) | |
)(Object.prototype.hasOwnProperty); | |
exports.hasOwn = hasOwn; | |
exports.default = hasOwn; |
{ | |
"name": "@actualwave/has-own", | |
"description": "Functional replacement for Object.prototype.hasOwnProperty()", | |
"version": "0.0.3", | |
"main": "index.js", | |
"module": "index.es.js", | |
"types": "index.d.ts", | |
"keywords": [ | |
"js", | |
"javascript", | |
"Object", | |
"hasOwnProperty", | |
"has", | |
"hasOwn" | |
], | |
"homepage": "https://gist.github.com/burdiuz/d81cd59d2d619d921531165fac0e8c77", | |
"bugs": { | |
"url": "https://gist.github.com/burdiuz/d81cd59d2d619d921531165fac0e8c77", | |
"email": "burdiuz@gmail.com" | |
}, | |
"license": "MIT", | |
"author": "Oleg Galaburda <burdiuz@gmail.com> (http://actualwave.com/)" | |
} |