# @ng-all/hid-scanner

> a service to get the string from a HID scanner device like `Honeywell HH450`

Latest version **0.3.0** (published 2024-07-10) · 0 weekly downloads

## Install

```sh
npm install @ng-all/hid-scanner
pnpm add @ng-all/hid-scanner
yarn add @ng-all/hid-scanner
bun add @ng-all/hid-scanner
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2024-07-10 |
| First published | 2021-08-18 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | emeryao |

## Links

- npm: https://www.npmjs.com/package/@ng-all/hid-scanner
- Repository: https://github.com/ng-all/hid-scanner
- Homepage: https://github.com/ng-all/hid-scanner#readme
- Issues: https://github.com/ng-all/hid-scanner/issues
- npm.io page: https://npm.io/package/@ng-all/hid-scanner

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.6.3

## Recent versions

- 0.3.0 (latest) — 2024-07-10
- 0.2.0 — 2024-04-09
- 0.1.6 — 2024-04-09
- 0.1.5 — 2023-10-19
- 0.1.3 — 2022-11-17
- 0.1.2 — 2022-02-03
- 0.1.1 — 2021-08-18
- 0.1.0 — 2021-08-18

## README

# HID Scanner 🐝
a service to get the string from a HID scanner device like `Honeywell HH450`

## Installation

```sh
$ npm install @ng-all/hid-scanner
```

## Usage

```typescript
@Component({
    selector: 'app-main',
    templateUrl: './main.component.html',
    styleUrls: ['./main.component.scss'],
})
export class MainComponent implements OnDestroy {

    private scannerSubscription?: Subscription;

    public constructor(
        // should be provided somewhere
        private scanner: HoneyScannerService,
    ) {

        // adjust the threshold of milliseconds for different sanner devices default is 99
        let threshold:number = 99;

        this.scannerSubscription = this.scanner.onScan(threshold).subscribe({
            next: e => {
                // scan result here
                console.log(e);
            },
        });
    }

    // for plain Angular project
    public ngOnDestroy(): void {
        if (this.scannerSubscription) {
            this.scanner.dispose();
            this.scannerSubscription.unsubscribe();
        }
    }

    // for Ionic project
    public ionViewWillLeave(): void {
        if (this.scannerSubscription) {
            this.scanner.dispose();
            this.scannerSubscription.unsubscribe();
        }
    }

}
```

## Tips
* the service will not working if a component is navigated by a `a[routerLink]` since the ***enter*** key from the scanner is missing after a `a[routerLink]` navigation so try to use a `div[routerLink]` instead
* it is recommended to provide the service in a component instead of a module
* do not forget to `unsubscribe` and `dispose`

---
_Source: https://npm.io/package/@ng-all/hid-scanner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
