JavaScript library to notify watchers of changes
Note: this ended up catching a typo instead of fixing what I said below: it was not meant to be executed immediately.

Why do you need something that's effectively an IIFE? Can't you just use:

const watchMap = new Map();

const watch = (objId, obj) =&gt; {
    if (isObjWatched(objId))
        throw objectAlreadyWatched(objId);

    watchMap.set(objId, {
        obj: obj,

        onChange: () =&gt; {}
    });
};

// ...

module.exports = {
    watch,
    unwatch,
    onChange,
    get,
    set,
    reset
};