wasmedge-quickjs icon indicating copy to clipboard operation
wasmedge-quickjs copied to clipboard

Add function 'check_prime' for node's crypto API

Open Aviii06 opened this issue 3 years ago • 3 comments

This implements one function of node's crypto API. This is to complete the assignment given for lfx

Aviii06 avatar Aug 29 '22 19:08 Aviii06

flows summarize

juntao avatar Apr 05 '23 23:04 juntao

Hello, I am a serverless review bot on flows.network. Here are my reviews of code commits in this PR.


Commit 1

This patch introduces a new function 'check_prime' to the node's crypto API. Here's a summary of the key changes:

  1. Add 'check_prime' function in 'src/internal_module/crypto.rs'.
    • The function checks if a given integer is prime or not and returns a boolean value. It takes an integer parameter and throws a type error if the parameter is not an integer.
  2. Import and use the new 'check_prime' function in 'example_js/node/main.mjs'.
  3. Add necessary Rollup configurations and dependencies to 'example_js/node/package.json'.
  4. Update the module initialization in 'src/quickjs_sys/mod.rs' to include the new crypto module.
  5. Modify 'src/internal_module/mod.rs' to include the crypto module.
  6. A small change in 'src/internal_module/os.rs' just adds a newline at the end of the file.

Potential problems:

  1. The check_prime function can be optimized further, as it checks for divisibility with even numbers after 2, which isn't necessary.
  2. There's no error handling in case the user tries to run 'check_prime' with a very large number, which could lead to performance issues.
  3. The added dependencies might lead to conflicts, so it's essential to test various use cases with the new function to ensure there aren't any unexpected dependency conflicts in the long run.

juntao avatar Apr 05 '23 23:04 juntao

Hi @L-jasmine

I think this PR is to apply for the LFX mentorship. If we're not going to merge this PR, please close this PR. Thanks.

alabulei1 avatar Jan 25 '24 11:01 alabulei1