Skip to content
View jaquinocode's full-sized avatar

Block or report jaquinocode

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse

Pinned Loading

  1. setdefault but for JavaScript. setde... setdefault but for JavaScript. setdefault is a function in Python which can be used to get around using a defaultdict. Here I recreate the behavior in JavaScript.
    1
    const getDefault = (o, key, defaultVal) => key in o ? o[key] : o[key] = defaultVal
    2
    
                  
    3
    // Prototype version of above. Allows for usage: o.getDefault(key, def)
    4
    Object.defineProperty(Object.prototype, "getDefault", {
    5
      value: function(key, defaultVal) {
  2. range function for JavaScript. range... range function for JavaScript. range is a function that's central to Python that I've implemented in JS. Here, it's a generator just like how it is in Python. Works with negative number arguments.
    1
    function* range(start, stop, step=1) {
    2
        if(typeof stop === 'undefined') [start, stop] = [0, start]
    3
        for(let i = start; step > 0 ? i < stop : i > stop; i += step)
    4
            yield i
    5
    }