time-to-botec

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

index.js (1824B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2021 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 BigInt.
     23 *
     24 * @module @stdlib/assert/is-bigint
     25 *
     26 * @example
     27 * var BigInt = require( '@stdlib/bigint/ctor' );
     28 * var isBigInt = require( '@stdlib/assert/is-bigint' );
     29 *
     30 * var bool = isBigInt( BigInt( '1' ) );
     31 * // returns true
     32 *
     33 * bool = isBigInt( Object( BigInt( '1' ) ) );
     34 * // returns true
     35 *
     36 * bool = isBigInt( {} );
     37 * // returns false
     38 *
     39 * @example
     40 * var isBigInt = require( '@stdlib/assert/is-bigint' ).isPrimitive;
     41 *
     42 * var bool = isBigInt( BigInt( '1' ) );
     43 * // returns true
     44 *
     45 * bool = isBigInt( Object( BigInt( '1' ) ) );
     46 * // returns false
     47 *
     48 * bool = isBigInt( {} );
     49 * // returns false
     50 *
     51 * @example
     52 * var isBigIntObject = require( '@stdlib/assert/is-bigint' ).isObject;
     53 *
     54 * var bool = isBigIntObject( BigInt( '1' ) );
     55 * // returns false
     56 *
     57 * bool = isBigIntObject( Object( BigInt( '1' ) ) );
     58 * // returns true
     59 *
     60 * bool = isBigIntObject( {} );
     61 * // returns false
     62 */
     63 
     64 // MODULES //
     65 
     66 var hasBigInts = require( './../../has-bigint-support' );
     67 var main = require( './main.js' );
     68 var polyfill = require( './polyfill.js' );
     69 
     70 
     71 // MAIN //
     72 
     73 var isBigInt;
     74 if ( hasBigInts() ) {
     75 	isBigInt = main;
     76 } else {
     77 	isBigInt = polyfill;
     78 }
     79 
     80 
     81 // EXPORTS //
     82 
     83 module.exports = isBigInt;