Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    BrittanyDilts
    @BrittanyDilts
    Yeah, I wanted to make sure I was expecting the right stuff to happen.
    Nope, that didn't work.
    So that's the code, being debugged. You can see "theseOrders" is an array of non-empty objects.
    Jordan Eldredge
    @captbaritone
    Hmm, that url doesn't work for me
    Can you just drag it into Gitter?
    BrittanyDilts
    @BrittanyDilts
    imgpsh_fullsize.png
    imgpsh_fullsize.png
    And there's the result of checking what "thisOrder" is. I expected it to be one of the non-empty objects. Is that a correct expectation?
    Jordan Eldredge
    @captbaritone
    I think it might just be confusion about how the debugger is working
    I think you are not yet in the scope of the callback, you are still in the outer scope
    BrittanyDilts
    @BrittanyDilts
    It always comes back to scope. What would you recommend?
    Jordan Eldredge
    @captbaritone
    And thisOrder is not defined in the outer scope.
    Just add a few new lines inside your callback so that it's easier to set a breakpoint in there.
    BrittanyDilts
    @BrittanyDilts
    Screenshot (1).png
    Ah. I see what you mean.
    It is populated now in the debugger, but not filtering as I expect it to.
    Jordan Eldredge
    @captbaritone
    What is the value of thisOrder?
    BrittanyDilts
    @BrittanyDilts
    Now that it's populated, it's the same as one of the entries in the theseOrders array.
    It could be because I am edgily trying to compare Date Strings.
    (is this one bigger than that one, etc.)
    Jordan Eldredge
    @captbaritone
    Yeah, that's probably not safe
    What format is the date string?
    BrittanyDilts
    @BrittanyDilts
    one of them is yyyy-mm-dd and the other is yyyy-mm-ddThh:MM:ss
    Jordan Eldredge
    @captbaritone
    I would add console.log(a, b, a <= b)
    BrittanyDilts
    @BrittanyDilts
    My very quick research into ASCII codes told me that would PROBABLY work.
    Jordan Eldredge
    @captbaritone
    Yeah, it seems dangerous (you should probably try to find a better way), but i would expect it to work as well.
    BrittanyDilts
    @BrittanyDilts
    Capture.PNG
    Apparently it doesn't work.
    I was expecting 0 to evaluate to less than 2.
    headdesk
    Capture.PNG
    That's better. It still doesn't filter out the last two objects from the resulting array, though.
    Well, that's all right. It's 5 here. I'm taking off. Thank you for your help!
    BrittanyDilts
    @BrittanyDilts
    I think I've got it to a working state. I appreciate it!
    Jordan Eldredge
    @captbaritone
    Great!
    Have a good weekend.
    Colton Donnelly
    @donnellycolton
    I'm learning cordova right now and trying to use underscore's isEqual function. I understand it comes with cordovalib, does anybody know how i can use it in my index.js?
    i also don't usually do webdev
    Jordan Eldredge
    @captbaritone
    I’m not familiar with Cordovalib. Do you have code you can share?
    Colton Donnelly
    @donnellycolton
    Fixed it: needed to npm install underscore, then copy underscore-min.js to platforms/[platform]/platform_www and do <script ... src="underscore-min.js"/> in my index.html
    @captbaritone I was fetching an object from a server and checking equality locally
    Colton Donnelly
    @donnellycolton
    working on a custom version of cordova-plugin-fetch and was testing it in an app, so did this in my index.js:
    tryFetch: function() {
        var parentElement = document.getElementById("fetchjson");
        var fetchingElement = parentElement.querySelector('.fetching');
        var verifiedElement = parentElement.querySelector('.verified');
        var invalidElement = parentElement.querySelector('.invalid');
    
        fetchingElement.setAttribute('style', 'display:block;');
        verifiedElement.setAttribute('style', 'display:none;');
        invalidElement.setAttribute('style', 'display:none;');
    
        // mvpnFetch should work, cordovaFetch shouldn't
        //cordovaFetch('http://server.local/json.json')
        mvpnFetch('http://server.local/json.json')
            .then(function(response) {
                return response.json();
            })
            .then(function(json) {
                console.log(json);
                fetchingElement.setAttribute('style', 'display:none;');
                if (_.isEqual(json.body, expectedJsonFromFetch)) {
                    verifiedElement.setAttribute('style', 'display:block');
                } else {
                    invalidElement.setAttribute('style', 'display:block');
                }
            })
    }
    
    const expectedJsonFromFetch = {
        "hello": "world",
        "number": 1,
        "subobject": {
            "key": "val"
        },
        "array": [
            "one",
            2,
            true
        ]
    }
    Jordan Eldredge
    @captbaritone
    Glad you got something sorted out.
    cabyambo
    @cabyambo
    Does anyone know if you can use underscore with cloud functions? I'm very new to javascript and coding in general, sorry for such a simple question!
    Jordan Eldredge
    @captbaritone
    Yeah. You can use Underscore anywhere you can use JavaScript.
    jsweibo
    @jsweibo

    https://github.com/jashkenas/underscore/blob/36eef3c118041ae6386b6bba2b48b099e57ca0e5/underscore.js#L861L864

    Hello, everybody.
    when I was reading the source code of throttle, I can't understand the usage of line 861 to line 864.
    sorry, My English is not good, but I will try to describe my question clearly.
    My question is "if remaining <= 0 is true, why still need call clearTimeout() to cancel the timer ?"
    In my opnion, if remaining <= 0 is true, It means timeout must be null or undefined. So It don't need to call clearTimeout().
    If you can give me a hand, I'll be appriciated.

    jsweibo
    @jsweibo
    I got it. Because of setTimeout() can not guarantee execute on time.
    tesoy-xx
    @tesoy-xx
    <script type="text/javascript" src="underscore.js"></script>
    <script type="text/javascript" src="underscore.object.builders.js"></script>

    Can you share a screenshot of the actual usage?
    I might be able to do that. One sec.
    It's probably something funny with the data, but a screenshot of the usage might help rule out any silly errors.
    Yeah, I wanted to make sure I was expecting the right stuff to happen.
    Nope, that didn't work.
    So that's the code, being debugged. You can see "theseOrders" is an array of non-empty objects.
    Hmm, that url doesn't work for me
    Can you just drag it into Gitter?
    imgpsh_fullsize.png
    imgpsh_fullsize.png
    And there's the result of checking what "thisOrder" is. I expected it to be one of the non-empty objects. Is that a correct expectation?
    I think it might just be confusion about how the debugger is working
    I think you are not yet in the scope of the callback, you are still in the outer scope
    It always comes back to scope. What would you recommend?
    And thisOrder is not defined in the outer scope.
    Just add a few new lines inside your callback so that it's easier to set a breakpoint in there.
    Screenshot (1).png
    Ah. I see what you mean.
    It is populated now in the debugger, but not filtering as I expect it to.
    What is the value of thisOrder?
    Now that it's populated, it's the same as one of the entries in the theseOrders array.
    It could be because I am edgily trying to compare Date Strings.
    (is this one bigger than that one, etc.)
    Yeah, that's probably not safe
    What format is the date string?
    one of them is yyyy-mm-dd and the other is yyyy-mm-ddThh:MM:ss
    I would add console.log(a, b, a <= b)
    My very quick research into ASCII codes told me that would PROBABLY work.
    Yeah, it seems dangerous (you should probably try to find a better way), but i would expect it to work as well.
    Capture.PNG
    Apparently it doesn't work.
    I was expecting 0 to evaluate to less than 2.
    headdesk
    Capture.PNG
    That's better. It still doesn't filter out the last two objects from the resulting array, though.
    Well, that's all right. It's 5 here. I'm taking off. Thank you for your help!
    I think I've got it to a working state. I appreciate it!
    Great!
    Have a good weekend.
    I'm learning cordova right now and trying to use underscore's isEqual function. I understand it comes with cordovalib, does anybody know how i can use it in my index.js?
    i also don't usually do webdev
    I’m not familiar with Cordovalib. Do you have code you can share?
    Fixed it: needed to npm install underscore, then copy underscore-min.js to platforms/[platform]/platform_www and do <script ... src="underscore-min.js"/> in my index.html
    @captbaritone I was fetching an object from a server and checking equality locally
    working on a custom version of cordova-plugin-fetch and was testing it in an app, so did this in my index.js:
    tryFetch: function() {
    var parentElement = document.getElementById("fetchjson");
    var fetchingElement = parentElement.querySelector('.fetching');
    var verifiedElement = parentElement.querySelector('.verified');
    var invalidElement = parentElement.querySelector('.invalid');

    fetchingElement.setAttribute('style', 'display:block;');
    verifiedElement.setAttribute('style', 'display:none;');
    invalidElement.setAttribute('style', 'display:none;');
    
    // mvpnFetch should work, cordovaFetch shouldn't
    //cordovaFetch('http://server.local/json.json')
    mvpnFetch('http://server.local/json.json')
        .then(function(response) {
            return response.json();
        })
        .then(function(json) {
            console.log(json);
            fetchingElement.setAttribute('style', 'display:none;');
            if (_.isEqual(json.body, expectedJsonFromFetch)) {
                verifiedElement.setAttribute('style', 'display:block');
            } else {
                invalidElement.setAttribute('style', 'display:block');
            }
        })

    }

    const expectedJsonFromFetch = {
    "hello": "world",
    "number": 1,
    "subobject": {
    "key": "val"
    },
    "array": [
    "one",
    2,
    true
    ]
    }

    ( )