main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
767 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var toStr = Object.prototype.toString;
|
---|
4 | var hasSymbols = require('has-symbols')();
|
---|
5 |
|
---|
6 | if (hasSymbols) {
|
---|
7 | var symToStr = Symbol.prototype.toString;
|
---|
8 | var symStringRegex = /^Symbol\(.*\)$/;
|
---|
9 | var isSymbolObject = function isRealSymbolObject(value) {
|
---|
10 | if (typeof value.valueOf() !== 'symbol') {
|
---|
11 | return false;
|
---|
12 | }
|
---|
13 | return symStringRegex.test(symToStr.call(value));
|
---|
14 | };
|
---|
15 |
|
---|
16 | module.exports = function isSymbol(value) {
|
---|
17 | if (typeof value === 'symbol') {
|
---|
18 | return true;
|
---|
19 | }
|
---|
20 | if (toStr.call(value) !== '[object Symbol]') {
|
---|
21 | return false;
|
---|
22 | }
|
---|
23 | try {
|
---|
24 | return isSymbolObject(value);
|
---|
25 | } catch (e) {
|
---|
26 | return false;
|
---|
27 | }
|
---|
28 | };
|
---|
29 | } else {
|
---|
30 |
|
---|
31 | module.exports = function isSymbol(value) {
|
---|
32 | // this environment does not support Symbols.
|
---|
33 | return false && value;
|
---|
34 | };
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.