source: trip-planner-front/node_modules/core-js/modules/es.symbol.description.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1// `Symbol.prototype.description` getter
2// https://tc39.es/ecma262/#sec-symbol.prototype.description
3'use strict';
4var $ = require('../internals/export');
5var DESCRIPTORS = require('../internals/descriptors');
6var global = require('../internals/global');
7var has = require('../internals/has');
8var isObject = require('../internals/is-object');
9var defineProperty = require('../internals/object-define-property').f;
10var copyConstructorProperties = require('../internals/copy-constructor-properties');
11
12var NativeSymbol = global.Symbol;
13
14if (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||
15 // Safari 12 bug
16 NativeSymbol().description !== undefined
17)) {
18 var EmptyStringDescriptionStore = {};
19 // wrap Symbol constructor for correct work with undefined description
20 var SymbolWrapper = function Symbol() {
21 var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
22 var result = this instanceof SymbolWrapper
23 ? new NativeSymbol(description)
24 // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
25 : description === undefined ? NativeSymbol() : NativeSymbol(description);
26 if (description === '') EmptyStringDescriptionStore[result] = true;
27 return result;
28 };
29 copyConstructorProperties(SymbolWrapper, NativeSymbol);
30 var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
31 symbolPrototype.constructor = SymbolWrapper;
32
33 var symbolToString = symbolPrototype.toString;
34 var native = String(NativeSymbol('test')) == 'Symbol(test)';
35 var regexp = /^Symbol\((.*)\)[^)]+$/;
36 defineProperty(symbolPrototype, 'description', {
37 configurable: true,
38 get: function description() {
39 var symbol = isObject(this) ? this.valueOf() : this;
40 var string = symbolToString.call(symbol);
41 if (has(EmptyStringDescriptionStore, symbol)) return '';
42 var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
43 return desc === '' ? undefined : desc;
44 }
45 });
46
47 $({ global: true, forced: true }, {
48 Symbol: SymbolWrapper
49 });
50}
Note: See TracBrowser for help on using the repository browser.