Giter VIP home page Giter VIP logo

Comments (4)

mansisce avatar mansisce commented on May 24, 2024

Please provide more details on the same

from cs-playground-react.

no-stack-dub-sack avatar no-stack-dub-sack commented on May 24, 2024

@mansisce right now there is an issue with the loop protection, for example, if you try to run the solution of Anagram Palindrome, the loop-protect babel transform is not working correctly and the tests don't run. This has to do with the fact that there was an issue with adding loop-protect to code that is unaffected by the babel transform (i.e. code that doesn't have loops, or loops that aren't recognized by loop-protect as having the potential to be infinite like for...of and for...in.

I've figured out the issue though, and essentially what is happening is that when loop-protect transforms code, it trims white space at either end of the code string, and thus is concatenating it with the tests array undesirably.

So, what needs to happen, is starting here, lines 30 & 31 can be replaced with:

  // apply loop-protect if not disabled by user
  if (!DISABLE_LOOP_PROTECT.test(code)) 
    code = loopProtect(code) + '\n'

this will make it so that all code is transformed by loop-protect unless the user has left a // DISABLE LOOP PROTECT comment in their code.

Since we're not using HAS_LOOPS any more, or trimComments both of those imports can be removed, as well as the trim-code.js file and the HAS_LOOPS declaration in the regexp.js file.

You can test that all of this works by running the anagram palindrome solution to make sure all the tests pass, and by going to the Sorting Algo Benchmarks repl and making sure that runs as well (toggle on and off the disable loop protect comment and make sure it runs both ways, when disable loop protect is enabled, it should throw a range error)

Let me know if all of this makes sense or if you have any questions!

from cs-playground-react.

no-stack-dub-sack avatar no-stack-dub-sack commented on May 24, 2024

Also, if you're working in these files, starting here, lines 41-44 can be replaced with console.log(e.toString()) as long as we change the error being thrown to a new RangeError instead of just new Error right here

from cs-playground-react.

no-stack-dub-sack avatar no-stack-dub-sack commented on May 24, 2024

Finally, I've also been thinking about changing the timeout from 500 to 200 ms for loop-protection. If you end up taking this on, let's go ahead and make that change as well (to both the timeout declaration and the error message in the loop-protect.js file

from cs-playground-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.