@stdlib/bigint-ctor

BigInts.

Usage no npm install needed!

<script type="module">
  import stdlibBigintCtor from 'https://cdn.skypack.dev/@stdlib/bigint-ctor';
</script>

README

BigInt

NPM version Build Status Coverage Status dependencies

BigInt factory.

Installation

npm install @stdlib/bigint-ctor

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.' );
}

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2021. The Stdlib Authors.