Compare commits

..

2 Commits

4 changed files with 23 additions and 15 deletions

2
lib/index.d.ts vendored
View File

@ -1,3 +1,3 @@
import type { IBls } from "./types.js"; import type { IBls } from "./types.js";
declare let bls: IBls; export declare const bls: () => Promise<IBls>;
export default bls; export default bls;

View File

@ -1,11 +1,14 @@
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]";
let bls; export const bls = async () => {
try { let bls;
try {
bls = await getImplementation(isNode ? "blst-native" : "herumi"); bls = await getImplementation(isNode ? "blst-native" : "herumi");
} }
catch (e) { catch (e) {
bls = await getImplementation("herumi"); bls = await getImplementation("herumi");
} }
return bls;
};
export default bls; export default bls;

File diff suppressed because one or more lines are too long

View File

@ -4,11 +4,16 @@ 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]";
let bls: IBls; export const bls = async (): Promise<IBls> => {
try { let bls: IBls;
try {
bls = await getImplementation(isNode ? "blst-native" : "herumi"); bls = await getImplementation(isNode ? "blst-native" : "herumi");
} catch (e) { } catch (e) {
bls = await getImplementation("herumi"); bls = await getImplementation("herumi");
} }
return bls;
};
export default bls; export default bls;