index.js (1940B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 /** 22 * Test if a value is a symbol. 23 * 24 * @module @stdlib/assert/is-symbol 25 * 26 * @example 27 * var Symbol = require( '@stdlib/symbol/ctor' ); 28 * var isSymbol = require( '@stdlib/assert/is-symbol' ); 29 * 30 * var bool = isSymbol( Symbol( 'beep' ) ); 31 * // returns true 32 * 33 * bool = isSymbol( Object( Symbol( 'beep' ) ) ); 34 * // returns true 35 * 36 * bool = isSymbol( {} ); 37 * // returns false 38 * 39 * @example 40 * var Symbol = require( '@stdlib/symbol/ctor' ); 41 * var isSymbol = require( '@stdlib/assert/is-symbol' ).isPrimitive; 42 * 43 * var bool = isSymbol( Symbol( 'beep' ) ); 44 * // returns true 45 * 46 * bool = isSymbol( Object( Symbol( 'beep' ) ) ); 47 * // returns false 48 * 49 * bool = isSymbol( {} ); 50 * // returns false 51 * 52 * @example 53 * var Symbol = require( '@stdlib/symbol/ctor' ); 54 * var isSymbolObject = require( '@stdlib/assert/is-symbol' ).isObject; 55 * 56 * var bool = isSymbolObject( Symbol( 'beep' ) ); 57 * // returns false 58 * 59 * bool = isSymbolObject( Object( Symbol( 'beep' ) ) ); 60 * // returns true 61 * 62 * bool = isSymbolObject( {} ); 63 * // returns false 64 */ 65 66 // MODULES // 67 68 var hasSymbols = require( './../../has-symbol-support' ); 69 var main = require( './main.js' ); 70 var polyfill = require( './polyfill.js' ); 71 72 73 // MAIN // 74 75 var isSymbol; 76 if ( hasSymbols() ) { 77 isSymbol = main; 78 } else { 79 isSymbol = polyfill; 80 } 81 82 83 // EXPORTS // 84 85 module.exports = isSymbol;