bifocal/node_modules/@stdlib/utils-keys/lib/has_automation_equality_bug.js

77 lines
1.8 KiB
JavaScript

/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
// MODULES //
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
var indexOf = require( '@stdlib/utils-index-of' );
var typeOf = require( '@stdlib/utils-type-of' );
var isConstructorPrototype = require( './is_constructor_prototype.js' );
var EXCLUDED_KEYS = require( './excluded_keys.json' );
var win = require( './window.js' );
// VARIABLES //
var bool;
// FUNCTIONS //
/**
* Determines whether an environment throws when comparing to the prototype of a value's constructor (e.g., [IE9][1]).
*
* [1]: https://stackoverflow.com/questions/7688070/why-is-comparing-the-constructor-property-of-two-windows-unreliable
*
* @private
* @returns {boolean} boolean indicating whether an environment is buggy
*/
function check() {
var k;
if ( typeOf( win ) === 'undefined' ) {
return false;
}
for ( k in win ) { // eslint-disable-line guard-for-in
try {
if (
indexOf( EXCLUDED_KEYS, k ) === -1 &&
hasOwnProp( win, k ) &&
win[ k ] !== null &&
typeOf( win[ k ] ) === 'object'
) {
isConstructorPrototype( win[ k ] );
}
} catch ( err ) { // eslint-disable-line no-unused-vars
return true;
}
}
return false;
}
// MAIN //
bool = check();
// EXPORTS //
module.exports = bool;