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