From e32c4900f5ab5fd3acea93e9d2f0d09e4a2f2ceb Mon Sep 17 00:00:00 2001 From: NoScripter Date: Wed, 27 Feb 2019 15:25:35 +0800 Subject: [PATCH] [Refactor] extract `has` --- checkPropTypes.js | 2 +- factoryWithTypeCheckers.js | 2 +- lib/has.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 lib/has.js diff --git a/checkPropTypes.js b/checkPropTypes.js index 1ad29fe..82788a5 100644 --- a/checkPropTypes.js +++ b/checkPropTypes.js @@ -12,7 +12,7 @@ var printWarning = function() {}; if (process.env.NODE_ENV !== 'production') { var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); var loggedTypeFailures = {}; - var has = Function.call.bind(Object.prototype.hasOwnProperty); + var has = require('./lib/has'); printWarning = function(text) { var message = 'Warning: ' + text; diff --git a/factoryWithTypeCheckers.js b/factoryWithTypeCheckers.js index 269e810..adbd752 100644 --- a/factoryWithTypeCheckers.js +++ b/factoryWithTypeCheckers.js @@ -11,9 +11,9 @@ var ReactIs = require('react-is'); var assign = require('object-assign'); var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); +var has = require('./lib/has'); var checkPropTypes = require('./checkPropTypes'); -var has = Function.call.bind(Object.prototype.hasOwnProperty); var printWarning = function() {}; if (process.env.NODE_ENV !== 'production') { diff --git a/lib/has.js b/lib/has.js new file mode 100644 index 0000000..007bae3 --- /dev/null +++ b/lib/has.js @@ -0,0 +1 @@ +module.exports = Function.call.bind(Object.prototype.hasOwnProperty);