Lutz Roeder 6 лет назад
Родитель
Сommit
3d3972a511
30 измененных файлов с 504 добавлено и 507 удалено
  1. 9 9
      src/app.js
  2. 3 4
      src/armnn.js
  3. 6 6
      src/bigdl.js
  4. 22 22
      src/caffe.js
  5. 7 6
      src/chainer.js
  6. 18 18
      src/cntk.js
  7. 15 15
      src/coreml.js
  8. 10 10
      src/darknet.js
  9. 12 12
      src/dl4j.js
  10. 3 3
      src/flux.js
  11. 6 6
      src/hdf5.js
  12. 23 23
      src/keras.js
  13. 22 19
      src/mlnet.js
  14. 6 6
      src/mnn.js
  15. 29 29
      src/mxnet.js
  16. 9 9
      src/ncnn.js
  17. 2 2
      src/numpy.js
  18. 26 29
      src/onnx.js
  19. 29 29
      src/openvino.js
  20. 10 10
      src/paddle.js
  21. 7 14
      src/pytorch.js
  22. 16 16
      src/sklearn.js
  23. 42 42
      src/tf.js
  24. 5 5
      src/tflite.js
  25. 19 19
      src/torch.js
  26. 41 41
      src/view-grapher.js
  27. 29 29
      src/view-sidebar.js
  28. 60 56
      src/view.js
  29. 3 3
      src/zip.js
  30. 15 15
      test/test.js

+ 9 - 9
src/app.js

