main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
774 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var GetIntrinsic = require('get-intrinsic');
|
---|
4 |
|
---|
5 | var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
---|
6 |
|
---|
7 | var hasToStringTag = require('has-tostringtag/shams')();
|
---|
8 | var hasOwn = require('hasown');
|
---|
9 |
|
---|
10 | var toStringTag = hasToStringTag ? Symbol.toStringTag : null;
|
---|
11 |
|
---|
12 | /** @type {import('.')} */
|
---|
13 | module.exports = function setToStringTag(object, value) {
|
---|
14 | var overrideIfSet = arguments.length > 2 && arguments[2] && arguments[2].force;
|
---|
15 | if (toStringTag && (overrideIfSet || !hasOwn(object, toStringTag))) {
|
---|
16 | if ($defineProperty) {
|
---|
17 | $defineProperty(object, toStringTag, {
|
---|
18 | configurable: true,
|
---|
19 | enumerable: false,
|
---|
20 | value: value,
|
---|
21 | writable: false
|
---|
22 | });
|
---|
23 | } else {
|
---|
24 | object[toStringTag] = value; // eslint-disable-line no-param-reassign
|
---|
25 | }
|
---|
26 | }
|
---|
27 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.