@@ -287,6 +287,10 @@ inline bool Value::IsNumber() const {
287
287
return Type () == napi_number;
288
288
}
289
289
290
+ inline bool Value::IsBigInt () const {
291
+ return Type () == napi_bigint;
292
+ }
293
+
290
294
inline bool Value::IsString () const {
291
295
return Type () == napi_string;
292
296
}
@@ -505,6 +509,67 @@ inline double Number::DoubleValue() const {
505
509
return result;
506
510
}
507
511
512
+ // //////////////////////////////////////////////////////////////////////////////
513
+ // BigInt Class
514
+ // //////////////////////////////////////////////////////////////////////////////
515
+
516
+ inline BigInt BigInt::New (napi_env env, int64_t val) {
517
+ napi_value value;
518
+ napi_status status = napi_create_double (env, val, &value);
519
+ NAPI_THROW_IF_FAILED (env, status, BigInt ());
520
+ return BigInt (env, value);
521
+ }
522
+
523
+ inline BigInt BigInt::New (napi_env env, uint64_t val) {
524
+ napi_value value;
525
+ napi_status status = napi_create_bigint_uint64 (env, val, &value);
526
+ NAPI_THROW_IF_FAILED (env, status, BigInt ());
527
+ return BigInt (env, value);
528
+ }
529
+
530
+ inline BigInt BigInt::New (napi_env env, int sign_bit, size_t word_count, uint64_t * words) {
531
+ napi_value value;
532
+ napi_status status = napi_create_bigint_words (env, sign_bit, word_count, words, &value);
533
+ NAPI_THROW_IF_FAILED (env, status, BigInt ());
534
+ return BigInt (env, value);
535
+ }
536
+
537
+ inline BigInt::BigInt () : Value() {
538
+ }
539
+
540
+ inline BigInt::BigInt (napi_env env, napi_value value) : Value(env, value) {
541
+ }
542
+
543
+ inline int64_t BigInt::Int64Value (bool * lossless) const {
544
+ int64_t result;
545
+ napi_status status = napi_get_value_bigint_int64 (
546
+ _env, _value, &result, lossless);
547
+ NAPI_THROW_IF_FAILED (_env, status, 0 );
548
+ return result;
549
+ }
550
+
551
+ inline uint64_t BigInt::Uint64Value (bool * lossless) const {
552
+ uint64_t result;
553
+ napi_status status = napi_get_value_bigint_uint64 (
554
+ _env, _value, &result, lossless);
555
+ NAPI_THROW_IF_FAILED (_env, status, 0 );
556
+ return result;
557
+ }
558
+
559
+ inline size_t BigInt::WordCount () const {
560
+ size_t word_count;
561
+ napi_status status = napi_get_bigint_word_count (_env, _value, &word_count);
562
+ NAPI_THROW_IF_FAILED (_env, status, 0 );
563
+ return word_count;
564
+ }
565
+
566
+ inline void BigInt::ToWords (int * sign_bit, size_t * word_count, uint64_t * words) {
567
+ napi_status status = napi_get_value_bigint_words (_env, _value, sign_bit, wourd_count, words);
568
+ NAPI_THROW_IF_FAILED (_env, status);
569
+ }
570
+
571
+ inline void ToWords (int * sign_bit, size_t * word_count, uint64_t * words) {}
572
+
508
573
// //////////////////////////////////////////////////////////////////////////////
509
574
// Name class
510
575
// //////////////////////////////////////////////////////////////////////////////
0 commit comments