Parcourir la source

Add no-negated-condition lint rule

Lutz Roeder il y a 1 an
Parent
commit
fdcb17e813
55 fichiers modifiés avec 803 ajouts et 805 suppressions
  1. 1 1
      publish/eslint.config.js
  2. 1 1
      source/acuity.js
  3. 1 1
      source/app.js
  4. 6 6
      source/base.js
  5. 10 10
      source/bigdl-proto.js
  6. 2 2
      source/browser.js
  7. 63 63
      source/caffe-proto.js
  8. 3 3
      source/caffe.js
  9. 22 22
      source/caffe2-proto.js
  10. 0 2
      source/caffe2.js
  11. 10 10
      source/cntk-proto.js
  12. 3 3
      source/cntk.js
  13. 112 112
      source/coreml-proto.js
  14. 7 7
      source/coreml.js
  15. 22 24
      source/dagre.js
  16. 2 2
      source/darknet.js
  17. 7 7
      source/dnn-proto.js
  18. 10 10
      source/electron.mjs
  19. 4 4
      source/flatbuffers.js
  20. 11 11
      source/hdf5.js
  21. 1 1
      source/keras-metadata.json
  22. 3 3
      source/keras-proto.js
  23. 4 4
      source/keras.js
  24. 1 1
      source/kmodel.js
  25. 3 3
      source/mediapipe.js
  26. 12 12
      source/megengine.js
  27. 1 1
      source/mlnet.js
  28. 4 3
      source/mslite.js
  29. 4 2
      source/ncnn.js
  30. 112 112
      source/nnabla-proto.js
  31. 13 13
      source/om-proto.js
  32. 3 3
      source/om.js
  33. 24 24
      source/onnx-proto.js
  34. 20 19
      source/onnx.js
  35. 3 3
      source/openvino.js
  36. 22 22
      source/paddle-proto.js
  37. 3 3
      source/paddle.js
  38. 6 6
      source/protobuf.js
  39. 20 20
      source/python.js
  40. 10 10
      source/pytorch.js
  41. 6 6
      source/sentencepiece-proto.js
  42. 1 1
      source/sklearn.js
  43. 3 3
      source/tar.js
  44. 112 112
      source/tf-proto.js
  45. 9 11
      source/tf.js
  46. 2 2
      source/torch.js
  47. 18 18
      source/uff-proto.js
  48. 14 14
      source/view.js
  49. 5 5
      source/xml.js
  50. 31 31
      source/xmodel-proto.js
  51. 7 7
      source/zip.js
  52. 1 1
      test/models.js
  53. 11 11
      test/worker.js
  54. 9 9
      tools/flatc.js
  55. 8 8
      tools/protoc.js

+ 1 - 1
publish/eslint.config.js

@@ -121,7 +121,7 @@ export default [
             'no-multi-assign': 'error',
             'no-multi-str': 'error',
             'no-multiple-empty-lines': ['error', { 'max': 1 }],
-            // 'no-negated-condition': 'error',
+            'no-negated-condition': 'error',
             'no-nested-ternary': 'error',
             'no-new': 'error',
             'no-new-func': 'error',

+ 1 - 1
source/acuity.js

@@ -289,7 +289,7 @@ acuity.Inference = class {
             const [input] = inputs;
             const [a, b] = input;
             let batch = a;
-            const output = params.num_proj !== null ? params.num_proj : params.weights;
+            const output = params.num_proj === null ? params.weights : params.num_proj;
             if (params.time_major) {
                 batch = b;
             }

+ 1 - 1
source/app.js

@@ -777,7 +777,7 @@ app.View = class {
                     if (value) {
                         this._path = value;
                         const location = app.Application.location(this._path);
-                        const title = process.platform !== 'darwin' ? `${location.label} - ${electron.app.name}` : location.label;
+                        const title = process.platform === 'darwin' ? location.label : `${location.label} - ${electron.app.name}`;
                         this._window.setTitle(title);
                         this._window.focus();
                     }

+ 6 - 6
source/base.js

@@ -302,7 +302,7 @@ base.BinaryStream = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         const end = this._position;
         this.seek(position);
         return this._buffer.subarray(position, end);
@@ -314,7 +314,7 @@ base.BinaryStream = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         return this._buffer.subarray(position, this._position);
     }
 };
@@ -373,7 +373,7 @@ base.BufferReader = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         const end = this._position;
         this._position = position;
         return this._buffer.slice(position, end);
@@ -385,7 +385,7 @@ base.BufferReader = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         return this._buffer.slice(position, this._position);
     }
 
@@ -459,7 +459,7 @@ base.BufferReader = class {
     }
 
     boolean() {
-        return this.byte() !== 0 ? true : false;
+        return this.byte() === 0 ? false : true;
     }
 };
 
@@ -566,7 +566,7 @@ base.StreamReader = class {
     }
 
     boolean() {
-        return this.byte() !== 0 ? true : false;
+        return this.byte() === 0 ? false : true;
     }
 };
 

+ 10 - 10
source/bigdl-proto.js

