time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

main.js (1900B)


      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 // MODULES //
     22 
     23 var isBoolean = require( './../../is-boolean' ).isObject;
     24 var isNumber = require( './../../is-number' ).isObject;
     25 var isString = require( './../../is-string' ).isObject;
     26 var isSymbol = require( './../../is-symbol' ).isObject;
     27 
     28 
     29 // MAIN //
     30 
     31 /**
     32 * Tests if a value is a JavaScript boxed primitive.
     33 *
     34 * @param {*} value - value to test
     35 * @returns {boolean} boolean indicating if a value is a JavaScript boxed primitive
     36 *
     37 * @example
     38 * var bool = isBoxedPrimitive( new String( 'beep' ) );
     39 * // returns true
     40 *
     41 * @example
     42 * var bool = isBoxedPrimitive( new Number( 3.21 ) );
     43 * // returns true
     44 *
     45 * @example
     46 * var Symbol = require( '@stdlib/symbol/ctor' );
     47 * var bool = isBoxedPrimitive( Object( Symbol( 'beep' ) ) );
     48 * // returns true
     49 *
     50 * @example
     51 * var bool = isBoxedPrimitive( true );
     52 * // returns false
     53 *
     54 * @example
     55 * var bool = isBoxedPrimitive( {} );
     56 * // returns false
     57 *
     58 * @example
     59 * var Symbol = require( '@stdlib/symbol/ctor' );
     60 * var bool = isBoxedPrimitive( Symbol( 'beep' ) );
     61 * // returns false
     62 */
     63 function isBoxedPrimitive( value ) {
     64 	if ( typeof value !== 'object' ) {
     65 		return false;
     66 	}
     67 	return (
     68 		isBoolean( value ) ||
     69 		isNumber( value ) ||
     70 		isString( value ) ||
     71 		isSymbol( value )
     72 	);
     73 }
     74 
     75 
     76 // EXPORTS //
     77 
     78 module.exports = isBoxedPrimitive;