source: trip-planner-front/node_modules/has-symbols/shams.js@ 6fe77af

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

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1'use strict';
2
3/* eslint complexity: [2, 18], max-statements: [2, 33] */
4module.exports = function hasSymbols() {
5 if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
6 if (typeof Symbol.iterator === 'symbol') { return true; }
7
8 var obj = {};
9 var sym = Symbol('test');
10 var symObj = Object(sym);
11 if (typeof sym === 'string') { return false; }
12
13 if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
14 if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
15
16 // temp disabled per https://github.com/ljharb/object.assign/issues/17
17 // if (sym instanceof Symbol) { return false; }
18 // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
19 // if (!(symObj instanceof Symbol)) { return false; }
20
21 // if (typeof Symbol.prototype.toString !== 'function') { return false; }
22 // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
23
24 var symVal = 42;
25 obj[sym] = symVal;
26 for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
27 if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
28
29 if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
30
31 var syms = Object.getOwnPropertySymbols(obj);
32 if (syms.length !== 1 || syms[0] !== sym) { return false; }
33
34 if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
35
36 if (typeof Object.getOwnPropertyDescriptor === 'function') {
37 var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
38 if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
39 }
40
41 return true;
42};
Note: See TracBrowser for help on using the repository browser.