diff --git a/helpers/javascript/CustomFxNoArgs.js b/helpers/javascript/CustomFxNoArgs.js index 56d3dbb3d..033f2c8b0 100644 --- a/helpers/javascript/CustomFxNoArgs.js +++ b/helpers/javascript/CustomFxNoArgs.js @@ -1,14 +1,14 @@ -// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild +'use strict'; (function (root, factory) { if (typeof define === 'function' && define.amd) { - define(['kaitai-struct/KaitaiStream'], factory); - } else if (typeof module === 'object' && module.exports) { - module.exports = factory(require('kaitai-struct/KaitaiStream')); + define(['exports', 'kaitai-struct/KaitaiStream'], factory); + } else if (typeof exports === 'object' && exports !== null && typeof exports.nodeType !== 'number') { + factory(exports, require('kaitai-struct/KaitaiStream')); } else { - root.CustomFxNoArgs = factory(root.KaitaiStream); + factory(root.CustomFxNoArgs || (root.CustomFxNoArgs = {}), root.KaitaiStream); } -}(this, function (KaitaiStream) { +})(typeof self !== 'undefined' ? self : this, function (CustomFxNoArgs_, KaitaiStream) { var CustomFxNoArgs = (function() { function CustomFxNoArgs() { } @@ -25,5 +25,5 @@ var CustomFxNoArgs = (function() { return CustomFxNoArgs; })(); -return CustomFxNoArgs; -})); +CustomFxNoArgs_.CustomFxNoArgs = CustomFxNoArgs; +}); diff --git a/helpers/javascript/MyCustomFx.js b/helpers/javascript/MyCustomFx.js index 0bd85acd4..8bf6a21c8 100644 --- a/helpers/javascript/MyCustomFx.js +++ b/helpers/javascript/MyCustomFx.js @@ -1,14 +1,14 @@ -// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild +'use strict'; (function (root, factory) { if (typeof define === 'function' && define.amd) { - define(['kaitai-struct/KaitaiStream'], factory); - } else if (typeof module === 'object' && module.exports) { - module.exports = factory(require('kaitai-struct/KaitaiStream')); + define(['exports', 'kaitai-struct/KaitaiStream'], factory); + } else if (typeof exports === 'object' && exports !== null && typeof exports.nodeType !== 'number') { + factory(exports, require('kaitai-struct/KaitaiStream')); } else { - root.MyCustomFx = factory(root.KaitaiStream); + factory(root.MyCustomFx || (root.MyCustomFx = {}), root.KaitaiStream); } -}(this, function (KaitaiStream) { +})(typeof self !== 'undefined' ? self : this, function (MyCustomFx_, KaitaiStream) { var MyCustomFx = (function() { function MyCustomFx(key, flag, someBytes) { this.key = flag ? key : -key; @@ -18,11 +18,11 @@ var MyCustomFx = (function() { var dest = new Uint8Array(len); for (var i = 0; i < len; i++) { dest[i] = src[i] + this.key; - } + } return dest; } return MyCustomFx; })(); -return MyCustomFx; -})); +MyCustomFx_.MyCustomFx = MyCustomFx; +}); diff --git a/helpers/javascript/nested-deeply/CustomFx.js b/helpers/javascript/nested-deeply/CustomFx.js index 437634e1c..a9a318dde 100644 --- a/helpers/javascript/nested-deeply/CustomFx.js +++ b/helpers/javascript/nested-deeply/CustomFx.js @@ -1,14 +1,14 @@ -// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild +'use strict'; (function (root, factory) { if (typeof define === 'function' && define.amd) { - define(['kaitai-struct/KaitaiStream'], factory); - } else if (typeof module === 'object' && module.exports) { - module.exports = factory(require('kaitai-struct/KaitaiStream')); + define(['exports', 'kaitai-struct/KaitaiStream'], factory); + } else if (typeof exports === 'object' && exports !== null && typeof exports.nodeType !== 'number') { + factory(exports, require('kaitai-struct/KaitaiStream')); } else { - root.CustomFx = factory(root.KaitaiStream); + factory(root.CustomFx || (root.CustomFx = {}), root.KaitaiStream); } -}(this, function (KaitaiStream) { +})(typeof self !== 'undefined' ? self : this, function (CustomFx_, KaitaiStream) { var CustomFx = (function() { function CustomFx(key) { this.key = key; @@ -26,5 +26,5 @@ var CustomFx = (function() { return CustomFx; })(); -return CustomFx; -})); +CustomFx_.CustomFx = CustomFx; +}); diff --git a/helpers/javascript/testHelper.js b/helpers/javascript/testHelper.js index ca50a9df7..e56a3573c 100644 --- a/helpers/javascript/testHelper.js +++ b/helpers/javascript/testHelper.js @@ -4,7 +4,7 @@ function testHelper(className, fileName, testFunc) { describe(className, function() { it('parses test properly', function(done) { - var parser = require(className); + var parser = require(className)[className]; fs.readFile(fileName, function(err, buf) { if (err) { done(err); diff --git a/helpers/javascript/testHelperStream.js b/helpers/javascript/testHelperStream.js index 7a09be119..feff8c517 100644 --- a/helpers/javascript/testHelperStream.js +++ b/helpers/javascript/testHelperStream.js @@ -4,7 +4,7 @@ function testHelperStream(className, fileName, testFunc) { describe(className, function() { it('parses test properly', function(done) { - var parser = require(className); + var parser = require(className)[className]; fs.readFile(fileName, function(err, buf) { var st = new KaitaiStream(buf); testFunc(st, parser); diff --git a/helpers/javascript/testHelperThrows.js b/helpers/javascript/testHelperThrows.js index 7486dafd3..bbdc2b517 100644 --- a/helpers/javascript/testHelperThrows.js +++ b/helpers/javascript/testHelperThrows.js @@ -6,7 +6,7 @@ function testHelperThrows(className, fileName, excClass) { describe(className, function() { it('parses test properly', function(done) { assert.ok(excClass); - var parser = require(className); + var parser = require(className)[className]; fs.readFile(fileName, function(err, buf) { var st = new KaitaiStream(buf); assert.throws(