Created
October 15, 2021 17:45
-
-
Save UltiRequiem/580b4710a13bb4a3edd71c8b0bcca8d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Buffer } from "../buffer.ts"; | |
export interface CheckPrimeOptions { | |
checks?: number | undefined; | |
} | |
export function checkPrime( | |
candidate: ArrayBuffer | bigint, | |
options: CheckPrimeOptions = {}, | |
); | |
export function checkPrime( | |
candidate: ArrayBuffer | bigint, | |
options: CheckPrimeOptions = {}, | |
callback: (err: Error | null, result: boolean) => void, | |
) { | |
if (typeof candidate === "bigint") { | |
const hex = candidate.toString(16); | |
const padded = hex.padStart(hex.length + (hex.length % 2), ""); | |
candidate = Buffer.from(padded, "hex"); | |
} | |
if (typeof options === "function") { | |
callback = options; | |
options = {}; | |
} | |
const { checks = 0 } = options; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment