Skip to content

Dart2JS/DDC: Re-use native BigInt where possible #32399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
matanlurey opened this issue Mar 3, 2018 · 4 comments
Open

Dart2JS/DDC: Re-use native BigInt where possible #32399

matanlurey opened this issue Mar 3, 2018 · 4 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js

Comments

@matanlurey
Copy link
Contributor

V8/Blink release notes:
https://groups.google.com/forum/#!msg/v8-dev/x571Gr0khNo/y8Jk0_vSBAAJ

@piyushchauhan2011
Copy link

Any updates on this issue ?

@matanlurey
Copy link
Contributor Author

Since this is not supported in all browsers, and works without re-using, it's not a priority.

@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 20, 2019
@lexaknyazev
Copy link
Contributor

Although Dart's BigInt works on its own, it is not directly interoperable with JS BigInt values that may come from external APIs linked via package:js.

@lexaknyazev
Copy link
Contributor

An interop workaround:

import 'package:js/js.dart';
import 'package:js/js_util.dart';

@JS('BigInt')
external Function get _JSBigInt;

Object _toJsBigInt(BigInt value) => _JSBigInt(value.toString()) as Object;

BigInt _fromJsBigInt(Object jsBigInt) =>
    BigInt.parse(callMethod(jsBigInt, 'toString', const []) as String);

bool _isJsBigInt(Object jsBigInt) =>
    getProperty(getProperty(jsBigInt, 'constructor') as Object, 'name') ==
    'BigInt';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants