source: imaps-frontend/node_modules/es-set-tostringtag/index.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 6 months ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
6
7var hasToStringTag = require('has-tostringtag/shams')();
8var hasOwn = require('hasown');
9var $TypeError = require('es-errors/type');
10
11var toStringTag = hasToStringTag ? Symbol.toStringTag : null;
12
13/** @type {import('.')} */
14module.exports = function setToStringTag(object, value) {
15 var overrideIfSet = arguments.length > 2 && !!arguments[2] && arguments[2].force;
16 var nonConfigurable = arguments.length > 2 && !!arguments[2] && arguments[2].nonConfigurable;
17 if (
18 (typeof overrideIfSet !== 'undefined' && typeof overrideIfSet !== 'boolean')
19 || (typeof nonConfigurable !== 'undefined' && typeof nonConfigurable !== 'boolean')
20 ) {
21 throw new $TypeError('if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans');
22 }
23 if (toStringTag && (overrideIfSet || !hasOwn(object, toStringTag))) {
24 if ($defineProperty) {
25 $defineProperty(object, toStringTag, {
26 configurable: !nonConfigurable,
27 enumerable: false,
28 value: value,
29 writable: false
30 });
31 } else {
32 object[toStringTag] = value; // eslint-disable-line no-param-reassign
33 }
34 }
35};
Note: See TracBrowser for help on using the repository browser.