node-escpos/driver

Can't use printer.getStatus

romaia opened this issue · 2 comments

As of version 0.4.0 of @node-escpos/core, I can´t find a way to actually use printer.getStatus due to the fact that the status classes are not exported.

can u show your code example ?

/**
   * get one specific status from the printer using it's class
   * @param  {string} StatusClass
   * @return {Promise} promise returning given status
   */
  getStatus<T extends DeviceStatus>(StatusClass: StatusClassConstructor<T>): Promise<T> {
    return new Promise((resolve) => {
      this.adapter.read((data) => {
        const byte = data.readInt8(0);
        resolve(new StatusClass(byte));
      });

      StatusClass.commands().forEach((c) => {
        this.buffer.write(c);
      });
    });
  }

The JSDOC declares that StatusClass should be a string but in the later code it uses the parameter as a constructor new StatusClass(byte). it's not PHP :) At the same time the module doesn't export status classes to be able to pass it as a parameter. As a result there is no way to use getStatus()