time-to-botec/squiggle/node_modules/@stdlib/bigint/ctor/README.md
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

2.7 KiB

BigInt

BigInt factory.

Usage

var BigInt = require( '@stdlib/bigint/ctor' );

BigInt( value )

Returns a BigInt primitive.

var v = BigInt( '1' );
// returns <bigint>

TODO: document properties/methods

Notes

  • Unlike conventional constructors, the function does not support the new keyword.
  • The function is only supported in environments which support BigInt. In non-supporting environments, the value is undefined.

Examples

var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' );
var BigInt = require( '@stdlib/bigint/ctor' );

var v;

if ( hasBigIntSupport() ) {
    v = BigInt( '1' );

    // Print the value type:
    console.log( typeof v );
    // => 'bigint'

    // Serialize the BigInt as a string:
    console.log( v.toString() );
    // => '1'
} else {
    console.log( 'Environment does not support BigInts.' );
}