-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
34 lines (29 loc) · 858 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
var hasSymbols = require('has-symbols')();
var isSymbol = require('is-symbol');
var flatMap = require('array.prototype.flatmap');
var ownKeys = require('reflect.ownkeys');
var callBound = require('call-bind/callBound');
var symbolValueOf = callBound('Symbol.prototype.valueOf', true);
var wellKnownSymbols = hasSymbols && flatMap(
ownKeys(Symbol),
function (k) {
var v = Symbol[k];
return typeof v === 'symbol' ? v : [];
}
);
var map = { __proto__: null };
for (var i = 0; i < wellKnownSymbols.length; i += 1) {
map[wellKnownSymbols[i]] = true;
}
module.exports = hasSymbols
? function isWellKnownSymbol(sym) {
if (!isSymbol(sym)) {
return false;
}
return (typeof sym === 'symbol' ? sym : symbolValueOf(sym)) in map;
}
// eslint-disable-next-line no-unused-vars
: function isWellKnownSymbol(sym) {
return false;
};