NMSCD - Coordinate Converter

How to use the library in your projects!

Install via npm 🔗

npm i @nmscd/coordinate-conversion

Using the library

import { PortalCode } from '@nmscd/coordinate-conversion';

const galacticConversionResult = PortalCode({ code: '023456123456' }).toGalacticCoordinates();
console.log(galacticConversionResult.isSuccess) // true
console.log(galacticConversionResult.value) // { "code": "0C55:00D5:0922:0234", "groups": ["0C55", "00D5", "0922", "0234"] }

Import from CDN

<script type="text/javascript" src="https://nmscd.com/Coordinate-Conversion/bundle.js"></script>

Using the library

const galacticConversionResult = nmscdCoordinateConversion.PortalCode({ code: '023456123456' }).toGalacticCoordinates();
console.log(galacticConversionResult) // { isSuccess: true, value: '0C55:00D5:0922:0234', errorMessage: '' }

Using the converters

Once the library has been imported using one of the methods described above, you will be able to use the functions the library provides.

const galacticConversionResult = PortalCode({ code: '023456123456' }).toGalacticCoordinates();
if (galacticConversionResult.isSuccess === true) {
    console.log(galacticConversionResult.value.code); // 0C55:00D5:0922:0234
}
else {
    console.warn(galacticConversionResult.errorMessage); // e.g. "Invalid portal code provided"
}

Example conversions

Valid characters are 0123456789ABCDEF.
0C55:00D5:0922:0234
{}

Valid characters are 0123456789ABCDEF with semicolons.
023456123456
{}

This input takes in an object representing a voxel coordinate.
023456123456
0C55:00D5:0922:0234