Add herumi fallback in default export

This commit is contained in:
Cayman 2022-04-13 13:48:25 -05:00
parent a8aa891768
commit 501f93e333
No known key found for this signature in database
GPG Key ID: 54B21AEC3C53E1F5
1 changed files with 7 additions and 1 deletions

View File

@ -1,8 +1,14 @@
import type {IBls} from "./interface.js";
import {getImplementation} from "./getImplementation.js"; import {getImplementation} from "./getImplementation.js";
// Thanks https://github.com/iliakan/detect-node/blob/master/index.esm.js // Thanks https://github.com/iliakan/detect-node/blob/master/index.esm.js
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]"; const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
const bls = await getImplementation(isNode ? "blst-native" : "herumi"); let bls: IBls;
try {
bls = await getImplementation(isNode ? "blst-native" : "herumi");
} catch (e) {
bls = await getImplementation("herumi");
}
export default bls; export default bls;