0.2.1 • Published 4 years ago

mmsi.js v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Build Status Code coverage Open issues NPM package License

mmsi.js

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.

About

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.

Installation

npm install mmsi.js

Usage

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)"

License

This project is licensed under the MIT License - see the LICENSE file for details.