6.0.2 • Published 4 months ago

bcbp v6.0.2

Weekly downloads
153
License
MIT
Repository
github
Last release
4 months ago

Build License Bundlephobia Version

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:

$ npm install bcbp

Encode

encode(bcbp: BarcodedBoardingPass) => string

Example

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

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

Example

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.

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 for the definition.

License

MIT

6.0.2

4 months ago

6.0.1

1 year ago

5.1.4

2 years ago

6.0.0

2 years ago

5.1.3

2 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago