In a compiled node module, why do I see (private)

2019-08-31 02:53发布

问题:

I'm using Mapbox GL JS, and I've found a private method that might be useful in solving a problem. It's _requestRenderFrame in map.js, and looks like this:

/**
 * Request that the given callback be executed during the next render
 * frame.  Schedule a render frame if one is not already scheduled.
 * @returns An id that can be used to cancel the callback
 * @private
 */
_requestRenderFrame(callback: () => void): TaskID {
    this._update();
    return this._renderTaskQueue.add(callback);
}

If I try to reference it in my project, I get undefined.

console.log(this.host.map['_requestRenderFrame']) // undefined;

When I search the mapbox package within my node_modules folder, I only see results for "_requestRenderFrame" in dist/mapbox-gl-dev.js.map.

There's other stuff that goes along with this feature that's not in there, so I can't really just hack the method back in on the fly.

I'm missing something. How can a method in source be omitted from compiled code? I have a hunch it may be just for testing??? But still, is there any way for me to use the omitted feature?