*Make bls export an async wrapper to prevent top-level await
This commit is contained in:
parent
a74045db4a
commit
1028fc1bb0
17
src/index.ts
17
src/index.ts
|
@ -4,11 +4,16 @@ import {getImplementation} from "./getImplementation.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]";
|
||||
|
||||
let bls: IBls;
|
||||
try {
|
||||
bls = await getImplementation(isNode ? "blst-native" : "herumi");
|
||||
} catch (e) {
|
||||
bls = await getImplementation("herumi");
|
||||
}
|
||||
export const bls = async (): Promise<IBls> => {
|
||||
let bls: IBls;
|
||||
|
||||
try {
|
||||
bls = await getImplementation(isNode ? "blst-native" : "herumi");
|
||||
} catch (e) {
|
||||
bls = await getImplementation("herumi");
|
||||
}
|
||||
|
||||
return bls;
|
||||
};
|
||||
|
||||
export default bls;
|
||||
|
|
Reference in New Issue