protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

fix: util.global = global when this is undefined

Open ZhiruiLi opened this issue 4 years ago • 0 comments

this may be undefined in strict mode, because source code may be wrapped by some lambda function before being executed. In this case, error will occur in the following code:

util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
         || /* istanbul ignore next */ util.global.Long
         || util.inquire("long");

Instead keeps the util.global as undefined, we assign user defined global to util.global. This can be very useful when using protobuf.js in some specifical env (for example: game engine).

ZhiruiLi avatar Mar 30 '21 09:03 ZhiruiLi