UNPKG

has-to-string-tag-x

Version:
765 lines (619 loc) 25 kB
/*! { "author": "Graham Fairweather", "copywrite": "Copyright (c) 2015-2017", "date": "2019-08-28T16:56:55.700Z", "describe": "", "description": "Tests if ES6 @@toStringTag is supported.", "file": "has-to-string-tag-x.js", "hash": "c0445a88046481fe23d6", "license": "MIT", "version": "2.1.2" } */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["hasToStringTagX"] = factory(); else root["hasToStringTagX"] = factory(); })((function () { 'use strict'; var ObjectCtr = {}.constructor; var objectPrototype = ObjectCtr.prototype; var defineProperty = ObjectCtr.defineProperty; var $globalThis; var getGlobalFallback = function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return void 0; }; var returnThis = function() { return this; }; try { if (defineProperty) { defineProperty(objectPrototype, '$$globalThis$$', { get: returnThis, configurable: true }); } else { objectPrototype.__defineGetter__('$$globalThis$$', returnThis); } $globalThis = typeof $$globalThis$$ === 'undefined' ? getGlobalFallback() : $$globalThis$$; delete objectPrototype.$$globalThis$$; return $globalThis; } catch (error) { return getGlobalFallback(); } }()), function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 5); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var toStr = Object.prototype.toString; var hasSymbols = __webpack_require__(2)(); if (hasSymbols) { var symToStr = Symbol.prototype.toString; var symStringRegex = /^Symbol\(.*\)$/; var isSymbolObject = function isRealSymbolObject(value) { if (typeof value.valueOf() !== 'symbol') { return false; } return symStringRegex.test(symToStr.call(value)); }; module.exports = function isSymbol(value) { if (typeof value === 'symbol') { return true; } if (toStr.call(value) !== '[object Symbol]') { return false; } try { return isSymbolObject(value); } catch (e) { return false; } }; } else { module.exports = function isSymbol(value) { // this environment does not support Symbols. return false && false; }; } /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var strValue = String.prototype.valueOf; var tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }; var toStr = Object.prototype.toString; var strClass = '[object String]'; var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; module.exports = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; }; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) { var origSymbol = global.Symbol; var hasSymbolSham = __webpack_require__(4); module.exports = function hasNativeSymbols() { if (typeof origSymbol !== 'function') { return false; } if (typeof Symbol !== 'function') { return false; } if (typeof origSymbol('foo') !== 'symbol') { return false; } if (typeof Symbol('bar') !== 'symbol') { return false; } return hasSymbolSham(); }; /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(3))) /***/ }), /* 3 */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || new Function("return this")(); } catch (e) { // This works if the window reference is available if (typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* eslint complexity: [2, 17], max-statements: [2, 33] */ module.exports = function hasSymbols() { if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } if (typeof Symbol.iterator === 'symbol') { return true; } var obj = {}; var sym = Symbol('test'); var symObj = Object(sym); if (typeof sym === 'string') { return false; } if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } // temp disabled per https://github.com/ljharb/object.assign/issues/17 // if (sym instanceof Symbol) { return false; } // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 // if (!(symObj instanceof Symbol)) { return false; } // if (typeof Symbol.prototype.toString !== 'function') { return false; } // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } var symVal = 42; obj[sym] = symVal; for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } var syms = Object.getOwnPropertySymbols(obj); if (syms.length !== 1 || syms[0] !== sym) { return false; } if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } if (typeof Object.getOwnPropertyDescriptor === 'function') { var descriptor = Object.getOwnPropertyDescriptor(obj, sym); if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } } return true; }; /***/ }), /* 5 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/is-primitive-x/dist/is-primitive-x.esm.js function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /** * Returns true if the value is a primitive. * * @param {*} [val] - The value to test. * @returns {boolean} True if a primitive, otherwise false.. */ var isPrimitive = function isPrimitive(val) { return _typeof(val) === 'object' ? val === null : typeof val !== 'function'; }; /* harmony default export */ var is_primitive_x_esm = (isPrimitive); // EXTERNAL MODULE: ./node_modules/is-string/index.js var is_string = __webpack_require__(1); var is_string_default = /*#__PURE__*/__webpack_require__.n(is_string); // CONCATENATED MODULE: ./node_modules/has-boxed-string-x/dist/has-boxed-string-x.esm.js var string = 'a'; var boxedString = {}.constructor(string); /** * Check failure of by-index access of string characters (IE < 9) * and failure of `0 in boxedString` (Rhino). * * `true` if no failure; otherwise `false`. * * @type boolean */ var hasBoxed = boxedString[0] === string && 0 in boxedString; /* harmony default export */ var has_boxed_string_x_esm = (hasBoxed); // CONCATENATED MODULE: ./node_modules/noop-x/dist/noop-x.esm.js /** * This method returns undefined. * * @returns {undefined} Always undefined. */ var noop = function noop() {}; /* eslint-disable-line lodash/prefer-noop */ /* harmony default export */ var noop_x_esm = (noop); // CONCATENATED MODULE: ./node_modules/has-working-bind-x/dist/has-working-bind-x.esm.js var has_working_bind_x_esm_bind = noop_x_esm.bind; var test1 = function test1() { var a1 = null; var a2 = null; var context = null; var testThis = []; var test1Fn = function test1Fn(arg1, arg2) { /* eslint-disable-next-line babel/no-invalid-this */ context = this; a1 = arg1; a2 = arg2; /* eslint-disable-next-line prefer-rest-params */ return arguments; }; try { var boundFn = has_working_bind_x_esm_bind.apply(test1Fn, [testThis, 1]); var args = boundFn(2); return boundFn.length === 1 && args.length === 2 && a1 === 1 && a2 === 2 && context === testThis; } catch (e) { return false; } }; var test2 = function test2() { var a1 = null; var a2 = null; var context = null; var oracle = [1, 2, 3]; var Ctr = function Ctr(arg1, arg2) { a1 = arg1; a2 = arg2; context = this; return oracle; }; try { var BoundFn = has_working_bind_x_esm_bind.apply(Ctr, [null]); var returned = new BoundFn(1, 2); return BoundFn.length === Ctr.length && returned === oracle && a1 === 1 && a2 === 2 && context !== oracle; } catch (e) { return false; } }; /** * Indicates if the engine has a working bind function. * * @type {boolean} */ var isWorking = typeof has_working_bind_x_esm_bind === 'function' && test1() && test2(); /* harmony default export */ var has_working_bind_x_esm = (isWorking); // CONCATENATED MODULE: ./node_modules/util-pusher-x/dist/util-pusher-x.esm.js var EMPTY_STRING = ''; var split = EMPTY_STRING.split; var max = Math.max; var util_pusher_x_esm_bind = is_primitive_x_esm.bind, util_pusher_x_esm_call = is_primitive_x_esm.call; var stringSplit = function stringSplit(string, pattern) { // noinspection JSUnresolvedFunction return split.call(string, pattern); }; var $split = has_working_bind_x_esm ? util_pusher_x_esm_bind.call(util_pusher_x_esm_call, split) : stringSplit; var util_pusher_x_esm_getIterable = function getIterable(arrayLike) { // noinspection JSUnresolvedFunction return is_string_default()(arrayLike) ? $split(arrayLike, EMPTY_STRING) : arrayLike; }; // eslint-disable jsdoc/no-undefined-types // noinspection JSCommentMatchesSignature /** * This pushes or concatenates into a new or existing array. * * @param {Array} arrayLike - The source. * @param {number} [from=0] - The from source index. * @param {Array} [target=[]] - The target array. * @returns {*} The target array. */ // eslint-enable jsdoc/no-undefined-types var util_pusher_x_esm_pusher = function pusher(arrayLike, from) { /* eslint-disable-next-line prefer-rest-params */ var target = arguments.length > 2 ? arguments[2] : []; if (typeof arrayLike !== 'string' && is_primitive_x_esm(arrayLike)) { return target; } var iterable = has_boxed_string_x_esm ? arrayLike : util_pusher_x_esm_getIterable(arrayLike); var length = iterable.length; for (var i = max(0, from) || 0; i < length; i += 1) { target[target.length] = arrayLike[i]; } return target; }; /* harmony default export */ var util_pusher_x_esm = (util_pusher_x_esm_pusher); // CONCATENATED MODULE: ./node_modules/simple-bind-x/dist/simple-bind-x.esm.js function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } var nativeBind = util_pusher_x_esm.bind, simple_bind_x_esm_call = util_pusher_x_esm.call; var ERROR_MESSAGE = 'bind called on incompatible '; var object = {}; var ObjectCtr = object.constructor; var toStringTag = object.toString; var funcType = '[object Function]'; var ZERO = 0; var argsOffset = 2; var getMax = function getMax(a, b) { return a >= b ? a : b; }; var assertIsFunction = function assertIsFunction(value) { if (typeof value !== 'function' && toStringTag.apply(value) !== funcType) { throw new TypeError(ERROR_MESSAGE + value); } }; var boundFns = [function zero(binder) { return function boundFn() { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments)); }; }, function one(binder, boundLength) { return function boundFn(a) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a])); }; }, function two(binder, boundLength) { return function boundFn(a, b) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a, b])); }; }, function three(binder, boundLength) { /* eslint-disable-next-line max-params */ return function boundFn(a, b, c) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a, b, c])); }; }, function four(binder, boundLength) { /* eslint-disable-next-line max-params */ return function boundFn(a, b, c, d) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a, b, c, d])); }; }, function five(binder, boundLength) { /* eslint-disable-next-line max-params */ return function boundFn(a, b, c, d, e) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a, b, c, d, e])); }; }, function six(binder, boundLength) { /* eslint-disable-next-line max-params */ return function boundFn(a, b, c, d, e, f) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a, b, c, d, e, f])); }; }, function seven(binder, boundLength) { /* eslint-disable-next-line max-params */ return function boundFn(a, b, c, d, e, f, g) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a, b, c, d, e, f, g])); }; }, function eight(binder, boundLength) { /* eslint-disable-next-line max-params */ return function boundFn(a, b, c, d, e, f, g, h) { /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ return binder.apply(this, util_pusher_x_esm(arguments, boundLength, [a, b, c, d, e, f, g, h])); }; }]; var getBoundFn = function getBoundFn(args) { var _args = _slicedToArray(args, 3), binder = _args[0], target = _args[1], bindArgs = _args[2]; var boundLength = getMax(ZERO, target.length - getMax(ZERO, bindArgs.length - argsOffset)); var fn = boundFns[boundLength]; var boundFn = fn ? fn(binder, boundLength) : boundFns[ZERO](binder); if (target.prototype) { /* eslint-disable-next-line lodash/prefer-noop */ var Empty = function Empty() {}; Empty.prototype = target.prototype; boundFn.prototype = new Empty(); Empty.prototype = null; } return boundFn; }; var getResult = function getResult(target, boundArgs) { /* eslint-disable-next-line babel/no-invalid-this */ var result = target.apply(this, boundArgs); /* eslint-disable-next-line babel/no-invalid-this,babel/new-cap */ return ObjectCtr(result) === result ? result : this; }; var implementation = function bind(target, thisArg) { assertIsFunction(target); /* eslint-disable-next-line prefer-rest-params */ var bindArgs = arguments; var bound; var binder = function binder() { /* eslint-disable-next-line prefer-rest-params */ var boundArgs = util_pusher_x_esm(arguments, ZERO, util_pusher_x_esm(bindArgs, argsOffset)); /* eslint-disable-next-line babel/no-invalid-this */ return this instanceof bound ? getResult.apply(this, [target, boundArgs]) : target.apply(thisArg, boundArgs); }; bound = getBoundFn([binder, target, bindArgs]); return bound; }; /** * The bind() method creates a new function that, when called, has its this * keyword set to the provided value, with a given sequence of arguments * preceding any provided when the new function is called. * * @function bind * @param {Function} target - The target function. * @param {*} [thisArg] - The value to be passed as the this parameter to the target * function when the bound function is called. The value is ignored if the * bound function is constructed using the new operator. * @param {...*} [args] - Arguments to prepend to arguments provided to the bound * function when invoking the target function. * @throws {TypeError} If target is not a function. * @returns {Function} The bound function. */ var $bind = has_working_bind_x_esm ? simple_bind_x_esm_call.bind(nativeBind) : implementation; /* harmony default export */ var simple_bind_x_esm = ($bind); // CONCATENATED MODULE: ./node_modules/simple-call-x/dist/simple-call-x.esm.js var $TypeError = TypeError; var nativeApply = simple_bind_x_esm.apply, nativeCall = simple_bind_x_esm.call; var $apply = simple_bind_x_esm(nativeCall, nativeApply); var simple_call_x_esm_toStringTag = simple_bind_x_esm(nativeApply, {}.toString); var simple_call_x_esm_ERROR_MESSAGE = ' is not a function'; var simple_call_x_esm_funcType = '[object Function]'; var simple_call_x_esm_assertIsFunction = function assertIsFunction(value) { if (typeof value !== 'function' && simple_call_x_esm_toStringTag(value) !== simple_call_x_esm_funcType) { throw new $TypeError(value + simple_call_x_esm_ERROR_MESSAGE); } return value; }; // eslint-disable jsdoc/check-param-names // noinspection JSCommentMatchesSignature /** * The abstract operation Call is used to call the [[Call]] internal method of a function object. * * @function call * @param {Function} F - The target function. * @param {*} [V] - The context. * @param {Array} [args] - Argument to call the function with. * @throws {TypeError} If target is not a function. * @returns {*} The the result of invoking the function. * @see https://www.ecma-international.org/ecma-262/6.0/#sec-call */ // eslint-enable jsdoc/check-param-names var simple_call_x_esm_call = function call(F, V) { /* eslint-disable-next-line prefer-rest-params */ return $apply(simple_call_x_esm_assertIsFunction(F), V, util_pusher_x_esm(arguments[2])); }; /* harmony default export */ var simple_call_x_esm = (simple_call_x_esm_call); // CONCATENATED MODULE: ./node_modules/attempt-x/dist/attempt-x.esm.js // eslint-disable jsdoc/check-param-names // noinspection JSCommentMatchesSignature /** * This method attempts to invoke the function, returning either the result or * the caught error object. Any additional arguments are provided to the * function when it's invoked. * * @function attempt * @param {Function} [fn] - The function to attempt. * @param {...*} [args] - The arguments to invoke the function with. * @returns {object} Returns an object of the result. */ // eslint-disable jsdoc/check-param-names var attempt_x_esm_attempt = function attempt(fn) { try { return { threw: false, /* eslint-disable-next-line babel/no-invalid-this,prefer-rest-params */ value: simple_call_x_esm(fn, this, util_pusher_x_esm(arguments, 1)) }; } catch (e) { return { threw: true, value: e }; } }; /* harmony default export */ var attempt_x_esm = (attempt_x_esm_attempt); // EXTERNAL MODULE: ./node_modules/is-symbol/index.js var is_symbol = __webpack_require__(0); var is_symbol_default = /*#__PURE__*/__webpack_require__.n(is_symbol); // CONCATENATED MODULE: ./node_modules/has-symbol-support-x/dist/has-symbol-support-x.esm.js var _this = undefined; function _newArrowCheck(innerThis, boundThis) { if (innerThis !== boundThis) { throw new TypeError("Cannot instantiate an arrow function"); } } var hasSymbolSupport = attempt_x_esm(function () { _newArrowCheck(this, _this); /* eslint-disable-next-line compat/compat */ return typeof Symbol === 'function' && is_symbol_default()(Symbol('')); }.bind(undefined)); /** * Indicates if `Symbol`exists and creates the correct type. * `true`, if it exists and creates the correct type, otherwise `false`. * * @type boolean */ /* harmony default export */ var has_symbol_support_x_esm = (hasSymbolSupport.threw === false && hasSymbolSupport.value === true); // CONCATENATED MODULE: ./dist/has-to-string-tag-x.esm.js /** * Indicates if `Symbol.toStringTag`exists and is the correct type. * `true`, if it exists and is the correct type, otherwise `false`. * * @type boolean */ /* harmony default export */ var has_to_string_tag_x_esm = __webpack_exports__["default"] = (has_symbol_support_x_esm && /* eslint-disable-next-line compat/compat */ is_symbol_default()(Symbol.toStringTag)); /***/ }) /******/ ]); }); //# sourceMappingURL=has-to-string-tag-x.js.map