A javascript library for parsing MMSI numbers (Maritime Mobile Service Identities) to validate format and extract information such as country or other jurisdiction of registration.
From Wikipedia:
A Maritime Mobile Service Identity (MMSI) is a series of nine digits which are sent in digital form over a radio frequency channel in order to uniquely identify ship stations, ship earth stations, coast stations, coast earth stations, and group calls.
With mmsi.js you can determine whether a given number or string is in the format of a valid MMSI and, if so, extract the Maritime Identification Digits from it, along with the corresponding country name and code.
Note that this library makes no attempt to verify that a given MMSI is actually in active use, or registered to a real vessel.
npm install mmsi.js
import { MMSI } from 'mmsi.js';
const mmsi = new MMSI(1234567890);
console.log(mmsi.isValid); // false -- too many digits
mmsi.identity = "ABCDEFGHI";
console.log(mmsi.isValid); // false -- not exclusively digits
mmsi.identity = 123;
console.log(mmsi.isValid); // true
console.log(mmsi.formatted); // "000000123"
mmsi.identity = "410123456";
console.log(mmsi.midCode); // "410"
const jurisdiction = mmsi.jurisdiction;
console.log(jurisdiction.code); // "BT"
console.log(jurisdiction.name); // "Bhutan"
console.log(jurisdiction.fullName); // "Bhutan (Kingdom of)"
This project is licensed under the MIT License - see the LICENSE file for details.