Skip to content

Commit 9e973ab

Browse files
refactor: check for Node + Dart2JS.
1 parent 020101f commit 9e973ab

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/src/platform_check/node_crypto.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ library nodecrypto;
33

44
import 'dart:js_interop';
55

6+
const bool isWASM = bool.fromEnvironment('dart.tool.dart2wasm');
7+
68
@JS()
79
@staticInterop
810
class Process {}
@@ -22,7 +24,7 @@ extension on Versions {
2224
external JSAny get node;
2325
}
2426

25-
bool get isNodeJS => _process?.versions?.node != null;
27+
bool get isNodeDart2JS => _process?.versions?.node != null && !isWASM;
2628

2729
@JS()
2830
@staticInterop

lib/src/platform_check/web.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'platform_check.dart';
1010

1111
class PlatformWeb extends Platform {
1212
static final PlatformWeb instance = PlatformWeb();
13-
static bool useBuiltInRng = !isNodeJS;
13+
static bool useBuiltInRng = !isNodeDart2JS;
1414

1515
const PlatformWeb();
1616

0 commit comments

Comments
 (0)