Skip to content

Instantly share code, notes, and snippets.

@UltiRequiem
Created October 15, 2021 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UltiRequiem/580b4710a13bb4a3edd71c8b0bcca8d5 to your computer and use it in GitHub Desktop.
Save UltiRequiem/580b4710a13bb4a3edd71c8b0bcca8d5 to your computer and use it in GitHub Desktop.
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