watermark-js-plus
Version:
watermark for the browser
74 lines (65 loc) • 3.4 kB
JavaScript
import { __module as makeBuiltIn } from '../../../_virtual/make-built-in.js';
import { __require as requireFunctionUncurryThis } from './function-uncurry-this.js';
import { __require as requireFails } from './fails.js';
import { __require as requireIsCallable } from './is-callable.js';
import { __require as requireHasOwnProperty } from './has-own-property.js';
import { __require as requireDescriptors } from './descriptors.js';
import { __require as requireFunctionName } from './function-name.js';
import { __require as requireInspectSource } from './inspect-source.js';
import { __require as requireInternalState } from './internal-state.js';
var hasRequiredMakeBuiltIn;
function requireMakeBuiltIn () {
if (hasRequiredMakeBuiltIn) return makeBuiltIn.exports;
hasRequiredMakeBuiltIn = 1;
var uncurryThis = requireFunctionUncurryThis();
var fails = requireFails();
var isCallable = requireIsCallable();
var hasOwn = requireHasOwnProperty();
var DESCRIPTORS = requireDescriptors();
var CONFIGURABLE_FUNCTION_NAME = requireFunctionName().CONFIGURABLE;
var inspectSource = requireInspectSource();
var InternalStateModule = requireInternalState();
var enforceInternalState = InternalStateModule.enforce;
var getInternalState = InternalStateModule.get;
var $String = String;
// eslint-disable-next-line es/no-object-defineproperty -- safe
var defineProperty = Object.defineProperty;
var stringSlice = uncurryThis(''.slice);
var replace = uncurryThis(''.replace);
var join = uncurryThis([].join);
var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
});
var TEMPLATE = String(String).split('String');
var makeBuiltIn$1 = makeBuiltIn.exports = function (value, name, options) {
if (stringSlice($String(name), 0, 7) === 'Symbol(') {
name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
}
if (options && options.getter) name = 'get ' + name;
if (options && options.setter) name = 'set ' + name;
if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true });
else value.name = name;
}
if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
defineProperty(value, 'length', { value: options.arity });
}
try {
if (options && hasOwn(options, 'constructor') && options.constructor) {
if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false });
// in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
} else if (value.prototype) value.prototype = undefined;
} catch (error) { /* empty */ }
var state = enforceInternalState(value);
if (!hasOwn(state, 'source')) {
state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
} return value;
};
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
// eslint-disable-next-line no-extend-native -- required
Function.prototype.toString = makeBuiltIn$1(function toString() {
return isCallable(this) && getInternalState(this).source || inspectSource(this);
}, 'toString');
return makeBuiltIn.exports;
}
export { requireMakeBuiltIn as __require };