Lutz Roeder 3 lat temu
rodzic
commit
a4bdaaa1c7
1 zmienionych plików z 6 dodań i 5 usunięć
  1. 6 5
      source/mnn.js

+ 6 - 5
source/mnn.js

@@ -5,10 +5,11 @@ var flatbuffers = require('./flatbuffers');
 mnn.ModelFactory = class {
 
     match(context) {
-        const stream = context.stream;
-        if (stream && stream.length >= 4) {
-            const extension = context.identifier.split('.').pop().toLowerCase();
-            if (extension == 'mnn') {
+        const identifier = context.identifier;
+        const extension = identifier.split('.').pop().toLowerCase();
+        if (extension == 'mnn') {
+            const stream = context.stream;
+            if (stream && stream.length >= 4) {
                 const buffer = stream.peek(4);
                 const reader = flatbuffers.BinaryReader.open(buffer);
                 if (reader.root === 0x00000018 || reader.root === 0x0000001C || reader.root === 0x00000020) {
@@ -16,7 +17,7 @@ mnn.ModelFactory = class {
                 }
             }
         }
-        return undefined;
+        return null;
     }
 
     open(context) {