augment-vir - v31.13.0
    Preparing search index...

    Function getOrSet

    Given an object, tries to get the given key in that object. If the key is not in that object, then the given createCallback is used to create a new value which is then stored in the given object and returned. Automatically handles an async createCallback.

    // instead of doing this
    if (!myObject[myKey]) {
    myObject[myKey] = {};
    }
    myObject[myKey]![nextKey] = 'some value';

    // do this
    getOrSetInObject(myObject, myKey, () => {
    return {};
    });