Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/magiclen/node-qr-code

Encode QR Code by using N-API.
https://github.com/magiclen/node-qr-code

nodejs qrcode rust

Last synced: 28 days ago
JSON representation

Encode QR Code by using N-API.

Awesome Lists containing this project

README

        

magic-qr-code
=================================

[![CI](https://github.com/magiclen/node-qr-code/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/node-qr-code/actions/workflows/ci.yml)

Encode QR Code by using N-API. The QR code generating library is [QR Code generator library](https://www.nayuki.io/page/qr-code-generator-library "QR Code generator library")

You need to set up the Rust development environment: [rustup](https://rustup.rs/)

## Usage

### Encode QR Code

You can use the `encodeString` function to encode a string or use the `encodeBuffer` function to encode a buffer into QR Code data which is an array of buffers (`Buffer[]`).

```typescript
import { encodeString } from "magic-qr-code";

const result = encodeString("https://magiclen.org".toUpperCase());
/*
[
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,

]
*/
```

Encoding QR code, you can also set the error correction level by passing a `ErrorCorrection` number to the second argument.

```typescript
import { encodeString, ErrorCorrection } from "magic-qr-code";

const result = encodeString("https://magiclen.org".toUpperCase(), ErrorCorrection.High);
```

## License

[MIT](LICENSE)