File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1+ const fnToString = ( fn ) => Function . prototype . toString . call ( fn ) ;
2+
3+ /**
4+ * @param {any } obj The object to inspect.
5+ * @returns {boolean } True if the argument appears to be a plain object.
6+ */
17export default function isPlainObject ( obj ) {
2- return obj ? typeof obj === 'object' && Object . getPrototypeOf ( obj ) === Object . prototype : false ;
8+ if ( ! obj || typeof obj !== 'object' ) {
9+ return false ;
10+ }
11+
12+ const proto = typeof obj . constructor === 'function' ?
13+ Object . getPrototypeOf ( obj ) :
14+ Object . prototype ;
15+
16+ if ( proto === null ) {
17+ return true ;
18+ }
19+
20+ const constructor = proto . constructor ;
21+
22+ return typeof constructor === 'function'
23+ && constructor instanceof constructor
24+ && fnToString ( constructor ) === fnToString ( Object ) ;
325}
You can’t perform that action at this time.
0 commit comments