Compare commits
2 Commits
a74045db4a
...
99f7fe9976
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 99f7fe9976 | |
Derrick Hammer | 1028fc1bb0 |
|
@ -1,3 +1,3 @@
|
|||
import type { IBls } from "./types.js";
|
||||
declare let bls: IBls;
|
||||
export declare const bls: () => Promise<IBls>;
|
||||
export default bls;
|
||||
|
|
17
lib/index.js
17
lib/index.js
|
@ -1,11 +1,14 @@
|
|||
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;
|
||||
try {
|
||||
bls = await getImplementation(isNode ? "blst-native" : "herumi");
|
||||
}
|
||||
catch (e) {
|
||||
bls = await getImplementation("herumi");
|
||||
}
|
||||
export const bls = async () => {
|
||||
let bls;
|
||||
try {
|
||||
bls = await getImplementation(isNode ? "blst-native" : "herumi");
|
||||
}
|
||||
catch (e) {
|
||||
bls = await getImplementation("herumi");
|
||||
}
|
||||
return bls;
|
||||
};
|
||||
export default bls;
|
||||
|
|
File diff suppressed because one or more lines are too long
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