diff options
author | Iain van der Bloat <ibloat@users.noreply.github.com> | 2017-04-08 09:14:01 +0900 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2017-04-07 17:14:01 -0700 |
commit | adc50051e00d8d8568e1c791c30e1da53e6e4b01 (patch) | |
tree | 1e81beb2f6f0a238d1a42896ba240437f2ab8aba /js | |
parent | 2aec880347394c04862dbbba3a1c09740e3a2198 (diff) | |
download | flatbuffers-adc50051e00d8d8568e1c791c30e1da53e6e4b01.tar.gz flatbuffers-adc50051e00d8d8568e1c791c30e1da53e6e4b01.tar.bz2 flatbuffers-adc50051e00d8d8568e1c791c30e1da53e6e4b01.zip |
make flatbuffers.js into a UMD module (#4228)
Diffstat (limited to 'js')
-rw-r--r-- | js/flatbuffers.js | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/js/flatbuffers.js b/js/flatbuffers.js index 2e34e98b..4a2bd236 100644 --- a/js/flatbuffers.js +++ b/js/flatbuffers.js @@ -3,18 +3,14 @@ /// @{ /// @cond FLATBUFFERS_INTERNAL -/** - * @fileoverview - * - * Need to suppress 'global this' error so the Node.js export line doesn't cause - * closure compile to error out. - * @suppress {globalThis} - */ - -/** - * @const - * @namespace - */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = { flatbuffers: factory() } : + typeof define === 'function' && define.amd ? define(factory) : + (global.flatbuffers = factory()); +}(this, (function () { 'use strict'; +/** +* @exports flatbuffers +*/ var flatbuffers = {}; /** @@ -1160,8 +1156,9 @@ flatbuffers.ByteBuffer.prototype.createLong = function(low, high) { return flatbuffers.Long.create(low, high); }; -// Exports for Node.js and RequireJS -this.flatbuffers = flatbuffers; +return flatbuffers; + +}))); /// @endcond /// @} |