# bcbp

> Encoding/decoding library for the IATA Bar Coded Boarding Pass

Latest version **6.0.2** (published 2024-01-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install bcbp
pnpm add bcbp
yarn add bcbp
bun add bcbp
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 6.0.2 |
| Published | 2024-01-04 |
| First published | 2018-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 64 |
| Author | George Smith |
| Maintainers | georgesmith46 |
| Keywords | iata, boarding pass, barcode, encode, decode |

## Links

- npm: https://www.npmjs.com/package/bcbp
- Repository: https://github.com/georgesmith46/bcbp
- Homepage: https://github.com/georgesmith46/bcbp#readme
- Issues: https://github.com/georgesmith46/bcbp/issues
- npm.io page: https://npm.io/package/bcbp

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 6.0.2 (latest) — 2024-01-04
- 6.0.1 — 2023-05-01
- 6.0.0 — 2022-10-27
- 5.1.4 — 2022-10-20
- 5.1.3 — 2022-08-08
- 5.1.2 — 2021-08-27
- 5.1.1 — 2021-07-07
- 5.1.0 — 2021-06-13
- 5.0.1 — 2021-06-13
- 5.0.0 — 2021-06-13
- 4.1.1 — 2021-03-11
- 4.1.0 — 2021-02-08
- 4.0.2 — 2021-01-09
- 4.0.1 — 2021-01-08
- 4.0.0 — 2021-01-08
- … 18 more at https://npm.io/package/bcbp/versions

## README

![Build](https://img.shields.io/github/workflow/status/georgesmith46/bcbp/Release?style=for-the-badge)
![License](https://img.shields.io/github/license/georgesmith46/bcbp?style=for-the-badge)
![Bundlephobia](https://img.shields.io/bundlephobia/minzip/bcbp?style=for-the-badge)
![Version](https://img.shields.io/npm/v/bcbp?style=for-the-badge)

# BCBP

Encoding/decoding library for the IATA Bar Coded Boarding Pass

- Supports version 6 of the BCBP standard
- Supports any number of legs

## Getting started

### Installation

Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):

```bash
$ npm install bcbp
```

## Encode

```ts
encode(bcbp: BarcodedBoardingPass) => string
```

### Example

```js
import { encode } from "bcbp";

let output = encode({
  data: {
    legs: [
      {
        operatingCarrierPNR: "ABC123",
        departureAirport: "YUL",
        arrivalAirport: "FRA",
        operatingCarrierDesignator: "AC",
        flightNumber: "0834",
        flightDate: new Date("2020-08-13T00:00:00.000Z"),
        compartmentCode: "F",
        seatNumber: "001A",
        checkInSequenceNumber: "0025",
        passengerStatus: "1",
      },
    ],
    passengerName: "DESMARAIS/LUC",
  },
});

console.log(output);
// M1DESMARAIS/LUC       EABC123 YULFRAAC 0834 226F001A0025 106>60000
```

## Decode

```ts
decode(bcbp: string, referenceYear?: number) => BarcodedBoardingPass
```

### Example

```js
import { decode } from "bcbp";

let output = decode(
  "M1DESMARAIS/LUC       EABC123 YULFRAAC 0834 226F001A0025 100"
);

console.log(output.data.passengerName);
// DESMARAIS/LUC
```

### Reference Year

Define the year which is used when parsing date fields. If this is undefined, the current year is used.

```js
import { decode } from "bcbp";

let output = decode(
  "M1DESMARAIS/LUC       EABC123 YULFRAAC 0834 226F001A0025 100",
  2010
);

console.log(output.data.legs[0].flightDate.toISOString());
// "2010-08-14T00:00:00.000Z"
```

# BarcodedBoardingPass

See [types.ts](src/types.ts) for the definition.

## License

MIT

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