cambricon.js 809 B

1234567891011121314151617181920212223242526272829303132
  1. const cambricon = {};
  2. cambricon.ModelFactory = class {
  3. match(context) {
  4. const stream = context.stream;
  5. if (stream) {
  6. const buffer = stream.peek(Math.min(20, stream.length));
  7. const text = Array.from(buffer).map((c) => String.fromCharCode(c)).join('');
  8. if (text.startsWith('\x7fMEF') || text.startsWith('cambricon_offline')) {
  9. return 'cambricon';
  10. }
  11. }
  12. return '';
  13. }
  14. async open(/* context, match */) {
  15. throw new cambricon.Error("File contains undocumented Cambricon data.");
  16. }
  17. };
  18. cambricon.Error = class extends Error {
  19. constructor(message) {
  20. super(message);
  21. this.name = 'Error loading Cambricon model.';
  22. }
  23. };
  24. export const ModelFactory = cambricon.ModelFactory;