npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vorld/mrz

v3.5.3

Published

Parse MRZ (Machine Readable Zone) from identity documents

Downloads

4

Readme

mrz

NPM version build status Test coverage David deps npm download

Parse MRZ (Machine Readable Zone) from identity documents.

Installation

$ npm install --save mrz

Example

const parse = require('mrz').parse;

let mrz = [
  'I<UTOD23145890<1233<<<<<<<<<<<',
  '7408122F1204159UTO<<<<<<<<<<<6',
  'ERIKSSON<<ANNA<MARIA<<<<<<<<<<'
];

var result = parse(mrz);
console.log(result);

API

parse(mrz)

Parses the provided MRZ. The argument can be an array of lines or a single string including line breaks. This function throws an error if the input is in an unsupported format. It will never throw an error when there are invalid fields in the MRZ. Instead, the result.valid value will be false and details about the invalid fields can be found in result.details.

result.format

String identifying the format of the parsed MRZ. Supported formats are:

  • TD1 (identity card with three MRZ lines)
  • TD2 (identity card with two MRZ lines)
  • TD3 (passport)
  • SWISS_DRIVING_LICENSE
  • FRENCH_NATIONAL_ID
  • FRENCH_DRIVING_LICENSE
  • ESTONIAN_DRIVING_LICENSE
  • IRELAND_DRIVING_LICENSE

result.valid

true if all fields are valid. false otherwise.

result.fields

Object mapping field names to their respective value. The value is set to null if it is invalid. The value may be different than the raw value. For example result.fields.sex will be "male" when the raw value was "M".

result.details

Array of objects describing all parsed fields. Its structure is:

  • label {string} - Full english term for the field.
  • field {string} - Name of the field in result.fields.
  • value {string} - Value of the field or null.
  • valid {boolean}
  • ranges {Array} - Array of ranges that are necessary to compute this field. Ranges are objects with line, start, end and raw.
  • line {number} - Index of the line where the field is located.
  • start {number} - Index of the start of the field in line.
  • end {number} - Index of the end of the field in line.

formats

Static mapping of supported formats.

states

Static mapping of state code to state name.

Specifications

TD1, TD2 and TD3

https://www.icao.int/publications/pages/publication.aspx?docnum=9303

Swiss driving license

http://www.astra2.admin.ch/media/pdfpub/2003-10-15_2262_f.pdf

French national id

https://fr.wikipedia.org/wiki/Carte_nationale_d%27identit%C3%A9_en_France#Codage_Bande_MRZ_(lecture_optique)

License

MIT