@@ -74,7 +74,7 @@ class Application {
     _parseCommandLine(argv) {
         let open = false;
         if (argv.length > 1) {
-            for (let arg of argv.slice(1)) {
+            for (const arg of argv.slice(1)) {
                 if (!arg.startsWith('-')) {
                     const extension = arg.split('.').pop().toLowerCase();
                     if (extension != '' && extension != 'js' && fs.existsSync(arg) && fs.statSync(arg).isFile()) {
@@ -138,7 +138,7 @@ class Application {
         };
         const selectedFiles = electron.dialog.showOpenDialogSync(showOpenDialogOptions);
         if (selectedFiles) {
-            for (let file of selectedFiles) {
+            for (const file of selectedFiles) {
                 this._openFile(file);
             }
         }
@@ -177,7 +177,7 @@ class Application {
 
     _dropFiles(sender, files) {
         let view = this._views.from(sender);
-        for (let file of files) {
+        for (const file of files) {
             if (view) {
                 this._loadFile(file, view);
                 view = null;
@@ -698,7 +698,7 @@ class View {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -765,7 +765,7 @@ class ViewCollection {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -835,8 +835,8 @@ class MenuService {
         this._menuTemplate = menuTemplate;
         this._commandTable = commandTable;
         this._itemTable = new Map();
-        for (let menu of menuTemplate) {
-            for (let item of menu.submenu) {
+        for (const menu of menuTemplate) {
+            for (const item of menu.submenu) {
                 if (item.id) {
                     if (!item.label) {
                         item.label = '';
@@ -865,7 +865,7 @@ class MenuService {
 
     _updateLabel(context) {
         let rebuild = false;
-        for (let entry of this._commandTable.entries()) {
+        for (const entry of this._commandTable.entries()) {
             const menuItem = this._menu.getMenuItemById(entry[0]);
             const command = entry[1];
             if (command && command.label) {
@@ -882,7 +882,7 @@ class MenuService {
     }
 
     _updateEnabled(context) {
-        for (let entry of this._commandTable.entries()) {
+        for (const entry of this._commandTable.entries()) {
             const menuItem = this._menu.getMenuItemById(entry[0]);
             if (menuItem) {
                 const command = entry[1];

+ 3 - 4
src/armnn.js

@@ -197,8 +197,7 @@ armnn.Node = class {
 
     static castLayer(layer) {
         let layerType = layer.layerType();
-
-        for (let k of Object.keys(armnn.schema.Layer)) {
+        for (const k of Object.keys(armnn.schema.Layer)) {
             if (layerType == armnn.schema.Layer[k]) 
                 return layer.layer(new armnn.schema[k]);
         }
@@ -596,7 +595,7 @@ armnn.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -616,7 +615,7 @@ armnn.Metadata = class {
             if (!attributeMap) {
                 attributeMap = {};
                 if (schema.attributes) {
-                    for (let attribute of schema.attributes) {
+                    for (const attribute of schema.attributes) {
                         attributeMap[attribute.name] = attribute;
                     }
                 }

+ 6 - 6
src/bigdl.js

@@ -88,14 +88,14 @@ bigdl.Graph = class {
 
     _loadSequential(metadata, group, module) {
         group = group.length > 0 ?  group + '.' + module.namePostfix : module.namePostfix;
-        for (let submodule of module.subModules) {
+        for (const submodule of module.subModules) {
             this._loadModule(metadata, group, submodule);
         }
     }
 
     _loadStaticGraph(metadata, group, module) {
         group = group.length > 0 ?  group + '.' + module.namePostfix : module.namePostfix;
-        for (let submodule of module.subModules) {
+        for (const submodule of module.subModules) {
             this._loadModule(metadata, group, submodule);
         }
     }
@@ -197,7 +197,7 @@ bigdl.Node = class {
             ]));
         }
         if (module.parameters && module.parameters.length > 0) {
-            for (let parameter of module.parameters) {
+            for (const parameter of module.parameters) {
                 const input = inputs.shift();
                 const inputName = input ? input.name : this._inputs.length.toString();
                 this._inputs.push(new bigdl.Parameter(inputName, [ 
@@ -205,7 +205,7 @@ bigdl.Node = class {
                 ]));
             }
         }
-        for (let key of Object.keys(module.attr)) {
+        for (const key of Object.keys(module.attr)) {
             const value = module.attr[key];
             if (key === 'module_numerics' || key === 'module_tags') {
                 continue;
@@ -453,7 +453,7 @@ bigdl.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -472,7 +472,7 @@ bigdl.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 22 - 22
src/caffe.js

@@ -198,8 +198,8 @@ caffe.Model = class {
         this._graphs = [];
 
         let phases = new Set();
-        for (let layer of net.layer) {
-            for (let include of layer.include) {
+        for (const layer of net.layer) {
+            for (const include of layer.include) {
                 if (include.phase !== undefined) {
                     phases.add(include.phase);
                 }
@@ -209,7 +209,7 @@ caffe.Model = class {
             phases.add(-1);
         }
 
-        for (let phase of phases) {
+        for (const phase of phases) {
             this._graphs.push(new caffe.Graph(metadata, phase, net, this._version));
         }
     }
@@ -238,14 +238,14 @@ caffe.Graph = class {
         this._inputs = [];
         this._outputs = [];
 
-        for (let layer of net.layer) {
+        for (const layer of net.layer) {
             layer.input = layer.bottom.slice(0);
             layer.output = layer.top.slice(0);
             layer.chain = [];
         }
 
         let layers = [];
-        for (let layer of net.layer) {
+        for (const layer of net.layer) {
             if (phase === -1 || layer.include.every((include) => include.phase === phase)) {
                 layers.push(layer);
             }
@@ -253,7 +253,7 @@ caffe.Graph = class {
 
         let scope = {};
         let index = 0;
-        for (let layer of layers) {
+        for (const layer of layers) {
             layer.input = layer.input.map((input) => scope[input] ? scope[input] : input);
             layer.output = layer.output.map((output) => {
                 scope[output] = scope[output] ? output + '\n' + index.toString() : output; // custom argument id
@@ -264,14 +264,14 @@ caffe.Graph = class {
 
         // Graph Inputs
         let usedOutputs = new Set();
-        for (let layer of layers) {
-            for (let output of layer.output) {
+        for (const layer of layers) {
+            for (const output of layer.output) {
                 usedOutputs.add(output);
             }
         }
         let unusedInputs = [];
-        for (let layer of layers) {
-            for (let input of layer.input) {
+        for (const layer of layers) {
+            for (const input of layer.input) {
                 if (!usedOutputs.has(input)) {
                     unusedInputs.push(input);
                 }
@@ -314,7 +314,7 @@ caffe.Graph = class {
 
         if (net.input && net.input.length > 0) {
             index = 0;
-            for (let input of net.input) {
+            for (const input of net.input) {
                 let inputType = null;
                 if (net.input_shape && index < net.input_shape.length) {
                     const blobShape = net.input_shape[index];
@@ -330,10 +330,10 @@ caffe.Graph = class {
             }
         }
 
-        for (let layer of nodes) {
+        for (const layer of nodes) {
             const node = new caffe.Node(metadata, layer, version);
             if (layer.chain && layer.chain.length > 0) {
-                for (let chain of layer.chain) {
+                for (const chain of layer.chain) {
                     node.chain.push(new caffe.Node(metadata, chain, version));
                 }
             }
@@ -435,7 +435,7 @@ caffe.Node = class {
                     if (!caffe.Node._operatorMap) {
                         caffe.Node._operatorMap = {};
                         const known = { 'BNLL': 'BNLL', 'HDF5': 'HDF5', 'LRN': 'LRN', 'RELU': 'ReLU', 'TANH': 'TanH', 'ARGMAX': 'ArgMax', 'MVN': 'MVN', 'ABSVAL': 'AbsVal' };
-                        for (let key of Object.keys(caffe.proto.V1LayerParameter.LayerType)) {
+                        for (const key of Object.keys(caffe.proto.V1LayerParameter.LayerType)) {
                             const index = caffe.proto.V1LayerParameter.LayerType[key];
                             caffe.Node._operatorMap[index] = key.split('_').map((item) => {
                                 return known[item] || item.substring(0, 1) + item.substring(1).toLowerCase();
@@ -456,7 +456,7 @@ caffe.Node = class {
 
         switch (version) {
             case 0:
-                for (let attributeName of Object.keys(layer.layer)) {
+                for (const attributeName of Object.keys(layer.layer)) {
                     if (attributeName != 'type' && attributeName != 'name' && attributeName != 'blobs' && attributeName != 'blobs_lr') {
                         this._attributes.push(new caffe.Attribute(this._metadata, this.operator, attributeName, layer.layer[attributeName]));
                     }
@@ -465,7 +465,7 @@ caffe.Node = class {
                 break;
             case 1:
             case 2:
-                for (let layer_kind of Object.keys(layer)) {
+                for (const layer_kind of Object.keys(layer)) {
                     if (layer_kind.endsWith('_param') || layer_kind == 'transform_param') {
                         const param = layer[layer_kind];
                         let type = this._type;
@@ -473,7 +473,7 @@ caffe.Node = class {
                             type = 'Convolution';
                         }
                         const prototype = Object.getPrototypeOf(param);
-                        for (let name of Object.keys(param)) {
+                        for (const name of Object.keys(param)) {
                             const defaultValue = prototype[name];
                             const value = param[name];
                             if (value != defaultValue && (!Array.isArray(value) || !Array.isArray(defaultValue) || value.length != 0 || defaultValue.length != 0)) {
@@ -501,11 +501,11 @@ caffe.Node = class {
         let inputs = layer.input.concat(initializers);
         let inputIndex = 0;
         if (schema && schema.inputs) {
-            for (let inputDef of schema.inputs) {
+            for (const inputDef of schema.inputs) {
                 if (inputIndex < inputs.length || inputDef.option != 'optional') {
                     let inputCount = (inputDef.option == 'variadic') ? (inputs.length - inputIndex) : 1;
                     let inputArguments = [];
-                    for (let input of inputs.slice(inputIndex, inputIndex + inputCount)) {
+                    for (const input of inputs.slice(inputIndex, inputIndex + inputCount)) {
                         if (input != '' || inputDef.option != 'optional') {
                             if (input instanceof caffe.Tensor) {
                                 inputArguments.push(new caffe.Argument('', null, input));
@@ -532,7 +532,7 @@ caffe.Node = class {
         let outputs = layer.output;
         let outputIndex = 0;
         if (schema && schema.outputs) {
-            for (let outputDef of schema.outputs) {
+            for (const outputDef of schema.outputs) {
                 if (outputIndex < outputs.length) {
                     let outputCount = (outputDef.option == 'variadic') ? (outputs.length - outputIndex) : 1;
                     this._outputs.push(new caffe.Parameter(outputDef.name, outputs.slice(outputIndex, outputIndex + outputCount).map((output) => {
@@ -798,7 +798,7 @@ caffe.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -817,7 +817,7 @@ caffe.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 7 - 6
src/chainer.js

@@ -12,7 +12,8 @@ chainer.ModelFactory = class {
         const identifier = context.identifier; 
         const extension = identifier.split('.').pop().toLowerCase();
         if (extension === 'npz') {
-            return context.entries.length > 0 && context.entries.every((entry) => entry.name.indexOf('/') !== -1);
+            const entries = context.entries('zip');
+            return entries.length > 0 && entries.every((entry) => entry.name.indexOf('/') !== -1);
         }
         if (extension === 'h5' || extension === 'hd5' || extension === 'hdf5' || extension === 'keras' || extension === 'model') {
             const buffer = context.buffer;
@@ -165,7 +166,7 @@ chainer.ModelFactory = class {
                         [ 'f2', 'float16'], [ 'f4', 'float32' ], [ 'f8', 'float64']
                     ]);
 
-                    for (let entry of context.entries) {
+                    for (const entry of context.entries('zip')) {
                         if (!entry.name.endsWith('.npy')) {
                             throw new chainer.Error("Invalid file name '" + entry.name + "'.");
                         }
@@ -228,7 +229,7 @@ chainer.ModelFactory = class {
                 }
                 let modules = [];
                 let map = new Map();
-                for (let moduleGroup of rootGroup.groups) {
+                for (const moduleGroup of rootGroup.groups) {
                     if (Object.keys(moduleGroup.attributes).length !== 0 || moduleGroup.value !== null) {
                         throw new chainer.Error('Module group format is not Chainer HDF5');
                     }
@@ -245,7 +246,7 @@ chainer.ModelFactory = class {
                         map.set(moduleName, module);
                         modules.push(module);
                     }
-                    for (let variableGroup of moduleGroup.groups) {
+                    for (const variableGroup of moduleGroup.groups) {
                         if (Object.keys(variableGroup.attributes).length !== 0 || variableGroup.groups.length !== 0) {
                             throw new chainer.Error('Variable format is not Chainer HDF5');
                         }
@@ -294,7 +295,7 @@ chainer.Graph = class {
 
     constructor(modules) {
         this._nodes = [];
-        for (let module of modules) {
+        for (const module of modules) {
             this._nodes.push(new chainer.Node(module));
         }
     }
@@ -357,7 +358,7 @@ chainer.Node = class {
     constructor(module) {
         this._name = module.name;
         this._inputs = [];
-        for (let parameter of module.parameters) {
+        for (const parameter of module.parameters) {
             const name = [ this._name, parameter.name ].join('/');
             const initializer = new chainer.Tensor(name, parameter.dataType, parameter.shape, parameter.data, parameter.byteOrder);
             this._inputs.push(new chainer.Parameter(parameter.name, [

+ 18 - 18
src/cntk.js

@@ -75,7 +75,7 @@ cntk.ModelFactory = class {
 
     static _convertDictionary(dictionary) {
         let target = {};
-        for (let key of Object.keys(dictionary.data).filter((key) => key != 'version')) {
+        for (const key of Object.keys(dictionary.data).filter((key) => key != 'version')) {
             target[key] = cntk.ModelFactory._convertDictionaryValue(dictionary.data[key]);
         }
         return target;
@@ -151,7 +151,7 @@ cntk.Graph = class {
         let args = {};
         switch (version) {
             case 1: {
-                for (let name of Object.keys(obj.nodes)) {
+                for (const name of Object.keys(obj.nodes)) {
                     const node = obj.nodes[name];
                     switch (node.__type__) {
                         case 'InputValue':
@@ -164,14 +164,14 @@ cntk.Graph = class {
                             break;
                     }
                 }
-                for (let name of Object.keys(obj.nodes)) {
+                for (const name of Object.keys(obj.nodes)) {
                     const node = obj.nodes[name];
                     if (node.__type__ != 'InputValue' && node.__type__ != 'LearnableParameter') {
                         this._nodes.push(new cntk.Node(metadata, version, node, args));
                     }
                 }
                 if (obj.output) {
-                    for (let output of obj.output) {
+                    for (const output of obj.output) {
                         this._outputs.push(new cntk.Parameter(output, [ 
                             new cntk.Argument(version, output)
                         ]));
@@ -181,10 +181,10 @@ cntk.Graph = class {
             }
             case 2: {
                 let nodeMap = new Map();
-                for (let node of obj.primitive_functions) {
+                for (const node of obj.primitive_functions) {
                     nodeMap.set(node.uid, node);
                 }
-                for (let input of obj.inputs) {
+                for (const input of obj.inputs) {
                     let argument = new cntk.Argument(version, input);
                     args[input.uid] = argument;
                     // VariableKind { 0: 'input', 1: 'output', 2: 'parameter', 3: 'constant', 4: 'placeholder' }
@@ -193,7 +193,7 @@ cntk.Graph = class {
                         this._inputs.push(new cntk.Parameter(inputName, [ argument ]));
                     }
                 }
-                for (let block of obj.primitive_functions) {
+                for (const block of obj.primitive_functions) {
                     if (block.op == 57 && block.block_function_composite) {
                         let list = [ block.block_function_composite.root ];
                         let nodes = [];
@@ -219,7 +219,7 @@ cntk.Graph = class {
                         this._functions.push(new cntk.Function(block.block_function_op_name, nodes, inputs, outputs));
                     }
                 }
-                for (let node of obj.primitive_functions) {
+                for (const node of obj.primitive_functions) {
                     if (nodeMap.has(node.uid)) {
                         this._nodes.push(new cntk.Node(metadata, version, node, args));
                     }
@@ -375,7 +375,7 @@ cntk.Node = class {
             case 1: {
                 this._operator = obj.__type__;
                 this._name = obj.name;
-                for (let attributeName of Object.keys(obj)) {
+                for (const attributeName of Object.keys(obj)) {
                     if (attributeName != '__type__' && attributeName != 'name' && attributeName != 'inputs' && attributeName != 'precision') {
                         this._attributes.push(new cntk.Attribute(this._metadata, this._operator, attributeName, obj[attributeName]));
                     }
@@ -403,7 +403,7 @@ cntk.Node = class {
                     if (!Object.prototype.hasOwnProperty.call(obj, 'op')) {
                         this._operator = obj.type;
                         if (obj.user_defined_state) {
-                            for (let attributeName of Object.keys(obj.user_defined_state)) {
+                            for (const attributeName of Object.keys(obj.user_defined_state)) {
                                 this._attributes.push(new cntk.Attribute(this._metadata, this._operator, attributeName, obj.user_defined_state[attributeName]));
                             }
                         }
@@ -416,11 +416,11 @@ cntk.Node = class {
                     }
                 }
                 if (obj.attributes) {
-                    for (let attributeName of Object.keys(obj.attributes)) {
+                    for (const attributeName of Object.keys(obj.attributes)) {
                         this._attributes.push(new cntk.Attribute(this._metadata, this._operator, attributeName, obj.attributes[attributeName]));
                     }
                 }
-                for (let input of obj.inputs) {
+                for (const input of obj.inputs) {
                     let argument = args[input];
                     if (argument) {
                         if (argument.initializer) {
@@ -443,11 +443,11 @@ cntk.Node = class {
         let inputIndex = 0;
         const schema = this._metadata.getSchema(this._function ? ('Function:' + this._operator) : this._operator);
         if (schema && schema.inputs) {
-            for (let inputSchema of schema.inputs) {
+            for (const inputSchema of schema.inputs) {
                 if (inputIndex < inputs.length || inputSchema.option != 'optional') {
                     let inputCount = (inputSchema.option == 'variadic') ? (inputs.length - inputIndex) : 1;
                     let inputArguments = [];
-                    for (let inputArgument of inputs.slice(inputIndex, inputIndex + inputCount)) {
+                    for (const inputArgument of inputs.slice(inputIndex, inputIndex + inputCount)) {
                         if (inputArgument.id != '' || inputSchema.option != 'optional') {
                             inputArguments.push(inputArgument);
                         }
@@ -463,7 +463,7 @@ cntk.Node = class {
 
         let outputIndex = 0;
         if (schema && schema.outputs) {
-            for (let outputSchema of schema.outputs) {
+            for (const outputSchema of schema.outputs) {
                 if (outputIndex < outputs.length || outputSchema.option != 'optional') {
                     let outputCount = (outputSchema.option == 'variadic') ? (outputs.length - outputIndex) : 1;
                     this._outputs.push(new cntk.Parameter(outputSchema.name, outputs.slice(outputIndex, outputIndex + outputCount)));
@@ -526,7 +526,7 @@ cntk.Attribute = class {
         }
         if (cntk_v2 && this._value instanceof cntk_v2.Axis) {
             const axis = { __type__: 'Axis' };
-            for (let key of Object.keys(value).filter((key) => key !== 'name')) {
+            for (const key of Object.keys(value).filter((key) => key !== 'name')) {
                 axis[key] = value[key];
             }
             this._value = axis;
@@ -803,7 +803,7 @@ cntk.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         const name = item.name;
                         const schema = item.schema;
@@ -832,7 +832,7 @@ cntk.Metadata = class {
             map = {};
             let schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 15 - 15
src/coreml.js

@@ -140,7 +140,7 @@ coreml.Graph = class {
     }
 
     _updateOutput(name, newName) {
-        for (let node of this._nodes) {
+        for (const node of this._nodes) {
             node._outputs = node._outputs.map((output) => (output != name) ? output : newName);
         }
         return newName;
@@ -166,20 +166,20 @@ coreml.Graph = class {
         if (preprocessing && preprocessing.length > 0) {
             let preprocessingInput = this._description.input[0].name;
             let inputNodes = [];
-            for (let node of this._nodes) {
+            for (const node of this._nodes) {
                 if (node._inputs.some((input => input == preprocessingInput))) {
                     inputNodes.push(node);
                 }
             }
             let preprocessorOutput = preprocessingInput;
             let preprocessorIndex = 0;
-            for (let p of preprocessing) {
+            for (const p of preprocessing) {
                 let input = p.featureName ? p.featureName : preprocessorOutput;
                 preprocessorOutput = preprocessingInput + ':' + preprocessorIndex.toString();
                 this._createNode(scope, group, p.preprocessor, null, p[p.preprocessor], [ input ], [ preprocessorOutput ]);
                 preprocessorIndex++;
             }
-            for (let inputNode of inputNodes) {
+            for (const inputNode of inputNodes) {
                 inputNode._inputs = inputNode._inputs.map((input) => (input != preprocessingInput) ? input : preprocessorOutput);
             }
         }
@@ -189,7 +189,7 @@ coreml.Graph = class {
         this._groups = this._groups | (group.length > 0 ? true : false);
         if (model.neuralNetworkClassifier) {
             const neuralNetworkClassifier = model.neuralNetworkClassifier;
-            for (let layer of neuralNetworkClassifier.layers) {
+            for (const layer of neuralNetworkClassifier.layers) {
                 this._createNode(scope, group, layer.layer, layer.name, layer[layer.layer], layer.input, layer.output);
             }
             this._updateClassifierOutput(group, neuralNetworkClassifier);
@@ -198,7 +198,7 @@ coreml.Graph = class {
         }
         else if (model.neuralNetwork) {
             const neuralNetwork = model.neuralNetwork;
-            for (let layer of neuralNetwork.layers) {
+            for (const layer of neuralNetwork.layers) {
                 this._createNode(scope, group, layer.layer, layer.name, layer[layer.layer], layer.input, layer.output);
             }
             this._updatePreprocessing(scope, group, neuralNetwork.preprocessing);
@@ -206,7 +206,7 @@ coreml.Graph = class {
         }
         else if (model.neuralNetworkRegressor) {
             const neuralNetworkRegressor = model.neuralNetworkRegressor;
-            for (let layer of neuralNetworkRegressor.layers) {
+            for (const layer of neuralNetworkRegressor.layers) {
                 this._createNode(scope, group, layer.layer, layer.name, layer[layer.layer], layer.input, layer.output);
             }
             this._updatePreprocessing(scope, group, neuralNetworkRegressor);
@@ -576,7 +576,7 @@ coreml.Node = class {
         this._initializers = [];
         if (data) {
             const initializerMap = this._initialize(data);
-            for (let key of Object.keys(data)) {
+            for (const key of Object.keys(data)) {
                 if (!initializerMap[key]) {
                     this._attributes.push(new coreml.Attribute(this._metadata, this.operator, key, data[key]));
                 }
@@ -606,21 +606,21 @@ coreml.Node = class {
                 schema.description = marked(schema.description);
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     if (attribute.description) {
                         attribute.description = marked(attribute.description);
                     }
                 }
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.description) {
                         input.description = marked(input.description);
                     }
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.description) {
                         output.description = marked(output.description);
                     }
@@ -901,7 +901,7 @@ coreml.Tensor = class {
                 this._quantization.lookupTableQuantization.floatValue &&
                 this._quantization.lookupTableQuantization.floatValue.length > 0) {
                 let map = [];
-                for (let key of Object.keys(this._quantization.lookupTableQuantization.floatValue)) {
+                for (const key of Object.keys(this._quantization.lookupTableQuantization.floatValue)) {
                     map.push(key.toString() + ' = ' + this._quantization.lookupTableQuantization.floatValue[key].toString());
                 }
                 return map.join('; ');
@@ -1124,7 +1124,7 @@ coreml.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -1143,7 +1143,7 @@ coreml.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }
@@ -1158,7 +1158,7 @@ coreml.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.inputs && schema.inputs.length > 0) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     map[input.name] = input;
                 }
             }

+ 10 - 10
src/darknet.js

@@ -119,7 +119,7 @@ darknet.Graph = class {
             let data = null;
             if (weights) {
                 let size = 1;
-                for (let dim of shape) {
+                for (const dim of shape) {
                     size *= dim;
                 }
                 data = weights.bytes(4 * size);
@@ -573,7 +573,7 @@ darknet.Graph = class {
                     case 'route': {
                         let layers = [].concat(layer.layers);
                         layer.out = 0;
-                        for (let next of layers) {
+                        for (const next of layers) {
                             layer.out += next.out;
                         }
                         const first = layers.shift();
@@ -743,13 +743,13 @@ darknet.Node = class {
             this._outputs.push(new darknet.Parameter(layer.outputs.length <= 1 ? 'output' : 'outputs', true, layer.outputs));
         }
         if (section.chain) {
-            for (let chain of section.chain) {
+            for (const chain of section.chain) {
                 this._chain.push(new darknet.Node(metadata, net, chain, ''));
             }
         }
         const options = section.options;
         if (options) {
-            for (let key of Object.keys(options)) {
+            for (const key of Object.keys(options)) {
                 this._attributes.push(new darknet.Attribute(metadata, this._operator, key, options[key]));
             }
         }
@@ -772,28 +772,28 @@ darknet.Node = class {
                 schema.description = marked(schema.description);
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     if (attribute.description) {
                         attribute.description = marked(attribute.description);
                     }
                 }
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.description) {
                         input.description = marked(input.description);
                     }
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.description) {
                         output.description = marked(output.description);
                     }
                 }
             }
             if (schema.references) {
-                for (let reference of schema.references) {
+                for (const reference of schema.references) {
                     if (reference) {
                         reference.description = marked(reference.description);
                     }
@@ -1068,7 +1068,7 @@ darknet.Metadata = class {
         if (data) {
             const items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item && item.name && item.schema) {
                         if (this._map.has(item.name)) {
                             throw new darknet.Error("Duplicate metadata key '" + item.name + "'.");
@@ -1090,7 +1090,7 @@ darknet.Metadata = class {
             this._attributeMap.set(key, null);
             const schema = this.getSchema(operator);
             if (schema && schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     this._attributeMap.set(operator + ':' + attribute.name, attribute);
                 }
             }

+ 12 - 12
src/dl4j.js

@@ -11,7 +11,7 @@ dl4j.ModelFactory = class {
     match(context) {
         const identifier = context.identifier.toLowerCase();
         const extension = identifier.split('.').pop().toLowerCase();
-        if (extension === 'zip' && context.entries.length > 0) {
+        if (extension === 'zip' && context.entries('zip').length > 0) {
             if (dl4j.ModelFactory._openContainer(context)) {
                 return true;
             }
@@ -45,7 +45,8 @@ dl4j.ModelFactory = class {
     }
 
     static _openContainer(context) {
-        const configurationEntries = context.entries.filter((entry) => entry.name === 'configuration.json');
+        const entries = context.entries('zip');
+        const configurationEntries = entries.filter((entry) => entry.name === 'configuration.json');
         if (configurationEntries.length != 1) {
             return null;
         }
@@ -59,7 +60,7 @@ dl4j.ModelFactory = class {
         if (configuration.indexOf('"vertices"') === -1 && configuration.indexOf('"confs"') === -1) {
             return null;
         }
-        const coefficientsEntries = context.entries.filter((entry) => entry.name === 'coefficients.bin');
+        const coefficientsEntries = entries.filter((entry) => entry.name === 'coefficients.bin');
         if (coefficientsEntries.length > 1) {
             return null;
         }
@@ -99,7 +100,7 @@ dl4j.Graph = class {
         let dataType = reader.dataType;
 
         if (configuration.networkInputs) {
-            for (let input of configuration.networkInputs) {
+            for (const input of configuration.networkInputs) {
                 this._inputs.push(new dl4j.Parameter(input, true, [
                     new dl4j.Argument(input, null, null)
                 ]));
@@ -107,7 +108,7 @@ dl4j.Graph = class {
         }
 
         if (configuration.networkOutputs) {
-            for (let output of configuration.networkOutputs) {
+            for (const output of configuration.networkOutputs) {
                 this._outputs.push(new dl4j.Parameter(output, true, [
                     new dl4j.Argument(output, null, null)
                 ]));
@@ -118,8 +119,7 @@ dl4j.Graph = class {
 
         // Computation Graph
         if (configuration.vertices) {
-            for (let name in configuration.vertices) {
-
+            for (const name in configuration.vertices) {
                 let vertex = dl4j.Node._object(configuration.vertices[name]);
                 inputs = configuration.vertexInputs[name];
                 let variables = [];
@@ -153,7 +153,7 @@ dl4j.Graph = class {
             this._inputs.push(new dl4j.Parameter('input', true, [
                 new dl4j.Argument('input', null, null)
             ]));
-            for (let conf of configuration.confs) {
+            for (const conf of configuration.confs) {
                 let layer = dl4j.Node._object(conf.layer);
                 this._nodes.push(new dl4j.Node(metadata, layer, inputs, dataType, conf.variables));
                 inputs = [ layer.layerName ];
@@ -239,7 +239,7 @@ dl4j.Node = class {
         }
 
         if (variables) {
-            for (let variable of variables) {
+            for (const variable of variables) {
                 let tensor = null;
                 switch (this._operator) {
                     case 'Convolution':
@@ -316,7 +316,7 @@ dl4j.Node = class {
             }
         }
 
-        for (let key in attributes) {
+        for (const key in attributes) {
             switch (key) {
                 case '__type__':
                 case 'constraints':
@@ -503,7 +503,7 @@ dl4j.Metadata = class {
             if (data) {
                 let items = JSON.parse(data);
                 if (items) {
-                    for (let item of items) {
+                    for (const item of items) {
                         if (item.name && item.schema) {
                             this._map[item.name] = item.schema;
                         }
@@ -523,7 +523,7 @@ dl4j.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 3 - 3
src/flux.js

@@ -61,7 +61,7 @@ flux.ModelFactory = class {
                 }
                 obj = root._backrefs[obj.ref - 1];
             }
-            for (let key of Object.keys(obj)) {
+            for (const key of Object.keys(obj)) {
                 if (obj !== root || key !== '_backrefs') {
                     obj[key] = flux.ModelFactory._backref(obj[key], root);
                 }
@@ -109,7 +109,7 @@ flux.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -128,7 +128,7 @@ flux.Metadata = class {
             map = {};
             let schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 6 - 6
src/hdf5.js

@@ -128,7 +128,7 @@ hdf5.Group = class {
         }
         if (!this._attributes) {
             this._attributes = {};
-            for (let attribute of this._dataObjectHeader.attributes) {
+            for (const attribute of this._dataObjectHeader.attributes) {
                 const name = attribute.name;
                 const value = attribute.decodeValue(this._globalHeap);
                 this._attributes[name] = value;
@@ -152,8 +152,8 @@ hdf5.Group = class {
                 if (this._entry.treeAddress || this._entry.heapAddress) {
                     const heap = new hdf5.Heap(this._reader.at(this._entry.heapAddress));
                     const tree = new hdf5.Tree(this._reader.at(this._entry.treeAddress));
-                    for (let node of tree.nodes) {
-                        for (let entry of node.entries) {
+                    for (const node of tree.nodes) {
+                        for (const entry of node.entries) {
                             const name = heap.getString(entry.linkNameOffset);
                             const group = new hdf5.Group(this._reader, entry, null, this._globalHeap, this._path, name);
                             this._groups.push(group);
@@ -164,7 +164,7 @@ hdf5.Group = class {
             }
             else {
                 this._decodeDataObject();
-                for (let link of this._dataObjectHeader.links) {
+                for (const link of this._dataObjectHeader.links) {
                     if (Object.prototype.hasOwnProperty.call(link, 'objectHeaderAddress')) {
                         const name = link.name;
                         const objectHeader = new hdf5.DataObjectHeader(this._reader.at(link.objectHeaderAddress));
@@ -227,7 +227,7 @@ hdf5.Variable = class {
                         size *= this._dataspace.shape[i];
                     }
                     var data = new Uint8Array(size);
-                    for (let node of tree.nodes) {
+                    for (const node of tree.nodes) {
                         if (node.fields.length !== 2 || node.fields[1] !== 0) {
                             return null;
                         }
@@ -237,7 +237,7 @@ hdf5.Variable = class {
                         const start = node.fields[0] * this._dataLayout.datasetElementSize;
                         var chunk = node.data;
                         if (this._filterPipeline) {
-                            for (let filter of this._filterPipeline.filters) {
+                            for (const filter of this._filterPipeline.filters) {
                                 chunk = filter.decode(chunk);
                             }
                         }

+ 23 - 23
src/keras.js

@@ -142,10 +142,10 @@ keras.Model = class {
                 model_weights_group = new keras.Group(model_weights_group);
                 let layer_names = model_weights_group.attribute('layer_names');
                 let layer_names_map = new Set();
-                for (let layer_name of layer_names) {
+                for (const layer_name of layer_names) {
                     layer_names_map.add(layer_name);
                 }
-                for (let layer_name of layer_names) {
+                for (const layer_name of layer_names) {
                     let layer_weights = model_weights_group.group(layer_name);
                     if (layer_weights) {
                         let weight_names = layer_weights.attribute('weight_names');
@@ -194,8 +194,8 @@ keras.Model = class {
             }
         }
         else if (weightsManifest) {
-            for (let manifest of weightsManifest) {
-                for (let weight of manifest.weights) {
+            for (const manifest of weightsManifest) {
+                for (const weight of manifest.weights) {
                     let p = weight.name.split('/');
                     p.pop();
                     let initializer = new keras.Tensor(weight.name, weight.dtype, weight.shape, false, null, manifest.paths.join(';'));
@@ -262,7 +262,7 @@ keras.Graph = class {
             }
         }
         else if (weights) {
-            for (let layer of Object.keys(weights)) {
+            for (const layer of Object.keys(weights)) {
                 if (weights[layer].length <= 6) {
                     const node = new keras.Node(metadata, 'Weights', { name: layer }, [], [], false, weights);
                     this._nodes.push(node)
@@ -297,7 +297,7 @@ keras.Graph = class {
         }
         let nodeMap = new Map();
         if (config.layers) {
-            for (let layer of config.layers) {
+            for (const layer of config.layers) {
                 if (layer.name) {
                     if (!nodeMap.has(layer.name)) {
                         nodeMap.set(layer.name, layer);
@@ -306,10 +306,10 @@ keras.Graph = class {
                     }
                 }
             }
-            for (let layer of config.layers) {
+            for (const layer of config.layers) {
                 if (layer.inbound_nodes) {
-                    for (let inbound_node of layer.inbound_nodes) {
-                        for (let inbound_connection of inbound_node) {
+                    for (const inbound_node of layer.inbound_nodes) {
+                        for (const inbound_connection of inbound_node) {
                             let inputName = inbound_connection[0];
                             let inputNode = nodeMap.get(inputName);
                             if (inputNode) {
@@ -341,7 +341,7 @@ keras.Graph = class {
                 }
                 if (inputs && i < inputs.length) {
                     if (config.layers) {
-                        for (let layer of config.layers) {
+                        for (const layer of config.layers) {
                             if (layer._inputs) {
                                 layer._inputs = layer._inputs.map((input) => {
                                     return input === name ? inputs[i] : input;
@@ -385,7 +385,7 @@ keras.Graph = class {
         }
 
         if (config.layers) {
-            for (let layer of config.layers) {
+            for (const layer of config.layers) {
                 if (nodeMap.has(layer.name)) {
                     this._loadNode(layer, layer._inputs, layer._outputs, weights, group, inputMap);
                 }
@@ -403,7 +403,7 @@ keras.Graph = class {
         let index = 0;
         let layers = config.layers ? config.layers : config;
 
-        for (let layer of layers) {
+        for (const layer of layers) {
             let name = index.toString();
             let nodeInputs = [ argument ];
             if (index == 0) {
@@ -546,9 +546,9 @@ keras.Node = class {
 
         let initializers = {};
         if (weights) {
-            for (let name of names) {
+            for (const name of names) {
                 if (weights[name]) {
-                    for (let initializer of weights[name]) {
+                    for (const initializer of weights[name]) {
                         inputs.push(initializer.name);
                         initializers[initializer.name] = initializer;
                     }
@@ -557,8 +557,8 @@ keras.Node = class {
         }
 
         if (config) {
-            for (let attributeName of Object.keys(config)) {
-                let attributeValue = config[attributeName];
+            for (const attributeName of Object.keys(config)) {
+                const attributeValue = config[attributeName];
                 if (attributeName != 'name' && attributeValue != null) {
                     this._attributes.push(new keras.Attribute(this._metadata, this.operator, attributeName, attributeValue));
                 }
@@ -662,28 +662,28 @@ keras.Node = class {
                 schema.description = marked(schema.description);
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     if (attribute.description) {
                         attribute.description = marked(attribute.description);
                     }
                 }
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.description) {
                         input.description = marked(input.description);
                     }
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.description) {
                         output.description = marked(output.description);
                     }
                 }
             }
             if (schema.references) {
-                for (let reference of schema.references) {
+                for (const reference of schema.references) {
                     if (reference) {
                         reference.description = marked(reference.description);
                     }
@@ -772,7 +772,7 @@ keras.Attribute = class {
         if (value.class_name) {
             obj.__type__ = value.class_name;
         }
-        for (let key of Object.keys(value.config)) {
+        for (const key of Object.keys(value.config)) {
             obj[key] = keras.Attribute._convert(value.config[key]);
         }
         return obj;
@@ -1043,7 +1043,7 @@ keras.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -1062,7 +1062,7 @@ keras.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 22 - 19
src/mlnet.js

@@ -12,10 +12,13 @@ mlnet.ModelFactory = class {
     match(context) {
         const identifier = context.identifier; 
         const extension = identifier.split('.').pop().toLowerCase();
-        if (extension === 'zip' && context.entries.length > 0) {
-            const root = new Set([ 'TransformerChain', 'Predictor']);
-            if (context.entries.some((e) => root.has(e.name.split('\\').shift().split('/').shift()))) {
-                return true;
+        if (extension === 'zip') {
+            const entries = context.entries('zip');
+            if (entries.length > 0) {
+                const root = new Set([ 'TransformerChain', 'Predictor']);
+                if (entries.some((e) => root.has(e.name.split('\\').shift().split('/').shift()))) {
+                    return true;
+                }
             }
         }
         return false;
@@ -25,7 +28,7 @@ mlnet.ModelFactory = class {
         const identifier = context.identifier;
         return mlnet.Metadata.open(host).then((metadata) => {
             try {
-                const reader = new mlnet.ModelReader(context.entries);
+                const reader = new mlnet.ModelReader(context.entries('zip'));
                 return new mlnet.Model(metadata, reader);
             }
             catch (error) {
@@ -67,7 +70,7 @@ mlnet.Graph = class {
         this._groups = false;
 
         if (reader.schema && reader.schema.inputs) {
-            for (let input of reader.schema.inputs) {
+            for (const input of reader.schema.inputs) {
                 this._inputs.push(new mlnet.Parameter(input.name, [
                     new mlnet.Argument(input.name, new mlnet.TensorType(input.type))
                 ]));
@@ -100,8 +103,8 @@ mlnet.Graph = class {
 
     _loadChain(metadata, scope, name, chain) {
         this._groups = true;
-        let group = name.split('/').splice(1).join('/');
-        for (let childTransformer of chain) {
+        const group = name.split('/').splice(1).join('/');
+        for (const childTransformer of chain) {
             this._loadTransformer(metadata, scope, group, childTransformer);
         }
     }
@@ -109,10 +112,10 @@ mlnet.Graph = class {
     _createNode(metadata, scope, group, transformer) {
 
         if (transformer.inputs && transformer.outputs) {
-            for (let input of transformer.inputs) {
+            for (const input of transformer.inputs) {
                 input.name = scope[input.name] ? scope[input.name].argument : input.name;
             }
-            for (let output of transformer.outputs) {
+            for (const output of transformer.outputs) {
                 if (scope[output.name]) {
                     scope[output.name].counter++;
                     var next = output.name + '\n' + scope[output.name].counter.toString(); // custom argument id
@@ -198,7 +201,7 @@ mlnet.Node = class {
 
         if (transformer.inputs) {
             let i = 0;
-            for (let input of transformer.inputs) {
+            for (const input of transformer.inputs) {
                 this._inputs.push(new mlnet.Parameter(i.toString(), [
                     new mlnet.Argument(input.name)
                 ]));
@@ -208,7 +211,7 @@ mlnet.Node = class {
 
         if (transformer.outputs) {
             let i = 0;
-            for (let output of transformer.outputs) {
+            for (const output of transformer.outputs) {
                 this._outputs.push(new mlnet.Parameter(i.toString(), [
                     new mlnet.Argument(output.name)
                 ]));
@@ -216,7 +219,7 @@ mlnet.Node = class {
             }
         }
 
-        for (let key of Object.keys(transformer).filter((key) => !key.startsWith('_') && key !== 'inputs' && key !== 'outputs')) {
+        for (const key of Object.keys(transformer).filter((key) => !key.startsWith('_') && key !== 'inputs' && key !== 'outputs')) {
             this._attributes.push(new mlnet.Attribute(metadata, this._operator, key, transformer[key]));
         }
     }
@@ -425,7 +428,7 @@ mlnet.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -444,7 +447,7 @@ mlnet.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }
@@ -1584,7 +1587,7 @@ mlnet.TermManager = class {
             }
         }
         else {
-            throw new mlnet.Error('');
+            throw new mlnet.Error('Unsupported TermManager version.');
             // for (let i = 0; i < cmap; ++i) {
             //    debugger;
             //    // termMap[i] = TermMap.TextImpl.Create(c, host)
@@ -1661,7 +1664,7 @@ mlnet.RowToRowMapperTransform = class extends mlnet.RowToRowTransformBase {
         super(context);
         let mapper = context.open('Mapper');
         this.__type__ = mapper.__type__;
-        for (let key of Object.keys(mapper)) {
+        for (const key of Object.keys(mapper)) {
             this[key] = mapper[key];
         }
     }
@@ -1985,7 +1988,7 @@ mlnet.InternalRegressionTree = class {
             if (categoricalNodeIndices.length > 0) {
                 this.CategoricalSplitFeatures = [];
                 this.CategoricalSplitFeatureRanges = [];
-                for (let index of categoricalNodeIndices) {
+                for (const index of categoricalNodeIndices) {
                     this.CategoricalSplitFeatures[index] = reader.int32s(reader.int32());
                     this.CategoricalSplitFeatureRanges[index] = reader.int32s(2);
                 }
@@ -2227,7 +2230,7 @@ mlnet.IidAnomalyDetectionBaseWrapper = class {
 
     constructor(context) {
         let internalTransform = new mlnet.IidAnomalyDetectionBase(context);
-        for (let key of Object.keys(internalTransform)) {
+        for (const key of Object.keys(internalTransform)) {
             this[key] = internalTransform[key];
         }
     }

+ 6 - 6
src/mnn.js

@@ -287,7 +287,7 @@ mnn.Node = class {
 
         let attributeNames = [];
         let attributeNamesMap = {};
-        for (let attributeName of Object.keys(Object.getPrototypeOf(parameter))) {
+        for (const attributeName of Object.keys(Object.getPrototypeOf(parameter))) {
             if (attributeName != '__init') {
                 attributeNames.push(attributeName);
             }
@@ -295,14 +295,14 @@ mnn.Node = class {
         }
 
         let attributeArrayNamesMap = {}; 
-        for (let attributeName of Object.keys(attributeNamesMap)) {
+        for (const attributeName of Object.keys(attributeNamesMap)) {
             if (attributeNamesMap[attributeName + 'Length']) { // some bugs without array
                 attributeArrayNamesMap[attributeName] = true;
                 attributeNames = attributeNames.filter((item) => item != (attributeName + 'Array') && item != (attributeName + 'Length'));
             }
         }
 
-        for (let attributeName of attributeNames) {
+        for (const attributeName of attributeNames) {
         
             if (invisibleAttributes && invisibleAttributes[attributeName]) {
                 continue;
@@ -336,7 +336,7 @@ mnn.Node = class {
     
     static _findParameterClassName(opParameterObject) {
         const keys = Object.getOwnPropertyNames(mnn.schema);
-        for (let key of keys) {
+        for (const key of keys) {
             const cls = mnn.schema[key];
             if (typeof cls === "function" && opParameterObject instanceof cls) {
                 return key;
@@ -616,7 +616,7 @@ mnn.Metadata = class {
         if (data) {
             const items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map.set(item.name, item.schema);
                     }
@@ -636,7 +636,7 @@ mnn.Metadata = class {
             if (!attributeMap) {
                 attributeMap = {};
                 if (schema.attributes) {
-                    for (let attribute of schema.attributes) {
+                    for (const attribute of schema.attributes) {
                         attributeMap[attribute.name] = attribute;
                     }
                 }

+ 29 - 29
src/mxnet.js

@@ -13,7 +13,7 @@ mxnet.ModelFactory = class {
         const identifier = context.identifier;
         const extension = identifier.split('.').pop().toLowerCase();
         if (extension == 'model' || extension == 'mar') {
-            if (context.entries.length > 0) {
+            if (context.entries('zip').length > 0) {
                 return true;
             }
         }
@@ -90,7 +90,7 @@ mxnet.ModelFactory = class {
             case 'model': {
                 let entries = new Map();
                 try {
-                    for (let entry of context.entries) {
+                    for (const entry of context.entries('zip')) {
                         entries.set(entry.name, entry);
                     }
                 }
@@ -218,7 +218,7 @@ mxnet.ModelFactory = class {
             if (params) {
                 try {
                     const stream = new ndarray.Stream(params);
-                    for (let key of Object.keys(stream.arrays)) {
+                    for (const key of Object.keys(stream.arrays)) {
                         let name = key;
                         if (name.startsWith('arg:') || name.startsWith('aux:')) {
                             name = key.substring(4);
@@ -400,7 +400,7 @@ mxnet.Graph = class {
         this._outputs = [];
 
         if (params) {
-            for (let key of Object.keys(params)) {
+            for (const key of Object.keys(params)) {
                 const param = params[key];
                 params[key] = new mxnet.Tensor('Initializer', key,
                     new mxnet.TensorType(param.dataType, new mxnet.TensorShape(param.shape.dimensions)),
@@ -410,7 +410,7 @@ mxnet.Graph = class {
 
         if (symbol) {
             const nodes = symbol.nodes;
-            for (let node of nodes) {
+            for (const node of nodes) {
                 if (node.op && node.op != 'null') { 
                     let operator = node.op;
                     const attrs = node.attrs || node.attr || node.param;
@@ -422,35 +422,35 @@ mxnet.Graph = class {
     
             let inputs = {};
             if (signature && signature.inputs) {
-                for (let input of signature.inputs) {
+                for (const input of signature.inputs) {
                     inputs[input.data_name] = input;
                 }
             }
             let outputs = {};
             if (signature && signature.outputs) {
-                for (let output of signature.outputs) {
+                for (const output of signature.outputs) {
                     outputs[output.data_name] = output;
                 }
             }
     
-            for (let node of nodes) {
+            for (const node of nodes) {
                 node.outputs = [];
             }
-            for (let node of nodes) {
+            for (const node of nodes) {
                 node.inputs = node.inputs.map((input) => {
                     return mxnet.Graph._updateOutput(nodes, input);
                 });
             }
     
             let outputCountMap = {};
-            for (let node of nodes) {
-                for (let output of node.outputs) {
+            for (const node of nodes) {
+                for (const output of node.outputs) {
                     outputCountMap[output] = (outputCountMap[output] || 0) + 1;
                 }
             }
     
             let argumentMap = {};
-            for (let index of symbol.arg_nodes) {
+            for (const index of symbol.arg_nodes) {
                 argumentMap[index] = (index < nodes.length) ? nodes[index] : null;
             }
     
@@ -467,11 +467,11 @@ mxnet.Graph = class {
             }
     
             let initializerMap = {};
-            for (let node of nodes.filter((node, index) => !argumentMap[index])) {
+            for (const node of nodes.filter((node, index) => !argumentMap[index])) {
                 this._nodes.push(new mxnet.Node(this._metadata, node, argumentMap, initializerMap, params));
             }
     
-            for (let argumentKey of Object.keys(argumentMap)) {
+            for (const argumentKey of Object.keys(argumentMap)) {
                 let argument = argumentMap[argumentKey];
                 if (argument && (!argument.inputs || argument.inputs.length == 0) && (argument.outputs && argument.outputs.length == 1)) {
                     const inputId = argument.outputs[0];
@@ -494,7 +494,7 @@ mxnet.Graph = class {
             }
             if (separator.length > 0) {
                 let blockMap = {};
-                for (let id of Object.keys(params)) {
+                for (const id of Object.keys(params)) {
                     let parts = id.split(separator);
                     let argumentName = parts.pop();
                     if (id.endsWith('moving_mean') || id.endsWith('moving_var')) {
@@ -611,7 +611,7 @@ mxnet.Node = class {
             if (this._operator == 'tvm_op' && attrs.func_name) {
                 this._operator = attrs.func_name;
             }
-            for (let attributeName of Object.keys(attrs)) {
+            for (const attributeName of Object.keys(attrs)) {
                 if (this._operator != 'tvm_op' && attributeName != 'func_name') {
                     this._attributes.push(new mxnet.Attribute(this._metadata, this.operator, attributeName, attrs[attributeName]));
                 }
@@ -637,7 +637,7 @@ mxnet.Node = class {
                 inputs = inputs.filter((item) => item != null);
             }
             let initializers = {};
-            for (let input of inputs) {
+            for (const input of inputs) {
                 const id = '[' + input.join(',') + ']';
                 initializer = initializerMap[id];
                 if (!initializer) {
@@ -688,11 +688,11 @@ mxnet.Node = class {
 
             let inputIndex = 0;
             if (schema && schema.inputs) {
-                for (let inputDef of schema.inputs) {
+                for (const inputDef of schema.inputs) {
                     if (inputIndex < inputs.length || inputDef.option != 'optional') {
                         let inputCount = (inputDef.option == 'variadic') ? (inputs.length - inputIndex) : 1;
                         let inputArguments = [];
-                        for (let input of inputs.slice(inputIndex, inputIndex + inputCount)) {
+                        for (const input of inputs.slice(inputIndex, inputIndex + inputCount)) {
                             const inputId = '[' + input.join(',') + ']';
                             if (inputId != '' || inputDef.option != 'optional') {
                                 inputArguments.push(new mxnet.Argument(inputId, inputDef.type, initializers[inputId]));
@@ -717,11 +717,11 @@ mxnet.Node = class {
             const outputs = node.outputs;
             let outputIndex = 0;
             if (schema && schema.outputs) {
-                for (let outputDef of schema.outputs) {
+                for (const outputDef of schema.outputs) {
                     if (outputIndex < outputs.length || outputDef.option != 'optional') {
                         let outputArguments = [];
                         const outputCount = (outputDef.option == 'variadic') ? (outputs.length - outputIndex) : 1;
-                        for (let output of outputs.slice(outputIndex, outputIndex + outputCount)) {
+                        for (const output of outputs.slice(outputIndex, outputIndex + outputCount)) {
                             outputArguments.push(new mxnet.Argument('[' + output.join(',') + ']', null, null));
                         }
                         this._outputs.push(new mxnet.Parameter(outputDef.name, outputArguments));
@@ -739,7 +739,7 @@ mxnet.Node = class {
         }
 
         if (node.params) {
-            for (let param of node.params) {
+            for (const param of node.params) {
                 this._inputs.push(new mxnet.Parameter(param.name, [
                     new mxnet.Argument(param.id, null, params[param.id] || null)
                 ]));
@@ -765,21 +765,21 @@ mxnet.Node = class {
                 schema.description = marked(schema.description);
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     if (attribute.description) {
                         attribute.description = marked(attribute.description);
                     }
                 }
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.description) {
                         input.description = marked(input.description);
                     }
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.description) {
                         output.description = marked(output.description);
                     }
@@ -842,7 +842,7 @@ mxnet.Attribute = class {
                         let items = this._value.substring(1, this._value.length - 1).split(',')
                             .map((item) => item.trim())
                             .map((item) => item.endsWith('L') ? item.substring(0, item.length - 1) : item);
-                        for (let item of items) {
+                        for (const item of items) {
                             number = Number.parseInt(item, 10);
                             if (Number.isNaN(item - number)) {
                                 array = null;
@@ -1119,7 +1119,7 @@ mxnet.Metadata = class {
         if (data) {
             const items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -1138,7 +1138,7 @@ mxnet.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }
@@ -1290,7 +1290,7 @@ ndarray.Shape = class {
 
     size() {
         let result = 1;
-        for (let dimension of this._dimensions) {
+        for (const dimension of this._dimensions) {
             result *= dimension;
         }
         return result;

+ 9 - 9
src/ncnn.js

@@ -128,7 +128,7 @@ ncnn.Graph = class {
             this._param(metadata, param, bin) :
             this._param_bin(metadata, param, bin);
  
-        for (let layer of layers) {
+        for (const layer of layers) {
             if (layer.type == 'Input') {
                 let dimensions = layer.attributes.map((a) => parseInt(a.value, 10));
                 let shape = new ncnn.TensorShape(dimensions);
@@ -316,19 +316,19 @@ ncnn.Node = class {
         let attributeMetadata = {};
         if (schema && schema.attributes) {
             for (let i = 0; i < schema.attributes.length; i++) {
-                let id = schema.attributes[i].id || i.toString();
+                const id = schema.attributes[i].id || i.toString();
                 attributeMetadata[id] = schema.attributes[i];
             }
         }
-        for (let attribute of layer.attributes) {
-            let attributeSchema = attributeMetadata[attribute.key];
+        for (const attribute of layer.attributes) {
+            const attributeSchema = attributeMetadata[attribute.key];
             this._attributes.push(new ncnn.Attribute(attributeSchema, attribute.key, attribute.value));
         }
 
         let inputs = layer.inputs;
         let inputIndex = 0;
         if (schema && schema.inputs) {
-            for (let inputDef of schema.inputs) {
+            for (const inputDef of schema.inputs) {
                 if (inputIndex < inputs.length || inputDef.option != 'optional') {
                     let inputCount = (inputDef.option == 'variadic') ? (inputs.length - inputIndex) : 1;
                     let inputArguments = inputs.slice(inputIndex, inputIndex + inputCount).filter((id) => id != '' || inputDef.option != 'optional').map((id) => {
@@ -351,7 +351,7 @@ ncnn.Node = class {
         let outputs = layer.outputs;
         let outputIndex = 0;
         if (schema && schema.outputs) {
-            for (let outputDef of schema.outputs) {
+            for (const outputDef of schema.outputs) {
                 if (outputIndex < outputs.length || outputDef.option != 'optional') {
                     let outputCount = (outputDef.option == 'variadic') ? (outputs.length - outputIndex) : 1;
                     let outputArguments = outputs.slice(outputIndex, outputIndex + outputCount).map((id) => {
@@ -510,7 +510,7 @@ ncnn.Node = class {
         let data = null;
         if (dimensions) {
             let size = 1;
-            for (let dimension of dimensions) {
+            for (const dimension of dimensions) {
                 size *= dimension;
             }
             if (!dataType) {
@@ -752,7 +752,7 @@ ncnn.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                         if (Object.prototype.hasOwnProperty.call(item.schema, 'operator')) {
@@ -778,7 +778,7 @@ ncnn.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 2 - 2
src/numpy.js

@@ -42,7 +42,7 @@ numpy.Array = class {
                     }
                     this._dataType = header.descr.substring(1);
                     let size = parseInt(header.descr[2]);
-                    for (let dimension of this._shape) {
+                    for (const dimension of this._shape) {
                         size *= dimension;
                     }
                     this._data = reader.bytes(size);
@@ -134,7 +134,7 @@ numpy.Array = class {
         writer.string(header);
 
         let size = context.itemSize;
-        for (let dimension of this._shape) {
+        for (const dimension of this._shape) {
             size *= dimension;
         }
 

+ 26 - 29
src/onnx.js

@@ -120,7 +120,7 @@ onnx.Model = class {
         let imports = {};
         if (model.opset_import && model.opset_import.length > 0) {
             let results = [];
-            for (let opset_import of model.opset_import) {
+            for (const opset_import of model.opset_import) {
                 let domain = opset_import.domain || 'ai.onnx';
                 let result = domain + ' v' + opset_import.version;
                 if (!results.includes(result)) {
@@ -141,7 +141,7 @@ onnx.Model = class {
         let imageFormat = '';
         if (model.metadata_props) {
             let imageMetadata = {};
-            for (let metadata_prop of model.metadata_props) {
+            for (const metadata_prop of model.metadata_props) {
                 switch (metadata_prop.key) {
                     case 'author':
                         this._author = metadata_prop.value;
@@ -261,27 +261,27 @@ onnx.Graph = class {
             this._description = graph.doc_string || '';
 
             let initializers = {};
-            for (let tensor of graph.initializer) {
+            for (const tensor of graph.initializer) {
                 initializers[tensor.name] = new onnx.Tensor(tensor, 'Initializer');
             }
             let nodes = [];
             let outputCountMap = {};
             let inputCountMap = {};
-            for (let node of graph.node) {
-                for (let input of node.input) {
+            for (const node of graph.node) {
+                for (const input of node.input) {
                     inputCountMap[input] = (inputCountMap[input] || 0) + 1;
                 }
-                for (let output of node.output) {
+                for (const output of node.output) {
                     outputCountMap[output] = (outputCountMap[output] || 0) + 1;
                 }
             }
-            for (let input of graph.input) {
+            for (const input of graph.input) {
                 delete inputCountMap[input];
             }
-            for (let output of graph.output) {
+            for (const output of graph.output) {
                 delete outputCountMap[output];
             }
-            for (let node of graph.node) {
+            for (const node of graph.node) {
                 let initializerNode = false;
                 if (node.op_type == 'Constant' && node.input.length == 0 && node.output.length == 1) {
                     let name = node.output[0];
@@ -299,26 +299,26 @@ onnx.Graph = class {
             }
 
             this._arguments = {};
-            for (let valueInfo of graph.value_info) {
+            for (const valueInfo of graph.value_info) {
                 this._argument(valueInfo.name, valueInfo.type, valueInfo.doc_string, initializers[valueInfo.name], imageFormat);
             }
-            for (let valueInfo of graph.input) {
+            for (const valueInfo of graph.input) {
                 let argument = this._argument(valueInfo.name, valueInfo.type, valueInfo.doc_string, initializers[valueInfo.name], imageFormat);
                 if (!initializers[valueInfo.name]) {
                     this._inputs.push(new onnx.Parameter(valueInfo.name, [ argument ]));
                 }
             }
-            for (let valueInfo of graph.output) {
+            for (const valueInfo of graph.output) {
                 let argument = this._argument(valueInfo.name, valueInfo.type, valueInfo.doc_string, initializers[valueInfo.name], imageFormat);
                 this._outputs.push(new onnx.Parameter(valueInfo.name, [ argument ]));
             }
-            for (let node of nodes) {
+            for (const node of nodes) {
                 let inputs = [];
                 const schema = metadata.getSchema(node.op_type);
                 if (node.input && node.input.length > 0) {
                     let inputIndex = 0;
                     if (schema && schema.inputs) {
-                        for (let inputSchema of schema.inputs) {
+                        for (const inputSchema of schema.inputs) {
                             if (inputIndex < node.input.length || inputSchema.option != 'optional') {
                                 let inputCount = (inputSchema.option == 'variadic') ? (node.input.length - inputIndex) : 1;
                                 let inputArguments = node.input.slice(inputIndex, inputIndex + inputCount).map((id) => {
@@ -341,7 +341,7 @@ onnx.Graph = class {
                 if (node.output && node.output.length > 0) {
                     let outputIndex = 0;
                     if (schema && schema.outputs) {
-                        for (let outputSchema of schema.outputs) {
+                        for (const outputSchema of schema.outputs) {
                             if (outputIndex < node.output.length || outputSchema.option != 'optional') {
                                 let outputCount = (outputSchema.option == 'variadic') ? (node.output.length - outputIndex) : 1;
                                 let outputArguments = node.output.slice(outputIndex, outputIndex + outputCount).map((id) => {
@@ -467,7 +467,7 @@ onnx.Node = class {
         this._description = description || '';
         this._attributes = [];
         if (attributes && attributes.length > 0) {
-            for (let attribute of attributes) {
+            for (const attribute of attributes) {
                 this._attributes.push(new onnx.Attribute(this._metadata, imageFormat, this.operator, attribute));
             }
         }            
@@ -497,21 +497,21 @@ onnx.Node = class {
                 schema.description = marked(schema.description, options);
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     if (attribute.description) {
                         attribute.description = marked(attribute.description, options);
                     }
                 }
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.description) {
                         input.description = marked(input.description, options);
                     }
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.description) {
                         output.description = marked(output.description, options);
                     }
@@ -527,7 +527,7 @@ onnx.Node = class {
                 schema.outputs_range = formatRange(schema.min_output) + ' - ' + formatRange(schema.max_output);
             }
             if (schema.type_constraints) {
-                for (let type_constraint of schema.type_constraints) {
+                for (const type_constraint of schema.type_constraints) {
                     if (type_constraint.allowed_type_strs) {
                         type_constraint.allowed_type_strs_display = type_constraint.allowed_type_strs.map((type) => { return type; }).join(', ');
                     }
@@ -1165,7 +1165,7 @@ onnx.GraphMetadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }
@@ -1195,7 +1195,7 @@ onnx.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         let name = item.name;
                         this._map[name] = this._map[name] || [];
@@ -1211,13 +1211,10 @@ onnx.Metadata = class {
         let schemas = this._map[operator];
         if (schemas) {
             let version = -1;
-            for (let schema of schemas) {
-                let domain = schema.domain;
-                if (domain == 'ai.onnx') {
-                    domain = '';
-                }
-                let importVersion = imports[domain];
-                let sinceVersion = schema.since_version;
+            for (const schema of schemas) {
+                const domain = schema.domain === 'ai.onnx' ? '' : schema.domain;
+                const importVersion = imports[domain];
+                const sinceVersion = schema.since_version;
                 if (importVersion >= sinceVersion && version < sinceVersion) {
                     version = sinceVersion;
                     result = schema;

+ 29 - 29
src/openvino.js

@@ -101,7 +101,7 @@ openvino.Graph = class {
 
         const edgeMap = this._collectEdges(edges);
 
-        for (let layer of layers) {
+        for (const  layer of layers) {
             const operator = layer.getAttribute('type');
             switch (operator) {
                 case 'Input': {
@@ -111,8 +111,8 @@ openvino.Graph = class {
                     // in IR v7 and newer the port is no longer an attribute of the layer but of each output port
                     const precision = layer.getAttribute('precision');
                     const id = layer.getAttribute('id');
-                    for (let outputElement of openvino.Node.children(layer, 'output')) {
-                        for (let portElement of openvino.Node.children(outputElement, 'port')) {
+                    for (const  outputElement of openvino.Node.children(layer, 'output')) {
+                        for (const  portElement of openvino.Node.children(outputElement, 'port')) {
                             const portPrecision = portElement.getAttribute('precision') || precision;
                             args.push(this._argument(id, portPrecision, portElement, null));
                         }
@@ -188,7 +188,7 @@ openvino.Graph = class {
         let argument = this._arguments[id];
         if (!argument) {
             let dimensions = [];
-            for (let dimElement of Array.prototype.slice.call(port.getElementsByTagName('dim'))) {
+            for (const  dimElement of Array.prototype.slice.call(port.getElementsByTagName('dim'))) {
                 dimensions.push(parseInt(dimElement.textContent.trim()));
             }
             const shape = (dimensions.length == 0) ? null : new openvino.TensorShape(dimensions);
@@ -199,7 +199,7 @@ openvino.Graph = class {
 
     _replaceTensorIteratorWithSubgraph(metadata, bin, layers, edges, edgeMap) {
         const tiNodes = layers.filter((node) => node.getAttribute('type') === 'TensorIterator');
-        for (let singleTensorIteratorNode of tiNodes) {
+        for (const  singleTensorIteratorNode of tiNodes) {
             const singleTensorIteratorNodeId = singleTensorIteratorNode.getAttribute("id");
             const tiNode = this._nodes.find((n) => n._id === `${singleTensorIteratorNodeId}`);
             const body = openvino.Node.children(singleTensorIteratorNode, 'body')[0];
@@ -213,11 +213,11 @@ openvino.Graph = class {
             const iteratorBackEdgesMap = this._collectEdges(iteratorBackEdges);
             const iteratorAllEdges = Object.assign({}, iteratorEdgeMap, iteratorBackEdgesMap);
             const mappingForNestedIR = this._parseMappingBlock(singleTensorIteratorNode);
-            for (let nestedLayer of iteratorLayers) {
+            for (const nestedLayer of iteratorLayers) {
                 let nestedNode = new openvino.Node(this, metadata, bin, nestedLayer, iteratorAllEdges);
                 nestedNode._id = `${singleTensorIteratorNodeId}_${nestedLayer.getAttribute('id')}`;
-                for (let input of nestedNode._inputs) {
-                    for (let input_argument of input.arguments) {
+                for (const input of nestedNode._inputs) {
+                    for (const input_argument of input.arguments) {
                         // we had a argument with id: 0:1  - meaning from layer "0" and its port "1"
                         // now as we rename all internal nodes to have an id of the TI included
                         // e.g. internal layer with id "0" and TI with id "14" results in internal layer to get id "14_0"
@@ -228,8 +228,8 @@ openvino.Graph = class {
                     }
                 }
 
-                for (let output of nestedNode._outputs) {
-                    for (let output_argument of output.arguments) {
+                for (const output of nestedNode._outputs) {
+                    for (const output_argument of output.arguments) {
                         // we had a argument with id: 1:1  - meaning from me with id "1" and my port "1"
                         // now as we rename all internal nodes to have an id of the TI included
                         // e.g. my layer with id "1" and TI with id "14" results in internal layer to get id "14_1"
@@ -245,7 +245,7 @@ openvino.Graph = class {
 
             // We know for sure that edges that appeared in the nested IR are not
             // aware of the external context
-            for (let nestedInput of mappingForNestedIR.input) {
+            for (const nestedInput of mappingForNestedIR.input) {
                 const nestedNode = this._nodes.find((n) => n._id === `${singleTensorIteratorNodeId}_${nestedInput.internal_layer_id}`);
                 const candidate_edges = edges.filter((edge) => {
                     return edge.getAttribute('to-layer') === singleTensorIteratorNodeId && edge.getAttribute('to-port') === nestedInput.external_port_id;
@@ -253,7 +253,7 @@ openvino.Graph = class {
                 if (!candidate_edges.length){
                     continue;
                 }
-                for (let candidate_edge of candidate_edges) {
+                for (const candidate_edge of candidate_edges) {
                     const parentLayerID = candidate_edge.getAttribute('from-layer');
                     const parentPortID = candidate_edge.getAttribute('from-port');
                     
@@ -303,7 +303,7 @@ openvino.Graph = class {
                 }
             }
 
-            for (let nestedOutput of mappingForNestedIR.output) {
+            for (const nestedOutput of mappingForNestedIR.output) {
                 const nestedNode = this._nodes.find((n) => n._id === `${singleTensorIteratorNodeId}_${nestedOutput.internal_layer_id}`);
                 const candidate_edges = edges.filter((edge) => {
                     return edge.getAttribute('from-layer') === singleTensorIteratorNodeId && edge.getAttribute('from-port') === nestedOutput.external_port_id;
@@ -311,15 +311,15 @@ openvino.Graph = class {
                 if (candidate_edges.length === 0){
                     continue;
                 }
-                for (let candidate_edge of candidate_edges) {
+                for (const candidate_edge of candidate_edges) {
                     const childLayerID = candidate_edge.getAttribute('to-layer');
                     const child = this._nodes.find((layer) => layer._id === childLayerID);
                     if (!child._inputs || (child._inputs && child._inputs.length === 0)){
                         continue;
                     }
                     if (nestedNode._outputs && nestedNode._outputs[0]) {
-                        for (let child_input of child._inputs) {
-                            for (let argument of child_input._arguments) {
+                        for (const child_input of child._inputs) {
+                            for (const argument of child_input._arguments) {
                                 if (!argument._id || (argument._id && argument._id.split(':')[0] !== singleTensorIteratorNodeId)) {
                                     continue;
                                 }
@@ -337,7 +337,7 @@ openvino.Graph = class {
 
     _collectEdges(edges){
         let edgeMap = {};
-        for (let edge of edges) {
+        for (const edge of edges) {
             const fromLayer = edge.getAttribute('from-layer');
             const fromPort = edge.getAttribute('from-port');
             const toLayer = edge.getAttribute('to-layer');
@@ -396,8 +396,8 @@ openvino.Node = class {
         let inputIndex = 0;
         const input = openvino.Node.children(layer, 'input')[0];
         if (input) {
-            for (let port of openvino.Node.children(input, 'port')) {
-                let inputName = (inputIndex == 0) ? 'input' : inputIndex.toString(); 
+            for (const port of openvino.Node.children(input, 'port')) {
+                const inputName = (inputIndex == 0) ? 'input' : inputIndex.toString(); 
                 this._inputs.push(new openvino.Parameter(inputName, [
                     graph._argument(this._id, precision, port, edgeMap)
                 ]));
@@ -407,8 +407,8 @@ openvino.Node = class {
         let outputIndex = 0;
         const output = openvino.Node.children(layer, 'output')[0];
         if (output) {
-            for (let portElement of openvino.Node.children(output, 'port')) {
-                let outputName = (outputIndex == 0) ? 'output' : outputIndex.toString();
+            for (const portElement of openvino.Node.children(output, 'port')) {
+                const outputName = (outputIndex == 0) ? 'output' : outputIndex.toString();
                 const portPrecision = portElement.getAttribute('precision') || precision;
                 this._outputs.push(new openvino.Parameter(outputName, [
                     graph._argument(this._id, portPrecision, portElement, null)
@@ -419,14 +419,14 @@ openvino.Node = class {
         let attributes = {};
         const data = openvino.Node.children(layer, 'data')[0];
         if (data && data.attributes) {
-            for (let attribute of Array.from(data.attributes)) {
+            for (const attribute of Array.from(data.attributes)) {
                 attributes[attribute.name] = attribute.value;
                 this._attributes.push(new openvino.Attribute(metadata, this, attribute.name, attribute.value));
             }
         }
         const blobs = openvino.Node.children(layer, 'blobs')[0];
         if (blobs){
-            for (let blob of Array.from(blobs.childNodes).filter((node) => node.nodeName != '#text')) {
+            for (const blob of Array.from(blobs.childNodes).filter((node) => node.nodeName != '#text')) {
                 if (blob.getAttribute && typeof blob.getAttribute === 'function') {
                     const name = blob.nodeName;
                     let data = null;
@@ -513,28 +513,28 @@ openvino.Node = class {
                 schema.description = marked(schema.description);
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     if (attribute.description) {
                         attribute.description = marked(attribute.description);
                     }
                 }
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.description) {
                         input.description = marked(input.description);
                     }
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.description) {
                         output.description = marked(output.description);
                     }
                 }
             }
             if (schema.references) {
-                for (let reference of schema.references) {
+                for (const reference of schema.references) {
                     if (reference) {
                         reference.description = marked(reference.description);
                     }
@@ -949,7 +949,7 @@ openvino.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item && item.name && item.schema) {
                         if (this._map.has(item.name)) {
                             throw new openvino.Error("Duplicate metadata key '" + item.name + "'.");
@@ -971,7 +971,7 @@ openvino.Metadata = class {
             this._attributeMap.set(key, null);
             const schema = this.getSchema(operator);
             if (schema && schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     this._attributeMap.set(operator + ':' + attribute.name, attribute);
                 }
             }

+ 10 - 10
src/paddle.js

@@ -44,7 +44,7 @@ paddle.Model = class {
 
     constructor(metadata, desc) {
         this._graphs = [];
-        for (let block of desc.blocks) {
+        for (const block of desc.blocks) {
             this._graphs.push(new paddle.Graph(metadata, block));
         }
     }
@@ -67,7 +67,7 @@ paddle.Graph = class {
 
         let initializers = {};
         let types = {};
-        for (let variable of block.vars) {
+        for (const variable of block.vars) {
             if (variable.persistable && variable.type && 
                 variable.type.type != paddle.proto.VarType.Type.FETCH_LIST && 
                 variable.type.type != paddle.proto.VarType.Type.FEED_MINIBATCH) {
@@ -81,10 +81,10 @@ paddle.Graph = class {
 
         let scope = {};
         for (let i = 0; i < block.ops.length; i++) {
-            for (let input of block.ops[i].inputs) {
+            for (const input of block.ops[i].inputs) {
                 input.arguments = input.arguments.map((argument) => scope[argument] ? scope[argument] : argument);
             }
-            for (let output of block.ops[i].outputs) {
+            for (const output of block.ops[i].outputs) {
                 output.arguments = output.arguments.map((argument) => {
                     if (scope[argument]) {
                         let next = argument + '\n' + i.toString(); // custom argument id
@@ -99,7 +99,7 @@ paddle.Graph = class {
 
         let lastNode = null;
         let lastOutput = null;
-        for (let op of block.ops) {
+        for (const op of block.ops) {
             if (op.type == 'feed') {
                 let inputName = op.attrs.filter((attr) => attr.name == 'col')[0].i.toString();
                 this._inputs.push(new paddle.Parameter(inputName, op.outputs[0].arguments.map((id) => {
@@ -221,16 +221,16 @@ paddle.Node = class {
         this._inputs = [];
         this._outputs = [];
         this._chain = [];
-        for (let attr of op.attrs) {
+        for (const attr of op.attrs) {
             this._attributes.push(new paddle.Attribute(metadata, this._operator, attr));
         }
-        for (let input of op.inputs) {
+        for (const input of op.inputs) {
             if (input.arguments.length > 0) {
                 let inputConnections = input.arguments.map((argument) => new paddle.Argument(argument, types[argument.split('\n').shift()], null, initializers[argument]));
                 this._inputs.push(new paddle.Parameter(input.parameter, inputConnections));
             }
         }
-        for (let output of op.outputs) {
+        for (const output of op.outputs) {
             if (output.arguments.length > 0) {
                 let outputConnections = output.arguments.map((argument) => new paddle.Argument(argument, types[argument.split('\n').shift()], null, null));
                 this._outputs.push(new paddle.Parameter(output.parameter, outputConnections));
@@ -485,7 +485,7 @@ paddle.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -504,7 +504,7 @@ paddle.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 7 - 14
src/pytorch.js

@@ -50,23 +50,16 @@ pytorch.ModelFactory = class {
 
     static _container(context, pickle, python, exception) {
         const identifier = context.identifier;
-        const entries = context.entries;
-        if (entries && entries.some((entry) => entry.name === 'model.json' || entry.name === 'data.pkl' || entry.name.endsWith('/model.json') || entry.name.endsWith('/data.pkl'))) {
-            return new pytorch.ZipContainer(identifier, entries, pickle, python, exception);
+        if (context.entries('zip').some((entry) => entry.name === 'model.json' || entry.name === 'data.pkl' || entry.name.endsWith('/model.json') || entry.name.endsWith('/data.pkl'))) {
+            return new pytorch.ZipContainer(identifier, context.entries('zip'), pickle, python, exception);
         }
         const buffer = context.buffer;
         const signature = [ 0x8a, 0x0a, 0x6c, 0xfc, 0x9c, 0x46, 0xf9, 0x20, 0x6a, 0xa8, 0x50, 0x19 ];
         if (buffer && buffer.length > 14 && buffer[0] == 0x80 && buffer[1] < 0x05 && signature.every((v, i) => v == buffer[i + 2])) {
             return new pytorch.PickleContainer(identifier, buffer, pickle, exception);
         }
-        try {
-            const archive = new tar.Archive(buffer);
-            if (archive.entries.some((entry) => entry.name == 'pickle')) {
-                return new pytorch.TarContainer(identifier, archive.entries, pickle, exception);
-            }
-        }
-        catch (error) {
-            // continue regardless of error
+        if (context.entries('tar').some((entry) => entry.name == 'pickle')) {
+            return new pytorch.TarContainer(identifier, context.entries('tar'), pickle, exception);
         }
         return null;
     }
@@ -1439,7 +1432,7 @@ pytorch.Execution = class {
                 obj.push({ key: key, value: value });
             };
             if (args) {
-                for (let arg of args) {
+                for (const arg of args) {
                     obj.__setitem__(arg[0], arg[1]);
                 }
             }
@@ -2167,7 +2160,7 @@ pytorch.TarContainer = class {
                 this._state = [];
                 let state_map = {};
                 if (obj && Array.isArray(obj)) {
-                    for (let item of obj) {
+                    for (const item of obj) {
                         if (!item || !item.key || !item.value) {
                             this._state = null;
                             break;
@@ -2849,7 +2842,7 @@ pytorch.ZipContainer = class {
     trace(obj, method) {
         let args = [];
         this._tensors = new Set();
-        for (let parameter of method.parameters) {
+        for (const parameter of method.parameters) {
             if (parameter.name !== 'self') {
                 this._tensors.add(parameter.name);
                 args.push({});

+ 16 - 16
src/sklearn.js

@@ -143,7 +143,7 @@ sklearn.ModelFactory = class {
                     };
                     this.__read__ = function(unpickler) {
                         let size = 1;
-                        for (let dimension of this.shape) {
+                        for (const dimension of this.shape) {
                             size *= dimension;
                         }
                         if (this.dtype.name == 'object') {
@@ -324,7 +324,7 @@ sklearn.ModelFactory = class {
                         obj.push({ key: key, value: value });
                     };
                     if (args) {
-                        for (let arg of args) {
+                        for (const arg of args) {
                             obj.__setitem__(arg[0], arg[1]);
                         }
                     }
@@ -375,11 +375,11 @@ sklearn.ModelFactory = class {
 
                 let find_weight_dict = function(dicts) {
 
-                    for (let dict of dicts) {
+                    for (const dict of dicts) {
                         if (dict && !Array.isArray(dict)) {
                             let list = [];
-                            for (let key in dict) {
-                                let value = dict[key]
+                            for (const key in dict) {
+                                const value = dict[key]
                                 if (key != 'weight_order' && key != 'lr') {
                                     if (!key ||
                                         !value.__type__ || !value.__type__ == 'numpy.ndarray') {
@@ -459,7 +459,7 @@ sklearn.Graph = class {
             switch (obj.__type__) {
                 case 'sklearn.pipeline.Pipeline':
                     this._groups = true;
-                    for (let step of obj.steps) {
+                    for (const step of obj.steps) {
                         this._add('pipeline', step[0], step[1], [ input ], [ step[0] ]);
                         input = step[0];
                     }
@@ -472,8 +472,8 @@ sklearn.Graph = class {
         else if (array_dict) {
             let group_map = {};
             let groups = [];
-            for (let array of array_dict) {
-                let key = array.key.split('_');
+            for (const array of array_dict) {
+                const key = array.key.split('_');
                 let id = null;
                 if (key.length > 1) {
                     array.name = key.pop();
@@ -503,7 +503,7 @@ sklearn.Graph = class {
     }
     _add(group, name, obj, inputs, outputs) {
         let initializers = [];
-        for (let key of Object.keys(obj)) {
+        for (const key of Object.keys(obj)) {
             if (!key.startsWith('_')) {
                 let value = obj[key];
                 if (value && value.__type__ && value.__type__ == 'numpy.ndarray') {
@@ -599,7 +599,7 @@ sklearn.Node = class {
         this._attributes = [];
         this._initializers = [];
 
-        for (let key of Object.keys(obj)) {
+        for (const key of Object.keys(obj)) {
             if (!key.startsWith('_')) {
                 let value = obj[key];
 
@@ -640,28 +640,28 @@ sklearn.Node = class {
                 schema.description = marked(schema.description);
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     if (attribute.description) {
                         attribute.description = marked(attribute.description);
                     }
                 }
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.description) {
                         input.description = marked(input.description);
                     }
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.description) {
                         output.description = marked(output.description);
                     }
                 }
             }
             if (schema.references) {
-                for (let reference of schema.references) {
+                for (const reference of schema.references) {
                     if (reference) {
                         reference.description = marked(reference.description);
                     }
@@ -1001,7 +1001,7 @@ sklearn.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -1020,7 +1020,7 @@ sklearn.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }

+ 42 - 42
src/tf.js

@@ -119,7 +119,7 @@ tf.ModelFactory = class {
                         meta_graph.graph_def = graph_def;
                         saved_model = new tf.proto.SavedModel();
                         saved_model.meta_graphs.push(meta_graph);
-                        for (let node of root.modelTopology.node) {
+                        for (const node of root.modelTopology.node) {
                             graph_def.node.push(node);
                             node.input = node.input || [];
                         }
@@ -358,7 +358,7 @@ tf.Graph = class {
             if (nodes) {
                 let nodeMap = {};
                 this._namespaces = {};
-                for (let node of nodes) {
+                for (const node of nodes) {
                     const nodeName = node.name;
                     nodeMap[nodeName] = node;
                     if (node.op != 'Const') {
@@ -370,11 +370,11 @@ tf.Graph = class {
                     }
                     node.output = [];
                 }
-                for (let node of nodes) {
+                for (const node of nodes) {
                     const inputs = node.input;
                     node.input = [];
                     node.controlDependencies = [];
-                    for (let input of inputs) {
+                    for (const input of inputs) {
                         let split = input.split(':', 2);
                         let inputName = split[0];
                         let outputIndex = split.length == 1 ? 0 : parseInt(split[1]);
@@ -396,16 +396,16 @@ tf.Graph = class {
                     }
                 }
                 this._nodeOutputCountMap = {};
-                for (let node of nodes) {
-                    for (let input of node.input) {
+                for (const node of nodes) {
+                    for (const input of node.input) {
                         this._nodeOutputCountMap[input] = (this._nodeOutputCountMap[input] || 0) + 1;
                     }
-                    for (let controlDependency of node.controlDependencies) {
+                    for (const controlDependency of node.controlDependencies) {
                         this._nodeOutputCountMap[controlDependency] = (this._nodeOutputCountMap[controlDependency] || 0) + 1;
                     }
                 }
                 let initializers = {};
-                for (let node of nodes) {
+                for (const node of nodes) {
                     if (node.op == 'Const' && node.input.length == 0 && node.controlDependencies.length == 0 && this._checkSingleOutput(node)) {
                         let value = node.attr.value;
                         if (value && Object.prototype.hasOwnProperty.call(value, 'tensor')) {
@@ -416,7 +416,7 @@ tf.Graph = class {
                         }
                     }
                 }
-                for (let node of nodes) {
+                for (const node of nodes) {
                     if (node.op == 'Identity' && node.input.length == 1 && node.controlDependencies.length == 0 && this._checkSingleOutput(node)) {
                         let initializer_name = node.input[0];
                         let initializer = initializers[initializer_name];
@@ -428,7 +428,7 @@ tf.Graph = class {
                     }
                 }
                 let inputMap = {};
-                for (let node of nodes) {
+                for (const node of nodes) {
                     if (node.op == 'Placeholder' && node.input.length == 0 && node.controlDependencies.length == 0 && node.output.length == 1) {
                         const dtype = node.attr.dtype;
                         const shape = node.attr.shape;
@@ -442,7 +442,7 @@ tf.Graph = class {
                 this._inputs = Object.keys(inputMap).map((key) => {
                     return inputMap[key];
                 });
-                for (let node of nodes) {
+                for (const node of nodes) {
                     let id = node.name;
                     if (!initializers[id] && !inputMap[id] /* && node.op != 'NoOp' */) {
                         this._nodes.push(new tf.Node(this, node, node.op, node.name, initializers, null));
@@ -451,8 +451,8 @@ tf.Graph = class {
             }
 
             if (graph.library) {
-                let funcs = graph.library.function;
-                for (let func of funcs) {
+                const funcs = graph.library.function;
+                for (const func of funcs) {
                     this._functions.push(new tf.Function(this, func, this._metadata));
                 }
             }
@@ -460,7 +460,7 @@ tf.Graph = class {
         else if (bundle) {
             let nodeNames = [];
             let nodeMap = new Map();
-            for (let tensor of bundle.tensors) {
+            for (const tensor of bundle.tensors) {
                 let parts = tensor.name.split('/');
                 if (bundle.format === 2) {
                     if (tensor.name === '_CHECKPOINTABLE_OBJECT_GRAPH' || 
@@ -482,7 +482,7 @@ tf.Graph = class {
                 }
                 nodeMap.get(nodeName).push({ name: tensorName, value: tensor });
             }
-            for (let nodeName of nodeNames) {
+            for (const nodeName of nodeNames) {
                 this._nodes.push(new tf.Node(this, null, 'Node', nodeName, null, nodeMap.get(nodeName)));
             }
         }
@@ -601,22 +601,22 @@ tf.Function = class {
 
         let inputs = func.signature.input_arg;
         if (inputs) {
-            for (let input of inputs) {
+            for (const input of inputs) {
                 let inputArgument = new tf.Argument(input.name, new tf.TensorType(input.type, null), null);
                 this._inputs.push(new tf.Parameter(input.name, [ inputArgument ]));
             }
         }
 
         let ret_map = {};
-        for (let key of Object.keys(func.ret)) {
-            let v = func.ret[key].split(':', 2);
+        for (const key of Object.keys(func.ret)) {
+            const v = func.ret[key].split(':', 2);
             ret_map[key] = v[0];
         }
 
         let out_args_reverse_map = {};
         let outputs = func.signature.output_arg;
         if (outputs) {
-            for (let output of outputs) {
+            for (const output of outputs) {
                 let name = ret_map[output.name];
                 this._outputs.push(new tf.Parameter(output.name, [ 
                     new tf.Argument(name, new tf.TensorType(output.type, null), null)
@@ -629,7 +629,7 @@ tf.Function = class {
         if (nodes) {
             let nodeMap = {};
 
-            for (let node of nodes) {
+            for (const node of nodes) {
                 let nodeName = node.name;
                 nodeMap[nodeName] = node;
                 if (node.op != 'Const') {
@@ -641,11 +641,11 @@ tf.Function = class {
                 }
                 node.output = [];
             }
-            for (let node of nodes) {
+            for (const node of nodes) {
                 let inputs = node.input;
                 node.input = [];
                 node.controlDependencies = [];
-                for (let input of inputs) {
+                for (const input of inputs) {
                     let split = input.split(':', 3);
                     let inputName = split[0];
                     let outputIndex = split.length == 1 ? 0 : parseInt(split[split.length - 1]);
@@ -672,17 +672,17 @@ tf.Function = class {
             }
 
             let nodeOutputCountMap = {};
-            for (let node of nodes) {
-                for (let input of node.input) {
+            for (const node of nodes) {
+                for (const input of node.input) {
                     nodeOutputCountMap[input] = (nodeOutputCountMap[input] || 0) + 1;
                 }
-                for (let controlDependency of node.controlDependencies) {
+                for (const controlDependency of node.controlDependencies) {
                     nodeOutputCountMap[controlDependency] = (nodeOutputCountMap[controlDependency] || 0) + 1;
                 }
             }
 
             let initializers = {};
-            for (let node of nodes) {
+            for (const node of nodes) {
                 if (node.op == 'Const' && node.input.length == 0 && node.controlDependencies.length == 0 && tf.Function._checkSingleOutput(node, nodeOutputCountMap)) {
                     let value = node.attr.value;
                     if (value && Object.prototype.hasOwnProperty.call(value, 'tensor')) {
@@ -693,7 +693,7 @@ tf.Function = class {
                     }
                 }
             }
-            for (let node of nodes) {
+            for (const node of nodes) {
                 if (node.op == 'Identity' && node.input.length == 1 && node.controlDependencies.length == 0 && tf.Function._checkSingleOutput(node, nodeOutputCountMap)) {
                     let initializer_name = node.input[0];
                     let initializer = initializers[initializer_name];
@@ -705,7 +705,7 @@ tf.Function = class {
                 }
             }
 
-            for (let node of nodes) {
+            for (const node of nodes) {
                 if (!initializers[node.name])
                     this._nodes.push(new tf.Node(this, node, node.op, node.name, initializers, null));
             }
@@ -781,7 +781,7 @@ tf.Node = class {
             }
             const metadata = graph.metadata;
             if (node.attr) {
-                for (let attributeName of Object.keys(node.attr)) {
+                for (const attributeName of Object.keys(node.attr)) {
                     this._attributes.push(new tf.Attribute(attributeName, node.attr[attributeName], this._operator, metadata));
                 }
             }
@@ -789,7 +789,7 @@ tf.Node = class {
             let inputIndex = 0;
             let inputs = node.input.filter(input => !input.startsWith('^'));
             if (schema && schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     let inputCount = 1;
                     if (input.numberAttr) {
                         let inputNumber = node.attr[input.numberAttr];
@@ -818,7 +818,7 @@ tf.Node = class {
             let outputIndex = 0;
             let outputs = node.output;
             if (schema && schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     let outputCount = 1;
                     if (output.numberAttr) {
                         let outputNumber = node.attr[output.numberAttr];
@@ -847,7 +847,7 @@ tf.Node = class {
             this._controlDependencies = node.controlDependencies;
         }
         else if (tensors) {
-            for (let tensor of tensors) {
+            for (const tensor of tensors) {
                 this._inputs.push(new tf.Parameter(tensor.name, [
                     new tf.Argument(tensor.value.name, null, tensor.value)
                 ]));
@@ -902,7 +902,7 @@ tf.Node = class {
                 schema.description = marked(schema.description);
             }
             if (schema.inputs) {
-                for (let input of schema.inputs) {
+                for (const input of schema.inputs) {
                     if (input.type) {
                         input.type = tf.Tensor.formatDataType(input.type);
                     }
@@ -918,7 +918,7 @@ tf.Node = class {
                 }
             }
             if (schema.outputs) {
-                for (let output of schema.outputs) {
+                for (const output of schema.outputs) {
                     if (output.type) {
                         output.type = tf.Tensor.formatDataType(output.type);
                     }
@@ -934,7 +934,7 @@ tf.Node = class {
                 }
             }
             if (schema.attributes) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     let description = attribute.description;
                     if (attribute.allowedValues) {
                         let allowedValues = tf.GraphMetadata._formatAttributeValue(attribute.allowedValues);
@@ -1174,7 +1174,7 @@ tf.Tensor = class {
             return context;
         }
 
-        for (let dim of shape.dim) {
+        for (const dim of shape.dim) {
             context.size = context.size * (dim.size ? dim.size : 0);
         }
 
@@ -1478,7 +1478,7 @@ tf.TensorBundle = class {
             case 1: {
                 const header = tf.proto.SavedTensorSlices.decode(entries.get(''));
                 let data = new Map();
-                for (let pair of entries) {
+                for (const pair of entries) {
                     if (pair[0] !== '' && pair[0] !== 'global_step') {
                         const slices = tf.proto.SavedTensorSlices.decode(pair[1]);
                         const name = slices.data.name;
@@ -1505,7 +1505,7 @@ tf.TensorBundle = class {
                         }
                     }
                 }
-                for (let meta of header.meta.tensor) {
+                for (const meta of header.meta.tensor) {
                     if (meta.name !== 'global_step') {
                         let tensor = new tf.proto.TensorProto();
                         tensor.dtype = meta.type;
@@ -1627,7 +1627,7 @@ tf.GraphMetadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }
@@ -1643,7 +1643,7 @@ tf.GraphMetadata = class {
             if (!map) {
                 map = {};
                 if (schema.inputs) {
-                    for (let input of schema.inputs) {
+                    for (const input of schema.inputs) {
                         if (input.typeAttr) {
                             map[input.typeAttr] = true;
                         }
@@ -1656,7 +1656,7 @@ tf.GraphMetadata = class {
                     }
                 }
                 if (schema.outputs) {
-                    for (let output of schema.outputs) {
+                    for (const output of schema.outputs) {
                         if (output.typeAttr) {
                             map[output.typeAttr] = true;
                         }
@@ -1724,7 +1724,7 @@ tf.Metadata = class {
             if (data) {
                 const items = JSON.parse(data);
                 if (items) {
-                    for (let item of items) {
+                    for (const item of items) {
                         if (item.name && item.schema) {
                             this._map[item.name] = item.schema;
                         }

+ 5 - 5
src/tflite.js

@@ -66,7 +66,7 @@ tflite.Model = class {
         this._description = model.description() || '';
         let operatorCodeList = [];
         let builtinOperatorMap = {};
-        for (let key of Object.keys(tflite.schema.BuiltinOperator)) {
+        for (const key of Object.keys(tflite.schema.BuiltinOperator)) {
             const upperCase = new Set([ '2D', 'LSH', 'SVDF', 'RNN', 'L2', 'LSTM' ]);
             const builtinOperatorIndex = tflite.schema.BuiltinOperator[key]; 
             builtinOperatorMap[builtinOperatorIndex] = key.split('_').map((s) => {
@@ -695,7 +695,7 @@ tflite.Metadata = class {
         if (data) {
             const items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -715,7 +715,7 @@ tflite.Metadata = class {
             if (!attributeMap) {
                 attributeMap = {};
                 if (schema.attributes) {
-                    for (let attribute of schema.attributes) {
+                    for (const attribute of schema.attributes) {
                         attributeMap[attribute.name] = attribute;
                     }
                 }
@@ -735,7 +735,7 @@ tflite.Utility = class {
     static dataType(type) {
         if (!tflite.Utility._tensorTypeMap) {
             tflite.Utility._tensorTypeMap = new Map();
-            for (let name of Object.keys(tflite.schema.TensorType)) {
+            for (const name of Object.keys(tflite.schema.TensorType)) {
                 tflite.Utility._tensorTypeMap.set(tflite.schema.TensorType[name], name.toLowerCase());
             }
             tflite.Utility._tensorTypeMap.set(6, 'boolean');
@@ -753,7 +753,7 @@ tflite.Utility = class {
                 typeMap = new Map();
                 const enumType = tflite.schema[type];
                 if (enumType) {
-                    for (let key of Object.keys(enumType)) {
+                    for (const key of Object.keys(enumType)) {
                         typeMap.set(enumType[key], key);
                     }
                 }

+ 19 - 19
src/torch.js

@@ -111,7 +111,7 @@ torch.Graph = class {
                 let subOutputs = [];
                 const length = module.modules.length;
                 let index = 0;
-                for (let subModule of module.modules) {
+                for (const subModule of module.modules) {
                     if (index == length - 1) {
                         subOutputs = outputs;
                     }                    
@@ -130,7 +130,7 @@ torch.Graph = class {
                 let newInputs = [];
                 let newOutputs = [];
                 let index = 0;
-                for (let subModule of module.modules) {
+                for (const subModule of module.modules) {
                     let subInputs = [].concat(inputs);
                     let subOutputs = [].concat(outputs);
                     this._loadModule(metadata, subModule, groups, index.toString(), subInputs, subOutputs);
@@ -143,7 +143,7 @@ torch.Graph = class {
                     index++;
                 }
                 inputs = inputs.concat(newInputs);
-                for (let newOutput of newOutputs) {
+                for (const newOutput of newOutputs) {
                     outputs.push(newOutput);
                 }
                 groups.pop();
@@ -157,7 +157,7 @@ torch.Graph = class {
                 }
                 let concatInputs = [];
                 let index = 0;
-                for (let subModule of module.modules) {
+                for (const subModule of module.modules) {
                     let streamInputs = inputs.map((input) => input);
                     let streamOutputs = [];
                     this._loadModule(metadata, subModule, groups, prefix + '.' + index.toString(), streamInputs, streamOutputs);
@@ -249,7 +249,7 @@ torch.Node = class {
         const type = module.__type__;
         this._operator = type ? type.split('.').pop() : 'Unknown';
         let initializers = [];
-        for (let key of Object.keys(module)) {
+        for (const key of Object.keys(module)) {
             const obj = module[key];
             if (obj && obj.__type__ && obj.__type__.startsWith('torch.') && obj.__type__.endsWith('Storage')) {
                 let array = [];
@@ -347,7 +347,7 @@ torch.Node = class {
         }
         this._attributes = [];
         if (module.__type__) {
-            for (let key of Object.keys(module)) {
+            for (const key of Object.keys(module)) {
                 if (key == '__type__' || key == '_type') {
                     continue;
                 }
@@ -640,7 +640,7 @@ torch.Metadata = class {
         if (data) {
             let items = JSON.parse(data);
             if (items) {
-                for (let item of items) {
+                for (const item of items) {
                     if (item.name && item.schema) {
                         this._map[item.name] = item.schema;
                     }
@@ -659,7 +659,7 @@ torch.Metadata = class {
             map = {};
             const schema = this.getSchema(operator);
             if (schema && schema.attributes && schema.attributes.length > 0) {
-                for (let attribute of schema.attributes) {
+                for (const attribute of schema.attributes) {
                     map[attribute.name] = attribute;
                 }
             }
@@ -982,7 +982,7 @@ torch.T7Reader = class {
     nn(obj) {
         let attributes = this.read();
         if (attributes != null) {
-            for (let key of Object.keys(attributes)) {
+            for (const key of Object.keys(attributes)) {
                 obj[key] = attributes[key];
             }
         }
@@ -1156,8 +1156,8 @@ torch.TextReader = class {
     }
 
     int64() {
-        let token = this._textDecoder.decode(this.line(20));
-        let number = Number.parseInt(token, 10);
+        const token = this._textDecoder.decode(this.line(20));
+        const number = Number.parseInt(token, 10);
         if (Number.isNaN(token - number)) {
             throw new torch.Error("Couldn't parse int64 '" + token + "'.");
         }
@@ -1167,9 +1167,9 @@ torch.TextReader = class {
     int64s(size) {
         let array = [];
         if (size > 0) {
-            let text = this._textDecoder.decode(this.line(Number.MAX_SAFE_INTEGER));
-            for (let token of text.split(' ')) {
-                let number = Number.parseInt(token, 10);
+            const text = this._textDecoder.decode(this.line(Number.MAX_SAFE_INTEGER));
+            for (const token of text.split(' ')) {
+                const number = Number.parseInt(token, 10);
                 if (Number.isNaN(token - number)) {
                     throw new torch.Error("Couldn't parse int64 '" + token + "'.");
                 }
@@ -1184,7 +1184,7 @@ torch.TextReader = class {
     }
 
     float64() {
-        let token = this._textDecoder.decode(this.line(24));
+        const token = this._textDecoder.decode(this.line(24));
         if (token.startsWith('-nan')) {
             return -NaN;
         }
@@ -1197,7 +1197,7 @@ torch.TextReader = class {
         if (token.startsWith('-inf')) {
             return -Infinity;
         }
-        let number = Number.parseFloat(token);
+        const number = Number.parseFloat(token);
         if (Number.isNaN(token - number)) {
             throw new Error("Couldn't parse float '" + token + "'.");
         }
@@ -1205,12 +1205,12 @@ torch.TextReader = class {
     }
 
     string() {
-        let size = this.int32();
+        const size = this.int32();
         if (size == 0) {
             return '';
         }
-        let data = this.line(size);
-        let text = this._textDecoder.decode(data);
+        const data = this.line(size);
+        const text = this._textDecoder.decode(data);
         if (size != text.length) {
             throw torch.Error('Invalid text length.');
         }

+ 41 - 41
src/view-grapher.js

@@ -33,22 +33,22 @@ grapher.Renderer = class {
         svgNodeGroup.setAttribute('class', 'nodes');
         this._svgElement.appendChild(svgNodeGroup);
 
-        for (let nodeId of graph.nodes()) {
+        for (const nodeId of graph.nodes()) {
             if (graph.children(nodeId).length == 0) {
-                let node = graph.node(nodeId);
-                let element = this.createElement('g');
+                const node = graph.node(nodeId);
+                const element = this.createElement('g');
                 if (node.id) {
                     element.setAttribute('id', node.id);
                 }
                 element.setAttribute('class', Object.prototype.hasOwnProperty.call(node, 'class') ? ('node ' + node.class) : 'node');
                 element.style.opacity = 0;
-                let container = this.createElement('g');
+                const container = this.createElement('g');
                 container.appendChild(node.label);
                 element.appendChild(container);
                 svgNodeGroup.appendChild(element);
-                let nodeBox = node.label.getBBox();
-                let nodeX = - nodeBox.width / 2;
-                let nodeY = - nodeBox.height / 2;
+                const nodeBox = node.label.getBBox();
+                const nodeX = - nodeBox.width / 2;
+                const nodeY = - nodeBox.height / 2;
                 container.setAttribute('transform', 'translate(' + nodeX + ',' + nodeY + ')');
                 node.width = nodeBox.width;
                 node.height = nodeBox.height;
@@ -56,26 +56,26 @@ grapher.Renderer = class {
             }
         }
 
-        for (let edgeId of graph.edges()) {
-            let edge = graph.edge(edgeId);
+        for (const edgeId of graph.edges()) {
+            const edge = graph.edge(edgeId);
             if (edge.label) {
                 let tspan = this.createElement('tspan');
                 tspan.setAttribute('xml:space', 'preserve');
                 tspan.setAttribute('dy', '1em');
                 tspan.setAttribute('x', '1');
                 tspan.appendChild(this._document.createTextNode(edge.label));
-                let text = this.createElement('text');
+                const text = this.createElement('text');
                 text.appendChild(tspan);
-                let textContainer = this.createElement('g');
+                const textContainer = this.createElement('g');
                 textContainer.appendChild(text);
-                let labelElement = this.createElement('g');
+                const labelElement = this.createElement('g');
                 labelElement.style.opacity = 0;
                 labelElement.setAttribute('class', 'edge-label');
                 labelElement.appendChild(textContainer);
                 svgEdgeLabelGroup.appendChild(labelElement);
-                let edgeBox = textContainer.getBBox();
-                let edgeX = - edgeBox.width / 2;
-                let edgeY = - edgeBox.height / 2;
+                const edgeBox = textContainer.getBBox();
+                const edgeX = - edgeBox.width / 2;
+                const edgeY = - edgeBox.height / 2;
                 textContainer.setAttribute('transform', 'translate(' + edgeX + ',' + edgeY + ')');
                 edge.width = edgeBox.width;
                 edge.height = edgeBox.height;
@@ -85,17 +85,17 @@ grapher.Renderer = class {
 
         dagre.layout(graph);
 
-        for (let nodeId of graph.nodes()) {
+        for (const nodeId of graph.nodes()) {
             if (graph.children(nodeId).length == 0) {
-                let node = graph.node(nodeId);
+                const node = graph.node(nodeId);
                 node.element.setAttribute('transform', 'translate(' + node.x + ',' + node.y + ')');
                 node.element.style.opacity = 1;
                 delete node.element;
             }
         }
 
-        for (let edgeId of graph.edges()) {
-            let edge = graph.edge(edgeId);
+        for (const edgeId of graph.edges()) {
+            const edge = graph.edge(edgeId);
             if (edge.labelElement) {
                 edge.labelElement.setAttribute('transform', 'translate(' + edge.x + ',' + edge.y + ')');
                 edge.labelElement.style.opacity = 1;
@@ -103,9 +103,9 @@ grapher.Renderer = class {
             }
         }
 
-        let edgePathGroupDefs = this.createElement('defs');
+        const edgePathGroupDefs = this.createElement('defs');
         svgEdgePathGroup.appendChild(edgePathGroupDefs);
-        let marker = this.createElement('marker');
+        const marker = this.createElement('marker');
         marker.setAttribute('id', 'arrowhead-vee');
         marker.setAttribute('viewBox', '0 0 10 10');
         marker.setAttribute('refX', 9);
@@ -115,16 +115,16 @@ grapher.Renderer = class {
         marker.setAttribute('markerHeight', 6);
         marker.setAttribute('orient', 'auto');
         edgePathGroupDefs.appendChild(marker);
-        let markerPath = this.createElement('path');
+        const markerPath = this.createElement('path');
         markerPath.setAttribute('d', 'M 0 0 L 10 5 L 0 10 L 4 5 z');
         markerPath.style.setProperty('stroke-width', 1);
         markerPath.style.setProperty('stroke-dasharray', '1,0');
         marker.appendChild(markerPath);
 
-        for (let edgeId of graph.edges()) {
-            let edge = graph.edge(edgeId);
-            let edgePath = grapher.Renderer._computeCurvePath(edge, graph.node(edgeId.v), graph.node(edgeId.w));
-            let edgeElement = this.createElement('path');
+        for (const edgeId of graph.edges()) {
+            const edge = graph.edge(edgeId);
+            const edgePath = grapher.Renderer._computeCurvePath(edge, graph.node(edgeId.v), graph.node(edgeId.w));
+            const edgeElement = this.createElement('path');
             edgeElement.setAttribute('class', Object.prototype.hasOwnProperty.call(edge, 'class') ? ('edge-path ' + edge.class) : 'edge-path');
             edgeElement.setAttribute('d', edgePath);
             edgeElement.setAttribute('marker-end', 'url(#arrowhead-vee)');
@@ -134,13 +134,13 @@ grapher.Renderer = class {
             svgEdgePathGroup.appendChild(edgeElement);
         }
 
-        for (let nodeId of graph.nodes()) {
+        for (const nodeId of graph.nodes()) {
             if (graph.children(nodeId).length > 0) {
-                let node = graph.node(nodeId);
-                let nodeElement = this.createElement('g');
+                const node = graph.node(nodeId);
+                const nodeElement = this.createElement('g');
                 nodeElement.setAttribute('class', 'cluster');
                 nodeElement.setAttribute('transform', 'translate(' + node.x + ',' + node.y + ')');
-                let rect = this.createElement('rect');
+                const rect = this.createElement('rect');
                 rect.setAttribute('x', - node.width / 2);
                 rect.setAttribute('y', - node.height / 2 );
                 rect.setAttribute('width', node.width);
@@ -166,10 +166,10 @@ grapher.Renderer = class {
         points.unshift(grapher.Renderer.intersectRect(tail, points[0]));
         points.push(grapher.Renderer.intersectRect(head, points[points.length - 1]));
 
-        let path = new Path();
-        let curve = new Curve(path);
+        const path = new Path();
+        const curve = new Curve(path);
         for (let i = 0; i < points.length; i++) {
-            let point = points[i];
+            const point = points[i];
             if (i == 0) {
                 curve.lineStart();
             }
@@ -183,10 +183,10 @@ grapher.Renderer = class {
     }
     
     static intersectRect(node, point) {
-        let x = node.x;
-        let y = node.y;
-        let dx = point.x - x;
-        let dy = point.y - y;
+        const x = node.x;
+        const y = node.y;
+        const dx = point.x - x;
+        const dy = point.y - y;
         let w = node.width / 2;
         let h = node.height / 2;
         let sx;
@@ -238,7 +238,7 @@ grapher.NodeElement = class {
         let height = 0;
         let tops = [];
 
-        for (let block of this._blocks) {
+        for (const block of this._blocks) {
             tops.push(height);
             block.layout(rootElement);
             if (width < block.width) {
@@ -262,7 +262,7 @@ grapher.NodeElement = class {
     }
 
     static roundedRect(x, y, width, height, r1, r2, r3, r4) {
-        let radius = 5;
+        const radius = 5;
         r1 = r1 ? radius : 0;
         r2 = r2 ? radius : 0;
         r3 = r3 ? radius : 0;
@@ -307,7 +307,7 @@ grapher.NodeElement.Header = class {
         this._elements = [];
         let x = 0;
         let y = 0;
-        for (let item of this._items) {
+        for (const item of this._items) {
             let yPadding = 4;
             let xPadding = 7;
             let element = this.createElement('g');
@@ -458,7 +458,7 @@ grapher.NodeElement.List = class {
         this._element.appendChild(this._backgroundElement);
         this._element.setAttribute('transform', 'translate(' + x + ',' + y + ')');
         this._height += 3;
-        for (let item of this._items) {
+        for (const item of this._items) {
             let yPadding = 1;
             let xPadding = 6;
             let textElement = this.createElement('text');

+ 29 - 29
src/view-sidebar.js

@@ -108,7 +108,7 @@ sidebar.Sidebar = class {
                 contentElement.innerHTML = item.content;
             }
             else if (item.content instanceof Array) {
-                for (let element of item.content) {
+                for (const element of item.content) {
                     contentElement.appendChild(element);
                 }
             }
@@ -171,7 +171,7 @@ sidebar.NodeSidebar = class {
         let attributes = node.attributes;
         if (attributes && attributes.length > 0) {
             this._addHeader('Attributes');
-            for (let attribute of attributes) {
+            for (const attribute of attributes) {
                 this._addAttribute(attribute.name, attribute);
             }
         }
@@ -179,7 +179,7 @@ sidebar.NodeSidebar = class {
         let inputs = node.inputs;
         if (inputs && inputs.length > 0) {
             this._addHeader('Inputs');
-            for (let input of inputs) {
+            for (const input of inputs) {
                 this._addInput(input.name, input);
             }
         }
@@ -187,7 +187,7 @@ sidebar.NodeSidebar = class {
         let outputs = node.outputs;
         if (outputs && outputs.length > 0) {
             this._addHeader('Outputs');
-            for (let output of outputs) {
+            for (const output of outputs) {
                 this._addOutput(output.name, output);
             }
         }
@@ -225,7 +225,7 @@ sidebar.NodeSidebar = class {
             view.on('export-tensor', (sender, tensor) => {
                 this._raise('export-tensor', tensor);
             });
-            let item = new sidebar.NameValueView(this._host, name, view);
+            const item = new sidebar.NameValueView(this._host, name, view);
             this._inputs.push(item);
             this._elements.push(item.render());
         }
@@ -233,14 +233,14 @@ sidebar.NodeSidebar = class {
 
     _addOutput(name, output) {
         if (output.arguments.length > 0) {
-            let item = new sidebar.NameValueView(this._host, name, new sidebar.ParameterView(this._host, output));
+            const item = new sidebar.NameValueView(this._host, name, new sidebar.ParameterView(this._host, output));
             this._outputs.push(item);
             this._elements.push(item.render());
         }
     }
 
     toggleInput(name) {
-        for (let input of this._inputs) {
+        for (const input of this._inputs) {
             if (name == input.name) {
                 input.toggle();
             }
@@ -255,7 +255,7 @@ sidebar.NodeSidebar = class {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -330,7 +330,7 @@ sidebar.NodeSidebar = class {
             list.push(sidebar.NodeSidebar.formatAttributeValue(value[Object.keys(value)[0]], null, true))
         }
         else {
-            for (let key of keys) {
+            for (const key of keys) {
                 list.push(key + ': ' + sidebar.NodeSidebar.formatAttributeValue(value[key], null, true));
             }
         }
@@ -372,7 +372,7 @@ sidebar.NameValueView = class {
         let valueElement = this._host.document.createElement('div');
         valueElement.className = 'sidebar-view-item-value-list';
 
-        for (let element of value.render()) {
+        for (const element of value.render()) {
             valueElement.appendChild(element);
         }
 
@@ -408,7 +408,7 @@ sidebar.SelectView = class {
         });
         this._elements.push(selectElement);
 
-        for (let value of values) {
+        for (const value of values) {
             let optionElement = this._host.document.createElement('option');
             optionElement.innerText = value;
             if (value == selected) {
@@ -430,7 +430,7 @@ sidebar.SelectView = class {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -554,7 +554,7 @@ sidebar.ParameterView = class {
         this._list = list;
         this._elements = [];
         this._items = [];
-        for (let argument of list.arguments) {
+        for (const argument of list.arguments) {
             let item = new sidebar.ArgumentView(host, argument);
             item.on('export-tensor', (sender, tensor) => {
                 this._raise('export-tensor', tensor);
@@ -569,7 +569,7 @@ sidebar.ParameterView = class {
     }
 
     toggle() {
-        for (let item of this._items) {
+        for (const item of this._items) {
             item.toggle();
         }
     }
@@ -582,7 +582,7 @@ sidebar.ParameterView = class {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -735,7 +735,7 @@ sidebar.ArgumentView = class {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -788,7 +788,7 @@ sidebar.ModelSidebar = class {
 
         let metadata = this._model.metadata;
         if (metadata) {
-            for (let property of this._model.metadata) {
+            for (const property of this._model.metadata) {
                 this._addProperty(property.name, new sidebar.ValueTextView(this._host, property.value));
             }
         }
@@ -817,14 +817,14 @@ sidebar.ModelSidebar = class {
 
             if (graph.inputs.length > 0) {
                 this._addHeader('Inputs');
-                for (let input of graph.inputs) {
+                for (const input of graph.inputs) {
                     this.addArgument(input.name, input);
                 }
             }
 
             if (graph.outputs.length > 0) {
                 this._addHeader('Outputs');
-                for (let output of graph.outputs) {
+                for (const output of graph.outputs) {
                     this.addArgument(output.name, output);
                 }
             }
@@ -862,7 +862,7 @@ sidebar.ModelSidebar = class {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -982,7 +982,7 @@ In domain <tt>{{{domain}}}</tt> since version <tt>{{{since_version}}}</tt> at su
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -1022,7 +1022,7 @@ sidebar.FindSidebar = class {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -1083,12 +1083,12 @@ sidebar.FindSidebar = class {
         let nodeMatches = new Set();
         let edgeMatches = new Set();
 
-        for (let node of this._graph.nodes) {
+        for (const node of this._graph.nodes) {
 
             let initializers = [];
 
-            for (let input of node.inputs) {
-                for (let argument of input.arguments) {
+            for (const input of node.inputs) {
+                for (const argument of input.arguments) {
                     if (argument.id && argument.id.toLowerCase().indexOf(text) != -1 && !edgeMatches.has(argument.id)) {
                         if (!argument.initializer) {
                             let inputItem = this._host.document.createElement('li');
@@ -1116,7 +1116,7 @@ sidebar.FindSidebar = class {
                 nodeMatches.add(node.name);
             }
 
-            for (let initializer of initializers) {
+            for (const initializer of initializers) {
                 let initializeItem = this._host.document.createElement('li');
                 initializeItem.innerText = '\u25A0 ' + initializer.name;
                 initializeItem.id = 'initializer-' + initializer.name;
@@ -1124,9 +1124,9 @@ sidebar.FindSidebar = class {
             }
         }
 
-        for (let node of this._graph.nodes) {
-            for (let output of node.outputs) {
-                for (let argument of output.arguments) {
+        for (const node of this._graph.nodes) {
+            for (const output of node.outputs) {
+                for (const argument of output.arguments) {
                     if (argument.id && argument.id.toLowerCase().indexOf(text) != -1 && !edgeMatches[argument.id]) {
                         let outputItem = this._host.document.createElement('li');
                         outputItem.innerText = '\u2192 ' + argument.id.split('\n').shift(); // custom argument id

+ 60 - 56
src/view.js

@@ -294,7 +294,7 @@ view.View = class {
             let graphRect = graphElement.getBoundingClientRect();
             let x = 0;
             let y = 0;
-            for (let element of selection) {
+            for (const element of selection) {
                 element.classList.add('select');
                 this._selection.push(element);
                 let box = element.getBBox();
@@ -446,7 +446,7 @@ view.View = class {
                 this._host.event('Graph', 'Render', 'Size', nodes.length);
 
                 if (groups) {
-                    for (let node of nodes) {
+                    for (const node of nodes) {
                         if (node.group) {
                             let path = node.group.split('/');
                             while (path.length > 0) {
@@ -459,7 +459,7 @@ view.View = class {
                 }
 
                 const self = this;
-                for (let node of nodes) {
+                for (const node of nodes) {
     
                     let element = new grapher.NodeElement(this._host.document);
 
@@ -486,7 +486,7 @@ view.View = class {
                         let initializers = [];
                         let hiddenInitializers = false;
                         if (self._showInitializers) {
-                            for (let input of node.inputs) {
+                            for (const input of node.inputs) {
                                 if (input.visible && input.arguments.length == 1 && input.arguments[0].initializer != null) {
                                     initializers.push(input);
                                 }
@@ -505,7 +505,7 @@ view.View = class {
                             block.handler = () => {
                                 self.showNodeProperties(node);
                             };
-                            for (let initializer of initializers) {
+                            for (const initializer of initializers) {
                                 const argument = initializer.arguments[0];
                                 const type = argument.type;
                                 let shape = '';
@@ -529,7 +529,7 @@ view.View = class {
                                 block.add(null, '\u3008' + '\u2026' + '\u3009', '', null, '');
                             }
 
-                            for (let attribute of attributes) {
+                            for (const attribute of attributes) {
                                 if (attribute.visible) {
                                     let attributeValue = sidebar.NodeSidebar.formatAttributeValue(attribute.value, attribute.type);
                                     if (attributeValue && attributeValue.length > 25) {
@@ -542,8 +542,8 @@ view.View = class {
 
                         if (edges) {
                             const inputs = node.inputs;
-                            for (let input of inputs) {
-                                for (let argument of input.arguments) {
+                            for (const input of inputs) {
+                                for (const argument of input.arguments) {
                                     if (argument.id != '' && !argument.initializer) {
                                         let tuple = edgeMap[argument.id];
                                         if (!tuple) {
@@ -564,8 +564,8 @@ view.View = class {
                                     outputs = chainOutputs;
                                 }
                             }
-                            for (let output of outputs) {
-                                for (let argument of output.arguments) {
+                            for (const output of outputs) {
+                                for (const argument of output.arguments) {
                                     if (argument.id != '') {
                                         let tuple = edgeMap[argument.id];
                                         if (!tuple) {
@@ -583,7 +583,7 @@ view.View = class {
                         }
     
                         if (node.chain && node.chain.length > 0) {
-                            for (let innerNode of node.chain) {
+                            for (const innerNode of node.chain) {
                                 addNode(element, innerNode, false);
                             }
                         }
@@ -596,7 +596,7 @@ view.View = class {
                     addNode(element, node, true);
 
                     if (node.controlDependencies && node.controlDependencies.length > 0) {
-                        for (let controlDependency of node.controlDependencies) {
+                        for (const controlDependency of node.controlDependencies) {
                             let tuple = edgeMap[controlDependency];
                             if (!tuple) {
                                 tuple = { from: null, to: [] };
@@ -656,8 +656,8 @@ view.View = class {
                     nodeId++;
                 }
 
-                for (let input of graph.inputs) {
-                    for (let argument of input.arguments) {
+                for (const input of graph.inputs) {
+                    for (const argument of input.arguments) {
                         let tuple = edgeMap[argument.id];
                         if (!tuple) {
                             tuple = { from: null, to: [] };
@@ -682,8 +682,8 @@ view.View = class {
                     g.setNode(nodeId++, { label: inputElement.format(graphElement), class: 'graph-input' } ); 
                 }
             
-                for (let output of graph.outputs) {
-                    for (let argument of output.arguments) {
+                for (const output of graph.outputs) {
+                    for (const argument of output.arguments) {
                         let tuple = edgeMap[argument.id];
                         if (!tuple) {
                             tuple = { from: null, to: [] };
@@ -705,10 +705,10 @@ view.View = class {
                     g.setNode(nodeId++, { label: outputElement.format(graphElement) } ); 
                 }
 
-                for (let edge of Object.keys(edgeMap)) {
+                for (const edge of Object.keys(edgeMap)) {
                     let tuple = edgeMap[edge];
                     if (tuple.from != null) {
-                        for (let to of tuple.to) {
+                        for (const to of tuple.to) {
                             let text = '';
                             let type = tuple.from.type;
                             if (type && type.shape && type.shape.dimensions && type.shape.dimensions.length > 0) {
@@ -800,7 +800,7 @@ view.View = class {
                                 let xs = [];
                                 let ys = [];
                                 for (let i = 0; i < inputElements.length; i++) {
-                                    let inputTransform = inputElements[i].transform.baseVal.consolidate().matrix;
+                                    const inputTransform = inputElements[i].transform.baseVal.consolidate().matrix;
                                     xs.push(inputTransform.e);
                                     ys.push(inputTransform.f);
                                 }
@@ -829,7 +829,7 @@ view.View = class {
     applyStyleSheet(element, name) {
         let rules = [];
         for (let i = 0; i < this._host.document.styleSheets.length; i++) {
-            let styleSheet = this._host.document.styleSheets[i];
+            const styleSheet = this._host.document.styleSheets[i];
             if (styleSheet && styleSheet.href && styleSheet.href.endsWith('/' + name)) {
                 rules = styleSheet.cssRules;
                 break;
@@ -837,12 +837,12 @@ view.View = class {
         }
         let nodes = element.getElementsByTagName('*');
         for (let j = 0; j < nodes.length; j++) {
-            let node = nodes[j];
+            const node = nodes[j];
             for (let k = 0; k < rules.length; k++) {
-                let rule = rules[k];
+                const rule = rules[k];
                 if (node.matches(rule.selectorText)) {
                     for (let l = 0; l < rule.style.length; l++) {
-                        let item = rule.style.item(l);
+                        const item = rule.style.item(l);
                         node.style[item] = rule.style[item];
                     }
                 }
@@ -851,11 +851,8 @@ view.View = class {
     }
 
     export(file) {
-        let extension = '';
-        let lastIndex = file.lastIndexOf('.');
-        if (lastIndex != -1) {
-            extension = file.substring(lastIndex + 1);
-        }
+        const lastIndex = file.lastIndexOf('.');
+        const extension = (lastIndex != -1) ? file.substring(lastIndex + 1) : '';
         if (this._activeGraph && (extension == 'png' || extension == 'svg')) {
             const graphElement = this._host.document.getElementById('graph');
             const exportElement = graphElement.cloneNode(true);
@@ -1001,6 +998,7 @@ class ModelContext {
     constructor(context) {
         this._context = context;
         this._tags = new Map();
+        this._entries = new Map();
     }
 
     request(file, encoding) {
@@ -1022,21 +1020,31 @@ class ModelContext {
         return this._text;
     }
 
-    get entries() {
-        if (!this._entries) {
-            this._entries = [];
-            let buffer = this.buffer;
-            if (buffer && buffer.length > 2 && buffer[0] == 0x50 && buffer[1] == 0x4B) {
-                try {
-                    let archive = new zip.Archive(buffer);
-                    this._entries = archive.entries;
-                }
-                catch (error) {
-                    this._entries = [];
+    entries(extension) {
+        let entries = this._entries.get(extension);
+        if (!entries) {
+            entries = [];
+            try {
+                const buffer = this.buffer;
+                switch (extension) {
+                    case 'zip': {
+                        if (buffer && buffer.length > 2 && buffer[0] == 0x50 && buffer[1] == 0x4B) {
+                            entries = new zip.Archive(buffer).entries;
+                        }
+                        break;
+                    }
+                    case 'tar': {
+                        entries = new tar.Archive(buffer).entries;
+                        break;
+                    }
                 }
             }
+            catch (error) {
+                entries = [];
+            }
+            this._entries.set(extension, entries);
         }
-        return this._entries;
+        return entries;
     }
 
     tags(extension) {
@@ -1044,10 +1052,9 @@ class ModelContext {
         if (!tags) {
             tags = new Map();
             try {
-                let reader = null;
                 switch (extension) {
                     case 'pbtxt': {
-                        let b = this.buffer;
+                        const b = this.buffer;
                         const length = b.length;
                         const signature = 
                             (length >= 3 && b[0] === 0xef && b[1] === 0xbb && b[2] === 0xbf) ||
@@ -1059,17 +1066,17 @@ class ModelContext {
                         if (!signature && b.subarray(0, Math.min(1024, length)).some((c) => c < 7 || (c > 14 && c < 32))) {
                             break;
                         }
-                        reader = prototxt.TextReader.create(this.text);
+                        const reader = prototxt.TextReader.create(this.text);
                         reader.start(false);
                         while (!reader.end(false)) {
-                            let tag = reader.tag();
+                            const tag = reader.tag();
                             tags.set(tag, true);
                             reader.skip();
                         }
                         break;
                     }
                     case 'pb': {
-                        reader = new protobuf.Reader.create(this.buffer);
+                        const reader = new protobuf.Reader.create(this.buffer);
                         while (reader.pos < reader.len) {
                             const tagType = reader.uint32();
                             tags.set(tagType >>> 3, tagType & 7);
@@ -1099,7 +1106,7 @@ class ArchiveContext {
     constructor(entries, rootFolder, identifier, buffer) {
         this._entries = {};
         if (entries) {
-            for (let entry of entries) {
+            for (const entry of entries) {
                 if (entry.name.startsWith(rootFolder)) {
                     let name = entry.name.substring(rootFolder.length);
                     if (identifier.length > 0 && identifier.indexOf('/') < 0) {
@@ -1113,14 +1120,11 @@ class ArchiveContext {
     }
 
     request(file, encoding) {
-        let entry = this._entries[file];
+        const entry = this._entries[file];
         if (!entry) {
             return Promise.reject(new Error('File not found.'));
         }
-        let data = entry.data;
-        if (encoding != null) {
-            data = new TextDecoder(encoding).decode(data);
-        }
+        const data = encoding ? new TextDecoder(encoding).decode(entry.data) : entry.data;
         return Promise.resolve(data);
     }
 
@@ -1172,7 +1176,7 @@ view.ModelFactoryService = class {
     }
 
     register(id, extensions) {
-        for (let extension of extensions) {
+        for (const extension of extensions) {
             this._extensions.push({ extension: extension, id: id });
         }
     }
@@ -1195,7 +1199,7 @@ view.ModelFactoryService = class {
                         if (!module.ModelFactory) {
                             throw new ModelError("Failed to load module '" + id + "'.");
                         }
-                        let modelFactory = new module.ModelFactory(); 
+                        const modelFactory = new module.ModelFactory(); 
                         if (!modelFactory.match(context)) {
                             return nextModule();
                         }
@@ -1303,7 +1307,7 @@ view.ModelFactoryService = class {
 
         try {
             let folders = {};
-            for (let entry of archive.entries) {
+            for (const entry of archive.entries) {
                 if (entry.name.indexOf('/') != -1) {
                     folders[entry.name.split('/').shift() + '/'] = true;
                 }
@@ -1379,7 +1383,7 @@ view.ModelFactoryService = class {
 
     accept(identifier) {
         identifier = identifier.toLowerCase();
-        for (let extension of this._extensions) {
+        for (const extension of this._extensions) {
             if (identifier.endsWith(extension.extension)) {
                 return true;
             }
@@ -1397,7 +1401,7 @@ view.ModelFactoryService = class {
         let moduleList = [];
         let moduleMap = {};
         const identifier = context.identifier.toLowerCase();
-        for (let extension of this._extensions) {
+        for (const extension of this._extensions) {
             if (identifier.endsWith(extension.extension)) {
                 if (!moduleMap[extension.id]) {
                     moduleList.push(extension.id);

+ 3 - 3
src/zip.js

@@ -67,7 +67,7 @@ zip.Entry = class {
         extraDataLength = reader.uint16();
         let nameBuffer = reader.bytes(nameLength);
         this._name = '';
-        for (let c of nameBuffer) {
+        for (const c of nameBuffer) {
             this._name += String.fromCharCode(c);
         }
         reader.skip(extraDataLength);
@@ -342,12 +342,12 @@ zip.Ouptut = class {
 
     merge() {
         let size = 0;
-        for (let block1 of this._blocks) {
+        for (const block1 of this._blocks) {
             size += block1.length;
         }
         let output = new Uint8Array(size);
         let offset = 0;
-        for (let block2 of this._blocks) {
+        for (const block2 of this._blocks) {
             output.set(block2, offset);
             offset += block2.length;
         }

+ 15 - 15
test/test.js

@@ -113,7 +113,7 @@ class TestHost {
 
     _raise(event, data) {
         if (this._events && this._events[event]) {
-            for (let callback of this._events[event]) {
+            for (const callback of this._events[event]) {
                 callback(this, data);
             }
         }
@@ -362,7 +362,7 @@ function download(folder, targets, sources) {
             sources = '';
         }
     }
-    for (let target of targets) {
+    for (const target of targets) {
         makeDir(path.dirname(folder + '/' + target));
     }
     return downloadFile(source).then((data) => {
@@ -372,7 +372,7 @@ function download(folder, targets, sources) {
             }
             process.stdout.write('  decompress...\r');
             const archive = decompress(data, source.split('?').shift().split('/').pop());
-            for (let file of sourceFiles) {
+            for (const file of sourceFiles) {
                 if (process.stdout.clearLine) {
                     process.stdout.clearLine();
                 }
@@ -458,11 +458,11 @@ function loadModel(target, item) {
         model.description;
         model.author;
         model.license;
-        for (let graph of model.graphs) {
-            for (let input of graph.inputs) {
+        for (const graph of model.graphs) {
+            for (const input of graph.inputs) {
                 input.name.toString();
                 input.name.length;
-                for (let argument of input.arguments) {
+                for (const argument of input.arguments) {
                     argument.id.toString();
                     argument.id.length;
                     if (argument.type) {
@@ -470,10 +470,10 @@ function loadModel(target, item) {
                     }
                 }
             }
-            for (let output of graph.outputs) {
+            for (const output of graph.outputs) {
                 output.name.toString();
                 output.name.length;
-                for (let argument of output.arguments) {
+                for (const argument of output.arguments) {
                     argument.id.toString();
                     argument.id.length;
                     if (argument.type) {
@@ -481,13 +481,13 @@ function loadModel(target, item) {
                     }
                 }
             }
-            for (let node of graph.nodes) {
+            for (const node of graph.nodes) {
                 node.name.toString();
                 node.name.length;
                 node.description;
                 node.documentation.toString();
                 node.category.toString();
-                for (let attribute of node.attributes) {
+                for (const attribute of node.attributes) {
                     attribute.name.toString();
                     attribute.name.length;
                     let value = sidebar.NodeSidebar.formatAttributeValue(attribute.value, attribute.type)
@@ -496,10 +496,10 @@ function loadModel(target, item) {
                     }
                     value = value.split('<');
                 }
-                for (let input of node.inputs) {
+                for (const input of node.inputs) {
                     input.name.toString();
                     input.name.length;
-                    for (let argument of input.arguments) {
+                    for (const argument of input.arguments) {
                         argument.id.toString();
                         argument.id.length;
                         argument.description;
@@ -512,10 +512,10 @@ function loadModel(target, item) {
                         }
                     }
                 }
-                for (let output of node.outputs) {
+                for (const output of node.outputs) {
                     output.name.toString();
                     output.name.length;
-                    for (let argument of output.arguments) {
+                    for (const argument of output.arguments) {
                         argument.id.toString();
                         argument.id.length;
                         if (argument.type) {
@@ -524,7 +524,7 @@ function loadModel(target, item) {
                     }
                 }
                 if (node.chain) {
-                    for (let chain of node.chain) {
+                    for (const chain of node.chain) {
                         chain.name.toString();
                         chain.name.length;
                     }