HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //usr/share/opensearch-dashboards/node_modules/is-native/index.js
'use strict';

var isNil    = require('is-nil');
var toSource = require('to-source-code');

function isObject(value) {

  var type = typeof value;

  return !!value && (type === 'object' || type === 'function');
}

// Checks if `value` is a host object in IE < 9.
function isHostObject(value) {

  // Many host objects are `Object` objects that can coerce to strings
  // despite having improperly defined `toString` methods.

  var result = false;

  if (!isNil(value) && typeof value.toString !== 'function') {
    try {
      result = ('' + value) !== '';
    } catch (e) {}
  }
  return result;
}

function isFunction(value) {

  var tag = isObject(value) ? Object.prototype.toString.call(value) : '';

  return tag === '[object Function]' || tag === '[object GeneratorFunction]';
}


module.exports = function (value) {

  if (!isObject(value)) {
    return false;
  }

  var pattern;

  if (isFunction(value) || isHostObject(value)) {

    var toString       = Function.prototype.toString;
    var hasOwnProperty = Object.prototype.hasOwnProperty;
    var reRegExpChar   = /[\\^$.*+?()[\]{}|]/g;

    pattern = new RegExp('^' +
      toString.call(hasOwnProperty)
        .replace(reRegExpChar, '\\$&')
        .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
    );
  } else {
    // detect host constructors (Safari).
    pattern = /^\[object .+?Constructor\]$/;
  }

  return pattern.test(toSource(value));
};