README.md (2795B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2021 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # BigInt 22 23 > [BigInt][mdn-bigint] factory. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var BigInt = require( '@stdlib/bigint/ctor' ); 41 ``` 42 43 #### BigInt( value ) 44 45 Returns a [`BigInt`][mdn-bigint] primitive. 46 47 <!-- run-disable --> 48 49 ```javascript 50 var v = BigInt( '1' ); 51 // returns <bigint> 52 ``` 53 54 TODO: document properties/methods 55 56 </section> 57 58 <!-- /.usage --> 59 60 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 61 62 <section class="notes"> 63 64 ## Notes 65 66 - Unlike conventional constructors, the function does **not** support the `new` keyword. 67 - The function is only supported in environments which support [`BigInt`][mdn-bigint]. In non-supporting environments, the value is `undefined`. 68 69 </section> 70 71 <!-- /.notes --> 72 73 <!-- Package usage examples. --> 74 75 <section class="examples"> 76 77 ## Examples 78 79 <!-- eslint no-undef: "error" --> 80 81 ```javascript 82 var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); 83 var BigInt = require( '@stdlib/bigint/ctor' ); 84 85 var v; 86 87 if ( hasBigIntSupport() ) { 88 v = BigInt( '1' ); 89 90 // Print the value type: 91 console.log( typeof v ); 92 // => 'bigint' 93 94 // Serialize the BigInt as a string: 95 console.log( v.toString() ); 96 // => '1' 97 } else { 98 console.log( 'Environment does not support BigInts.' ); 99 } 100 ``` 101 102 </section> 103 104 <!-- /.examples --> 105 106 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 107 108 <section class="references"> 109 110 </section> 111 112 <!-- /.references --> 113 114 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 115 116 <section class="links"> 117 118 [mdn-bigint]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt 119 120 </section> 121 122 <!-- /.links -->