Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
exotic / dist / types / NATIVE / isNative.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// import { matchNative } from 'exoticdeps'
const deps_1 = require("../../deps");
const NATIVE_NAMES_LIST_1 = require("./CONSTANTS/NATIVE_NAMES_LIST");
const PROTOTYPE_METHODS_1 = require("./CONSTANTS/PROTOTYPE_METHODS");
/**
 * @desc based on isNative from react-fibers, based on isNative() from Lodash
 * @since 4.0.6
 * @memberOf is
 * @func isNative
 *
 * @param {*} x value to check
 * @return {boolean}
 *
 * {@link https://esdiscuss.org/topic/spec-feedback-on-rev-6#content-2 esdiscuss-functiontostring}
 * {@link https://github.com/lodash/lodash/issues/2185 lodash-functiontostring-issue}
 * {@link http://tc39.github.io/Function-prototype-toString-revision/ functiontostring-emca}
 * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString Function.toString}
 *
 * @see {@link Function.toString}
 * @see {@link functiontostring-emca}
 * @see {@link lodash-functiontostring-issue}
 * @see {@link esdiscuss-functiontostring}
 *
 * @example
 *
 * isNative(Array.prototype.push)
 * //=> true
 *
 * isNative(function normalFunction() {})
 * //=> false
 *
 */
function isNativeFunction(x) {
    try {
        const source = PROTOTYPE_METHODS_1.functionToString.call(x);
        return deps_1.matchNative.test(source);
    }
    catch (err) {
        return false;
    }
}
exports.isNativeFunction = isNativeFunction;
// Native - much faster than try catch function toString regexp matching
// though it would not include ALL **METHODS** (Object Properties)
// eslint-disable-next-line
const isBuiltIn = (x) => NATIVE_NAMES_LIST_1.default.indexOf(x) !== -1 || isNativeFunction(x);
exports.isBuiltIn = isBuiltIn;
const isNative = isBuiltIn;
exports.isNative = isNative;
//# sourceMappingURL=isNative.js.map