(candidate, options = kEmptyObject, callback)
| 582 | } |
| 583 | |
| 584 | function checkPrime(candidate, options = kEmptyObject, callback) { |
| 585 | if (typeof candidate === 'bigint') |
| 586 | candidate = unsignedBigIntToBuffer(candidate, 'candidate'); |
| 587 | if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) { |
| 588 | throw new ERR_INVALID_ARG_TYPE( |
| 589 | 'candidate', |
| 590 | [ |
| 591 | 'ArrayBuffer', |
| 592 | 'TypedArray', |
| 593 | 'Buffer', |
| 594 | 'DataView', |
| 595 | 'bigint', |
| 596 | ], |
| 597 | candidate, |
| 598 | ); |
| 599 | } |
| 600 | if (typeof options === 'function') { |
| 601 | callback = options; |
| 602 | options = kEmptyObject; |
| 603 | } |
| 604 | validateFunction(callback, 'callback'); |
| 605 | validateObject(options, 'options'); |
| 606 | let { |
| 607 | checks = 0, |
| 608 | } = options; |
| 609 | |
| 610 | // The checks option is unsigned but must fit into a signed C int for OpenSSL. |
| 611 | validateInt32(checks, 'options.checks', 0); |
| 612 | // Coerce -0 to +0. |
| 613 | checks += 0; |
| 614 | |
| 615 | const job = new CheckPrimeJob(kCryptoJobAsync, candidate, checks); |
| 616 | job.ondone = callback; |
| 617 | job.run(); |
| 618 | } |
| 619 | |
| 620 | function checkPrimeSync(candidate, options = kEmptyObject) { |
| 621 | if (typeof candidate === 'bigint') |
no test coverage detected
searching dependent graphs…