Giter VIP home page Giter VIP logo

Comments (10)

danielroe avatar danielroe commented on May 30, 2024 3

This is definitely a worthy enhancement. I think @didavid61202 might be working on this very thing (so let's wait to hear from him), but if not then contribution would be very welcome ❤️

from magic-regexp.

michaelschufi avatar michaelschufi commented on May 30, 2024 1

Yes, I've been working on a new type inferencing (fully parse, interpret, exact match, permutation all possible values) for string.match, string.replace, string.matchAll and string.replaceAll

Sounds awesome! 😀
Of course, if the other functions can also benefit of the inference, it's even better. I haven't worked yet with .replace with this library, but this sounds really game changing. It makes it so much easier to work with string manipulation of all kind.

The inference looks great so far. Tell me if I can help with some testing or similar.

from magic-regexp.

didavid61202 avatar didavid61202 commented on May 30, 2024 1

Sounds awesome! 😀

Of course, if the other functions can also benefit of the inference, it's even better. I haven't worked yet with .replace with this library, but this sounds really game changing. It makes it so much easier to work with string manipulation of all kind.

The inference looks great so far. Tell me if I can help with some testing or similar.

Definitely would love to have some helps on testing and improving it! ❤️

Will let you know as soon as I finish wrapping it up. 👍

from magic-regexp.

michaelschufi avatar michaelschufi commented on May 30, 2024 1

HI @didavid61202
Thank you. I've got a lot on my plate right now, so it might take me a moment. But I'll try to have a look at it this weekend.

from magic-regexp.

michaelschufi avatar michaelschufi commented on May 30, 2024 1

Sorry for my late response @didavid61202
I have tested the repo lately, and I couldn't find any breaking issue. I'm in awe of what this thing can do! 😍

Only one negative thing that I noticed: It seems to push either VS Code or the typescript language server to their limits. But this could be because of my pc, VS Code, TS, TLS, the repo itself with many complex examples, or any combination of those things...

I have a few minor things that I would like to discuss. E.g. what the restInput key represents. Should I file an issue in your repo?

from magic-regexp.

didavid61202 avatar didavid61202 commented on May 30, 2024 1

Hi @michaelschufi, thanks!
Yes, I think this is pushing the language server to its limit by both lots of recursions and also lots of test examples. 😂 There are some performance issues that can be improved by a better parser and match algorithm. I've been testing some benchmark methods and I will start by rewriting the ParseRegExp generic. Any inputs regarding performance improvement are welcome!

Do file issues if you have any questions 👍
The restInput generic argument in RegExpMatchResult represents the rest of input string that is not matched by the regexp provided, it's used for resolving the preceding string before the matching string, and getting the preceding string length for index value of the match result.

from magic-regexp.

michaelschufi avatar michaelschufi commented on May 30, 2024 1

Hi @didavid61202
About performance:
I've just read about the TypeScript 5.1 Beta's release notes and came across the Negative Case Checks for Union Literals section. Maybe those optimizations also affect the regex type literals.

from magic-regexp.

didavid61202 avatar didavid61202 commented on May 30, 2024

Hi @michaelschufi,

Yes, I've been working on features similar to this, although might be in very different approach, it's a new type inferencing (fully parse, interpret, exact match, permutation all possible values) for string.match, string.replace, string.matchAll and string.replaceAll,

a little peek at what's possible (blue text are type hints from vscode-twoslash-queries), still testing out with pure string literal:
type_level_regexp

Still have to finish writing more robust test cases and testing for some edge cases.

from magic-regexp.

didavid61202 avatar didavid61202 commented on May 30, 2024

Hi @michaelschufi, Here's the repository for the type-level RegExp parser and matcher. Check out examples in the 'tests/index.test-d.ts' file and others when you have some time. Please let me know if you encounter any issues or have any ideas. Thank you! 😄

👉 https://github.com/didavid61202/type-level-regexp

from magic-regexp.

didavid61202 avatar didavid61202 commented on May 30, 2024

Hi @michaelschufi, thanks for the info! 👍
I'll have to check if this affect the current implementation, or how we can utilize this to improve the performance

from magic-regexp.

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.