@@ -25,7 +25,7 @@ com.intel.analytics.bigdl.serialization.BigDLModule = class BigDLModule {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.BigDLModule();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -172,7 +172,7 @@ com.intel.analytics.bigdl.serialization.InitMethod = class InitMethod {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.InitMethod();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -202,7 +202,7 @@ com.intel.analytics.bigdl.serialization.BigDLTensor = class BigDLTensor {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.BigDLTensor();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -268,7 +268,7 @@ com.intel.analytics.bigdl.serialization.TensorStorage = class TensorStorage {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.TensorStorage();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -319,7 +319,7 @@ com.intel.analytics.bigdl.serialization.Regularizer = class Regularizer {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.Regularizer();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -371,7 +371,7 @@ com.intel.analytics.bigdl.serialization.AttrValue = class AttrValue {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.AttrValue();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -463,7 +463,7 @@ com.intel.analytics.bigdl.serialization.AttrValue.ArrayValue = class ArrayValue
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.AttrValue.ArrayValue();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -538,7 +538,7 @@ com.intel.analytics.bigdl.serialization.NameAttrList = class NameAttrList {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.NameAttrList();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -568,7 +568,7 @@ com.intel.analytics.bigdl.serialization.Shape = class Shape {
 
     static decode(reader, length) {
         const message = new com.intel.analytics.bigdl.serialization.Shape();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -607,7 +607,7 @@ google.protobuf.Any = class Any {
 
     static decode(reader, length) {
         const message = new google.protobuf.Any();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 2 - 2
source/browser.js

@@ -698,7 +698,7 @@ host.BrowserHost.FileStream = class {
     }
 
     peek(length) {
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         if (length < 0x10000000) {
             const position = this._fill(length);
             this._position -= length;
@@ -718,7 +718,7 @@ host.BrowserHost.FileStream = class {
     }
 
     read(length) {
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         if (length < 0x10000000) {
             const position = this._fill(length);
             return this._buffer.subarray(position, position + length);

+ 63 - 63
source/caffe-proto.js

@@ -9,7 +9,7 @@ caffe.BlobShape = class BlobShape {
 
     static decode(reader, length) {
         const message = new caffe.BlobShape();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -53,7 +53,7 @@ caffe.BlobProto = class BlobProto {
 
     static decode(reader, length) {
         const message = new caffe.BlobProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -148,7 +148,7 @@ caffe.BlobProtoVector = class BlobProtoVector {
 
     static decode(reader, length) {
         const message = new caffe.BlobProtoVector();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -189,7 +189,7 @@ caffe.Datum = class Datum {
 
     static decode(reader, length) {
         const message = new caffe.Datum();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -269,7 +269,7 @@ caffe.FillerParameter = class FillerParameter {
 
     static decode(reader, length) {
         const message = new caffe.FillerParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -371,7 +371,7 @@ caffe.NetParameter = class NetParameter {
 
     static decode(reader, length) {
         const message = new caffe.NetParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -470,7 +470,7 @@ caffe.SolverParameter = class SolverParameter {
 
     static decode(reader, length) {
         const message = new caffe.SolverParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -813,7 +813,7 @@ caffe.SolverState = class SolverState {
 
     static decode(reader, length) {
         const message = new caffe.SolverState();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -881,7 +881,7 @@ caffe.NetState = class NetState {
 
     static decode(reader, length) {
         const message = new caffe.NetState();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -938,7 +938,7 @@ caffe.NetStateRule = class NetStateRule {
 
     static decode(reader, length) {
         const message = new caffe.NetStateRule();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1003,7 +1003,7 @@ caffe.ParamSpec = class ParamSpec {
 
     static decode(reader, length) {
         const message = new caffe.ParamSpec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1079,7 +1079,7 @@ caffe.LayerParameter = class LayerParameter {
 
     static decode(reader, length) {
         const message = new caffe.LayerParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1527,7 +1527,7 @@ caffe.TransformationParameter = class TransformationParameter {
 
     static decode(reader, length) {
         const message = new caffe.TransformationParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1607,7 +1607,7 @@ caffe.LossParameter = class LossParameter {
 
     static decode(reader, length) {
         const message = new caffe.LossParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1667,7 +1667,7 @@ caffe.AccuracyParameter = class AccuracyParameter {
 
     static decode(reader, length) {
         const message = new caffe.AccuracyParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1720,7 +1720,7 @@ caffe.ArgMaxParameter = class ArgMaxParameter {
 
     static decode(reader, length) {
         const message = new caffe.ArgMaxParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1773,7 +1773,7 @@ caffe.ClipParameter = class ClipParameter {
 
     static decode(reader, length) {
         const message = new caffe.ClipParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1819,7 +1819,7 @@ caffe.ConcatParameter = class ConcatParameter {
 
     static decode(reader, length) {
         const message = new caffe.ConcatParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1865,7 +1865,7 @@ caffe.BatchNormParameter = class BatchNormParameter {
 
     static decode(reader, length) {
         const message = new caffe.BatchNormParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1918,7 +1918,7 @@ caffe.BiasParameter = class BiasParameter {
 
     static decode(reader, length) {
         const message = new caffe.BiasParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1971,7 +1971,7 @@ caffe.ContrastiveLossParameter = class ContrastiveLossParameter {
 
     static decode(reader, length) {
         const message = new caffe.ContrastiveLossParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2024,7 +2024,7 @@ caffe.ConvolutionParameter = class ConvolutionParameter {
 
     static decode(reader, length) {
         const message = new caffe.ConvolutionParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2188,7 +2188,7 @@ caffe.CropParameter = class CropParameter {
 
     static decode(reader, length) {
         const message = new caffe.CropParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2233,7 +2233,7 @@ caffe.DataParameter = class DataParameter {
 
     static decode(reader, length) {
         const message = new caffe.DataParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2340,7 +2340,7 @@ caffe.DropoutParameter = class DropoutParameter {
 
     static decode(reader, length) {
         const message = new caffe.DropoutParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2388,7 +2388,7 @@ caffe.DummyDataParameter = class DummyDataParameter {
 
     static decode(reader, length) {
         const message = new caffe.DummyDataParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2459,7 +2459,7 @@ caffe.EltwiseParameter = class EltwiseParameter {
 
     static decode(reader, length) {
         const message = new caffe.EltwiseParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2517,7 +2517,7 @@ caffe.ELUParameter = class ELUParameter {
 
     static decode(reader, length) {
         const message = new caffe.ELUParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2556,7 +2556,7 @@ caffe.EmbedParameter = class EmbedParameter {
 
     static decode(reader, length) {
         const message = new caffe.EmbedParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2623,7 +2623,7 @@ caffe.ExpParameter = class ExpParameter {
 
     static decode(reader, length) {
         const message = new caffe.ExpParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2676,7 +2676,7 @@ caffe.FlattenParameter = class FlattenParameter {
 
     static decode(reader, length) {
         const message = new caffe.FlattenParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2722,7 +2722,7 @@ caffe.HDF5DataParameter = class HDF5DataParameter {
 
     static decode(reader, length) {
         const message = new caffe.HDF5DataParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2775,7 +2775,7 @@ caffe.HDF5OutputParameter = class HDF5OutputParameter {
 
     static decode(reader, length) {
         const message = new caffe.HDF5OutputParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2814,7 +2814,7 @@ caffe.HingeLossParameter = class HingeLossParameter {
 
     static decode(reader, length) {
         const message = new caffe.HingeLossParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2858,7 +2858,7 @@ caffe.ImageDataParameter = class ImageDataParameter {
 
     static decode(reader, length) {
         const message = new caffe.ImageDataParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -2974,7 +2974,7 @@ caffe.InfogainLossParameter = class InfogainLossParameter {
 
     static decode(reader, length) {
         const message = new caffe.InfogainLossParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3020,7 +3020,7 @@ caffe.InnerProductParameter = class InnerProductParameter {
 
     static decode(reader, length) {
         const message = new caffe.InnerProductParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3098,7 +3098,7 @@ caffe.InputParameter = class InputParameter {
 
     static decode(reader, length) {
         const message = new caffe.InputParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3135,7 +3135,7 @@ caffe.LogParameter = class LogParameter {
 
     static decode(reader, length) {
         const message = new caffe.LogParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3188,7 +3188,7 @@ caffe.LRNParameter = class LRNParameter {
 
     static decode(reader, length) {
         const message = new caffe.LRNParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3273,7 +3273,7 @@ caffe.MemoryDataParameter = class MemoryDataParameter {
 
     static decode(reader, length) {
         const message = new caffe.MemoryDataParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3333,7 +3333,7 @@ caffe.MVNParameter = class MVNParameter {
 
     static decode(reader, length) {
         const message = new caffe.MVNParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3386,7 +3386,7 @@ caffe.ParameterParameter = class ParameterParameter {
 
     static decode(reader, length) {
         const message = new caffe.ParameterParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3425,7 +3425,7 @@ caffe.PoolingParameter = class PoolingParameter {
 
     static decode(reader, length) {
         const message = new caffe.PoolingParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3565,7 +3565,7 @@ caffe.PowerParameter = class PowerParameter {
 
     static decode(reader, length) {
         const message = new caffe.PowerParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3618,7 +3618,7 @@ caffe.PythonParameter = class PythonParameter {
 
     static decode(reader, length) {
         const message = new caffe.PythonParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3678,7 +3678,7 @@ caffe.RecurrentParameter = class RecurrentParameter {
 
     static decode(reader, length) {
         const message = new caffe.RecurrentParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3745,7 +3745,7 @@ caffe.ReductionParameter = class ReductionParameter {
 
     static decode(reader, length) {
         const message = new caffe.ReductionParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3805,7 +3805,7 @@ caffe.ReLUParameter = class ReLUParameter {
 
     static decode(reader, length) {
         const message = new caffe.ReLUParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3857,7 +3857,7 @@ caffe.ReshapeParameter = class ReshapeParameter {
 
     static decode(reader, length) {
         const message = new caffe.ReshapeParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3910,7 +3910,7 @@ caffe.ScaleParameter = class ScaleParameter {
 
     static decode(reader, length) {
         const message = new caffe.ScaleParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -3977,7 +3977,7 @@ caffe.SigmoidParameter = class SigmoidParameter {
 
     static decode(reader, length) {
         const message = new caffe.SigmoidParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4026,7 +4026,7 @@ caffe.SliceParameter = class SliceParameter {
 
     static decode(reader, length) {
         const message = new caffe.SliceParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4078,7 +4078,7 @@ caffe.SoftmaxParameter = class SoftmaxParameter {
 
     static decode(reader, length) {
         const message = new caffe.SoftmaxParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4130,7 +4130,7 @@ caffe.SwishParameter = class SwishParameter {
 
     static decode(reader, length) {
         const message = new caffe.SwishParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4169,7 +4169,7 @@ caffe.TanHParameter = class TanHParameter {
 
     static decode(reader, length) {
         const message = new caffe.TanHParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4214,7 +4214,7 @@ caffe.TileParameter = class TileParameter {
 
     static decode(reader, length) {
         const message = new caffe.TileParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4260,7 +4260,7 @@ caffe.ThresholdParameter = class ThresholdParameter {
 
     static decode(reader, length) {
         const message = new caffe.ThresholdParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4299,7 +4299,7 @@ caffe.WindowDataParameter = class WindowDataParameter {
 
     static decode(reader, length) {
         const message = new caffe.WindowDataParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4422,7 +4422,7 @@ caffe.SPPParameter = class SPPParameter {
 
     static decode(reader, length) {
         const message = new caffe.SPPParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4500,7 +4500,7 @@ caffe.V1LayerParameter = class V1LayerParameter {
 
     static decode(reader, length) {
         const message = new caffe.V1LayerParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -4877,7 +4877,7 @@ caffe.V0LayerParameter = class V0LayerParameter {
 
     static decode(reader, length) {
         const message = new caffe.V0LayerParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -5178,7 +5178,7 @@ caffe.PReLUParameter = class PReLUParameter {
 
     static decode(reader, length) {
         const message = new caffe.PReLUParameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 3 - 3
source/caffe.js

@@ -134,13 +134,13 @@ caffe.ModelFactory = class {
         while (!reader.end()) {
             const tag = reader.tag();
             const value = reader.read();
-            if (!message[tag]) {
-                message[tag] = value;
-            } else {
+            if (message[tag]) {
                 if (!Array.isArray(message[tag])) {
                     message[tag] = [message[tag]];
                 }
                 message[tag].push(value);
+            } else {
+                message[tag] = value;
             }
         }
         return message;

+ 22 - 22
source/caffe2-proto.js

@@ -14,7 +14,7 @@ caffe2.TensorProto = class TensorProto {
 
     static decode(reader, length) {
         const message = new caffe2.TensorProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -154,7 +154,7 @@ caffe2.TensorProto.Segment = class Segment {
 
     static decode(reader, length) {
         const message = new caffe2.TensorProto.Segment();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -219,7 +219,7 @@ caffe2.QTensorProto = class QTensorProto {
 
     static decode(reader, length) {
         const message = new caffe2.QTensorProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -359,7 +359,7 @@ caffe2.TensorProtos = class TensorProtos {
 
     static decode(reader, length) {
         const message = new caffe2.TensorProtos();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -401,7 +401,7 @@ caffe2.TensorShape = class TensorShape {
 
     static decode(reader, length) {
         const message = new caffe2.TensorShape();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -470,7 +470,7 @@ caffe2.TensorShapes = class TensorShapes {
 
     static decode(reader, length) {
         const message = new caffe2.TensorShapes();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -511,7 +511,7 @@ caffe2.TensorBoundShape = class TensorBoundShape {
 
     static decode(reader, length) {
         const message = new caffe2.TensorBoundShape();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -584,7 +584,7 @@ caffe2.TensorBoundShapes = class TensorBoundShapes {
 
     static decode(reader, length) {
         const message = new caffe2.TensorBoundShapes();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -636,7 +636,7 @@ caffe2.AOTConfig = class AOTConfig {
 
     static decode(reader, length) {
         const message = new caffe2.AOTConfig();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -730,7 +730,7 @@ caffe2.Argument = class Argument {
 
     static decode(reader, length) {
         const message = new caffe2.Argument();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -859,7 +859,7 @@ caffe2.DeviceOption = class DeviceOption {
 
     static decode(reader, length) {
         const message = new caffe2.DeviceOption();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -939,7 +939,7 @@ caffe2.OperatorDef = class OperatorDef {
 
     static decode(reader, length) {
         const message = new caffe2.OperatorDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1051,7 +1051,7 @@ caffe2.MapFieldEntry = class MapFieldEntry {
 
     static decode(reader, length) {
         const message = new caffe2.MapFieldEntry();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1113,7 +1113,7 @@ caffe2.BackendOptions = class BackendOptions {
 
     static decode(reader, length) {
         const message = new caffe2.BackendOptions();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1169,7 +1169,7 @@ caffe2.PartitionInfo = class PartitionInfo {
 
     static decode(reader, length) {
         const message = new caffe2.PartitionInfo();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1241,7 +1241,7 @@ caffe2.NetDef = class NetDef {
 
     static decode(reader, length) {
         const message = new caffe2.NetDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1336,7 +1336,7 @@ caffe2.ExecutionStep = class ExecutionStep {
 
     static decode(reader, length) {
         const message = new caffe2.ExecutionStep();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1462,7 +1462,7 @@ caffe2.PlanDef = class PlanDef {
 
     static decode(reader, length) {
         const message = new caffe2.PlanDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1513,7 +1513,7 @@ caffe2.BlobProto = class BlobProto {
 
     static decode(reader, length) {
         const message = new caffe2.BlobProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1594,7 +1594,7 @@ caffe2.DBReaderProto = class DBReaderProto {
 
     static decode(reader, length) {
         const message = new caffe2.DBReaderProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1654,7 +1654,7 @@ caffe2.BlobSerializationOptions = class BlobSerializationOptions {
 
     static decode(reader, length) {
         const message = new caffe2.BlobSerializationOptions();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1717,7 +1717,7 @@ caffe2.SerializationOptions = class SerializationOptions {
 
     static decode(reader, length) {
         const message = new caffe2.SerializationOptions();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 0 - 2
source/caffe2.js

@@ -411,8 +411,6 @@ caffe2.Attribute = class {
         } else if (arg.n) {
             this.value = new caffe2.Graph(metadata, arg.n, null);
             this.type = 'graph';
-        } else if (arg.i !== 0) {
-            this.value = arg.i;
         } else {
             this.value = arg.i;
         }

+ 10 - 10
source/cntk-proto.js

@@ -11,7 +11,7 @@ CNTK.proto.NDShape = class NDShape {
 
     static decode(reader, length) {
         const message = new CNTK.proto.NDShape();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -31,7 +31,7 @@ CNTK.proto.Axis = class Axis {
 
     static decode(reader, length) {
         const message = new CNTK.proto.Axis();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -66,7 +66,7 @@ CNTK.proto.NDArrayView = class NDArrayView {
 
     static decode(reader, length) {
         const message = new CNTK.proto.NDArrayView();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -127,7 +127,7 @@ CNTK.proto.NDArrayView.FloatValues = class FloatValues {
 
     static decode(reader, length) {
         const message = new CNTK.proto.NDArrayView.FloatValues();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -151,7 +151,7 @@ CNTK.proto.NDArrayView.DoubleValues = class DoubleValues {
 
     static decode(reader, length) {
         const message = new CNTK.proto.NDArrayView.DoubleValues();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -171,7 +171,7 @@ CNTK.proto.NDArrayView.BytesValue = class BytesValue {
 
     static decode(reader, length) {
         const message = new CNTK.proto.NDArrayView.BytesValue();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -197,7 +197,7 @@ CNTK.proto.NDArrayView.IntValues = class IntValues {
 
     static decode(reader, length) {
         const message = new CNTK.proto.NDArrayView.IntValues();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -221,7 +221,7 @@ CNTK.proto.Vector = class Vector {
 
     static decode(reader, length) {
         const message = new CNTK.proto.Vector();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -245,7 +245,7 @@ CNTK.proto.Dictionary = class Dictionary {
 
     static decode(reader, length) {
         const message = new CNTK.proto.Dictionary();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -275,7 +275,7 @@ CNTK.proto.DictionaryValue = class DictionaryValue {
 
     static decode(reader, length) {
         const message = new CNTK.proto.DictionaryValue();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 3 - 3
source/cntk.js

@@ -753,10 +753,10 @@ cntk.ComputationNetwork = class {
                 this.blendTimeConstant = reader.float64();
                 this.imageLayoutKind = reader.int32();
                 if (version >= 13) {
-                    if (version !== 19) {
-                        this.runCountUntied = reader.uint64().toNumber();
-                    } else {
+                    if (version === 19) {
                         this.runCountUntied = reader.boolean() ? 0 : 'SIZE_MAX';
+                    } else {
+                        this.runCountUntied = reader.uint64().toNumber();
                     }
                 } else {
                     mbCount = reader.uint64().toNumber();

Fichier diff supprimé car celui-ci est trop grand
+ 112 - 112
source/coreml-proto.js


+ 7 - 7
source/coreml.js

@@ -552,17 +552,17 @@ coreml.Context = class {
     }
 
     output(name) {
-        if (!this.values.has(name)) {
-            const value = { counter: 0, name, to: [], from: [] };
-            this.values.set(name, value);
-            const key = `${name}|${value.counter}`;
-            this.values.set(key, value);
-        } else {
+        if (this.values.has(name)) {
             const value = Object.assign({}, this.values.get(name));
             value.counter++;
             value.name = `${name}|${value.counter}`; // custom argument id
             this.values.set(name, value);
             this.values.set(value.name, value);
+        } else {
+            const value = { counter: 0, name, to: [], from: [] };
+            this.values.set(name, value);
+            const key = `${name}|${value.counter}`;
+            this.values.set(key, value);
         }
         return this.values.get(name);
     }
@@ -642,7 +642,7 @@ coreml.Context = class {
                     const weightsShape = [data.outputChannels, data.kernelChannels, data.kernelSize[0], data.kernelSize[1]];
                     if (data.isDeconvolution) {
                         weightsShape[0] = data.kernelChannels;
-                        weightsShape[1] = Math.floor(Number(data.outputChannels / (data.nGroups !== 0 ? data.nGroups : 1)));
+                        weightsShape[1] = Math.floor(Number(data.outputChannels / (data.nGroups === 0 ? 1 : data.nGroups)));
                     }
                     initializer(type, 'weights', weightsShape, data.weights);
                     if (data.hasBias) {

+ 22 - 24
source/dagre.js

@@ -160,22 +160,20 @@ dagre.layout = (graph, layout) => {
             const stack = Array.from(g.nodes.keys()).reverse();
             while (stack.length > 0) {
                 const v = stack.pop();
-                if (!Array.isArray(v)) {
-                    if (!visited.has(v)) {
-                        visited.add(v);
-                        path.add(v);
-                        stack.push([v]);
-                        const out = g.node(v).out;
-                        for (let i = out.length - 1; i >= 0; i--) {
-                            const e = out[i];
-                            if (path.has(e.w)) {
-                                edges.push(e);
-                            }
-                            stack.push(e.w);
+                if (Array.isArray(v)) {
+                    path.delete(v[0]);
+                } else if (!visited.has(v)) {
+                    visited.add(v);
+                    path.add(v);
+                    stack.push([v]);
+                    const out = g.node(v).out;
+                    for (let i = out.length - 1; i >= 0; i--) {
+                        const e = out[i];
+                        if (path.has(e.w)) {
+                            edges.push(e);
                         }
+                        stack.push(e.w);
                     }
-                } else {
-                    path.delete(v[0]);
                 }
             }
             for (const e of edges) {
@@ -657,7 +655,7 @@ dagre.layout = (graph, layout) => {
                     const childTop = childNode.borderTop ? childNode.borderTop : child;
                     const childBottom = childNode.borderBottom ? childNode.borderBottom : child;
                     const thisWeight = childNode.borderTop ? weight : 2 * weight;
-                    const minlen = childTop !== childBottom ? 1 : height - depths[v] + 1;
+                    const minlen = childTop === childBottom ? height - depths[v] + 1 : 1;
                     g.setEdge(top, childTop, { weight: thisWeight, minlen, nestingEdge: true });
                     g.setEdge(childBottom, bottom, { weight: thisWeight, minlen, nestingEdge: true });
                 }
@@ -1041,7 +1039,7 @@ dagre.layout = (graph, layout) => {
                             } else if (entryV.barycenter > entryW.barycenter) {
                                 return 1;
                             }
-                            return !bias ? entryV.i - entryW.i : entryW.i - entryV.i;
+                            return bias ? entryW.i - entryV.i : entryV.i - entryW.i;
                         };
                     };
                     // partition
@@ -1086,12 +1084,12 @@ dagre.layout = (graph, layout) => {
                         const result = sortSubgraph(g, entry.v, cg, biasRight);
                         subgraphs[entry.v] = result;
                         if ('barycenter' in result) {
-                            if (entry.barycenter !== undefined) {
-                                entry.barycenter = (entry.barycenter * entry.weight + result.barycenter * result.weight) / (entry.weight + result.weight);
-                                entry.weight += result.weight;
-                            } else {
+                            if (entry.barycenter === undefined) {
                                 entry.barycenter = result.barycenter;
                                 entry.weight = result.weight;
+                            } else {
+                                entry.barycenter = (entry.barycenter * entry.weight + result.barycenter * result.weight) / (entry.weight + result.weight);
+                                entry.weight += result.weight;
                             }
                         }
                     }
@@ -1939,13 +1937,13 @@ dagre.layout = (graph, layout) => {
                 const wNode = e.wNode.label;
                 let p1 = null;
                 let p2 = null;
-                if (!edge.points) {
+                if (edge.points) {
+                    [p1] = edge.points;
+                    p2 = edge.points[edge.points.length - 1];
+                } else {
                     edge.points = [];
                     p1 = wNode;
                     p2 = vNode;
-                } else {
-                    [p1] = edge.points;
-                    p2 = edge.points[edge.points.length - 1];
                 }
                 edge.points.unshift(intersectRect(vNode, p1));
                 edge.points.push(intersectRect(wNode, p2));

+ 2 - 2
source/darknet.js

@@ -107,7 +107,7 @@ darknet.Graph = class {
         };
         const option_find_str = (options, key, defaultValue) => {
             const value = options[key];
-            return value !== undefined ? value : defaultValue;
+            return value === undefined ? defaultValue : value;
         };
         const make_shape = (dimensions, source) => {
             if (dimensions.some((dimension) => dimension === 0 || dimension === undefined || isNaN(dimension))) {
@@ -813,7 +813,7 @@ darknet.Node = class {
 
     constructor(metadata, net, section) {
         this._name = section.name || '';
-        this._location = section.line !== undefined ? section.line.toString() : undefined;
+        this._location = section.line === undefined ? undefined : section.line.toString();
         this._attributes = [];
         this._inputs = [];
         this._outputs = [];

+ 7 - 7
source/dnn-proto.js

@@ -13,7 +13,7 @@ dnn.Model = class Model {
 
     static decode(reader, length) {
         const message = new dnn.Model();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -58,7 +58,7 @@ dnn.Parameter = class Parameter {
 
     static decode(reader, length) {
         const message = new dnn.Parameter();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -84,7 +84,7 @@ dnn.Shape = class Shape {
 
     static decode(reader, length) {
         const message = new dnn.Shape();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -123,7 +123,7 @@ dnn.Node = class Node {
 
     static decode(reader, length) {
         const message = new dnn.Node();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -155,7 +155,7 @@ dnn.Layer = class Layer {
 
     static decode(reader, length) {
         const message = new dnn.Layer();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -292,7 +292,7 @@ dnn.Buffer = class Buffer {
 
     static decode(reader, length) {
         const message = new dnn.Buffer();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -314,7 +314,7 @@ dnn.Tensor = class Tensor {
 
     static decode(reader, length) {
         const message = new dnn.Tensor();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 10 - 10
source/electron.mjs

@@ -465,13 +465,7 @@ host.ElectronHost = class {
                 options.timeout = timeout;
             }
             const request = protocol.request(location, options, (response) => {
-                if (response.statusCode !== 200) {
-                    const err = new Error(`The web request failed with status code ${response.statusCode} at '${location}'.`);
-                    err.type = 'error';
-                    err.url = location;
-                    err.status = response.statusCode;
-                    reject(err);
-                } else {
+                if (response.statusCode === 200) {
                     let data = '';
                     response.on('data', (chunk) => {
                         data += chunk;
@@ -482,6 +476,12 @@ host.ElectronHost = class {
                     response.on('end', () => {
                         resolve(data);
                     });
+                } else {
+                    const err = new Error(`The web request failed with status code ${response.statusCode} at '${location}'.`);
+                    err.type = 'error';
+                    err.url = location;
+                    err.status = response.statusCode;
+                    reject(err);
                 }
             });
             request.on("error", (err) => {
@@ -531,7 +531,7 @@ host.ElectronHost = class {
                 const path = label.split(this._environment.separator || '/');
                 for (let i = 0; i < path.length; i++) {
                     const span = this.document.createElement('span');
-                    span.innerHTML = ` ${path[i]} ${i !== path.length - 1 ? '<svg class="titlebar-icon" aria-hidden="true"><use xlink:href="#icon-arrow-right"></use></svg>' : ''}`;
+                    span.innerHTML = ` ${path[i]} ${i === path.length - 1 ? '' : '<svg class="titlebar-icon" aria-hidden="true"><use xlink:href="#icon-arrow-right"></use></svg>'}`;
                     element.appendChild(span);
                 }
             }
@@ -627,7 +627,7 @@ host.ElectronHost.FileStream = class {
     }
 
     peek(length) {
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         if (length < 0x1000000) {
             const position = this._fill(length);
             this._position -= length;
@@ -642,7 +642,7 @@ host.ElectronHost.FileStream = class {
     }
 
     read(length) {
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         if (length < 0x10000000) {
             const position = this._fill(length);
             return this._buffer.slice(position, position + length);

+ 4 - 4
source/flatbuffers.js

@@ -462,19 +462,19 @@ flatbuffers.TextReader = class {
     }
 
     int64(obj, defaultValue) {
-        return obj !== undefined ? BigInt(obj) : defaultValue;
+        return obj === undefined ? defaultValue : BigInt(obj);
     }
 
     uint64(obj, defaultValue) {
-        return obj !== undefined ? BigInt(obj) : defaultValue;
+        return obj === undefined ? defaultValue : BigInt(obj);
     }
 
     value(obj, defaultValue) {
-        return obj !== undefined ? obj : defaultValue;
+        return obj === undefined ? defaultValue : obj;
     }
 
     object(obj, decode) {
-        return obj !== undefined ? decode(this, obj) : obj;
+        return obj === undefined ? obj : decode(this, obj);
     }
 
     array(obj) {

+ 11 - 11
source/hdf5.js

@@ -508,7 +508,7 @@ hdf5.BinaryReader = class extends hdf5.Reader {
 
     peek(length) {
         const position = this._offset + this._position;
-        length = length !== undefined ? length : this._buffer.length - position;
+        length = length === undefined ? this._buffer.length - position : length;
         this.take(length);
         const buffer = this._buffer.subarray(position, position + length);
         this._position = position - this._offset;
@@ -1017,15 +1017,7 @@ hdf5.Datatype = class {
         switch (this._class) {
             case 0: // fixed-point
                 if ((this._flags & 0xfff6) === 0) {
-                    if ((this._flags && 0x08) !== 0) {
-                        switch (this._size) {
-                            case 1: return 'int8';
-                            case 2: return 'int16';
-                            case 4: return 'int32';
-                            case 8: return 'int64';
-                            default: throw new hdf5.Error(`Unsupported int size '${this._size}'.`);
-                        }
-                    } else {
+                    if ((this._flags && 0x08) === 0) {
                         switch (this._size) {
                             case 1: return 'uint8';
                             case 2: return 'uint16';
@@ -1033,6 +1025,14 @@ hdf5.Datatype = class {
                             case 8: return 'uint64';
                             default: throw new hdf5.Error(`Unsupported uint size '${this._size}'.`);
                         }
+                    } else {
+                        switch (this._size) {
+                            case 1: return 'int8';
+                            case 2: return 'int16';
+                            case 4: return 'int32';
+                            case 8: return 'int64';
+                            default: throw new hdf5.Error(`Unsupported int size '${this._size}'.`);
+                        }
                     }
                 }
                 break;
@@ -1209,7 +1209,7 @@ hdf5.Link = class {
         switch (version) {
             case 1: {
                 const flags = reader.byte();
-                this.type = (flags & 0x08) !== 0 ? reader.byte() : 0;
+                this.type = (flags & 0x08) === 0 ? 0 : reader.byte();
                 if ((flags & 0x04) !== 0) {
                     this.creationOrder = reader.uint32();
                 }

+ 1 - 1
source/keras-metadata.json

@@ -1982,7 +1982,7 @@
     ],
     "examples": [
       {
-        "code": ">>> model = keras.Sequential()\n>>> model.add(keras.layers.Embedding(1000, 64, input_length=10))\n>>> # The model will take as input an integer matrix of size (batch,\n>>> # input_length), and the largest integer (i.e. word index) in the input\n>>> # should be no larger than 999 (vocabulary size).\n>>> # Now model.output_shape is (None, 10, 64), where `None` is the batch\n>>> # dimension.\n>>> input_array = np.random.randint(1000, size=(32, 10))\n>>> model.compile('rmsprop', 'mse')\n>>> output_array = model.predict(input_array)\n>>> print(output_array.shape)\n(32, 10, 64)"
+        "code": ">>> model = keras.Sequential()\n>>> model.add(keras.layers.Embedding(1000, 64))\n>>> # The model will take as input an integer matrix of size (batch,\n>>> # input_length), and the largest integer (i.e. word index) in the input\n>>> # should be no larger than 999 (vocabulary size).\n>>> # Now model.output_shape is (None, 10, 64), where `None` is the batch\n>>> # dimension.\n>>> input_array = np.random.randint(1000, size=(32, 10))\n>>> model.compile('rmsprop', 'mse')\n>>> output_array = model.predict(input_array)\n>>> print(output_array.shape)\n(32, 10, 64)"
       }
     ]
   },

+ 3 - 3
source/keras-proto.js

@@ -17,7 +17,7 @@ third_party.tensorflow.python.keras.protobuf.SavedMetadata = class SavedMetadata
 
     static decode(reader, length) {
         const message = new third_party.tensorflow.python.keras.protobuf.SavedMetadata();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -54,7 +54,7 @@ third_party.tensorflow.python.keras.protobuf.SavedObject = class SavedObject {
 
     static decode(reader, length) {
         const message = new third_party.tensorflow.python.keras.protobuf.SavedObject();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -125,7 +125,7 @@ third_party.tensorflow.python.keras.protobuf.VersionDef = class VersionDef {
 
     static decode(reader, length) {
         const message = new third_party.tensorflow.python.keras.protobuf.VersionDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 4 - 4
source/keras.js

@@ -134,12 +134,12 @@ keras.ModelFactory = class {
                     return name.toLowerCase();
                 };
                 let name = pascal_to_snake_case(trackable.class_name);
-                if (!used_names.has(name)) {
-                    used_names.set(name, 0);
-                } else {
+                if (used_names.has(name)) {
                     const next = used_names.get(name) + 1;
                     used_names.set(name, next);
                     name = `${name}_${next}`;
+                } else {
+                    used_names.set(name, 0);
                 }
                 _load_state(trackable, weights_store, assets_store, `${inner_path}/${name}`);
             }
@@ -1095,7 +1095,7 @@ keras.Node = class {
                         break;
                 }
             }
-            const input = !list ? [inputs.shift()] : inputs.splice(0, inputs.length);
+            const input = list ? inputs.splice(0, inputs.length) : [inputs.shift()];
             const inputArguments = input.map((input) => {
                 if (input.name) {
                     return values.map(input.name, null, input.initializer);

+ 1 - 1
source/kmodel.js

@@ -194,7 +194,7 @@ kmodel.Tensor = class {
 kmodel.Node = class {
 
     constructor(layer, value) {
-        this.location = layer.location !== undefined ? layer.location.toString() : layer.location;
+        this.location = layer.location === undefined ? layer.location : layer.location.toString();
         this.name = '';
         this.type = layer.type;
         this.inputs = [];

+ 3 - 3
source/mediapipe.js

@@ -250,11 +250,11 @@ mediapipe.Object = class {
                         obj.push(parseFloat(data));
                     }
                 }
-            } else if (!isNaN(next)) {
-                obj = parseFloat(next);
+            } else if (isNaN(next)) {
+                obj = next;
                 reader.next();
             } else {
-                obj = next;
+                obj = parseFloat(next);
                 reader.next();
             }
             if (this[tag] && (!Array.isArray(this[tag]) || arrayTags.has(tag))) {

+ 12 - 12
source/megengine.js

@@ -108,7 +108,7 @@ megengine.Graph = class {
                 let inpIdx = 0;
                 for (const i of expr.inputs) {
                     if (i.__class__.__name__ !== 'ModuleNode') {
-                        const initializer = i.initializer !== undefined ? i.initializer : null;
+                        const initializer = i.initializer === undefined ? null : i.initializer;
                         const name = `inp${inpIdx}`;
                         const type = getTensorType(i._dtype, i._shape);
                         const argument = new megengine.Argument(name, [value(i._fullname, type, initializer)]);
@@ -143,16 +143,16 @@ megengine.Graph = class {
                             return obj && obj.__class__ && obj.__class__.__module__ === 'megengine.tensor' && (obj.__class__.__name__ === 'Tensor' || obj.__class__.__name__ === 'Parameter');
                         };
                         if (!key.startsWith('_') && !isModule(state[key])) {
-                            if (!isTensor(state[key])) {
-                                const attribute = new megengine.Attribute(null, key, state[key] !== null ? state[key] : 'None');
-                                node.attributes.push(attribute);
-                            } else {
+                            if (isTensor(state[key])) {
                                 const tensor = state[key];
                                 const type = getTensorType(tensor.dtype, tensor.data.shape);
                                 const data = tensor.data.data;
                                 const initializer = new megengine.Tensor(key, type, data);
                                 const argument = new megengine.Argument(key, [value('', type, initializer)]);
                                 node.inputs.push(argument);
+                            } else {
+                                const attribute = new megengine.Attribute(null, key, state[key] === null ? 'None' : state[key]);
+                                node.attributes.push(attribute);
                             }
                         }
                     }
@@ -200,7 +200,7 @@ megengine.Graph = class {
                         throw new megengine.Error(`Invalid argument '${obj.__class__.__name__}'.`);
                     }
                     if (obj.__class__.__name__ === 'TreeDef') {
-                        const type = typeof obj.type !== 'string' ? obj.type.__name__ : obj.type.split('.').slice(-1)[0];
+                        const type = typeof obj.type === 'string' ? obj.type.split('.').slice(-1)[0] : obj.type.__name__;
                         const list = obj.children_defs.map((child) => formatTreeDef(child));
                         switch (type) {
                             case 'tuple': {
@@ -305,7 +305,7 @@ megengine.Graph = class {
                                 }
                                 return `${obj.__class__.__module__}.${obj.__class__.__name__}`;
                             };
-                            const moduleType = module.__class__.__name__ !== 'TracedModule' ? getModuleType(module) : 'TracedModule';
+                            const moduleType = module.__class__.__name__ === 'TracedModule' ? 'TracedModule' : getModuleType(module);
                             if (moduleType === 'TracedModule') {
                                 const moduleName = expression.outputs[0]._name.endsWith("_out") ? expression.outputs[0]._name.substring(0, expression.outputs[0]._name.length - 4) : expression.outputs[0]._name;
                                 const prefix = getFullName(namePrefix, moduleName);
@@ -318,17 +318,17 @@ megengine.Graph = class {
                                 for (let i = 0; i < expression.outputs.length; i++) {
                                     const actualName = getFullName(namePrefix, expression.outputs[i]._name);
                                     const internalName = getFullName(prefix, internalGraph._outputs[i]._name);
-                                    if (context.get(internalName) !== undefined) {
-                                        context.set(actualName, context.get(internalName));
-                                    } else {
+                                    if (context.get(internalName) === undefined) {
                                         context.set(internalName, actualName);
+                                    } else {
+                                        context.set(actualName, context.get(internalName));
                                     }
                                 }
                                 loadGraph(module, internalGraph, context, prefix, metadata, false);
                                 continue;
                             }
                             const item = { 'name': '', 'type': moduleType };
-                            let state = module.__class__.__name__ !== 'TracedModule' ? module.state : module;
+                            let state = module.__class__.__name__ === 'TracedModule' ? module : module.state;
                             if (state === undefined) {
                                 state = module;
                             }
@@ -395,7 +395,7 @@ megengine.Graph = class {
             if (opr.tensors.length > 0) {
                 const [tensor] = opr.tensors;
                 const type = new megengine.TensorType(tensor.dtype.type, new megengine.TensorShape(tensor.shape));
-                const data = tensor.data.byteLength !== 0 ? tensor.data.slice(0) : undefined;
+                const data = tensor.data.byteLength === 0 ? undefined : tensor.data.slice(0);
                 const initializer = opr.type === 'Host2DeviceCopy' ? undefined : new megengine.Tensor('', type, data);
                 const quantization = tensor.dtype.param ? { scale: tensor.dtype.param.scale, zeroPoint: tensor.dtype.param.zero_point } : null;
                 args.push(value(name, type, initializer, quantization));

+ 1 - 1
source/mlnet.js

@@ -1450,7 +1450,7 @@ mlnet.NormalizingTransformer = class extends mlnet.OneToOneTransformerBase {
                 case 10: itemType = 'float64'; break;
                 default: throw new mlnet.Error(`Unsupported NormalizingTransformer item kind '${itemKind}'.`);
             }
-            const type = itemType + (!isVector ? '' : `[${shape.map((dim) => dim.toString()).join(',')}]`);
+            const type = itemType + (isVector ? `[${shape.map((dim) => dim.toString()).join(',')}]` : '');
             const name = `Normalizer_${(`00${i}`).slice(-3)}`;
             const func = context.open(name);
             this.Options.push({ type, func });

+ 4 - 3
source/mslite.js

@@ -47,12 +47,13 @@ mslite.Model = class {
         const version = model.version ? model.version.match(/^.*(\d\.\d\.\d)$/) : null;
         this.format = `MindSpore Lite${version ? ` v${version[1]}` : ''}`;
         const subgraphs = model.subGraph;
-        if (!Array.isArray(subgraphs)) {
-            this.graphs.push(new mslite.Graph(metadata, model, model));
-        } else {
+        if (Array.isArray(subgraphs)) {
             for (const subgraph of subgraphs) {
                 this.graphs.push(new mslite.Graph(metadata, subgraph, model));
             }
+        } else {
+            const graph = new mslite.Graph(metadata, model, model);
+            this.graphs.push(graph);
         }
     }
 };

+ 4 - 2
source/ncnn.js

@@ -191,7 +191,7 @@ ncnn.Graph = class {
         }
         for (const layer of layers) {
             if (layer.type === 'Input' || layer.type === 16) {
-                const dimensions = Array.from(layer.attributes.values()).map((value) => !isNaN(parseInt(value, 10)) ? parseInt(value, 10) : value);
+                const dimensions = Array.from(layer.attributes.values()).map((value) => isNaN(parseInt(value, 10)) ? value : parseInt(value, 10));
                 const shape = new ncnn.TensorShape(dimensions);
                 const type = new ncnn.TensorType('float32', shape);
                 const input = new ncnn.Argument(layer.name, layer.outputs.map((output) => values.map(output, type)));
@@ -482,6 +482,7 @@ ncnn.Node = class {
                 const h = parseInt(attributes.get('1') || 0, 10);
                 const d = parseInt(attributes.get('11') || 0, 10);
                 const c = parseInt(attributes.get('2') || 0, 10);
+                /* eslint-disable no-negated-condition */
                 if (d !== 0) {
                     weight(blobReader, 'data', [c, d, h, w], 'float32');
                 } else if (c !== 0) {
@@ -493,6 +494,7 @@ ncnn.Node = class {
                 } else {
                     weight(blobReader, 'data', [1], 'float32');
                 }
+                /* eslint-enable no-negated-condition */
                 break;
             }
             case 'GroupNorm': {
@@ -755,7 +757,7 @@ ncnn.TextParamReader = class {
             lines.push(line.trim());
         }
         const signature = lines.shift();
-        const header = (signature !== '7767517' ? signature : lines.shift()).split(' ');
+        const header = (signature === '7767517' ? lines.shift() : signature).split(' ');
         if (header.length !== 2 || !header.every((value) => value >>> 0 === parseFloat(value))) {
             throw new ncnn.Error('Invalid header.');
         }

Fichier diff supprimé car celui-ci est trop grand
+ 112 - 112
source/nnabla-proto.js


+ 13 - 13
source/om-proto.js

@@ -47,7 +47,7 @@ ge.proto.AttrDef = class AttrDef {
 
     static decode(reader, length) {
         const message = new ge.proto.AttrDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -169,7 +169,7 @@ ge.proto.AttrDef.ListValue = class ListValue {
 
     static decode(reader, length) {
         const message = new ge.proto.AttrDef.ListValue();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -286,7 +286,7 @@ ge.proto.AttrDef.ListListInt = class ListListInt {
 
     static decode(reader, length) {
         const message = new ge.proto.AttrDef.ListListInt();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -327,7 +327,7 @@ ge.proto.AttrDef.ListListInt.ListInt = class ListInt {
 
     static decode(reader, length) {
         const message = new ge.proto.AttrDef.ListListInt.ListInt();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -368,7 +368,7 @@ ge.proto.AttrDef.ListListFloat = class ListListFloat {
 
     static decode(reader, length) {
         const message = new ge.proto.AttrDef.ListListFloat();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -409,7 +409,7 @@ ge.proto.AttrDef.ListListFloat.ListFloat = class ListFloat {
 
     static decode(reader, length) {
         const message = new ge.proto.AttrDef.ListListFloat.ListFloat();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -450,7 +450,7 @@ ge.proto.NamedAttrs = class NamedAttrs {
 
     static decode(reader, length) {
         const message = new ge.proto.NamedAttrs();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -499,7 +499,7 @@ ge.proto.ShapeDef = class ShapeDef {
 
     static decode(reader, length) {
         const message = new ge.proto.ShapeDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -540,7 +540,7 @@ ge.proto.TensorDescriptor = class TensorDescriptor {
 
     static decode(reader, length) {
         const message = new ge.proto.TensorDescriptor();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -697,7 +697,7 @@ ge.proto.TensorDef = class TensorDef {
 
     static decode(reader, length) {
         const message = new ge.proto.TensorDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -761,7 +761,7 @@ ge.proto.OpDef = class OpDef {
 
     static decode(reader, length) {
         const message = new ge.proto.OpDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -925,7 +925,7 @@ ge.proto.GraphDef = class GraphDef {
 
     static decode(reader, length) {
         const message = new ge.proto.GraphDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -993,7 +993,7 @@ ge.proto.ModelDef = class ModelDef {
 
     static decode(reader, length) {
         const message = new ge.proto.ModelDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 3 - 3
source/om.js

@@ -591,11 +591,11 @@ svp.ModelDef = class ModelDef {
                                     break;
                                 }
                             }
-                            if (curr_op !== null) {
-                                curr_op.output_desc = curr_op.output_desc.concat(out_list);
-                            } else {
+                            if (curr_op === null) {
                                 op.output_desc = op.output_desc.concat(out_list);
                                 item.op.push(op);
+                            } else {
+                                curr_op.output_desc = curr_op.output_desc.concat(out_list);
                             }
                             break;
                         }

+ 24 - 24
source/onnx-proto.js

@@ -29,7 +29,7 @@ onnx.AttributeProto = class AttributeProto {
 
     static decode(reader, length) {
         const message = new onnx.AttributeProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -202,7 +202,7 @@ onnx.ValueInfoProto = class ValueInfoProto {
 
     static decode(reader, length) {
         const message = new onnx.ValueInfoProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -268,7 +268,7 @@ onnx.NodeProto = class NodeProto {
 
     static decode(reader, length) {
         const message = new onnx.NodeProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -364,7 +364,7 @@ onnx.TrainingInfoProto = class TrainingInfoProto {
 
     static decode(reader, length) {
         const message = new onnx.TrainingInfoProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -429,7 +429,7 @@ onnx.ModelProto = class ModelProto {
 
     static decode(reader, length) {
         const message = new onnx.ModelProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -534,7 +534,7 @@ onnx.StringStringEntryProto = class StringStringEntryProto {
 
     static decode(reader, length) {
         const message = new onnx.StringStringEntryProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -584,7 +584,7 @@ onnx.TensorAnnotation = class TensorAnnotation {
 
     static decode(reader, length) {
         const message = new onnx.TensorAnnotation();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -640,7 +640,7 @@ onnx.GraphProto = class GraphProto {
 
     static decode(reader, length) {
         const message = new onnx.GraphProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -746,7 +746,7 @@ onnx.TensorProto = class TensorProto {
 
     static decode(reader, length) {
         const message = new onnx.TensorProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -900,7 +900,7 @@ onnx.TensorProto.Segment = class Segment {
 
     static decode(reader, length) {
         const message = new onnx.TensorProto.Segment();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -955,7 +955,7 @@ onnx.SparseTensorProto = class SparseTensorProto {
 
     static decode(reader, length) {
         const message = new onnx.SparseTensorProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1011,7 +1011,7 @@ onnx.TensorShapeProto = class TensorShapeProto {
 
     static decode(reader, length) {
         const message = new onnx.TensorShapeProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1053,7 +1053,7 @@ onnx.TensorShapeProto.Dimension = class Dimension {
 
     static decode(reader, length) {
         const message = new onnx.TensorShapeProto.Dimension();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1109,7 +1109,7 @@ onnx.TypeProto = class TypeProto {
 
     static decode(reader, length) {
         const message = new onnx.TypeProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1184,7 +1184,7 @@ onnx.TypeProto.Tensor = class Tensor {
 
     static decode(reader, length) {
         const message = new onnx.TypeProto.Tensor();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1230,7 +1230,7 @@ onnx.TypeProto.Sequence = class Sequence {
 
     static decode(reader, length) {
         const message = new onnx.TypeProto.Sequence();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1269,7 +1269,7 @@ onnx.TypeProto.Map = class Map {
 
     static decode(reader, length) {
         const message = new onnx.TypeProto.Map();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1315,7 +1315,7 @@ onnx.TypeProto.Optional = class Optional {
 
     static decode(reader, length) {
         const message = new onnx.TypeProto.Optional();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1354,7 +1354,7 @@ onnx.TypeProto.SparseTensor = class SparseTensor {
 
     static decode(reader, length) {
         const message = new onnx.TypeProto.SparseTensor();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1400,7 +1400,7 @@ onnx.TypeProto.Opaque = class Opaque {
 
     static decode(reader, length) {
         const message = new onnx.TypeProto.Opaque();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1446,7 +1446,7 @@ onnx.OperatorSetIdProto = class OperatorSetIdProto {
 
     static decode(reader, length) {
         const message = new onnx.OperatorSetIdProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1508,7 +1508,7 @@ onnx.FunctionProto = class FunctionProto {
 
     static decode(reader, length) {
         const message = new onnx.FunctionProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1616,7 +1616,7 @@ onnx.OperatorProto = class OperatorProto {
 
     static decode(reader, length) {
         const message = new onnx.OperatorProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1681,7 +1681,7 @@ onnx.OperatorSetProto = class OperatorSetProto {
 
     static decode(reader, length) {
         const message = new onnx.OperatorSetProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 20 - 19
source/onnx.js

@@ -1084,7 +1084,7 @@ onnx.Context.Graph = class {
                         attribute.type = onnx.AttributeType.TENSOR;
                     } else if (attribute.g !== undefined) {
                         attribute.type = onnx.AttributeType.GRAPH;
-                    } else if (attribute.sparse_tensor !== undefined) {
+                    } else if (attribute.sparse_tensor) {
                         attribute.type = onnx.AttributeType.SPARSE_TENSOR;
                     } else {
                         attribute.type = onnx.AttributeType.UNDEFINED;
@@ -2231,7 +2231,25 @@ onnx.TextReader = class {
         }
         this._expect('=');
         if (this._match('[')) {
-            if (!this._match(']')) {
+            if (this._match(']')) {
+
+                if (attribute.type === onnx.AttributeType.UNDEFINED) {
+                    this._throw('Empty list attribute value requires type annotation.');
+                }
+                switch (attribute.type) {
+                    case onnx.AttributeType.FLOAT:
+                    case onnx.AttributeType.INT:
+                    case onnx.AttributeType.STRING:
+                    case onnx.AttributeType.TENSOR:
+                    case onnx.AttributeType.GRAPH:
+                    case onnx.AttributeType.SPARSE_TENSOR:
+                    case onnx.AttributeType.TYPE_PROTO:
+                        this._throw("Singleton attribute value cannot be specified as a list.");
+                        break;
+                    default:
+                        break;
+                }
+            } else {
                 do {
                     const value = new onnx.proto.AttributeProto();
                     let type = onnx.AttributeType.UNDEFINED;
@@ -2264,23 +2282,6 @@ onnx.TextReader = class {
                     }
                 }
                 while (this._match(','));
-            } else {
-                if (attribute.type === onnx.AttributeType.UNDEFINED) {
-                    this._throw('Empty list attribute value requires type annotation.');
-                }
-                switch (attribute.type) {
-                    case onnx.AttributeType.FLOAT:
-                    case onnx.AttributeType.INT:
-                    case onnx.AttributeType.STRING:
-                    case onnx.AttributeType.TENSOR:
-                    case onnx.AttributeType.GRAPH:
-                    case onnx.AttributeType.SPARSE_TENSOR:
-                    case onnx.AttributeType.TYPE_PROTO:
-                        this._throw("Singleton attribute value cannot be specified as a list.");
-                        break;
-                    default:
-                        break;
-                }
             }
             this._expect(']');
         } else {

+ 3 - 3
source/openvino.js

@@ -141,14 +141,14 @@ openvino.ModelFactory = class {
                 layer.output = ports(element, 'output');
                 const data = child(element, 'data');
                 const blobs = child(element, 'blobs');
-                layer.data = !data ? {} : object(data);
-                layer.blobs = !blobs ? [] : blobs.getElementsByTagName('*').map((blob) => {
+                layer.data = data ? object(data) : {};
+                layer.blobs = blobs ? blobs.getElementsByTagName('*').map((blob) => {
                     const obj = object(blob);
                     obj.name = blob.localName;
                     obj.offset = parseInt(obj.offset, 10);
                     obj.size = parseInt(obj.size, 10);
                     return obj;
-                });
+                }) : [];
                 if (layer.type === 'TensorIterator') {
                     layer.back_edges = edges(element, 'back_edges');
                     const body = child(element, 'body');

+ 22 - 22
source/paddle-proto.js

@@ -9,7 +9,7 @@ paddle.framework.proto.Version = class Version {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.Version();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -69,7 +69,7 @@ paddle.framework.proto.Complex = class Complex {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.Complex();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -127,7 +127,7 @@ paddle.framework.proto.Scalar = class Scalar {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.Scalar();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -213,7 +213,7 @@ paddle.framework.proto.OpDesc = class OpDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -295,7 +295,7 @@ paddle.framework.proto.OpDesc.Attr = class Attr {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpDesc.Attr();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -474,7 +474,7 @@ paddle.framework.proto.OpDesc.Var = class Var {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpDesc.Var();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -531,7 +531,7 @@ paddle.framework.proto.OpProto = class OpProto {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -607,7 +607,7 @@ paddle.framework.proto.OpProto.Var = class Var {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpProto.Var();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -700,7 +700,7 @@ paddle.framework.proto.OpProto.Attr = class Attr {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpProto.Attr();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -799,7 +799,7 @@ paddle.framework.proto.VarType = class VarType {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarType();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -952,7 +952,7 @@ paddle.framework.proto.VarType.TensorDesc = class TensorDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarType.TensorDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1003,7 +1003,7 @@ paddle.framework.proto.VarType.LoDTensorDesc = class LoDTensorDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarType.LoDTensorDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1055,7 +1055,7 @@ paddle.framework.proto.VarType.LoDTensorArrayDesc = class LoDTensorArrayDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarType.LoDTensorArrayDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1111,7 +1111,7 @@ paddle.framework.proto.VarType.ReaderDesc = class ReaderDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarType.ReaderDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1152,7 +1152,7 @@ paddle.framework.proto.VarType.Tuple = class Tuple {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarType.Tuple();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1193,7 +1193,7 @@ paddle.framework.proto.VarDesc = class VarDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1289,7 +1289,7 @@ paddle.framework.proto.VarDesc.Attr = class Attr {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.VarDesc.Attr();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1372,7 +1372,7 @@ paddle.framework.proto.BlockDesc = class BlockDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.BlockDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1449,7 +1449,7 @@ paddle.framework.proto.OpVersion = class OpVersion {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpVersion();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1498,7 +1498,7 @@ paddle.framework.proto.OpVersionMap = class OpVersionMap {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpVersionMap();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1535,7 +1535,7 @@ paddle.framework.proto.OpVersionMap.OpVersionPair = class OpVersionPair {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.OpVersionMap.OpVersionPair();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1597,7 +1597,7 @@ paddle.framework.proto.ProgramDesc = class ProgramDesc {
 
     static decode(reader, length) {
         const message = new paddle.framework.proto.ProgramDesc();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 3 - 3
source/paddle.js

@@ -172,7 +172,7 @@ paddle.ModelFactory = class {
                         return new paddle.Model(metadata, target.format, null, target.weights);
                     }
                     case 'paddle.params': {
-                        const file = identifier !== 'params' ? `${base}.pdmodel` : 'model';
+                        const file = identifier === 'params' ? 'model' : `${base}.pdmodel`;
                         const params = loadParams(context.stream);
                         try {
                             const content = await context.fetch(file);
@@ -349,7 +349,7 @@ paddle.Graph = class {
             const ops = new Map();
             for (const [name, tensor] of tensors) {
                 values.set(name, new paddle.Value(name, tensor.type, tensor));
-                const separator = name.indexOf('.') !== -1 ? '.' : '_';
+                const separator = name.indexOf('.') === -1 ? '_' : '.';
                 const regex = /(.*)_((w_attr|scale|weights|offset|b|w|b_attr)_(moment|beta|velocity|mean_square|mean_grad).*)/;
                 let parts = [];
                 if (separator === '.') {
@@ -557,7 +557,7 @@ paddle.TensorShape = class {
     constructor(dimensions) {
         dimensions = dimensions.map((dim) => typeof dim === 'bigint' ? dim.toNumber() : dim);
         this.dimensions = dimensions.map((dimension) => {
-            return dimension !== -1 ? dimension : '?';
+            return dimension === -1 ? '?' : dimension;
         });
     }
 

+ 6 - 6
source/protobuf.js

@@ -96,15 +96,15 @@ protobuf.BinaryReader = class {
                                 }
                                 if (inner === 2) {
                                     tags[field] = inner;
-                                } else if (!type) {
-                                    tags[field] = inner;
-                                } else {
+                                } else if (type) {
                                     for (const [key, value] of Object.entries(inner)) {
                                         if (type[key] === 2 && value !== 2) {
                                             continue;
                                         }
                                         type[key] = value;
                                     }
+                                } else {
+                                    tags[field] = inner;
                                 }
                                 continue;
                             }
@@ -147,15 +147,15 @@ protobuf.BinaryReader = class {
                                 }
                                 if (inner === 2) {
                                     tags[field] = inner;
-                                } else if (!type) {
-                                    tags[field] = inner;
-                                } else {
+                                } else if (type) {
                                     for (const [name, value] of Object.entries(inner)) {
                                         if (type[name] === 2 && value !== 2) {
                                             continue;
                                         }
                                         type[name] = value;
                                     }
+                                } else {
+                                    tags[field] = inner;
                                 }
                                 continue;
                             }

+ 20 - 20
source/python.js

@@ -714,7 +714,7 @@ python.Parser = class {
                 throw new python.Error(`Invalid decorator ${this._tokenizer.location()}`);
             }
             this._tokenizer.eat('\n');
-            list = list !== null ? list : [];
+            list = list === null ? [] : list;
             list.push(node);
         }
         return list;
@@ -1337,7 +1337,7 @@ python.Tokenizer = class {
             }
             if (radix > 0 && this._get(i) !== '.') {
                 const radixText = this._text.substring(this._position, i);
-                const radixParseText = radixText.indexOf('_') !== -1 ? radixText.split('_').join('') : radixText;
+                const radixParseText = radixText.indexOf('_') === -1 ? radixText : radixText.split('_').join('');
                 if (!isNaN(parseInt(radixParseText, radix))) {
                     return { type: 'number', value: radixText };
                 }
@@ -1384,12 +1384,12 @@ python.Tokenizer = class {
                     if (this._get(i) === '-' || this._get(i) === '+') {
                         i++;
                     }
-                    if (!decimal(this._get(i))) {
-                        i = this._position;
-                    } else {
+                    if (decimal(this._get(i))) {
                         while (decimal(this._get(i))) {
                             i++;
                         }
+                    } else {
+                        i = this._position;
                     }
                 } else {
                     while (decimal(this._get(i))) {
@@ -1402,7 +1402,7 @@ python.Tokenizer = class {
                     return { type: 'number', value: this._text.substring(this._position, i + 1) };
                 }
                 const floatText = this._text.substring(this._position, i);
-                const floatParseText = floatText.indexOf('_') !== -1 ? floatText.split('_').join('') : floatText;
+                const floatParseText = floatText.indexOf('_') === -1 ? floatText : floatText.split('_').join('');
                 if (!isNaN(parseFloat(floatParseText))) {
                     return { type: 'number', value: floatText };
                 }
@@ -1867,7 +1867,7 @@ python.Execution = class {
             }
             read(size) {
                 const start = this._point;
-                this._point = size !== undefined ? start + size : this._buf.length;
+                this._point = size === undefined ? this._buf.length : start + size;
                 return this._buf.subarray(start, this._point);
             }
             write(data) {
@@ -2302,10 +2302,10 @@ python.Execution = class {
         this.registerType('megengine.traced_module.pytree.LeafDef', class {
             toString() {
                 let content = '';
-                if (this.const_val !== null) {
-                    content += this.const_val;
-                } else {
+                if (this.const_val === null) {
                     content += '[';
+                } else {
+                    content += this.const_val;
                 }
                 for (const t of Object.values(this.type)) {
                     content += t.__name__;
@@ -2341,10 +2341,10 @@ python.Execution = class {
             constructor(shape, dtype, buffer, offset, strides, order) {
                 this.shape = shape;
                 this.dtype = dtype;
-                this.data = buffer !== undefined ? buffer : null;
-                this.offset = offset !== undefined ? offset : 0;
-                this._strides = strides !== undefined ? strides : null;
-                this.order = offset !== undefined ? order : null;
+                this.data = buffer === undefined ? null : buffer;
+                this.offset = offset === undefined ? 0 : offset;
+                this._strides = strides === undefined ? null : strides;
+                this.order = order === undefined ? null : order;
                 this.flags = {};
                 this._read();
             }
@@ -4906,10 +4906,10 @@ python.Execution = class {
                 // ret = ret.as_subclass(new_type);
             }
             const setstate = execution.invoke('builtins.getattr', [ret.__class__, '__setstate__', torch.Tensor.__setstate__]);
-            if (setstate !== torch.Tensor.__setstate__) {
-                ret.__setstate__(state);
-            } else {
+            if (setstate === torch.Tensor.__setstate__) {
                 ret = execution.invoke('torch._utils._set_obj_state', [ret, state]);
+            } else {
+                ret.__setstate__(state);
             }
             return ret;
         });
@@ -6534,7 +6534,7 @@ python.Execution = class {
                     data = self.invoke('torch.Tensor', [[]]);
                 }
                 this.data = data;
-                this.requires_grad = requires_grad !== undefined ? requires_grad : true;
+                this.requires_grad = requires_grad === undefined ? true : requires_grad;
             }
         });
         this.registerType('torch.nn.parameter.UninitializedParameter', class extends torch.nn.parameter.Parameter {
@@ -7499,7 +7499,7 @@ python.BinaryReader = class {
 
     peek(length) {
         const position = this._position;
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         this.skip(length);
         const end = this._position;
         this.skip(-length);
@@ -7511,7 +7511,7 @@ python.BinaryReader = class {
 
     read(length) {
         const position = this._position;
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         this.skip(length);
         if (position === 0 && length === this._length) {
             return this._buffer;

+ 10 - 10
source/pytorch.js

@@ -297,7 +297,7 @@ pytorch.Node = class {
             }
             const type = Object.assign({}, metadata.type(name) || { name });
             type.identifier = type.name;
-            type.name = type.name.indexOf('::') !== -1 ? type.name.split('::').pop().split('.')[0] : type.name;
+            type.name = type.name.indexOf('::') === -1 ? type.name : type.name.split('::').pop().split('.')[0];
             return type;
         };
         const createAttribute = (metadata, name, value) => {
@@ -2182,7 +2182,9 @@ pytorch.jit.Execution = class extends pytorch.Execution {
                             continue;
                         }
                         throw new pytorch.Error();
-                    } else if (arg.type !== '=') {
+                    } else if (arg.type === '=') {
+                        throw new pytorch.Error('Expected named argument.');
+                    } else {
                         copyArgs.shift();
                         copyEvalArgs.shift();
                         switch (parameter.type) {
@@ -2209,8 +2211,6 @@ pytorch.jit.Execution = class extends pytorch.Execution {
                                 break;
                             }
                         }
-                    } else {
-                        throw new pytorch.Error('Expected named argument.');
                     }
                 }
             }
@@ -2539,7 +2539,7 @@ pytorch.jit.Execution = class extends pytorch.Execution {
                 }
             }
             if (overloads) {
-                overloads = !Array.isArray(overloads) ? [overloads] : overloads;
+                overloads = Array.isArray(overloads) ? overloads : [overloads];
                 const evalArgs = args.map((argument) => {
                     if (argument.type === '=' && argument.target && argument.target.type === 'id') {
                         argument = argument.expression;
@@ -2610,11 +2610,11 @@ pytorch.jit.Execution = class extends pytorch.Execution {
                                     continue;
                                 }
                                 next = true;
-                            } else if (arg.type !== '=') {
+                            } else if (arg.type === '=') {
+                                throw new pytorch.Error('Expected named argument.');
+                            } else {
                                 copyArgs.shift();
                                 copyEvalArgs.shift();
-                            } else {
-                                throw new pytorch.Error('Expected named argument.');
                             }
                         }
                         if (next) {
@@ -3603,7 +3603,7 @@ pytorch.Utility = class {
             if (!Array.isArray(obj) && !(obj instanceof Map) && obj === Object(obj) && Object.keys(obj).length === 0) {
                 return new Map();
             }
-            const keys = !Array.isArray(obj) ? Object.keys(obj) : [];
+            const keys = Array.isArray(obj) ? [] : Object.keys(obj);
             if (keys.length > 1) {
                 keys.splice(0, keys.length);
             }
@@ -3979,7 +3979,7 @@ pytorch.nnapi.Graph = class {
                     case 'quant16_asymm':
                     case 'quant16_symm':
                         quantization = dataType;
-                        dataType = dataType.indexOf('16') !== -1 ? 'uint16' : 'uint8';
+                        dataType = dataType.indexOf('16') === -1 ? 'uint8' : 'uint16';
                         break;
                     default:
                         break;

+ 6 - 6
source/sentencepiece-proto.js

@@ -12,7 +12,7 @@ sentencepiece.TrainerSpec = class TrainerSpec {
 
     static decode(reader, length) {
         const message = new sentencepiece.TrainerSpec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -369,7 +369,7 @@ sentencepiece.NormalizerSpec = class NormalizerSpec {
 
     static decode(reader, length) {
         const message = new sentencepiece.NormalizerSpec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -447,7 +447,7 @@ sentencepiece.SelfTestData = class SelfTestData {
 
     static decode(reader, length) {
         const message = new sentencepiece.SelfTestData();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -484,7 +484,7 @@ sentencepiece.SelfTestData.Sample = class Sample {
 
     static decode(reader, length) {
         const message = new sentencepiece.SelfTestData.Sample();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -534,7 +534,7 @@ sentencepiece.ModelProto = class ModelProto {
 
     static decode(reader, length) {
         const message = new sentencepiece.ModelProto();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -600,7 +600,7 @@ sentencepiece.ModelProto.SentencePiece = class SentencePiece {
 
     static decode(reader, length) {
         const message = new sentencepiece.ModelProto.SentencePiece();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 1 - 1
source/sklearn.js

@@ -302,7 +302,7 @@ sklearn.Attribute = class {
         this.name = name;
         this.value = value;
         this.type = type;
-        this.visible = visible !== false ? true : false;
+        this.visible = visible !== false;
     }
 };
 

+ 3 - 3
source/tar.js

@@ -69,7 +69,7 @@ tar.Entry = class {
             this._name = reader.string(155) + this._name;
         }
         this._stream = stream.stream(size);
-        stream.read(((size % 512) !== 0) ? (512 - (size % 512)) : 0);
+        stream.read(((size % 512) === 0) ? 0 : (512 - (size % 512)));
     }
 
     get type() {
@@ -123,7 +123,7 @@ tar.BinaryReader = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         const end = this._position;
         this.seek(position);
         return this._buffer.subarray(position, end);
@@ -135,7 +135,7 @@ tar.BinaryReader = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         return this._buffer.subarray(position, this._position);
     }
 

Fichier diff supprimé car celui-ci est trop grand
+ 112 - 112
source/tf-proto.js


+ 9 - 11
source/tf.js

@@ -375,7 +375,7 @@ tf.ModelFactory = class {
                             const name = item.name;
                             if (name.indexOf('::') !== -1) {
                                 const index = name.indexOf('.');
-                                const key = (index !== -1) ? name.substring(0, index) : name;
+                                const key = index === -1 ? name : name.substring(0, index);
                                 if (!metadata.has(key)) {
                                     metadata.set(key, []);
                                 }
@@ -842,7 +842,7 @@ tf.Function = class {
         this.nodes = [];
         this.inputs = [];
         this.outputs = [];
-        this.description = !func ? 'Function definition not found.' : null;
+        this.description = func ? null : 'Function definition not found.';
         this.groups = false;
         const context = new tf.Context();
         const input_arg = func && func.signature ? func.signature.input_arg : [];
@@ -1282,7 +1282,7 @@ tf.TensorShape = class {
 tf.TensorBundle = class {
 
     static async open(stream, identifier, context) {
-        const format = !identifier.toLowerCase().endsWith('.index') ? 1 : 2;
+        const format = identifier.toLowerCase().endsWith('.index') ? 2 : 1;
         const table = new tf.TensorBundle.Table(stream);
         if (!table.entries.has('')) {
             throw new tf.Error('Bundle header not available.');
@@ -1329,14 +1329,7 @@ tf.TensorBundle = class {
                         const slices = tf.proto.tensorflow.SavedTensorSlices.decode(reader);
                         const name = slices.data.name;
                         const tensor = slices.data.data;
-                        if (!data.has(name)) {
-                            if (tensor.tensor_content && tensor.tensor_content.length > 0) {
-                                data.set(name, { key: 'tensor_content', value: tensor.tensor_content });
-                            } else {
-                                const keys = Object.keys(tensor).filter((key) => key.endsWith('_val') && tensor[key] && tensor[key].length > 0);
-                                data.set(name, keys.length === 1 ? { key: keys[0], value: tensor[keys[0]] } : null);
-                            }
-                        } else {
+                        if (data.has(name)) {
                             const item = data.get(name);
                             if (item !== null) {
                                 if (tensor[item.key] && tensor[item.key].length > 0) {
@@ -1345,6 +1338,11 @@ tf.TensorBundle = class {
                                     data.set(name, null);
                                 }
                             }
+                        } else if (tensor.tensor_content && tensor.tensor_content.length > 0) {
+                            data.set(name, { key: 'tensor_content', value: tensor.tensor_content });
+                        } else {
+                            const keys = Object.keys(tensor).filter((key) => key.endsWith('_val') && tensor[key] && tensor[key].length > 0);
+                            data.set(name, keys.length === 1 ? { key: keys[0], value: tensor[keys[0]] } : null);
                         }
                     }
                 }

+ 2 - 2
source/torch.js

@@ -170,10 +170,10 @@ torch.Graph = class {
         const outputs = [];
         loadModule(metadata, root, [], '', inputs, outputs);
         this.inputs = this.inputs.concat(inputs.map((input, index) => {
-            return new torch.Argument(`input${index !== 0 ? (index + 1).toString() : ''}`, [input]);
+            return new torch.Argument(`input${index === 0 ? '' : (index + 1).toString()}`, [input]);
         }));
         this.outputs = this.outputs.concat(outputs.map((output, index) => {
-            return new torch.Argument(`output${index !== 0 ? (index + 1).toString() : ''}`, [output]);
+            return new torch.Argument(`output${index === 0 ? '' : (index + 1).toString()}`, [output]);
         }));
     }
 };

+ 18 - 18
source/uff-proto.js

@@ -12,7 +12,7 @@ uff.MetaGraph = class MetaGraph {
 
     static decode(reader, length) {
         const message = new uff.MetaGraph();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -82,7 +82,7 @@ uff.MetaGraph.ReferencedDataEntry = class ReferencedDataEntry {
 
     static decode(reader, length) {
         const message = new uff.MetaGraph.ReferencedDataEntry();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -128,7 +128,7 @@ uff.MetaGraph.ExtraFieldsEntry = class ExtraFieldsEntry {
 
     static decode(reader, length) {
         const message = new uff.MetaGraph.ExtraFieldsEntry();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -174,7 +174,7 @@ uff.Descriptor = class Descriptor {
 
     static decode(reader, length) {
         const message = new uff.Descriptor();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -232,7 +232,7 @@ uff.Graph = class Graph {
 
     static decode(reader, length) {
         const message = new uff.Graph();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -283,7 +283,7 @@ uff.Graph.ExtraFieldsEntry = class ExtraFieldsEntry {
 
     static decode(reader, length) {
         const message = new uff.Graph.ExtraFieldsEntry();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -335,7 +335,7 @@ uff.Node = class Node {
 
     static decode(reader, length) {
         const message = new uff.Node();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -399,7 +399,7 @@ uff.Node.FieldsEntry = class FieldsEntry {
 
     static decode(reader, length) {
         const message = new uff.Node.FieldsEntry();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -445,7 +445,7 @@ uff.Node.ExtraFieldsEntry = class ExtraFieldsEntry {
 
     static decode(reader, length) {
         const message = new uff.Node.ExtraFieldsEntry();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -496,7 +496,7 @@ uff.Data = class Data {
 
     static decode(reader, length) {
         const message = new uff.Data();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -632,7 +632,7 @@ uff.DimensionOrders = class DimensionOrders {
 
     static decode(reader, length) {
         const message = new uff.DimensionOrders();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -669,7 +669,7 @@ uff.DimensionOrders.OrdersEntry = class OrdersEntry {
 
     static decode(reader, length) {
         const message = new uff.DimensionOrders.OrdersEntry();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -719,7 +719,7 @@ uff.ListString = class ListString {
 
     static decode(reader, length) {
         const message = new uff.ListString();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -760,7 +760,7 @@ uff.ListDouble = class ListDouble {
 
     static decode(reader, length) {
         const message = new uff.ListDouble();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -801,7 +801,7 @@ uff.ListBool = class ListBool {
 
     static decode(reader, length) {
         const message = new uff.ListBool();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -842,7 +842,7 @@ uff.ListInt64 = class ListInt64 {
 
     static decode(reader, length) {
         const message = new uff.ListInt64();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -883,7 +883,7 @@ uff.ListDataType = class ListDataType {
 
     static decode(reader, length) {
         const message = new uff.ListDataType();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -924,7 +924,7 @@ uff.ListDimensionOrders = class ListDimensionOrders {
 
     static decode(reader, length) {
         const message = new uff.ListDimensionOrders();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 14 - 14
source/view.js

@@ -617,7 +617,7 @@ view.View = class {
         if (button === 0 && (url || this._host.type === 'Electron')) {
             this._host.openURL(url || `${this._host.environment('repository')}/issues`);
         }
-        this.show(screen !== undefined ? screen : 'welcome');
+        this.show(screen ? screen : 'welcome');
     }
 
     accept(file, size) {
@@ -907,7 +907,7 @@ view.View = class {
 
     export(file) {
         const lastIndex = file.lastIndexOf('.');
-        const extension = (lastIndex !== -1) ? file.substring(lastIndex + 1).toLowerCase() : 'png';
+        const extension = lastIndex === -1 ? 'png' : file.substring(lastIndex + 1).toLowerCase();
         if (this.activeGraph && (extension === 'png' || extension === 'svg')) {
             const canvas = this._element('canvas');
             const clone = canvas.cloneNode(true);
@@ -1674,14 +1674,14 @@ view.Graph = class extends grapher.Graph {
 
     createValue(argument) {
         const name = argument.name;
-        if (!this._values.has(name)) {
-            const value = new view.Value(this, argument);
-            this._values.set(name, value);
-            this._table.set(argument, value);
-        } else {
+        if (this._values.has(name)) {
             // duplicate argument name
             const value = this._values.get(name);
             this._table.set(argument, value);
+        } else {
+            const value = new view.Value(this, argument);
+            this._values.set(name, value);
+            this._table.set(argument, value);
         }
         return this._values.get(name);
     }
@@ -1765,13 +1765,13 @@ view.Graph = class extends grapher.Graph {
                 if (groupName && groupName.length > 0) {
                     if (!clusterParentMap.has(groupName)) {
                         const lastIndex = groupName.lastIndexOf('/');
-                        if (lastIndex !== -1) {
+                        if (lastIndex === -1) {
+                            groupName = null;
+                        } else {
                             groupName = groupName.substring(0, lastIndex);
                             if (!clusterParentMap.has(groupName)) {
                                 groupName = null;
                             }
-                        } else {
-                            groupName = null;
                         }
                     }
                     if (groupName) {
@@ -3399,7 +3399,7 @@ view.FindSidebar = class extends view.Control {
                 edge(value);
             }
         }
-        this._contentElement.style.display = this._contentElement.childNodes.length !== 0 ? 'block' : 'none';
+        this._contentElement.style.display = this._contentElement.childNodes.length === 0 ? 'none' : 'block';
     }
 
     render() {
@@ -4935,9 +4935,9 @@ markdown.Generator = class {
     _outputLink(match, href, title) {
         title = title ? this._escape(title) : null;
         const text = match[1].replace(/\\([[\]])/g, '$1');
-        return match[0].charAt(0) !== '!' ?
-            { type: 'link', href, title, text } :
-            { type: 'image', href, title, text: this._escape(text) };
+        return match[0].charAt(0) === '!' ?
+            { type: 'image', href, title, text: this._escape(text) } :
+            { type: 'link', href, title, text };
     }
 
     _splitCells(tableRow, count) {

+ 5 - 5
source/xml.js

@@ -210,15 +210,15 @@ xml.TextReader = class {
                             let element = null;
                             const documentType = document.documentType;
                             const elementType = documentType ? documentType.elements.getNamedItem(name) : null;
-                            if (namespaceURI !== null) {
+                            if (namespaceURI === null) {
+                                this._assert((pair[0] === null && !name.endsWith(':')) || name === ':' || elementType !== null);
+                                element = document.createElement(name);
+                            } else {
                                 this._assert(name === ':' || (!name.endsWith(':') && !name.startsWith(':')));
                                 if (prefix && namespaceURI === '') {
                                     this._error(`Invalid namespace prefix '${prefix}'`, this._start);
                                 }
                                 element = document.createElementNS(namespaceURI, name);
-                            } else {
-                                this._assert((pair[0] === null && !name.endsWith(':')) || name === ':' || elementType !== null);
-                                element = document.createElement(name);
                             }
                             const parent = this._node();
                             if (parent.nodeType === xml.NodeType.Document && parent.documentElement !== null) {
@@ -729,7 +729,7 @@ xml.TextReader = class {
     }
 
     _content() {
-        const c = this._char !== '&' ? this._char : this._resolveEntityReference();
+        const c = this._char === '&' ? this._resolveEntityReference() : this._char;
         if (c === undefined) {
             return '';
         }

+ 31 - 31
source/xmodel-proto.js

@@ -11,7 +11,7 @@ serial_v2.Graph = class Graph {
 
     static decode(reader, length) {
         const message = new serial_v2.Graph();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -80,7 +80,7 @@ serial_v2.OPNode = class OPNode {
 
     static decode(reader, length) {
         const message = new serial_v2.OPNode();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -149,7 +149,7 @@ serial_v2.OpArg = class OpArg {
 
     static decode(reader, length) {
         const message = new serial_v2.OpArg();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -199,7 +199,7 @@ serial_v2.Tensor = class Tensor {
 
     static decode(reader, length) {
         const message = new serial_v2.Tensor();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -270,7 +270,7 @@ serial_v2.SubGraph = class SubGraph {
 
     static decode(reader, length) {
         const message = new serial_v2.SubGraph();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -332,7 +332,7 @@ serial_v2.OpDef = class OpDef {
 
     static decode(reader, length) {
         const message = new serial_v2.OpDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -390,7 +390,7 @@ serial_v2.AttrDef = class AttrDef {
 
     static decode(reader, length) {
         const message = new serial_v2.AttrDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -462,7 +462,7 @@ serial_v2.OpArgDef = class OpArgDef {
 
     static decode(reader, length) {
         const message = new serial_v2.OpArgDef();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -534,7 +534,7 @@ serial_v2.AttrValue = class AttrValue {
 
     static decode(reader, length) {
         const message = new serial_v2.AttrValue();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -739,7 +739,7 @@ serial_v2.Bytes = class Bytes {
 
     static decode(reader, length) {
         const message = new serial_v2.Bytes();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -782,7 +782,7 @@ serial_v2.BoolVec = class BoolVec {
 
     static decode(reader, length) {
         const message = new serial_v2.BoolVec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -823,7 +823,7 @@ serial_v2.Int32Vec = class Int32Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.Int32Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -864,7 +864,7 @@ serial_v2.Uint32Vec = class Uint32Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.Uint32Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -905,7 +905,7 @@ serial_v2.Int64Vec = class Int64Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.Int64Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -946,7 +946,7 @@ serial_v2.Uint64Vec = class Uint64Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.Uint64Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -987,7 +987,7 @@ serial_v2.FloatVec = class FloatVec {
 
     static decode(reader, length) {
         const message = new serial_v2.FloatVec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1028,7 +1028,7 @@ serial_v2.DoubleVec = class DoubleVec {
 
     static decode(reader, length) {
         const message = new serial_v2.DoubleVec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1069,7 +1069,7 @@ serial_v2.StringVec = class StringVec {
 
     static decode(reader, length) {
         const message = new serial_v2.StringVec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1110,7 +1110,7 @@ serial_v2.BytesVec = class BytesVec {
 
     static decode(reader, length) {
         const message = new serial_v2.BytesVec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1151,7 +1151,7 @@ serial_v2.MapString2Int32 = class MapString2Int32 {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Int32();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1192,7 +1192,7 @@ serial_v2.MapString2Uint32 = class MapString2Uint32 {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Uint32();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1233,7 +1233,7 @@ serial_v2.MapString2Int64 = class MapString2Int64 {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Int64();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1274,7 +1274,7 @@ serial_v2.MapString2Uint64 = class MapString2Uint64 {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Uint64();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1315,7 +1315,7 @@ serial_v2.MapString2Bytes = class MapString2Bytes {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Bytes();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1356,7 +1356,7 @@ serial_v2.MapString2String = class MapString2String {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2String();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1397,7 +1397,7 @@ serial_v2.MapString2Int32Vec = class MapString2Int32Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Int32Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1438,7 +1438,7 @@ serial_v2.MapString2Uint32Vec = class MapString2Uint32Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Uint32Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1479,7 +1479,7 @@ serial_v2.MapString2Int64Vec = class MapString2Int64Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Int64Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1520,7 +1520,7 @@ serial_v2.MapString2Uint64Vec = class MapString2Uint64Vec {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2Uint64Vec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1561,7 +1561,7 @@ serial_v2.MapString2BytesVec = class MapString2BytesVec {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2BytesVec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {
@@ -1602,7 +1602,7 @@ serial_v2.MapString2StringVec = class MapString2StringVec {
 
     static decode(reader, length) {
         const message = new serial_v2.MapString2StringVec();
-        const end = length !== undefined ? reader.position + length : reader.length;
+        const end = length === undefined ? reader.length : reader.position + length;
         while (reader.position < end) {
             const tag = reader.uint32();
             switch (tag >>> 3) {

+ 7 - 7
source/zip.js

@@ -369,7 +369,7 @@ zip.Inflater = class {
         const lengthMask = lengthTree.length - 1;
         const distanceMask = distanceTree.length - 1;
         const buffer = writer.buffer;
-        const threshold = writer.threshold !== undefined ? writer.threshold : writer.length;
+        const threshold = writer.threshold === undefined ? writer.length : writer.threshold;
         let position = writer.position;
         for (;;) {
             if (position > threshold) {
@@ -624,7 +624,7 @@ zip.InflaterStream = class {
 
     peek(length) {
         const position = this._position;
-        length = length !== undefined ? length : this.length - position;
+        length = length === undefined ? this.length - position : length;
         this.skip(length);
         const end = this._position;
         this.seek(position);
@@ -636,7 +636,7 @@ zip.InflaterStream = class {
 
     read(length) {
         const position = this._position;
-        length = length !== undefined ? length : this.length - position;
+        length = length === undefined ? this.length - position : length;
         this.skip(length);
         if (position === 0 && length === this.length) {
             return this._buffer;
@@ -741,7 +741,7 @@ zip.BinaryReader = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         const end = this._position;
         this.seek(position);
         return this._buffer.subarray(position, end);
@@ -753,7 +753,7 @@ zip.BinaryReader = class {
             return this._buffer;
         }
         const position = this._position;
-        this.skip(length !== undefined ? length : this._length - this._position);
+        this.skip(length === undefined ? this._length - this._position : length);
         return this._buffer.subarray(position, this._position);
     }
 
@@ -895,7 +895,7 @@ gzip.InflaterStream = class {
 
     peek(length) {
         const position = this._position;
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         this.skip(length);
         const end = this._position;
         this.seek(position);
@@ -907,7 +907,7 @@ gzip.InflaterStream = class {
 
     read(length) {
         const position = this._position;
-        length = length !== undefined ? length : this._length - this._position;
+        length = length === undefined ? this._length - this._position : length;
         this.skip(length);
         if (position === 0 && length === this._length) {
             return this._buffer;

+ 1 - 1
test/models.js

@@ -70,7 +70,7 @@ class Logger {
                 case 'download':
                     if (message.percent !== undefined) {
                         value = `${(`  ${Math.floor(100 * message.percent)}`).slice(-3)}% `;
-                    } else if (message.position !== undefined) {
+                    } else if (Number.isInteger(message.position)) {
                         value = ` ${message.position}${this._threads === 1 ? ' bytes' : ''} `;
                     } else {
                         value = '  \u2714  ';

+ 11 - 11
test/worker.js

@@ -427,12 +427,12 @@ export class Target {
             sources = sources && sources.startsWith(',') ? sources.substring(1).trim() : '';
         } else {
             const commaIndex = sources.indexOf(',');
-            if (commaIndex !== -1) {
-                source = sources.substring(0, commaIndex);
-                sources = sources.substring(commaIndex + 1);
-            } else {
+            if (commaIndex === -1) {
                 source = sources;
                 sources = '';
+            } else {
+                source = sources.substring(0, commaIndex);
+                sources = sources.substring(commaIndex + 1);
             }
         }
         await Promise.all(targets.map((target) => {
@@ -447,7 +447,13 @@ export class Target {
             const archive = decompress(data);
             for (const name of sourceFiles) {
                 this.status({ name: 'write', target: name });
-                if (name !== '.') {
+                if (name === '.') {
+                    const target = targets.shift();
+                    const dir = path.join(this.folder, target);
+                    /* eslint-disable no-await-in-loop */
+                    await fs.mkdir(dir, { recursive: true });
+                    /* eslint-enable no-await-in-loop */
+                } else {
                     const stream = archive.entries.get(name);
                     if (!stream) {
                         throw new Error(`Entry not found '${name}. Archive contains entries: ${JSON.stringify(Array.from(archive.entries.keys()))} .`);
@@ -458,12 +464,6 @@ export class Target {
                     /* eslint-disable no-await-in-loop */
                     await fs.writeFile(file, buffer, null);
                     /* eslint-enable no-await-in-loop */
-                } else {
-                    const target = targets.shift();
-                    const dir = path.join(this.folder, target);
-                    /* eslint-disable no-await-in-loop */
-                    await fs.mkdir(dir, { recursive: true });
-                    /* eslint-enable no-await-in-loop */
                 }
             }
         } else {

+ 9 - 9
tools/flatc.js

@@ -208,16 +208,16 @@ flatc.Struct = class extends flatc.Type {
                         throw new flatc.Error(`Struct '${name}' may contain only scalar or struct fields.`);
                     }
                     const size = fieldType.size;
-                    field.offset = (offset % size) !== 0 ? (Math.floor(offset / size) + 1) * size : offset;
+                    field.offset = (offset % size) === 0 ? offset : (Math.floor(offset / size) + 1) * size;
                     offset = field.offset + (field.length * size);
                 } else if (fieldType instanceof flatc.PrimitiveType && field.type !== 'string') {
                     const size = fieldType.size;
-                    field.offset = (offset % size) !== 0 ? (Math.floor(offset / size) + 1) * size : offset;
+                    field.offset = (offset % size) === 0 ? offset : (Math.floor(offset / size) + 1) * size;
                     offset = field.offset + size;
                 } else if (field.type instanceof flatc.Struct) {
                     field.type.resolve();
                     const align = 8;
-                    field.offset = (offset % align) !== 0 ? (Math.floor(offset / align) + 1) * align : offset;
+                    field.offset = (offset % align) === 0 ? offset : (Math.floor(offset / align) + 1) * align;
                     offset += field.type.size;
                 } else {
                     throw new flatc.Error('Structs may contain only scalar or struct fields.');
@@ -971,7 +971,7 @@ flatc.Generator = class {
             }
 
             this._builder.add('');
-            this._builder.add(type.fields.size !== 0 ? 'static decode(reader, position) {' : 'static decode(/* reader, position */) {');
+            this._builder.add(type.fields.size === 0 ? 'static decode(/* reader, position */) {' : 'static decode(reader, position) {');
             this._builder.indent();
                 this._builder.add(`const $ = new ${typeReference}();`);
                 for (const field of type.fields.values()) {
@@ -1031,7 +1031,7 @@ flatc.Generator = class {
 
             if (this._text) {
                 this._builder.add('');
-                this._builder.add(type.fields.size !== 0 ? 'static decodeText(reader, json) {' : 'static decodeText(/* reader, json */) {');
+                this._builder.add(type.fields.size === 0 ? 'static decodeText(/* reader, json */) {' : 'static decodeText(reader, json) {');
                 this._builder.indent();
                     this._builder.add(`const $ = new ${typeReference}();`);
                     for (const field of type.fields.values()) {
@@ -1107,7 +1107,7 @@ flatc.Generator = class {
         this._builder.indent();
 
             this._builder.add('');
-            this._builder.add(type.fields.size !== 0 ? 'static decode(reader, position) {' : 'static decode(/* reader, position */) {');
+            this._builder.add(type.fields.size === 0 ? 'static decode(/* reader, position */) {' : 'static decode(reader, position) {');
             this._builder.indent();
                 this._builder.add(`const $ = new ${typeReference}();`);
                 for (const field of type.fields.values()) {
@@ -1133,7 +1133,7 @@ flatc.Generator = class {
 
             if (this._text) {
                 this._builder.add('');
-                this._builder.add(type.fields.size !== 0 ? 'static decodeText(reader, json) {' : 'static decodeText(/* reader, json */) {');
+                this._builder.add(type.fields.size === 0 ? 'static decodeText(/* reader, json */) {' : 'static decodeText(reader, json) {');
                 this._builder.indent();
                     this._builder.add(`const $ = new ${typeReference}();`);
                     for (const field of type.fields.values()) {
@@ -1168,7 +1168,7 @@ flatc.Generator = class {
 
         this._builder.indent();
             this._builder.add('');
-            this._builder.add(type.values.size !== 0 ? 'static decode(reader, position, type) {' : 'static decode(/* reader, position, type */) {');
+            this._builder.add(type.values.size === 0 ? 'static decode(/* reader, position, type */) {' : 'static decode(reader, position, type) {');
             this._builder.indent();
                 this._builder.add('switch (type) {');
                 this._builder.indent();
@@ -1184,7 +1184,7 @@ flatc.Generator = class {
 
             if (this._text) {
                 this._builder.add('');
-                this._builder.add(type.values.size !== 0 ? 'static decodeText(reader, json, type) {' : 'static decodeText(/* reader, json, type */) {');
+                this._builder.add(type.values.size === 0 ? 'static decodeText(/* reader, json, type */) {' : 'static decodeText(reader, json, type) {');
                 this._builder.indent();
                     this._builder.add('switch (type) {');
                     this._builder.indent();

+ 8 - 8
tools/protoc.js

@@ -174,7 +174,10 @@ protoc.Root = class extends protoc.Namespace {
     async _loadFile(paths, file, weak) {
         if (!this._files.has(file)) {
             this._files.add(file);
-            if (!this._library.has(file)) {
+            if (this._library.has(file)) {
+                const callback = this._library.get(file);
+                callback();
+            } else {
                 try {
                     await this._parseFile(paths, file);
                 } catch (err) {
@@ -182,9 +185,6 @@ protoc.Root = class extends protoc.Namespace {
                         throw err;
                     }
                 }
-            } else {
-                const callback = this._library.get(file);
-                callback();
             }
         }
     }
@@ -274,7 +274,7 @@ protoc.Enum = class extends protoc.Type {
 
     constructor(parent, name) {
         super(parent, name);
-        this.valuesById = {};
+        this.valuesById = new Map();
         this.values = {};
         this.reserved = [];
     }
@@ -292,12 +292,12 @@ protoc.Enum = class extends protoc.Type {
         if (protoc.Namespace.isReservedName(this.reserved, name)) {
             throw new protoc.Error(`Name '${name}' is reserved in '${this.name}'.`);
         }
-        if (this.valuesById[id] !== undefined) {
+        if (this.valuesById.has(id)) {
             if (!this.options.has('allow_alias')) {
                 throw new protoc.Error(`Duplicate identifier '${id}' in '${this.name}'.`);
             }
         } else {
-            this.valuesById[id] = name;
+            this.valuesById.set(id, name);
         }
         this.values[name] = id;
     }
@@ -1270,7 +1270,7 @@ protoc.Generator = class {
         this._builder.add('static decode(reader, length) {');
         this._builder.indent();
             this._builder.add(`const message = new ${type.fullName}();`);
-            this._builder.add('const end = length !== undefined ? reader.position + length : reader.length;');
+            this._builder.add('const end = length === undefined ? reader.length : reader.position + length;');
             this._builder.add("while (reader.position < end) {");
             this._builder.indent();
                 this._builder.add("const tag = reader.uint32();");

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff