Giter Site home page Giter Site logo

recurrence.next(1) hangs about moment-recur HOT 9 OPEN

zhex900 avatar zhex900 commented on September 5, 2024 2
recurrence.next(1) hangs

from moment-recur.

Comments (9)

Hyperblaster avatar Hyperblaster commented on September 5, 2024 2

Wouldn’t the expected behaviour be to throw an error? Currently it freezes the entite process or crashes the browser.

In version 1.0.5 it works perfectly.

from moment-recur.

zhex900 avatar zhex900 commented on September 5, 2024

I guess it is not possible to have compound intervals.

// It is NOT possible to create compound intervals. The following will never match.

from moment-recur.

Hyperblaster avatar Hyperblaster commented on September 5, 2024

Just hit this bug also! Such a pain in the neck.

Rolling back to version 1.0.5 it works fine

from moment-recur.

jefbarn avatar jefbarn commented on September 5, 2024

You are starting your recurrence on a Monday and asking for every 3 weeks, which will always be a Monday, but then also saying to only match Tuesdays, so it will never match anything.
Try starting from 01/02/2018

from moment-recur.

jefbarn avatar jefbarn commented on September 5, 2024

I think expected result would be to return an empty array (nothing matches this query).
The reason it never returns is the code is busy looking for a date that will match these conditions that doesn't exist and will try all dates until the end date.

from moment-recur.

Hyperblaster avatar Hyperblaster commented on September 5, 2024

from moment-recur.

Hyperblaster avatar Hyperblaster commented on September 5, 2024

Any response to this? It works perfectly in 1.0.5 but crashes javascript 1.0.7

from moment-recur.

YaoHuiJi avatar YaoHuiJi commented on September 5, 2024

I find that the recur.maches function works perfectly ,so I use my own next function to solve this issue temporary, maybe it's helpful for someone, you can change the function to return an array if you need

    function next(start, end, recur) {
        let result = null, cur = start;

        while (cur < end) {

            if (recur.matches(cur)) {
                result = cur;
                break;
            }

            cur.add(1, 'day');
        }

        return result;
    }

from moment-recur.

joaom182 avatar joaom182 commented on September 5, 2024

@Hyperblaster thanks! I've rollback to version 1.0.5 and works perfectly.

from moment-recur.

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.