Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use printer.getStatus #72

Open
romaia opened this issue Mar 31, 2023 · 2 comments
Open

Can't use printer.getStatus #72

romaia opened this issue Mar 31, 2023 · 2 comments

Comments

@romaia
Copy link

romaia commented Mar 31, 2023

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.

@YovanggaAnandhika
Copy link
Contributor

can u show your code example ?

@zaycker
Copy link

zaycker commented Jul 7, 2024

/**
   * 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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants